From patchwork Thu Mar 18 15:22:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 48041 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id D93A3B7E85 for ; Fri, 19 Mar 2010 02:22:44 +1100 (EST) Received: from mail-pv0-f179.google.com (mail-pv0-f179.google.com [74.125.83.179]) by ozlabs.org (Postfix) with ESMTP id 6C091B7E5F for ; Fri, 19 Mar 2010 02:22:22 +1100 (EST) Received: by pvg12 with SMTP id 12so1087418pvg.38 for ; Thu, 18 Mar 2010 08:22:21 -0700 (PDT) Received: by 10.143.84.6 with SMTP id m6mr1366123wfl.162.1268925740956; Thu, 18 Mar 2010 08:22:20 -0700 (PDT) Received: from angua (S01060002b3d79728.cg.shawcable.net [70.72.87.49]) by mx.google.com with ESMTPS id 22sm63136pzk.1.2010.03.18.08.22.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 18 Mar 2010 08:22:20 -0700 (PDT) Received: from [127.0.1.1] (localhost [127.0.0.1]) by angua (Postfix) with ESMTP id DB355C4C; Thu, 18 Mar 2010 09:22:16 -0600 (MDT) From: Grant Likely Subject: [V2 PATCH 02/10] i2c/of: Allow device node to be passed via i2c_board_info To: davem@davemloft.net, benh@kernel.crashing.org, linux-kernel@vger.kernel.org, michal.simek@petalogix.com, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, microblaze-uclinux@itee.uq.edu.au Date: Thu, 18 Mar 2010 09:22:16 -0600 Message-ID: <20100318152216.21082.63.stgit@angua> In-Reply-To: <20100318144836.21082.93040.stgit@angua> References: <20100318144836.21082.93040.stgit@angua> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org The struct device_node *of_node pointer is moving out of dev->archdata and into the struct device proper. of_i2c.c needs to set the of_node pointer before the device is registered. Since the i2c subsystem doesn't allow 2 stage allocation and registration of i2c devices, the of_node pointer needs to be passed via the i2c_board_info structure so that it is set prior to registration. This patch adds of_node to struct i2c_board_info (conditional on CONFIG_OF), sets of_node in i2c_new_device(), and modifies of_i2c.c to use the new parameter. The calling of dev_archdata_set_node() from of_i2c will be removed in a subsequent patch when of_node is removed from archdata and all users are converted over. Signed-off-by: Grant Likely --- drivers/i2c/i2c-core.c | 3 +++ drivers/of/of_i2c.c | 1 + include/linux/i2c.h | 4 ++++ 3 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 3202a86..4099b2b 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -387,6 +387,9 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) client->dev.parent = &client->adapter->dev; client->dev.bus = &i2c_bus_type; client->dev.type = &i2c_client_type; +#ifdef CONFIG_OF + client->dev.of_node = info->of_node; +#endif dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap), client->addr); diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c index a3a708e..e690a2a 100644 --- a/drivers/of/of_i2c.c +++ b/drivers/of/of_i2c.c @@ -43,6 +43,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap, info.addr = be32_to_cpup(addr); dev_archdata_set_node(&dev_ad, node); + info.of_node = node; info.archdata = &dev_ad; request_module("%s", info.type); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0a5da63..4f37ff1 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -34,6 +34,7 @@ #include /* for struct device */ #include /* for completion */ #include +#include /* for struct device_node */ extern struct bus_type i2c_bus_type; @@ -251,6 +252,9 @@ struct i2c_board_info { unsigned short addr; void *platform_data; struct dev_archdata *archdata; +#ifdef CONFIG_OF + struct device_node *of_node; +#endif int irq; };