[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTinR-mwXyrGlrCg2TCR3DtPewBPnaoZf_MWySJzX@mail.gmail.com>
Date: Fri, 11 Jun 2010 15:23:26 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Linus Walleij <linus.walleij@...ricsson.com>
Cc: linux-kernel@...r.kernel.org,
Jonas Aaberg <jonas.aberg@...ricsson.com>
Subject: Re: [PATCH 02/18] DMAENGINE: ste_dma40: only write phy channel config
first time
On Tue, Jun 1, 2010 at 5:20 AM, Linus Walleij
<linus.walleij@...ricsson.com> wrote:
> We only need to write the configuration to a physical channel if
> it is free, else it is already written.
>
> Signed-off-by: Jonas Aaberg <jonas.aberg@...ricsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@...ricsson.com>
> ---
> drivers/dma/ste_dma40.c | 19 +++++++++++++------
> 1 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
> index 4618d6c..1cd1ff7 100644
> --- a/drivers/dma/ste_dma40.c
> +++ b/drivers/dma/ste_dma40.c
> @@ -1211,9 +1211,9 @@ out:
> }
>
> static int d40_config_chan(struct d40_chan *d40c,
> - struct stedma40_chan_cfg *info)
> + struct stedma40_chan_cfg *info,
> + bool is_free_phy)
> {
> -
> /* Fill in basic CFG register values */
> d40_phy_cfg(&d40c->dma_cfg, &d40c->src_def_cfg,
> &d40c->dst_def_cfg, d40c->log_num != D40_PHY_CHAN);
> @@ -1230,8 +1230,14 @@ static int d40_config_chan(struct d40_chan *d40c,
> d40c->dma_cfg.dst_dev_type * 32 + 16;
> }
>
> - /* Write channel configuration to the DMA */
> - return d40_config_write(d40c);
> + /*
> + * Only write channel configuration to the DMA if the physical
> + * resource is free. In case of multiple logical channels
> + * on the same physical resource, only the first write is necessary.
> + */
> + if (is_free_phy)
> + return d40_config_write(d40c);
> + return 0;
> }
>
> static int d40_config_memcpy(struct d40_chan *d40c)
> @@ -1691,7 +1697,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
> unsigned long flags;
> struct d40_chan *d40c =
> container_of(chan, struct d40_chan, chan);
> -
> + bool is_free_phy;
> spin_lock_irqsave(&d40c->lock, flags);
>
> d40c->completed = chan->cookie = 1;
> @@ -1705,6 +1711,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
> if (err)
> goto err_alloc;
> }
> + is_free_phy = (d40c->phy_chan == NULL);
>
It seems like d40_config_chan() just wants to be open coded in
d40_alloc_chan_resources(). It does not have its own local variables,
and the only thing that returns an error is d40_config_write().
While trying to figure out why this flag was needed I happened to
notice a gratuitous use of gotos in d40_allocate_channel(). Can we
make this function easier to read by just returning -EINVAL directly
when those tests fail?
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists