Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp718483ybz; Wed, 15 Apr 2020 17:25:55 -0700 (PDT) X-Google-Smtp-Source: APiQypKnEv1ksZYIFBmP2AgwR1Co+CWU7JgKgXJocXp3j1iyRSPHpWfuZpUYCrdmczr2SeHPLjh1 X-Received: by 2002:a50:e007:: with SMTP id e7mr27474231edl.361.1586996755593; Wed, 15 Apr 2020 17:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996755; cv=none; d=google.com; s=arc-20160816; b=JH9Wn+2vQX2Oz3cSz0ir+BKgzILBtK3F9WdS5V5QxGtOSC0MNXoYMh7s4J7jPFIEsh DwHuEakSqe5Q8aBKO+cTjrnq0WFZkEUXz1sDeDVzHdm+TNv2JpnZG9EFUSKqIG5Z2WKy 9i9xwEgUpJIWFlPr1RdY0+UCdovKz0Vy0FmFu+KEeRgkWc+cz8j+CtdeX6Mu2juhe317 Hg/sh8hpATFysQ8MTCvNS218+KaxAdTZmoluxU1EsSKelKmaUwAn0/RbUyHH75n8Y0Jw dyglLX29k9PSNGnX7/4q/YFzzgrZZ+pwcDNQ4zRVGFkFiPdH4054WIIzMcoK1bxQzKc6 zMtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0zz7rP3DWvUJ/VdB/uYLN17A7qtq95b2KZVxc0CNxN8=; b=rrkrpP/w2sHoUwUvVUzpLXRdCuC8R5lAEbm+A2DJmTDdcOx55GsmOVDkJLPIrRvuDI KFFBCeQUKOuZgw1AwG2LffY9McKSezIuBpDFdZlgWXrYIEZWit2TsWoWmGuE/dqMiOLT b0agPzjhyHHRCYvoE32s2Y+iHEaQrMKvALCRPwx5lY5zihJHSwmz9bRLTaTbi+5PT3o6 A/LHKWCz52S7+F60/hYp0NCpftrUpSDfgIiApO0euvaYm+jK4z5gKymviMr8450S53QA j7B62lgb9HFpClnaEB6/SuPx9OnWXczD5ttchVSGBO3/BpLpUuJ4PZwpuzhG9Kqf+uid w1Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nMScmT1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si10883333edk.466.2020.04.15.17.25.31; Wed, 15 Apr 2020 17:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nMScmT1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2410603AbgDORA7 (ORCPT + 99 others); Wed, 15 Apr 2020 13:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728755AbgDORAw (ORCPT ); Wed, 15 Apr 2020 13:00:52 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C136FC061A0C for ; Wed, 15 Apr 2020 10:00:52 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id nu11so106639pjb.1 for ; Wed, 15 Apr 2020 10:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0zz7rP3DWvUJ/VdB/uYLN17A7qtq95b2KZVxc0CNxN8=; b=nMScmT1YfkHnp5d9ktcd27MszVIt1dzN6BZYoV9+sCpGotbOhmNHMTymZ/mgfEzo2/ XQFEjXL/GcQz3TOQgZwOJMDQoP0vJrYGaQg6Dy9WRYnzJXT529pfOdBeFcnv5eO59T8j Uo1C6C+kEOvLzXqU9/EmZjhlh3ApbvGerYBKI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0zz7rP3DWvUJ/VdB/uYLN17A7qtq95b2KZVxc0CNxN8=; b=S2pMXz6Nn+SzbSTYukdB0e3svCXmnRrnaBRP39mqnsr35Tjd+50Vcbml5dTDd6KJMl smjIbagmF5q3HWius6Ne97PDRFekVLK06bs4LkKd3FtDVj8lzxbaNJe/At2EgZCa/NQI uyRNcBPh95bFC/rJ1iZYTjomAEQ/Ija8yw/F5pdHYc7DRSx5lRZsxO+o7gZ5QmJWjTca 5ociv6lXLv1p0z8XsSYXuxODqyZpEFwAq/q0mtxuiy4dW0nYkx+HseiHjB6SKysDVlV+ 0wbnEz7xruj+xS4zAx95Yc6OT59Zh/zp03lgpKgJjpGU15rwAfZCKsoGtucUN2yte49P BzVA== X-Gm-Message-State: AGi0PubLyPd7OoEN+wNihom8iGTV+Idnu0aFZNZfeBEvVkcu0oBzNdQl q/nc61UrSg1EC/R5ayL422/mNQ== X-Received: by 2002:a17:902:322:: with SMTP id 31mr5876290pld.103.1586970049865; Wed, 15 Apr 2020 10:00:49 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id i187sm14203509pfg.33.2020.04.15.10.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 10:00:49 -0700 (PDT) From: Douglas Anderson To: Andy Gross , Bjorn Andersson Cc: mkshah@codeaurora.org, mka@chromium.org, joe@perches.com, swboyd@chromium.org, evgreen@chromium.org, Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation Date: Wed, 15 Apr 2020 10:00:27 -0700 Message-Id: <20200415095953.v3.1.Ic70288f256ff0be65cac6a600367212dfe39f6c9@changeid> X-Mailer: git-send-email 2.26.0.110.g2183baf09c-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can make some of the register access functions more readable by factoring out the calculations a little bit. Suggested-by: Joe Perches Signed-off-by: Douglas Anderson Reviewed-by: Stephen Boyd --- Changes in v3: None Changes in v2: - Make drv parameter const. drivers/soc/qcom/rpmh-rsc.c | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index a9e15699f55f..ce39d8399312 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -137,36 +137,47 @@ * +---------------------------------------------------+ */ -static u32 read_tcs_cmd(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id) +static inline void __iomem * +tcs_reg_addr(const struct rsc_drv *drv, int reg, int tcs_id) { - return readl_relaxed(drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg + - RSC_DRV_CMD_OFFSET * cmd_id); + return drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg; } -static u32 read_tcs_reg(struct rsc_drv *drv, int reg, int tcs_id) +static inline void __iomem * +tcs_cmd_addr(const struct rsc_drv *drv, int reg, int tcs_id, int cmd_id) { - return readl_relaxed(drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg); + return tcs_reg_addr(drv, reg, tcs_id) + RSC_DRV_CMD_OFFSET * cmd_id; } -static void write_tcs_cmd(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id, - u32 data) +static u32 read_tcs_cmd(const struct rsc_drv *drv, int reg, int tcs_id, + int cmd_id) +{ + return readl_relaxed(tcs_cmd_addr(drv, reg, tcs_id, cmd_id)); +} + +static u32 read_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id) { - writel_relaxed(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg + - RSC_DRV_CMD_OFFSET * cmd_id); + return readl_relaxed(tcs_reg_addr(drv, reg, tcs_id)); } -static void write_tcs_reg(struct rsc_drv *drv, int reg, int tcs_id, u32 data) +static void write_tcs_cmd(const struct rsc_drv *drv, int reg, int tcs_id, + int cmd_id, u32 data) +{ + writel_relaxed(data, tcs_cmd_addr(drv, reg, tcs_id, cmd_id)); +} + +static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id, + u32 data) { - writel_relaxed(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg); + writel_relaxed(data, tcs_reg_addr(drv, reg, tcs_id)); } -static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id, +static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, u32 data) { - writel(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg); + writel(data, tcs_reg_addr(drv, reg, tcs_id)); for (;;) { - if (data == readl(drv->tcs_base + reg + - RSC_DRV_TCS_OFFSET * tcs_id)) + if (data == readl(tcs_reg_addr(drv, reg, tcs_id))) break; udelay(1); } -- 2.26.0.110.g2183baf09c-goog