X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fbase%2Fplatform.c;h=869ff8c001460929a6b5721129b434c9cd50ef4f;hb=09c7d8293a2d1317d16ef4ddb9f6dd2553d0694e;hp=f9c903ba9fcd1259e37120e2db74d55c6acdcbce;hpb=9cdf083f981b8d37b3212400a359368661385099;p=pandora-kernel.git diff --git a/drivers/base/platform.c b/drivers/base/platform.c index f9c903ba9fcd..869ff8c00146 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -160,6 +160,11 @@ static void platform_device_release(struct device *dev) * * Create a platform device object which can have other objects attached * to it, and which will have attached objects freed when it is released. + * + * This device will be marked as not supporting hotpluggable drivers; no + * device add/remove uevents will be generated. In the unusual case that + * the device isn't being dynamically allocated as a legacy "probe the + * hardware" driver, infrastructure code should reverse this marking. */ struct platform_device *platform_device_alloc(const char *name, unsigned int id) { @@ -172,6 +177,12 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id) pa->pdev.id = id; device_initialize(&pa->pdev.dev); pa->pdev.dev.release = platform_device_release; + + /* prevent hotplug "modprobe $(MODALIAS)" from causing trouble in + * legacy probe-the-hardware drivers, which don't properly split + * out device enumeration logic from drivers. + */ + pa->pdev.dev.uevent_suppress = 1; } return pa ? &pa->pdev : NULL; @@ -292,20 +303,22 @@ EXPORT_SYMBOL_GPL(platform_device_add); * @pdev: platform device we're removing * * Note that this function will also release all memory- and port-based - * resources owned by the device (@dev->resource). + * resources owned by the device (@dev->resource). This function + * must _only_ be externally called in error cases. All other usage + * is a bug. */ void platform_device_del(struct platform_device *pdev) { int i; if (pdev) { + device_del(&pdev->dev); + for (i = 0; i < pdev->num_resources; i++) { struct resource *r = &pdev->resource[i]; if (r->flags & (IORESOURCE_MEM|IORESOURCE_IO)) release_resource(r); } - - device_del(&pdev->dev); } } EXPORT_SYMBOL_GPL(platform_device_del); @@ -347,8 +360,15 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); * This function creates a simple platform device that requires minimal * resource and memory management. Canned release function freeing * memory allocated for the device allows drivers using such devices - * to be unloaded iwithout waiting for the last reference to the device + * to be unloaded without waiting for the last reference to the device * to be dropped. + * + * This interface is primarily intended for use with legacy drivers + * which probe hardware directly. Because such drivers create sysfs + * device nodes themselves, rather than letting system infrastructure + * handle such device enumeration tasks, they don't fully conform to + * the Linux driver model. In particular, when such drivers are built + * as modules, they can't be "hotplugged". */ struct platform_device *platform_device_register_simple(char *name, unsigned int id, struct resource *res, unsigned int num) @@ -611,8 +631,15 @@ EXPORT_SYMBOL_GPL(platform_bus_type); int __init platform_bus_init(void) { - device_register(&platform_bus); - return bus_register(&platform_bus_type); + int error; + + error = device_register(&platform_bus); + if (error) + return error; + error = bus_register(&platform_bus_type); + if (error) + device_unregister(&platform_bus); + return error; } #ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK