Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2885950rwb; Mon, 15 Aug 2022 13:18:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4lwLOd8FIvJtuWMtkyNqDAX/03MMUvT+quXAigg3uiah3QJ+CnvzE6RptblWQTlt8uEVeo X-Received: by 2002:a17:907:3e03:b0:722:e694:438 with SMTP id hp3-20020a1709073e0300b00722e6940438mr11628093ejc.755.1660594714217; Mon, 15 Aug 2022 13:18:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594714; cv=none; d=google.com; s=arc-20160816; b=mvRcqRQ8fInF3Gi1v0g5XdM7btYcIFIDvJPUcwAU6iCVUMU3+5haqiJPYk0BUGoKig kEpzMh+1grQjy1eS++svqQ3IAyTRlOiixDFJKmokLh/67X77MIy/O8voz6uqmNFovOu8 YtEWvyFiJlbiLAN/Vi979ucTS5aCaCIKD9BEWYUTZQ8YZfDIq6fOQ8bQHF1P6JI7K/ND /rbdnrRTxt6Z3SZVVVgIPMFZV84JJr8UjYrzmZxDqUoIONWoTuqRoxGG8MBRFx8U5SxP QfMZmw4YfX+VyxtBeL5oNMWv7+J5EM23d5dNSSDJd9ox9JFL5P/kBUrF029U6L7lMwP1 EP4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yaC83BIs6/lxh6LXE6OhZXp0M36Jq5bSuHpZkJgHxIc=; b=MUbNFXtP7+tCKeg3cAn1Hy9dIDPKwjY4IgtjGFOYbbdvebnYPCM4PLaea4wllD2DIi 6Tq9iGnL75yfp/gJP6KHGKYI8GObb7grJrkt/Da4SMp1fqrljHgfpCpzb1bXWwBSo70g Jga2K3RVCXcf/19Eoj+l4Y9J2JbHYE8fJ8ZwcJXSvWxlv/eOmT4V6m7BZP7sD1F2YV/j 4lCVVWIE1Wq/8b76oBgy8cjGNosCxbxFfAbEvW+zy/6I3bw84Zj98x59HEJ57Zko447Q ic8FSc2ihZkWRG+KAaDA+2wgC0mExl3TeHEj2bsHB5Ro1rbVMuz3hms9XDXaJqaJDQ0C rEeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uFT4n5HI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa7-20020a1709076d0700b00732f74ed931si9810068ejc.793.2022.08.15.13.18.07; Mon, 15 Aug 2022 13:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uFT4n5HI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243924AbiHOSr5 (ORCPT + 99 others); Mon, 15 Aug 2022 14:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242444AbiHOSmq (ORCPT ); Mon, 15 Aug 2022 14:42:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F287B2B634; Mon, 15 Aug 2022 11:26:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F21460FA2; Mon, 15 Aug 2022 18:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DA21C433C1; Mon, 15 Aug 2022 18:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587987; bh=vrIzN52GEEHh/T0R5cqvOZOYcnv5hQLjIKksDxnlmEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uFT4n5HIyD1iEfXfdW7qihANasROOk9E2lZIaV0fxDawrn5DH2XLHQ3RF61050N0X AMrKqUoBRRl4ZpriIJSlaXdhvD9dC3iKTRjJOivUjjqbyfTN4q+gkmm+V/nw+XJqrS YfsL4qiIrTMpnz+XE3XWuI2T9vHV0v5AOtFbzOlI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Emil Renner Berthing , Thierry Reding , Sasha Levin Subject: [PATCH 5.15 228/779] pwm: sifive: Simplify offset calculation for PWMCMP registers Date: Mon, 15 Aug 2022 19:57:52 +0200 Message-Id: <20220815180347.042370561@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Uwe Kleine-König [ Upstream commit 20550a61880fc55e68a0d290ad195b74729c0e7b ] Instead of explicitly using PWM_SIFIVE_PWMCMP0 + pwm->hwpwm * PWM_SIFIVE_SIZE_PWMCMP for each access to one of the PWMCMP registers, introduce a macro that takes the hwpwm id as parameter. For the register definition using a plain 4 instead of the cpp constant PWM_SIFIVE_SIZE_PWMCMP is easier to read, so define the offset macro without the constant. The latter can then be dropped as there are no users left. Signed-off-by: Uwe Kleine-König Tested-by: Emil Renner Berthing Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-sifive.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index 253c4a17d255..a55f7345dc87 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -23,7 +23,7 @@ #define PWM_SIFIVE_PWMCFG 0x0 #define PWM_SIFIVE_PWMCOUNT 0x8 #define PWM_SIFIVE_PWMS 0x10 -#define PWM_SIFIVE_PWMCMP0 0x20 +#define PWM_SIFIVE_PWMCMP(i) (0x20 + 4 * (i)) /* PWMCFG fields */ #define PWM_SIFIVE_PWMCFG_SCALE GENMASK(3, 0) @@ -36,8 +36,6 @@ #define PWM_SIFIVE_PWMCFG_GANG BIT(24) #define PWM_SIFIVE_PWMCFG_IP BIT(28) -/* PWM_SIFIVE_SIZE_PWMCMP is used to calculate offset for pwmcmpX registers */ -#define PWM_SIFIVE_SIZE_PWMCMP 4 #define PWM_SIFIVE_CMPWIDTH 16 #define PWM_SIFIVE_DEFAULT_PERIOD 10000000 @@ -112,8 +110,7 @@ static void pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); u32 duty, val; - duty = readl(ddata->regs + PWM_SIFIVE_PWMCMP0 + - pwm->hwpwm * PWM_SIFIVE_SIZE_PWMCMP); + duty = readl(ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm)); state->enabled = duty > 0; @@ -194,8 +191,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, pwm_sifive_update_clock(ddata, clk_get_rate(ddata->clk)); } - writel(frac, ddata->regs + PWM_SIFIVE_PWMCMP0 + - pwm->hwpwm * PWM_SIFIVE_SIZE_PWMCMP); + writel(frac, ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm)); if (state->enabled != enabled) pwm_sifive_enable(chip, state->enabled); -- 2.35.1