From patchwork Wed Oct 31 15:57:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pantelis Antoniou X-Patchwork-Id: 1672341 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 27863DFB7B for ; Tue, 30 Oct 2012 18:22:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TTGSe-0006bE-Jp; Tue, 30 Oct 2012 18:22:48 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TTGSd-0006b7-FP for spi-devel-general@lists.sourceforge.net; Tue, 30 Oct 2012 18:22:47 +0000 X-ACL-Warn: Received: from li42-95.members.linode.com ([209.123.162.95]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1TTGSc-0002Zs-EL for spi-devel-general@lists.sourceforge.net; Tue, 30 Oct 2012 18:22:47 +0000 Received: from sles11esa.localdomain (unknown [195.97.110.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: panto) by li42-95.members.linode.com (Postfix) with ESMTPSA id 17C429C1F5; Tue, 30 Oct 2012 18:04:25 +0000 (UTC) From: Pantelis Antoniou To: Grant Likely Subject: [PATCH] spi: Export OF interfaces. Date: Wed, 31 Oct 2012 17:57:33 +0200 Message-Id: <1351699053-4533-1-git-send-email-panto@antoniou-consulting.com> X-Mailer: git-send-email 1.7.12 X-Spam-Score: 2.2 (++) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 2.5 DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date -0.3 AWL AWL: From: address is in the auto white-list X-Headers-End: 1TTGSc-0002Zs-EL Cc: Matt Porter , devicetree-discuss@lists.ozlabs.org, Pantelis Antoniou , linux-kernel@vger.kernel.org, Russ Dill , spi-devel-general@lists.sourceforge.net, linux-omap@vger.kernel.org, Koen Kooi X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net Export an interface that other in-kernel users can utilize. Signed-off-by: Pantelis Antoniou --- drivers/spi/spi.c | 31 +++++++++++++++++++++++-------- include/linux/spi/spi.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 84c2861..f8de2f2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -801,14 +801,17 @@ err_init_queue: /*-------------------------------------------------------------------------*/ #if defined(CONFIG_OF) && !defined(CONFIG_SPARC) + /** - * of_register_spi_devices() - Register child devices onto the SPI bus + * of_register_node_spi_devices() - Register child devices onto the SPI bus * @master: Pointer to spi_master device + * @parent_node: Pointer to the device node containg the devices * * Registers an spi_device for each child node of master node which has a 'reg' * property. */ -static void of_register_spi_devices(struct spi_master *master) +void of_register_node_spi_devices(struct spi_master *master, + struct device_node *parent_node) { struct spi_device *spi; struct device_node *nc; @@ -816,10 +819,10 @@ static void of_register_spi_devices(struct spi_master *master) int rc; int len; - if (!master->dev.of_node) + if (!parent_node) return; - for_each_child_of_node(master->dev.of_node, nc) { + for_each_child_of_node(parent_node, nc) { /* Alloc an spi_device */ spi = spi_alloc_device(master); if (!spi) { @@ -884,8 +887,20 @@ static void of_register_spi_devices(struct spi_master *master) } } -#else -static void of_register_spi_devices(struct spi_master *master) { } +EXPORT_SYMBOL_GPL(of_register_node_spi_devices); + +/** + * of_register_spi_devices() - Register child devices onto the SPI bus + * @master: Pointer to spi_master device + * + * Registers an spi_device for each child node of master node which has a 'reg' + * property. + */ +void of_register_spi_devices(struct spi_master *master) +{ + of_register_node_spi_devices(master, master->dev.of_node); +} +EXPORT_SYMBOL_GPL(of_register_spi_devices); #endif static void spi_master_release(struct device *dev) @@ -896,12 +911,12 @@ static void spi_master_release(struct device *dev) kfree(master); } -static struct class spi_master_class = { +struct class spi_master_class = { .name = "spi_master", .owner = THIS_MODULE, .dev_release = spi_master_release, }; - +EXPORT_SYMBOL_GPL(spi_master_class); /** diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index fa702ae..618aa5e 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -30,6 +30,8 @@ */ extern struct bus_type spi_bus_type; +extern struct class spi_master_class; + /** * struct spi_device - Master side proxy for an SPI slave device * @dev: Driver model representation of the device. @@ -856,4 +858,20 @@ spi_unregister_device(struct spi_device *spi) extern const struct spi_device_id * spi_get_device_id(const struct spi_device *sdev); +#if defined(CONFIG_OF) && !defined(CONFIG_SPARC) + +void of_register_node_spi_devices(struct spi_master *master, + struct device_node *parent_node); + +void of_register_spi_devices(struct spi_master *master); + +#else + +static inline void of_register_node_spi_devices(struct spi_master *master, + struct device_node *parent_node) { } + +static inline void of_register_spi_devices(struct spi_master *master) { } + +#endif + #endif /* __LINUX_SPI_H */