Received: by 10.223.176.46 with SMTP id f43csp2712892wra; Mon, 22 Jan 2018 02:06:29 -0800 (PST) X-Google-Smtp-Source: AH8x227dY069Ik3shSM9Ezngxg3dnK5rc4Q5FsZliv7oH+5hhFfKfhXVQeb8i9srUGk55sX9sXtq X-Received: by 2002:a17:902:6005:: with SMTP id r5-v6mr3218482plj.307.1516615588925; Mon, 22 Jan 2018 02:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516615588; cv=none; d=google.com; s=arc-20160816; b=pyreG79NrWlK7PwkPRWx8BY1TGv5Wwd5hYdBopn8Kx7ngI2ZaE9lAOSibgdTI+Tehx QLAUJykeG44sSqi/85M0iyMWYFeh95xYlhJcCbFKoSqyXeyoP5bdRoJUgCWaFC0nleao KnKlu2Yk2ibtd+LlbPeGl1i4M+h4DKVlZvy/9CUZAy2pRZAGRG+a6WFpTRCbNo08PP5k R+/HtEmSYy897XJ7BdRDDlxK5ymsfe42A4+cnG8aJPmMMs/fyzMW4NwMc4A5rTXIB61D 63NZBtLhs+572FstEzErd5kjgFB+76giAylw42Tts12UIvr+hyf/NsThF666hTVgzAwU cK8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=S5VFFFHmg5EU6FOkH54w5s5STyjP112VW3dfApXp1Zg=; b=dLT0bw/QfUZKupUA5MJDnZyR82zw6Ondi2hDP+X0KlU/Cb0IIWwQNWgDDYxu2GlQxc bfushjQ0829I3w8NeabkX4yIus2o1uJF7S2mXUZhPo6aXxPCObwG/zdLzVuGdkKU5Zow 6tlhFUgJVQYLhZkbx7fHGmc0vorgjyKHCSxk9QVePj85GiGJR7Z0Fuzs60ZuO3APCIPw MnX2oUsmU6ZJdrQsJ1I1Egq2fjIFmfnmgZIPEpKzPR3qnd9kHjWe7F0lIu4ok1nyZjP9 3Xo0CJjwydsuLBcrGIPDKIEeddRuqOtZcWD+MLFgy5176QtCjbMmK5Yy694nasTIVq8u O3vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si3260496plx.696.2018.01.22.02.06.15; Mon, 22 Jan 2018 02:06:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbeAVKEc (ORCPT + 99 others); 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" Received: from exsmtp01.microchip.com (HELO email.microchip.com) ([198.175.253.37]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES128-SHA; 22 Jan 2018 03:04:30 -0700 Received: from [10.145.6.87] (10.10.76.4) by CHN-SV-EXCH01.mchp-main.com (10.10.76.37) with Microsoft SMTP Server id 14.3.352.0; Mon, 22 Jan 2018 03:04:29 -0700 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 Precedence: bulk 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 >