Skip to content

Commit

Permalink
V4L/DVB (10298): remove err macro from few usb devices
Browse files Browse the repository at this point in the history
Patch removes err() macros from few usb devices.
It places pr_err in pvrusb2-v4l2.c, dev_err in dabusb and in usbvision
drivers. Beside placing dev_err, patch defines new s2255_dev_err macro
with S2255_DRIVER_NAME in s2255 module.

Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Acked-by: Thierry Merle <thierry.merle@free.fr>
Acked-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab authored and Mauro Carvalho Chehab committed Mar 30, 2009
1 parent f180152 commit be9ed51
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 80 deletions.
70 changes: 43 additions & 27 deletions drivers/media/video/dabusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,20 @@ static void dabusb_iso_complete (struct urb *purb)
dst += len;
}
else
err("dabusb_iso_complete: invalid len %d", len);
dev_err(&purb->dev->dev,
"dabusb_iso_complete: invalid len %d\n", len);
}
else
dev_warn(&purb->dev->dev, "dabusb_iso_complete: corrupted packet status: %d\n", purb->iso_frame_desc[i].status);
if (dst != purb->actual_length)
err("dst!=purb->actual_length:%d!=%d", dst, purb->actual_length);
dev_err(&purb->dev->dev,
"dst!=purb->actual_length:%d!=%d\n",
dst, purb->actual_length);
}

if (atomic_dec_and_test (&s->pending_io) && !s->remove_pending && s->state != _stopped) {
s->overruns++;
err("overrun (%d)", s->overruns);
dev_err(&purb->dev->dev, "overrun (%d)\n", s->overruns);
}
wake_up (&s->wait);
}
Expand All @@ -220,13 +223,14 @@ static int dabusb_alloc_buffers (pdabusb_t s)
while (transfer_len < (s->total_buffer_size << 10)) {
b = kzalloc(sizeof (buff_t), GFP_KERNEL);
if (!b) {
err("kzalloc(sizeof(buff_t))==NULL");
dev_err(&s->usbdev->dev,
"kzalloc(sizeof(buff_t))==NULL\n");
goto err;
}
b->s = s;
b->purb = usb_alloc_urb(packets, GFP_KERNEL);
if (!b->purb) {
err("usb_alloc_urb == NULL");
dev_err(&s->usbdev->dev, "usb_alloc_urb == NULL\n");
kfree (b);
goto err;
}
Expand All @@ -235,7 +239,8 @@ static int dabusb_alloc_buffers (pdabusb_t s)
if (!b->purb->transfer_buffer) {
kfree (b->purb);
kfree (b);
err("kmalloc(%d)==NULL", transfer_buffer_length);
dev_err(&s->usbdev->dev,
"kmalloc(%d)==NULL\n", transfer_buffer_length);
goto err;
}

Expand Down Expand Up @@ -279,10 +284,11 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)

ret=usb_bulk_msg(s->usbdev, pipe, pb->data, pb->size, &actual_length, 100);
if(ret<0) {
err("dabusb: usb_bulk_msg failed(%d)",ret);
dev_err(&s->usbdev->dev,
"usb_bulk_msg failed(%d)\n", ret);

if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) {
err("set_interface failed");
dev_err(&s->usbdev->dev, "set_interface failed\n");
return -EINVAL;
}

Expand All @@ -291,7 +297,7 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)
if( ret == -EPIPE ) {
dev_warn(&s->usbdev->dev, "CLEAR_FEATURE request to remove STALL condition.\n");
if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe)))
err("request failed");
dev_err(&s->usbdev->dev, "request failed\n");
}

pb->size = actual_length;
Expand All @@ -305,7 +311,8 @@ static int dabusb_writemem (pdabusb_t s, int pos, const unsigned char *data,
unsigned char *transfer_buffer = kmalloc (len, GFP_KERNEL);

if (!transfer_buffer) {
err("dabusb_writemem: kmalloc(%d) failed.", len);
dev_err(&s->usbdev->dev,
"dabusb_writemem: kmalloc(%d) failed.\n", len);
return -ENOMEM;
}

Expand Down Expand Up @@ -333,7 +340,8 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname)

