[PATCH] s2255drv: cleanup of device structure

2010-06-01 Thread sensoray-dev
s2255drv: cleanup of device structure

From: Dean Anderson 

cleanup of device structure.
single channel array instead of multiple arrays in device for
each channel property.
simplifies open callback by removing search for channel index.

Priority: normal

Signed-off-by: Dean Anderson 

 drivers/media/video/s2255drv.c |  724 +++-
 1 files changed, 352 insertions(+), 372 deletions(-)

---

diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 3c7a79f..8ec7c9a 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -191,7 +191,6 @@ struct s2255_bufferi {
 struct s2255_dmaqueue {
struct list_headactive;
struct s2255_dev*dev;
-   int channel;
 };
 
 /* for firmware loading, fw_state */
@@ -226,51 +225,60 @@ struct s2255_pipeinfo {
 };
 
 struct s2255_fmt; /*forward declaration */
+struct s2255_dev;
+
+struct s2255_channel {
+   struct video_device vdev;
+   int resources;
+   struct s2255_dmaqueue   vidq;
+   struct s2255_bufferibuffer;
+   struct s2255_mode   mode;
+   /* jpeg compression */
+   struct v4l2_jpegcompression jc;
+   /* capture parameters (for high quality mode full size) */
+   struct v4l2_captureparm cap_parm;
+   int cur_frame;
+   int last_frame;
+
+   int b_acquire;
+   /* allocated image size */
+   unsigned long   req_image_size;
+   /* received packet size */
+   unsigned long   pkt_size;
+   int bad_payload;
+   unsigned long   frame_count;
+   /* if JPEG image */
+   int jpg_size;
+   /* if channel configured to default state */
+   int configured;
+   wait_queue_head_t   wait_setmode;
+   int setmode_ready;
+   /* video status items */
+   int vidstatus;
+   wait_queue_head_t   wait_vidstatus;
+   int vidstatus_ready;
+   unsigned intwidth;
+   unsigned intheight;
+   const struct s2255_fmt  *fmt;
+   int idx; /* channel number on device, 0-3 */
+};
+
 
 struct s2255_dev {
-   struct video_device vdev[MAX_CHANNELS];
+   struct s2255_channelchannel[MAX_CHANNELS];
struct v4l2_device  v4l2_dev;
-   atomic_tchannels; /* number of channels registered */
+   atomic_tnum_channels;
int frames;
struct mutexlock;
struct mutexopen_lock;
-   int resources[MAX_CHANNELS];
struct usb_device   *udev;
struct usb_interface*interface;
u8  read_endpoint;
-
-   struct s2255_dmaqueue   vidq[MAX_CHANNELS];
struct timer_list   timer;
struct s2255_fw *fw_data;
struct s2255_pipeinfo   pipe;
-   struct s2255_bufferibuffer[MAX_CHANNELS];
-   struct s2255_mode   mode[MAX_CHANNELS];
-   /* jpeg compression */
-   struct v4l2_jpegcompression jc[MAX_CHANNELS];
-   /* capture parameters (for high quality mode full size) */
-   struct v4l2_captureparm cap_parm[MAX_CHANNELS];
-   const struct s2255_fmt  *cur_fmt[MAX_CHANNELS];
-   int cur_frame[MAX_CHANNELS];
-   int last_frame[MAX_CHANNELS];
u32 cc; /* current channel */
-   int b_acquire[MAX_CHANNELS];
-   /* allocated image size */
-   unsigned long   req_image_size[MAX_CHANNELS];
-   /* received packet size */
-   unsigned long   pkt_size[MAX_CHANNELS];
-   int bad_payload[MAX_CHANNELS];
-   unsigned long   frame_count[MAX_CHANNELS];
int frame_ready;
-   /* if JPEG image */
-   int jpg_size[MAX_CHANNELS];
-   /* if channel configured to default state */
-   int chn_configured[MAX_CHANNELS];
-   wait_queue_head_t   wait_setmode[MAX_CHANNELS];
-   int setmode_ready[MAX_CHANNELS];
-   /* video status items */
-   int vidstatus[MAX_CHANNELS];
-   wait_queue_head_t   wait_vidstatus[MAX_CHANNELS];
-   int vidstatus_ready[MAX_CHANNELS];
int chn_ready;
spinlock_t  slock;
/* dsp firmware version (f2255usb.bin) */
@@ -298,16 +306,10 @@ struct s2255_buffer {
 
 struct s2255_fh {
struct s2255_dev*dev;
-   const struct s2255_fmt  *fmt;
-   unsigned intwidth;
-   unsigned intheight;
struct videobuf_queue   vb_vidq;

Re: [PATCH] s2255drv: cleanup of device structure

2010-04-20 Thread Mauro Carvalho Chehab
Hi Dean,

Em Mon, 12 Apr 2010 10:19:13 -0700 (PDT)
sensoray-dev  escreveu:

> # HG changeset patch
> # User Dean Anderson 
> # Date 1271092523 25200
> # Node ID 686a2330f4a6a4c79e299a17663f0f150031098e
> # Parent  f2f44853e2eb914d4fc6c7004631839b86fb6d0e
> s2255drv: cleanup of device structure
> 
> From: Dean Anderson 
> 
> cleanup of device structure
> better organization of channels instead of multiple arrays in device
> simplifies open callback by removing search for channel index
> adding v4l2_device_disconnect
> 
> Priority: normal
> 
> Signed-off-by: Dean Anderson 


Sorry, but the patch didn't apply:

patching file drivers/media/video/s2255drv.c
Hunk #1 succeeded at 190 (offset -1 lines).
Hunk #3 succeeded at 305 (offset -1 lines).
Hunk #5 succeeded at 577 (offset -1 lines).
Hunk #7 succeeded at 622 (offset -1 lines).
Hunk #9 succeeded at 661 (offset -1 lines).
Hunk #11 succeeded at 686 (offset -1 lines).
Hunk #13 succeeded at 754 (offset -1 lines).
Hunk #15 succeeded at 778 (offset -1 lines).
Hunk #17 succeeded at 893 (offset -1 lines).
Hunk #19 succeeded at 1013 (offset -1 lines).
Hunk #21 succeeded at 1243 (offset -1 lines).
Hunk #23 succeeded at 1307 (offset -1 lines).
Hunk #25 succeeded at 1353 (offset -1 lines).
Hunk #27 succeeded at 1414 (offset -1 lines).
Hunk #29 succeeded at 1435 (offset -1 lines).
Hunk #31 succeeded at 1477 (offset -1 lines).
Hunk #33 succeeded at 1531 (offset -1 lines).
Hunk #35 succeeded at 1584 (offset -1 lines).
Hunk #37 succeeded at 1632 (offset -1 lines).
Hunk #39 succeeded at 1711 (offset -1 lines).
Hunk #41 succeeded at 1843 (offset -1 lines).
Hunk #43 succeeded at 1925 (offset -1 lines).
Hunk #44 FAILED at 1947.
Hunk #45 succeeded at 2017 (offset 1 line).
Hunk #46 succeeded at 2044 (offset -1 lines).
Hunk #47 succeeded at 2065 (offset 1 line).
Hunk #48 succeeded at 2084 (offset -1 lines).
Hunk #49 succeeded at 2105 (offset 1 line).
Hunk #50 succeeded at 2132 (offset -1 lines).
Hunk #51 succeeded at 2228 (offset 1 line).
Hunk #52 succeeded at 2240 (offset -1 lines).
Hunk #53 succeeded at 2312 (offset 1 line).
Hunk #54 succeeded at 2337 (offset -1 lines).
Hunk #55 succeeded at 2437 (offset 1 line).
Hunk #56 succeeded at 2465 (offset -1 lines).
Hunk #57 succeeded at 2492 (offset 1 line).
Hunk #58 succeeded at 2548 (offset -1 lines).
Hunk #59 succeeded at 2587 (offset 1 line).
Hunk #60 succeeded at 2626 (offset -1 lines).
Hunk #61 succeeded at 2670 (offset 1 line).
1 out of 61 hunks FAILED -- saving rejects to file 
drivers/media/video/s2255drv.c.rej
>>> Patch patches/lmml_92061_s2255drv_cleanup_of_device_structure.patch doesn't 
>>> apply

I might try to fix the failed hunk, but I prefer if you could double check 
what's going
wrong, since this is a long patch that are replacing some structs.

Please use my -git tree as the basis, since Douglas is currently in a training
and it may take some time until he could be able to sync the -hg tree.




> 
> diff -r f2f44853e2eb -r 686a2330f4a6 linux/drivers/media/video/s2255drv.c
> --- a/linux/drivers/media/video/s2255drv.cFri Apr 09 15:51:28 2010 -0700
> +++ b/linux/drivers/media/video/s2255drv.cMon Apr 12 10:15:23 2010 -0700
> @@ -191,7 +191,6 @@
>  struct s2255_dmaqueue {
>   struct list_headactive;
>   struct s2255_dev*dev;
> - int channel;
>  };
>  
>  /* for firmware loading, fw_state */
> @@ -226,51 +225,60 @@
>  };
>  
>  struct s2255_fmt; /*forward declaration */
> +struct s2255_dev;
> +
> +struct s2255_channel {
> + struct video_device vdev;
> + int resources;
> + struct s2255_dmaqueue   vidq;
> + struct s2255_bufferibuffer;
> + struct s2255_mode   mode;
> + /* jpeg compression */
> + struct v4l2_jpegcompression jc;
> + /* capture parameters (for high quality mode full size) */
> + struct v4l2_captureparm cap_parm;
> + int cur_frame;
> + int last_frame;
> +
> + int b_acquire;
> + /* allocated image size */
> + unsigned long   req_image_size;
> + /* received packet size */
> + unsigned long   pkt_size;
> + int bad_payload;
> + unsigned long   frame_count;
> + /* if JPEG image */
> + int jpg_size;
> + /* if channel configured to default state */
> + int configured;
> + wait_queue_head_t   wait_setmode;
> + int setmode_ready;
> + /* video status items */
> + int vidstatus;
> + wait_queue_head_t   wait_vidstatus;
> + int vidstatus_ready;
> + unsigned intwidth;
> + unsigned intheight;
> + const struct s2255_fmt  *fmt;
> + int idx; /* channel number on device, 0-3 */
> +};
> +
>  
>  struct s2255_dev {
> - struct video_device vdev[MAX_CHANNELS];
> + struct s2255_ch

[PATCH] s2255drv: cleanup of device structure

2010-04-12 Thread sensoray-dev
# HG changeset patch
# User Dean Anderson 
# Date 1271092523 25200
# Node ID 686a2330f4a6a4c79e299a17663f0f150031098e
# Parent  f2f44853e2eb914d4fc6c7004631839b86fb6d0e
s2255drv: cleanup of device structure

From: Dean Anderson 

cleanup of device structure
better organization of channels instead of multiple arrays in device
simplifies open callback by removing search for channel index
adding v4l2_device_disconnect

Priority: normal

Signed-off-by: Dean Anderson 

diff -r f2f44853e2eb -r 686a2330f4a6 linux/drivers/media/video/s2255drv.c
--- a/linux/drivers/media/video/s2255drv.c  Fri Apr 09 15:51:28 2010 -0700
+++ b/linux/drivers/media/video/s2255drv.c  Mon Apr 12 10:15:23 2010 -0700
@@ -191,7 +191,6 @@
 struct s2255_dmaqueue {
struct list_headactive;
struct s2255_dev*dev;
-   int channel;
 };
 
 /* for firmware loading, fw_state */
@@ -226,51 +225,60 @@
 };
 
 struct s2255_fmt; /*forward declaration */
+struct s2255_dev;
+
+struct s2255_channel {
+   struct video_device vdev;
+   int resources;
+   struct s2255_dmaqueue   vidq;
+   struct s2255_bufferibuffer;
+   struct s2255_mode   mode;
+   /* jpeg compression */
+   struct v4l2_jpegcompression jc;
+   /* capture parameters (for high quality mode full size) */
+   struct v4l2_captureparm cap_parm;
+   int cur_frame;
+   int last_frame;
+
+   int b_acquire;
+   /* allocated image size */
+   unsigned long   req_image_size;
+   /* received packet size */
+   unsigned long   pkt_size;
+   int bad_payload;
+   unsigned long   frame_count;
+   /* if JPEG image */
+   int jpg_size;
+   /* if channel configured to default state */
+   int configured;
+   wait_queue_head_t   wait_setmode;
+   int setmode_ready;
+   /* video status items */
+   int vidstatus;
+   wait_queue_head_t   wait_vidstatus;
+   int vidstatus_ready;
+   unsigned intwidth;
+   unsigned intheight;
+   const struct s2255_fmt  *fmt;
+   int idx; /* channel number on device, 0-3 */
+};
+
 
 struct s2255_dev {
-   struct video_device vdev[MAX_CHANNELS];
+   struct s2255_channelchannel[MAX_CHANNELS];
struct v4l2_device  v4l2_dev;
-   atomic_tchannels; /* number of channels registered */
+   atomic_tnum_channels;
int frames;
struct mutexlock;
struct mutexopen_lock;
-   int resources[MAX_CHANNELS];
struct usb_device   *udev;
struct usb_interface*interface;
u8  read_endpoint;
-
-   struct s2255_dmaqueue   vidq[MAX_CHANNELS];
struct timer_list   timer;
struct s2255_fw *fw_data;
struct s2255_pipeinfo   pipe;
-   struct s2255_bufferibuffer[MAX_CHANNELS];
-   struct s2255_mode   mode[MAX_CHANNELS];
-   /* jpeg compression */
-   struct v4l2_jpegcompression jc[MAX_CHANNELS];
-   /* capture parameters (for high quality mode full size) */
-   struct v4l2_captureparm cap_parm[MAX_CHANNELS];
-   const struct s2255_fmt  *cur_fmt[MAX_CHANNELS];
-   int cur_frame[MAX_CHANNELS];
-   int last_frame[MAX_CHANNELS];
u32 cc; /* current channel */
-   int b_acquire[MAX_CHANNELS];
-   /* allocated image size */
-   unsigned long   req_image_size[MAX_CHANNELS];
-   /* received packet size */
-   unsigned long   pkt_size[MAX_CHANNELS];
-   int bad_payload[MAX_CHANNELS];
-   unsigned long   frame_count[MAX_CHANNELS];
int frame_ready;
-   /* if JPEG image */
-   int jpg_size[MAX_CHANNELS];
-   /* if channel configured to default state */
-   int chn_configured[MAX_CHANNELS];
-   wait_queue_head_t   wait_setmode[MAX_CHANNELS];
-   int setmode_ready[MAX_CHANNELS];
-   /* video status items */
-   int vidstatus[MAX_CHANNELS];
-   wait_queue_head_t   wait_vidstatus[MAX_CHANNELS];
-   int vidstatus_ready[MAX_CHANNELS];
int chn_ready;
spinlock_t  slock;
/* dsp firmware version (f2255usb.bin) */
@@ -298,16 +306,10 @@
 
 struct s2255_fh {
struct s2255_dev*dev;
-   const struct s2255_fmt  *fmt;
-   unsigned intwidth;
-   unsigned intheight;
struct vi