From: Nandor Han <nandor.han@vaisala.com>
To: srinivas.kandagatla@linaro.org, robh+dt@kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: Nandor Han <nandor.han@vaisala.com>
Subject: [PATCH v2 3/4] nvmem: snvs_lpgpr: use cell stride for regmap size calculation
Date: Wed, 28 Apr 2021 16:50:40 +0300 [thread overview]
Message-ID: <58cbd9be039086307790910045b17f37d40a7a86.1619617498.git.nandor.han@vaisala.com> (raw)
In-Reply-To: <cover.1619617498.git.nandor.han@vaisala.com>
Using a hard-coded value for calculating the number of registers to read
makes future changes more challenging.
Change the calculation to use the NVMEM cell stride instead of a hard
coded value. This will allow specifying different NVMEM cell sizes.
Signed-off-by: Nandor Han <nandor.han@vaisala.com>
---
drivers/nvmem/snvs_lpgpr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nvmem/snvs_lpgpr.c b/drivers/nvmem/snvs_lpgpr.c
index 4692aa985bd6..35457421314a 100644
--- a/drivers/nvmem/snvs_lpgpr.c
+++ b/drivers/nvmem/snvs_lpgpr.c
@@ -72,7 +72,7 @@ static int snvs_lpgpr_write(void *context, unsigned int offset, void *val,
return -EPERM;
return regmap_bulk_write(priv->regmap, dcfg->offset + offset, val,
- bytes / 4);
+ bytes / priv->cfg.stride);
}
static int snvs_lpgpr_read(void *context, unsigned int offset, void *val,
@@ -81,8 +81,8 @@ static int snvs_lpgpr_read(void *context, unsigned int offset, void *val,
struct snvs_lpgpr_priv *priv = context;
const struct snvs_lpgpr_cfg *dcfg = priv->dcfg;
- return regmap_bulk_read(priv->regmap, dcfg->offset + offset,
- val, bytes / 4);
+ return regmap_bulk_read(priv->regmap, dcfg->offset + offset, val,
+ bytes / priv->cfg.stride);
}
static int snvs_lpgpr_probe(struct platform_device *pdev)
--
2.26.3
next prev parent reply other threads:[~2021-04-28 13:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 13:50 [PATCH v2 0/4] Bootcount driver using NVMEM cell as backend Nandor Han
2021-04-28 13:50 ` [PATCH v2 1/4] dt-bindings: nvmem: Add bootcount-nvmem Nandor Han
2021-04-28 22:15 ` Rob Herring
2021-04-29 20:53 ` Rob Herring
2021-04-30 8:21 ` Nandor Han
2021-04-28 13:50 ` [PATCH v2 2/4] nvmem: bootcount: add bootcount driver Nandor Han
2021-04-28 13:50 ` Nandor Han [this message]
2021-04-28 13:50 ` [PATCH v2 4/4] nvmem: snvs_lpgpr: support two bytes NVMEM cell size Nandor Han
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58cbd9be039086307790910045b17f37d40a7a86.1619617498.git.nandor.han@vaisala.com \
--to=nandor.han@vaisala.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).