From patchwork Wed Jan 17 21:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10172037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2202260386 for ; Wed, 17 Jan 2018 21:47:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1113523B32 for ; Wed, 17 Jan 2018 21:47:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 039A3251F4; Wed, 17 Jan 2018 21:47:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F19D23B32 for ; Wed, 17 Jan 2018 21:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3e6CBzJtlcI6fzPVdNwWzVaG5dQ5uO1rh4qSlty4Bc8=; b=tnogYv1rRxAyhn CVY6Wi9r6Dbe9hscL6o1R8oqDYdNUYAftI2Eb4qFUfqMY1gVN5A8z72d6ionTp3RElR5j/fiujp6j 9qRzEmDdPNZ1SOEZyx5ThyUp89kbbeNbaHkprXmtPkJ10SqSz7yjkpHyQHtnUfLqBgtTF6OFgJHnS Uz5SdcUIlZurrRExD/ZC7apK5PzykEEnXuHds+S0OEY/h2W1su6VONj/nKY/XzJyBAP23bctf2cG3 8C5eJF328kocL7ZTs99/CNCR7tdwtS3aN/l6lSzXnIR6J2k++OJuS3rJ9YsXZeFbAI8fFzhwocCBo Q5nwgkLvFdR3mWE2uI9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebvYF-0006IN-4a; Wed, 17 Jan 2018 21:47:19 +0000 Received: from eddie.linux-mips.org ([148.251.95.138] helo=cvs.linux-mips.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebvYC-0005yx-38 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 21:47:17 +0000 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990409AbeAQVrPp1HAq (ORCPT ); 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 Subject: [PATCH 1/3] clocksource: timer-dm: Check prescaler value Message-ID: <20180117214714.GB11952@lenoch> References: <20180117214629.GA11952@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180117214629.GA11952@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: t-kristo@ti.com, grygorii.strashko@ti.com, aaro.koskinen@iki.fi, tony@atomide.com, Keerthy , daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, narmstrong@baylibre.com, thierry.reding@gmail.com, sebastian.reichel@collabora.co.uk, Claudiu.Beznea@microchip.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }