Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2770282ybh; Mon, 9 Mar 2020 12:37:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuXEQbKGqi6P8BmwrwNJ5OxIjbeRqoYnhCWXJzv3+F1mSxIWDcscRieDmHA0iyMwNEwC7za X-Received: by 2002:a05:6830:20c9:: with SMTP id z9mr3070916otq.44.1583782677024; Mon, 09 Mar 2020 12:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583782677; cv=none; d=google.com; s=arc-20160816; b=thadhRn4S3uXcrUHbD0//39TZeU5PpmhI07iJmGht5YMu+vw87quAHU+hmgb8tvWIA rBzmmhzco5AaPMvePAbaS53+OAtaoedx7OWQC3BHoEiUH2i1iuHbg8fIcK91XOXAK1u/ XKURcE4R5exQuJjaEZk/LlawQKnr2m4OGRIwmoYnOzR4kmM6tRKA7L+JlBRfWkWqNfF0 eVtQEu4RXrttauP3me+VhPqMY+eWhHdwjOlEJs04kPmu5nNQXWhOCVqcPKgH/5WCgogy 6OtrixCeMuwQNXG63VWMy6SKjDYc6hpdpUve1GRLVeZismOe5wx6jvj+6l29lmNPUPpk /QSA== 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=JJ2jcYQcanIRis8uKXQiQkwejwWOSLvly1GxKgzu35s=; b=eFSL371/Ci03W2Bb830Q6B0b0OvPS4+94MqkXvGqFkPMLXWRtoczDVgD2i90h61iXb LxPT+Wmu/YfdLkNhaJ536FaWeXqFSuiDGgby8aQ9FlALyTWWN4xG4J4tR1iQR1OK04Th vDF4JLlH8aDPSXZ+Ldhhdh46vBJpS0ZqZ3ylnZ/TA89nr771PNyGDAEqexLxIZsQtXqW jYy3gJ8/J1a+78iD5G/xLJevgiPzkTPcc3BrtPxnhghHB4/v7i9Ad5mNrFji0j5rZdfS z2/9S/8d6jSuOHjw4IgQHx9aLuV+ZllRdc+7nC9NURhBEZXT9dZGWHWBDqGJ86XEMUU8 CE5w== 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 b3si4609339oiy.82.2020.03.09.12.37.44; Mon, 09 Mar 2020 12:37:57 -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 S1726859AbgCITfx (ORCPT + 99 others); Mon, 9 Mar 2020 15:35:53 -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 S1726521AbgCITfX (ORCPT ); Mon, 9 Mar 2020 15:35:23 -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 CA6D54973; 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 , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Subject: [PATCH v7 06/13] pwm: pwm-imx-tpm: Use 64-bit division macros for period and duty cycle Date: Mon, 9 Mar 2020 12:35:09 -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: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Signed-off-by: Guru Das Srinagesh --- drivers/pwm/pwm-imx-tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 9145f61..53bf364 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -126,7 +126,7 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip, real_state->duty_cycle = state->duty_cycle; tmp = (u64)p->mod * real_state->duty_cycle; - p->val = DIV_ROUND_CLOSEST_ULL(tmp, real_state->period); + p->val = DIV64_U64_ROUND_CLOSEST(tmp, real_state->period); real_state->polarity = state->polarity; real_state->enabled = state->enabled; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project