diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 068aa1c9538c..d021c98605b3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -53,7 +53,7 @@ static inline int device_is_not_partition(struct device *dev) | |||
53 | * it is attached to. If it is not attached to a bus either, an empty | 53 | * it is attached to. If it is not attached to a bus either, an empty |
54 | * string will be returned. | 54 | * string will be returned. |
55 | */ | 55 | */ |
56 | const char *dev_driver_string(struct device *dev) | 56 | const char *dev_driver_string(const struct device *dev) |
57 | { | 57 | { |
58 | return dev->driver ? dev->driver->name : | 58 | return dev->driver ? dev->driver->name : |
59 | (dev->bus ? dev->bus->name : | 59 | (dev->bus ? dev->bus->name : |
@@ -541,6 +541,7 @@ void device_initialize(struct device *dev) | |||
541 | spin_lock_init(&dev->devres_lock); | 541 | spin_lock_init(&dev->devres_lock); |
542 | INIT_LIST_HEAD(&dev->devres_head); | 542 | INIT_LIST_HEAD(&dev->devres_head); |
543 | device_init_wakeup(dev, 0); | 543 | device_init_wakeup(dev, 0); |
544 | device_pm_init(dev); | ||
544 | set_dev_node(dev, -1); | 545 | set_dev_node(dev, -1); |
545 | } | 546 | } |
546 | 547 | ||
@@ -843,13 +844,19 @@ int device_add(struct device *dev) | |||
843 | { | 844 | { |
844 | struct device *parent = NULL; | 845 | struct device *parent = NULL; |
845 | struct class_interface *class_intf; | 846 | struct class_interface *class_intf; |
846 | int error; | 847 | int error = -EINVAL; |
847 | 848 | ||
848 | dev = get_device(dev); | 849 | dev = get_device(dev); |
849 | if (!dev || !strlen(dev->bus_id)) { | 850 | if (!dev) |
850 | error = -EINVAL; | 851 | goto done; |
851 | goto Done; | 852 | |
852 | } | 853 | /* Temporarily support init_name if it is set. |
854 | * It will override bus_id for now */ | ||
855 | if (dev->init_name) | ||
856 | dev_set_name(dev, "%s", dev->init_name); | ||
857 | |||
858 | if (!strlen(dev->bus_id)) | ||
859 | goto done; | ||
853 | 860 | ||
854 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); | 861 | pr_debug("device: '%s': %s\n", dev->bus_id, __func__); |
855 | 862 | ||
@@ -897,9 +904,10 @@ int device_add(struct device *dev) | |||
897 | error = bus_add_device(dev); | 904 | error = bus_add_device(dev); |
898 | if (error) | 905 | if (error) |
899 | goto BusError; | 906 | goto BusError; |
900 | error = device_pm_add(dev); | 907 | error = dpm_sysfs_add(dev); |
901 | if (error) | 908 | if (error) |
902 | goto PMError; | 909 | goto DPMError; |
910 | device_pm_add(dev); | ||
903 | kobject_uevent(&dev->kobj, KOBJ_ADD); | 911 | kobject_uevent(&dev->kobj, KOBJ_ADD); |
904 | bus_attach_device(dev); | 912 | bus_attach_device(dev); |
905 | if (parent) | 913 | if (parent) |
@@ -917,10 +925,10 @@ int device_add(struct device *dev) | |||
917 | class_intf->add_dev(dev, class_intf); | 925 | class_intf->add_dev(dev, class_intf); |
918 | mutex_unlock(&dev->class->p->class_mutex); | 926 | mutex_unlock(&dev->class->p->class_mutex); |
919 | } | 927 | } |
920 | Done: | 928 | done: |
921 | put_device(dev); | 929 | put_device(dev); |
922 | return error; | 930 | return error; |
923 | PMError: | 931 | DPMError: |
924 | bus_remove_device(dev); | 932 | bus_remove_device(dev); |
925 | BusError: | 933 | BusError: |
926 | if (dev->bus) | 934 | if (dev->bus) |
@@ -944,7 +952,7 @@ int device_add(struct device *dev) | |||
944 | cleanup_device_parent(dev); | 952 | cleanup_device_parent(dev); |
945 | if (parent) | 953 | if (parent) |
946 | put_device(parent); | 954 | put_device(parent); |
947 | goto Done; | 955 | goto done; |
948 | } | 956 | } |
949 | 957 | ||
950 | /** | 958 | /** |
@@ -1007,6 +1015,7 @@ void device_del(struct device *dev) | |||
1007 | struct class_interface *class_intf; | 1015 | struct class_interface *class_intf; |
1008 | 1016 | ||
1009 | device_pm_remove(dev); | 1017 | device_pm_remove(dev); |
1018 | dpm_sysfs_remove(dev); | ||
1010 | if (parent) | 1019 | if (parent) |
1011 | klist_del(&dev->knode_parent); | 1020 | klist_del(&dev->knode_parent); |
1012 | if (MAJOR(dev->devt)) { | 1021 | if (MAJOR(dev->devt)) { |