Re: [PATCH v2 01/11] pwm: Make .get_state() callback return an error code

Tzung-Bi Shih
2022-12-01T02:41:38Z

On Wed, Nov 30, 2022 at 04:21:38PM +0100, Uwe Kleine-König wrote:
> diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
> index 7f10f56c3eb6..11684edc0620 100644
> --- a/drivers/pwm/pwm-cros-ec.c
> +++ b/drivers/pwm/pwm-cros-ec.c
> @@ -183,8 +183,8 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> return 0;
> }
>
> -static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> - struct pwm_state *state)
> +static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> + struct pwm_state *state)
> {
> struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip);
> struct cros_ec_pwm *channel = pwm_get_chip_data(pwm);
> @@ -193,7 +193,7 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> ret = cros_ec_pwm_get_duty(ec_pwm, pwm->hwpwm);
> if (ret < 0) {
> dev_err(chip->dev, "error getting initial duty: %d\n", ret);
> - return;
> + return 0;
> }
>
> state->enabled = (ret > 0);
> @@ -212,6 +212,8 @@ static void cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
> state->duty_cycle = channel->duty_cycle;
> else
> state->duty_cycle = ret;
> +
> + return 0;
> }

For the cros-ec part:
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>