X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=drivers%2Fbase%2Fplatform.c;h=fb56092414821645342071f5c0da32ef2a486b4b;hb=97a4649d6ffce4a5d7f5ce018d87a6cefcb4ad03;hp=30480f6f2af2beb9b73d41463f5b8c45ceb4b9ae;hpb=f8abea8f8c24ecdad6d6861bffb912f23f2741cd;p=~andy%2Flinux diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 30480f6f2af..fb560924148 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -161,7 +161,7 @@ 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. */ -struct platform_device *platform_device_alloc(const char *name, unsigned int id) +struct platform_device *platform_device_alloc(const char *name, int id) { struct platform_object *pa; @@ -245,7 +245,8 @@ int platform_device_add(struct platform_device *pdev) pdev->dev.bus = &platform_bus_type; if (pdev->id != -1) - snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%u", pdev->name, pdev->id); + snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%d", pdev->name, + pdev->id); else strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); @@ -292,20 +293,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,10 +350,17 @@ 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 platform_device *platform_device_register_simple(char *name, int id, struct resource *res, unsigned int num) { struct platform_device *pdev; @@ -510,7 +520,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; } @@ -520,13 +530,11 @@ static struct device_attribute platform_dev_attrs[] = { __ATTR_NULL, }; -static int platform_uevent(struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size) +static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) { struct platform_device *pdev = to_platform_device(dev); - envp[0] = buffer; - snprintf(buffer, buffer_size, "MODALIAS=%s", pdev->name); + add_uevent_var(env, "MODALIAS=platform:%s", pdev->name); return 0; }