diff mbox

[2/2] dvb_usb_v2: use %*ph to dump usb xfer debugs

Message ID 1344380196-9488-2-git-send-email-crope@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Antti Palosaari Aug. 7, 2012, 10:56 p.m. UTC
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Andy Shevchenko Aug. 8, 2012, 4:16 a.m. UTC | #1
On Wed, Aug 8, 2012 at 1:56 AM, Antti Palosaari <crope@iki.fi> wrote:
> diff --git a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
> index 5f5bdd0..0431bee 100644
> --- a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
> +++ b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c

> @@ -37,10 +36,8 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
>         if (ret < 0)
>                 return ret;
>
> -#ifdef DVB_USB_XFER_DEBUG
> -       print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": >>> ", DUMP_PREFIX_NONE,
> -                       32, 1, wbuf, wlen, 0);
> -#endif
> +       dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf);
> +
>         ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
>                         d->props->generic_bulk_ctrl_endpoint), wbuf, wlen,
>                         &actual_length, 2000);
> @@ -64,11 +61,8 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
>                         dev_err(&d->udev->dev, "%s: 2nd usb_bulk_msg() " \
>                                         "failed=%d\n", KBUILD_MODNAME, ret);
>
> -#ifdef DVB_USB_XFER_DEBUG
> -               print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": <<< ",
> -                               DUMP_PREFIX_NONE, 32, 1, rbuf, actual_length,
> -                               0);
> -#endif
> +               dev_dbg(&d->udev->dev, "%s: <<< %*ph\n", __func__,
> +                               actual_length, rbuf);
>         }
>
Antti, I didn't check how long buffer could be in above cases, but be
aware that %*ph prints up to 64 bytes only. Is it enough here?
Antti Palosaari Aug. 8, 2012, 9:37 a.m. UTC | #2
On 08/08/2012 07:16 AM, Andy Shevchenko wrote:
> On Wed, Aug 8, 2012 at 1:56 AM, Antti Palosaari <crope@iki.fi> wrote:
>> diff --git a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
>> index 5f5bdd0..0431bee 100644
>> --- a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
>> +++ b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
>
>> @@ -37,10 +36,8 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
>>          if (ret < 0)
>>                  return ret;
>>
>> -#ifdef DVB_USB_XFER_DEBUG
>> -       print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": >>> ", DUMP_PREFIX_NONE,
>> -                       32, 1, wbuf, wlen, 0);
>> -#endif
>> +       dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf);
>> +
>>          ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
>>                          d->props->generic_bulk_ctrl_endpoint), wbuf, wlen,
>>                          &actual_length, 2000);
>> @@ -64,11 +61,8 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
>>                          dev_err(&d->udev->dev, "%s: 2nd usb_bulk_msg() " \
>>                                          "failed=%d\n", KBUILD_MODNAME, ret);
>>
>> -#ifdef DVB_USB_XFER_DEBUG
>> -               print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": <<< ",
>> -                               DUMP_PREFIX_NONE, 32, 1, rbuf, actual_length,
>> -                               0);
>> -#endif
>> +               dev_dbg(&d->udev->dev, "%s: <<< %*ph\n", __func__,
>> +                               actual_length, rbuf);
>>          }
>>
> Antti, I didn't check how long buffer could be in above cases, but be
> aware that %*ph prints up to 64 bytes only. Is it enough here?

It is correct behavior. I saw from the LKML patch limit was selected 
using min_t() not causing any other side effect than cut print length.

For some cases it could be more than 64 here, likely for the firmware 
download packed. I suspect, situation where control message is longer 
than 64 byte does not exist in real life as USB1.1 BULK max is 64. And 
even such case exists, we are not interested those not printed bytes.

regards
Antti
diff mbox

Patch

diff --git a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
index 5f5bdd0..0431bee 100644
--- a/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
+++ b/drivers/media/dvb/dvb-usb-v2/dvb_usb_urb.c
@@ -21,7 +21,6 @@ 
 
 #include "dvb_usb_common.h"
 
-#undef DVB_USB_XFER_DEBUG
 int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
 		u16 rlen)
 {
@@ -37,10 +36,8 @@  int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
 	if (ret < 0)
 		return ret;
 
-#ifdef DVB_USB_XFER_DEBUG
-	print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": >>> ", DUMP_PREFIX_NONE,
-			32, 1, wbuf, wlen, 0);
-#endif
+	dev_dbg(&d->udev->dev, "%s: >>> %*ph\n", __func__, wlen, wbuf);
+
 	ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
 			d->props->generic_bulk_ctrl_endpoint), wbuf, wlen,
 			&actual_length, 2000);
@@ -64,11 +61,8 @@  int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
 			dev_err(&d->udev->dev, "%s: 2nd usb_bulk_msg() " \
 					"failed=%d\n", KBUILD_MODNAME, ret);
 
-#ifdef DVB_USB_XFER_DEBUG
-		print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": <<< ",
-				DUMP_PREFIX_NONE, 32, 1, rbuf, actual_length,
-				0);
-#endif
+		dev_dbg(&d->udev->dev, "%s: <<< %*ph\n", __func__,
+				actual_length, rbuf);
 	}
 
 	mutex_unlock(&d->usb_mutex);