aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/s2255drv.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index e1de2c4940b0..e6dc7fac5b01 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -229,7 +229,7 @@ struct s2255_fmt; /*forward declaration */
229 229
230struct s2255_dev { 230struct s2255_dev {
231 struct video_device vdev[MAX_CHANNELS]; 231 struct video_device vdev[MAX_CHANNELS];
232 struct v4l2_device v4l2_dev[MAX_CHANNELS]; 232 struct v4l2_device v4l2_dev;
233 int channels; /* number of channels registered */ 233 int channels; /* number of channels registered */
234 int frames; 234 int frames;
235 struct mutex lock; 235 struct mutex lock;
@@ -278,7 +278,14 @@ struct s2255_dev {
278 u16 pid; /* product id */ 278 u16 pid; /* product id */
279 struct kref kref; 279 struct kref kref;
280}; 280};
281#define to_s2255_dev(d) container_of(d, struct s2255_dev, kref) 281
282/* kref will be removed soon */
283#define to_s2255_dev_from_kref(d) container_of(d, struct s2255_dev, kref)
284
285static inline struct s2255_dev *to_s2255_dev(struct v4l2_device *v4l2_dev)
286{
287 return container_of(v4l2_dev, struct s2255_dev, v4l2_dev);
288}
282 289
283struct s2255_fmt { 290struct s2255_fmt {
284 char *name; 291 char *name;
@@ -1829,7 +1836,7 @@ static unsigned int s2255_poll(struct file *file,
1829 1836
1830static void s2255_destroy(struct kref *kref) 1837static void s2255_destroy(struct kref *kref)
1831{ 1838{
1832 struct s2255_dev *dev = to_s2255_dev(kref); 1839 struct s2255_dev *dev = to_s2255_dev_from_kref(kref);
1833 /* board shutdown stops the read pipe if it is running */ 1840 /* board shutdown stops the read pipe if it is running */
1834 s2255_board_shutdown(dev); 1841 s2255_board_shutdown(dev);
1835 /* make sure firmware still not trying to load */ 1842 /* make sure firmware still not trying to load */
@@ -1947,11 +1954,9 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1947 int ret; 1954 int ret;
1948 int i; 1955 int i;
1949 int cur_nr = video_nr; 1956 int cur_nr = video_nr;
1950 for (i = 0; i < MAX_CHANNELS; i++) { 1957 ret = v4l2_device_register(&dev->interface->dev, &dev->v4l2_dev);
1951 ret = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev[i]); 1958 if (ret)
1952 if (ret) 1959 return ret;
1953 goto unreg_v4l2;
1954 }
1955 /* initialize all video 4 linux */ 1960 /* initialize all video 4 linux */
1956 /* register 4 video devices */ 1961 /* register 4 video devices */
1957 for (i = 0; i < MAX_CHANNELS; i++) { 1962 for (i = 0; i < MAX_CHANNELS; i++) {
@@ -1976,7 +1981,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1976 break; 1981 break;
1977 } 1982 }
1978 dev->channels++; 1983 dev->channels++;
1979 v4l2_info(&dev->v4l2_dev[i], "V4L2 device registered as %s\n", 1984 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
1980 video_device_node_name(&dev->vdev[i])); 1985 video_device_node_name(&dev->vdev[i]));
1981 1986
1982 } 1987 }
@@ -1985,15 +1990,13 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1985 S2255_MAJOR_VERSION, 1990 S2255_MAJOR_VERSION,
1986 S2255_MINOR_VERSION); 1991 S2255_MINOR_VERSION);
1987 /* if no channels registered, return error and probe will fail*/ 1992 /* if no channels registered, return error and probe will fail*/
1988 if (dev->channels == 0) 1993 if (dev->channels == 0) {
1994 v4l2_device_unregister(&dev->v4l2_dev);
1989 return ret; 1995 return ret;
1996 }
1990 if (dev->channels != MAX_CHANNELS) 1997 if (dev->channels != MAX_CHANNELS)
1991 printk(KERN_WARNING "s2255: Not all channels available.\n"); 1998 printk(KERN_WARNING "s2255: Not all channels available.\n");
1992 return 0; 1999 return 0;
1993unreg_v4l2:
1994 for (i-- ; i > 0; i--)
1995 v4l2_device_unregister(&dev->v4l2_dev[i]);
1996 return ret;
1997} 2000}
1998 2001
1999/* this function moves the usb stream read pipe data 2002/* this function moves the usb stream read pipe data
@@ -2596,8 +2599,6 @@ static int s2255_probe(struct usb_interface *interface,
2596 dev_err(&interface->dev, "Could not find bulk-in endpoint\n"); 2599 dev_err(&interface->dev, "Could not find bulk-in endpoint\n");
2597 goto errorEP; 2600 goto errorEP;
2598 } 2601 }
2599 /* set intfdata */
2600 usb_set_intfdata(interface, dev);
2601 init_timer(&dev->timer); 2602 init_timer(&dev->timer);
2602 dev->timer.function = s2255_timer; 2603 dev->timer.function = s2255_timer;
2603 dev->timer.data = (unsigned long)dev->fw_data; 2604 dev->timer.data = (unsigned long)dev->fw_data;
@@ -2682,13 +2683,12 @@ errorFWDATA1:
2682 return retval; 2683 return retval;
2683} 2684}
2684 2685
2685
2686/* disconnect routine. when board is removed physically or with rmmod */ 2686/* disconnect routine. when board is removed physically or with rmmod */
2687static void s2255_disconnect(struct usb_interface *interface) 2687static void s2255_disconnect(struct usb_interface *interface)
2688{ 2688{
2689 struct s2255_dev *dev = NULL; 2689 struct s2255_dev *dev = to_s2255_dev(usb_get_intfdata(interface));
2690 int i; 2690 int i;
2691 dev = usb_get_intfdata(interface); 2691 v4l2_device_unregister(&dev->v4l2_dev);
2692 /* unregister each video device. */ 2692 /* unregister each video device. */
2693 for (i = 0; i < MAX_CHANNELS; i++) 2693 for (i = 0; i < MAX_CHANNELS; i++)
2694 if (video_is_registered(&dev->vdev[i])) 2694 if (video_is_registered(&dev->vdev[i]))
@@ -2702,7 +2702,6 @@ static void s2255_disconnect(struct usb_interface *interface)
2702 dev->vidstatus_ready[i] = 1; 2702 dev->vidstatus_ready[i] = 1;
2703 wake_up(&dev->wait_vidstatus[i]); 2703 wake_up(&dev->wait_vidstatus[i]);
2704 } 2704 }
2705 usb_set_intfdata(interface, NULL);
2706 kref_put(&dev->kref, s2255_destroy); 2705 kref_put(&dev->kref, s2255_destroy);
2707 dev_info(&interface->dev, "%s\n", __func__); 2706 dev_info(&interface->dev, "%s\n", __func__);
2708} 2707}