mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size
@ 2021-10-21 13:27 André Almeida
  2021-10-21 13:54 ` Mark Brown
  2021-10-23 19:58 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: André Almeida @ 2021-10-21 13:27 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-kernel, kernel, Lucas Tanure, Charles Keepax, André Almeida

From: Lucas Tanure <tanureal@opensource.cirrus.com>

Set regmap raw read/write from spi max_transfer_size
so regmap_raw_read/write can split the access into chunks

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
[André: fix build warning]
Signed-off-by: André Almeida <andrealmeid@collabora.com>
---
Changes from v2:
- Fix build warning
v2: https://lore.kernel.org/lkml/20210913130101.1577964-1-tanureal@opensource.cirrus.com/

 drivers/base/regmap/regmap-spi.c | 36 ++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c
index c1894e93c378..719323bc6c7f 100644
--- a/drivers/base/regmap/regmap-spi.c
+++ b/drivers/base/regmap/regmap-spi.c
@@ -109,13 +109,37 @@ static const struct regmap_bus regmap_spi = {
 	.val_format_endian_default = REGMAP_ENDIAN_BIG,
 };
 
+static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi,
+						   const struct regmap_config *config)
+{
+	size_t max_size = spi_max_transfer_size(spi);
+	struct regmap_bus *bus;
+
+	if (max_size != SIZE_MAX) {
+		bus = kmemdup(&regmap_spi, sizeof(*bus), GFP_KERNEL);
+		if (!bus)
+			return ERR_PTR(-ENOMEM);
+
+		bus->free_on_exit = true;
+		bus->max_raw_read = max_size;
+		bus->max_raw_write = max_size;
+		return bus;
+	}
+
+	return &regmap_spi;
+}
+
 struct regmap *__regmap_init_spi(struct spi_device *spi,
 				 const struct regmap_config *config,
 				 struct lock_class_key *lock_key,
 				 const char *lock_name)
 {
-	return __regmap_init(&spi->dev, &regmap_spi, &spi->dev, config,
-			     lock_key, lock_name);
+	const struct regmap_bus *bus = regmap_get_spi_bus(spi, config);
+
+	if (IS_ERR(bus))
+		return ERR_CAST(bus);
+
+	return __regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name);
 }
 EXPORT_SYMBOL_GPL(__regmap_init_spi);
 
@@ -124,8 +148,12 @@ struct regmap *__devm_regmap_init_spi(struct spi_device *spi,
 				      struct lock_class_key *lock_key,
 				      const char *lock_name)
 {
-	return __devm_regmap_init(&spi->dev, &regmap_spi, &spi->dev, config,
-				  lock_key, lock_name);
+	const struct regmap_bus *bus = regmap_get_spi_bus(spi, config);
+
+	if (IS_ERR(bus))
+		return ERR_CAST(bus);
+
+	return __devm_regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name);
 }
 EXPORT_SYMBOL_GPL(__devm_regmap_init_spi);
 
-- 
2.33.1


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

* Re: [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size
  2021-10-21 13:27 [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size André Almeida
@ 2021-10-21 13:54 ` Mark Brown
  2021-10-21 13:56   ` André Almeida
  2021-10-23 19:58 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2021-10-21 13:54 UTC (permalink / raw)
  To: André Almeida
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel, kernel,
	Lucas Tanure, Charles Keepax

[-- Attachment #1: Type: text/plain, Size: 327 bytes --]

On Thu, Oct 21, 2021 at 10:27:21AM -0300, André Almeida wrote:

> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> [André: fix build warning]
> Signed-off-by: André Almeida <andrealmeid@collabora.com>

It wasn't just a warning, as I told Lucas it was a build error given
that allmodconfig now has -Werror.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size
  2021-10-21 13:54 ` Mark Brown
@ 2021-10-21 13:56   ` André Almeida
  2021-10-21 14:32     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: André Almeida @ 2021-10-21 13:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel, kernel,
	Lucas Tanure, Charles Keepax

Às 10:54 de 21/10/21, Mark Brown escreveu:
> On Thu, Oct 21, 2021 at 10:27:21AM -0300, André Almeida wrote:
> 
>> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
>> [André: fix build warning]
>> Signed-off-by: André Almeida <andrealmeid@collabora.com>
> 
> It wasn't just a warning, as I told Lucas it was a build error given
> that allmodconfig now has -Werror.
> 

Ok, I didn't know that -Werror was around. Should I resend the patch
with [André: fix build error]?

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

* Re: [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size
  2021-10-21 13:56   ` André Almeida
@ 2021-10-21 14:32     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-10-21 14:32 UTC (permalink / raw)
  To: André Almeida
  Cc: Greg Kroah-Hartman, Rafael J . Wysocki, linux-kernel, kernel,
	Lucas Tanure, Charles Keepax

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

On Thu, Oct 21, 2021 at 10:56:21AM -0300, André Almeida wrote:
> Às 10:54 de 21/10/21, Mark Brown escreveu:

> > It wasn't just a warning, as I told Lucas it was a build error given
> > that allmodconfig now has -Werror.

> Ok, I didn't know that -Werror was around. Should I resend the patch
> with [André: fix build error]?

No, it doesn't make any practical difference.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size
  2021-10-21 13:27 [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size André Almeida
  2021-10-21 13:54 ` Mark Brown
@ 2021-10-23 19:58 ` Mark Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-10-23 19:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, André Almeida, Rafael J . Wysocki
  Cc: Mark Brown, kernel, linux-kernel, Lucas Tanure, Charles Keepax

On Thu, 21 Oct 2021 10:27:21 -0300, André Almeida wrote:
> From: Lucas Tanure <tanureal@opensource.cirrus.com>
> 
> Set regmap raw read/write from spi max_transfer_size
> so regmap_raw_read/write can split the access into chunks
> 
> 

Applied to

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

Thanks!

[1/1] regmap: spi: Set regmap max raw r/w from max_transfer_size
      commit: f231ff38b7b23197013b437128d196710fe282da

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] 5+ messages in thread

end of thread, other threads:[~2021-10-23 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 13:27 [PATCH v3] regmap: spi: Set regmap max raw r/w from max_transfer_size André Almeida
2021-10-21 13:54 ` Mark Brown
2021-10-21 13:56   ` André Almeida
2021-10-21 14:32     ` Mark Brown
2021-10-23 19:58 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®