From patchwork Wed May 25 21:31:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 818812 Received: from canuck.infradead.org (canuck.infradead.org [134.117.69.58]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4PNw1KN032507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 25 May 2011 23:58:22 GMT Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QPN3n-00013B-SV; Wed, 25 May 2011 23:00:15 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPMzQ-0000Sq-4v for linux-arm-kernel@canuck.infradead.org; Wed, 25 May 2011 22:55:44 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by casper.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QPLkG-00046r-NC for linux-arm-kernel@lists.infradead.org; Wed, 25 May 2011 21:36:01 +0000 Received: by iyb39 with SMTP id 39so141213iyb.36 for ; Wed, 25 May 2011 14:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=2OTS/4fY19874mWeYz755nihqo6R89/bC4KIOFt7KVc=; b=Y7DPQxjwBcx+xgr9/dDUyiDMr3NDGKSFCxuAeZjoapViiAIox74Qa1FnGU7gQdZVU1 1pR7JTM83o4K0vaxtJBG48xhlmZF8v/tuJidUloq9yzp1MzL0wYGgs0XrQf7VoFd4zGe 3zx/0ftqxHrcqE2Lr7E/z5z8hDS8h3usJUVzo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=bRU3rr3JdQavU/dFqY1wv/WLmTE1F4RQvwxdYs5qlCV76NFutlrXs7E7I43JVuRm1D JwqEpr84RgkDbG/pNAo6FXGONY5ewxyjHUZXuPCiNoeoS/MHL9ra8b7GKfu9FCG4GVzn 5sgrWdGmlLsz5iw1ERGhIqufF9H/WiYx2RAhE= Received: by 10.42.131.69 with SMTP id y5mr53267ics.418.1306359101228; Wed, 25 May 2011 14:31:41 -0700 (PDT) Received: from rob-laptop.i.smooth-stone.com ([173.226.190.126]) by mx.google.com with ESMTPS id d10sm19886ibb.66.2011.05.25.14.31.39 (version=SSLv3 cipher=OTHER); Wed, 25 May 2011 14:31:40 -0700 (PDT) From: Rob Herring To: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v3 2/2] dt: add custom device creation to platform bus scan Date: Wed, 25 May 2011 16:31:13 -0500 Message-Id: <1306359073-16274-3-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1306359073-16274-1-git-send-email-robherring2@gmail.com> References: <1306359073-16274-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110525_223601_170607_8CAA6E1B X-CRM114-Status: GOOD ( 19.83 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.3.2-r929478 on casper.infradead.org summary: Content analysis details: (-1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.6 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: linux@arm.linux.org.uk, arnd@arndb.de, Linus Walleij , Rob Herring , Grant Likely , Jeremy Kerr X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 25 May 2011 23:58:22 +0000 (UTC) From: Rob Herring Add support to the platform bus scanning to call custom device creation functions. This enables creation of non-platform devices like amba_bus. Cc: Jeremy Kerr Cc: Grant Likely Cc: linux@arm.linux.org.uk Cc: arnd@arndb.de Cc: Linus Walleij Signed-off-by: Rob Herring --- drivers/of/platform.c | 27 +++++++++++++++++++-------- include/linux/of_platform.h | 11 ++++++++--- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9b785be..8c0f43400 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -176,9 +176,9 @@ EXPORT_SYMBOL(of_device_alloc); * Returns pointer to created platform device, or NULL if a device was not * registered. Unavailable devices will not get registered. */ -struct platform_device *of_platform_device_create(struct device_node *np, - const char *bus_id, - struct device *parent) +struct device *of_platform_device_create(struct device_node *np, + const char *bus_id, + struct device *parent) { struct platform_device *dev; @@ -205,7 +205,7 @@ struct platform_device *of_platform_device_create(struct device_node *np, return NULL; } - return dev; + return &dev->dev; } EXPORT_SYMBOL(of_platform_device_create); @@ -224,7 +224,9 @@ static int of_platform_bus_create(struct device_node *bus, struct device *parent, bool strict) { struct device_node *child; - struct platform_device *dev; + struct device *dev; + struct of_device_id *id; + struct of_platform_match_data *mdata; int rc = 0; /* Make sure it has a compatible property */ @@ -234,13 +236,22 @@ static int of_platform_bus_create(struct device_node *bus, return 0; } - dev = of_platform_device_create(bus, NULL, parent); - if (!dev || !of_match_node(matches, bus)) + id = of_match_node(matches, bus); + if (!id) + return 0; + + /* Found a matching node, so create the device */ + mdata = id->data; + if (mdata && mdata->dev_create) + dev = mdata->dev_create(bus, parent); + else + dev = of_platform_device_create(bus, NULL, parent); + if (!dev) return 0; for_each_child_of_node(bus, child) { pr_debug(" create child: %s\n", child->full_name); - rc = of_platform_bus_create(child, matches, &dev->dev, strict); + rc = of_platform_bus_create(child, matches, dev, strict); if (rc) { of_node_put(child); break; diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 43c723d..f59d25e 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -40,6 +40,11 @@ struct of_platform_driver #define to_of_platform_driver(drv) \ container_of(drv,struct of_platform_driver, driver) +struct of_platform_match_data { + struct device * (*dev_create)(struct device_node *node, + struct device *parent); +}; + /* Platform drivers register/unregister */ extern struct platform_device *of_device_alloc(struct device_node *np, const char *bus_id, @@ -48,9 +53,9 @@ extern struct platform_device *of_find_device_by_node(struct device_node *np); #if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */ /* Platform devices and busses creation */ -extern struct platform_device *of_platform_device_create(struct device_node *np, - const char *bus_id, - struct device *parent); +extern struct device *of_platform_device_create(struct device_node *np, + const char *bus_id, + struct device *parent); extern int of_platform_bus_probe(struct device_node *root, const struct of_device_id *matches,