From 23d8e63a903bf8b6d9bf99bdd0e45aa901a90fff Mon Sep 17 00:00:00 2001 From: Antti Palosaari Date: Wed, 6 Jun 2012 22:46:38 -0300 Subject: [PATCH] [media] dvb_usb_v2: use Kernel logging (pr_debug/pr_err/pr_info) Use Kernel logging insteads of own macros. Get rid of old debugs and use dynamic debug. Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/dvb_usb.h | 38 -------------------- drivers/media/dvb/dvb-usb/dvb_usb_common.h | 5 --- drivers/media/dvb/dvb-usb/dvb_usb_dvb.c | 25 +++++++------ drivers/media/dvb/dvb-usb/dvb_usb_i2c.c | 2 +- drivers/media/dvb/dvb-usb/dvb_usb_init.c | 41 +++++++++++----------- drivers/media/dvb/dvb-usb/dvb_usb_remote.c | 8 ++--- drivers/media/dvb/dvb-usb/dvb_usb_urb.c | 20 ++++++----- drivers/media/dvb/dvb-usb/usb_urb.c | 35 ++++++++++-------- 8 files changed, 71 insertions(+), 103 deletions(-) diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h index 44c799cedc87..78b69286a803 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb.h @@ -20,46 +20,8 @@ #include "dvb_demux.h" #include "dvb_net.h" #include "dmxdev.h" - -#include "dvb-pll.h" - #include "dvb-usb-ids.h" -/* debug */ -#ifdef CONFIG_DVB_USB_DEBUG -#define dprintk(var, level, args...) \ - do { if ((var & level)) { printk(args); } } while (0) - -#define debug_dump(b, l, func) {\ - int loop_; \ - for (loop_ = 0; loop_ < l; loop_++) \ - func("%02x ", b[loop_]); \ - func("\n");\ -} -#define DVB_USB_DEBUG_STATUS -#else -#define dprintk(args...) -#define debug_dump(b, l, func) - -#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)" - -#endif - -/* generic log methods - taken from usb.h */ -#ifndef DVB_USB_LOG_PREFIX - #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)" -#endif - -#undef err -#define err(format, arg...) \ - printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) -#undef info -#define info(format, arg...) \ - printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) -#undef warn -#define warn(format, arg...) \ - printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg) - struct dvb_usb_driver_info { const char *name; const char *rc_map; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_common.h b/drivers/media/dvb/dvb-usb/dvb_usb_common.h index 3a092053d823..058fa8c06846 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_common.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb_common.h @@ -9,15 +9,10 @@ #ifndef DVB_USB_COMMON_H #define DVB_USB_COMMON_H -#define DVB_USB_LOG_PREFIX "dvb_usb" #include "dvb_usb.h" -extern int dvb_usb_debug; extern int dvb_usb_disable_rc_polling; -#define deb_xfer(args...) dprintk(dvb_usb_debug, 0x002, args) -#define deb_uxfer(args...) dprintk(dvb_usb_debug, 0x100, args) - /* commonly used methods */ extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff); diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c index b6fc5a6fe99b..b9524326c8ba 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c @@ -83,7 +83,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) if (adap->props.streaming_ctrl != NULL) { ret = adap->props.streaming_ctrl(adap, 0); if (ret < 0) { - err("error while stopping stream."); + pr_err("%s: error while stopping stream", + KBUILD_MODNAME); return ret; } } @@ -150,7 +151,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ret = adap->props.pid_filter_ctrl(adap, adap->pid_filtering); if (ret < 0) { - err("could not handle pid_parser"); + pr_err("%s: could not handle pid_parser", + KBUILD_MODNAME); return ret; } } @@ -158,7 +160,8 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) if (adap->props.streaming_ctrl != NULL) { ret = adap->props.streaming_ctrl(adap, 1); if (ret < 0) { - err("error while enabling fifo."); + pr_err("%s: error while enabling fifo", + KBUILD_MODNAME); return ret; } } @@ -172,14 +175,14 @@ err: static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - pr_debug("%s: start pid %04x feedtype %d", __func__, dvbdmxfeed->pid, + pr_debug("%s: start pid=%04x feedtype=%d\n", __func__, dvbdmxfeed->pid, dvbdmxfeed->type); return dvb_usb_ctrl_feed(dvbdmxfeed, 1); } static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - pr_debug("%s: stop pid %04x feedtype %d", __func__, dvbdmxfeed->pid, + pr_debug("%s: stop pid=%04x feedtype=%d\n", __func__, dvbdmxfeed->pid, dvbdmxfeed->type); return dvb_usb_ctrl_feed(dvbdmxfeed, 0); } @@ -200,9 +203,11 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address(adap->dev, adap->dvb_adap.proposed_mac) == 0) - info("MAC address: %pM", adap->dvb_adap.proposed_mac); + pr_info("%s: MAC address: %pM", KBUILD_MODNAME, + adap->dvb_adap.proposed_mac); else - err("MAC address reading failed."); + pr_err("%s: MAC address reading failed", + KBUILD_MODNAME); } @@ -218,7 +223,7 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->demux.write_to_decoder = NULL; ret = dvb_dmx_init(&adap->demux); if (ret < 0) { - err("dvb_dmx_init failed: error %d", ret); + pr_err("%s: dvb_dmx_init() failed=%d", KBUILD_MODNAME, ret); goto err_dmx; } @@ -227,13 +232,13 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->dmxdev.capabilities = 0; ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap); if (ret < 0) { - err("dvb_dmxdev_init failed: error %d", ret); + pr_err("%s: dvb_dmxdev_init failed=%d", KBUILD_MODNAME, ret); goto err_dmx_dev; } ret = dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx); if (ret < 0) { - err("dvb_net_init failed: error %d", ret); + pr_err("%s: dvb_net_init failed=%d", KBUILD_MODNAME, ret); goto err_net_init; } diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c b/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c index ced91e6f480f..202e1d1acffb 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_i2c.c @@ -23,7 +23,7 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d) ret = i2c_add_adapter(&d->i2c_adap); if (ret < 0) - err("could not add i2c adapter"); + pr_err("%s: could not add i2c adapter", KBUILD_MODNAME); d->state |= DVB_USB_STATE_I2C; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_init.c b/drivers/media/dvb/dvb-usb/dvb_usb_init.c index 581be9d990a0..9dcf4e525795 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_init.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_init.c @@ -13,13 +13,6 @@ */ #include "dvb_usb_common.h" -/* debug */ -int dvb_usb_debug; -module_param_named(debug, dvb_usb_debug, int, 0644); -MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8"\ - ",err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." - DVB_USB_DEBUG_STATUS); - int dvb_usb_disable_rc_polling; module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); MODULE_PARM_DESC(disable_rc_polling, @@ -52,13 +45,15 @@ int dvb_usb_download_firmware(struct dvb_usb_device *d) ret = request_firmware(&fw, name, &d->udev->dev); if (ret < 0) { - err("did not find the firmware file. (%s) " \ - "Please see linux/Documentation/dvb/ for more" \ - " details on firmware-problems. (%d)", name, ret); + pr_err("%s: did not find the firmware file. (%s) " \ + "Please see linux/Documentation/dvb/ for " \ + "more details on firmware-problems. (%d)", + KBUILD_MODNAME, name, ret); goto err; } - info("downloading firmware from file '%s'", name); + pr_info("%s: downloading firmware from file '%s'", KBUILD_MODNAME, + name); ret = d->props.download_firmware(d, fw); @@ -99,28 +94,31 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) /* speed - when running at FULL speed we need a HW PID filter */ if (d->udev->speed == USB_SPEED_FULL && !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) { - err("This USB2.0 device cannot be run on a" \ - " USB1.1 port. (it lacks a" \ - " hardware PID filter)"); + pr_err("%s: this USB2.0 device cannot be run on a " \ + "USB1.1 port (it lacks a hardware " \ + "PID filter)", KBUILD_MODNAME); return -ENODEV; } else if ((d->udev->speed == USB_SPEED_FULL && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) || (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { - info("will use the device's hardware PID" \ - " filter (table count: %d).", - adap->props.pid_filter_count); + pr_info("%s: will use the device's hardware PID " \ + "filter (table count: %d)", + KBUILD_MODNAME, + adap->props.pid_filter_count); adap->pid_filtering = 1; adap->max_feed_count = adap->props.pid_filter_count; } else { - info("will pass the complete MPEG2 transport" \ - " stream to the software demuxer."); + pr_info("%s: will pass the complete MPEG2 transport " \ + "stream to the software demuxer", + KBUILD_MODNAME); adap->pid_filtering = 0; adap->max_feed_count = 255; } if (!adap->pid_filtering && dvb_usb_force_pid_filter_usage && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) { - info("pid filter enabled by module option."); + pr_info("%s: pid filter enabled by module option", + KBUILD_MODNAME); adap->pid_filtering = 1; adap->max_feed_count = adap->props.pid_filter_count; } @@ -210,7 +208,8 @@ static int dvb_usb_init(struct dvb_usb_device *d) ret = dvb_usb_remote_init(d); if (ret) - err("could not initialize remote control."); + pr_err("%s: could not initialize remote control\n", + KBUILD_MODNAME); dvb_usb_device_power_ctrl(d, 0); diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_remote.c b/drivers/media/dvb/dvb-usb/dvb_usb_remote.c index 22d7790e7c42..f64982a1cd83 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_remote.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_remote.c @@ -31,7 +31,8 @@ static void dvb_usb_read_remote_control(struct work_struct *work) ret = d->rc.query(d); if (ret < 0) - err("error %d while querying for an remote control event", ret); + pr_err("%s: error %d while querying for an remote control " \ + "event", KBUILD_MODNAME, ret); schedule_delayed_work(&d->rc_query_work, msecs_to_jiffies(d->rc.interval)); @@ -89,9 +90,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d) /* initialize a work queue for handling polling */ INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control); - - info("schedule remote query interval to %d msecs", - d->rc.interval); + pr_info("%s: schedule remote query interval to %d msecs", + KBUILD_MODNAME, d->rc.interval); schedule_delayed_work(&d->rc_query_work, msecs_to_jiffies(d->rc.interval)); } diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c index 43563b341b80..e28a4dc3cb04 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_urb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_urb.c @@ -17,7 +17,8 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, return -EINVAL; if (d->props.generic_bulk_ctrl_endpoint == 0) { - err("endpoint for generic control not specified."); + pr_err("%s: endpoint for generic control not specified", + KBUILD_MODNAME); return -EINVAL; } @@ -25,15 +26,16 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, if (ret) return ret; - deb_xfer(">>> "); - debug_dump(wbuf, wlen, deb_xfer); + print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": >>> ", DUMP_PREFIX_NONE, + 32, 1, wbuf, wlen, 0); ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint), wbuf, wlen, &actlen, 2000); if (ret) - err("bulk message failed: %d (%d/%d)", ret, wlen, actlen); + pr_err("%s: bulk message failed: %d (%d/%d)", KBUILD_MODNAME, + ret, wlen, actlen); else ret = actlen != wlen ? -1 : 0; @@ -49,11 +51,11 @@ int dvb_usbv2_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, rbuf, rlen, &actlen, 2000); if (ret) - err("recv bulk message failed: %d", ret); - else { - deb_xfer("<<< "); - debug_dump(rbuf, actlen, deb_xfer); - } + pr_err("%s: recv bulk message failed: %d", + KBUILD_MODNAME, ret); + else + print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": <<< ", + DUMP_PREFIX_NONE, 32, 1, wbuf, wlen, 0); } mutex_unlock(&d->usb_mutex); diff --git a/drivers/media/dvb/dvb-usb/usb_urb.c b/drivers/media/dvb/dvb-usb/usb_urb.c index bf987c09b0cd..baa2938db151 100644 --- a/drivers/media/dvb/dvb-usb/usb_urb.c +++ b/drivers/media/dvb/dvb-usb/usb_urb.c @@ -22,11 +22,12 @@ static void usb_urb_complete(struct urb *urb) int i; u8 *b; - deb_uxfer("'%s' urb completed. status: %d, length: %d/%d," \ - " pack_num: %d, errors: %d\n", - ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", - urb->status, urb->actual_length, urb->transfer_buffer_length, - urb->number_of_packets, urb->error_count); + pr_debug("%s: %s urb completed status=%d length=%d/%d" \ + " pack_num=%d errors=%d\n", __func__, + ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", + urb->status, urb->actual_length, + urb->transfer_buffer_length, + urb->number_of_packets, urb->error_count); switch (urb->status) { case 0: /* success */ @@ -47,8 +48,8 @@ static void usb_urb_complete(struct urb *urb) case PIPE_ISOCHRONOUS: for (i = 0; i < urb->number_of_packets; i++) { if (urb->iso_frame_desc[i].status != 0) - pr_debug("%s: iso frame descriptor has an" \ - " error=%d\n", __func__, + pr_debug("%s: iso frame descriptor has an " \ + "error=%d\n", __func__, urb->iso_frame_desc[i].status); else if (urb->iso_frame_desc[i].actual_length > 0) stream->complete(stream, @@ -58,14 +59,14 @@ static void usb_urb_complete(struct urb *urb) urb->iso_frame_desc[i].status = 0; urb->iso_frame_desc[i].actual_length = 0; } - debug_dump(b, 20, deb_uxfer); break; case PIPE_BULK: if (urb->actual_length > 0) stream->complete(stream, b, urb->actual_length); break; default: - err("unknown endpoint type in completition handler."); + pr_err("%s: unknown endpoint type in completition handler", + KBUILD_MODNAME); return; } usb_submit_urb(urb, GFP_ATOMIC); @@ -98,8 +99,8 @@ int usb_urb_submit(struct usb_data_stream *stream, pr_debug("%s: submit URB=%d\n", __func__, i); ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC); if (ret) { - err("could not submit URB no. %d - get them all back", - i); + pr_err("%s: could not submit URB no. %d - get them " \ + "all back", KBUILD_MODNAME, i); usb_urb_kill(stream); return ret; } @@ -263,12 +264,14 @@ int usb_urb_reconfig(struct usb_data_stream *stream, } else if (props->type == USB_ISOC) { buf_size = props->u.isoc.framesize * props->u.isoc.framesperurb; } else { - err("invalid endpoint type=%d", props->type); + pr_err("%s: invalid endpoint type=%d", KBUILD_MODNAME, + props->type); return -EINVAL; } if (stream->buf_num < props->count || stream->buf_size < buf_size) { - err("cannot reconfigure as allocated buffers are too small"); + pr_err("%s: cannot reconfigure as allocated buffers are too " \ + "small", KBUILD_MODNAME); return -EINVAL; } @@ -316,7 +319,8 @@ int usb_urb_init(struct usb_data_stream *stream, stream->props.endpoint)); if (stream->complete == NULL) { - err("there is no data callback - this doesn't make sense."); + pr_err("%s: there is no data callback - this doesn't make " \ + "sense", KBUILD_MODNAME); return -EINVAL; } @@ -337,7 +341,8 @@ int usb_urb_init(struct usb_data_stream *stream, return usb_urb_alloc_isoc_urbs(stream); default: - err("unknown URB-type for data transfer."); + pr_err("%s: unknown URB-type for data transfer", + KBUILD_MODNAME); return -EINVAL; } } -- 2.34.1