Received: by 10.223.176.46 with SMTP id f43csp2706871wra; Mon, 22 Jan 2018 02:00:40 -0800 (PST) X-Google-Smtp-Source: AH8x225WFoxofAhnzwNOZBDqWVPadZjyjFH0XdI6aBKkaWGT2EMsKMwC2raVeE5WYAsb12RScFjQ X-Received: by 10.98.223.196 with SMTP id d65mr8120069pfl.176.1516615240111; Mon, 22 Jan 2018 02:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516615240; cv=none; d=google.com; s=arc-20160816; b=ed4Ku2r2cqhcRGQc7eUYvwTebl2SYyX36+IIbXo9NFNHibGGv4EQPGBuHKj4nxNkwV TPqbI19Qyt9lcvg0z0spxisiYINCmfvVJIbe6CEjm/i52yH1vFG0+I2HNALhNR37bYng qdQLCDs3jvVp4EP3euaWZMGgCNfmCZ18WeBfIFXl7lyw/Qqd16MtdQbekcOMKfhBF8do HTk5CZfPB+J11MQYmCvY+9x0ENFADzA3C7mFUSf9COBOJ4mfh1K7/StPedlg8Q8eO0I1 eL+2jJd4PYCqffS21prwH+3n4NAmwakNCpJ/u9vevA0Qg7dE+MqttB3BCtccI7NbOoNM 9FLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=M7VDaWupcvEtLVLFbA5QYobS3XeN7f0ropj8awnxoGM=; b=ewTxx6Q4KOtlW5VToIp+8EFF0Lnm/AUPhBJ+8GL5BvWRGpLzwtm6f0/lOJ+mLNubt5 xyTgmMU7Ozve1eALyVGHWUnKSBL7yo0z4+zqvn6iMKhpe5qIsE3CIpCNQJSWTouiexAN rx2MXsPthBM0ZMMVy+awPeLtbdaPw655Sv38h5J7qL1dt35E78DfhL7qgRfmYOhY/vpc arze1oFYBykZw6D3R35aeoVvLEzG2IUF52PpYyohTzluuwKpujb93N0POzltgWSDKjCm mS447P1rjnS5yUSUIuM/+oMiBDEtRTTsyft69+4rzQe5gklgwnhW5dIPyRJEsu9Lh+dE sgIw== 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 f13si15190173pfj.28.2018.01.22.02.00.25; Mon, 22 Jan 2018 02:00:40 -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 S1751184AbeAVJ7z (ORCPT + 99 others); Mon, 22 Jan 2018 04:59:55 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:51546 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751024AbeAVJ7x (ORCPT ); Mon, 22 Jan 2018 04:59:53 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990723AbeAVJ7vo97Zl (ORCPT + 2 others); Mon, 22 Jan 2018 10:59:51 +0100 Date: Mon, 22 Jan 2018 10:59:50 +0100 From: Ladislav Michl To: Claudiu Beznea Cc: linux-omap@vger.kernel.org, linux-pwm@vger.kernel.org, Keerthy , daniel.lezcano@linaro.org, thierry.reding@gmail.com, tony@atomide.com, aaro.koskinen@iki.fi, narmstrong@baylibre.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sebastian.reichel@collabora.co.uk, robh+dt@kernel.org, t-kristo@ti.com, grygorii.strashko@ti.com Subject: Re: [PATCH 1/3] clocksource: timer-dm: Check prescaler value Message-ID: <20180122095950.GA19401@lenoch> References: <20180117214629.GA11952@lenoch> <20180117214714.GB11952@lenoch> <4688ef73-99ac-1295-2e3b-ed79e8670262@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4688ef73-99ac-1295-2e3b-ed79e8670262@microchip.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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