lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190401183847.7xhlgff63cvlzz2h@pengutronix.de>
Date:   Mon, 1 Apr 2019 20:38:47 +0200
From:   Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
To:     Martin Blumenstingl <martin.blumenstingl@...glemail.com>
Cc:     thierry.reding@...il.com, linux-pwm@...r.kernel.org,
        linux-amlogic@...ts.infradead.org, narmstrong@...libre.com,
        jbrunet@...libre.com, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, bichao.zheng@...ogic.com
Subject: Re: [PATCH 1/2] pwm: meson: consider 128 a valid pre-divider

Hello Martin,

On Mon, Apr 01, 2019 at 08:18:16PM +0200, Martin Blumenstingl wrote:
> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
> index f6e738ad7bd9..4b708c1fcb1d 100644
> --- a/drivers/pwm/pwm-meson.c
> +++ b/drivers/pwm/pwm-meson.c
> @@ -188,7 +188,7 @@ static int meson_pwm_calc(struct meson_pwm *meson,
>  	do_div(fin_ps, fin_freq);
>  
>  	/* Calc pre_div with the period */
> -	for (pre_div = 0; pre_div < MISC_CLK_DIV_MASK; pre_div++) {
> +	for (pre_div = 0; pre_div <= MISC_CLK_DIV_MASK; pre_div++) {
>  		cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000,
>  					    fin_ps * (pre_div + 1));
>  		dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n",

You could even calculate pre_div without the loop.

Something like:

	u64 pre_div = (u64)period * rate;
	do_div_round_up(pre_div, NSEC_PER_SEC * 0xffff);
	pre_div--;

(I didn't check rounding and maybe its off by one and ...) This would
also get rid of the strange 1000 that is currently used in the
calculation without a real benefit (unless I missed something).

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