Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Kay Sievers and committed by
Greg Kroah-Hartman
1e0b2cf9 210272a2

+45 -53
+1 -1
drivers/base/attribute_container.c
··· 167 167 ic->classdev.parent = get_device(dev); 168 168 ic->classdev.class = cont->class; 169 169 cont->class->dev_release = attribute_container_release; 170 - strcpy(ic->classdev.bus_id, dev->bus_id); 170 + dev_set_name(&ic->classdev, dev_name(dev)); 171 171 if (fn) 172 172 fn(cont, dev, &ic->classdev); 173 173 else
+6 -6
drivers/base/bus.c
··· 333 333 { 334 334 const char *name = data; 335 335 336 - return sysfs_streq(name, dev->bus_id); 336 + return sysfs_streq(name, dev_name(dev)); 337 337 } 338 338 339 339 /** ··· 461 461 int error = 0; 462 462 463 463 if (bus) { 464 - pr_debug("bus: '%s': add device %s\n", bus->name, dev->bus_id); 464 + pr_debug("bus: '%s': add device %s\n", bus->name, dev_name(dev)); 465 465 error = device_add_attrs(bus, dev); 466 466 if (error) 467 467 goto out_put; 468 468 error = sysfs_create_link(&bus->p->devices_kset->kobj, 469 - &dev->kobj, dev->bus_id); 469 + &dev->kobj, dev_name(dev)); 470 470 if (error) 471 471 goto out_id; 472 472 error = sysfs_create_link(&dev->kobj, ··· 482 482 out_deprecated: 483 483 sysfs_remove_link(&dev->kobj, "subsystem"); 484 484 out_subsys: 485 - sysfs_remove_link(&bus->p->devices_kset->kobj, dev->bus_id); 485 + sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev)); 486 486 out_id: 487 487 device_remove_attrs(bus, dev); 488 488 out_put: ··· 526 526 sysfs_remove_link(&dev->kobj, "subsystem"); 527 527 remove_deprecated_bus_links(dev); 528 528 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 529 - dev->bus_id); 529 + dev_name(dev)); 530 530 device_remove_attrs(dev->bus, dev); 531 531 if (klist_node_attached(&dev->knode_bus)) 532 532 klist_del(&dev->knode_bus); 533 533 534 534 pr_debug("bus: '%s': remove device %s\n", 535 - dev->bus->name, dev->bus_id); 535 + dev->bus->name, dev_name(dev)); 536 536 device_release_driver(dev); 537 537 bus_put(dev->bus); 538 538 }
+18 -18
drivers/base/core.c
··· 119 119 else 120 120 WARN(1, KERN_ERR "Device '%s' does not have a release() " 121 121 "function, it is broken and must be fixed.\n", 122 - dev->bus_id); 122 + dev_name(dev)); 123 123 } 124 124 125 125 static struct kobj_type device_ktype = { ··· 209 209 retval = dev->bus->uevent(dev, env); 210 210 if (retval) 211 211 pr_debug("device: '%s': %s: bus uevent() returned %d\n", 212 - dev->bus_id, __func__, retval); 212 + dev_name(dev), __func__, retval); 213 213 } 214 214 215 215 /* have the class specific function add its stuff */ ··· 217 217 retval = dev->class->dev_uevent(dev, env); 218 218 if (retval) 219 219 pr_debug("device: '%s': %s: class uevent() " 220 - "returned %d\n", dev->bus_id, 220 + "returned %d\n", dev_name(dev), 221 221 __func__, retval); 222 222 } 223 223 ··· 226 226 retval = dev->type->uevent(dev, env); 227 227 if (retval) 228 228 pr_debug("device: '%s': %s: dev_type uevent() " 229 - "returned %d\n", dev->bus_id, 229 + "returned %d\n", dev_name(dev), 230 230 __func__, retval); 231 231 } 232 232 ··· 672 672 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 673 673 device_is_not_partition(dev)) { 674 674 error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 675 - &dev->kobj, dev->bus_id); 675 + &dev->kobj, dev_name(dev)); 676 676 if (error) 677 677 goto out_subsys; 678 678 } ··· 712 712 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 713 713 device_is_not_partition(dev)) 714 714 sysfs_remove_link(&dev->class->p->class_subsys.kobj, 715 - dev->bus_id); 715 + dev_name(dev)); 716 716 #else 717 717 /* link in the class directory pointing to the device */ 718 718 error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 719 - &dev->kobj, dev->bus_id); 719 + &dev->kobj, dev_name(dev)); 720 720 if (error) 721 721 goto out_subsys; 722 722 ··· 729 729 return 0; 730 730 731 731 out_busid: 732 - sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); 732 + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); 733 733 #endif 734 734 735 735 out_subsys: ··· 758 758 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 759 759 device_is_not_partition(dev)) 760 760 sysfs_remove_link(&dev->class->p->class_subsys.kobj, 761 - dev->bus_id); 761 + dev_name(dev)); 762 762 #else 763 763 if (dev->parent && device_is_not_partition(dev)) 764 764 sysfs_remove_link(&dev->kobj, "device"); 765 765 766 - sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id); 766 + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); 767 767 #endif 768 768 769 769 sysfs_remove_link(&dev->kobj, "subsystem"); ··· 866 866 if (!strlen(dev->bus_id)) 867 867 goto done; 868 868 869 - pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 869 + pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 870 870 871 871 parent = get_device(dev->parent); 872 872 setup_parent(dev, parent); ··· 876 876 set_dev_node(dev, dev_to_node(parent)); 877 877 878 878 /* first, register with generic layer. */ 879 - error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev->bus_id); 879 + error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev)); 880 880 if (error) 881 881 goto Error; 882 882 ··· 1086 1086 */ 1087 1087 void device_unregister(struct device *dev) 1088 1088 { 1089 - pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 1089 + pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 1090 1090 device_del(dev); 1091 1091 put_device(dev); 1092 1092 } ··· 1199 1199 1200 1200 static void device_create_release(struct device *dev) 1201 1201 { 1202 - pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 1202 + pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 1203 1203 kfree(dev); 1204 1204 } 1205 1205 ··· 1344 1344 if (!dev) 1345 1345 return -EINVAL; 1346 1346 1347 - pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, 1347 + pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev), 1348 1348 __func__, new_name); 1349 1349 1350 1350 #ifdef CONFIG_SYSFS_DEPRECATED ··· 1381 1381 #else 1382 1382 if (dev->class) { 1383 1383 error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj, 1384 - &dev->kobj, dev->bus_id); 1384 + &dev->kobj, dev_name(dev)); 1385 1385 if (error) 1386 1386 goto out; 1387 1387 sysfs_remove_link(&dev->class->p->class_subsys.kobj, ··· 1459 1459 new_parent = get_device(new_parent); 1460 1460 new_parent_kobj = get_device_parent(dev, new_parent); 1461 1461 1462 - pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, 1463 - __func__, new_parent ? new_parent->bus_id : "<NULL>"); 1462 + pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev), 1463 + __func__, new_parent ? dev_name(new_parent) : "<NULL>"); 1464 1464 error = kobject_move(&dev->kobj, new_parent_kobj); 1465 1465 if (error) { 1466 1466 cleanup_glue_dir(dev, new_parent_kobj);
+6 -6
drivers/base/dd.c
··· 34 34 return; 35 35 } 36 36 37 - pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, 37 + pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev), 38 38 __func__, dev->driver->name); 39 39 40 40 if (dev->bus) ··· 104 104 105 105 atomic_inc(&probe_count); 106 106 pr_debug("bus: '%s': %s: probing driver %s with device %s\n", 107 - drv->bus->name, __func__, drv->name, dev->bus_id); 107 + drv->bus->name, __func__, drv->name, dev_name(dev)); 108 108 WARN_ON(!list_empty(&dev->devres_head)); 109 109 110 110 dev->driver = drv; 111 111 if (driver_sysfs_add(dev)) { 112 112 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", 113 - __func__, dev->bus_id); 113 + __func__, dev_name(dev)); 114 114 goto probe_failed; 115 115 } 116 116 ··· 127 127 driver_bound(dev); 128 128 ret = 1; 129 129 pr_debug("bus: '%s': %s: bound device %s to driver %s\n", 130 - drv->bus->name, __func__, dev->bus_id, drv->name); 130 + drv->bus->name, __func__, dev_name(dev), drv->name); 131 131 goto done; 132 132 133 133 probe_failed: ··· 139 139 /* driver matched but the probe failed */ 140 140 printk(KERN_WARNING 141 141 "%s: probe of %s failed with error %d\n", 142 - drv->name, dev->bus_id, ret); 142 + drv->name, dev_name(dev), ret); 143 143 } 144 144 /* 145 145 * Ignore errors returned by ->probe so that the next driver can try ··· 194 194 goto done; 195 195 196 196 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 197 - drv->bus->name, __func__, dev->bus_id, drv->name); 197 + drv->bus->name, __func__, dev_name(dev), drv->name); 198 198 199 199 ret = really_probe(dev, drv); 200 200
+1 -7
drivers/base/firmware_class.c
··· 291 291 fw_load_abort(fw_priv); 292 292 } 293 293 294 - static inline void fw_setup_device_id(struct device *f_dev, struct device *dev) 295 - { 296 - /* XXX warning we should watch out for name collisions */ 297 - strlcpy(f_dev->bus_id, dev->bus_id, BUS_ID_SIZE); 298 - } 299 - 300 294 static int fw_register_device(struct device **dev_p, const char *fw_name, 301 295 struct device *device) 302 296 { ··· 315 321 fw_priv->timeout.data = (u_long) fw_priv; 316 322 init_timer(&fw_priv->timeout); 317 323 318 - fw_setup_device_id(f_dev, device); 324 + dev_set_name(f_dev, dev_name(device)); 319 325 f_dev->parent = device; 320 326 f_dev->class = &firmware_class; 321 327 dev_set_drvdata(f_dev, fw_priv);
+3 -4
drivers/base/isa.c
··· 11 11 #include <linux/isa.h> 12 12 13 13 static struct device isa_bus = { 14 - .bus_id = "isa" 14 + .init_name = "isa" 15 15 }; 16 16 17 17 struct isa_dev { ··· 135 135 isa_dev->dev.parent = &isa_bus; 136 136 isa_dev->dev.bus = &isa_bus_type; 137 137 138 - snprintf(isa_dev->dev.bus_id, BUS_ID_SIZE, "%s.%u", 139 - isa_driver->driver.name, id); 140 - 138 + dev_set_name(&isa_dev->dev, "%s.%u", 139 + isa_driver->driver.name, id); 141 140 isa_dev->dev.platform_data = isa_driver; 142 141 isa_dev->dev.release = isa_dev_release; 143 142 isa_dev->id = id;
+7 -8
drivers/base/platform.c
··· 24 24 driver)) 25 25 26 26 struct device platform_bus = { 27 - .bus_id = "platform", 27 + .init_name = "platform", 28 28 }; 29 29 EXPORT_SYMBOL_GPL(platform_bus); 30 30 ··· 242 242 pdev->dev.bus = &platform_bus_type; 243 243 244 244 if (pdev->id != -1) 245 - snprintf(pdev->dev.bus_id, BUS_ID_SIZE, "%s.%d", pdev->name, 246 - pdev->id); 245 + dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); 247 246 else 248 - strlcpy(pdev->dev.bus_id, pdev->name, BUS_ID_SIZE); 247 + dev_set_name(&pdev->dev, pdev->name); 249 248 250 249 for (i = 0; i < pdev->num_resources; i++) { 251 250 struct resource *p, *r = &pdev->resource[i]; 252 251 253 252 if (r->name == NULL) 254 - r->name = pdev->dev.bus_id; 253 + r->name = dev_name(&pdev->dev); 255 254 256 255 p = r->parent; 257 256 if (!p) { ··· 263 264 if (p && insert_resource(p, r)) { 264 265 printk(KERN_ERR 265 266 "%s: failed to claim resource %d\n", 266 - pdev->dev.bus_id, i); 267 + dev_name(&pdev->dev), i); 267 268 ret = -EBUSY; 268 269 goto failed; 269 270 } 270 271 } 271 272 272 273 pr_debug("Registering platform device '%s'. Parent at %s\n", 273 - pdev->dev.bus_id, pdev->dev.parent->bus_id); 274 + dev_name(&pdev->dev), dev_name(pdev->dev.parent)); 274 275 275 276 ret = device_add(&pdev->dev); 276 277 if (ret == 0) ··· 606 607 struct platform_device *pdev; 607 608 608 609 pdev = container_of(dev, struct platform_device, dev); 609 - return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); 610 + return (strcmp(pdev->name, drv->name) == 0); 610 611 } 611 612 612 613 #ifdef CONFIG_PM_SLEEP
+1 -1
drivers/base/power/main.c
··· 76 76 if (dev->parent) { 77 77 if (dev->parent->power.status >= DPM_SUSPENDING) 78 78 dev_warn(dev, "parent %s should not be sleeping\n", 79 - dev->parent->bus_id); 79 + dev_name(dev->parent)); 80 80 } else if (transition_started) { 81 81 /* 82 82 * We refuse to register parentless devices while a PM
+2 -2
drivers/base/power/trace.c
··· 140 140 141 141 void set_trace_device(struct device *dev) 142 142 { 143 - dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH); 143 + dev_hash_value = hash_string(DEVSEED, dev_name(dev), DEVHASH); 144 144 } 145 145 EXPORT_SYMBOL(set_trace_device); 146 146 ··· 192 192 193 193 while (entry != &dpm_list) { 194 194 struct device * dev = to_device(entry); 195 - unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH); 195 + unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH); 196 196 if (hash == value) { 197 197 dev_info(dev, "hash matches\n"); 198 198 match++;