aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/core.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2017-01-22 11:14:08 -0500
committerThierry Reding <thierry.reding@gmail.com>2017-01-30 03:36:42 -0500
commitb526a314263ea217b8fa9758dca5dc245fd49997 (patch)
tree33bc36f29bee3acf277fded5b5d30513d16bfd53 /drivers/pwm/core.c
parent69efb3439ccf2ce72e01edde05d2c63d624e251e (diff)
pwm: Try to load modules during pwm_get()
Add a module name string to the pwm_lookup struct and if specified try to load the module using request_module() if pwmchip_find_by_name() is unable to find the PWM chip. This is a last resort to work around drivers that can't - and can't be made to - deal with deferred probe. Signed-off-by: Hans de Goede <hdegoede@redhat.com> [thierry.reding@gmail.com: rename new macro, reword commit message] [thierry.reding@gmail.com: add comment explaining use-case] Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/core.c')
-rw-r--r--drivers/pwm/core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 799c4fb4cc2f..a0860b30bd93 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -765,6 +765,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
765 unsigned int best = 0; 765 unsigned int best = 0;
766 struct pwm_lookup *p, *chosen = NULL; 766 struct pwm_lookup *p, *chosen = NULL;
767 unsigned int match; 767 unsigned int match;
768 int err;
768 769
769 /* look up via DT first */ 770 /* look up via DT first */
770 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) 771 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
@@ -825,6 +826,19 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
825 return ERR_PTR(-ENODEV); 826 return ERR_PTR(-ENODEV);
826 827
827 chip = pwmchip_find_by_name(chosen->provider); 828 chip = pwmchip_find_by_name(chosen->provider);
829
830 /*
831 * If the lookup entry specifies a module, load the module and retry
832 * the PWM chip lookup. This can be used to work around driver load
833 * ordering issues if driver's can't be made to properly support the
834 * deferred probe mechanism.
835 */
836 if (!chip && chosen->module) {
837 err = request_module(chosen->module);
838 if (err == 0)
839 chip = pwmchip_find_by_name(chosen->provider);
840 }
841
828 if (!chip) 842 if (!chip)
829 return ERR_PTR(-EPROBE_DEFER); 843 return ERR_PTR(-EPROBE_DEFER);
830 844