aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/s2255
diff options
context:
space:
mode:
authorsensoray-dev <linux-dev@sensoray.com>2014-01-29 13:24:07 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-02-04 07:01:14 -0500
commitf5402007da542ec5a583e92b8b6e2a96d625b537 (patch)
tree5c20154c1ddc22f72279e9364d484a38457c9cc7 /drivers/media/usb/s2255
parent2d27b37d3598b1ae57c48a3ac8ce388708d8cab8 (diff)
[media] s2255drv: checkpatch fix: coding style fix
Fixes all style warnings from scripts/checkpatch -f Signed-off-by: Dean Anderson <linux-dev@sensoray.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb/s2255')
-rw-r--r--drivers/media/usb/s2255/s2255drv.c333
1 files changed, 151 insertions, 182 deletions
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 6bc9b8e19e20..c6bdcccbd5c7 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -218,6 +218,7 @@ struct s2255_fmt; /*forward declaration */
218struct s2255_dev; 218struct s2255_dev;
219 219
220struct s2255_channel { 220struct s2255_channel {
221 struct s2255_dev *dev;
221 struct video_device vdev; 222 struct video_device vdev;
222 struct v4l2_ctrl_handler hdl; 223 struct v4l2_ctrl_handler hdl;
223 struct v4l2_ctrl *jpegqual_ctrl; 224 struct v4l2_ctrl *jpegqual_ctrl;
@@ -259,7 +260,7 @@ struct s2255_channel {
259 260
260struct s2255_dev { 261struct s2255_dev {
261 struct s2255_channel channel[MAX_CHANNELS]; 262 struct s2255_channel channel[MAX_CHANNELS];
262 struct v4l2_device v4l2_dev; 263 struct v4l2_device v4l2_dev;
263 atomic_t num_channels; 264 atomic_t num_channels;
264 int frames; 265 int frames;
265 struct mutex lock; /* channels[].vdev.lock */ 266 struct mutex lock; /* channels[].vdev.lock */
@@ -352,7 +353,6 @@ struct s2255_fh {
352static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0}; 353static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
353 354
354static int debug; 355static int debug;
355static int *s2255_debug = &debug;
356 356
357static int s2255_start_readpipe(struct s2255_dev *dev); 357static int s2255_start_readpipe(struct s2255_dev *dev);
358static void s2255_stop_readpipe(struct s2255_dev *dev); 358static void s2255_stop_readpipe(struct s2255_dev *dev);
@@ -373,13 +373,8 @@ static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
373#define s2255_dev_err(dev, fmt, arg...) \ 373#define s2255_dev_err(dev, fmt, arg...) \
374 dev_err(dev, S2255_DRIVER_NAME " - " fmt, ##arg) 374 dev_err(dev, S2255_DRIVER_NAME " - " fmt, ##arg)
375 375
376#define dprintk(level, fmt, arg...) \ 376#define dprintk(dev, level, fmt, arg...) \
377 do { \ 377 v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg)
378 if (*s2255_debug >= (level)) { \
379 printk(KERN_DEBUG S2255_DRIVER_NAME \
380 ": " fmt, ##arg); \
381 } \
382 } while (0)
383 378
384static struct usb_driver s2255_driver; 379static struct usb_driver s2255_driver;
385 380
@@ -498,7 +493,7 @@ static void planar422p_to_yuv_packed(const unsigned char *in,
498static void s2255_reset_dsppower(struct s2255_dev *dev) 493static void s2255_reset_dsppower(struct s2255_dev *dev)
499{ 494{
500 s2255_vendor_req(dev, 0x40, 0x0000, 0x0001, NULL, 0, 1); 495 s2255_vendor_req(dev, 0x40, 0x0000, 0x0001, NULL, 0, 1);
501 msleep(10); 496 msleep(20);
502 s2255_vendor_req(dev, 0x50, 0x0000, 0x0000, NULL, 0, 1); 497 s2255_vendor_req(dev, 0x50, 0x0000, 0x0000, NULL, 0, 1);
503 msleep(600); 498 msleep(600);
504 s2255_vendor_req(dev, 0x10, 0x0000, 0x0000, NULL, 0, 1); 499 s2255_vendor_req(dev, 0x10, 0x0000, 0x0000, NULL, 0, 1);
@@ -510,9 +505,8 @@ static void s2255_reset_dsppower(struct s2255_dev *dev)
510static void s2255_timer(unsigned long user_data) 505static void s2255_timer(unsigned long user_data)
511{ 506{
512 struct s2255_fw *data = (struct s2255_fw *)user_data; 507 struct s2255_fw *data = (struct s2255_fw *)user_data;
513 dprintk(100, "%s\n", __func__);
514 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) { 508 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) {
515 printk(KERN_ERR "s2255: can't submit urb\n"); 509 pr_err("s2255: can't submit urb\n");
516 atomic_set(&data->fw_state, S2255_FW_FAILED); 510 atomic_set(&data->fw_state, S2255_FW_FAILED);
517 /* wake up anything waiting for the firmware */ 511 /* wake up anything waiting for the firmware */
518 wake_up(&data->wait_fw); 512 wake_up(&data->wait_fw);
@@ -532,7 +526,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
532 struct s2255_fw *data = urb->context; 526 struct s2255_fw *data = urb->context;
533 struct usb_device *udev = urb->dev; 527 struct usb_device *udev = urb->dev;
534 int len; 528 int len;
535 dprintk(100, "%s: udev %p urb %p", __func__, udev, urb);
536 if (urb->status) { 529 if (urb->status) {
537 dev_err(&udev->dev, "URB failed with status %d\n", urb->status); 530 dev_err(&udev->dev, "URB failed with status %d\n", urb->status);
538 atomic_set(&data->fw_state, S2255_FW_FAILED); 531 atomic_set(&data->fw_state, S2255_FW_FAILED);
@@ -559,9 +552,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
559 if (len < CHUNK_SIZE) 552 if (len < CHUNK_SIZE)
560 memset(data->pfw_data, 0, CHUNK_SIZE); 553 memset(data->pfw_data, 0, CHUNK_SIZE);
561 554
562 dprintk(100, "completed len %d, loaded %d \n", len,
563 data->fw_loaded);
564
565 memcpy(data->pfw_data, 555 memcpy(data->pfw_data,
566 (char *) data->fw->data + data->fw_loaded, len); 556 (char *) data->fw->data + data->fw_loaded, len);
567 557
@@ -576,10 +566,8 @@ static void s2255_fwchunk_complete(struct urb *urb)
576 return; 566 return;
577 } 567 }
578 data->fw_loaded += len; 568 data->fw_loaded += len;
579 } else { 569 } else
580 atomic_set(&data->fw_state, S2255_FW_LOADED_DSPWAIT); 570 atomic_set(&data->fw_state, S2255_FW_LOADED_DSPWAIT);
581 dprintk(100, "%s: firmware upload complete\n", __func__);
582 }
583 return; 571 return;
584 572
585} 573}
@@ -593,7 +581,7 @@ static int s2255_got_frame(struct s2255_channel *channel, int jpgsize)
593 int rc = 0; 581 int rc = 0;
594 spin_lock_irqsave(&dev->slock, flags); 582 spin_lock_irqsave(&dev->slock, flags);
595 if (list_empty(&dma_q->active)) { 583 if (list_empty(&dma_q->active)) {
596 dprintk(1, "No active queue to serve\n"); 584 dprintk(dev, 1, "No active queue to serve\n");
597 rc = -1; 585 rc = -1;
598 goto unlock; 586 goto unlock;
599 } 587 }
@@ -603,7 +591,7 @@ static int s2255_got_frame(struct s2255_channel *channel, int jpgsize)
603 v4l2_get_timestamp(&buf->vb.ts); 591 v4l2_get_timestamp(&buf->vb.ts);
604 s2255_fillbuff(channel, buf, jpgsize); 592 s2255_fillbuff(channel, buf, jpgsize);
605 wake_up(&buf->vb.done); 593 wake_up(&buf->vb.done);
606 dprintk(2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i); 594 dprintk(dev, 2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i);
607unlock: 595unlock:
608 spin_unlock_irqrestore(&dev->slock, flags); 596 spin_unlock_irqrestore(&dev->slock, flags);
609 return rc; 597 return rc;
@@ -615,9 +603,9 @@ static const struct s2255_fmt *format_by_fourcc(int fourcc)
615 for (i = 0; i < ARRAY_SIZE(formats); i++) { 603 for (i = 0; i < ARRAY_SIZE(formats); i++) {
616 if (-1 == formats[i].fourcc) 604 if (-1 == formats[i].fourcc)
617 continue; 605 continue;
618 if (!jpeg_enable && ((formats[i].fourcc == V4L2_PIX_FMT_JPEG) || 606 if (!jpeg_enable && ((formats[i].fourcc == V4L2_PIX_FMT_JPEG) ||
619 (formats[i].fourcc == V4L2_PIX_FMT_MJPEG))) 607 (formats[i].fourcc == V4L2_PIX_FMT_MJPEG)))
620 continue; 608 continue;
621 if (formats[i].fourcc == fourcc) 609 if (formats[i].fourcc == fourcc)
622 return formats + i; 610 return formats + i;
623 } 611 }
@@ -639,6 +627,7 @@ static void s2255_fillbuff(struct s2255_channel *channel,
639 const char *tmpbuf; 627 const char *tmpbuf;
640 char *vbuf = videobuf_to_vmalloc(&buf->vb); 628 char *vbuf = videobuf_to_vmalloc(&buf->vb);
641 unsigned long last_frame; 629 unsigned long last_frame;
630 struct s2255_dev *dev = channel->dev;
642 631
643 if (!vbuf) 632 if (!vbuf)
644 return; 633 return;
@@ -667,18 +656,16 @@ static void s2255_fillbuff(struct s2255_channel *channel,
667 buf->vb.width * buf->vb.height * 2); 656 buf->vb.width * buf->vb.height * 2);
668 break; 657 break;
669 default: 658 default:
670 printk(KERN_DEBUG "s2255: unknown format?\n"); 659 pr_info("s2255: unknown format?\n");
671 } 660 }
672 channel->last_frame = -1; 661 channel->last_frame = -1;
673 } else { 662 } else {
674 printk(KERN_ERR "s2255: =======no frame\n"); 663 pr_err("s2255: =======no frame\n");
675 return; 664 return;
676
677 } 665 }
678 dprintk(2, "s2255fill at : Buffer 0x%08lx size= %d\n", 666 dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n",
679 (unsigned long)vbuf, pos); 667 (unsigned long)vbuf, pos);
680 /* tell v4l buffer was filled */ 668 /* tell v4l buffer was filled */
681
682 buf->vb.field_count = channel->frame_count * 2; 669 buf->vb.field_count = channel->frame_count * 2;
683 v4l2_get_timestamp(&buf->vb.ts); 670 v4l2_get_timestamp(&buf->vb.ts);
684 buf->vb.state = VIDEOBUF_DONE; 671 buf->vb.state = VIDEOBUF_DONE;
@@ -707,8 +694,6 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
707 694
708static void free_buffer(struct videobuf_queue *vq, struct s2255_buffer *buf) 695static void free_buffer(struct videobuf_queue *vq, struct s2255_buffer *buf)
709{ 696{
710 dprintk(4, "%s\n", __func__);
711
712 videobuf_vmalloc_free(&buf->vb); 697 videobuf_vmalloc_free(&buf->vb);
713 buf->vb.state = VIDEOBUF_NEEDS_INIT; 698 buf->vb.state = VIDEOBUF_NEEDS_INIT;
714} 699}
@@ -722,7 +707,7 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
722 int rc; 707 int rc;
723 int w = channel->width; 708 int w = channel->width;
724 int h = channel->height; 709 int h = channel->height;
725 dprintk(4, "%s, field=%d\n", __func__, field); 710 dprintk(fh->dev, 4, "%s, field=%d\n", __func__, field);
726 if (channel->fmt == NULL) 711 if (channel->fmt == NULL)
727 return -EINVAL; 712 return -EINVAL;
728 713
@@ -730,12 +715,12 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
730 (w > norm_maxw(channel)) || 715 (w > norm_maxw(channel)) ||
731 (h < norm_minh(channel)) || 716 (h < norm_minh(channel)) ||
732 (h > norm_maxh(channel))) { 717 (h > norm_maxh(channel))) {
733 dprintk(4, "invalid buffer prepare\n"); 718 dprintk(fh->dev, 4, "invalid buffer prepare\n");
734 return -EINVAL; 719 return -EINVAL;
735 } 720 }
736 buf->vb.size = w * h * (channel->fmt->depth >> 3); 721 buf->vb.size = w * h * (channel->fmt->depth >> 3);
737 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) { 722 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) {
738 dprintk(4, "invalid buffer prepare\n"); 723 dprintk(fh->dev, 4, "invalid buffer prepare\n");
739 return -EINVAL; 724 return -EINVAL;
740 } 725 }
741 726
@@ -763,7 +748,7 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
763 struct s2255_fh *fh = vq->priv_data; 748 struct s2255_fh *fh = vq->priv_data;
764 struct s2255_channel *channel = fh->channel; 749 struct s2255_channel *channel = fh->channel;
765 struct s2255_dmaqueue *vidq = &channel->vidq; 750 struct s2255_dmaqueue *vidq = &channel->vidq;
766 dprintk(1, "%s\n", __func__); 751 dprintk(fh->dev, 1, "%s\n", __func__);
767 buf->vb.state = VIDEOBUF_QUEUED; 752 buf->vb.state = VIDEOBUF_QUEUED;
768 list_add_tail(&buf->vb.queue, &vidq->active); 753 list_add_tail(&buf->vb.queue, &vidq->active);
769} 754}
@@ -773,7 +758,7 @@ static void buffer_release(struct videobuf_queue *vq,
773{ 758{
774 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 759 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
775 struct s2255_fh *fh = vq->priv_data; 760 struct s2255_fh *fh = vq->priv_data;
776 dprintk(4, "%s %d\n", __func__, fh->channel->idx); 761 dprintk(fh->dev, 4, "%s %d\n", __func__, fh->channel->idx);
777 free_buffer(vq, buf); 762 free_buffer(vq, buf);
778} 763}
779 764
@@ -794,7 +779,7 @@ static int res_get(struct s2255_fh *fh)
794 /* it's free, grab it */ 779 /* it's free, grab it */
795 channel->resources = 1; 780 channel->resources = 1;
796 fh->resources = 1; 781 fh->resources = 1;
797 dprintk(1, "s2255: res: get\n"); 782 dprintk(fh->dev, 1, "s2255: res: get\n");
798 return 1; 783 return 1;
799} 784}
800 785
@@ -814,7 +799,6 @@ static void res_free(struct s2255_fh *fh)
814 struct s2255_channel *channel = fh->channel; 799 struct s2255_channel *channel = fh->channel;
815 channel->resources = 0; 800 channel->resources = 0;
816 fh->resources = 0; 801 fh->resources = 0;
817 dprintk(1, "res: put\n");
818} 802}
819 803
820static int vidioc_querycap(struct file *file, void *priv, 804static int vidioc_querycap(struct file *file, void *priv,
@@ -841,7 +825,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
841 if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) || 825 if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
842 (formats[index].fourcc == V4L2_PIX_FMT_MJPEG))) 826 (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
843 return -EINVAL; 827 return -EINVAL;
844 dprintk(4, "name %s\n", formats[index].name);
845 strlcpy(f->description, formats[index].name, sizeof(f->description)); 828 strlcpy(f->description, formats[index].name, sizeof(f->description));
846 f->pixelformat = formats[index].fourcc; 829 f->pixelformat = formats[index].fourcc;
847 return 0; 830 return 0;
@@ -885,7 +868,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
885 868
886 field = f->fmt.pix.field; 869 field = f->fmt.pix.field;
887 870
888 dprintk(50, "%s NTSC: %d suggested width: %d, height: %d\n", 871 dprintk(fh->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n",
889 __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height); 872 __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height);
890 if (is_ntsc) { 873 if (is_ntsc) {
891 /* NTSC */ 874 /* NTSC */
@@ -927,7 +910,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
927 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 910 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
928 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 911 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
929 f->fmt.pix.priv = 0; 912 f->fmt.pix.priv = 0;
930 dprintk(50, "%s: set width %d height %d field %d\n", __func__, 913 dprintk(fh->dev, 50, "%s: set width %d height %d field %d\n", __func__,
931 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); 914 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
932 return 0; 915 return 0;
933} 916}
@@ -955,13 +938,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
955 mutex_lock(&q->vb_lock); 938 mutex_lock(&q->vb_lock);
956 939
957 if (videobuf_queue_is_busy(&fh->vb_vidq)) { 940 if (videobuf_queue_is_busy(&fh->vb_vidq)) {
958 dprintk(1, "queue busy\n"); 941 dprintk(fh->dev, 1, "queue busy\n");
959 ret = -EBUSY; 942 ret = -EBUSY;
960 goto out_s_fmt; 943 goto out_s_fmt;
961 } 944 }
962 945
963 if (res_locked(fh)) { 946 if (res_locked(fh)) {
964 dprintk(1, "%s: channel busy\n", __func__); 947 dprintk(fh->dev, 1, "%s: channel busy\n", __func__);
965 ret = -EBUSY; 948 ret = -EBUSY;
966 goto out_s_fmt; 949 goto out_s_fmt;
967 } 950 }
@@ -1160,7 +1143,7 @@ static int s2255_set_mode(struct s2255_channel *channel,
1160 int i; 1143 int i;
1161 1144
1162 chn_rev = G_chnmap[channel->idx]; 1145 chn_rev = G_chnmap[channel->idx];
1163 dprintk(3, "%s channel: %d\n", __func__, channel->idx); 1146 dprintk(dev, 3, "%s channel: %d\n", __func__, channel->idx);
1164 /* if JPEG, set the quality */ 1147 /* if JPEG, set the quality */
1165 if ((mode->color & MASK_COLOR) == COLOR_JPG) { 1148 if ((mode->color & MASK_COLOR) == COLOR_JPG) {
1166 mode->color &= ~MASK_COLOR; 1149 mode->color &= ~MASK_COLOR;
@@ -1171,7 +1154,7 @@ static int s2255_set_mode(struct s2255_channel *channel,
1171 /* save the mode */ 1154 /* save the mode */
1172 channel->mode = *mode; 1155 channel->mode = *mode;
1173 channel->req_image_size = get_transfer_size(mode); 1156 channel->req_image_size = get_transfer_size(mode);
1174 dprintk(1, "%s: reqsize %ld\n", __func__, channel->req_image_size); 1157 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, channel->req_image_size);
1175 buffer = kzalloc(512, GFP_KERNEL); 1158 buffer = kzalloc(512, GFP_KERNEL);
1176 if (buffer == NULL) { 1159 if (buffer == NULL) {
1177 dev_err(&dev->udev->dev, "out of mem\n"); 1160 dev_err(&dev->udev->dev, "out of mem\n");
@@ -1194,13 +1177,13 @@ static int s2255_set_mode(struct s2255_channel *channel,
1194 (channel->setmode_ready != 0), 1177 (channel->setmode_ready != 0),
1195 msecs_to_jiffies(S2255_SETMODE_TIMEOUT)); 1178 msecs_to_jiffies(S2255_SETMODE_TIMEOUT));
1196 if (channel->setmode_ready != 1) { 1179 if (channel->setmode_ready != 1) {
1197 printk(KERN_DEBUG "s2255: no set mode response\n"); 1180 dprintk(dev, 0, "s2255: no set mode response\n");
1198 res = -EFAULT; 1181 res = -EFAULT;
1199 } 1182 }
1200 } 1183 }
1201 /* clear the restart flag */ 1184 /* clear the restart flag */
1202 channel->mode.restart = 0; 1185 channel->mode.restart = 0;
1203 dprintk(1, "%s chn %d, result: %d\n", __func__, channel->idx, res); 1186 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, channel->idx, res);
1204 return res; 1187 return res;
1205} 1188}
1206 1189
@@ -1211,7 +1194,7 @@ static int s2255_cmd_status(struct s2255_channel *channel, u32 *pstatus)
1211 u32 chn_rev; 1194 u32 chn_rev;
1212 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 1195 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev);
1213 chn_rev = G_chnmap[channel->idx]; 1196 chn_rev = G_chnmap[channel->idx];
1214 dprintk(4, "%s chan %d\n", __func__, channel->idx); 1197 dprintk(dev, 4, "%s chan %d\n", __func__, channel->idx);
1215 buffer = kzalloc(512, GFP_KERNEL); 1198 buffer = kzalloc(512, GFP_KERNEL);
1216 if (buffer == NULL) { 1199 if (buffer == NULL) {
1217 dev_err(&dev->udev->dev, "out of mem\n"); 1200 dev_err(&dev->udev->dev, "out of mem\n");
@@ -1229,11 +1212,11 @@ static int s2255_cmd_status(struct s2255_channel *channel, u32 *pstatus)
1229 (channel->vidstatus_ready != 0), 1212 (channel->vidstatus_ready != 0),
1230 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT)); 1213 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT));
1231 if (channel->vidstatus_ready != 1) { 1214 if (channel->vidstatus_ready != 1) {
1232 printk(KERN_DEBUG "s2255: no vidstatus response\n"); 1215 dprintk(dev, 0, "s2255: no vidstatus response\n");
1233 res = -EFAULT; 1216 res = -EFAULT;
1234 } 1217 }
1235 *pstatus = channel->vidstatus; 1218 *pstatus = channel->vidstatus;
1236 dprintk(4, "%s, vid status %d\n", __func__, *pstatus); 1219 dprintk(dev, 4, "%s, vid status %d\n", __func__, *pstatus);
1237 return res; 1220 return res;
1238} 1221}
1239 1222
@@ -1244,7 +1227,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1244 struct s2255_dev *dev = fh->dev; 1227 struct s2255_dev *dev = fh->dev;
1245 struct s2255_channel *channel = fh->channel; 1228 struct s2255_channel *channel = fh->channel;
1246 int j; 1229 int j;
1247 dprintk(4, "%s\n", __func__); 1230 dprintk(dev, 4, "%s\n", __func__);
1248 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1231 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1249 dev_err(&dev->udev->dev, "invalid fh type0\n"); 1232 dev_err(&dev->udev->dev, "invalid fh type0\n");
1250 return -EINVAL; 1233 return -EINVAL;
@@ -1279,15 +1262,13 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1279static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) 1262static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1280{ 1263{
1281 struct s2255_fh *fh = priv; 1264 struct s2255_fh *fh = priv;
1282 dprintk(4, "%s\n, channel: %d", __func__, fh->channel->idx); 1265 dprintk(fh->dev, 4, "%s\n, channel: %d", __func__, fh->channel->idx);
1283 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1266 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1284 printk(KERN_ERR "invalid fh type0\n"); 1267 dprintk(fh->dev, 1, "invalid fh type0\n");
1285 return -EINVAL; 1268 return -EINVAL;
1286 } 1269 }
1287 if (i != fh->type) { 1270 if (i != fh->type)
1288 printk(KERN_ERR "invalid type i\n");
1289 return -EINVAL; 1271 return -EINVAL;
1290 }
1291 s2255_stop_acquire(fh->channel); 1272 s2255_stop_acquire(fh->channel);
1292 videobuf_streamoff(&fh->vb_vidq); 1273 videobuf_streamoff(&fh->vb_vidq);
1293 res_free(fh); 1274 res_free(fh);
@@ -1304,13 +1285,13 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1304 1285
1305 mutex_lock(&q->vb_lock); 1286 mutex_lock(&q->vb_lock);
1306 if (res_locked(fh)) { 1287 if (res_locked(fh)) {
1307 dprintk(1, "can't change standard after started\n"); 1288 dprintk(fh->dev, 1, "can't change standard after started\n");
1308 ret = -EBUSY; 1289 ret = -EBUSY;
1309 goto out_s_std; 1290 goto out_s_std;
1310 } 1291 }
1311 mode = fh->channel->mode; 1292 mode = fh->channel->mode;
1312 if (i & V4L2_STD_525_60) { 1293 if (i & V4L2_STD_525_60) {
1313 dprintk(4, "%s 60 Hz\n", __func__); 1294 dprintk(fh->dev, 4, "%s 60 Hz\n", __func__);
1314 /* if changing format, reset frame decimation/intervals */ 1295 /* if changing format, reset frame decimation/intervals */
1315 if (mode.format != FORMAT_NTSC) { 1296 if (mode.format != FORMAT_NTSC) {
1316 mode.restart = 1; 1297 mode.restart = 1;
@@ -1320,7 +1301,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1320 channel->height = NUM_LINES_4CIFS_NTSC * 2; 1301 channel->height = NUM_LINES_4CIFS_NTSC * 2;
1321 } 1302 }
1322 } else if (i & V4L2_STD_625_50) { 1303 } else if (i & V4L2_STD_625_50) {
1323 dprintk(4, "%s 50 Hz\n", __func__); 1304 dprintk(fh->dev, 4, "%s 50 Hz\n", __func__);
1324 if (mode.format != FORMAT_PAL) { 1305 if (mode.format != FORMAT_PAL) {
1325 mode.restart = 1; 1306 mode.restart = 1;
1326 mode.format = FORMAT_PAL; 1307 mode.format = FORMAT_PAL;
@@ -1370,7 +1351,8 @@ static int vidioc_enum_input(struct file *file, void *priv,
1370 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) { 1351 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) {
1371 int rc; 1352 int rc;
1372 rc = s2255_cmd_status(fh->channel, &status); 1353 rc = s2255_cmd_status(fh->channel, &status);
1373 dprintk(4, "s2255_cmd_status rc: %d status %x\n", rc, status); 1354 dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n",
1355 rc, status);
1374 if (rc == 0) 1356 if (rc == 0)
1375 inp->status = (status & 0x01) ? 0 1357 inp->status = (status & 0x01) ? 0
1376 : V4L2_IN_ST_NO_SIGNAL; 1358 : V4L2_IN_ST_NO_SIGNAL;
@@ -1405,10 +1387,7 @@ static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1405 struct s2255_channel *channel = 1387 struct s2255_channel *channel =
1406 container_of(ctrl->handler, struct s2255_channel, hdl); 1388 container_of(ctrl->handler, struct s2255_channel, hdl);
1407 struct s2255_mode mode; 1389 struct s2255_mode mode;
1408
1409 mode = channel->mode; 1390 mode = channel->mode;
1410 dprintk(4, "%s\n", __func__);
1411
1412 /* update the mode to the corresponding value */ 1391 /* update the mode to the corresponding value */
1413 switch (ctrl->id) { 1392 switch (ctrl->id) {
1414 case V4L2_CID_BRIGHTNESS: 1393 case V4L2_CID_BRIGHTNESS:
@@ -1450,7 +1429,7 @@ static int vidioc_g_jpegcomp(struct file *file, void *priv,
1450 1429
1451 memset(jc, 0, sizeof(*jc)); 1430 memset(jc, 0, sizeof(*jc));
1452 jc->quality = channel->jpegqual; 1431 jc->quality = channel->jpegqual;
1453 dprintk(2, "%s: quality %d\n", __func__, jc->quality); 1432 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1454 return 0; 1433 return 0;
1455} 1434}
1456 1435
@@ -1462,7 +1441,7 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
1462 if (jc->quality < 0 || jc->quality > 100) 1441 if (jc->quality < 0 || jc->quality > 100)
1463 return -EINVAL; 1442 return -EINVAL;
1464 v4l2_ctrl_s_ctrl(channel->jpegqual_ctrl, jc->quality); 1443 v4l2_ctrl_s_ctrl(channel->jpegqual_ctrl, jc->quality);
1465 dprintk(2, "%s: quality %d\n", __func__, jc->quality); 1444 dprintk(fh->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1466 return 0; 1445 return 0;
1467} 1446}
1468 1447
@@ -1494,7 +1473,8 @@ static int vidioc_g_parm(struct file *file, void *priv,
1494 sp->parm.capture.timeperframe.numerator = def_num * 5; 1473 sp->parm.capture.timeperframe.numerator = def_num * 5;
1495 break; 1474 break;
1496 } 1475 }
1497 dprintk(4, "%s capture mode, %d timeperframe %d/%d\n", __func__, 1476 dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d\n",
1477 __func__,
1498 sp->parm.capture.capturemode, 1478 sp->parm.capture.capturemode,
1499 sp->parm.capture.timeperframe.numerator, 1479 sp->parm.capture.timeperframe.numerator,
1500 sp->parm.capture.timeperframe.denominator); 1480 sp->parm.capture.timeperframe.denominator);
@@ -1535,7 +1515,7 @@ static int vidioc_s_parm(struct file *file, void *priv,
1535 mode.fdec = fdec; 1515 mode.fdec = fdec;
1536 sp->parm.capture.timeperframe.denominator = def_dem; 1516 sp->parm.capture.timeperframe.denominator = def_dem;
1537 s2255_set_mode(channel, &mode); 1517 s2255_set_mode(channel, &mode);
1538 dprintk(4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", 1518 dprintk(fh->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n",
1539 __func__, 1519 __func__,
1540 sp->parm.capture.capturemode, 1520 sp->parm.capture.capturemode,
1541 sp->parm.capture.timeperframe.numerator, 1521 sp->parm.capture.timeperframe.numerator,
@@ -1604,7 +1584,8 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1604 fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; 1584 fe->type = V4L2_FRMIVAL_TYPE_DISCRETE;
1605 fe->discrete.denominator = is_ntsc ? 30000 : 25000; 1585 fe->discrete.denominator = is_ntsc ? 30000 : 25000;
1606 fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; 1586 fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index];
1607 dprintk(4, "%s discrete %d/%d\n", __func__, fe->discrete.numerator, 1587 dprintk(fh->dev, 4, "%s discrete %d/%d\n", __func__,
1588 fe->discrete.numerator,
1608 fe->discrete.denominator); 1589 fe->discrete.denominator);
1609 return 0; 1590 return 0;
1610} 1591}
@@ -1617,7 +1598,7 @@ static int __s2255_open(struct file *file)
1617 struct s2255_fh *fh; 1598 struct s2255_fh *fh;
1618 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1599 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1619 int state; 1600 int state;
1620 dprintk(1, "s2255: open called (dev=%s)\n", 1601 dprintk(dev, 1, "s2255: open called (dev=%s)\n",
1621 video_device_node_name(vdev)); 1602 video_device_node_name(vdev));
1622 state = atomic_read(&dev->fw_data->fw_state); 1603 state = atomic_read(&dev->fw_data->fw_state);
1623 switch (state) { 1604 switch (state) {
@@ -1640,7 +1621,7 @@ static int __s2255_open(struct file *file)
1640 case S2255_FW_LOADED_DSPWAIT: 1621 case S2255_FW_LOADED_DSPWAIT:
1641 /* give S2255_LOAD_TIMEOUT time for firmware to load in case 1622 /* give S2255_LOAD_TIMEOUT time for firmware to load in case
1642 driver loaded and then device immediately opened */ 1623 driver loaded and then device immediately opened */
1643 printk(KERN_INFO "%s waiting for firmware load\n", __func__); 1624 pr_info("%s waiting for firmware load\n", __func__);
1644 wait_event_timeout(dev->fw_data->wait_fw, 1625 wait_event_timeout(dev->fw_data->wait_fw,
1645 ((atomic_read(&dev->fw_data->fw_state) 1626 ((atomic_read(&dev->fw_data->fw_state)
1646 == S2255_FW_SUCCESS) || 1627 == S2255_FW_SUCCESS) ||
@@ -1659,16 +1640,15 @@ static int __s2255_open(struct file *file)
1659 case S2255_FW_SUCCESS: 1640 case S2255_FW_SUCCESS:
1660 break; 1641 break;
1661 case S2255_FW_FAILED: 1642 case S2255_FW_FAILED:
1662 printk(KERN_INFO "2255 firmware load failed.\n"); 1643 pr_info("2255 firmware load failed.\n");
1663 return -ENODEV; 1644 return -ENODEV;
1664 case S2255_FW_DISCONNECTING: 1645 case S2255_FW_DISCONNECTING:
1665 printk(KERN_INFO "%s: disconnecting\n", __func__); 1646 pr_info("%s: disconnecting\n", __func__);
1666 return -ENODEV; 1647 return -ENODEV;
1667 case S2255_FW_LOADED_DSPWAIT: 1648 case S2255_FW_LOADED_DSPWAIT:
1668 case S2255_FW_NOTLOADED: 1649 case S2255_FW_NOTLOADED:
1669 printk(KERN_INFO "%s: firmware not loaded yet" 1650 pr_info("%s: firmware not loaded, please retry\n",
1670 "please try again later\n", 1651 __func__);
1671 __func__);
1672 /* 1652 /*
1673 * Timeout on firmware load means device unusable. 1653 * Timeout on firmware load means device unusable.
1674 * Set firmware failure state. 1654 * Set firmware failure state.
@@ -1678,7 +1658,7 @@ static int __s2255_open(struct file *file)
1678 S2255_FW_FAILED); 1658 S2255_FW_FAILED);
1679 return -EAGAIN; 1659 return -EAGAIN;
1680 default: 1660 default:
1681 printk(KERN_INFO "%s: unknown state\n", __func__); 1661 pr_info("%s: unknown state\n", __func__);
1682 return -EFAULT; 1662 return -EFAULT;
1683 } 1663 }
1684 /* allocate + initialize per filehandle data */ 1664 /* allocate + initialize per filehandle data */
@@ -1697,12 +1677,12 @@ static int __s2255_open(struct file *file)
1697 s2255_set_mode(channel, &channel->mode); 1677 s2255_set_mode(channel, &channel->mode);
1698 channel->configured = 1; 1678 channel->configured = 1;
1699 } 1679 }
1700 dprintk(1, "%s: dev=%s type=%s\n", __func__, 1680 dprintk(dev, 1, "%s: dev=%s type=%s\n", __func__,
1701 video_device_node_name(vdev), v4l2_type_names[type]); 1681 video_device_node_name(vdev), v4l2_type_names[type]);
1702 dprintk(2, "%s: fh=0x%08lx, dev=0x%08lx, vidq=0x%08lx\n", __func__, 1682 dprintk(dev, 2, "%s: fh=0x%08lx, dev=0x%08lx, vidq=0x%08lx\n", __func__,
1703 (unsigned long)fh, (unsigned long)dev, 1683 (unsigned long)fh, (unsigned long)dev,
1704 (unsigned long)&channel->vidq); 1684 (unsigned long)&channel->vidq);
1705 dprintk(4, "%s: list_empty active=%d\n", __func__, 1685 dprintk(dev, 4, "%s: list_empty active=%d\n", __func__,
1706 list_empty(&channel->vidq.active)); 1686 list_empty(&channel->vidq.active));
1707 videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops, 1687 videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops,
1708 NULL, &dev->slock, 1688 NULL, &dev->slock,
@@ -1732,7 +1712,7 @@ static unsigned int s2255_poll(struct file *file,
1732 struct s2255_dev *dev = fh->dev; 1712 struct s2255_dev *dev = fh->dev;
1733 int rc = v4l2_ctrl_poll(file, wait); 1713 int rc = v4l2_ctrl_poll(file, wait);
1734 1714
1735 dprintk(100, "%s\n", __func__); 1715 dprintk(dev, 100, "%s\n", __func__);
1736 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) 1716 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
1737 return POLLERR; 1717 return POLLERR;
1738 mutex_lock(&dev->lock); 1718 mutex_lock(&dev->lock);
@@ -1743,6 +1723,7 @@ static unsigned int s2255_poll(struct file *file,
1743 1723
1744static void s2255_destroy(struct s2255_dev *dev) 1724static void s2255_destroy(struct s2255_dev *dev)
1745{ 1725{
1726 dprintk(dev, 1, "%s", __func__);
1746 /* board shutdown stops the read pipe if it is running */ 1727 /* board shutdown stops the read pipe if it is running */
1747 s2255_board_shutdown(dev); 1728 s2255_board_shutdown(dev);
1748 /* make sure firmware still not trying to load */ 1729 /* make sure firmware still not trying to load */
@@ -1760,7 +1741,6 @@ static void s2255_destroy(struct s2255_dev *dev)
1760 mutex_destroy(&dev->lock); 1741 mutex_destroy(&dev->lock);
1761 usb_put_dev(dev->udev); 1742 usb_put_dev(dev->udev);
1762 v4l2_device_unregister(&dev->v4l2_dev); 1743 v4l2_device_unregister(&dev->v4l2_dev);
1763 dprintk(1, "%s", __func__);
1764 kfree(dev); 1744 kfree(dev);
1765} 1745}
1766 1746
@@ -1782,7 +1762,7 @@ static int s2255_release(struct file *file)
1782 } 1762 }
1783 videobuf_mmap_free(&fh->vb_vidq); 1763 videobuf_mmap_free(&fh->vb_vidq);
1784 mutex_unlock(&dev->lock); 1764 mutex_unlock(&dev->lock);
1785 dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev)); 1765 dprintk(dev, 1, "%s[%s]\n", __func__, video_device_node_name(vdev));
1786 v4l2_fh_del(&fh->fh); 1766 v4l2_fh_del(&fh->fh);
1787 v4l2_fh_exit(&fh->fh); 1767 v4l2_fh_exit(&fh->fh);
1788 kfree(fh); 1768 kfree(fh);
@@ -1794,16 +1774,15 @@ static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma)
1794 struct s2255_fh *fh = file->private_data; 1774 struct s2255_fh *fh = file->private_data;
1795 struct s2255_dev *dev; 1775 struct s2255_dev *dev;
1796 int ret; 1776 int ret;
1797
1798 if (!fh) 1777 if (!fh)
1799 return -ENODEV; 1778 return -ENODEV;
1800 dev = fh->dev; 1779 dev = fh->dev;
1801 dprintk(4, "%s, vma=0x%08lx\n", __func__, (unsigned long)vma); 1780 dprintk(dev, 4, "%s, vma=0x%08lx\n", __func__, (unsigned long)vma);
1802 if (mutex_lock_interruptible(&dev->lock)) 1781 if (mutex_lock_interruptible(&dev->lock))
1803 return -ERESTARTSYS; 1782 return -ERESTARTSYS;
1804 ret = videobuf_mmap_mapper(&fh->vb_vidq, vma); 1783 ret = videobuf_mmap_mapper(&fh->vb_vidq, vma);
1805 mutex_unlock(&dev->lock); 1784 mutex_unlock(&dev->lock);
1806 dprintk(4, "%s vma start=0x%08lx, size=%ld, ret=%d\n", __func__, 1785 dprintk(dev, 4, "%s vma start=0x%08lx, size=%ld, ret=%d\n", __func__,
1807 (unsigned long)vma->vm_start, 1786 (unsigned long)vma->vm_start,
1808 (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, ret); 1787 (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, ret);
1809 return ret; 1788 return ret;
@@ -1852,10 +1831,11 @@ static void s2255_video_device_release(struct video_device *vdev)
1852 struct s2255_channel *channel = 1831 struct s2255_channel *channel =
1853 container_of(vdev, struct s2255_channel, vdev); 1832 container_of(vdev, struct s2255_channel, vdev);
1854 1833
1855 v4l2_ctrl_handler_free(&channel->hdl); 1834 dprintk(dev, 4, "%s, chnls: %d\n", __func__,
1856 dprintk(4, "%s, chnls: %d\n", __func__,
1857 atomic_read(&dev->num_channels)); 1835 atomic_read(&dev->num_channels));
1858 1836
1837 v4l2_ctrl_handler_free(&channel->hdl);
1838
1859 if (atomic_dec_and_test(&dev->num_channels)) 1839 if (atomic_dec_and_test(&dev->num_channels))
1860 s2255_destroy(dev); 1840 s2255_destroy(dev);
1861 return; 1841 return;
@@ -1913,7 +1893,8 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1913 0, 100, 1, S2255_DEF_JPEG_QUAL); 1893 0, 100, 1, S2255_DEF_JPEG_QUAL);
1914 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER && 1894 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER &&
1915 (dev->pid != 0x2257 || channel->idx <= 1)) 1895 (dev->pid != 0x2257 || channel->idx <= 1))
1916 v4l2_ctrl_new_custom(&channel->hdl, &color_filter_ctrl, NULL); 1896 v4l2_ctrl_new_custom(&channel->hdl, &color_filter_ctrl,
1897 NULL);
1917 if (channel->hdl.error) { 1898 if (channel->hdl.error) {
1918 ret = channel->hdl.error; 1899 ret = channel->hdl.error;
1919 v4l2_ctrl_handler_free(&channel->hdl); 1900 v4l2_ctrl_handler_free(&channel->hdl);
@@ -1947,15 +1928,15 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1947 video_device_node_name(&channel->vdev)); 1928 video_device_node_name(&channel->vdev));
1948 1929
1949 } 1930 }
1950 printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %s\n", 1931 pr_info("Sensoray 2255 V4L driver Revision: %s\n",
1951 S2255_VERSION); 1932 S2255_VERSION);
1952 /* if no channels registered, return error and probe will fail*/ 1933 /* if no channels registered, return error and probe will fail*/
1953 if (atomic_read(&dev->num_channels) == 0) { 1934 if (atomic_read(&dev->num_channels) == 0) {
1954 v4l2_device_unregister(&dev->v4l2_dev); 1935 v4l2_device_unregister(&dev->v4l2_dev);
1955 return ret; 1936 return ret;
1956 } 1937 }
1957 if (atomic_read(&dev->num_channels) != MAX_CHANNELS) 1938 if (atomic_read(&dev->num_channels) != MAX_CHANNELS)
1958 printk(KERN_WARNING "s2255: Not all channels available.\n"); 1939 pr_warn("s2255: Not all channels available.\n");
1959 return 0; 1940 return 0;
1960} 1941}
1961 1942
@@ -1981,11 +1962,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1981 s32 idx = -1; 1962 s32 idx = -1;
1982 struct s2255_framei *frm; 1963 struct s2255_framei *frm;
1983 unsigned char *pdata; 1964 unsigned char *pdata;
1984 struct s2255_channel *channel; 1965 struct s2255_channel *ch;
1985 dprintk(100, "buffer to user\n"); 1966 dprintk(dev, 100, "buffer to user\n");
1986 channel = &dev->channel[dev->cc]; 1967 ch = &dev->channel[dev->cc];
1987 idx = channel->cur_frame; 1968 idx = ch->cur_frame;
1988 frm = &channel->buffer.frame[idx]; 1969 frm = &ch->buffer.frame[idx];
1989 if (frm->ulState == S2255_READ_IDLE) { 1970 if (frm->ulState == S2255_READ_IDLE) {
1990 int jj; 1971 int jj;
1991 unsigned int cc; 1972 unsigned int cc;
@@ -1997,28 +1978,27 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1997 for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) { 1978 for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) {
1998 switch (*pdword) { 1979 switch (*pdword) {
1999 case S2255_MARKER_FRAME: 1980 case S2255_MARKER_FRAME:
2000 dprintk(4, "found frame marker at offset:" 1981 dprintk(dev, 4, "marker @ offset: %d [%x %x]\n",
2001 " %d [%x %x]\n", jj, pdata[0], 1982 jj, pdata[0], pdata[1]);
2002 pdata[1]);
2003 offset = jj + PREFIX_SIZE; 1983 offset = jj + PREFIX_SIZE;
2004 bframe = 1; 1984 bframe = 1;
2005 cc = le32_to_cpu(pdword[1]); 1985 cc = le32_to_cpu(pdword[1]);
2006 if (cc >= MAX_CHANNELS) { 1986 if (cc >= MAX_CHANNELS) {
2007 printk(KERN_ERR 1987 dprintk(dev, 0,
2008 "bad channel\n"); 1988 "bad channel\n");
2009 return -EINVAL; 1989 return -EINVAL;
2010 } 1990 }
2011 /* reverse it */ 1991 /* reverse it */
2012 dev->cc = G_chnmap[cc]; 1992 dev->cc = G_chnmap[cc];
2013 channel = &dev->channel[dev->cc]; 1993 ch = &dev->channel[dev->cc];
2014 payload = le32_to_cpu(pdword[3]); 1994 payload = le32_to_cpu(pdword[3]);
2015 if (payload > channel->req_image_size) { 1995 if (payload > ch->req_image_size) {
2016 channel->bad_payload++; 1996 ch->bad_payload++;
2017 /* discard the bad frame */ 1997 /* discard the bad frame */
2018 return -EINVAL; 1998 return -EINVAL;
2019 } 1999 }
2020 channel->pkt_size = payload; 2000 ch->pkt_size = payload;
2021 channel->jpg_size = le32_to_cpu(pdword[4]); 2001 ch->jpg_size = le32_to_cpu(pdword[4]);
2022 break; 2002 break;
2023 case S2255_MARKER_RESPONSE: 2003 case S2255_MARKER_RESPONSE:
2024 2004
@@ -2029,34 +2009,34 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2029 cc = G_chnmap[le32_to_cpu(pdword[1])]; 2009 cc = G_chnmap[le32_to_cpu(pdword[1])];
2030 if (cc >= MAX_CHANNELS) 2010 if (cc >= MAX_CHANNELS)
2031 break; 2011 break;
2032 channel = &dev->channel[cc]; 2012 ch = &dev->channel[cc];
2033 switch (pdword[2]) { 2013 switch (pdword[2]) {
2034 case S2255_RESPONSE_SETMODE: 2014 case S2255_RESPONSE_SETMODE:
2035 /* check if channel valid */ 2015 /* check if channel valid */
2036 /* set mode ready */ 2016 /* set mode ready */
2037 channel->setmode_ready = 1; 2017 ch->setmode_ready = 1;
2038 wake_up(&channel->wait_setmode); 2018 wake_up(&ch->wait_setmode);
2039 dprintk(5, "setmode ready %d\n", cc); 2019 dprintk(dev, 5, "setmode rdy %d\n", cc);
2040 break; 2020 break;
2041 case S2255_RESPONSE_FW: 2021 case S2255_RESPONSE_FW:
2042 dev->chn_ready |= (1 << cc); 2022 dev->chn_ready |= (1 << cc);
2043 if ((dev->chn_ready & 0x0f) != 0x0f) 2023 if ((dev->chn_ready & 0x0f) != 0x0f)
2044 break; 2024 break;
2045 /* all channels ready */ 2025 /* all channels ready */
2046 printk(KERN_INFO "s2255: fw loaded\n"); 2026 pr_info("s2255: fw loaded\n");
2047 atomic_set(&dev->fw_data->fw_state, 2027 atomic_set(&dev->fw_data->fw_state,
2048 S2255_FW_SUCCESS); 2028 S2255_FW_SUCCESS);
2049 wake_up(&dev->fw_data->wait_fw); 2029 wake_up(&dev->fw_data->wait_fw);
2050 break; 2030 break;
2051 case S2255_RESPONSE_STATUS: 2031 case S2255_RESPONSE_STATUS:
2052 channel->vidstatus = le32_to_cpu(pdword[3]); 2032 ch->vidstatus = le32_to_cpu(pdword[3]);
2053 channel->vidstatus_ready = 1; 2033 ch->vidstatus_ready = 1;
2054 wake_up(&channel->wait_vidstatus); 2034 wake_up(&ch->wait_vidstatus);
2055 dprintk(5, "got vidstatus %x chan %d\n", 2035 dprintk(dev, 5, "vstat %x chan %d\n",
2056 le32_to_cpu(pdword[3]), cc); 2036 le32_to_cpu(pdword[3]), cc);
2057 break; 2037 break;
2058 default: 2038 default:
2059 printk(KERN_INFO "s2255 unknown resp\n"); 2039 pr_info("s2255 unknown resp\n");
2060 } 2040 }
2061 default: 2041 default:
2062 pdata++; 2042 pdata++;
@@ -2068,11 +2048,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2068 if (!bframe) 2048 if (!bframe)
2069 return -EINVAL; 2049 return -EINVAL;
2070 } 2050 }
2071 channel = &dev->channel[dev->cc]; 2051 ch = &dev->channel[dev->cc];
2072 idx = channel->cur_frame; 2052 idx = ch->cur_frame;
2073 frm = &channel->buffer.frame[idx]; 2053 frm = &ch->buffer.frame[idx];
2074 /* search done. now find out if should be acquiring on this channel */ 2054 /* search done. now find out if should be acquiring on this channel */
2075 if (!channel->b_acquire) { 2055 if (!ch->b_acquire) {
2076 /* we found a frame, but this channel is turned off */ 2056 /* we found a frame, but this channel is turned off */
2077 frm->ulState = S2255_READ_IDLE; 2057 frm->ulState = S2255_READ_IDLE;
2078 return -EINVAL; 2058 return -EINVAL;
@@ -2088,7 +2068,7 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2088 2068
2089 2069
2090 if (frm->lpvbits == NULL) { 2070 if (frm->lpvbits == NULL) {
2091 dprintk(1, "s2255 frame buffer == NULL.%p %p %d %d", 2071 dprintk(dev, 1, "s2255 frame buffer == NULL.%p %p %d %d",
2092 frm, dev, dev->cc, idx); 2072 frm, dev, dev->cc, idx);
2093 return -ENOMEM; 2073 return -ENOMEM;
2094 } 2074 }
@@ -2097,28 +2077,28 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2097 2077
2098 copy_size = (pipe_info->cur_transfer_size - offset); 2078 copy_size = (pipe_info->cur_transfer_size - offset);
2099 2079
2100 size = channel->pkt_size - PREFIX_SIZE; 2080 size = ch->pkt_size - PREFIX_SIZE;
2101 2081
2102 /* sanity check on pdest */ 2082 /* sanity check on pdest */
2103 if ((copy_size + frm->cur_size) < channel->req_image_size) 2083 if ((copy_size + frm->cur_size) < ch->req_image_size)
2104 memcpy(pdest, psrc, copy_size); 2084 memcpy(pdest, psrc, copy_size);
2105 2085
2106 frm->cur_size += copy_size; 2086 frm->cur_size += copy_size;
2107 dprintk(4, "cur_size size %lu size %lu \n", frm->cur_size, size); 2087 dprintk(dev, 4, "cur_size: %lu, size: %lu\n", frm->cur_size, size);
2108 2088
2109 if (frm->cur_size >= size) { 2089 if (frm->cur_size >= size) {
2110 dprintk(2, "****************[%d]Buffer[%d]full*************\n", 2090 dprintk(dev, 2, "******[%d]Buffer[%d]full*******\n",
2111 dev->cc, idx); 2091 dev->cc, idx);
2112 channel->last_frame = channel->cur_frame; 2092 ch->last_frame = ch->cur_frame;
2113 channel->cur_frame++; 2093 ch->cur_frame++;
2114 /* end of system frame ring buffer, start at zero */ 2094 /* end of system frame ring buffer, start at zero */
2115 if ((channel->cur_frame == SYS_FRAMES) || 2095 if ((ch->cur_frame == SYS_FRAMES) ||
2116 (channel->cur_frame == channel->buffer.dwFrames)) 2096 (ch->cur_frame == ch->buffer.dwFrames))
2117 channel->cur_frame = 0; 2097 ch->cur_frame = 0;
2118 /* frame ready */ 2098 /* frame ready */
2119 if (channel->b_acquire) 2099 if (ch->b_acquire)
2120 s2255_got_frame(channel, channel->jpg_size); 2100 s2255_got_frame(ch, ch->jpg_size);
2121 channel->frame_count++; 2101 ch->frame_count++;
2122 frm->ulState = S2255_READ_IDLE; 2102 frm->ulState = S2255_READ_IDLE;
2123 frm->cur_size = 0; 2103 frm->cur_size = 0;
2124 2104
@@ -2131,7 +2111,7 @@ static void s2255_read_video_callback(struct s2255_dev *dev,
2131 struct s2255_pipeinfo *pipe_info) 2111 struct s2255_pipeinfo *pipe_info)
2132{ 2112{
2133 int res; 2113 int res;
2134 dprintk(50, "callback read video \n"); 2114 dprintk(dev, 50, "callback read video\n");
2135 2115
2136 if (dev->cc >= MAX_CHANNELS) { 2116 if (dev->cc >= MAX_CHANNELS) {
2137 dev->cc = 0; 2117 dev->cc = 0;
@@ -2141,9 +2121,9 @@ static void s2255_read_video_callback(struct s2255_dev *dev,
2141 /* otherwise copy to the system buffers */ 2121 /* otherwise copy to the system buffers */
2142 res = save_frame(dev, pipe_info); 2122 res = save_frame(dev, pipe_info);
2143 if (res != 0) 2123 if (res != 0)
2144 dprintk(4, "s2255: read callback failed\n"); 2124 dprintk(dev, 4, "s2255: read callback failed\n");
2145 2125
2146 dprintk(50, "callback read video done\n"); 2126 dprintk(dev, 50, "callback read video done\n");
2147 return; 2127 return;
2148} 2128}
2149 2129
@@ -2181,9 +2161,9 @@ static int s2255_get_fx2fw(struct s2255_dev *dev)
2181 ret = s2255_vendor_req(dev, S2255_VR_FW, 0, 0, transBuffer, 2, 2161 ret = s2255_vendor_req(dev, S2255_VR_FW, 0, 0, transBuffer, 2,
2182 S2255_VR_IN); 2162 S2255_VR_IN);
2183 if (ret < 0) 2163 if (ret < 0)
2184 dprintk(2, "get fw error: %x\n", ret); 2164 dprintk(dev, 2, "get fw error: %x\n", ret);
2185 fw = transBuffer[0] + (transBuffer[1] << 8); 2165 fw = transBuffer[0] + (transBuffer[1] << 8);
2186 dprintk(2, "Get FW %x %x\n", transBuffer[0], transBuffer[1]); 2166 dprintk(dev, 2, "Get FW %x %x\n", transBuffer[0], transBuffer[1]);
2187 return fw; 2167 return fw;
2188} 2168}
2189 2169
@@ -2195,7 +2175,6 @@ static int s2255_create_sys_buffers(struct s2255_channel *channel)
2195{ 2175{
2196 unsigned long i; 2176 unsigned long i;
2197 unsigned long reqsize; 2177 unsigned long reqsize;
2198 dprintk(1, "create sys buffers\n");
2199 channel->buffer.dwFrames = SYS_FRAMES; 2178 channel->buffer.dwFrames = SYS_FRAMES;
2200 /* always allocate maximum size(PAL) for system buffers */ 2179 /* always allocate maximum size(PAL) for system buffers */
2201 reqsize = SYS_FRAMES_MAXSIZE; 2180 reqsize = SYS_FRAMES_MAXSIZE;
@@ -2206,12 +2185,9 @@ static int s2255_create_sys_buffers(struct s2255_channel *channel)
2206 for (i = 0; i < SYS_FRAMES; i++) { 2185 for (i = 0; i < SYS_FRAMES; i++) {
2207 /* allocate the frames */ 2186 /* allocate the frames */
2208 channel->buffer.frame[i].lpvbits = vmalloc(reqsize); 2187 channel->buffer.frame[i].lpvbits = vmalloc(reqsize);
2209 dprintk(1, "valloc %p chan %d, idx %lu, pdata %p\n",
2210 &channel->buffer.frame[i], channel->idx, i,
2211 channel->buffer.frame[i].lpvbits);
2212 channel->buffer.frame[i].size = reqsize; 2188 channel->buffer.frame[i].size = reqsize;
2213 if (channel->buffer.frame[i].lpvbits == NULL) { 2189 if (channel->buffer.frame[i].lpvbits == NULL) {
2214 printk(KERN_INFO "out of memory. using less frames\n"); 2190 pr_info("out of memory. using less frames\n");
2215 channel->buffer.dwFrames = i; 2191 channel->buffer.dwFrames = i;
2216 break; 2192 break;
2217 } 2193 }
@@ -2231,13 +2207,9 @@ static int s2255_create_sys_buffers(struct s2255_channel *channel)
2231static int s2255_release_sys_buffers(struct s2255_channel *channel) 2207static int s2255_release_sys_buffers(struct s2255_channel *channel)
2232{ 2208{
2233 unsigned long i; 2209 unsigned long i;
2234 dprintk(1, "release sys buffers\n");
2235 for (i = 0; i < SYS_FRAMES; i++) { 2210 for (i = 0; i < SYS_FRAMES; i++) {
2236 if (channel->buffer.frame[i].lpvbits) { 2211 if (channel->buffer.frame[i].lpvbits)
2237 dprintk(1, "vfree %p\n",
2238 channel->buffer.frame[i].lpvbits);
2239 vfree(channel->buffer.frame[i].lpvbits); 2212 vfree(channel->buffer.frame[i].lpvbits);
2240 }
2241 channel->buffer.frame[i].lpvbits = NULL; 2213 channel->buffer.frame[i].lpvbits = NULL;
2242 } 2214 }
2243 return 0; 2215 return 0;
@@ -2249,7 +2221,7 @@ static int s2255_board_init(struct s2255_dev *dev)
2249 int fw_ver; 2221 int fw_ver;
2250 int j; 2222 int j;
2251 struct s2255_pipeinfo *pipe = &dev->pipe; 2223 struct s2255_pipeinfo *pipe = &dev->pipe;
2252 dprintk(4, "board init: %p", dev); 2224 dprintk(dev, 4, "board init: %p", dev);
2253 memset(pipe, 0, sizeof(*pipe)); 2225 memset(pipe, 0, sizeof(*pipe));
2254 pipe->dev = dev; 2226 pipe->dev = dev;
2255 pipe->cur_transfer_size = S2255_USB_XFER_SIZE; 2227 pipe->cur_transfer_size = S2255_USB_XFER_SIZE;
@@ -2258,18 +2230,18 @@ static int s2255_board_init(struct s2255_dev *dev)
2258 pipe->transfer_buffer = kzalloc(pipe->max_transfer_size, 2230 pipe->transfer_buffer = kzalloc(pipe->max_transfer_size,
2259 GFP_KERNEL); 2231 GFP_KERNEL);
2260 if (pipe->transfer_buffer == NULL) { 2232 if (pipe->transfer_buffer == NULL) {
2261 dprintk(1, "out of memory!\n"); 2233 dprintk(dev, 1, "out of memory!\n");
2262 return -ENOMEM; 2234 return -ENOMEM;
2263 } 2235 }
2264 /* query the firmware */ 2236 /* query the firmware */
2265 fw_ver = s2255_get_fx2fw(dev); 2237 fw_ver = s2255_get_fx2fw(dev);
2266 2238
2267 printk(KERN_INFO "s2255: usb firmware version %d.%d\n", 2239 pr_info("s2255: usb firmware version %d.%d\n",
2268 (fw_ver >> 8) & 0xff, 2240 (fw_ver >> 8) & 0xff,
2269 fw_ver & 0xff); 2241 fw_ver & 0xff);
2270 2242
2271 if (fw_ver < S2255_CUR_USB_FWVER) 2243 if (fw_ver < S2255_CUR_USB_FWVER)
2272 printk(KERN_INFO "s2255: newer USB firmware available\n"); 2244 pr_info("s2255: newer USB firmware available\n");
2273 2245
2274 for (j = 0; j < MAX_CHANNELS; j++) { 2246 for (j = 0; j < MAX_CHANNELS; j++) {
2275 struct s2255_channel *channel = &dev->channel[j]; 2247 struct s2255_channel *channel = &dev->channel[j];
@@ -2290,14 +2262,14 @@ static int s2255_board_init(struct s2255_dev *dev)
2290 } 2262 }
2291 /* start read pipe */ 2263 /* start read pipe */
2292 s2255_start_readpipe(dev); 2264 s2255_start_readpipe(dev);
2293 dprintk(1, "%s: success\n", __func__); 2265 dprintk(dev, 1, "%s: success\n", __func__);
2294 return 0; 2266 return 0;
2295} 2267}
2296 2268
2297static int s2255_board_shutdown(struct s2255_dev *dev) 2269static int s2255_board_shutdown(struct s2255_dev *dev)
2298{ 2270{
2299 u32 i; 2271 u32 i;
2300 dprintk(1, "%s: dev: %p", __func__, dev); 2272 dprintk(dev, 1, "%s: dev: %p", __func__, dev);
2301 2273
2302 for (i = 0; i < MAX_CHANNELS; i++) { 2274 for (i = 0; i < MAX_CHANNELS; i++) {
2303 if (dev->channel[i].b_acquire) 2275 if (dev->channel[i].b_acquire)
@@ -2318,13 +2290,10 @@ static void read_pipe_completion(struct urb *purb)
2318 int status; 2290 int status;
2319 int pipe; 2291 int pipe;
2320 pipe_info = purb->context; 2292 pipe_info = purb->context;
2321 dprintk(100, "%s: urb:%p, status %d\n", __func__, purb,
2322 purb->status);
2323 if (pipe_info == NULL) { 2293 if (pipe_info == NULL) {
2324 dev_err(&purb->dev->dev, "no context!\n"); 2294 dev_err(&purb->dev->dev, "no context!\n");
2325 return; 2295 return;
2326 } 2296 }
2327
2328 dev = pipe_info->dev; 2297 dev = pipe_info->dev;
2329 if (dev == NULL) { 2298 if (dev == NULL) {
2330 dev_err(&purb->dev->dev, "no context!\n"); 2299 dev_err(&purb->dev->dev, "no context!\n");
@@ -2333,13 +2302,13 @@ static void read_pipe_completion(struct urb *purb)
2333 status = purb->status; 2302 status = purb->status;
2334 /* if shutting down, do not resubmit, exit immediately */ 2303 /* if shutting down, do not resubmit, exit immediately */
2335 if (status == -ESHUTDOWN) { 2304 if (status == -ESHUTDOWN) {
2336 dprintk(2, "%s: err shutdown\n", __func__); 2305 dprintk(dev, 2, "%s: err shutdown\n", __func__);
2337 pipe_info->err_count++; 2306 pipe_info->err_count++;
2338 return; 2307 return;
2339 } 2308 }
2340 2309
2341 if (pipe_info->state == 0) { 2310 if (pipe_info->state == 0) {
2342 dprintk(2, "%s: exiting USB pipe", __func__); 2311 dprintk(dev, 2, "%s: exiting USB pipe", __func__);
2343 return; 2312 return;
2344 } 2313 }
2345 2314
@@ -2347,7 +2316,7 @@ static void read_pipe_completion(struct urb *purb)
2347 s2255_read_video_callback(dev, pipe_info); 2316 s2255_read_video_callback(dev, pipe_info);
2348 else { 2317 else {
2349 pipe_info->err_count++; 2318 pipe_info->err_count++;
2350 dprintk(1, "%s: failed URB %d\n", __func__, status); 2319 dprintk(dev, 1, "%s: failed URB %d\n", __func__, status);
2351 } 2320 }
2352 2321
2353 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint); 2322 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
@@ -2359,11 +2328,10 @@ static void read_pipe_completion(struct urb *purb)
2359 read_pipe_completion, pipe_info); 2328 read_pipe_completion, pipe_info);
2360 2329
2361 if (pipe_info->state != 0) { 2330 if (pipe_info->state != 0) {
2362 if (usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC)) { 2331 if (usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC))
2363 dev_err(&dev->udev->dev, "error submitting urb\n"); 2332 dev_err(&dev->udev->dev, "error submitting urb\n");
2364 }
2365 } else { 2333 } else {
2366 dprintk(2, "%s :complete state 0\n", __func__); 2334 dprintk(dev, 2, "%s :complete state 0\n", __func__);
2367 } 2335 }
2368 return; 2336 return;
2369} 2337}
@@ -2374,7 +2342,7 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
2374 int retval; 2342 int retval;
2375 struct s2255_pipeinfo *pipe_info = &dev->pipe; 2343 struct s2255_pipeinfo *pipe_info = &dev->pipe;
2376 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint); 2344 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
2377 dprintk(2, "%s: IN %d\n", __func__, dev->read_endpoint); 2345 dprintk(dev, 2, "%s: IN %d\n", __func__, dev->read_endpoint);
2378 pipe_info->state = 1; 2346 pipe_info->state = 1;
2379 pipe_info->err_count = 0; 2347 pipe_info->err_count = 0;
2380 pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL); 2348 pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2391,7 +2359,7 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
2391 read_pipe_completion, pipe_info); 2359 read_pipe_completion, pipe_info);
2392 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL); 2360 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL);
2393 if (retval) { 2361 if (retval) {
2394 printk(KERN_ERR "s2255: start read pipe failed\n"); 2362 pr_err("s2255: start read pipe failed\n");
2395 return retval; 2363 return retval;
2396 } 2364 }
2397 return 0; 2365 return 0;
@@ -2428,7 +2396,7 @@ static int s2255_start_acquire(struct s2255_channel *channel)
2428 if (res != 0) 2396 if (res != 0)
2429 dev_err(&dev->udev->dev, "CMD_START error\n"); 2397 dev_err(&dev->udev->dev, "CMD_START error\n");
2430 2398
2431 dprintk(2, "start acquire exit[%d] %d \n", channel->idx, res); 2399 dprintk(dev, 2, "start acquire exit[%d] %d\n", channel->idx, res);
2432 kfree(buffer); 2400 kfree(buffer);
2433 return 0; 2401 return 0;
2434} 2402}
@@ -2454,7 +2422,7 @@ static int s2255_stop_acquire(struct s2255_channel *channel)
2454 dev_err(&dev->udev->dev, "CMD_STOP error\n"); 2422 dev_err(&dev->udev->dev, "CMD_STOP error\n");
2455 kfree(buffer); 2423 kfree(buffer);
2456 channel->b_acquire = 0; 2424 channel->b_acquire = 0;
2457 dprintk(4, "%s: chn %d, res %d\n", __func__, channel->idx, res); 2425 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, channel->idx, res);
2458 return res; 2426 return res;
2459} 2427}
2460 2428
@@ -2469,7 +2437,7 @@ static void s2255_stop_readpipe(struct s2255_dev *dev)
2469 usb_free_urb(pipe->stream_urb); 2437 usb_free_urb(pipe->stream_urb);
2470 pipe->stream_urb = NULL; 2438 pipe->stream_urb = NULL;
2471 } 2439 }
2472 dprintk(4, "%s", __func__); 2440 dprintk(dev, 4, "%s", __func__);
2473 return; 2441 return;
2474} 2442}
2475 2443
@@ -2501,7 +2469,6 @@ static int s2255_probe(struct usb_interface *interface,
2501 int retval = -ENOMEM; 2469 int retval = -ENOMEM;
2502 __le32 *pdata; 2470 __le32 *pdata;
2503 int fw_size; 2471 int fw_size;
2504 dprintk(2, "%s\n", __func__);
2505 /* allocate memory for our device state and initialize it to zero */ 2472 /* allocate memory for our device state and initialize it to zero */
2506 dev = kzalloc(sizeof(struct s2255_dev), GFP_KERNEL); 2473 dev = kzalloc(sizeof(struct s2255_dev), GFP_KERNEL);
2507 if (dev == NULL) { 2474 if (dev == NULL) {
@@ -2521,12 +2488,13 @@ static int s2255_probe(struct usb_interface *interface,
2521 retval = -ENODEV; 2488 retval = -ENODEV;
2522 goto errorUDEV; 2489 goto errorUDEV;
2523 } 2490 }
2524 dprintk(1, "dev: %p, udev %p interface %p\n", dev, 2491 dev_dbg(&interface->dev, "dev: %p, udev %p interface %p\n",
2525 dev->udev, interface); 2492 dev, dev->udev, interface);
2526 dev->interface = interface; 2493 dev->interface = interface;
2527 /* set up the endpoint information */ 2494 /* set up the endpoint information */
2528 iface_desc = interface->cur_altsetting; 2495 iface_desc = interface->cur_altsetting;
2529 dprintk(1, "num endpoints %d\n", iface_desc->desc.bNumEndpoints); 2496 dev_dbg(&interface->dev, "num EP: %d\n",
2497 iface_desc->desc.bNumEndpoints);
2530 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 2498 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2531 endpoint = &iface_desc->endpoint[i].desc; 2499 endpoint = &iface_desc->endpoint[i].desc;
2532 if (!dev->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) { 2500 if (!dev->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) {
@@ -2545,7 +2513,8 @@ static int s2255_probe(struct usb_interface *interface,
2545 init_waitqueue_head(&dev->fw_data->wait_fw); 2513 init_waitqueue_head(&dev->fw_data->wait_fw);
2546 for (i = 0; i < MAX_CHANNELS; i++) { 2514 for (i = 0; i < MAX_CHANNELS; i++) {
2547 struct s2255_channel *channel = &dev->channel[i]; 2515 struct s2255_channel *channel = &dev->channel[i];
2548 dev->channel[i].idx = i; 2516 channel->idx = i;
2517 channel->dev = dev;
2549 init_waitqueue_head(&channel->wait_setmode); 2518 init_waitqueue_head(&channel->wait_setmode);
2550 init_waitqueue_head(&channel->wait_vidstatus); 2519 init_waitqueue_head(&channel->wait_vidstatus);
2551 } 2520 }
@@ -2564,7 +2533,7 @@ static int s2255_probe(struct usb_interface *interface,
2564 /* load the first chunk */ 2533 /* load the first chunk */
2565 if (request_firmware(&dev->fw_data->fw, 2534 if (request_firmware(&dev->fw_data->fw,
2566 FIRMWARE_FILE_NAME, &dev->udev->dev)) { 2535 FIRMWARE_FILE_NAME, &dev->udev->dev)) {
2567 printk(KERN_ERR "sensoray 2255 failed to get firmware\n"); 2536 dev_err(&interface->dev, "sensoray 2255 failed to get firmware\n");
2568 goto errorREQFW; 2537 goto errorREQFW;
2569 } 2538 }
2570 /* check the firmware is valid */ 2539 /* check the firmware is valid */
@@ -2572,21 +2541,21 @@ static int s2255_probe(struct usb_interface *interface,
2572 pdata = (__le32 *) &dev->fw_data->fw->data[fw_size - 8]; 2541 pdata = (__le32 *) &dev->fw_data->fw->data[fw_size - 8];
2573 2542
2574 if (*pdata != S2255_FW_MARKER) { 2543 if (*pdata != S2255_FW_MARKER) {
2575 printk(KERN_INFO "Firmware invalid.\n"); 2544 dev_err(&interface->dev, "Firmware invalid.\n");
2576 retval = -ENODEV; 2545 retval = -ENODEV;
2577 goto errorFWMARKER; 2546 goto errorFWMARKER;
2578 } else { 2547 } else {
2579 /* make sure firmware is the latest */ 2548 /* make sure firmware is the latest */
2580 __le32 *pRel; 2549 __le32 *pRel;
2581 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4]; 2550 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4];
2582 printk(KERN_INFO "s2255 dsp fw version %x\n", le32_to_cpu(*pRel)); 2551 pr_info("s2255 dsp fw version %x\n", le32_to_cpu(*pRel));
2583 dev->dsp_fw_ver = le32_to_cpu(*pRel); 2552 dev->dsp_fw_ver = le32_to_cpu(*pRel);
2584 if (dev->dsp_fw_ver < S2255_CUR_DSP_FWVER) 2553 if (dev->dsp_fw_ver < S2255_CUR_DSP_FWVER)
2585 printk(KERN_INFO "s2255: f2255usb.bin out of date.\n"); 2554 pr_info("s2255: f2255usb.bin out of date.\n");
2586 if (dev->pid == 0x2257 && 2555 if (dev->pid == 0x2257 &&
2587 dev->dsp_fw_ver < S2255_MIN_DSP_COLORFILTER) 2556 dev->dsp_fw_ver < S2255_MIN_DSP_COLORFILTER)
2588 printk(KERN_WARNING "s2255: 2257 requires firmware %d" 2557 pr_warn("2257 needs firmware %d or above.\n",
2589 " or above.\n", S2255_MIN_DSP_COLORFILTER); 2558 S2255_MIN_DSP_COLORFILTER);
2590 } 2559 }
2591 usb_reset_device(dev->udev); 2560 usb_reset_device(dev->udev);
2592 /* load 2255 board specific */ 2561 /* load 2255 board specific */
@@ -2618,7 +2587,7 @@ errorUDEV:
2618 mutex_destroy(&dev->lock); 2587 mutex_destroy(&dev->lock);
2619errorFWDATA1: 2588errorFWDATA1:
2620 kfree(dev); 2589 kfree(dev);
2621 printk(KERN_WARNING "Sensoray 2255 driver load failed: 0x%x\n", retval); 2590 pr_warn("Sensoray 2255 driver load failed: 0x%x\n", retval);
2622 return retval; 2591 return retval;
2623} 2592}
2624 2593