From patchwork Thu Jan 27 12:30:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 511491 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0RCVaOc002985 for ; Thu, 27 Jan 2011 12:31:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753474Ab1A0MbB (ORCPT ); Thu, 27 Jan 2011 07:31:01 -0500 Received: from perceval.ideasonboard.com ([95.142.166.194]:59831 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753446Ab1A0MbA (ORCPT ); Thu, 27 Jan 2011 07:31:00 -0500 Received: from localhost.localdomain (unknown [91.178.11.103]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11E4D35CD0; Thu, 27 Jan 2011 12:30:57 +0000 (UTC) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: sakari.ailus@maxwell.research.nokia.com Subject: [PATCH v6 06/11] v4l: subdev: Add a new file operations class Date: Thu, 27 Jan 2011 13:30:51 +0100 Message-Id: <1296131456-30000-7-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296131456-30000-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1296131456-30000-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 27 Jan 2011 12:31:39 +0000 (UTC) diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index 15449fc..0f904e2 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c @@ -61,7 +61,7 @@ static int subdev_open(struct file *file) struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); struct v4l2_subdev_fh *subdev_fh; #if defined(CONFIG_MEDIA_CONTROLLER) - struct media_entity *entity; + struct media_entity *entity = NULL; #endif int ret; @@ -104,9 +104,17 @@ static int subdev_open(struct file *file) } #endif + ret = v4l2_subdev_call(sd, file, open, subdev_fh); + if (ret < 0 && ret != -ENOIOCTLCMD) + goto err; + return 0; err: +#if defined(CONFIG_MEDIA_CONTROLLER) + if (entity) + media_entity_put(entity); +#endif v4l2_fh_del(&subdev_fh->vfh); v4l2_fh_exit(&subdev_fh->vfh); subdev_fh_free(subdev_fh); @@ -117,13 +125,12 @@ err: static int subdev_close(struct file *file) { -#if defined(CONFIG_MEDIA_CONTROLLER) struct video_device *vdev = video_devdata(file); struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); -#endif struct v4l2_fh *vfh = file->private_data; struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh); + v4l2_subdev_call(sd, file, close, subdev_fh); #if defined(CONFIG_MEDIA_CONTROLLER) if (sd->v4l2_dev->mdev) media_entity_put(&sd->entity); diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index f8704ff..af704df 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -175,6 +175,15 @@ struct v4l2_subdev_core_ops { struct v4l2_event_subscription *sub); }; +/* open: called when the subdev device node is opened by an application. + + close: called when the subdev device node is close. + */ +struct v4l2_subdev_file_ops { + int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh); + int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh); +}; + /* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. @@ -416,6 +425,7 @@ struct v4l2_subdev_ir_ops { struct v4l2_subdev_ops { const struct v4l2_subdev_core_ops *core; + const struct v4l2_subdev_file_ops *file; const struct v4l2_subdev_tuner_ops *tuner; const struct v4l2_subdev_audio_ops *audio; const struct v4l2_subdev_video_ops *video;