From patchwork Wed Aug 4 22:14:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Pannuto X-Patchwork-Id: 117162 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o74MEnnt010342 for ; Wed, 4 Aug 2010 22:14:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756909Ab0HDWOq (ORCPT ); Wed, 4 Aug 2010 18:14:46 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:64001 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756576Ab0HDWOp (ORCPT ); Wed, 4 Aug 2010 18:14:45 -0400 X-IronPort-AV: E=McAfee;i="5400,1158,6064"; a="49893966" Received: from pdmz-ns-mip.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.114.10]) by wolverine01.qualcomm.com with ESMTP/TLS/ADH-AES256-SHA; 04 Aug 2010 15:14:42 -0700 Received: from [10.42.111.47] (pdmz-snip-v218.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 4826F10004D6; Wed, 4 Aug 2010 15:14:43 -0700 (PDT) Message-ID: <4C59E654.1090403@codeaurora.org> Date: Wed, 04 Aug 2010 15:14:44 -0700 From: Patrick Pannuto User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12pre) Gecko/20100715 Shredder/3.0.7pre MIME-Version: 1.0 To: "linux-kernel@vger.kernel.org" CC: "linux-arm-msm@vger.kernel.org" , "linux-omap@vger.kernel.org" , "damm@opensource.se" , "lethal@linux-sh.org" , "rjw@sisk.pl" , "eric.y.miao@gmail.com" , "netdev@vger.kernel.org" , Greg Kroah-Hartman , alan@lxorguk.ukuu.org.uk, zt.tmzt@gmail.com Subject: [PATCH] platform: Facilitate the creation of pseduo-platform busses Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 04 Aug 2010 22:14:50 +0000 (UTC) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4d99c8b..c86be03 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -241,7 +241,8 @@ int platform_device_add(struct platform_device *pdev) if (!pdev->dev.parent) pdev->dev.parent = &platform_bus; - pdev->dev.bus = &platform_bus_type; + if (!pdev->dev.bus) + pdev->dev.bus = &platform_bus_type; if (pdev->id != -1) dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); @@ -482,7 +483,8 @@ static void platform_drv_shutdown(struct device *_dev) */ int platform_driver_register(struct platform_driver *drv) { - drv->driver.bus = &platform_bus_type; + if (!drv->driver.bus) + drv->driver.bus = &platform_bus_type; if (drv->probe) drv->driver.probe = platform_drv_probe; if (drv->remove) @@ -539,12 +541,12 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv, * if the probe was successful, and make sure any forced probes of * new devices fail. */ - spin_lock(&platform_bus_type.p->klist_drivers.k_lock); + spin_lock(&drv->driver.bus->p->klist_drivers.k_lock); drv->probe = NULL; if (code == 0 && list_empty(&drv->driver.p->klist_devices.k_list)) retval = -ENODEV; drv->driver.probe = platform_drv_probe_fail; - spin_unlock(&platform_bus_type.p->klist_drivers.k_lock); + spin_unlock(&drv->driver.bus->p->klist_drivers.k_lock); if (code != retval) platform_driver_unregister(drv); @@ -1017,6 +1019,26 @@ struct bus_type platform_bus_type = { }; EXPORT_SYMBOL_GPL(platform_bus_type); +/** platform_bus_type_init - fill in a pseudo-platform-bus + * @bus: foriegn bus type + * + * This init is basically a selective memcpy that + * won't overwrite any user-defined attributes and + * only copies things that platform bus defines anyway + */ +void platform_bus_type_init(struct bus_type *bus) +{ + if (!bus->dev_attrs) + bus->dev_attrs = platform_bus_type.dev_attrs; + if (!bus->match) + bus->match = platform_bus_type.match; + if (!bus->uevent) + bus->uevent = platform_bus_type.uevent; + if (!bus->pm) + bus->pm = platform_bus_type.pm; +} +EXPORT_SYMBOL_GPL(platform_bus_type_init); + int __init platform_bus_init(void) { int error; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 5417944..fa8c35a 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -79,6 +79,8 @@ extern int platform_driver_probe(struct platform_driver *driver, #define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) #define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) +extern void platform_bus_type_init(struct bus_type *); + extern struct platform_device *platform_create_bundle(struct platform_driver *driver, int (*probe)(struct platform_device *), struct resource *res, unsigned int n_res,