Re: [PATCH 11/15] dmaengine: dw: platform: use field-by-field initialization

From: Andy Shevchenko
Date: Mon Jan 25 2016 - 03:48:16 EST


On Sun, 2016-01-24 at 19:21 +0000, Mans Rullgard wrote:
> From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>
> This is a simple stylish change that allows to use less lines of
> code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
> I'm a little ambivalent on this one.ÂÂWhile the patch is correct as
> such,
> the change means that if struct dw_dma_slave gains new members in
> future,
> these will not be initialised.ÂÂThis added fragility seems an
> unnecesary
> price to pay for saving one line of code.

We may useÂ

Âstruct dw_dma_slave slave = {0};

if it makes someone happier.

> ---
> Âdrivers/dma/dw/platform.c | 19 +++++++++----------
> Â1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
> index 808bafdd7d48..0fd5a49311a2 100644
> --- a/drivers/dma/dw/platform.c
> +++ b/drivers/dma/dw/platform.c
> @@ -32,14 +32,13 @@ static struct dma_chan *dw_dma_of_xlate(struct
> of_phandle_args *dma_spec,
> Â struct of_dma *ofdma)
> Â{
> Â struct dw_dma *dw = ofdma->of_dma_data;
> - struct dw_dma_slave slave = {
> - .dma_dev = dw->dma.dev,
> - };
> + struct dw_dma_slave slave;
> Â dma_cap_mask_t cap;
> Â
> Â if (dma_spec->args_count != 3)
> Â return NULL;
> Â
> + slave.dma_dev = dw->dma.dev;
> Â slave.src_id = dma_spec->args[0];
> Â slave.dst_id = dma_spec->args[0];
> Â slave.m_master = dma_spec->args[1];
> @@ -62,13 +61,13 @@ static struct dma_chan *dw_dma_of_xlate(struct
> of_phandle_args *dma_spec,
> Âstatic bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
> Â{
> Â struct acpi_dma_spec *dma_spec = param;
> - struct dw_dma_slave slave = {
> - .dma_dev = dma_spec->dev,
> - .src_id = dma_spec->slave_id,
> - .dst_id = dma_spec->slave_id,
> - .m_master = 1,
> - .p_master = 0,
> - };
> + struct dw_dma_slave slave;
> +
> + slave.dma_dev = dma_spec->dev;
> + slave.src_id = dma_spec->slave_id;
> + slave.dst_id = dma_spec->slave_id;
> + slave.m_master = 1;
> + slave.p_master = 0;
> Â
> Â return dw_dma_filter(chan, &slave);
> Â}

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy