lkml.org 
[lkml]   [2021]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/4] nvmem: snvs_lpgpr: use cell stride for regmap size calculation
Date
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
\
 
 \ /
  Last update: 2021-04-27 10:28    [W:0.075 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site