Commit 69efb343 authored by Hans de Goede's avatar Hans de Goede Committed by Thierry Reding

pwm: Don't hold pwm_lookup_lock longer than necessary

There is no need to hold pwm_lookup_lock after we're done with looping
over pwm_lookup_list, so release it earlier.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 42883cbc
...@@ -759,9 +759,9 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num) ...@@ -759,9 +759,9 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num)
*/ */
struct pwm_device *pwm_get(struct device *dev, const char *con_id) struct pwm_device *pwm_get(struct device *dev, const char *con_id)
{ {
struct pwm_device *pwm = ERR_PTR(-EPROBE_DEFER);
const char *dev_id = dev ? dev_name(dev) : NULL; const char *dev_id = dev ? dev_name(dev) : NULL;
struct pwm_chip *chip = NULL; struct pwm_device *pwm;
struct pwm_chip *chip;
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;
...@@ -819,24 +819,22 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) ...@@ -819,24 +819,22 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
} }
} }
if (!chosen) { mutex_unlock(&pwm_lookup_lock);
pwm = ERR_PTR(-ENODEV);
goto out; if (!chosen)
} return ERR_PTR(-ENODEV);
chip = pwmchip_find_by_name(chosen->provider); chip = pwmchip_find_by_name(chosen->provider);
if (!chip) if (!chip)
goto out; return ERR_PTR(-EPROBE_DEFER);
pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id);
if (IS_ERR(pwm)) if (IS_ERR(pwm))
goto out; return pwm;
pwm->args.period = chosen->period; pwm->args.period = chosen->period;
pwm->args.polarity = chosen->polarity; pwm->args.polarity = chosen->polarity;
out:
mutex_unlock(&pwm_lookup_lock);
return pwm; return pwm;
} }
EXPORT_SYMBOL_GPL(pwm_get); EXPORT_SYMBOL_GPL(pwm_get);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment