Skip to content

Commit 4b2b7b1

Browse files
author
Uwe Kleine-König
committed
leds: qcom-lpg: Make use of devm_pwmchip_alloc() function
This prepares the pwm sub-driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Acked-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/0be073477092eeccaac6c021cf07e38fc30c74fc.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 596de87 commit 4b2b7b1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/leds/rgb/leds-qcom-lpg.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct lpg {
7777

7878
struct mutex lock;
7979

80-
struct pwm_chip pwm;
80+
struct pwm_chip *pwm;
8181

8282
const struct lpg_data *data;
8383

@@ -978,7 +978,7 @@ static int lpg_pattern_mc_clear(struct led_classdev *cdev)
978978

979979
static inline struct lpg *lpg_pwm_from_chip(struct pwm_chip *chip)
980980
{
981-
return container_of(chip, struct lpg, pwm);
981+
return pwmchip_get_drvdata(chip);
982982
}
983983

984984
static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -1093,13 +1093,17 @@ static const struct pwm_ops lpg_pwm_ops = {
10931093

10941094
static int lpg_add_pwm(struct lpg *lpg)
10951095
{
1096+
struct pwm_chip *chip;
10961097
int ret;
10971098

1098-
lpg->pwm.dev = lpg->dev;
1099-
lpg->pwm.npwm = lpg->num_channels;
1100-
lpg->pwm.ops = &lpg_pwm_ops;
1099+
lpg->pwm = chip = devm_pwmchip_alloc(lpg->dev, lpg->num_channels, 0);
1100+
if (IS_ERR(chip))
1101+
return PTR_ERR(chip);
11011102

1102-
ret = devm_pwmchip_add(lpg->dev, &lpg->pwm);
1103+
chip->ops = &lpg_pwm_ops;
1104+
pwmchip_set_drvdata(chip, lpg);
1105+
1106+
ret = devm_pwmchip_add(lpg->dev, chip);
11031107
if (ret)
11041108
dev_err_probe(lpg->dev, ret, "failed to add PWM chip\n");
11051109

0 commit comments

Comments
 (0)