diff options
author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2024-09-23 14:54:17 +0200 |
---|---|---|
committer | Uwe Kleine-König <ukleinek@kernel.org> | 2024-10-25 11:33:34 +0200 |
commit | 22f032c7900ca457f4facdd711eee61c9648c7c1 (patch) | |
tree | bb3f961efdfbb317605aee0f972ae582778009c2 /drivers/pwm/pwm-axi-pwmgen.c | |
parent | 51f8137022752c8bab2621e8ee461c5af3dccf52 (diff) |
pwm: axi-pwmgen: Create a dedicated function for getting driver data from a chip
Compared to direct calls to pwmchip_get_drvdata() a dedicated function
has two upsides: A better name and the right type. So the code becomes
easier to read and the new function is harder to use wrongly.
Another side effect (which is the secret motivation for this patch, but
shhh) is that the driver becomes a bit easier to backport to kernel
versions that don't have devm_pwmchip_alloc() yet.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Link: https://lore.kernel.org/r/20240923125418.16558-2-u.kleine-koenig@baylibre.com
[ukleinek: added an * to the new function's prototype to make the compiler happy]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'drivers/pwm/pwm-axi-pwmgen.c')
-rw-r--r-- | drivers/pwm/pwm-axi-pwmgen.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c index b5477659ba18..5cee5645fe80 100644 --- a/drivers/pwm/pwm-axi-pwmgen.c +++ b/drivers/pwm/pwm-axi-pwmgen.c @@ -53,10 +53,15 @@ static const struct regmap_config axi_pwmgen_regmap_config = { .max_register = 0xFC, }; +static struct axi_pwmgen_ddata *axi_pwmgen_ddata_from_chip(struct pwm_chip *chip) +{ + return pwmchip_get_drvdata(chip); +} + static int axi_pwmgen_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { - struct axi_pwmgen_ddata *ddata = pwmchip_get_drvdata(chip); + struct axi_pwmgen_ddata *ddata = axi_pwmgen_ddata_from_chip(chip); unsigned int ch = pwm->hwpwm; struct regmap *regmap = ddata->regmap; u64 period_cnt, duty_cnt; @@ -100,7 +105,7 @@ static int axi_pwmgen_apply(struct pwm_chip *chip, struct pwm_device *pwm, static int axi_pwmgen_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { - struct axi_pwmgen_ddata *ddata = pwmchip_get_drvdata(chip); + struct axi_pwmgen_ddata *ddata = axi_pwmgen_ddata_from_chip(chip); struct regmap *regmap = ddata->regmap; unsigned int ch = pwm->hwpwm; u32 cnt; |