aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s2255drv.c
diff options
context:
space:
mode:
authorDean Anderson <dean@sensoray.com>2010-04-08 22:52:20 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:57:25 -0400
commit3a67b5cc6f6ae37500b8f41fd52628395f7276a8 (patch)
tree8556630f94581332fcd0707d3c112014039668e5 /drivers/media/video/s2255drv.c
parent85b85482c243398839564d5f95d75f479bed591c (diff)
V4L/DVB: s2255drv: adding v4l2_device structure. video_register_device cleanup
adding v4l2_device structure. if one video_register_device call fails, allows use of other devices or channels. Signed-off-by: Dean Anderson <dean@sensoray.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r--drivers/media/video/s2255drv.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index aba7a72f355f..e1de2c4940b0 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -52,6 +52,7 @@
52#include <linux/smp_lock.h> 52#include <linux/smp_lock.h>
53#include <media/videobuf-vmalloc.h> 53#include <media/videobuf-vmalloc.h>
54#include <media/v4l2-common.h> 54#include <media/v4l2-common.h>
55#include <media/v4l2-device.h>
55#include <media/v4l2-ioctl.h> 56#include <media/v4l2-ioctl.h>
56#include <linux/vmalloc.h> 57#include <linux/vmalloc.h>
57#include <linux/usb.h> 58#include <linux/usb.h>
@@ -81,7 +82,6 @@
81#define S2255_DEF_BUFS 16 82#define S2255_DEF_BUFS 16
82#define S2255_SETMODE_TIMEOUT 500 83#define S2255_SETMODE_TIMEOUT 500
83#define S2255_VIDSTATUS_TIMEOUT 350 84#define S2255_VIDSTATUS_TIMEOUT 350
84#define MAX_CHANNELS 4
85#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL) 85#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
86#define S2255_MARKER_RESPONSE cpu_to_le32(0x2255ACACL) 86#define S2255_MARKER_RESPONSE cpu_to_le32(0x2255ACACL)
87#define S2255_RESPONSE_SETMODE cpu_to_le32(0x01) 87#define S2255_RESPONSE_SETMODE cpu_to_le32(0x01)
@@ -229,6 +229,8 @@ 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];
233 int channels; /* number of channels registered */
232 int frames; 234 int frames;
233 struct mutex lock; 235 struct mutex lock;
234 struct mutex open_lock; 236 struct mutex open_lock;
@@ -1710,7 +1712,8 @@ static int s2255_open(struct file *file)
1710 int state; 1712 int state;
1711 dprintk(1, "s2255: open called (dev=%s)\n", 1713 dprintk(1, "s2255: open called (dev=%s)\n",
1712 video_device_node_name(vdev)); 1714 video_device_node_name(vdev));
1713 for (i = 0; i < MAX_CHANNELS; i++) 1715
1716 for (i = 0; i < dev->channels; i++)
1714 if (&dev->vdev[i] == vdev) { 1717 if (&dev->vdev[i] == vdev) {
1715 cur_channel = i; 1718 cur_channel = i;
1716 break; 1719 break;
@@ -1944,7 +1947,11 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1944 int ret; 1947 int ret;
1945 int i; 1948 int i;
1946 int cur_nr = video_nr; 1949 int cur_nr = video_nr;
1947 1950 for (i = 0; i < MAX_CHANNELS; i++) {
1951 ret = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev[i]);
1952 if (ret)
1953 goto unreg_v4l2;
1954 }
1948 /* initialize all video 4 linux */ 1955 /* initialize all video 4 linux */
1949 /* register 4 video devices */ 1956 /* register 4 video devices */
1950 for (i = 0; i < MAX_CHANNELS; i++) { 1957 for (i = 0; i < MAX_CHANNELS; i++) {
@@ -1963,16 +1970,29 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1963 VFL_TYPE_GRABBER, 1970 VFL_TYPE_GRABBER,
1964 cur_nr + i); 1971 cur_nr + i);
1965 video_set_drvdata(&dev->vdev[i], dev); 1972 video_set_drvdata(&dev->vdev[i], dev);
1966 1973 if (ret) {
1967 if (ret != 0) {
1968 dev_err(&dev->udev->dev, 1974 dev_err(&dev->udev->dev,
1969 "failed to register video device!\n"); 1975 "failed to register video device!\n");
1970 return ret; 1976 break;
1971 } 1977 }
1978 dev->channels++;
1979 v4l2_info(&dev->v4l2_dev[i], "V4L2 device registered as %s\n",
1980 video_device_node_name(&dev->vdev[i]));
1981
1972 } 1982 }
1983
1973 printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %d.%d\n", 1984 printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %d.%d\n",
1974 S2255_MAJOR_VERSION, 1985 S2255_MAJOR_VERSION,
1975 S2255_MINOR_VERSION); 1986 S2255_MINOR_VERSION);
1987 /* if no channels registered, return error and probe will fail*/
1988 if (dev->channels == 0)
1989 return ret;
1990 if (dev->channels != MAX_CHANNELS)
1991 printk(KERN_WARNING "s2255: Not all channels available.\n");
1992 return 0;
1993unreg_v4l2:
1994 for (i-- ; i > 0; i--)
1995 v4l2_device_unregister(&dev->v4l2_dev[i]);
1976 return ret; 1996 return ret;
1977} 1997}
1978 1998
@@ -2637,13 +2657,9 @@ static int s2255_probe(struct usb_interface *interface,
2637 /* loads v4l specific */ 2657 /* loads v4l specific */
2638 retval = s2255_probe_v4l(dev); 2658 retval = s2255_probe_v4l(dev);
2639 if (retval) 2659 if (retval)
2640 goto errorV4L; 2660 goto errorBOARDINIT;
2641 dev_info(&interface->dev, "Sensoray 2255 detected\n"); 2661 dev_info(&interface->dev, "Sensoray 2255 detected\n");
2642 return 0; 2662 return 0;
2643errorV4L:
2644 for (i = 0; i < MAX_CHANNELS; i++)
2645 if (video_is_registered(&dev->vdev[i]))
2646 video_unregister_device(&dev->vdev[i]);
2647errorBOARDINIT: 2663errorBOARDINIT:
2648 s2255_board_shutdown(dev); 2664 s2255_board_shutdown(dev);
2649errorFWMARKER: 2665errorFWMARKER: