diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 6bee6af8d8e1..282025770429 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -56,7 +56,14 @@ static inline int device_is_not_partition(struct device *dev) | |||
56 | */ | 56 | */ |
57 | const char *dev_driver_string(const struct device *dev) | 57 | const char *dev_driver_string(const struct device *dev) |
58 | { | 58 | { |
59 | return dev->driver ? dev->driver->name : | 59 | struct device_driver *drv; |
60 | |||
61 | /* dev->driver can change to NULL underneath us because of unbinding, | ||
62 | * so be careful about accessing it. dev->bus and dev->class should | ||
63 | * never change once they are set, so they don't need special care. | ||
64 | */ | ||
65 | drv = ACCESS_ONCE(dev->driver); | ||
66 | return drv ? drv->name : | ||
60 | (dev->bus ? dev->bus->name : | 67 | (dev->bus ? dev->bus->name : |
61 | (dev->class ? dev->class->name : "")); | 68 | (dev->class ? dev->class->name : "")); |
62 | } | 69 | } |
@@ -439,7 +446,8 @@ struct kset *devices_kset; | |||
439 | * @dev: device. | 446 | * @dev: device. |
440 | * @attr: device attribute descriptor. | 447 | * @attr: device attribute descriptor. |
441 | */ | 448 | */ |
442 | int device_create_file(struct device *dev, struct device_attribute *attr) | 449 | int device_create_file(struct device *dev, |
450 | const struct device_attribute *attr) | ||
443 | { | 451 | { |
444 | int error = 0; | 452 | int error = 0; |
445 | if (dev) | 453 | if (dev) |
@@ -452,7 +460,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr) | |||
452 | * @dev: device. | 460 | * @dev: device. |
453 | * @attr: device attribute descriptor. | 461 | * @attr: device attribute descriptor. |
454 | */ | 462 | */ |
455 | void device_remove_file(struct device *dev, struct device_attribute *attr) | 463 | void device_remove_file(struct device *dev, |
464 | const struct device_attribute *attr) | ||
456 | { | 465 | { |
457 | if (dev) | 466 | if (dev) |
458 | sysfs_remove_file(&dev->kobj, &attr->attr); | 467 | sysfs_remove_file(&dev->kobj, &attr->attr); |
@@ -463,7 +472,8 @@ void device_remove_file(struct device *dev, struct device_attribute *attr) | |||
463 | * @dev: device. | 472 | * @dev: device. |
464 | * @attr: device binary attribute descriptor. | 473 | * @attr: device binary attribute descriptor. |
465 | */ | 474 | */ |
466 | int device_create_bin_file(struct device *dev, struct bin_attribute *attr) | 475 | int device_create_bin_file(struct device *dev, |
476 | const struct bin_attribute *attr) | ||
467 | { | 477 | { |
468 | int error = -EINVAL; | 478 | int error = -EINVAL; |
469 | if (dev) | 479 | if (dev) |
@@ -477,7 +487,8 @@ EXPORT_SYMBOL_GPL(device_create_bin_file); | |||
477 | * @dev: device. | 487 | * @dev: device. |
478 | * @attr: device binary attribute descriptor. | 488 | * @attr: device binary attribute descriptor. |
479 | */ | 489 | */ |
480 | void device_remove_bin_file(struct device *dev, struct bin_attribute *attr) | 490 | void device_remove_bin_file(struct device *dev, |
491 | const struct bin_attribute *attr) | ||
481 | { | 492 | { |
482 | if (dev) | 493 | if (dev) |
483 | sysfs_remove_bin_file(&dev->kobj, attr); | 494 | sysfs_remove_bin_file(&dev->kobj, attr); |
@@ -898,8 +909,10 @@ int device_add(struct device *dev) | |||
898 | dev->init_name = NULL; | 909 | dev->init_name = NULL; |
899 | } | 910 | } |
900 | 911 | ||
901 | if (!dev_name(dev)) | 912 | if (!dev_name(dev)) { |
913 | error = -EINVAL; | ||
902 | goto name_error; | 914 | goto name_error; |
915 | } | ||
903 | 916 | ||
904 | pr_debug("device: '%s': %s\n", dev_name(dev), __func__); | 917 | pr_debug("device: '%s': %s\n", dev_name(dev), __func__); |
905 | 918 | ||
@@ -987,6 +1000,8 @@ done: | |||
987 | device_remove_class_symlinks(dev); | 1000 | device_remove_class_symlinks(dev); |
988 | SymlinkError: | 1001 | SymlinkError: |
989 | if (MAJOR(dev->devt)) | 1002 | if (MAJOR(dev->devt)) |
1003 | devtmpfs_delete_node(dev); | ||
1004 | if (MAJOR(dev->devt)) | ||
990 | device_remove_sys_dev_entry(dev); | 1005 | device_remove_sys_dev_entry(dev); |
991 | devtattrError: | 1006 | devtattrError: |
992 | if (MAJOR(dev->devt)) | 1007 | if (MAJOR(dev->devt)) |
@@ -1728,8 +1743,5 @@ void device_shutdown(void) | |||
1728 | dev->driver->shutdown(dev); | 1743 | dev->driver->shutdown(dev); |
1729 | } | 1744 | } |
1730 | } | 1745 | } |
1731 | kobject_put(sysfs_dev_char_kobj); | ||
1732 | kobject_put(sysfs_dev_block_kobj); | ||
1733 | kobject_put(dev_kobj); | ||
1734 | async_synchronize_full(); | 1746 | async_synchronize_full(); |
1735 | } | 1747 | } |