Received: by 10.223.148.5 with SMTP id 5csp6437601wrq; Wed, 17 Jan 2018 13:48:08 -0800 (PST) X-Google-Smtp-Source: ACJfBoswXm6/xCvnzgLMQjqxVDhAh4WfDOETVWswQUJ+IxkUpe7XDo41DbFLbzRqFtTxaOKtmxCH X-Received: by 10.159.196.135 with SMTP id c7mr4998482plo.410.1516225688684; Wed, 17 Jan 2018 13:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516225688; cv=none; d=google.com; s=arc-20160816; b=SuyBTRcyenvucTNmQDvm6GPt3pxTky5T7ylbVgtlvvbgxA4Li0xNz4tWCVVaNzASvf Eoyb+cF1H/cxI+06h9EZoY9BB+v5Aoptgqs2Lr4zuVi4Jqmz5uvk/przPOiCHxRsq/3Q pInaxv/Nzyb+E0Bnb7oBtH1Zm1Vei58JZNrW/myaCsGGPrnMvgEbeOpOWt9bXC6ZBxSv Y/5GsGrwBi/SEZG4rTkDlfSF+DsDoXogEwmtuV9wleH+xex5WVIEjzY4qPWIOS6Dts10 ofHCwxEntjAps6NQNxSPKHpx85/lDd8xTJHP4fisPwWm48B4l7sEqokZ5E4cToPT/LHw 6kLA== 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=LsRtaGPtN46a1lVz465ABym+6iPX+3LYfSMZ9r0xvvY=; b=qoW5dxZ9RP6krY8DdXysFdQWMnlElBssaWtZj5tgKoQ54J622ommaqQvql6O+hx+8J Cw4g+UeCjXbjWoX/mWnQ8Fn3Vir4uN7ZuGjYgyH1Gy2DH9wicKlStBSL+T75W6tssKQn I/Fg9ihkAY3G9UHN2sCJDsEBOkEptSG0TaKgcJpIgbLyynTCPreSJMH4NuM13tuJLcDz krc6vX7vuUqj9NWe42FU506sQwWiuOyGaZKd5I3s9uMMK8P9vQq/hszQhtpmkzI8XOtP tzXXQ42bvPh+/Mqdx2vHRpzRVKuYOx4TeSPIooBCqO0zAZsgnTtqeW6xLtyIW733EpAB AQ9g== 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 j3si5077072plk.506.2018.01.17.13.47.55; Wed, 17 Jan 2018 13:48:08 -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 S1753764AbeAQVrS (ORCPT + 99 others); Wed, 17 Jan 2018 16:47:18 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:42996 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752578AbeAQVrR (ORCPT ); Wed, 17 Jan 2018 16:47:17 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990409AbeAQVrPp1HAq (ORCPT + 2 others); Wed, 17 Jan 2018 22:47:15 +0100 Date: Wed, 17 Jan 2018 22:47:14 +0100 From: Ladislav Michl To: linux-omap@vger.kernel.org, linux-pwm@vger.kernel.org Cc: Keerthy , daniel.lezcano@linaro.org, thierry.reding@gmail.com, tony@atomide.com, aaro.koskinen@iki.fi, Claudiu.Beznea@microchip.com, 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: [PATCH 1/3] clocksource: timer-dm: Check prescaler value Message-ID: <20180117214714.GB11952@lenoch> References: <20180117214629.GA11952@lenoch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180117214629.GA11952@lenoch> 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 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) 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) { l |= OMAP_TIMER_CTRL_PRE; l |= prescaler << 2; }