[v1,1/1] regmap: spi: Use spi_message_init_with_transfers()
Commit Message
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(-)
Comments
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>
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.
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.
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.
@@ -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;