From patchwork Wed Mar 31 16:34:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dean Anderson X-Patchwork-Id: 89985 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2VGfSUf014989 for ; Wed, 31 Mar 2010 16:41:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757628Ab0CaQl1 (ORCPT ); Wed, 31 Mar 2010 12:41:27 -0400 Received: from gateway03.websitewelcome.com ([69.93.87.23]:60447 "HELO gateway03.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1757604Ab0CaQl0 (ORCPT ); Wed, 31 Mar 2010 12:41:26 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 31 Mar 2010 16:41:59 +0000 (UTC) X-Greylist: delayed 399 seconds by postgrey-1.27 at vger.kernel.org; Wed, 31 Mar 2010 12:41:26 EDT Received: (qmail 16450 invoked from network); 31 Mar 2010 16:35:51 -0000 Received: from gator886.hostgator.com (174.120.40.226) by gateway03.websitewelcome.com with SMTP; 31 Mar 2010 16:35:51 -0000 Received: from [66.15.212.169] (port=21212 helo=user-desktop.local) by gator886.hostgator.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Nx0sQ-0007hP-Uz; Wed, 31 Mar 2010 11:34:47 -0500 Date: Wed, 31 Mar 2010 09:34:39 -0700 (PDT) From: "Dean A." Subject: [PATCH] s2255drv: v4l2 device added To: linux-media@vger.kernel.org cc: hverkuil@xs4all.nl Message-ID: MIME-Version: 1.0 Content-Disposition: INLINE X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator886.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sensoray.com Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -r c72bdc8732ab -r 0690e4e1d81e linux/drivers/media/video/s2255drv.c --- a/linux/drivers/media/video/s2255drv.c Wed Mar 31 07:38:11 2010 -0700 +++ b/linux/drivers/media/video/s2255drv.c Wed Mar 31 09:30:44 2010 -0700 @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -77,7 +78,6 @@ #define S2255_DEF_BUFS 16 #define S2255_SETMODE_TIMEOUT 500 #define S2255_VIDSTATUS_TIMEOUT 350 -#define MAX_CHANNELS 4 #define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL) #define S2255_MARKER_RESPONSE cpu_to_le32(0x2255ACACL) #define S2255_RESPONSE_SETMODE cpu_to_le32(0x01) @@ -225,6 +225,8 @@ struct s2255_dev { struct video_device vdev[MAX_CHANNELS]; + struct v4l2_device v4l2_dev[MAX_CHANNELS]; + int channels; /* number of channels registered */ int frames; struct mutex lock; struct mutex open_lock; @@ -1753,7 +1755,8 @@ int state; dprintk(1, "s2255: open called (dev=%s)\n", video_device_node_name(vdev)); - for (i = 0; i < MAX_CHANNELS; i++) + + for (i = 0; i < dev->channels; i++) if (&dev->vdev[i] == vdev) { cur_channel = i; break; @@ -1994,7 +1997,11 @@ int ret; int i; int cur_nr = video_nr; - + for (i = 0; i < MAX_CHANNELS; i++) { + ret = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev[i]); + if (ret) + goto unreg_v4l2; + } /* initialize all video 4 linux */ /* register 4 video devices */ for (i = 0; i < MAX_CHANNELS; i++) { @@ -2014,16 +2021,29 @@ VFL_TYPE_GRABBER, cur_nr + i); video_set_drvdata(&dev->vdev[i], dev); - - if (ret != 0) { + if (ret) { dev_err(&dev->udev->dev, "failed to register video device!\n"); - return ret; + break; } + dev->channels++; + v4l2_info(&dev->v4l2_dev[i], "V4L2 device registered as %s\n", + video_device_node_name(&dev->vdev[i])); + } + printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %d.%d\n", S2255_MAJOR_VERSION, S2255_MINOR_VERSION); + /* if no channels registered, return error and probe will fail*/ + if (dev->channels == 0) + return ret; + if (dev->channels != MAX_CHANNELS) + printk(KERN_WARNING "s2255: Not all channels available.\n"); + return 0; +unreg_v4l2: + for (i-- ; i > 0; i--) + v4l2_device_unregister(&dev->v4l2_dev[i]); return ret; } @@ -2705,13 +2725,9 @@ /* loads v4l specific */ retval = s2255_probe_v4l(dev); if (retval) - goto errorV4L; + goto errorBOARDINIT; dev_info(&interface->dev, "Sensoray 2255 detected\n"); return 0; -errorV4L: - for (i = 0; i < MAX_CHANNELS; i++) - if (video_is_registered(&dev->vdev[i])) - video_unregister_device(&dev->vdev[i]); errorBOARDINIT: s2255_board_shutdown(dev); errorFWMARKER: