Merge tag 'leds-next-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds
[linux-2.6-microblaze.git] / drivers / leds / rgb / leds-qcom-lpg.c
index 0c7d838..6bdc5b9 100644 (file)
@@ -109,7 +109,7 @@ struct lpg {
 
        struct mutex lock;
 
-       struct pwm_chip pwm;
+       struct pwm_chip *pwm;
 
        const struct lpg_data *data;
 
@@ -1199,7 +1199,7 @@ static int lpg_pattern_mc_clear(struct led_classdev *cdev)
 
 static inline struct lpg *lpg_pwm_from_chip(struct pwm_chip *chip)
 {
-       return container_of(chip, struct lpg, pwm);
+       return pwmchip_get_drvdata(chip);
 }
 
 static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -1314,13 +1314,17 @@ static const struct pwm_ops lpg_pwm_ops = {
 
 static int lpg_add_pwm(struct lpg *lpg)
 {
+       struct pwm_chip *chip;
        int ret;
 
-       lpg->pwm.dev = lpg->dev;
-       lpg->pwm.npwm = lpg->num_channels;
-       lpg->pwm.ops = &lpg_pwm_ops;
+       lpg->pwm = chip = devm_pwmchip_alloc(lpg->dev, lpg->num_channels, 0);
+       if (IS_ERR(chip))
+               return PTR_ERR(chip);
 
-       ret = devm_pwmchip_add(lpg->dev, &lpg->pwm);
+       chip->ops = &lpg_pwm_ops;
+       pwmchip_set_drvdata(chip, lpg);
+
+       ret = devm_pwmchip_add(lpg->dev, chip);
        if (ret)
                dev_err_probe(lpg->dev, ret, "failed to add PWM chip\n");