Re: [PATCH v6 2/2] Add PWM fan controller driver for LGM SoC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/ |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux