[PATCH] s2255drv: code cleanup

2010-03-29 Thread Dean A.
# HG changeset patch
# User Dean Anderson 
# Date 1269900678 25200
# Node ID 18586e4ac3ed5972dac2015600f8c21e26c0fc16
# Parent  c437bd6f3659885afbe20ad12857347f0850156b
s2255drv: code cleanup

From: Dean Anderson 

removal of unused pipe array (of size one).

Priority: normal

Signed-off-by: Dean Anderson 

diff -r c437bd6f3659 -r 18586e4ac3ed linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Mon Mar 29 14:57:45 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Mon Mar 29 15:11:18 2010 -0700
@@ -85,7 +85,6 @@
 #define S2255_RESPONSE_STATUS   cpu_to_le32(0x20)
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
-#define MAX_PIPE_BUFFERS   1
 #define SYS_FRAMES 4
 /* maximum size is PAL full size plus room for the marker header(s) */
 #define SYS_FRAMES_MAXSIZE (720*288*2*2 + 4096)
@@ -237,8 +236,8 @@
struct video_device *vdev[MAX_CHANNELS];
struct timer_list   timer;
struct s2255_fw *fw_data;
-   struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
-   struct s2255_bufferibuffer[MAX_CHANNELS];
+   struct s2255_pipeinfo   pipe;
+   struct s2255_bufferibuffer[MAX_CHANNELS];
struct s2255_mode   mode[MAX_CHANNELS];
/* jpeg compression */
struct v4l2_jpegcompression jc[MAX_CHANNELS];
@@ -2334,25 +2333,21 @@
 
 static int s2255_board_init(struct s2255_dev *dev)
 {
-   int j;
struct s2255_mode mode_def = DEF_MODEI_NTSC_CONT;
int fw_ver;
+   int j;
+   struct s2255_pipeinfo *pipe = &dev->pipe;
dprintk(4, "board init: %p", dev);
+   memset(pipe, 0, sizeof(*pipe));
+   pipe->dev = dev;
+   pipe->cur_transfer_size = S2255_USB_XFER_SIZE;
+   pipe->max_transfer_size = S2255_USB_XFER_SIZE;
 
-   for (j = 0; j < MAX_PIPE_BUFFERS; j++) {
-   struct s2255_pipeinfo *pipe = &dev->pipes[j];
-
-   memset(pipe, 0, sizeof(*pipe));
-   pipe->dev = dev;
-   pipe->cur_transfer_size = S2255_USB_XFER_SIZE;
-   pipe->max_transfer_size = S2255_USB_XFER_SIZE;
-
-   pipe->transfer_buffer = kzalloc(pipe->max_transfer_size,
-   GFP_KERNEL);
-   if (pipe->transfer_buffer == NULL) {
-   dprintk(1, "out of memory!\n");
-   return -ENOMEM;
-   }
+   pipe->transfer_buffer = kzalloc(pipe->max_transfer_size,
+   GFP_KERNEL);
+   if (pipe->transfer_buffer == NULL) {
+   dprintk(1, "out of memory!\n");
+   return -ENOMEM;
}
/* query the firmware */
fw_ver = s2255_get_fx2fw(dev);
@@ -2401,12 +2396,8 @@
 
for (i = 0; i < MAX_CHANNELS; i++)
s2255_release_sys_buffers(dev, i);
-
-   /* release transfer buffers */
-   for (i = 0; i < MAX_PIPE_BUFFERS; i++) {
-   struct s2255_pipeinfo *pipe = &dev->pipes[i];
-   kfree(pipe->transfer_buffer);
-   }
+   /* release transfer buffer */
+   kfree(dev->pipe.transfer_buffer);
return 0;
 }
 
@@ -2472,35 +2463,30 @@
 {
int pipe;
int retval;
-   int i;
-   struct s2255_pipeinfo *pipe_info = dev->pipes;
+   struct s2255_pipeinfo *pipe_info = &dev->pipe;
pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
dprintk(2, "start pipe IN %d\n", dev->read_endpoint);
+   pipe_info->state = 1;
+   pipe_info->err_count = 0;
+   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\n");
+   return -ENOMEM;
+   }
+   /* transfer buffer allocated in board_init */
+   usb_fill_bulk_urb(pipe_info->stream_urb, dev->udev,
+ pipe,
+ pipe_info->transfer_buffer,
+ pipe_info->cur_transfer_size,
+ read_pipe_completion, pipe_info);
 
-   for (i = 0; i < MAX_PIPE_BUFFERS; i++) {
-   pipe_info->state = 1;
-   pipe_info->err_count = 0;
-   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\n");
-   return -ENOMEM;
-   }
-   /* transfer buffer allocated in board_init */
-   usb_fill_bulk_urb(pipe_info->stream_urb, dev->udev,
- pipe,
- pipe_info->transfer_buffer,
- pipe_info->cur_transfer_size,
- read_pipe_completion, pipe_info);
-
-   dprintk(4, "submitting URB %p\n", pipe_in

patch: s2255drv: code cleanup

2009-04-23 Thread Dean A.
From: Dean Anderson 

Removal of unused structure items. Response values defined. Driver revision 
printk.

Signed-off-by: Dean Anderson 

--- v4l-dvb-ebb7b82f2b48/linux/drivers/media/video/s2255drv.c.orig  
2009-04-23 11:37:28.0 -0700
+++ v4l-dvb-ebb7b82f2b48/linux/drivers/media/video/s2255drv.c   2009-04-23 
11:54:24.0 -0700
@@ -78,6 +78,8 @@
 #define MAX_CHANNELS   4
 #define S2255_MARKER_FRAME 0x2255DA4AL
 #define S2255_MARKER_RESPONSE  0x2255ACACL
+#define S2255_RESPONSE_SETMODE  0x01
+#define S2255_RESPONSE_FW   0x10
 #define S2255_USB_XFER_SIZE(16 * 1024)
 #define MAX_CHANNELS   4
 #define MAX_PIPE_BUFFERS   1
@@ -179,9 +181,6 @@ struct s2255_bufferi {
 
 struct s2255_dmaqueue {
struct list_headactive;
-   /* thread for acquisition */
-   struct task_struct  *kthread;
-   int frame;
struct s2255_dev*dev;
int channel;
 };
@@ -211,16 +210,11 @@ struct s2255_pipeinfo {
u32 max_transfer_size;
u32 cur_transfer_size;
u8 *transfer_buffer;
-   u32 transfer_flags;;
u32 state;
-   u32 prev_state;
-   u32 urb_size;
void *stream_urb;
void *dev;  /* back pointer to s2255_dev struct*/
u32 err_count;
-   u32 buf_index;
u32 idx;
-   u32 priority_set;
 };
 
 struct s2255_fmt; /*forward declaration */
@@ -240,8 +234,6 @@ struct s2255_dev {
struct list_heads2255_devlist;
struct timer_list   timer;
struct s2255_fw *fw_data;
-   int board_num;
-   int is_open;
struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
struct s2255_bufferibuffer[MAX_CHANNELS];
struct s2255_mode   mode[MAX_CHANNELS];
@@ -298,9 +290,10 @@ struct s2255_fh {
int resources[MAX_CHANNELS];
 };
 
-#define CUR_USB_FWVER  774 /* current cypress EEPROM firmware version */
+/* current cypress EEPROM firmware version */
+#define S2255_CUR_USB_FWVER((3 << 8) | 6)
 #define S2255_MAJOR_VERSION1
-#define S2255_MINOR_VERSION13
+#define S2255_MINOR_VERSION14
 #define S2255_RELEASE  0
 #define S2255_VERSION  KERNEL_VERSION(S2255_MAJOR_VERSION, \
   S2255_MINOR_VERSION, \
@@ -1819,7 +1812,6 @@ static int s2255_probe_v4l(struct s2255_
INIT_LIST_HEAD(&dev->vidq[i].active);
dev->vidq[i].dev = dev;
dev->vidq[i].channel = i;
-   dev->vidq[i].kthread = NULL;
/* register 4 video devices */
dev->vdev[i] = video_device_alloc();
memcpy(dev->vdev[i], &template, sizeof(struct video_device));
@@ -1840,7 +1832,9 @@ static int s2255_probe_v4l(struct s2255_
return ret;
}
}
-   printk(KERN_INFO "Sensoray 2255 V4L driver\n");
+   printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %d.%d\n",
+  S2255_MAJOR_VERSION,
+  S2255_MINOR_VERSION);
return ret;
 }
 
@@ -1930,14 +1924,14 @@ static int save_frame(struct s2255_dev *
if (!(cc >= 0 && cc < MAX_CHANNELS))
break;
switch (pdword[2]) {
-   case 0x01:
+   case S2255_RESPONSE_SETMODE:
/* check if channel valid */
/* set mode ready */
dev->setmode_ready[cc] = 1;
wake_up(&dev->wait_setmode[cc]);
dprintk(5, "setmode ready %d\n", cc);
break;
-   case 0x10:
+   case S2255_RESPONSE_FW:
 
dev->chn_ready |= (1 << cc);
if ((dev->chn_ready & 0x0f) != 0x0f)
@@ -2173,10 +2167,15 @@ static int s2255_board_init(struct s2255
/* query the firmware */
fw_ver = s2255_get_fx2fw(dev);
 
-   printk(KERN_INFO "2255 usb firmware version %d \n", fw_ver);
-   if (fw_ver < CUR_USB_FWVER)
+   printk(KERN_INFO "2255 usb firmware version %d.%d\n",
+  (fw_ver >> 8) & 0xff,
+  fw_ver & 0xff);
+
+   if (fw_ver < S2255_CUR_USB_FWVER)
dev_err(&dev->udev->dev,
-   "usb firmware not up to date %d\n", fw_ver);
+   "usb firmware not up to date %d.%d\n",
+   (fw_ver >> 8) & 0xff,
+   fw_ver & 0xff);
 
for (j = 0; j < MAX_CHANNELS; j++) {
dev->b_acquire[j] = 0;
@@ -2284,8 +2283,7 @@ static int s2255_start_readpipe(struct s