From patchwork Mon Jan 8 15:41:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10149787 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 6DBE9602CA for ; Mon, 8 Jan 2018 15:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2BB28112 for ; Mon, 8 Jan 2018 15:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60A7828389; Mon, 8 Jan 2018 15:45:59 +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 D93F328112 for ; Mon, 8 Jan 2018 15:45:58 +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=JSRa/mt/mCsnzi876+vLgL5taMQcFgOoy4Dh4fkr5pI=; b=b/KpvcP5kwK/X0 6QiVQUUgM7VxJHxd0NjKzNQfVLHllmk+ApneX2tpIByx6H1KJ4CKUluFg/unhpTOBuCpMhV7XWK89 StpG/DUXLtnzxcy5PIS4oDcUbEQkfTHad4P47wiruTiqlD2WGTaUuD8rwVKezRdAwBzd4LDdbSqnm nejTqtI0yXeeUB01/92R2sT7QQuqto72uHXJZt61qRBRdUgPIy9ZArPgUg724RQQUXd9/hgZ7G9W7 fQLoaAlIIe8oreZd7OkPV9A+nBENWUvmldSg5Qk/kiUPw0SajcLfIfL/7RiUEgVyilWaP19xE6MkU 1IliOExdCaUqB7Hk42fQ==; 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 1eYZcX-0007Qq-MM; Mon, 08 Jan 2018 15:45:53 +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 1eYZXu-0001Xf-Bn for linux-arm-kernel@lists.infradead.org; Mon, 08 Jan 2018 15:41:54 +0000 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992391AbeAHPlFKpsaT (ORCPT ); Mon, 8 Jan 2018 16:41:05 +0100 Date: Mon, 8 Jan 2018 16:41:04 +0100 From: Ladislav Michl To: Keerthy , tony@atomide.com, aaro.koskinen@iki.fi, thierry.reding@gmail.com, daniel.lezcano@linaro.org Subject: [PATCH 2/5] clocksource: timer-dm: Check prescaler value Message-ID: <20180108154104.GB4077@lenoch> References: <20180108153926.GA3916@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180108153926.GA3916@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_074107_168454_E4213726 X-CRM114-Status: UNSURE ( 6.79 ) X-CRM114-Notice: Please train this message. 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: linux-pwm@vger.kernel.org, grygorii.strashko@ti.com, t-kristo@ti.com, robh+dt@kernel.org, sebastian.reichel@collabora.co.uk, linux-omap@vger.kernel.org, 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 diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c index 43531eecbe54..bde1014308f9 100644 --- a/drivers/clocksource/timer-dm.c +++ b/drivers/clocksource/timer-dm.c @@ -663,13 +663,13 @@ static int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, { 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; }