Skip to content

Commit 9e314de

Browse files
Uwe Kleine-Königlag-linaro
authored andcommitted
leds: qcom-lpg: Introduce a wrapper for getting driver data from a pwm chip
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/4785982785812615d15c7dd6d2755270bd8670b2.1701860672.git.u.kleine-koenig@pengutronix.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent e7431bd commit 9e314de

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,14 @@ static int lpg_pattern_mc_clear(struct led_classdev *cdev)
976976
return lpg_pattern_clear(led);
977977
}
978978

979+
static inline struct lpg *lpg_pwm_from_chip(struct pwm_chip *chip)
980+
{
981+
return container_of(chip, struct lpg, pwm);
982+
}
983+
979984
static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
980985
{
981-
struct lpg *lpg = container_of(chip, struct lpg, pwm);
986+
struct lpg *lpg = lpg_pwm_from_chip(chip);
982987
struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
983988

984989
return chan->in_use ? -EBUSY : 0;
@@ -994,7 +999,7 @@ static int lpg_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
994999
static int lpg_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
9951000
const struct pwm_state *state)
9961001
{
997-
struct lpg *lpg = container_of(chip, struct lpg, pwm);
1002+
struct lpg *lpg = lpg_pwm_from_chip(chip);
9981003
struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
9991004
int ret = 0;
10001005

@@ -1025,7 +1030,7 @@ static int lpg_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
10251030
static int lpg_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
10261031
struct pwm_state *state)
10271032
{
1028-
struct lpg *lpg = container_of(chip, struct lpg, pwm);
1033+
struct lpg *lpg = lpg_pwm_from_chip(chip);
10291034
struct lpg_channel *chan = &lpg->channels[pwm->hwpwm];
10301035
unsigned int resolution;
10311036
unsigned int pre_div;

0 commit comments

Comments
 (0)