On 12-03-26, 12:37, Rosen Penev wrote:
> A flexible array member can be used to combine allocations.
> 
> Signed-off-by: Rosen Penev <[email protected]>
> Acked-by: Viresh Kumar <[email protected]>
> ---
>  v3: add counting field for __counted_by.
>  v2: add space in struct
>  drivers/gpio/gpio-virtio.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index ed6e0e90fa8a..57d0eb532c3c 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -52,7 +52,6 @@ struct virtio_gpio {
>       struct virtio_device *vdev;
>       struct mutex lock; /* Protects virtqueue operation */
>       struct gpio_chip gc;
> -     struct virtio_gpio_line *lines;
>       struct virtqueue *request_vq;
> 
>       /* irq support */
> @@ -60,6 +59,9 @@ struct virtio_gpio {
>       struct mutex irq_lock; /* Protects irq operation */
>       raw_spinlock_t eventq_lock; /* Protects queuing of the buffer */
>       struct vgpio_irq_line *irq_lines;
> +
> +     u16 ngpio;
> +     struct virtio_gpio_line lines[] __counted_by(ngpio);
>  };

I wonder if it is worth it anymore. Why combining allocations is better when we
are ending up using more memory ?

-- 
viresh

Reply via email to