[PATCH v2 3/4] nvmem: snvs_lpgpr: use cell stride for regmap size calculation

From: Nandor Han
Date: Wed Apr 28 2021 - 09:51:01 EST


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@xxxxxxxxxxx>
---
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