From patchwork Tue Jun 11 08:23:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2701041 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CA14A40213 for ; Tue, 11 Jun 2013 09:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753319Ab3FKJ7h (ORCPT ); Tue, 11 Jun 2013 05:59:37 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:60098 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752581Ab3FKJ7f (ORCPT ); Tue, 11 Jun 2013 05:59:35 -0400 Received: from axis700.grange (dslb-178-001-148-081.pools.arcor-ip.net [178.1.148.81]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MeMIx-1V0IP51zYt-00Pqxp; Tue, 11 Jun 2013 11:29:17 +0200 Received: from 6a.grange (unknown [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 47D3240BCD; Tue, 11 Jun 2013 10:24:05 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1UmJs4-0002Bs-TK; Tue, 11 Jun 2013 10:24:04 +0200 From: Guennadi Liakhovetski To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Sylwester Nawrocki , Hans Verkuil , linux-sh@vger.kernel.org, Magnus Damm , Sakari Ailus , Prabhakar Lad , Sascha Hauer , Guennadi Liakhovetski Subject: [PATCH v10 15/21] V4L2: add a device pointer to struct v4l2_subdev Date: Tue, 11 Jun 2013 10:23:42 +0200 Message-Id: <1370939028-8352-16-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1370939028-8352-1-git-send-email-g.liakhovetski@gmx.de> References: <1370939028-8352-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:MTbG+OCM8RoPO74pXMbhZVLnIEHSHLUBe6NZ25katms cvW/tsGlqjAFUFrKxdPHw9y/Huje3lVHRQZJPKhM6kZ9J6YI1h pIdIOfiPycSwSA+h3rUE+4tCmoaRrJsqH/GKvmnF/6tAZlF9MR Gde5W6eO0J7o2WiP/YETVV6jyt48AX+QYEftrTby/I9Jo9EJRZ hfG+Ek/MXWQhU+fTIp1fEDzQlmGlnItzBZSKnELxtgX3w5nTyk vrAjZiLvPNm8kHv2pKoC8zCrwV+4hRf6vQrUdmf1wZktFCh3bl 2npg3PYc4QSKBx4iJoa8K9QlIi2d9f3FQVw76+x+mXK8l30a+C IwVeic+iAZ0IObPA2gKrW1IdPm1YonTTYobXm66B9ZCR4N7vDF zRobiBw2e+TuQ== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org It is often useful to have simple means to get from a subdevice to the underlying physical device. This patch adds such a pointer to struct v4l2_subdev and sets it accordingly in the I2C and SPI cases. Signed-off-by: Guennadi Liakhovetski Acked-by: Lad, Prabhakar --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ include/media/v4l2-subdev.h | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 3fed63f..accfec6 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -291,6 +291,7 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_IS_I2C; /* the owner is the same as the i2c_client's driver owner */ sd->owner = client->driver->driver.owner; + sd->dev = &client->dev; /* i2c_client and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, client); i2c_set_clientdata(client, sd); @@ -426,6 +427,7 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, sd->flags |= V4L2_SUBDEV_FL_IS_SPI; /* the owner is the same as the spi_device's driver owner */ sd->owner = spi->dev.driver->owner; + sd->dev = &spi->dev; /* spi_device and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, spi); spi_set_drvdata(spi, sd); diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 5298d67..d8756fa 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -585,6 +585,8 @@ struct v4l2_subdev { void *host_priv; /* subdev device node */ struct video_device *devnode; + /* pointer to the physical device */ + struct device *dev; }; #define media_entity_to_v4l2_subdev(ent) \