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>
This commit is contained in:
parent
69efb3439c
commit
b526a31426
|
@ -765,6 +765,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
|
||||||
unsigned int best = 0;
|
unsigned int best = 0;
|
||||||
struct pwm_lookup *p, *chosen = NULL;
|
struct pwm_lookup *p, *chosen = NULL;
|
||||||
unsigned int match;
|
unsigned int match;
|
||||||
|
int err;
|
||||||
|
|
||||||
/* look up via DT first */
|
/* look up via DT first */
|
||||||
if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
|
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)
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
chip = pwmchip_find_by_name(chosen->provider);
|
chip = pwmchip_find_by_name(chosen->provider);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the lookup entry specifies a module, load the module and retry
|
||||||
|
* the PWM chip lookup. This can be used to work around driver load
|
||||||
|
* ordering issues if driver's can't be made to properly support the
|
||||||
|
* deferred probe mechanism.
|
||||||
|
*/
|
||||||
|
if (!chip && chosen->module) {
|
||||||
|
err = request_module(chosen->module);
|
||||||
|
if (err == 0)
|
||||||
|
chip = pwmchip_find_by_name(chosen->provider);
|
||||||
|
}
|
||||||
|
|
||||||
if (!chip)
|
if (!chip)
|
||||||
return ERR_PTR(-EPROBE_DEFER);
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
|
|
||||||
|
|
|
@ -603,18 +603,25 @@ struct pwm_lookup {
|
||||||
const char *con_id;
|
const char *con_id;
|
||||||
unsigned int period;
|
unsigned int period;
|
||||||
enum pwm_polarity polarity;
|
enum pwm_polarity polarity;
|
||||||
|
const char *module; /* optional, may be NULL */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
|
#define PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id, \
|
||||||
{ \
|
_period, _polarity, _module) \
|
||||||
.provider = _provider, \
|
{ \
|
||||||
.index = _index, \
|
.provider = _provider, \
|
||||||
.dev_id = _dev_id, \
|
.index = _index, \
|
||||||
.con_id = _con_id, \
|
.dev_id = _dev_id, \
|
||||||
.period = _period, \
|
.con_id = _con_id, \
|
||||||
.polarity = _polarity \
|
.period = _period, \
|
||||||
|
.polarity = _polarity, \
|
||||||
|
.module = _module, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
|
||||||
|
PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id, _period, \
|
||||||
|
_polarity, NULL)
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_PWM)
|
#if IS_ENABLED(CONFIG_PWM)
|
||||||
void pwm_add_table(struct pwm_lookup *table, size_t num);
|
void pwm_add_table(struct pwm_lookup *table, size_t num);
|
||||||
void pwm_remove_table(struct pwm_lookup *table, size_t num);
|
void pwm_remove_table(struct pwm_lookup *table, size_t num);
|
||||||
|
|
Loading…
Reference in New Issue