[v2,0/3] spi: axi-spi-engine: small cleanups

Message ID 20240304-mainline-axi-spi-engine-small-cleanups-v2-0-5b14ed729a31@baylibre.com
Headers
Series spi: axi-spi-engine: small cleanups |

Message

David Lechner March 4, 2024, 4:04 p.m. UTC
  This series contains a few small cleanups to the axi-spi-engine driver,
mostly suggested from previous reviews.

---
Changes in v2:
- Picked up the Reviewed-by trailers.
- Modified second patch to reorder assignment of the length field.
- Link to v1: https://lore.kernel.org/r/20240301-mainline-axi-spi-engine-small-cleanups-v1-0-241dfd2a79f7@baylibre.com

---
David Lechner (3):
      spi: axi-spi-engine: remove p from struct spi_engine_message_state
      spi: axi-spi-engine: use __counted_by() attribute
      spi: axi-spi-engine: use struct_size() macro

 drivers/spi/spi-axi-spi-engine.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
base-commit: bf790d87088a04d5f3a4659e04ff2a5a16eca294
change-id: 20240301-mainline-axi-spi-engine-small-cleanups-cd08b51cb6d4

Best regards,
  

Comments

Gustavo A. R. Silva March 4, 2024, 4:16 p.m. UTC | #1
On 04/03/24 10:04, David Lechner wrote:
> This adds the __counted_by() attribute to the flex array at the end of
> struct spi_engine_program in the AXI SPI Engine controller driver.
> 
> The assignment of the length field has to be reordered to be before
> the access to the flex array in order to avoid potential compiler
> warnings/errors due to adding the __counted_by() attribute.
> 
> Suggested-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: David Lechner <dlechner@baylibre.com>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
--
Gustavo

> ---
> v2 changes:
> * Reordered assignment of length field.
> ---
>   drivers/spi/spi-axi-spi-engine.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
> index d89f75170c9e..a8f626165f44 100644
> --- a/drivers/spi/spi-axi-spi-engine.c
> +++ b/drivers/spi/spi-axi-spi-engine.c
> @@ -75,7 +75,7 @@
>   
>   struct spi_engine_program {
>   	unsigned int length;
> -	uint16_t instructions[];
> +	uint16_t instructions[] __counted_by(length);
>   };
>   
>   /**
> @@ -115,9 +115,10 @@ struct spi_engine {
>   static void spi_engine_program_add_cmd(struct spi_engine_program *p,
>   	bool dry, uint16_t cmd)
>   {
> -	if (!dry)
> -		p->instructions[p->length] = cmd;
>   	p->length++;
> +
> +	if (!dry)
> +		p->instructions[p->length - 1] = cmd;
>   }
>   
>   static unsigned int spi_engine_get_config(struct spi_device *spi)
>