Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2768797ybh; Mon, 9 Mar 2020 12:36:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs5WlHNV9QLHEFXActPTbRm90HoSPjYd6v9BhjEoF6I6rJUiJei8jGmObEBVddZnk0X98ax X-Received: by 2002:a9d:6f14:: with SMTP id n20mr14040964otq.271.1583782575702; Mon, 09 Mar 2020 12:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583782575; cv=none; d=google.com; s=arc-20160816; b=BQud8fwtBSLXfu7N+s2GYjRC7sPMfxmXxX7MgwSt2iU/uNEJxz3DrrX1Wq55Y5FA+K j/V0cZxxJJwqRsgKcBVQnfr1hyrEMdPc4ttkQDQm69oS1vigv3sUJ1V/1mzZI3PQsXfe jyZ1FKgq/dFlCXd9c7LAZpRXDnvIy+Hwu3YQJ8ZBR5OFXEc7Co9J8dTQuBTR5m0CXaRU 6V0JKydnkOBmNlvC6aUX6qcfO2B5CfVvxnkyrnC+bl30bqFlxN7IlT0KYM+K1Goitlth iDKjHubQ9ukprfByVqZIxgkawiZ/h7GSe1Ku3nhe2FYkAsiiQgRkgrQvkcuj82TVvvMi bA3Q== 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=Y2ngzn6M7oR5aJj/LIrhEYGJxv12HEFUoaYYVkJJZNQ=; b=t89rlSMLZqI1WIFpGPzL8Vwtt3lCfcUCB1PCoFO51kYmXG7sz5dZ6kC4gfIZ+9y8rM kQ5DiCCd8wEyuMmhT6hSLLN8MnZn29wq/zZqZuG/BU4tdMiO1qnZTpnk4ukgHSQRz5jH 2LmVsTn3+3p8RKYLMf25RAoJioqXqdaaQpvszGM5OmvePhJD3K1SAmoYgpITyRI2j1sA DlW8WqEla2kX4tZqDe3kuNzCYHNm3p+tei05aUfEXlmMqAZcvlCs2/nishMWHV7Yjyw9 w6P2eV8U94YnSjTEukfmIFyFlVpwbtDG2V70X02CqR2TEfphQ449Yvbb9WeWYQ234dVg Vu0g== 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 q4si6488358oth.163.2020.03.09.12.36.02; Mon, 09 Mar 2020 12:36:15 -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 S1726677AbgCITf2 (ORCPT + 99 others); Mon, 9 Mar 2020 15:35:28 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:22384 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbgCITfY (ORCPT ); Mon, 9 Mar 2020 15:35:24 -0400 Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) 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 ironmsg05-sd.qualcomm.com with ESMTP; 09 Mar 2020 12:35:20 -0700 Received: by gurus-linux.qualcomm.com (Postfix, from userid 383780) id AF5EB4A19; 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 , Mauro Carvalho Chehab , Richard Fontana , Thomas Gleixner , Kate Stewart , Allison Randal , linux-media@vger.kernel.org Subject: [PATCH v7 04/13] ir-rx51: Use 64-bit division macros for period and duty cycle Date: Mon, 9 Mar 2020 12:35:07 -0700 Message-Id: <22ae6da55c914f9434fc7871a51524d03317646f.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 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: Mauro Carvalho Chehab Cc: Richard Fontana Cc: Thomas Gleixner Cc: Kate Stewart Cc: Allison Randal Cc: linux-media@vger.kernel.org Signed-off-by: Guru Das Srinagesh --- drivers/media/rc/ir-rx51.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/ir-rx51.c b/drivers/media/rc/ir-rx51.c index 8574eda..9a5dfd7 100644 --- a/drivers/media/rc/ir-rx51.c +++ b/drivers/media/rc/ir-rx51.c @@ -241,7 +241,8 @@ static int ir_rx51_probe(struct platform_device *dev) } /* Use default, in case userspace does not set the carrier */ - ir_rx51.freq = DIV_ROUND_CLOSEST(pwm_get_period(pwm), NSEC_PER_SEC); + ir_rx51.freq = DIV_ROUND_CLOSEST_ULL(pwm_get_period(pwm), + NSEC_PER_SEC); pwm_put(pwm); hrtimer_init(&ir_rx51.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project