aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/bus.c22
-rw-r--r--drivers/base/class.c45
-rw-r--r--drivers/base/core.c52
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/node.c2
5 files changed, 64 insertions, 59 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 472810f8e6e7..253868e03c70 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -324,27 +324,25 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
return error;
}
-static int device_add_attrs(struct bus_type * bus, struct device * dev)
+static int device_add_attrs(struct bus_type *bus, struct device *dev)
{
int error = 0;
int i;
- if (bus->dev_attrs) {
- for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
- error = device_create_file(dev,&bus->dev_attrs[i]);
- if (error)
- goto Err;
+ if (!bus->dev_attrs)
+ return 0;
+
+ for (i = 0; attr_name(bus->dev_attrs[i]); i++) {
+ error = device_create_file(dev,&bus->dev_attrs[i]);
+ if (error) {
+ while (--i >= 0)
+ device_remove_file(dev, &bus->dev_attrs[i]);
+ break;
}
}
- Done:
return error;
- Err:
- while (--i >= 0)
- device_remove_file(dev,&bus->dev_attrs[i]);
- goto Done;
}
-
static void device_remove_attrs(struct bus_type * bus, struct device * dev)
{
int i;
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 96def1ddba19..d5968128be2b 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -163,8 +163,7 @@ int class_register(struct class * cls)
void class_unregister(struct class * cls)
{
pr_debug("device class '%s': unregistering\n", cls->name);
- if (cls->virtual_dir)
- kobject_unregister(cls->virtual_dir);
+ kobject_unregister(cls->virtual_dir);
remove_class_attrs(cls);
subsystem_unregister(&cls->subsys);
}
@@ -841,48 +840,6 @@ void class_device_destroy(struct class *cls, dev_t devt)
class_device_unregister(class_dev);
}
-int class_device_rename(struct class_device *class_dev, char *new_name)
-{
- int error = 0;
- char *old_class_name = NULL, *new_class_name = NULL;
-
- class_dev = class_device_get(class_dev);
- if (!class_dev)
- return -EINVAL;
-
- pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id,
- new_name);
-
-#ifdef CONFIG_SYSFS_DEPRECATED
- if (class_dev->dev)
- old_class_name = make_class_name(class_dev->class->name,
- &class_dev->kobj);
-#endif
-
- strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN);
-
- error = kobject_rename(&class_dev->kobj, new_name);
-
-#ifdef CONFIG_SYSFS_DEPRECATED
- if (class_dev->dev) {
- new_class_name = make_class_name(class_dev->class->name,
- &class_dev->kobj);
- if (new_class_name)
- sysfs_create_link(&class_dev->dev->kobj,
- &class_dev->kobj, new_class_name);
- if (old_class_name)
- sysfs_remove_link(&class_dev->dev->kobj,
- old_class_name);
- }
-#endif
- class_device_put(class_dev);
-
- kfree(old_class_name);
- kfree(new_class_name);
-
- return error;
-}
-
struct class_device * class_device_get(struct class_device *class_dev)
{
if (class_dev)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a8ac34ba6107..89ebe3682726 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -28,6 +28,20 @@ int (*platform_notify)(struct device * dev) = NULL;
int (*platform_notify_remove)(struct device * dev) = NULL;
/*
+ * Detect the LANANA-assigned LOCAL/EXPERIMENTAL majors
+ */
+bool is_lanana_major(unsigned int major)
+{
+ if (major >= 60 && major <= 63)
+ return 1;
+ if (major >= 120 && major <= 127)
+ return 1;
+ if (major >= 240 && major <= 254)
+ return 1;
+ return 0;
+}
+
+/*
* sysfs bindings for devices.
*/
@@ -623,12 +637,41 @@ int device_add(struct device *dev)
BUS_NOTIFY_DEL_DEVICE, dev);
device_remove_groups(dev);
GroupError:
- device_remove_attrs(dev);
+ device_remove_attrs(dev);
AttrsError:
if (dev->devt_attr) {
device_remove_file(dev, dev->devt_attr);
kfree(dev->devt_attr);
}
+
+ if (dev->class) {
+ sysfs_remove_link(&dev->kobj, "subsystem");
+ /* If this is not a "fake" compatible device, remove the
+ * symlink from the class to the device. */
+ if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
+ sysfs_remove_link(&dev->class->subsys.kset.kobj,
+ dev->bus_id);
+#ifdef CONFIG_SYSFS_DEPRECATED
+ if (parent) {
+ char *class_name = make_class_name(dev->class->name,
+ &dev->kobj);
+ if (class_name)
+ sysfs_remove_link(&dev->parent->kobj,
+ class_name);
+ kfree(class_name);
+ sysfs_remove_link(&dev->kobj, "device");
+ }
+#endif
+
+ down(&dev->class->sem);
+ /* notify any interfaces that the device is now gone */
+ list_for_each_entry(class_intf, &dev->class->interfaces, node)
+ if (class_intf->remove_dev)
+ class_intf->remove_dev(dev, class_intf);
+ /* remove the device from the class list */
+ list_del_init(&dev->node);
+ up(&dev->class->sem);
+ }
ueventattrError:
device_remove_file(dev, &dev->uevent_attr);
attrError:
@@ -744,6 +787,13 @@ void device_del(struct device * dev)
device_remove_attrs(dev);
bus_remove_device(dev);
+ /*
+ * Some platform devices are driven without driver attached
+ * and managed resources may have been acquired. Make sure
+ * all resources are released.
+ */
+ devres_release_all(dev);
+
/* Notify the platform of the removal, in case they
* need to do anything...
*/
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 7fd095efaebd..fe7ef3394144 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -103,7 +103,7 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
#endif
/*
- * register_cpu - Setup a driverfs device for a CPU.
+ * register_cpu - Setup a sysfs device for a CPU.
* @cpu - cpu->hotpluggable field set to 1 will generate a control file in
* sysfs for this CPU.
* @num - CPU number to use when creating the device.
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 475e33f76e0d..cae346ef1b20 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -133,7 +133,7 @@ static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
/*
- * register_node - Setup a driverfs device for a node.
+ * register_node - Setup a sysfs device for a node.
* @num - Node number to use when creating the device.
*
* Initialize and register the node device.