Skip to contentSkip to conversation

The data type of "period" in struct pwm_state is different from that of "period_ns" in struct pwm_ops

DISCUSSION Leo Liang 1 participant 1 message Jan 20, 2022 PWM

lore
Share & tools
lore

Leo Liang

author
#0 lore raw

Hi guys,

The data type of "period" member in struct pwm_state is "u64", but the "period_ns" argument in struct pwm_ops for config operation is "int".

Should a patch be created to have consistent data type in case of an overflow ? Or that is it the API users' responsibility to do the correct conversion ?

struct pwm_state {
	u64 period;						<<-------------
	u64 duty_cycle;					<<-------------
	enum pwm_polarity polarity;
	bool enabled;
	bool usage_power;
};
struct pwm_ops {
	...
	/* Only used by legacy drivers */
	int (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
		      int duty_ns, int period_ns);							<<---------
	int (*set_polarity)(struct pwm_chip *chip, struct pwm_device *pwm,
			    enum pwm_polarity polarity);
	int (*enable)(struct pwm_chip *chip, struct pwm_device *pwm);
	void (*disable)(struct pwm_chip *chip, struct pwm_device *pwm);
};

Best regards,
Leo