Commit 575b48ad authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Kleber Sacilotto de Souza

pwm: Clear chip_data in pwm_put()

BugLink: https://bugs.launchpad.net/bugs/1855313

commit e926b12c upstream.

After a PWM is disposed by its user the per chip data becomes invalid.
Clear the data in common code instead of the device drivers to get
consistent behaviour. Before this patch only three of nine drivers
cleaned up here.
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent d9b2c9d7
...@@ -781,6 +781,7 @@ void pwm_put(struct pwm_device *pwm) ...@@ -781,6 +781,7 @@ void pwm_put(struct pwm_device *pwm)
if (pwm->chip->ops->free) if (pwm->chip->ops->free)
pwm->chip->ops->free(pwm->chip, pwm); pwm->chip->ops->free(pwm->chip, pwm);
pwm_set_chip_data(pwm, NULL);
pwm->label = NULL; pwm->label = NULL;
module_put(pwm->chip->ops->owner); module_put(pwm->chip->ops->owner);
......
...@@ -226,7 +226,6 @@ static int pwm_samsung_request(struct pwm_chip *chip, struct pwm_device *pwm) ...@@ -226,7 +226,6 @@ static int pwm_samsung_request(struct pwm_chip *chip, struct pwm_device *pwm)
static void pwm_samsung_free(struct pwm_chip *chip, struct pwm_device *pwm) static void pwm_samsung_free(struct pwm_chip *chip, struct pwm_device *pwm)
{ {
devm_kfree(chip->dev, pwm_get_chip_data(pwm)); devm_kfree(chip->dev, pwm_get_chip_data(pwm));
pwm_set_chip_data(pwm, NULL);
} }
static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm) static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm)
......
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