Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2769240ybh; Mon, 9 Mar 2020 12:36:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vucgW7+k9KHwPRsZHf/6cBD+dCY1PahdLg+R/TfVtwA78uoyFnpvl7So6YgdwXo/pBr2JaY X-Received: by 2002:aca:c70f:: with SMTP id x15mr135721oif.80.1583782600618; Mon, 09 Mar 2020 12:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583782600; cv=none; d=google.com; s=arc-20160816; b=Bbs3GWem7lteVPvce96AiXVlwhjJi7tWML7wdGTxIK29DKqGwlG4SDQPJbYicJB8P7 Bm2vjEM8A2AajPv/eOO49JveR1LAzMC0iGND+IjqrRrxWzPjG0BGo6Ra+VeD2RGzt8oE ga/BCW0/Pb2JukJwaawdwfGy574tfAoqzETSUfeMUdQtABd5j1283inYZd5akIiAXOq6 TZ3PKkKUwUWmG/UvMp3LZIxg9Uu6I2kC2bQaPEL4+3FSafK0xPgqA9naxaWkbtRdrAcv A6lBRpho2sHxxrjYXoRYtr6LmrGPQ8R7uJD38Va0UDP2/vPQ+QlopVxz4TL4HxHpIgD9 BZIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=4BYqTJWiFCkq1lVuCnpAzEiPal0H39x8vdlqXDaKUCY=; b=pH8jHmp3P7nbT2obKyjosRw07JFF4IiH94hi8/AGFfcs3ssoSCtGDwy1vcs/cwuWdp Cf1o0qWM6T+CnVz8VpEh4GyqnLxXSHM7UHmLrvUOOytly/mqel6rcMmBD6P7nDlt6cD2 MfmLTinB1/dMc+5rAf6ohbw9gcb1IFblOmyCNV7M0ThmN0lf4XrLLkcBn8vc2VIaoCwL mwjRe6i0mbW7s3fpwoJJ2CvfEh/5+m8PBsaZdSz0vaLsfew7cYNrYNfITZZz8nPSPonR KCPTjt0EsE6zek44LK3FR3GqQDdwcoeUqhIJ4hchItYT81/sqPimBrin1wioio1Cee/A yq0w== 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 m5si6823727ote.187.2020.03.09.12.36.26; Mon, 09 Mar 2020 12:36:40 -0700 (PDT) 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 S1726610AbgCITfr (ORCPT + 99 others); Mon, 9 Mar 2020 15:35:47 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:22379 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbgCITfY (ORCPT ); Mon, 9 Mar 2020 15:35:24 -0400 Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-02.qualcomm.com with ESMTP; 09 Mar 2020 12:35:22 -0700 Received: from gurus-linux.qualcomm.com ([10.46.162.81]) by ironmsg03-sd.qualcomm.com with ESMTP; 09 Mar 2020 12:35:21 -0700 Received: by gurus-linux.qualcomm.com (Postfix, from userid 383780) id 5A9504A19; Mon, 9 Mar 2020 12:35:21 -0700 (PDT) From: Guru Das Srinagesh To: linux-pwm@vger.kernel.org Cc: Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Subbaraman Narayanamurthy , linux-kernel@vger.kernel.org, Guru Das Srinagesh Subject: [PATCH v7 13/13] pwm: core: Convert period and duty cycle to u64 Date: Mon, 9 Mar 2020 12:35:16 -0700 Message-Id: <7e8afd3b8c716e1771b2e0ff4049bd037c8dcd72.1583782035.git.gurus@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because period and duty cycle are defined as ints with units of nanoseconds, the maximum time duration that can be set is limited to ~2.147 seconds. Change their definitions to u64 in the structs of the PWM framework so that higher durations may be set. Signed-off-by: Guru Das Srinagesh --- drivers/pwm/core.c | 4 ++-- drivers/pwm/sysfs.c | 8 ++++---- include/linux/pwm.h | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 5a7f659..81aa3c2 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -1163,8 +1163,8 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) if (state.enabled) seq_puts(s, " enabled"); - seq_printf(s, " period: %u ns", state.period); - seq_printf(s, " duty: %u ns", state.duty_cycle); + seq_printf(s, " period: %llu ns", state.period); + seq_printf(s, " duty: %llu ns", state.duty_cycle); seq_printf(s, " polarity: %s", state.polarity ? "inverse" : "normal"); diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c index 2389b86..449dbc0 100644 --- a/drivers/pwm/sysfs.c +++ b/drivers/pwm/sysfs.c @@ -42,7 +42,7 @@ static ssize_t period_show(struct device *child, pwm_get_state(pwm, &state); - return sprintf(buf, "%u\n", state.period); + return sprintf(buf, "%llu\n", state.period); } static ssize_t period_store(struct device *child, @@ -52,10 +52,10 @@ static ssize_t period_store(struct device *child, struct pwm_export *export = child_to_pwm_export(child); struct pwm_device *pwm = export->pwm; struct pwm_state state; - unsigned int val; + u64 val; int ret; - ret = kstrtouint(buf, 0, &val); + ret = kstrtou64(buf, 0, &val); if (ret) return ret; @@ -77,7 +77,7 @@ static ssize_t duty_cycle_show(struct device *child, pwm_get_state(pwm, &state); - return sprintf(buf, "%u\n", state.duty_cycle); + return sprintf(buf, "%llu\n", state.duty_cycle); } static ssize_t duty_cycle_store(struct device *child, diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 0ef808d..b53f13d 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -39,7 +39,7 @@ enum pwm_polarity { * current PWM hardware state. */ struct pwm_args { - unsigned int period; + u64 period; enum pwm_polarity polarity; }; @@ -56,8 +56,8 @@ enum { * @enabled: PWM enabled status */ struct pwm_state { - unsigned int period; - unsigned int duty_cycle; + u64 period; + u64 duty_cycle; enum pwm_polarity polarity; bool enabled; }; @@ -105,13 +105,13 @@ static inline bool pwm_is_enabled(const struct pwm_device *pwm) return state.enabled; } -static inline void pwm_set_period(struct pwm_device *pwm, unsigned int period) +static inline void pwm_set_period(struct pwm_device *pwm, u64 period) { if (pwm) pwm->state.period = period; } -static inline unsigned int pwm_get_period(const struct pwm_device *pwm) +static inline u64 pwm_get_period(const struct pwm_device *pwm) { struct pwm_state state; @@ -126,7 +126,7 @@ static inline void pwm_set_duty_cycle(struct pwm_device *pwm, unsigned int duty) pwm->state.duty_cycle = duty; } -static inline unsigned int pwm_get_duty_cycle(const struct pwm_device *pwm) +static inline u64 pwm_get_duty_cycle(const struct pwm_device *pwm) { struct pwm_state state; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project