All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support
@ 2022-06-16  7:34 Javier Martinez Canillas
  2022-06-16  7:34 ` [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read() Javier Martinez Canillas
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Javier Martinez Canillas @ 2022-06-16  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Javier Martinez Canillas, Greg Kroah-Hartman,
	Mark Brown, Rafael J. Wysocki

Hello,

This series contains fixes for a few issues found while testing the recent
support for drivers to define bulk read/write callbacks in regmap_config.

I tested this with drivers/gpu/drm/solomon/ssd130x-spi.c, by converting it
to use this new API instead of defining its own regmap bus for bulk write.

Patch #1 and patch #2 are fixes for regresions introduced by that commit
and patch #3 adds regmap_config provided bulk write support to functions
regmap_noinc_write() and regmap_bulk_write(), that were missed.

Best regards,
Javier


Javier Martinez Canillas (3):
  regmap: Re-introduce bulk read support check in regmap_bulk_read()
  regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't
    set
  regmap: Wire up regmap_config provided bulk write in missed functions

 drivers/base/regmap/regmap.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.36.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read()
  2022-06-16  7:34 [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Javier Martinez Canillas
@ 2022-06-16  7:34 ` Javier Martinez Canillas
  2022-06-18 22:58   ` Marek Vasut
  2022-06-16  7:34 ` [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set Javier Martinez Canillas
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Javier Martinez Canillas @ 2022-06-16  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Javier Martinez Canillas, Greg Kroah-Hartman,
	Mark Brown, Rafael J. Wysocki

Support for drivers to define bulk read/write callbacks in regmap_config
was introduced by the commit d77e74561368 ("regmap: Add bulk read/write
callbacks into regmap_config"), but this commit wrongly dropped a check
in regmap_bulk_read() to determine whether bulk reads can be done or not.

Before that commit, it was checked if map->bus was set. Now has to check
if a map->read callback has been set.

Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/base/regmap/regmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 2221d9863831..e5bb70374ffc 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -3017,7 +3017,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 	if (val_count == 0)
 		return -EINVAL;
 
-	if (map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
+	if (map->read && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
 		ret = regmap_raw_read(map, reg, val, val_bytes * val_count);
 		if (ret != 0)
 			return ret;
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set
  2022-06-16  7:34 [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Javier Martinez Canillas
  2022-06-16  7:34 ` [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read() Javier Martinez Canillas
@ 2022-06-16  7:34 ` Javier Martinez Canillas
  2022-06-18 22:58   ` Marek Vasut
  2022-06-16  7:34 ` [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions Javier Martinez Canillas
  2022-06-20 15:40 ` [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Mark Brown
  3 siblings, 1 reply; 8+ messages in thread
From: Javier Martinez Canillas @ 2022-06-16  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Javier Martinez Canillas, Greg Kroah-Hartman,
	Mark Brown, Rafael J. Wysocki

Before adding support to define bulk read/write callbacks in regmap_config
by the commit d77e74561368 ("regmap: Add bulk read/write callbacks into
regmap_config"), the regmap_noinc_read() function returned an errno early
a map->bus->read callback wasn't set.

But that commit dropped the check and now a call to _regmap_raw_read() is
attempted even when bulk read operations are not supported. That function
checks for map->read anyways but there's no point to continue if the read
can't succeed.

Also is a fragile assumption to make so is better to make it fail earlier.

Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/base/regmap/regmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e5bb70374ffc..f37f80a52115 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2904,6 +2904,9 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg,
 	size_t read_len;
 	int ret;
 
+	if (!map->read)
+		return -ENOTSUPP;
+
 	if (val_len % map->format.val_bytes)
 		return -EINVAL;
 	if (!IS_ALIGNED(reg, map->reg_stride))
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions
  2022-06-16  7:34 [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Javier Martinez Canillas
  2022-06-16  7:34 ` [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read() Javier Martinez Canillas
  2022-06-16  7:34 ` [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set Javier Martinez Canillas
@ 2022-06-16  7:34 ` Javier Martinez Canillas
  2022-06-18 23:02   ` Marek Vasut
  2022-06-20 15:40 ` [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Mark Brown
  3 siblings, 1 reply; 8+ messages in thread
From: Javier Martinez Canillas @ 2022-06-16  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Javier Martinez Canillas, Greg Kroah-Hartman,
	Mark Brown, Rafael J. Wysocki

There are some functions that were missed by commit d77e74561368 ("regmap:
Add bulk read/write callbacks into regmap_config") when support to define
bulk read/write callbacks in regmap_config was introduced.

The regmap_bulk_write() and regmap_noinc_write() functions weren't changed
to use the added map->write instead of the map->bus->write handler.

Also, the regmap_can_raw_write() was not modified to take map->write into
account. So will only return true if a bus with a .write callback is set.

Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

 drivers/base/regmap/regmap.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index f37f80a52115..c3517ccc3159 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1880,8 +1880,7 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
  */
 bool regmap_can_raw_write(struct regmap *map)
 {
-	return map->bus && map->bus->write && map->format.format_val &&
-		map->format.format_reg;
+	return map->write && map->format.format_val && map->format.format_reg;
 }
 EXPORT_SYMBOL_GPL(regmap_can_raw_write);
 
@@ -2155,10 +2154,9 @@ int regmap_noinc_write(struct regmap *map, unsigned int reg,
 	size_t write_len;
 	int ret;
 
-	if (!map->bus)
-		return -EINVAL;
-	if (!map->bus->write)
+	if (!map->write)
 		return -ENOTSUPP;
+
 	if (val_len % map->format.val_bytes)
 		return -EINVAL;
 	if (!IS_ALIGNED(reg, map->reg_stride))
@@ -2278,7 +2276,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
 	 * Some devices don't support bulk write, for them we have a series of
 	 * single write operations.
 	 */
-	if (!map->bus || !map->format.parse_inplace) {
+	if (!map->write || !map->format.parse_inplace) {
 		map->lock(map->lock_arg);
 		for (i = 0; i < val_count; i++) {
 			unsigned int ival;
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read()
  2022-06-16  7:34 ` [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read() Javier Martinez Canillas
@ 2022-06-18 22:58   ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2022-06-18 22:58 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Greg Kroah-Hartman, Mark Brown, Rafael J. Wysocki

On 6/16/22 09:34, Javier Martinez Canillas wrote:
> Support for drivers to define bulk read/write callbacks in regmap_config
> was introduced by the commit d77e74561368 ("regmap: Add bulk read/write
> callbacks into regmap_config"), but this commit wrongly dropped a check
> in regmap_bulk_read() to determine whether bulk reads can be done or not.
> 
> Before that commit, it was checked if map->bus was set. Now has to check
> if a map->read callback has been set.
> 
> Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set
  2022-06-16  7:34 ` [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set Javier Martinez Canillas
@ 2022-06-18 22:58   ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2022-06-18 22:58 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Greg Kroah-Hartman, Mark Brown, Rafael J. Wysocki

On 6/16/22 09:34, Javier Martinez Canillas wrote:
> Before adding support to define bulk read/write callbacks in regmap_config
> by the commit d77e74561368 ("regmap: Add bulk read/write callbacks into
> regmap_config"), the regmap_noinc_read() function returned an errno early
> a map->bus->read callback wasn't set.
> 
> But that commit dropped the check and now a call to _regmap_raw_read() is
> attempted even when bulk read operations are not supported. That function
> checks for map->read anyways but there's no point to continue if the read
> can't succeed.
> 
> Also is a fragile assumption to make so is better to make it fail earlier.
> 
> Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions
  2022-06-16  7:34 ` [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions Javier Martinez Canillas
@ 2022-06-18 23:02   ` Marek Vasut
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2022-06-18 23:02 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: Greg Kroah-Hartman, Mark Brown, Rafael J. Wysocki

On 6/16/22 09:34, Javier Martinez Canillas wrote:
> There are some functions that were missed by commit d77e74561368 ("regmap:
> Add bulk read/write callbacks into regmap_config") when support to define
> bulk read/write callbacks in regmap_config was introduced.
> 
> The regmap_bulk_write() and regmap_noinc_write() functions weren't changed
> to use the added map->write instead of the map->bus->write handler.
> 
> Also, the regmap_can_raw_write() was not modified to take map->write into
> account. So will only return true if a bus with a .write callback is set.
> 
> Fixes: d77e74561368 ("regmap: Add bulk read/write callbacks into regmap_config")
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support
  2022-06-16  7:34 [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Javier Martinez Canillas
                   ` (2 preceding siblings ...)
  2022-06-16  7:34 ` [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions Javier Martinez Canillas
@ 2022-06-20 15:40 ` Mark Brown
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-06-20 15:40 UTC (permalink / raw)
  To: javierm, linux-kernel; +Cc: marex, rafael, gregkh

On Thu, 16 Jun 2022 09:34:32 +0200, Javier Martinez Canillas wrote:
> This series contains fixes for a few issues found while testing the recent
> support for drivers to define bulk read/write callbacks in regmap_config.
> 
> I tested this with drivers/gpu/drm/solomon/ssd130x-spi.c, by converting it
> to use this new API instead of defining its own regmap bus for bulk write.
> 
> Patch #1 and patch #2 are fixes for regresions introduced by that commit
> and patch #3 adds regmap_config provided bulk write support to functions
> regmap_noinc_write() and regmap_bulk_write(), that were missed.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read()
      commit: 5ac01e023a1b0492e159ad2f6734e0a350c1b6b6
[2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set
      commit: f6e5c3850d1174bf3ca53457d64e6665f48c9041
[3/3] regmap: Wire up regmap_config provided bulk write in missed functions
      commit: 1db43c8ad90ce07311a3ef9af7ace758d79224f9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-20 15:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16  7:34 [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Javier Martinez Canillas
2022-06-16  7:34 ` [PATCH 1/3] regmap: Re-introduce bulk read support check in regmap_bulk_read() Javier Martinez Canillas
2022-06-18 22:58   ` Marek Vasut
2022-06-16  7:34 ` [PATCH 2/3] regmap: Make regmap_noinc_read() return -ENOTSUPP if map->read isn't set Javier Martinez Canillas
2022-06-18 22:58   ` Marek Vasut
2022-06-16  7:34 ` [PATCH 3/3] regmap: Wire up regmap_config provided bulk write in missed functions Javier Martinez Canillas
2022-06-18 23:02   ` Marek Vasut
2022-06-20 15:40 ` [PATCH 0/3] remap: Some fixes for bulk read/write callbacks in regmap_config support Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.