2023-07-10 16:32:57

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH v2 09/15] spi: Use struct_size() helper

On 10.07.2023 18:49:26, Andy Shevchenko wrote:
> Prefer struct_size() over open-coded versions.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> include/linux/spi/spi.h | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> index c9479badf38c..9fb8efb068c6 100644
> --- a/include/linux/spi/spi.h
> +++ b/include/linux/spi/spi.h
> @@ -17,6 +17,7 @@
> #include <linux/minmax.h>
> #include <linux/mod_devicetable.h>
> #include <linux/mutex.h>
> +#include <linux/overflow.h>
> #include <linux/scatterlist.h>
> #include <linux/slab.h>
> #include <linux/smp.h>
> @@ -1095,6 +1096,8 @@ struct spi_transfer {
> * @state: for use by whichever driver currently owns the message
> * @resources: for resource management when the spi message is processed
> * @prepared: spi_prepare_message was called for the this message
> + * @t: for use with spi_message_alloc() when message and transfers have
> + * been allocated together
> *
> * A @spi_message is used to execute an atomic sequence of data transfers,
> * each represented by a struct spi_transfer. The sequence is "atomic"
> @@ -1147,6 +1150,9 @@ struct spi_message {
>
> /* List of spi_res reources when the spi message is processed */
> struct list_head resources;
> +
> + /* For embedding transfers into the memory of the message */
> + struct spi_transfer t[];

You might want to use the DECLARE_FLEX_ARRAY helper here.

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |


Attachments:
(No filename) (1.79 kB)
signature.asc (499.00 B)
Download all attachments

2023-07-10 17:14:37

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 09/15] spi: Use struct_size() helper

On Mon, Jul 10, 2023 at 05:59:55PM +0200, Marc Kleine-Budde wrote:
> On 10.07.2023 18:49:26, Andy Shevchenko wrote:

...

> > + struct spi_transfer t[];
>
> You might want to use the DECLARE_FLEX_ARRAY helper here.

Technically, yes, semantically documentation [1] disagrees with
you, so I leave it as is.

[1]: Documentation/process/deprecated.rst:269

--
With Best Regards,
Andy Shevchenko