Re: [PATCH] dmaengine: sf-pdma: Reduce scope for the variable “vd” in sf_pdma_desc_residue()

From: Vinod Koul
Date: Thu Dec 10 2020 - 04:22:23 EST


On 09-12-20, 21:00, Markus Elfring wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Wed, 9 Dec 2020 20:55:05 +0100
>
> A local variable was used only within an else branch.
> Thus move the definition for the variable “vd” into the corresponding
> code block.
>
> This issue was detected by using the Coccinelle software.

And what was the issue detected...?

I feel this is fine and patch below does not add much value..

>
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/dma/sf-pdma/sf-pdma.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/dma/sf-pdma/sf-pdma.c b/drivers/dma/sf-pdma/sf-pdma.c
> index c4c4e8575764..c66da79a1b34 100644
> --- a/drivers/dma/sf-pdma/sf-pdma.c
> +++ b/drivers/dma/sf-pdma/sf-pdma.c
> @@ -164,7 +164,6 @@ static void sf_pdma_free_chan_resources(struct dma_chan *dchan)
> static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan,
> dma_cookie_t cookie)
> {
> - struct virt_dma_desc *vd = NULL;
> struct pdma_regs *regs = &chan->regs;
> unsigned long flags;
> u64 residue = 0;
> @@ -180,7 +179,7 @@ static size_t sf_pdma_desc_residue(struct sf_pdma_chan *chan,
> if (cookie == tx->cookie) {
> residue = readq(regs->residue);
> } else {
> - vd = vchan_find_desc(&chan->vchan, cookie);
> + struct virt_dma_desc *vd = vchan_find_desc(&chan->vchan, cookie);
> if (!vd)
> goto out;
>
> --
> 2.29.2

--
~Vinod