ret = request_ihex_firmware(&fw, "dabusb/firmware.fw", &s->usbdev->dev);
if (ret) {
err("Failed to load \"dabusb/firmware.fw\": %d\n", ret);
dev_err(&s->usbdev->dev,
"Failed to load \"dabusb/firmware.fw\": %d\n", ret);
goto out;
}
ret = dabusb_8051_reset (s, 1);
Expand All @@ -346,9 +354,10 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname)
ret = dabusb_writemem(s, be32_to_cpu(rec->addr), rec->data,
be16_to_cpu(rec->len));
if (ret < 0) {
err("dabusb_writemem failed (%d %04X %p %d)", ret,
be32_to_cpu(rec->addr), rec->data,
be16_to_cpu(rec->len));
dev_err(&s->usbdev->dev,
"dabusb_writemem failed (%d %04X %p %d)\n",
ret, be32_to_cpu(rec->addr),
rec->data, be16_to_cpu(rec->len));
break;
}
}
Expand Down Expand Up @@ -396,13 +405,15 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname)
dbg("Enter dabusb_fpga_download (internal)");

if (!b) {
err("kmalloc(sizeof(bulk_transfer_t))==NULL");
dev_err(&s->usbdev->dev,
"kmalloc(sizeof(bulk_transfer_t))==NULL\n");
return -ENOMEM;
}

ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev);
if (ret) {
err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret);
dev_err(&s->usbdev->dev,
"Failed to load \"dabusb/bitstream.bin\": %d\n", ret);
kfree(b);
return ret;
}
Expand All @@ -425,7 +436,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname)
memcpy (b->data + 4, fw->data + 74 + n, 60);
ret = dabusb_bulk (s, b);
if (ret < 0) {
err("dabusb_bulk failed.");
dev_err(&s->usbdev->dev, "dabusb_bulk failed.\n");
break;
}
mdelay (1);
Expand Down Expand Up @@ -478,9 +489,11 @@ static int dabusb_startrek (pdabusb_t s)

ret = usb_submit_urb (end->purb, GFP_KERNEL);
if (ret) {
err("usb_submit_urb returned:%d", ret);
dev_err(&s->usbdev->dev,
"usb_submit_urb returned:%d\n", ret);
if (dabusb_add_buf_tail (s, &s->free_buff_list, &s->rec_buff_list))
err("startrek: dabusb_add_buf_tail failed");
dev_err(&s->usbdev->dev,
"startrek: dabusb_add_buf_tail failed\n");
break;
}
else
Expand Down Expand Up @@ -523,7 +536,8 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l

spin_unlock_irqrestore(&s->lock, flags);

err("error: rec_buf_list is empty");
dev_err(&s->usbdev->dev,
"error: rec_buf_list is empty\n");
goto err;
}

Expand Down Expand Up @@ -552,7 +566,8 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l

if (list_empty (&s->rec_buff_list)) {
spin_unlock_irqrestore(&s->lock, flags);
err("error: still no buffer available.");
dev_err(&s->usbdev->dev,
"error: still no buffer available.\n");
goto err;
}
spin_unlock_irqrestore(&s->lock, flags);
Expand All @@ -573,7 +588,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
dbg("copy_to_user:%p %p %d",buf, purb->transfer_buffer + s->readptr, cnt);

if (copy_to_user (buf, purb->transfer_buffer + s->readptr, cnt)) {
err("read: copy_to_user failed");
dev_err(&s->usbdev->dev, "read: copy_to_user failed\n");
if (!ret)
ret = -EFAULT;
goto err;
Expand All @@ -587,7 +602,8 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
if (s->readptr == purb->actual_length) {
// finished, take next buffer
if (dabusb_add_buf_tail (s, &s->free_buff_list, &s->rec_buff_list))
err("read: dabusb_add_buf_tail failed");
dev_err(&s->usbdev->dev,
"read: dabusb_add_buf_tail failed\n");
s->readptr = 0;
}
}
Expand Down Expand Up @@ -623,7 +639,7 @@ static int dabusb_open (struct inode *inode, struct file *file)
}
if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) {
mutex_unlock(&s->mutex);
err("set_interface failed");
dev_err(&s->usbdev->dev, "set_interface failed\n");
return -EINVAL;
}
s->opened = 1;
Expand All @@ -648,7 +664,7 @@ static int dabusb_release (struct inode *inode, struct file *file)

