Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3083969rwb; Mon, 15 Aug 2022 17:44:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xHgg+AggpX/CSE/JpuTkebNdwBH9X8TwrPq4FxKDXERySta3UDfQA6KgzO9m3IUxa5xYE X-Received: by 2002:a17:902:7242:b0:171:398d:9e66 with SMTP id c2-20020a170902724200b00171398d9e66mr20036362pll.19.1660610652629; Mon, 15 Aug 2022 17:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610652; cv=none; d=google.com; s=arc-20160816; b=ATmDxIk04aHM71gvmldbbPWiXTtBS3U6snQeV8ufyzihTCeSrR3k//qqoajCi6FbdS kO+Y5QexKRKuFZq3VuIJBq9IgP8jKXhUe3ojaLuzM/x59Zs1sKL6zQkxGZmf5qK8E58b TSllh48nf7qZYG7tuzZbeaLUKdZt8KlrcfAsijiufRITwnFRsgOw8u9n9FfR/xYRI4lb /MaZOuWja1R0Xi0GSLVhlDxCbphXGybPzejRdlREYVR+YO5a01nVn9aXEZTbIVf3iF00 6EfOQGmQl2knBk4VEBqpyBfOhbRLRrQx1M+NsedUd2BvbBhVmbML2YnJ9iYCY6jhp3s2 MX2Q== 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=/u8jxZhWjl4YwRsC7jNZgUc1aJ9k8XnBDlO2+szC2jU=; b=OPuQFfy6V19dcxeRmvc/FnPW6qpQKXlErzXZt44JbfQ6SjfecFQE3isT1oiAbKcIOF p4fWSucG7zKUGIdwMtlvC8xbCGwtK3wGHSvGLjvqrHwRJyMf6ol5AWeGqVFZ/N7AP3xM 60RsQu80yVvNox0utxRj1Vef/KUkiGH0qalkLMBCh4GbbH1lpr6wbA9tOFnV0GvAihZP e7sKKo5cYepYZeQgyFZXz2FpALdq92nhRWSYRSCbpnEiNZ/19D/MQMG5vNnccbsdBq6i Hx1KrV2rLmiYsuMAdAiuU4yaI+Vizyp3VjystDJQkhZGbfQKZWE86m8uZR4rkZmgZKWG rH0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=byrLS6v6; 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 w2-20020a63d742000000b0041dd0c2ef5asi12303241pgi.421.2022.08.15.17.44.01; Mon, 15 Aug 2022 17:44:12 -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=byrLS6v6; 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 S244532AbiHOXNj (ORCPT + 99 others); Mon, 15 Aug 2022 19:13:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347465AbiHOXMo (ORCPT ); Mon, 15 Aug 2022 19:12:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3829E74366; Mon, 15 Aug 2022 13:00:40 -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 AD3126068D; Mon, 15 Aug 2022 20:00:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B60A1C433C1; Mon, 15 Aug 2022 20:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593639; bh=ryxwm41VWL2aK/agzC6JbMFIsiwDeS5/8sP4GLGrsqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byrLS6v6NgueAO4fjYyB73MTTqZIhewuh2n8itfy8Uqlt9OMFlKojQQQ+UV2/T+Y9 kfWx8m8k4apZ2e5aA2ExSekoID89aNE/mbSDwDotQ1pJl8AYP0FgX7X6Q2M9xLs4Qu oj3dw7qG/g6Ov2astaZJI/jX00Ibmh090N3i8NIQ= 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.19 0300/1157] pwm: sifive: Simplify offset calculation for PWMCMP registers Date: Mon, 15 Aug 2022 19:54:16 +0200 Message-Id: <20220815180451.648270404@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 e6d05a329002..b7fc33b08d82 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; @@ -193,8 +190,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