From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751210AbeAVKEc (ORCPT ); Mon, 22 Jan 2018 05:04:32 -0500 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:65117 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbeAVKEb (ORCPT ); Mon, 22 Jan 2018 05:04:31 -0500 X-IronPort-AV: E=Sophos;i="5.46,396,1511852400"; d="scan'208";a="10661126" Subject: Re: [PATCH 1/3] clocksource: timer-dm: Check prescaler value To: Ladislav Michl CC: , , Keerthy , , , , , , , , , , , References: <20180117214629.GA11952@lenoch> <20180117214714.GB11952@lenoch> <4688ef73-99ac-1295-2e3b-ed79e8670262@microchip.com> <20180122095950.GA19401@lenoch> From: Claudiu Beznea Message-ID: <62985c64-b05c-e3ae-2473-6b0f20dd71b3@microchip.com> Date: Mon, 22 Jan 2018 12:04:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180122095950.GA19401@lenoch> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.01.2018 11:59, Ladislav Michl wrote: > On Mon, Jan 22, 2018 at 11:00:15AM +0200, Claudiu Beznea wrote: >> >> >> On 17.01.2018 23:47, Ladislav Michl wrote: >>> Invalid value silently disables use of the prescaler. >>> Use -1 explicitely for that purpose and error out on >>> invalid value. >>> >>> Signed-off-by: Ladislav Michl >>> --- >>> drivers/clocksource/timer-dm.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c >>> index 60db1734ea3b..324ec93d3dd2 100644 >>> --- a/drivers/clocksource/timer-dm.c >>> +++ b/drivers/clocksource/timer-dm.c >>> @@ -663,13 +663,13 @@ int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler) >>> { >>> u32 l; >>> >>> - if (unlikely(!timer)) >>> + if (unlikely(!timer) || prescaler < -1 || prescaler > 7) >> You are checking the prescaller here to be in [0, 7] interval. > > You mean [-1, 7] I suppose. Right, [-1, 7], my bad. Ok, So you use -1 to disable the prescaler. > >>> return -EINVAL; >>> >>> omap_dm_timer_enable(timer); >>> l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); >>> l &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2)); >>> - if (prescaler >= 0x00 && prescaler <= 0x07) { >>> + if (prescaler >= 0) { >> Is this check still necessary? > > Yes, as we need also some way to disable prescaler, see commit message. > >>> l |= OMAP_TIMER_CTRL_PRE; >>> l |= prescaler << 2; >>> } > > Best regards, > ladis >