if (!s->remove_pending) {
if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0)
err("set_interface failed");
dev_err(&s->usbdev->dev, "set_interface failed\n");
}
else
wake_up (&s->remove_ok);
Expand Down Expand Up @@ -764,7 +780,7 @@ static int dabusb_probe (struct usb_interface *intf,
s->devnum = intf->minor;

if (usb_reset_configuration (usbdev) < 0) {
err("reset_configuration failed");
dev_err(&intf->dev, "reset_configuration failed\n");
goto reject;
}
if (le16_to_cpu(usbdev->descriptor.idProduct) == 0x2131) {
Expand All @@ -775,7 +791,7 @@ static int dabusb_probe (struct usb_interface *intf,
dabusb_fpga_download (s, NULL);

if (usb_set_interface (s->usbdev, _DABUSB_IF, 0) < 0) {
err("set_interface failed");
dev_err(&intf->dev, "set_interface failed\n");
goto reject;
}
}
Expand Down
12 changes: 7 additions & 5 deletions drivers/media/video/pvrusb2/pvrusb2-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,9 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
dip->minor_type = pvr2_v4l_type_video;
nr_ptr = video_nr;
if (!dip->stream) {
err("Failed to set up pvrusb2 v4l video dev"
" due to missing stream instance");
pr_err(KBUILD_MODNAME
": Failed to set up pvrusb2 v4l video dev"
" due to missing stream instance\n");
return;
}
break;
Expand All @@ -1286,8 +1287,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
break;
default:
/* Bail out (this should be impossible) */
err("Failed to set up pvrusb2 v4l dev"
" due to unrecognized config");
pr_err(KBUILD_MODNAME ": Failed to set up pvrusb2 v4l dev"
" due to unrecognized config\n");
return;
}

Expand All @@ -1303,7 +1304,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
dip->v4l_type, mindevnum) < 0) &&
(video_register_device(&dip->devbase,
dip->v4l_type, -1) < 0)) {
err("Failed to register pvrusb2 v4l device");
pr_err(KBUILD_MODNAME
": Failed to register pvrusb2 v4l device\n");
}

printk(KERN_INFO "pvrusb2: registered device %s%u [%s]\n",
Expand Down
38 changes: 23 additions & 15 deletions drivers/media/video/s2255drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,19 @@ static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
u16 index, u16 value, void *buf,
s32 buf_len, int bOut);

