Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2769762ybh; Mon, 9 Mar 2020 12:37:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuR2SsbzCKIIXZaudXdg0jUUa/STiDW5RQXTFVp4LgHXXuNayWFkDJyvbyIQ/CpWotPFA+S X-Received: by 2002:aca:5508:: with SMTP id j8mr608111oib.71.1583782636151; Mon, 09 Mar 2020 12:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583782636; cv=none; d=google.com; s=arc-20160816; b=nsJKyOIcNg7rXzWBoi+hlSgPRsZCttV1unsN2mghw84FxL+LpZv77E3ZqRo0Sxuf4+ 6WLXcaS6mRKxNmvd0QWtloWlswFTG6E+nfb4JztrgB8sk7oQ117hle9YtlCj4o6dEbbA aDmkk6CcdGSqh1xpUK+RNqv07iE2W21pObFzBayobG4KuCYRQkZXBNZKbn2rxFTCcuQN yjPJTQSHNHi6jF5FrTYF3jFp2rZtMHZfYUS2/3do6D3PpzL5S2wqdR4IRw5XEaCmuqju +CoF7pBUtQC4UnBU52on51Zpn4l2CHJzZc3N14Lb9XCvqYSYXd+KMtIF6rDSoFhDvoyR 3SBg== 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=hQAeGkjY9qZAFdK5gcWN03z6Zo9mFXUA0hmt7UHWb4w=; b=CtYPuTNzYZV8GQMxsmBUP3mGQPCYumpqv+tfF8twSNeW0K98Ek/uDWS619pkJnD9bC XpXWlLhWwvg59+hop3L7UJnOpVSw+9lhpQ/QYiLDLTCdih9pWRAqUG2QK6kpy3I4RHmf 70hPTvTyBa6szInOMwnlalnif8Zr1zX2s5KX8xYa3w51BYOGda9GcB8auRxp6+qMXgLm 80w2xesKsd1efWtpWUd4cFHkEnbSkYgVNNTO8rttd/JmXdV+FExucmqBt+3e3rjNSq7w a5ALEZGYJ9sSs2f1bAdY2H+ZmCPopU4XUywMVZpFWm2CNKSiJzMDR11AUflrx48DCE+1 hkNw== 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 x9si1400840oia.194.2020.03.09.12.37.01; Mon, 09 Mar 2020 12:37:16 -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 S1726530AbgCITfX (ORCPT + 99 others); Mon, 9 Mar 2020 15:35:23 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:22361 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgCITfW (ORCPT ); Mon, 9 Mar 2020 15:35:22 -0400 Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-02.qualcomm.com with ESMTP; 09 Mar 2020 12:35:21 -0700 Received: from gurus-linux.qualcomm.com ([10.46.162.81]) by ironmsg01-sd.qualcomm.com with ESMTP; 09 Mar 2020 12:35:21 -0700 Received: by gurus-linux.qualcomm.com (Postfix, from userid 383780) id F3EF04973; Mon, 9 Mar 2020 12:35:20 -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 , Lee Jones Subject: [PATCH v7 09/13] pwm: sti: Use 64-bit division macros for period and duty cycle Date: Mon, 9 Mar 2020 12:35:12 -0700 Message-Id: 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 in the PWM framework structs as ints with units of nanoseconds, the maximum time duration that can be set is limited to ~2.147 seconds. Redefining them as u64 values will enable larger time durations to be set. As a first step, prepare drivers to handle the switch to u64 period and duty_cycle by replacing division operations involving pwm period and duty cycle with their 64-bit equivalents as appropriate. The actual switch to u64 period and duty_cycle follows as a separate patch. Where the dividend is 64-bit but the divisor is 32-bit, use *_ULL macros: - DIV_ROUND_UP_ULL - DIV_ROUND_CLOSEST_ULL - div_u64 Where the divisor is 64-bit (dividend may be 32-bit or 64-bit), use DIV64_* macros: - DIV64_U64_ROUND_CLOSEST - div64_u64 Cc: Lee Jones Signed-off-by: Guru Das Srinagesh --- drivers/pwm/pwm-sti.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index 1508616..5a7f337 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -371,10 +371,11 @@ static int sti_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm, effective_ticks = clk_get_rate(pc->cpt_clk); result->period = (high + low) * NSEC_PER_SEC; - result->period /= effective_ticks; + result->period = div_u64(result->period, effective_ticks); result->duty_cycle = high * NSEC_PER_SEC; - result->duty_cycle /= effective_ticks; + result->duty_cycle = div_u64(result->duty_cycle, + effective_ticks); break; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project