From patchwork Mon Jan 11 11:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 360702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 304B0C433DB for ; Mon, 11 Jan 2021 11:18:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7370224B1 for ; Mon, 11 Jan 2021 11:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729568AbhAKLS3 (ORCPT ); Mon, 11 Jan 2021 06:18:29 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:43340 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729549AbhAKLS3 (ORCPT ); Mon, 11 Jan 2021 06:18:29 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id 23C644407ED; Mon, 11 Jan 2021 13:17:46 +0200 (IST) From: Baruch Siach To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?b?w7ZuaWc=?= , Lee Jones , Linus Walleij , Bartosz Golaszewski Cc: Baruch Siach , Andrew Lunn , Gregory Clement , Russell King , Sebastian Hesselbarth , Thomas Petazzoni , Chris Packham , Sascha Hauer , Ralph Sennhauser , linux-pwm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] gpio: mvebu: don't limit pwm period/duty_cycle to UINT_MAX Date: Mon, 11 Jan 2021 13:17:05 +0200 Message-Id: <97e5ed4dfc4385a99c585f7980210f9dd7c6ee3d.1610362661.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org PWM on/off registers are limited to UINT_MAX. However the state period and duty_cycle fields are ns values of type u64. There is no reason to limit them to UINT_MAX. Reported-by: Uwe Kleine-König Signed-off-by: Baruch Siach --- drivers/gpio/gpio-mvebu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 6fc64846eda3..eb7456fa6d86 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -669,9 +669,7 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, regmap_read(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), &u); val = (unsigned long long) u * NSEC_PER_SEC; val = DIV_ROUND_UP_ULL(val, mvpwm->clk_rate); - if (val > UINT_MAX) - state->duty_cycle = UINT_MAX; - else if (val) + if (val) state->duty_cycle = val; else state->duty_cycle = 1; @@ -681,9 +679,7 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, val += (unsigned long long) u; /* period = on + off duration */ val *= NSEC_PER_SEC; val = DIV_ROUND_UP_ULL(val, mvpwm->clk_rate); - if (val > UINT_MAX) - state->period = UINT_MAX; - else if (val) + if (val) state->period = val; else state->period = 1;