2013-05-31 20:23:21

by Emil Goode

[permalink] [raw]
Subject: [PATCH] usb: musb: Fix format specifier warning

This patch fixes a format specifier warning. dma_addr_t can be either
u32 or u64 so we should cast to the largest type and change the format
specifier to %llx.
The addition of urb->transfer_dma and urb->actual_length is also done a
few lines below. I have moved this code up and pass the variable buf to
dev_dbg.

Sparse output:
drivers/usb/musb/musb_host.c:1761:4: warning:
format ‘%x’ expects argument of type ‘unsigned int’,
but argument 6 has type ‘dma_addr_t’ [-Wformat]

Signed-off-by: Emil Goode <[email protected]>
---
drivers/usb/musb/musb_host.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 094cf80..d647ccb 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1756,11 +1756,11 @@ void musb_host_rx(struct musb *musb, u8 epnum)
dma_addr_t buf;

rx_count = musb_readw(epio, MUSB_RXCOUNT);
+ buf = urb->transfer_dma + urb->actual_length;

- dev_dbg(musb->controller, "RX%d count %d, buffer 0x%x len %d/%d\n",
+ dev_dbg(musb->controller, "RX%d count %d, buffer 0x%llx len %d/%d\n",
epnum, rx_count,
- urb->transfer_dma
- + urb->actual_length,
+ (unsigned long long)buf,
qh->offset,
urb->transfer_buffer_length);

@@ -1789,11 +1789,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
length = rx_count;
d->status = d_status;
buf = urb->transfer_dma + d->offset;
- } else {
+ } else
length = rx_count;
- buf = urb->transfer_dma +
- urb->actual_length;
- }

dma->desired_mode = 0;
#ifdef USE_MODE1
--
1.7.10.4


2013-05-31 20:27:32

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

Hello.

On 06/01/2013 12:22 AM, Emil Goode wrote:

> This patch fixes a format specifier warning. dma_addr_t can be either
> u32 or u64 so we should cast to the largest type and change the format
> specifier to %llx.
> The addition of urb->transfer_dma and urb->actual_length is also done a
> few lines below. I have moved this code up and pass the variable buf to
> dev_dbg.
>
> Sparse output:
> drivers/usb/musb/musb_host.c:1761:4: warning:
> format ‘%x’ expects argument of type ‘unsigned int’,
> but argument 6 has type ‘dma_addr_t’ [-Wformat]
>
> Signed-off-by: Emil Goode <[email protected]>
> ---
> drivers/usb/musb/musb_host.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 094cf80..d647ccb 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
[...]
> @@ -1789,11 +1789,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
> length = rx_count;
> d->status = d_status;
> buf = urb->transfer_dma + d->offset;
> - } else {
> + } else

You should keep {} on the *else* branch since *if* branch has {},
according to Documentation/CodingStyle.

> length = rx_count;
> - buf = urb->transfer_dma +
> - urb->actual_length;
> - }

WBR, Sergei

2013-05-31 22:35:01

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

On Fri, May 31, 2013 at 11:22 PM, Emil Goode <[email protected]> wrote:
> This patch fixes a format specifier warning. dma_addr_t can be either
> u32 or u64 so we should cast to the largest type and change the format
> specifier to %llx.

dma_addr_t is derived from phys_addr_t, thus you may use %pa specifier
which is available from v3.8(?).

Something like this:
dma_addr_t src_addr;
dev_dbg(dev, "DMA addr: %pa\n", src_addr);

--
With Best Regards,
Andy Shevchenko

2013-05-31 22:40:47

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

On 05/31/13 15:34, Andy Shevchenko wrote:
> On Fri, May 31, 2013 at 11:22 PM, Emil Goode <[email protected]> wrote:
>> This patch fixes a format specifier warning. dma_addr_t can be either
>> u32 or u64 so we should cast to the largest type and change the format
>> specifier to %llx.
>
> dma_addr_t is derived from phys_addr_t, thus you may use %pa specifier
> which is available from v3.8(?).
>
> Something like this:
> dma_addr_t src_addr;
> dev_dbg(dev, "DMA addr: %pa\n", src_addr);

Isn't that:

deb_dbg(dev, "DMA addr: %pa\n", &src_addr);


--
~Randy

2013-06-01 13:15:07

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

On Sat, Jun 1, 2013 at 1:39 AM, Randy Dunlap <[email protected]> wrote:
> On 05/31/13 15:34, Andy Shevchenko wrote:
>> On Fri, May 31, 2013 at 11:22 PM, Emil Goode <[email protected]> wrote:
>>> This patch fixes a format specifier warning. dma_addr_t can be either
>>> u32 or u64 so we should cast to the largest type and change the format
>>> specifier to %llx.
>>
>> dma_addr_t is derived from phys_addr_t, thus you may use %pa specifier
>> which is available from v3.8(?).
>>
>> Something like this:
>> dma_addr_t src_addr;
>> dev_dbg(dev, "DMA addr: %pa\n", src_addr);
>
> Isn't that:
>
> deb_dbg(dev, "DMA addr: %pa\n", &src_addr);

It's.
You are right.

--
With Best Regards,
Andy Shevchenko

2013-06-01 17:11:53

by Emil Goode

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

Hello,

Thank's for your pointers.
I will send a patch that applies on top of Felipe's patch.

Best regards,

Emil Goode

On Sat, Jun 01, 2013 at 04:15:03PM +0300, Andy Shevchenko wrote:
> On Sat, Jun 1, 2013 at 1:39 AM, Randy Dunlap <[email protected]> wrote:
> > On 05/31/13 15:34, Andy Shevchenko wrote:
> >> On Fri, May 31, 2013 at 11:22 PM, Emil Goode <[email protected]> wrote:
> >>> This patch fixes a format specifier warning. dma_addr_t can be either
> >>> u32 or u64 so we should cast to the largest type and change the format
> >>> specifier to %llx.
> >>
> >> dma_addr_t is derived from phys_addr_t, thus you may use %pa specifier
> >> which is available from v3.8(?).
> >>
> >> Something like this:
> >> dma_addr_t src_addr;
> >> dev_dbg(dev, "DMA addr: %pa\n", src_addr);
> >
> > Isn't that:
> >
> > deb_dbg(dev, "DMA addr: %pa\n", &src_addr);
>
> It's.
> You are right.
>
> --
> With Best Regards,
> Andy Shevchenko

2013-06-01 22:52:05

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] usb: musb: Fix format specifier warning

On Sat, Jun 1, 2013 at 8:11 PM, Emil Goode <[email protected]> wrote:
> Thank's for your pointers.
> I will send a patch that applies on top of Felipe's patch.

I guess there is not much sense to do that since Felipe applied your
patch already. Just keep in mind the hint for future changes.

--
With Best Regards,
Andy Shevchenko