mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 04/11] regmap: factor out regmap cdev size calculation
Date: Wed, 11 Jan 2023 14:29:49 +0100	[thread overview]
Message-ID: <20230111132956.1153359-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230111132956.1153359-1-a.fatoum@pengutronix.de>

We will add a new user of this calculate in a follow-up commit, so
make it available as a global function.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/base/regmap/regmap.c | 9 +++++++--
 include/regmap.h             | 2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 19f5356105f6..da20dc05828d 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -401,6 +401,12 @@ static struct cdev_operations regmap_fops = {
 	.write	= regmap_cdev_write,
 };
 
+size_t regmap_size_bytes(struct regmap *map)
+{
+	return regmap_round_val_bytes(map) * (map->max_register + 1) /
+		map->reg_stride;
+}
+
 /*
  * regmap_register_cdev - register a devfs file for a regmap
  *
@@ -428,8 +434,7 @@ int regmap_register_cdev(struct regmap *map, const char *name)
 			map->cdev.name = xstrdup(dev_name(map->dev));
 	}
 
-	map->cdev.size = regmap_round_val_bytes(map) * (map->max_register + 1) /
-			map->reg_stride;
+	map->cdev.size = regmap_size_bytes(map);
 	map->cdev.dev = map->dev;
 	map->cdev.ops = &regmap_fops;
 
diff --git a/include/regmap.h b/include/regmap.h
index 8f191c87cfcb..986ed391ab28 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -204,6 +204,8 @@ static inline int regmap_clear_bits(struct regmap *map,
 	return regmap_update_bits(map, reg, bits, 0);
 }
 
+size_t regmap_size_bytes(struct regmap *map);
+
 /**
  * regmap_read_poll_timeout - Poll until a condition is met or a timeout occurs
  *
-- 
2.30.2




  parent reply	other threads:[~2023-01-11 13:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 13:29 [PATCH v2 00/11] net: dsa: ksz9477: use regmap to add I2C support next to SPI Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 01/11] regmap: consolidate reg/val format into regmap_format Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 02/11] regmap: support formatted read and write Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 03/11] regmap: port regmap_init_spi Ahmad Fatoum
2023-01-11 13:29 ` Ahmad Fatoum [this message]
2023-01-11 13:29 ` [PATCH v2 05/11] net: dsa: ksz9477: switch to regmap_init_spi Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 06/11] net: dsa: ksz9477: create regmap cdev for switch registers Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 07/11] drivers: base: regmap: introduce REGMAP_I2C Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 08/11] dev: add dev_bus_is_spi/i2c helpers Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 09/11] net: dsa: ksz9477: refactor to prepare i2c support Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 10/11] regmap: i2c: use formatted I/O Ahmad Fatoum
2023-01-11 13:29 ` [PATCH v2 11/11] net: ksz9477: add I2C support Ahmad Fatoum
2023-01-12 14:58 ` [PATCH v2 00/11] net: dsa: ksz9477: use regmap to add I2C support next to SPI Sascha Hauer

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=20230111132956.1153359-5-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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