lkml.org 
[lkml]   [2020]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 2/2] Add PWM fan controller driver for LGM SoC
Hello,

I only found a two minor issues this round, see below.

On Tue, Jul 28, 2020 at 04:52:13PM +0800, Rahul Tanwar wrote:
> +static int lgm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> + const struct pwm_state *state)
> +{
> + struct lgm_pwm_chip *pc = to_lgm_pwm_chip(chip);
> + u32 duty_cycle, val;
> + int ret;
> +
> + /*
> + * HW only supports only NORMAL polarity
> + * HW supports fixed period

there are too many "only"s here. What about:

/*
* The hardware only supports
* normal polarity and fixed period.
*/

?

> + */
> + if (state->polarity != PWM_POLARITY_NORMAL ||
> + state->period < pc->period)
> + return -EINVAL;
> +
> + if (!state->enabled) {
> + ret = lgm_pwm_enable(chip, 0);
> + return ret;
> + }
> +
> + duty_cycle = min_t(u64, state->duty_cycle, pc->period);
> + val = duty_cycle * LGM_PWM_MAX_DUTY_CYCLE / pc->period;
> +
> + ret = regmap_update_bits(pc->regmap, LGM_PWM_FAN_CON0, LGM_PWM_FAN_DC_MSK,
> + FIELD_PREP(LGM_PWM_FAN_DC_MSK, val));
> + if (ret)
> + return ret;
> +
> + if (state->enabled)
> + ret = lgm_pwm_enable(chip, 1);

You can do this unconditionally, if state->enabled is false the function
returns a few lines above already.

> +
> + return ret;
> +}

The rest looks fine.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-07-31 21:47    [W:0.073 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site