Commit f1bd9bd6 authored by Joe Perches's avatar Joe Perches Committed by Mauro Carvalho Chehab

media: stkwebcam: Use more common logging styles

Convert STK_<LEVEL> to pr_<level> to use the typical kernel logging.
Add a define for pr_fmt.  No change in logging output.

Miscellanea:

o Remove now unused PREFIX and STK_<LEVEL> macros
o Realign arguments
o Use pr_<level>_ratelimited
o Add a few missing newlines to formats
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 9b80f12e
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
/* It seems the i2c bus is controlled with these registers */ /* It seems the i2c bus is controlled with these registers */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "stk-webcam.h" #include "stk-webcam.h"
#define STK_IIC_BASE (0x0200) #define STK_IIC_BASE (0x0200)
...@@ -239,8 +241,8 @@ static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val) ...@@ -239,8 +241,8 @@ static int stk_sensor_outb(struct stk_camera *dev, u8 reg, u8 val)
} while (tmpval == 0 && i < MAX_RETRIES); } while (tmpval == 0 && i < MAX_RETRIES);
if (tmpval != STK_IIC_STAT_TX_OK) { if (tmpval != STK_IIC_STAT_TX_OK) {
if (tmpval) if (tmpval)
STK_ERROR("stk_sensor_outb failed, status=0x%02x\n", pr_err("stk_sensor_outb failed, status=0x%02x\n",
tmpval); tmpval);
return 1; return 1;
} else } else
return 0; return 0;
...@@ -262,8 +264,8 @@ static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val) ...@@ -262,8 +264,8 @@ static int stk_sensor_inb(struct stk_camera *dev, u8 reg, u8 *val)
} while (tmpval == 0 && i < MAX_RETRIES); } while (tmpval == 0 && i < MAX_RETRIES);
if (tmpval != STK_IIC_STAT_RX_OK) { if (tmpval != STK_IIC_STAT_RX_OK) {
if (tmpval) if (tmpval)
STK_ERROR("stk_sensor_inb failed, status=0x%02x\n", pr_err("stk_sensor_inb failed, status=0x%02x\n",
tmpval); tmpval);
return 1; return 1;
} }
...@@ -366,29 +368,29 @@ int stk_sensor_init(struct stk_camera *dev) ...@@ -366,29 +368,29 @@ int stk_sensor_init(struct stk_camera *dev)
if (stk_camera_write_reg(dev, STK_IIC_ENABLE, STK_IIC_ENABLE_YES) if (stk_camera_write_reg(dev, STK_IIC_ENABLE, STK_IIC_ENABLE_YES)
|| stk_camera_write_reg(dev, STK_IIC_ADDR, SENSOR_ADDRESS) || stk_camera_write_reg(dev, STK_IIC_ADDR, SENSOR_ADDRESS)
|| stk_sensor_outb(dev, REG_COM7, COM7_RESET)) { || stk_sensor_outb(dev, REG_COM7, COM7_RESET)) {
STK_ERROR("Sensor resetting failed\n"); pr_err("Sensor resetting failed\n");
return -ENODEV; return -ENODEV;
} }
msleep(10); msleep(10);
/* Read the manufacturer ID: ov = 0x7FA2 */ /* Read the manufacturer ID: ov = 0x7FA2 */
if (stk_sensor_inb(dev, REG_MIDH, &idh) if (stk_sensor_inb(dev, REG_MIDH, &idh)
|| stk_sensor_inb(dev, REG_MIDL, &idl)) { || stk_sensor_inb(dev, REG_MIDL, &idl)) {
STK_ERROR("Strange error reading sensor ID\n"); pr_err("Strange error reading sensor ID\n");
return -ENODEV; return -ENODEV;
} }
if (idh != 0x7f || idl != 0xa2) { if (idh != 0x7f || idl != 0xa2) {
STK_ERROR("Huh? you don't have a sensor from ovt\n"); pr_err("Huh? you don't have a sensor from ovt\n");
return -ENODEV; return -ENODEV;
} }
if (stk_sensor_inb(dev, REG_PID, &idh) if (stk_sensor_inb(dev, REG_PID, &idh)
|| stk_sensor_inb(dev, REG_VER, &idl)) { || stk_sensor_inb(dev, REG_VER, &idl)) {
STK_ERROR("Could not read sensor model\n"); pr_err("Could not read sensor model\n");
return -ENODEV; return -ENODEV;
} }
stk_sensor_write_regvals(dev, ov_initvals); stk_sensor_write_regvals(dev, ov_initvals);
msleep(10); msleep(10);
STK_INFO("OmniVision sensor detected, id %02X%02X at address %x\n", pr_info("OmniVision sensor detected, id %02X%02X at address %x\n",
idh, idl, SENSOR_ADDRESS); idh, idl, SENSOR_ADDRESS);
return 0; return 0;
} }
...@@ -520,7 +522,8 @@ int stk_sensor_configure(struct stk_camera *dev) ...@@ -520,7 +522,8 @@ int stk_sensor_configure(struct stk_camera *dev)
case MODE_SXGA: com7 = COM7_FMT_SXGA; case MODE_SXGA: com7 = COM7_FMT_SXGA;
dummylines = 0; dummylines = 0;
break; break;
default: STK_ERROR("Unsupported mode %d\n", dev->vsettings.mode); default:
pr_err("Unsupported mode %d\n", dev->vsettings.mode);
return -EFAULT; return -EFAULT;
} }
switch (dev->vsettings.palette) { switch (dev->vsettings.palette) {
...@@ -544,7 +547,8 @@ int stk_sensor_configure(struct stk_camera *dev) ...@@ -544,7 +547,8 @@ int stk_sensor_configure(struct stk_camera *dev)
com7 |= COM7_PBAYER; com7 |= COM7_PBAYER;
rv = ov_fmt_bayer; rv = ov_fmt_bayer;
break; break;
default: STK_ERROR("Unsupported colorspace\n"); default:
pr_err("Unsupported colorspace\n");
return -EFAULT; return -EFAULT;
} }
/*FIXME sometimes the sensor go to a bad state /*FIXME sometimes the sensor go to a bad state
...@@ -564,7 +568,7 @@ int stk_sensor_configure(struct stk_camera *dev) ...@@ -564,7 +568,7 @@ int stk_sensor_configure(struct stk_camera *dev)
switch (dev->vsettings.mode) { switch (dev->vsettings.mode) {
case MODE_VGA: case MODE_VGA:
if (stk_sensor_set_hw(dev, 302, 1582, 6, 486)) if (stk_sensor_set_hw(dev, 302, 1582, 6, 486))
STK_ERROR("stk_sensor_set_hw failed (VGA)\n"); pr_err("stk_sensor_set_hw failed (VGA)\n");
break; break;
case MODE_SXGA: case MODE_SXGA:
case MODE_CIF: case MODE_CIF:
...@@ -572,7 +576,7 @@ int stk_sensor_configure(struct stk_camera *dev) ...@@ -572,7 +576,7 @@ int stk_sensor_configure(struct stk_camera *dev)
case MODE_QCIF: case MODE_QCIF:
/*FIXME These settings seem ignored by the sensor /*FIXME These settings seem ignored by the sensor
if (stk_sensor_set_hw(dev, 220, 1500, 10, 1034)) if (stk_sensor_set_hw(dev, 220, 1500, 10, 1034))
STK_ERROR("stk_sensor_set_hw failed (SXGA)\n"); pr_err("stk_sensor_set_hw failed (SXGA)\n");
*/ */
break; break;
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -175,15 +177,15 @@ static int stk_start_stream(struct stk_camera *dev) ...@@ -175,15 +177,15 @@ static int stk_start_stream(struct stk_camera *dev)
if (!is_present(dev)) if (!is_present(dev))
return -ENODEV; return -ENODEV;
if (!is_memallocd(dev) || !is_initialised(dev)) { if (!is_memallocd(dev) || !is_initialised(dev)) {
STK_ERROR("FIXME: Buffers are not allocated\n"); pr_err("FIXME: Buffers are not allocated\n");
return -EFAULT; return -EFAULT;
} }
ret = usb_set_interface(dev->udev, 0, 5); ret = usb_set_interface(dev->udev, 0, 5);
if (ret < 0) if (ret < 0)
STK_ERROR("usb_set_interface failed !\n"); pr_err("usb_set_interface failed !\n");
if (stk_sensor_wakeup(dev)) if (stk_sensor_wakeup(dev))
STK_ERROR("error awaking the sensor\n"); pr_err("error awaking the sensor\n");
stk_camera_read_reg(dev, 0x0116, &value_116); stk_camera_read_reg(dev, 0x0116, &value_116);
stk_camera_read_reg(dev, 0x0117, &value_117); stk_camera_read_reg(dev, 0x0117, &value_117);
...@@ -224,9 +226,9 @@ static int stk_stop_stream(struct stk_camera *dev) ...@@ -224,9 +226,9 @@ static int stk_stop_stream(struct stk_camera *dev)
unset_streaming(dev); unset_streaming(dev);
if (usb_set_interface(dev->udev, 0, 0)) if (usb_set_interface(dev->udev, 0, 0))
STK_ERROR("usb_set_interface failed !\n"); pr_err("usb_set_interface failed !\n");
if (stk_sensor_sleep(dev)) if (stk_sensor_sleep(dev))
STK_ERROR("error suspending the sensor\n"); pr_err("error suspending the sensor\n");
} }
return 0; return 0;
} }
...@@ -313,7 +315,7 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -313,7 +315,7 @@ static void stk_isoc_handler(struct urb *urb)
dev = (struct stk_camera *) urb->context; dev = (struct stk_camera *) urb->context;
if (dev == NULL) { if (dev == NULL) {
STK_ERROR("isoc_handler called with NULL device !\n"); pr_err("isoc_handler called with NULL device !\n");
return; return;
} }
...@@ -326,14 +328,13 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -326,14 +328,13 @@ static void stk_isoc_handler(struct urb *urb)
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
if (urb->status != -EINPROGRESS && urb->status != 0) { if (urb->status != -EINPROGRESS && urb->status != 0) {
STK_ERROR("isoc_handler: urb->status == %d\n", urb->status); pr_err("isoc_handler: urb->status == %d\n", urb->status);
goto resubmit; goto resubmit;
} }
if (list_empty(&dev->sio_avail)) { if (list_empty(&dev->sio_avail)) {
/*FIXME Stop streaming after a while */ /*FIXME Stop streaming after a while */
(void) (printk_ratelimit() && pr_err_ratelimited("isoc_handler without available buffer!\n");
STK_ERROR("isoc_handler without available buffer!\n"));
goto resubmit; goto resubmit;
} }
fb = list_first_entry(&dev->sio_avail, fb = list_first_entry(&dev->sio_avail,
...@@ -343,8 +344,8 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -343,8 +344,8 @@ static void stk_isoc_handler(struct urb *urb)
for (i = 0; i < urb->number_of_packets; i++) { for (i = 0; i < urb->number_of_packets; i++) {
if (urb->iso_frame_desc[i].status != 0) { if (urb->iso_frame_desc[i].status != 0) {
if (urb->iso_frame_desc[i].status != -EXDEV) if (urb->iso_frame_desc[i].status != -EXDEV)
STK_ERROR("Frame %d has error %d\n", i, pr_err("Frame %d has error %d\n",
urb->iso_frame_desc[i].status); i, urb->iso_frame_desc[i].status);
continue; continue;
} }
framelen = urb->iso_frame_desc[i].actual_length; framelen = urb->iso_frame_desc[i].actual_length;
...@@ -368,9 +369,8 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -368,9 +369,8 @@ static void stk_isoc_handler(struct urb *urb)
/* This marks a new frame */ /* This marks a new frame */
if (fb->v4lbuf.bytesused != 0 if (fb->v4lbuf.bytesused != 0
&& fb->v4lbuf.bytesused != dev->frame_size) { && fb->v4lbuf.bytesused != dev->frame_size) {
(void) (printk_ratelimit() && pr_err_ratelimited("frame %d, bytesused=%d, skipping\n",
STK_ERROR("frame %d, bytesused=%d, skipping\n", i, fb->v4lbuf.bytesused);
i, fb->v4lbuf.bytesused));
fb->v4lbuf.bytesused = 0; fb->v4lbuf.bytesused = 0;
fill = fb->buffer; fill = fb->buffer;
} else if (fb->v4lbuf.bytesused == dev->frame_size) { } else if (fb->v4lbuf.bytesused == dev->frame_size) {
...@@ -395,8 +395,7 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -395,8 +395,7 @@ static void stk_isoc_handler(struct urb *urb)
/* Our buffer is full !!! */ /* Our buffer is full !!! */
if (framelen + fb->v4lbuf.bytesused > dev->frame_size) { if (framelen + fb->v4lbuf.bytesused > dev->frame_size) {
(void) (printk_ratelimit() && pr_err_ratelimited("Frame buffer overflow, lost sync\n");
STK_ERROR("Frame buffer overflow, lost sync\n"));
/*FIXME Do something here? */ /*FIXME Do something here? */
continue; continue;
} }
...@@ -414,8 +413,8 @@ static void stk_isoc_handler(struct urb *urb) ...@@ -414,8 +413,8 @@ static void stk_isoc_handler(struct urb *urb)
urb->dev = dev->udev; urb->dev = dev->udev;
ret = usb_submit_urb(urb, GFP_ATOMIC); ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret != 0) { if (ret != 0) {
STK_ERROR("Error (%d) re-submitting urb in stk_isoc_handler.\n", pr_err("Error (%d) re-submitting urb in stk_isoc_handler\n",
ret); ret);
} }
} }
...@@ -433,32 +432,31 @@ static int stk_prepare_iso(struct stk_camera *dev) ...@@ -433,32 +432,31 @@ static int stk_prepare_iso(struct stk_camera *dev)
udev = dev->udev; udev = dev->udev;
if (dev->isobufs) if (dev->isobufs)
STK_ERROR("isobufs already allocated. Bad\n"); pr_err("isobufs already allocated. Bad\n");
else else
dev->isobufs = kcalloc(MAX_ISO_BUFS, sizeof(*dev->isobufs), dev->isobufs = kcalloc(MAX_ISO_BUFS, sizeof(*dev->isobufs),
GFP_KERNEL); GFP_KERNEL);
if (dev->isobufs == NULL) { if (dev->isobufs == NULL) {
STK_ERROR("Unable to allocate iso buffers\n"); pr_err("Unable to allocate iso buffers\n");
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < MAX_ISO_BUFS; i++) { for (i = 0; i < MAX_ISO_BUFS; i++) {
if (dev->isobufs[i].data == NULL) { if (dev->isobufs[i].data == NULL) {
kbuf = kzalloc(ISO_BUFFER_SIZE, GFP_KERNEL); kbuf = kzalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
if (kbuf == NULL) { if (kbuf == NULL) {
STK_ERROR("Failed to allocate iso buffer %d\n", pr_err("Failed to allocate iso buffer %d\n", i);
i);
goto isobufs_out; goto isobufs_out;
} }
dev->isobufs[i].data = kbuf; dev->isobufs[i].data = kbuf;
} else } else
STK_ERROR("isobuf data already allocated\n"); pr_err("isobuf data already allocated\n");
if (dev->isobufs[i].urb == NULL) { if (dev->isobufs[i].urb == NULL) {
urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL); urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL);
if (urb == NULL) if (urb == NULL)
goto isobufs_out; goto isobufs_out;
dev->isobufs[i].urb = urb; dev->isobufs[i].urb = urb;
} else { } else {
STK_ERROR("Killing URB\n"); pr_err("Killing URB\n");
usb_kill_urb(dev->isobufs[i].urb); usb_kill_urb(dev->isobufs[i].urb);
urb = dev->isobufs[i].urb; urb = dev->isobufs[i].urb;
} }
...@@ -567,7 +565,7 @@ static int stk_prepare_sio_buffers(struct stk_camera *dev, unsigned n_sbufs) ...@@ -567,7 +565,7 @@ static int stk_prepare_sio_buffers(struct stk_camera *dev, unsigned n_sbufs)
{ {
int i; int i;
if (dev->sio_bufs != NULL) if (dev->sio_bufs != NULL)
STK_ERROR("sio_bufs already allocated\n"); pr_err("sio_bufs already allocated\n");
else { else {
dev->sio_bufs = kzalloc(n_sbufs * sizeof(struct stk_sio_buffer), dev->sio_bufs = kzalloc(n_sbufs * sizeof(struct stk_sio_buffer),
GFP_KERNEL); GFP_KERNEL);
...@@ -690,7 +688,7 @@ static ssize_t stk_read(struct file *fp, char __user *buf, ...@@ -690,7 +688,7 @@ static ssize_t stk_read(struct file *fp, char __user *buf,
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
if (list_empty(&dev->sio_full)) { if (list_empty(&dev->sio_full)) {
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
STK_ERROR("BUG: No siobufs ready\n"); pr_err("BUG: No siobufs ready\n");
return 0; return 0;
} }
sbuf = list_first_entry(&dev->sio_full, struct stk_sio_buffer, list); sbuf = list_first_entry(&dev->sio_full, struct stk_sio_buffer, list);
...@@ -907,7 +905,7 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp, ...@@ -907,7 +905,7 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp,
stk_sizes[i].m != dev->vsettings.mode; i++) stk_sizes[i].m != dev->vsettings.mode; i++)
; ;
if (i == ARRAY_SIZE(stk_sizes)) { if (i == ARRAY_SIZE(stk_sizes)) {
STK_ERROR("ERROR: mode invalid\n"); pr_err("ERROR: mode invalid\n");
return -EINVAL; return -EINVAL;
} }
pix_format->width = stk_sizes[i].w; pix_format->width = stk_sizes[i].w;
...@@ -985,7 +983,7 @@ static int stk_setup_format(struct stk_camera *dev) ...@@ -985,7 +983,7 @@ static int stk_setup_format(struct stk_camera *dev)
stk_sizes[i].m != dev->vsettings.mode) stk_sizes[i].m != dev->vsettings.mode)
i++; i++;
if (i == ARRAY_SIZE(stk_sizes)) { if (i == ARRAY_SIZE(stk_sizes)) {
STK_ERROR("Something is broken in %s\n", __func__); pr_err("Something is broken in %s\n", __func__);
return -EFAULT; return -EFAULT;
} }
/* This registers controls some timings, not sure of what. */ /* This registers controls some timings, not sure of what. */
...@@ -1241,7 +1239,7 @@ static void stk_v4l_dev_release(struct video_device *vd) ...@@ -1241,7 +1239,7 @@ static void stk_v4l_dev_release(struct video_device *vd)
struct stk_camera *dev = vdev_to_camera(vd); struct stk_camera *dev = vdev_to_camera(vd);
if (dev->sio_bufs != NULL || dev->isobufs != NULL) if (dev->sio_bufs != NULL || dev->isobufs != NULL)
STK_ERROR("We are leaking memory\n"); pr_err("We are leaking memory\n");
usb_put_intf(dev->interface); usb_put_intf(dev->interface);
kfree(dev); kfree(dev);
} }
...@@ -1264,10 +1262,10 @@ static int stk_register_video_device(struct stk_camera *dev) ...@@ -1264,10 +1262,10 @@ static int stk_register_video_device(struct stk_camera *dev)
video_set_drvdata(&dev->vdev, dev); video_set_drvdata(&dev->vdev, dev);
err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
if (err) if (err)
STK_ERROR("v4l registration failed\n"); pr_err("v4l registration failed\n");
else else
STK_INFO("Syntek USB2.0 Camera is now controlling device %s\n", pr_info("Syntek USB2.0 Camera is now controlling device %s\n",
video_device_node_name(&dev->vdev)); video_device_node_name(&dev->vdev));
return err; return err;
} }
...@@ -1288,7 +1286,7 @@ static int stk_camera_probe(struct usb_interface *interface, ...@@ -1288,7 +1286,7 @@ static int stk_camera_probe(struct usb_interface *interface,
dev = kzalloc(sizeof(struct stk_camera), GFP_KERNEL); dev = kzalloc(sizeof(struct stk_camera), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL) {
STK_ERROR("Out of memory !\n"); pr_err("Out of memory !\n");
return -ENOMEM; return -ENOMEM;
} }
err = v4l2_device_register(&interface->dev, &dev->v4l2_dev); err = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
...@@ -1352,7 +1350,7 @@ static int stk_camera_probe(struct usb_interface *interface, ...@@ -1352,7 +1350,7 @@ static int stk_camera_probe(struct usb_interface *interface,
} }
} }
if (!dev->isoc_ep) { if (!dev->isoc_ep) {
STK_ERROR("Could not find isoc-in endpoint"); pr_err("Could not find isoc-in endpoint\n");
err = -ENODEV; err = -ENODEV;
goto error; goto error;
} }
...@@ -1387,8 +1385,8 @@ static void stk_camera_disconnect(struct usb_interface *interface) ...@@ -1387,8 +1385,8 @@ static void stk_camera_disconnect(struct usb_interface *interface)
wake_up_interruptible(&dev->wait_frame); wake_up_interruptible(&dev->wait_frame);
STK_INFO("Syntek USB2.0 Camera release resources device %s\n", pr_info("Syntek USB2.0 Camera release resources device %s\n",
video_device_node_name(&dev->vdev)); video_device_node_name(&dev->vdev));
video_unregister_device(&dev->vdev); video_unregister_device(&dev->vdev);
v4l2_ctrl_handler_free(&dev->hdl); v4l2_ctrl_handler_free(&dev->hdl);
......
...@@ -31,12 +31,6 @@ ...@@ -31,12 +31,6 @@
#define ISO_MAX_FRAME_SIZE 3 * 1024 #define ISO_MAX_FRAME_SIZE 3 * 1024
#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE) #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
#define PREFIX "stkwebcam: "
#define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
#define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
#define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
struct stk_iso_buf { struct stk_iso_buf {
void *data; void *data;
int length; int length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment