* [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers()
@ 2023-07-10 14:23 Andy Shevchenko
2023-07-10 14:34 ` Cristian Ciocaltea
2023-07-10 14:38 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-07-10 14:23 UTC (permalink / raw)
To: Cristian Ciocaltea, Andy Shevchenko, linux-kernel
Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki
Use spi_message_init_with_transfers() instead of open coded variants.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap-spi.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c
index 37ab23a9d034..65e8adac8d0e 100644
--- a/drivers/base/regmap/regmap-spi.c
+++ b/drivers/base/regmap/regmap-spi.c
@@ -43,9 +43,7 @@ static int regmap_spi_gather_write(void *context,
struct spi_transfer t[2] = { { .tx_buf = reg, .len = reg_len, },
{ .tx_buf = val, .len = val_len, }, };
- spi_message_init(&m);
- spi_message_add_tail(&t[0], &m);
- spi_message_add_tail(&t[1], &m);
+ spi_message_init_with_transfers(&m, t, 2);
return spi_sync(spi, &m);
}
@@ -66,10 +64,7 @@ static int regmap_spi_async_write(void *context,
async->t[1].tx_buf = val;
async->t[1].len = val_len;
- spi_message_init(&async->m);
- spi_message_add_tail(&async->t[0], &async->m);
- if (val)
- spi_message_add_tail(&async->t[1], &async->m);
+ spi_message_init_with_transfers(&async->m, async->t, val ? 2 : 1);
async->m.complete = regmap_spi_complete;
async->m.context = async;
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers()
2023-07-10 14:23 [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers() Andy Shevchenko
@ 2023-07-10 14:34 ` Cristian Ciocaltea
2023-07-10 14:38 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Cristian Ciocaltea @ 2023-07-10 14:34 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel
Cc: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki
On 7/10/23 17:23, Andy Shevchenko wrote:
> Use spi_message_init_with_transfers() instead of open coded variants.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers()
2023-07-10 14:23 [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers() Andy Shevchenko
2023-07-10 14:34 ` Cristian Ciocaltea
@ 2023-07-10 14:38 ` Mark Brown
2023-07-10 15:01 ` Andy Shevchenko
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2023-07-10 14:38 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Cristian Ciocaltea, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
On Mon, Jul 10, 2023 at 05:23:35PM +0300, Andy Shevchenko wrote:
> @@ -66,10 +64,7 @@ static int regmap_spi_async_write(void *context,
> async->t[1].tx_buf = val;
> async->t[1].len = val_len;
>
> - spi_message_init(&async->m);
> - spi_message_add_tail(&async->t[0], &async->m);
> - if (val)
> - spi_message_add_tail(&async->t[1], &async->m);
> + spi_message_init_with_transfers(&async->m, async->t, val ? 2 : 1);
I'm not sure this is a legibility win.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers()
2023-07-10 14:38 ` Mark Brown
@ 2023-07-10 15:01 ` Andy Shevchenko
2023-07-10 15:54 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2023-07-10 15:01 UTC (permalink / raw)
To: Mark Brown
Cc: Cristian Ciocaltea, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki
On Mon, Jul 10, 2023 at 03:38:55PM +0100, Mark Brown wrote:
> On Mon, Jul 10, 2023 at 05:23:35PM +0300, Andy Shevchenko wrote:
...
> > - spi_message_init(&async->m);
> > - spi_message_add_tail(&async->t[0], &async->m);
> > - if (val)
> > - spi_message_add_tail(&async->t[1], &async->m);
> > + spi_message_init_with_transfers(&async->m, async->t, val ? 2 : 1);
>
> I'm not sure this is a legibility win.
Fair enough. Since it's not an inlined call, ion x86_64 it gives +64 bytes
to the code.
Let's drop it.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers()
2023-07-10 15:01 ` Andy Shevchenko
@ 2023-07-10 15:54 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-07-10 15:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Cristian Ciocaltea, linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki
[-- Attachment #1: Type: text/plain, Size: 429 bytes --]
On Mon, Jul 10, 2023 at 06:01:47PM +0300, Andy Shevchenko wrote:
> On Mon, Jul 10, 2023 at 03:38:55PM +0100, Mark Brown wrote:
>
> > > + spi_message_init_with_transfers(&async->m, async->t, val ? 2 : 1);
> > I'm not sure this is a legibility win.
> Fair enough. Since it's not an inlined call, ion x86_64 it gives +64 bytes
> to the code.
> Let's drop it.
Sure. The ones without the ternery operator are fine.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-10 15:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10 14:23 [PATCH v1 1/1] regmap: spi: Use spi_message_init_with_transfers() Andy Shevchenko
2023-07-10 14:34 ` Cristian Ciocaltea
2023-07-10 14:38 ` Mark Brown
2023-07-10 15:01 ` Andy Shevchenko
2023-07-10 15:54 ` 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®