[PATCH v2 2/3] pwm/core: Try to get the module from pwm_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a module_name string to the pwm_lookup struct and if specified
and pwmchip_find_by_name() does not find the pwmchip try calling
request_module with the specified name.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/pwm/core.c  |  4 ++++
 include/linux/pwm.h | 11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 0d3ef29..c418a7a 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -823,6 +823,10 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
 		return ERR_PTR(-ENODEV);
 
 	chip = pwmchip_find_by_name(chosen->provider);
+	if (!chip && chosen->module_name) {
+		request_module(chosen->module_name);
+		chip = pwmchip_find_by_name(chosen->provider);
+	}
 	if (!chip)
 		return ERR_PTR(-EPROBE_DEFER);
 
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 2c6c511..40ab8b6 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -613,18 +613,25 @@ struct pwm_lookup {
 	const char *con_id;
 	unsigned int period;
 	enum pwm_polarity polarity;
+	const char *module_name; /* Optional may be NULL */
 };
 
-#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
+#define PWM_LOOKUP_MODNAME(_provider, _index, _dev_id, _con_id, _period, \
+			   _polarity, _module_name) \
 	{						\
 		.provider = _provider,			\
 		.index = _index,			\
 		.dev_id = _dev_id,			\
 		.con_id = _con_id,			\
 		.period = _period,			\
-		.polarity = _polarity			\
+		.polarity = _polarity,			\
+		.module_name = _module_name		\
 	}
 
+#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
+	PWM_LOOKUP_MODNAME(_provider, _index, _dev_id, _con_id, _period, \
+			   _polarity, NULL)
+
 #if IS_ENABLED(CONFIG_PWM)
 void pwm_add_table(struct pwm_lookup *table, size_t num);
 void pwm_remove_table(struct pwm_lookup *table, size_t num);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux