]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/base/platform.c
platform: prefix MODALIAS with "platform:"
[mv-sheeva.git] / drivers / base / platform.c
index f9c903ba9fcd1259e37120e2db74d55c6acdcbce..9bfc434d132734c759fcfabac43cc11b3835f994 100644 (file)
@@ -292,20 +292,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 +349,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)
@@ -510,7 +519,7 @@ static ssize_t
 modalias_show(struct device *dev, struct device_attribute *a, char *buf)
 {
        struct platform_device  *pdev = to_platform_device(dev);
-       int len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->name);
+       int len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name);
 
        return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
@@ -526,7 +535,7 @@ static int platform_uevent(struct device *dev, char **envp, int num_envp,
        struct platform_device  *pdev = to_platform_device(dev);
 
        envp[0] = buffer;
-       snprintf(buffer, buffer_size, "MODALIAS=%s", pdev->name);
+       snprintf(buffer, buffer_size, "MODALIAS=platform:%s", pdev->name);
        return 0;
 }
 
@@ -611,8 +620,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