Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1676057 > unrolled thread

[PATCH 4/8] usb: bdc: Small code cleanup

Started byAl Cooper <alcooperx@gmail.com>
First post2017-06-27 20:30 +0200
Last post2017-06-29 16:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 4/8] usb: bdc: Small code cleanup Al Cooper <alcooperx@gmail.com> - 2017-06-27 20:30 +0200
    RE: [PATCH 4/8] usb: bdc: Small code cleanup David Laight <David.Laight@ACULAB.COM> - 2017-06-28 10:50 +0200
      Re: [PATCH 4/8] usb: bdc: Small code cleanup Al Cooper <al.cooper@broadcom.com> - 2017-06-28 17:00 +0200
        RE: [PATCH 4/8] usb: bdc: Small code cleanup David Laight <David.Laight@ACULAB.COM> - 2017-06-29 16:30 +0200

#1676057 — [PATCH 4/8] usb: bdc: Small code cleanup

FromAl Cooper <alcooperx@gmail.com>
Date2017-06-27 20:30 +0200
Subject[PATCH 4/8] usb: bdc: Small code cleanup
Message-ID<tX3pn-4kt-3@gated-at.bofh.it>
Signed-off-by: Al Cooper <alcooperx@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 3bd82d2..621328f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -488,28 +488,29 @@ static int bdc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, bdc);
 	bdc->irq = irq;
 	bdc->dev = dev;
-	dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
+	dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
 	temp = bdc_readl(bdc->regs, BDC_BDCSC);
 	if ((temp & BDC_P64) &&
 			!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
-		dev_dbg(bdc->dev, "Using 64-bit address\n");
+		dev_dbg(dev, "Using 64-bit address\n");
 	} else {
-		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
 		if (ret) {
-			dev_err(bdc->dev, "No suitable DMA config available, abort\n");
+			dev_err(dev,
+				"No suitable DMA config available, abort\n");
 			return -ENOTSUPP;
 		}
-		dev_dbg(bdc->dev, "Using 32-bit address\n");
+		dev_dbg(dev, "Using 32-bit address\n");
 	}
 	ret = bdc_hw_init(bdc);
 	if (ret) {
-		dev_err(bdc->dev, "BDC init failure:%d\n", ret);
+		dev_err(dev, "BDC init failure:%d\n", ret);
 		return ret;
 	}
 	ret = bdc_udc_init(bdc);
 	if (ret) {
-		dev_err(bdc->dev, "BDC Gadget init failure:%d\n", ret);
+		dev_err(dev, "BDC Gadget init failure:%d\n", ret);
 		goto cleanup;
 	}
 	return 0;
-- 
1.9.0.138.g2de3478

[toc] | [next] | [standalone]


#1676450

FromDavid Laight <David.Laight@ACULAB.COM>
Date2017-06-28 10:50 +0200
Message-ID<tXgPD-4wG-3@gated-at.bofh.it>
In reply to#1676057
From: Al Cooper
> Sent: 27 June 2017 19:23
> Signed-off-by: Al Cooper <alcooperx@gmail.com>
> ---
>  drivers/usb/gadget/udc/bdc/bdc_core.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
> index 3bd82d2..621328f 100644
> --- a/drivers/usb/gadget/udc/bdc/bdc_core.c
> +++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
> @@ -488,28 +488,29 @@ static int bdc_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, bdc);
>  	bdc->irq = irq;
>  	bdc->dev = dev;
> -	dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
> +	dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);

The compiler will use the value without re-reading it.
In the other places it makes very little difference.
The changed code might require one less memory read, but if the extra
'live' local variable causes gcc to save registers to stack all
bets are off.

The more explicit bdc->dev is probably more readable.

> 
>  	temp = bdc_readl(bdc->regs, BDC_BDCSC);
>  	if ((temp & BDC_P64) &&
>  			!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
> -		dev_dbg(bdc->dev, "Using 64-bit address\n");
> +		dev_dbg(dev, "Using 64-bit address\n");
>  	} else {
> -		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));

That just wrong...
Or was wrong before.

...

	David

[toc] | [prev] | [next] | [standalone]


#1676740

FromAl Cooper <al.cooper@broadcom.com>
Date2017-06-28 17:00 +0200
Message-ID<tXmBI-86L-9@gated-at.bofh.it>
In reply to#1676450
On Wed, Jun 28, 2017 at 4:47 AM, David Laight <David.Laight@aculab.com> wrote:
>>
>>       temp = bdc_readl(bdc->regs, BDC_BDCSC);
>>       if ((temp & BDC_P64) &&
>>                       !dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
>> -             dev_dbg(bdc->dev, "Using 64-bit address\n");
>> +             dev_dbg(dev, "Using 64-bit address\n");
>>       } else {
>> -             ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>> +             ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
>
> That just wrong...
> Or was wrong before.

Why is this wrong?

Al

[toc] | [prev] | [next] | [standalone]


#1677809

FromDavid Laight <David.Laight@ACULAB.COM>
Date2017-06-29 16:30 +0200
Message-ID<tXICf-eR-35@gated-at.bofh.it>
In reply to#1676740
From: Al Cooper
> Sent: 28 June 2017 15:56
> On Wed, Jun 28, 2017 at 4:47 AM, David Laight <David.Laight@aculab.com> wrote:
> >>
> >>       temp = bdc_readl(bdc->regs, BDC_BDCSC);
> >>       if ((temp & BDC_P64) &&
> >>                       !dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
> >> -             dev_dbg(bdc->dev, "Using 64-bit address\n");
> >> +             dev_dbg(dev, "Using 64-bit address\n");
> >>       } else {
> >> -             ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> >> +             ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
> >
> > That just wrong...
> > Or was wrong before.
> 
> Why is this wrong?

It isn't obvious that &pdev->dev is bdc->dev and hence dev.

	David

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web