From patchwork Tue May 19 23:04:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 6440941 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B08319F318 for ; Tue, 19 May 2015 23:05:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6846203DC for ; Tue, 19 May 2015 23:05:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0C88203DB for ; Tue, 19 May 2015 23:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752316AbbESXFc (ORCPT ); Tue, 19 May 2015 19:05:32 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:56193 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751967AbbESXFb (ORCPT ); Tue, 19 May 2015 19:05:31 -0400 Received: from lanttu.localdomain (lanttu-e.localdomain [192.168.1.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id D9D8860098; Wed, 20 May 2015 02:05:24 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: linux-leds@vger.kernel.org, j.anaszewski@samsung.com, cooloney@gmail.com, g.liakhovetski@gmx.de, s.nawrocki@samsung.com, laurent.pinchart@ideasonboard.com, mchehab@osg.samsung.com Subject: [PATCH 3/5] v4l: flash: Pass struct device and device_node to v4l2_flash_init() Date: Wed, 20 May 2015 02:04:03 +0300 Message-Id: <1432076645-4799-4-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432076645-4799-1-git-send-email-sakari.ailus@iki.fi> References: <1432076645-4799-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The V4L2 sub-device node's dev will thus refer to the physical device, not the LED flash device node. Also matching against device_node is possible in cases where the LED flash controller drives multiple LEDs. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-flash.c | 10 ++++++---- include/media/v4l2-flash.h | 10 +++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-flash.c b/drivers/media/v4l2-core/v4l2-flash.c index bed2036..d182adc 100644 --- a/drivers/media/v4l2-core/v4l2-flash.c +++ b/drivers/media/v4l2-core/v4l2-flash.c @@ -542,9 +542,10 @@ static const struct v4l2_subdev_ops v4l2_flash_subdev_ops = { .core = &v4l2_flash_core_ops, }; -struct v4l2_flash *v4l2_flash_init(struct led_classdev_flash *fled_cdev, - const struct v4l2_flash_ops *ops, - struct v4l2_flash_config *config) +struct v4l2_flash *v4l2_flash_init( + struct device *dev, struct device_node *of_node, + struct led_classdev_flash *fled_cdev, const struct v4l2_flash_ops *ops, + struct v4l2_flash_config *config) { struct v4l2_flash *v4l2_flash; struct led_classdev *led_cdev = &fled_cdev->led_cdev; @@ -562,7 +563,8 @@ struct v4l2_flash *v4l2_flash_init(struct led_classdev_flash *fled_cdev, sd = &v4l2_flash->sd; v4l2_flash->fled_cdev = fled_cdev; v4l2_flash->ops = ops; - sd->dev = led_cdev->dev; + sd->dev = dev; + sd->of_node = of_node; v4l2_subdev_init(sd, &v4l2_flash_subdev_ops); sd->internal_ops = &v4l2_flash_subdev_internal_ops; sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; diff --git a/include/media/v4l2-flash.h b/include/media/v4l2-flash.h index 67a2cbf..31e421d 100644 --- a/include/media/v4l2-flash.h +++ b/include/media/v4l2-flash.h @@ -115,6 +115,8 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) /** * v4l2_flash_init - initialize V4L2 flash led sub-device + * @dev: flash device, e.g. an I2C device + * @of_node: of_node of the LED, may be NULL if the same as device's * @fled_cdev: the LED Flash class device to wrap * @flash_ops: V4L2 Flash device ops * @config: initialization data for V4L2 Flash sub-device @@ -125,9 +127,10 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) * value is encoded using ERR_PTR(). Use IS_ERR() to check and * PTR_ERR() to obtain the numeric return value. */ -struct v4l2_flash *v4l2_flash_init(struct led_classdev_flash *fled_cdev, - const struct v4l2_flash_ops *ops, - struct v4l2_flash_config *config); +struct v4l2_flash *v4l2_flash_init( + struct device *dev, struct device_node *of_node, + struct led_classdev_flash *fled_cdev, const struct v4l2_flash_ops *ops, + struct v4l2_flash_config *config); /** * v4l2_flash_release - release V4L2 Flash sub-device @@ -139,6 +142,7 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash); #else static inline struct v4l2_flash *v4l2_flash_init( + struct device *dev, struct device_node *of_node, struct led_classdev_flash *fled_cdev, const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config) {