/* dev_err macro with driver name */
#define S2255_DRIVER_NAME "s2255"
#define s2255_dev_err(dev, fmt, arg...) \
dev_err(dev, S2255_DRIVER_NAME " - " fmt, ##arg)

#define dprintk(level, fmt, arg...) \
do { \
if (*s2255_debug >= (level)) { \
printk(KERN_DEBUG "s2255: " fmt, ##arg); \
printk(KERN_DEBUG S2255_DRIVER_NAME \
": " fmt, ##arg); \
} \
} while (0)


static struct usb_driver s2255_driver;


Expand Down Expand Up @@ -528,14 +533,14 @@ static void s2255_fwchunk_complete(struct urb *urb)
int len;
dprintk(100, "udev %p urb %p", udev, urb);
if (urb->status) {
dev_err(&udev->dev, "URB failed with status %d", urb->status);
dev_err(&udev->dev, "URB failed with status %d\n", urb->status);
atomic_set(&data->fw_state, S2255_FW_FAILED);
/* wake up anything waiting for the firmware */
wake_up(&data->wait_fw);
return;
}
if (data->fw_urb == NULL) {
dev_err(&udev->dev, "s2255 disconnected\n");
s2255_dev_err(&udev->dev, "disconnected\n");
atomic_set(&data->fw_state, S2255_FW_FAILED);
/* wake up anything waiting for the firmware */
wake_up(&data->wait_fw);
Expand Down Expand Up @@ -1278,7 +1283,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
}

if (!res_get(dev, fh)) {
dev_err(&dev->udev->dev, "s2255: stream busy\n");
s2255_dev_err(&dev->udev->dev, "stream busy\n");
return -EBUSY;
}

Expand Down Expand Up @@ -1545,7 +1550,8 @@ static int s2255_open(struct file *file)

switch (atomic_read(&dev->fw_data->fw_state)) {
case S2255_FW_FAILED:
err("2255 firmware load failed. retrying.\n");
s2255_dev_err(&dev->udev->dev,
"firmware load failed. retrying.\n");
s2255_fwload_start(dev, 1);
wait_event_timeout(dev->fw_data->wait_fw,
((atomic_read(&dev->fw_data->fw_state)
Expand Down Expand Up @@ -2173,7 +2179,8 @@ static int s2255_board_init(struct s2255_dev *dev)

printk(KERN_INFO "2255 usb firmware version %d \n", fw_ver);
if (fw_ver < CUR_USB_FWVER)
err("usb firmware not up to date %d\n", fw_ver);
dev_err(&dev->udev->dev,
"usb firmware not up to date %d\n", fw_ver);

for (j = 0; j < MAX_CHANNELS; j++) {
dev->b_acquire[j] = 0;
Expand Down Expand Up @@ -2228,13 +2235,13 @@ static void read_pipe_completion(struct urb *purb)
dprintk(100, "read pipe completion %p, status %d\n", purb,
purb->status);
if (pipe_info == NULL) {
err("no context !");
dev_err(&purb->dev->dev, "no context!\n");
return;
}

dev = pipe_info->dev;
if (dev == NULL) {
err("no context !");
dev_err(&purb->dev->dev, "no context!\n");
return;
}
status = purb->status;
Expand Down Expand Up @@ -2286,7 +2293,7 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!pipe_info->stream_urb) {
dev_err(&dev->udev->dev,
"ReadStream: Unable to alloc URB");
"ReadStream: Unable to alloc URB\n");
return -ENOMEM;
}
/* transfer buffer allocated in board_init */
Expand Down Expand Up @@ -2391,7 +2398,7 @@ static void s2255_stop_readpipe(struct s2255_dev *dev)
int j;

if (dev == NULL) {
err("s2255: invalid device");
s2255_dev_err(&dev->udev->dev, "invalid device\n");
return;
}
dprintk(4, "stop read pipe\n");
Expand Down Expand Up @@ -2453,7 +2460,7 @@ static int s2255_probe(struct usb_interface *interface,
/* allocate memory for our device state and initialize it to zero */
dev = kzalloc(sizeof(struct s2255_dev), GFP_KERNEL);
if (dev == NULL) {
err("s2255: out of memory");
s2255_dev_err(&interface->dev, "out of memory\n");
goto error;
}

Expand Down Expand Up @@ -2487,7 +2494,7 @@ static int s2255_probe(struct usb_interface *interface,
}

if (!dev->read_endpoint) {
dev_err(&interface->dev, "Could not find bulk-in endpoint");
dev_err(&interface->dev, "Could not find bulk-in endpoint\n");
goto error;
}

Expand Down Expand Up @@ -2583,7 +2590,7 @@ static void s2255_disconnect(struct usb_interface *interface)
}

static struct usb_driver s2255_driver = {
.name = "s2255",
.name = S2255_DRIVER_NAME,
.probe = s2255_probe,
.disconnect = s2255_disconnect,
.id_table = s2255_table,
Expand All @@ -2597,7 +2604,8 @@ static int __init usb_s2255_init(void)
result = usb_register(&s2255_driver);

if (result)
err("usb_register failed. Error number %d", result);
pr_err(KBUILD_MODNAME
": usb_register failed. Error number %d\n", result);

dprintk(2, "s2255_init: done\n");
return result;
Expand Down
Loading

0 comments on commit be9ed51

Please sign in to comment.