Commit 1e0b2cf9 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

driver core: struct device - replace bus_id with dev_name(), dev_set_name()

Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 210272a2
...@@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev, ...@@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
ic->classdev.parent = get_device(dev); ic->classdev.parent = get_device(dev);
ic->classdev.class = cont->class; ic->classdev.class = cont->class;
cont->class->dev_release = attribute_container_release; cont->class->dev_release = attribute_container_release;
strcpy(ic->classdev.bus_id, dev->bus_id); dev_set_name(&ic->classdev, dev_name(dev));
if (fn) if (fn)
fn(cont, dev, &ic->classdev); fn(cont, dev, &ic->classdev);
else else
......
...@@ -333,7 +333,7 @@ static int match_name(struct device *dev, void *data) ...@@ -333,7 +333,7 @@ static int match_name(struct device *dev, void *data)
{ {
const char *name = data; const char *name = data;
return sysfs_streq(name, dev->bus_id); return sysfs_streq(name, dev_name(dev));
} }
/** /**
...@@ -461,12 +461,12 @@ int bus_add_device(struct device *dev) ...@@ -461,12 +461,12 @@ int bus_add_device(struct device *dev)
int error = 0; int error = 0;
if (bus) { if (bus) {
pr_debug("bus: '%s': add device %s\n", bus->name, dev->bus_id); pr_debug("bus: '%s': add device %s\n", bus->name, dev_name(dev));
error = device_add_attrs(bus, dev); error = device_add_attrs(bus, dev);
if (error) if (error)
goto out_put; goto out_put;
error = sysfs_create_link(&bus->p->devices_kset->kobj, error = sysfs_create_link(&bus->p->devices_kset->kobj,
&dev->kobj, dev->bus_id); &dev->kobj, dev_name(dev));
if (error) if (error)
goto out_id; goto out_id;
error = sysfs_create_link(&dev->kobj, error = sysfs_create_link(&dev->kobj,
...@@ -482,7 +482,7 @@ int bus_add_device(struct device *dev) ...@@ -482,7 +482,7 @@ int bus_add_device(struct device *dev)
out_deprecated: out_deprecated:
sysfs_remove_link(&dev->kobj, "subsystem"); sysfs_remove_link(&dev->kobj, "subsystem");
out_subsys: out_subsys:
sysfs_remove_link(&bus->p->devices_kset->kobj, dev->bus_id); sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev));
out_id: out_id:
device_remove_attrs(bus, dev); device_remove_attrs(bus, dev);
out_put: out_put:
...@@ -526,13 +526,13 @@ void bus_remove_device(struct device *dev) ...@@ -526,13 +526,13 @@ void bus_remove_device(struct device *dev)
sysfs_remove_link(&dev->kobj, "subsystem"); sysfs_remove_link(&dev->kobj, "subsystem");
remove_deprecated_bus_links(dev); remove_deprecated_bus_links(dev);
sysfs_remove_link(&dev->bus->p->devices_kset->kobj, sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
dev->bus_id); dev_name(dev));
device_remove_attrs(dev->bus, dev); device_remove_attrs(dev->bus, dev);
if (klist_node_attached(&dev->knode_bus)) if (klist_node_attached(&dev->knode_bus))
klist_del(&dev->knode_bus); klist_del(&dev->knode_bus);
pr_debug("bus: '%s': remove device %s\n", pr_debug("bus: '%s': remove device %s\n",
dev->bus->name, dev->bus_id); dev->bus->name, dev_name(dev));
device_release_driver(dev); device_release_driver(dev);
bus_put(dev->bus); bus_put(dev->bus);
} }
......
...@@ -119,7 +119,7 @@ static void device_release(struct kobject *kobj) ...@@ -119,7 +119,7 @@ static void device_release(struct kobject *kobj)
else else
WARN(1, KERN_ERR "Device '%s' does not have a release() " WARN(1, KERN_ERR "Device '%s' does not have a release() "
"function, it is broken and must be fixed.\n", "function, it is broken and must be fixed.\n",
dev->bus_id); dev_name(dev));
} }
static struct kobj_type device_ktype = { static struct kobj_type device_ktype = {
...@@ -209,7 +209,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, ...@@ -209,7 +209,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
retval = dev->bus->uevent(dev, env); retval = dev->bus->uevent(dev, env);
if (retval) if (retval)
pr_debug("device: '%s': %s: bus uevent() returned %d\n", pr_debug("device: '%s': %s: bus uevent() returned %d\n",
dev->bus_id, __func__, retval); dev_name(dev), __func__, retval);
} }
/* have the class specific function add its stuff */ /* have the class specific function add its stuff */
...@@ -217,7 +217,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, ...@@ -217,7 +217,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
retval = dev->class->dev_uevent(dev, env); retval = dev->class->dev_uevent(dev, env);
if (retval) if (retval)
pr_debug("device: '%s': %s: class uevent() " pr_debug("device: '%s': %s: class uevent() "
"returned %d\n", dev->bus_id, "returned %d\n", dev_name(dev),
__func__, retval); __func__, retval);
} }
...@@ -226,7 +226,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, ...@@ -226,7 +226,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
retval = dev->type->uevent(dev, env); retval = dev->type->uevent(dev, env);
if (retval) if (retval)
pr_debug("device: '%s': %s: dev_type uevent() " pr_debug("device: '%s': %s: dev_type uevent() "
"returned %d\n", dev->bus_id, "returned %d\n", dev_name(dev),
__func__, retval); __func__, retval);
} }
...@@ -672,7 +672,7 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -672,7 +672,7 @@ static int device_add_class_symlinks(struct device *dev)
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
device_is_not_partition(dev)) { device_is_not_partition(dev)) {
error = sysfs_create_link(&dev->class->p->class_subsys.kobj, error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
&dev->kobj, dev->bus_id); &dev->kobj, dev_name(dev));
if (error) if (error)
goto out_subsys; goto out_subsys;
} }
...@@ -712,11 +712,11 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -712,11 +712,11 @@ static int device_add_class_symlinks(struct device *dev)
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
device_is_not_partition(dev)) device_is_not_partition(dev))
sysfs_remove_link(&dev->class->p->class_subsys.kobj, sysfs_remove_link(&dev->class->p->class_subsys.kobj,
dev->bus_id); dev_name(dev));
#else #else
/* link in the class directory pointing to the device */ /* link in the class directory pointing to the device */
error = sysfs_create_link(&dev->class->p->class_subsys.kobj, error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
&dev->kobj, dev->bus_id); &dev->kobj, dev_name(dev));
if (error) if (error)
goto out_subsys; goto out_subsys;
...@@ -729,7 +729,7 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -729,7 +729,7 @@ static int device_add_class_symlinks(struct device *dev)
return 0; return 0;
out_busid: out_busid:
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev));
#endif #endif
out_subsys: out_subsys:
...@@ -758,12 +758,12 @@ static void device_remove_class_symlinks(struct device *dev) ...@@ -758,12 +758,12 @@ static void device_remove_class_symlinks(struct device *dev)
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
device_is_not_partition(dev)) device_is_not_partition(dev))
sysfs_remove_link(&dev->class->p->class_subsys.kobj, sysfs_remove_link(&dev->class->p->class_subsys.kobj,
dev->bus_id); dev_name(dev));
#else #else
if (dev->parent && device_is_not_partition(dev)) if (dev->parent && device_is_not_partition(dev))
sysfs_remove_link(&dev->kobj, "device"); sysfs_remove_link(&dev->kobj, "device");
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev));
#endif #endif
sysfs_remove_link(&dev->kobj, "subsystem"); sysfs_remove_link(&dev->kobj, "subsystem");
...@@ -866,7 +866,7 @@ int device_add(struct device *dev) ...@@ -866,7 +866,7 @@ int device_add(struct device *dev)
if (!strlen(dev->bus_id)) if (!strlen(dev->bus_id))
goto done; goto done;
pr_debug("device: '%s': %s\n", dev->bus_id, __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
parent = get_device(dev->parent); parent = get_device(dev->parent);
setup_parent(dev, parent); setup_parent(dev, parent);
...@@ -876,7 +876,7 @@ int device_add(struct device *dev) ...@@ -876,7 +876,7 @@ int device_add(struct device *dev)
set_dev_node(dev, dev_to_node(parent)); set_dev_node(dev, dev_to_node(parent));
/* first, register with generic layer. */ /* first, register with generic layer. */
error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev->bus_id); error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev));
if (error) if (error)
goto Error; goto Error;
...@@ -1086,7 +1086,7 @@ void device_del(struct device *dev) ...@@ -1086,7 +1086,7 @@ void device_del(struct device *dev)
*/ */
void device_unregister(struct device *dev) void device_unregister(struct device *dev)
{ {
pr_debug("device: '%s': %s\n", dev->bus_id, __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
device_del(dev); device_del(dev);
put_device(dev); put_device(dev);
} }
...@@ -1199,7 +1199,7 @@ EXPORT_SYMBOL_GPL(device_remove_file); ...@@ -1199,7 +1199,7 @@ EXPORT_SYMBOL_GPL(device_remove_file);
static void device_create_release(struct device *dev) static void device_create_release(struct device *dev)
{ {
pr_debug("device: '%s': %s\n", dev->bus_id, __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
kfree(dev); kfree(dev);
} }
...@@ -1344,7 +1344,7 @@ int device_rename(struct device *dev, char *new_name) ...@@ -1344,7 +1344,7 @@ int device_rename(struct device *dev, char *new_name)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev),
__func__, new_name); __func__, new_name);
#ifdef CONFIG_SYSFS_DEPRECATED #ifdef CONFIG_SYSFS_DEPRECATED
...@@ -1381,7 +1381,7 @@ int device_rename(struct device *dev, char *new_name) ...@@ -1381,7 +1381,7 @@ int device_rename(struct device *dev, char *new_name)
#else #else
if (dev->class) { if (dev->class) {
error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj, error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
&dev->kobj, dev->bus_id); &dev->kobj, dev_name(dev));
if (error) if (error)
goto out; goto out;
sysfs_remove_link(&dev->class->p->class_subsys.kobj, sysfs_remove_link(&dev->class->p->class_subsys.kobj,
...@@ -1459,8 +1459,8 @@ int device_move(struct device *dev, struct device *new_parent) ...@@ -1459,8 +1459,8 @@ int device_move(struct device *dev, struct device *new_parent)
new_parent = get_device(new_parent); new_parent = get_device(new_parent);
new_parent_kobj = get_device_parent(dev, new_parent); new_parent_kobj = get_device_parent(dev, new_parent);
pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev),
__func__, new_parent ? new_parent->bus_id : "<NULL>"); __func__, new_parent ? dev_name(new_parent) : "<NULL>");
error = kobject_move(&dev->kobj, new_parent_kobj); error = kobject_move(&dev->kobj, new_parent_kobj);
if (error) { if (error) {
cleanup_glue_dir(dev, new_parent_kobj); cleanup_glue_dir(dev, new_parent_kobj);
......
...@@ -34,7 +34,7 @@ static void driver_bound(struct device *dev) ...@@ -34,7 +34,7 @@ static void driver_bound(struct device *dev)
return; return;
} }
pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev),
__func__, dev->driver->name); __func__, dev->driver->name);
if (dev->bus) if (dev->bus)
...@@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv) ...@@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv)
atomic_inc(&probe_count); atomic_inc(&probe_count);
pr_debug("bus: '%s': %s: probing driver %s with device %s\n", pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
drv->bus->name, __func__, drv->name, dev->bus_id); drv->bus->name, __func__, drv->name, dev_name(dev));
WARN_ON(!list_empty(&dev->devres_head)); WARN_ON(!list_empty(&dev->devres_head));
dev->driver = drv; dev->driver = drv;
if (driver_sysfs_add(dev)) { if (driver_sysfs_add(dev)) {
printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
__func__, dev->bus_id); __func__, dev_name(dev));
goto probe_failed; goto probe_failed;
} }
...@@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) ...@@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
driver_bound(dev); driver_bound(dev);
ret = 1; ret = 1;
pr_debug("bus: '%s': %s: bound device %s to driver %s\n", pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
drv->bus->name, __func__, dev->bus_id, drv->name); drv->bus->name, __func__, dev_name(dev), drv->name);
goto done; goto done;
probe_failed: probe_failed:
...@@ -139,7 +139,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) ...@@ -139,7 +139,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
/* driver matched but the probe failed */ /* driver matched but the probe failed */
printk(KERN_WARNING printk(KERN_WARNING
"%s: probe of %s failed with error %d\n", "%s: probe of %s failed with error %d\n",
drv->name, dev->bus_id, ret); drv->name, dev_name(dev), ret);
} }
/* /*
* Ignore errors returned by ->probe so that the next driver can try * Ignore errors returned by ->probe so that the next driver can try
...@@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) ...@@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
goto done; goto done;
pr_debug("bus: '%s': %s: matched device %s with driver %s\n", pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
drv->bus->name, __func__, dev->bus_id, drv->name); drv->bus->name, __func__, dev_name(dev), drv->name);
ret = really_probe(dev, drv); ret = really_probe(dev, drv);
......
...@@ -291,12 +291,6 @@ firmware_class_timeout(u_long data) ...@@ -291,12 +291,6 @@ firmware_class_timeout(u_long data)
fw_load_abort(fw_priv); fw_load_abort(fw_priv);
} }
static inline void fw_setup_device_id(struct device *f_dev, struct device *dev)
{
/* XXX warning we should watch out for name collisions */
strlcpy(f_dev->bus_id, dev->bus_id, BUS_ID_SIZE);
}
static int fw_register_device(struct device **dev_p, const char *fw_name, static int fw_register_device(struct device **dev_p, const char *fw_name,
struct device *device) struct device *device)
{ {
...@@ -321,7 +315,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, ...@@ -321,7 +315,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
fw_priv->timeout.data = (u_long) fw_priv; fw_priv->timeout.data = (u_long) fw_priv;
init_timer(&fw_priv->timeout); init_timer(&fw_priv->timeout);
fw_setup_device_id(f_dev, device); dev_set_name(f_dev, dev_name(device));
f_dev->parent = device; f_dev->parent = device;
f_dev->class = &firmware_class; f_dev->class = &firmware_class;
dev_set_drvdata(f_dev, fw_priv); dev_set_drvdata(f_dev, fw_priv);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/isa.h> #include <linux/isa.h>
static struct device isa_bus = { static struct device isa_bus = {
.bus_id = "isa" .init_name = "isa"
}; };
struct isa_dev { struct isa_dev {
...@@ -135,9 +135,8 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev) ...@@ -135,9 +135,8 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev)
isa_dev->dev.parent = &isa_bus; isa_dev->dev.parent = &isa_bus;
isa_dev->dev.bus = &isa_bus_type; isa_dev->dev.bus = &isa_bus_type;
snprintf(isa_dev->dev.bus_id, BUS_ID_SIZE, "%s.%u", dev_set_name(&isa_dev->dev, "%s.%u",
isa_driver->driver.name, id); isa_driver->driver.name, id);
isa_dev->dev.platform_data = isa_driver; isa_dev->dev.platform_data = isa_driver;
isa_dev->dev.release = isa_dev_release; isa_dev->dev.release = isa_dev_release;
isa_dev->id = id; isa_dev->id = id;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
driver)) driver))
struct device platform_bus = { struct device platform_bus = {
.bus_id = "platform", .init_name = "platform",
}; };
EXPORT_SYMBOL_GPL(platform_bus); EXPORT_SYMBOL_GPL(platform_bus);
...@@ -242,16 +242,15 @@ int platform_device_add(struct platform_device *pdev) ...@@ -242,16 +242,15 @@ int platform_device_add(struct platform_device *pdev)
pdev->dev.bus = &platform_bus_type; pdev->dev.bus = &platform_bus_type;
if (pdev->id != -1) if (pdev->id != -1)
snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%d", pdev->name, dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);
pdev->id);
else else
strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); dev_set_name(&pdev->dev, pdev->name);
for (i = 0; i < pdev->num_resources; i++) { for (i = 0; i < pdev->num_resources; i++) {
struct resource *p, *r = &pdev->resource[i]; struct resource *p, *r = &pdev->resource[i];
if (r->name == NULL) if (r->name == NULL)
r->name = pdev->dev.bus_id; r->name = dev_name(&pdev->dev);
p = r->parent; p = r->parent;
if (!p) { if (!p) {
...@@ -264,14 +263,14 @@ int platform_device_add(struct platform_device *pdev) ...@@ -264,14 +263,14 @@ int platform_device_add(struct platform_device *pdev)
if (p && insert_resource(p, r)) { if (p && insert_resource(p, r)) {
printk(KERN_ERR printk(KERN_ERR
"%s: failed to claim resource %d\n", "%s: failed to claim resource %d\n",
pdev->dev.bus_id, i); dev_name(&pdev->dev), i);
ret = -EBUSY; ret = -EBUSY;
goto failed; goto failed;
} }
} }
pr_debug("Registering platform device '%s'. Parent at %s\n", pr_debug("Registering platform device '%s'. Parent at %s\n",
pdev->dev.bus_id, pdev->dev.parent->bus_id); dev_name(&pdev->dev), dev_name(pdev->dev.parent));
ret = device_add(&pdev->dev); ret = device_add(&pdev->dev);
if (ret == 0) if (ret == 0)
...@@ -607,7 +606,7 @@ static int platform_match(struct device *dev, struct device_driver *drv) ...@@ -607,7 +606,7 @@ static int platform_match(struct device *dev, struct device_driver *drv)
struct platform_device *pdev; struct platform_device *pdev;
pdev = container_of(dev, struct platform_device, dev); pdev = container_of(dev, struct platform_device, dev);
return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); return (strcmp(pdev->name, drv->name) == 0);
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
......
...@@ -76,7 +76,7 @@ void device_pm_add(struct device *dev) ...@@ -76,7 +76,7 @@ void device_pm_add(struct device *dev)
if (dev->parent) { if (dev->parent) {
if (dev->parent->power.status >= DPM_SUSPENDING) if (dev->parent->power.status >= DPM_SUSPENDING)
dev_warn(dev, "parent %s should not be sleeping\n", dev_warn(dev, "parent %s should not be sleeping\n",
dev->parent->bus_id); dev_name(dev->parent));
} else if (transition_started) { } else if (transition_started) {
/* /*
* We refuse to register parentless devices while a PM * We refuse to register parentless devices while a PM
......
...@@ -140,7 +140,7 @@ static unsigned int hash_string(unsigned int seed, const char *data, unsigned in ...@@ -140,7 +140,7 @@ static unsigned int hash_string(unsigned int seed, const char *data, unsigned in
void set_trace_device(struct device *dev) void set_trace_device(struct device *dev)
{ {
dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH); dev_hash_value = hash_string(DEVSEED, dev_name(dev), DEVHASH);
} }
EXPORT_SYMBOL(set_trace_device); EXPORT_SYMBOL(set_trace_device);
...@@ -192,7 +192,7 @@ static int show_dev_hash(unsigned int value) ...@@ -192,7 +192,7 @@ static int show_dev_hash(unsigned int value)
while (entry != &dpm_list) { while (entry != &dpm_list) {
struct device * dev = to_device(entry); struct device * dev = to_device(entry);
unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH);
if (hash == value) { if (hash == value) {
dev_info(dev, "hash matches\n"); dev_info(dev, "hash matches\n");
match++; match++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment