[PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

Lino Sanfilippo LinoSanfilippo at gmx.de
Fri Dec 4 18:16:01 EST 2020

Hi Sean,

On 04.12.20 at 09:44, Sean Young wrote:

>> What about an extra check then to make sure that the period has not been truncated,
>> e.g:
>> 	value = DIV_ROUND_CLOSEST_ULL(state->period, scaler);
>> 	/* dont accept a period that is too small or has been truncated */
>> 	if ((value < PERIOD_MIN) ||
>> 	    (value != DIV_ROUND_CLOSEST_ULL(state->period, scaler)))
>> 		return -EINVAL;
> Rather than doing another 64 bit division which is expensive (esp on 32 bit
> kernels), you could assign to u64 and check:
> 	if (value < PERIOD || value > U32_MAX)
> 		return -EINVAL;

Sound reasonable, I will adjust this.

> There was a problem where the carrier is incorrect for some IR hardware
> which uses a carrier of 455kHz. With periods that small, rounding errors
> do really matter and rounding down might cause problems.
> A policy of rounding down the carrier is not the right thing to do
> for pwm-ir-tx, and such a change will probably break pwm-ir-tx in some
> edge cases.

Thanks for this background information.


More information about the linux-arm-kernel mailing list