pwm: jz4740: Change prototype of a helper to prepare further changes

This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given jz4740_pwm_chip. To just not have to
do that, rework jz4740_pwm_can_use_chn() to take a pwm_chip.

Link: https://lore.kernel.org/r/83b826f0bf58b93f26d3bc30b1a957f84eedf41a.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
Uwe Kleine-König 2024-02-14 10:31:42 +01:00
parent 1b6691680b
commit cebf107de5

View File

@ -35,13 +35,12 @@ static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
return container_of(chip, struct jz4740_pwm_chip, chip);
}
static bool jz4740_pwm_can_use_chn(struct jz4740_pwm_chip *jz,
unsigned int channel)
static bool jz4740_pwm_can_use_chn(struct pwm_chip *chip, unsigned int channel)
{
/* Enable all TCU channels for PWM use by default except channels 0/1 */
u32 pwm_channels_mask = GENMASK(jz->chip.npwm - 1, 2);
u32 pwm_channels_mask = GENMASK(chip->npwm - 1, 2);
device_property_read_u32(jz->chip.dev->parent,
device_property_read_u32(chip->dev->parent,
"ingenic,pwm-channels-mask",
&pwm_channels_mask);
@ -55,7 +54,7 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
char name[16];
int err;
if (!jz4740_pwm_can_use_chn(jz, pwm->hwpwm))
if (!jz4740_pwm_can_use_chn(chip, pwm->hwpwm))
return -EBUSY;
snprintf(name, sizeof(name), "timer%u", pwm->hwpwm);