@@ -76,6 +76,7 @@
#define REG_OFF_L(C) ((C) >= PCA9685_MAXCHAN ? PCA9685_ALL_LED_OFF_L : LED_N_OFF_L((C)))
struct pca9685 {
+ struct device *parent;
struct pwm_chip *chip;
struct regmap *regmap;
struct mutex lock;
@@ -237,7 +238,7 @@ static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
if (pca9685_pwm_test_and_set_inuse(pca, offset))
return -EBUSY;
- pm_runtime_get_sync(pca->chip->dev);
+ pm_runtime_get_sync(pca->parent);
return 0;
}
@@ -261,7 +262,7 @@ static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
struct pca9685 *pca = gpiochip_get_data(gpio);
pca9685_pwm_set_duty(pca, offset, 0);
- pm_runtime_put(pca->chip->dev);
+ pm_runtime_put(pca->parent);
pca9685_pwm_clear_inuse(pca, offset);
}
@@ -294,7 +295,7 @@ static int pca9685_pwm_gpio_direction_output(struct gpio_chip *gpio,
*/
static int pca9685_pwm_gpio_probe(struct pca9685 *pca)
{
- struct device *dev = pca->chip->dev;
+ struct device *dev = pca->parent;
pca->gpio.label = dev_name(dev);
pca->gpio.parent = dev;
@@ -331,7 +332,7 @@ static inline int pca9685_pwm_gpio_probe(struct pca9685 *pca)
static void pca9685_set_sleep_mode(struct pca9685 *pca, bool enable)
{
- struct device *dev = pca->chip->dev;
+ struct device *dev = pca->parent;
int err = regmap_update_bits(pca->regmap, PCA9685_MODE1,
MODE1_SLEEP, enable ? MODE1_SLEEP : 0);
if (err) {
@@ -463,7 +464,7 @@ static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
mutex_unlock(&pca->lock);
}
- pm_runtime_get_sync(chip->dev);
+ pm_runtime_get_sync(pca->parent);
return 0;
}
@@ -477,7 +478,7 @@ static void pca9685_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
clear_bit(pwm->hwpwm, pca->pwms_enabled);
mutex_unlock(&pca->lock);
- pm_runtime_put(chip->dev);
+ pm_runtime_put(pca->parent);
pca9685_pwm_clear_inuse(pca, pwm->hwpwm);
}
@@ -508,6 +509,7 @@ static int pca9685_pwm_probe(struct i2c_client *client)
return PTR_ERR(chip);
pca = to_pca(chip);
pca->chip = chip;
+ pca->parent = &client->dev;
pca->regmap = devm_regmap_init_i2c(client, &pca9685_regmap_i2c_config);
if (IS_ERR(pca->regmap)) {
@@ -290,7 +290,7 @@ struct pwm_ops {
* @pwms: array of PWM devices allocated by the framework
*/
struct pwm_chip {
- struct device dev;
+ struct device *dev;
const struct pwm_ops *ops;
struct module *owner;
int id;
struct pwm_chip::dev is about to change. To not have to touch this driver in the same commit as struct pwm_chip::dev, store a pointer to the parent device in driver data. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- drivers/pwm/pwm-pca9685.c | 14 ++++++++------ include/linux/pwm.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-)