diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/Makefile | 4 | ||||
-rw-r--r-- | drivers/base/base.h | 12 | ||||
-rw-r--r-- | drivers/base/bus.c | 293 | ||||
-rw-r--r-- | drivers/base/class.c | 14 | ||||
-rw-r--r-- | drivers/base/core.c | 85 | ||||
-rw-r--r-- | drivers/base/cpu.c | 153 | ||||
-rw-r--r-- | drivers/base/devtmpfs.c | 3 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 14 | ||||
-rw-r--r-- | drivers/base/init.c | 1 | ||||
-rw-r--r-- | drivers/base/memory.c | 160 | ||||
-rw-r--r-- | drivers/base/node.c | 154 | ||||
-rw-r--r-- | drivers/base/platform.c | 2 | ||||
-rw-r--r-- | drivers/base/sys.c | 10 | ||||
-rw-r--r-- | drivers/base/topology.c | 51 |
14 files changed, 623 insertions, 333 deletions
diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 99a375ad2cc9..1334d893b560 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile | |||
@@ -3,7 +3,8 @@ | |||
3 | obj-y := core.o sys.o bus.o dd.o syscore.o \ | 3 | obj-y := core.o sys.o bus.o dd.o syscore.o \ |
4 | driver.o class.o platform.o \ | 4 | driver.o class.o platform.o \ |
5 | cpu.o firmware.o init.o map.o devres.o \ | 5 | cpu.o firmware.o init.o map.o devres.o \ |
6 | attribute_container.o transport_class.o | 6 | attribute_container.o transport_class.o \ |
7 | topology.o | ||
7 | obj-$(CONFIG_DEVTMPFS) += devtmpfs.o | 8 | obj-$(CONFIG_DEVTMPFS) += devtmpfs.o |
8 | obj-y += power/ | 9 | obj-y += power/ |
9 | obj-$(CONFIG_HAS_DMA) += dma-mapping.o | 10 | obj-$(CONFIG_HAS_DMA) += dma-mapping.o |
@@ -12,7 +13,6 @@ obj-$(CONFIG_ISA) += isa.o | |||
12 | obj-$(CONFIG_FW_LOADER) += firmware_class.o | 13 | obj-$(CONFIG_FW_LOADER) += firmware_class.o |
13 | obj-$(CONFIG_NUMA) += node.o | 14 | obj-$(CONFIG_NUMA) += node.o |
14 | obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o | 15 | obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o |
15 | obj-$(CONFIG_SMP) += topology.o | ||
16 | ifeq ($(CONFIG_SYSFS),y) | 16 | ifeq ($(CONFIG_SYSFS),y) |
17 | obj-$(CONFIG_MODULES) += module.o | 17 | obj-$(CONFIG_MODULES) += module.o |
18 | endif | 18 | endif |
diff --git a/drivers/base/base.h b/drivers/base/base.h index 21c1b96c34c6..7a6ae4228761 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -4,7 +4,9 @@ | |||
4 | * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. | 4 | * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. |
5 | * | 5 | * |
6 | * @subsys - the struct kset that defines this subsystem | 6 | * @subsys - the struct kset that defines this subsystem |
7 | * @devices_kset - the list of devices associated | 7 | * @devices_kset - the subsystem's 'devices' directory |
8 | * @interfaces - list of subsystem interfaces associated | ||
9 | * @mutex - protect the devices, and interfaces lists. | ||
8 | * | 10 | * |
9 | * @drivers_kset - the list of drivers associated | 11 | * @drivers_kset - the list of drivers associated |
10 | * @klist_devices - the klist to iterate over the @devices_kset | 12 | * @klist_devices - the klist to iterate over the @devices_kset |
@@ -14,10 +16,8 @@ | |||
14 | * @bus - pointer back to the struct bus_type that this structure is associated | 16 | * @bus - pointer back to the struct bus_type that this structure is associated |
15 | * with. | 17 | * with. |
16 | * | 18 | * |
17 | * @class_interfaces - list of class_interfaces associated | ||
18 | * @glue_dirs - "glue" directory to put in-between the parent device to | 19 | * @glue_dirs - "glue" directory to put in-between the parent device to |
19 | * avoid namespace conflicts | 20 | * avoid namespace conflicts |
20 | * @class_mutex - mutex to protect the children, devices, and interfaces lists. | ||
21 | * @class - pointer back to the struct class that this structure is associated | 21 | * @class - pointer back to the struct class that this structure is associated |
22 | * with. | 22 | * with. |
23 | * | 23 | * |
@@ -28,6 +28,8 @@ | |||
28 | struct subsys_private { | 28 | struct subsys_private { |
29 | struct kset subsys; | 29 | struct kset subsys; |
30 | struct kset *devices_kset; | 30 | struct kset *devices_kset; |
31 | struct list_head interfaces; | ||
32 | struct mutex mutex; | ||
31 | 33 | ||
32 | struct kset *drivers_kset; | 34 | struct kset *drivers_kset; |
33 | struct klist klist_devices; | 35 | struct klist klist_devices; |
@@ -36,9 +38,7 @@ struct subsys_private { | |||
36 | unsigned int drivers_autoprobe:1; | 38 | unsigned int drivers_autoprobe:1; |
37 | struct bus_type *bus; | 39 | struct bus_type *bus; |
38 | 40 | ||
39 | struct list_head class_interfaces; | ||
40 | struct kset glue_dirs; | 41 | struct kset glue_dirs; |
41 | struct mutex class_mutex; | ||
42 | struct class *class; | 42 | struct class *class; |
43 | }; | 43 | }; |
44 | #define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) | 44 | #define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) |
@@ -94,7 +94,6 @@ extern int hypervisor_init(void); | |||
94 | static inline int hypervisor_init(void) { return 0; } | 94 | static inline int hypervisor_init(void) { return 0; } |
95 | #endif | 95 | #endif |
96 | extern int platform_bus_init(void); | 96 | extern int platform_bus_init(void); |
97 | extern int system_bus_init(void); | ||
98 | extern int cpu_dev_init(void); | 97 | extern int cpu_dev_init(void); |
99 | 98 | ||
100 | extern int bus_add_device(struct device *dev); | 99 | extern int bus_add_device(struct device *dev); |
@@ -116,6 +115,7 @@ extern char *make_class_name(const char *name, struct kobject *kobj); | |||
116 | 115 | ||
117 | extern int devres_release_all(struct device *dev); | 116 | extern int devres_release_all(struct device *dev); |
118 | 117 | ||
118 | /* /sys/devices directory */ | ||
119 | extern struct kset *devices_kset; | 119 | extern struct kset *devices_kset; |
120 | 120 | ||
121 | #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) | 121 | #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 000e7b2006f8..99dc5921e1dd 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -16,9 +16,14 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
19 | #include <linux/mutex.h> | ||
19 | #include "base.h" | 20 | #include "base.h" |
20 | #include "power/power.h" | 21 | #include "power/power.h" |
21 | 22 | ||
23 | /* /sys/devices/system */ | ||
24 | /* FIXME: make static after drivers/base/sys.c is deleted */ | ||
25 | struct kset *system_kset; | ||
26 | |||
22 | #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) | 27 | #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) |
23 | 28 | ||
24 | /* | 29 | /* |
@@ -360,6 +365,47 @@ struct device *bus_find_device_by_name(struct bus_type *bus, | |||
360 | } | 365 | } |
361 | EXPORT_SYMBOL_GPL(bus_find_device_by_name); | 366 | EXPORT_SYMBOL_GPL(bus_find_device_by_name); |
362 | 367 | ||
368 | /** | ||
369 | * subsys_find_device_by_id - find a device with a specific enumeration number | ||
370 | * @subsys: subsystem | ||
371 | * @id: index 'id' in struct device | ||
372 | * @hint: device to check first | ||
373 | * | ||
374 | * Check the hint's next object and if it is a match return it directly, | ||
375 | * otherwise, fall back to a full list search. Either way a reference for | ||
376 | * the returned object is taken. | ||
377 | */ | ||
378 | struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id, | ||
379 | struct device *hint) | ||
380 | { | ||
381 | struct klist_iter i; | ||
382 | struct device *dev; | ||
383 | |||
384 | if (!subsys) | ||
385 | return NULL; | ||
386 | |||
387 | if (hint) { | ||
388 | klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus); | ||
389 | dev = next_device(&i); | ||
390 | if (dev && dev->id == id && get_device(dev)) { | ||
391 | klist_iter_exit(&i); | ||
392 | return dev; | ||
393 | } | ||
394 | klist_iter_exit(&i); | ||
395 | } | ||
396 | |||
397 | klist_iter_init_node(&subsys->p->klist_devices, &i, NULL); | ||
398 | while ((dev = next_device(&i))) { | ||
399 | if (dev->id == id && get_device(dev)) { | ||
400 | klist_iter_exit(&i); | ||
401 | return dev; | ||
402 | } | ||
403 | } | ||
404 | klist_iter_exit(&i); | ||
405 | return NULL; | ||
406 | } | ||
407 | EXPORT_SYMBOL_GPL(subsys_find_device_by_id); | ||
408 | |||
363 | static struct device_driver *next_driver(struct klist_iter *i) | 409 | static struct device_driver *next_driver(struct klist_iter *i) |
364 | { | 410 | { |
365 | struct klist_node *n = klist_next(i); | 411 | struct klist_node *n = klist_next(i); |
@@ -487,38 +533,59 @@ out_put: | |||
487 | void bus_probe_device(struct device *dev) | 533 | void bus_probe_device(struct device *dev) |
488 | { | 534 | { |
489 | struct bus_type *bus = dev->bus; | 535 | struct bus_type *bus = dev->bus; |
536 | struct subsys_interface *sif; | ||
490 | int ret; | 537 | int ret; |
491 | 538 | ||
492 | if (bus && bus->p->drivers_autoprobe) { | 539 | if (!bus) |
540 | return; | ||
541 | |||
542 | if (bus->p->drivers_autoprobe) { | ||
493 | ret = device_attach(dev); | 543 | ret = device_attach(dev); |
494 | WARN_ON(ret < 0); | 544 | WARN_ON(ret < 0); |
495 | } | 545 | } |
546 | |||
547 | mutex_lock(&bus->p->mutex); | ||
548 | list_for_each_entry(sif, &bus->p->interfaces, node) | ||
549 | if (sif->add_dev) | ||
550 | sif->add_dev(dev, sif); | ||
551 | mutex_unlock(&bus->p->mutex); | ||
496 | } | 552 | } |
497 | 553 | ||
498 | /** | 554 | /** |
499 | * bus_remove_device - remove device from bus | 555 | * bus_remove_device - remove device from bus |
500 | * @dev: device to be removed | 556 | * @dev: device to be removed |
501 | * | 557 | * |
502 | * - Remove symlink from bus's directory. | 558 | * - Remove device from all interfaces. |
559 | * - Remove symlink from bus' directory. | ||
503 | * - Delete device from bus's list. | 560 | * - Delete device from bus's list. |
504 | * - Detach from its driver. | 561 | * - Detach from its driver. |
505 | * - Drop reference taken in bus_add_device(). | 562 | * - Drop reference taken in bus_add_device(). |
506 | */ | 563 | */ |
507 | void bus_remove_device(struct device *dev) | 564 | void bus_remove_device(struct device *dev) |
508 | { | 565 | { |
509 | if (dev->bus) { | 566 | struct bus_type *bus = dev->bus; |
510 | sysfs_remove_link(&dev->kobj, "subsystem"); | 567 | struct subsys_interface *sif; |
511 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | 568 | |
512 | dev_name(dev)); | 569 | if (!bus) |
513 | device_remove_attrs(dev->bus, dev); | 570 | return; |
514 | if (klist_node_attached(&dev->p->knode_bus)) | 571 | |
515 | klist_del(&dev->p->knode_bus); | 572 | mutex_lock(&bus->p->mutex); |
516 | 573 | list_for_each_entry(sif, &bus->p->interfaces, node) | |
517 | pr_debug("bus: '%s': remove device %s\n", | 574 | if (sif->remove_dev) |
518 | dev->bus->name, dev_name(dev)); | 575 | sif->remove_dev(dev, sif); |
519 | device_release_driver(dev); | 576 | mutex_unlock(&bus->p->mutex); |
520 | bus_put(dev->bus); | 577 | |
521 | } | 578 | sysfs_remove_link(&dev->kobj, "subsystem"); |
579 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | ||
580 | dev_name(dev)); | ||
581 | device_remove_attrs(dev->bus, dev); | ||
582 | if (klist_node_attached(&dev->p->knode_bus)) | ||
583 | klist_del(&dev->p->knode_bus); | ||
584 | |||
585 | pr_debug("bus: '%s': remove device %s\n", | ||
586 | dev->bus->name, dev_name(dev)); | ||
587 | device_release_driver(dev); | ||
588 | bus_put(dev->bus); | ||
522 | } | 589 | } |
523 | 590 | ||
524 | static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv) | 591 | static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv) |
@@ -847,14 +914,14 @@ static ssize_t bus_uevent_store(struct bus_type *bus, | |||
847 | static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); | 914 | static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); |
848 | 915 | ||
849 | /** | 916 | /** |
850 | * bus_register - register a bus with the system. | 917 | * __bus_register - register a driver-core subsystem |
851 | * @bus: bus. | 918 | * @bus: bus. |
852 | * | 919 | * |
853 | * Once we have that, we registered the bus with the kobject | 920 | * Once we have that, we registered the bus with the kobject |
854 | * infrastructure, then register the children subsystems it has: | 921 | * infrastructure, then register the children subsystems it has: |
855 | * the devices and drivers that belong to the bus. | 922 | * the devices and drivers that belong to the subsystem. |
856 | */ | 923 | */ |
857 | int bus_register(struct bus_type *bus) | 924 | int __bus_register(struct bus_type *bus, struct lock_class_key *key) |
858 | { | 925 | { |
859 | int retval; | 926 | int retval; |
860 | struct subsys_private *priv; | 927 | struct subsys_private *priv; |
@@ -898,6 +965,8 @@ int bus_register(struct bus_type *bus) | |||
898 | goto bus_drivers_fail; | 965 | goto bus_drivers_fail; |
899 | } | 966 | } |
900 | 967 | ||
968 | INIT_LIST_HEAD(&priv->interfaces); | ||
969 | __mutex_init(&priv->mutex, "subsys mutex", key); | ||
901 | klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put); | 970 | klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put); |
902 | klist_init(&priv->klist_drivers, NULL, NULL); | 971 | klist_init(&priv->klist_drivers, NULL, NULL); |
903 | 972 | ||
@@ -927,7 +996,7 @@ out: | |||
927 | bus->p = NULL; | 996 | bus->p = NULL; |
928 | return retval; | 997 | return retval; |
929 | } | 998 | } |
930 | EXPORT_SYMBOL_GPL(bus_register); | 999 | EXPORT_SYMBOL_GPL(__bus_register); |
931 | 1000 | ||
932 | /** | 1001 | /** |
933 | * bus_unregister - remove a bus from the system | 1002 | * bus_unregister - remove a bus from the system |
@@ -939,6 +1008,8 @@ EXPORT_SYMBOL_GPL(bus_register); | |||
939 | void bus_unregister(struct bus_type *bus) | 1008 | void bus_unregister(struct bus_type *bus) |
940 | { | 1009 | { |
941 | pr_debug("bus: '%s': unregistering\n", bus->name); | 1010 | pr_debug("bus: '%s': unregistering\n", bus->name); |
1011 | if (bus->dev_root) | ||
1012 | device_unregister(bus->dev_root); | ||
942 | bus_remove_attrs(bus); | 1013 | bus_remove_attrs(bus); |
943 | remove_probe_files(bus); | 1014 | remove_probe_files(bus); |
944 | kset_unregister(bus->p->drivers_kset); | 1015 | kset_unregister(bus->p->drivers_kset); |
@@ -1028,10 +1099,194 @@ void bus_sort_breadthfirst(struct bus_type *bus, | |||
1028 | } | 1099 | } |
1029 | EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); | 1100 | EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); |
1030 | 1101 | ||
1102 | /** | ||
1103 | * subsys_dev_iter_init - initialize subsys device iterator | ||
1104 | * @iter: subsys iterator to initialize | ||
1105 | * @subsys: the subsys we wanna iterate over | ||
1106 | * @start: the device to start iterating from, if any | ||
1107 | * @type: device_type of the devices to iterate over, NULL for all | ||
1108 | * | ||
1109 | * Initialize subsys iterator @iter such that it iterates over devices | ||
1110 | * of @subsys. If @start is set, the list iteration will start there, | ||
1111 | * otherwise if it is NULL, the iteration starts at the beginning of | ||
1112 | * the list. | ||
1113 | */ | ||
1114 | void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys, | ||
1115 | struct device *start, const struct device_type *type) | ||
1116 | { | ||
1117 | struct klist_node *start_knode = NULL; | ||
1118 | |||
1119 | if (start) | ||
1120 | start_knode = &start->p->knode_bus; | ||
1121 | klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode); | ||
1122 | iter->type = type; | ||
1123 | } | ||
1124 | EXPORT_SYMBOL_GPL(subsys_dev_iter_init); | ||
1125 | |||
1126 | /** | ||
1127 | * subsys_dev_iter_next - iterate to the next device | ||
1128 | * @iter: subsys iterator to proceed | ||
1129 | * | ||
1130 | * Proceed @iter to the next device and return it. Returns NULL if | ||
1131 | * iteration is complete. | ||
1132 | * | ||
1133 | * The returned device is referenced and won't be released till | ||
1134 | * iterator is proceed to the next device or exited. The caller is | ||
1135 | * free to do whatever it wants to do with the device including | ||
1136 | * calling back into subsys code. | ||
1137 | */ | ||
1138 | struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter) | ||
1139 | { | ||
1140 | struct klist_node *knode; | ||
1141 | struct device *dev; | ||
1142 | |||
1143 | for (;;) { | ||
1144 | knode = klist_next(&iter->ki); | ||
1145 | if (!knode) | ||
1146 | return NULL; | ||
1147 | dev = container_of(knode, struct device_private, knode_bus)->device; | ||
1148 | if (!iter->type || iter->type == dev->type) | ||
1149 | return dev; | ||
1150 | } | ||
1151 | } | ||
1152 | EXPORT_SYMBOL_GPL(subsys_dev_iter_next); | ||
1153 | |||
1154 | /** | ||
1155 | * subsys_dev_iter_exit - finish iteration | ||
1156 | * @iter: subsys iterator to finish | ||
1157 | * | ||
1158 | * Finish an iteration. Always call this function after iteration is | ||
1159 | * complete whether the iteration ran till the end or not. | ||
1160 | */ | ||
1161 | void subsys_dev_iter_exit(struct subsys_dev_iter *iter) | ||
1162 | { | ||
1163 | klist_iter_exit(&iter->ki); | ||
1164 | } | ||
1165 | EXPORT_SYMBOL_GPL(subsys_dev_iter_exit); | ||
1166 | |||
1167 | int subsys_interface_register(struct subsys_interface *sif) | ||
1168 | { | ||
1169 | struct bus_type *subsys; | ||
1170 | struct subsys_dev_iter iter; | ||
1171 | struct device *dev; | ||
1172 | |||
1173 | if (!sif || !sif->subsys) | ||
1174 | return -ENODEV; | ||
1175 | |||
1176 | subsys = bus_get(sif->subsys); | ||
1177 | if (!subsys) | ||
1178 | return -EINVAL; | ||
1179 | |||
1180 | mutex_lock(&subsys->p->mutex); | ||
1181 | list_add_tail(&sif->node, &subsys->p->interfaces); | ||
1182 | if (sif->add_dev) { | ||
1183 | subsys_dev_iter_init(&iter, subsys, NULL, NULL); | ||
1184 | while ((dev = subsys_dev_iter_next(&iter))) | ||
1185 | sif->add_dev(dev, sif); | ||
1186 | subsys_dev_iter_exit(&iter); | ||
1187 | } | ||
1188 | mutex_unlock(&subsys->p->mutex); | ||
1189 | |||
1190 | return 0; | ||
1191 | } | ||
1192 | EXPORT_SYMBOL_GPL(subsys_interface_register); | ||
1193 | |||
1194 | void subsys_interface_unregister(struct subsys_interface *sif) | ||
1195 | { | ||
1196 | struct bus_type *subsys = sif->subsys; | ||
1197 | struct subsys_dev_iter iter; | ||
1198 | struct device *dev; | ||
1199 | |||
1200 | if (!sif) | ||
1201 | return; | ||
1202 | |||
1203 | mutex_lock(&subsys->p->mutex); | ||
1204 | list_del_init(&sif->node); | ||
1205 | if (sif->remove_dev) { | ||
1206 | subsys_dev_iter_init(&iter, subsys, NULL, NULL); | ||
1207 | while ((dev = subsys_dev_iter_next(&iter))) | ||
1208 | sif->remove_dev(dev, sif); | ||
1209 | subsys_dev_iter_exit(&iter); | ||
1210 | } | ||
1211 | mutex_unlock(&subsys->p->mutex); | ||
1212 | |||
1213 | bus_put(subsys); | ||
1214 | } | ||
1215 | EXPORT_SYMBOL_GPL(subsys_interface_unregister); | ||
1216 | |||
1217 | static void system_root_device_release(struct device *dev) | ||
1218 | { | ||
1219 | kfree(dev); | ||
1220 | } | ||
1221 | /** | ||
1222 | * subsys_system_register - register a subsystem at /sys/devices/system/ | ||
1223 | * @subsys - system subsystem | ||
1224 | * @groups - default attributes for the root device | ||
1225 | * | ||
1226 | * All 'system' subsystems have a /sys/devices/system/<name> root device | ||
1227 | * with the name of the subsystem. The root device can carry subsystem- | ||
1228 | * wide attributes. All registered devices are below this single root | ||
1229 | * device and are named after the subsystem with a simple enumeration | ||
1230 | * number appended. The registered devices are not explicitely named; | ||
1231 | * only 'id' in the device needs to be set. | ||
1232 | * | ||
1233 | * Do not use this interface for anything new, it exists for compatibility | ||
1234 | * with bad ideas only. New subsystems should use plain subsystems; and | ||
1235 | * add the subsystem-wide attributes should be added to the subsystem | ||
1236 | * directory itself and not some create fake root-device placed in | ||
1237 | * /sys/devices/system/<name>. | ||
1238 | */ | ||
1239 | int subsys_system_register(struct bus_type *subsys, | ||
1240 | const struct attribute_group **groups) | ||
1241 | { | ||
1242 | struct device *dev; | ||
1243 | int err; | ||
1244 | |||
1245 | err = bus_register(subsys); | ||
1246 | if (err < 0) | ||
1247 | return err; | ||
1248 | |||
1249 | dev = kzalloc(sizeof(struct device), GFP_KERNEL); | ||
1250 | if (!dev) { | ||
1251 | err = -ENOMEM; | ||
1252 | goto err_dev; | ||
1253 | } | ||
1254 | |||
1255 | err = dev_set_name(dev, "%s", subsys->name); | ||
1256 | if (err < 0) | ||
1257 | goto err_name; | ||
1258 | |||
1259 | dev->kobj.parent = &system_kset->kobj; | ||
1260 | dev->groups = groups; | ||
1261 | dev->release = system_root_device_release; | ||
1262 | |||
1263 | err = device_register(dev); | ||
1264 | if (err < 0) | ||
1265 | goto err_dev_reg; | ||
1266 | |||
1267 | subsys->dev_root = dev; | ||
1268 | return 0; | ||
1269 | |||
1270 | err_dev_reg: | ||
1271 | put_device(dev); | ||
1272 | dev = NULL; | ||
1273 | err_name: | ||
1274 | kfree(dev); | ||
1275 | err_dev: | ||
1276 | bus_unregister(subsys); | ||
1277 | return err; | ||
1278 | } | ||
1279 | EXPORT_SYMBOL_GPL(subsys_system_register); | ||
1280 | |||
1031 | int __init buses_init(void) | 1281 | int __init buses_init(void) |
1032 | { | 1282 | { |
1033 | bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); | 1283 | bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); |
1034 | if (!bus_kset) | 1284 | if (!bus_kset) |
1035 | return -ENOMEM; | 1285 | return -ENOMEM; |
1286 | |||
1287 | system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj); | ||
1288 | if (!system_kset) | ||
1289 | return -ENOMEM; | ||
1290 | |||
1036 | return 0; | 1291 | return 0; |
1037 | } | 1292 | } |
diff --git a/drivers/base/class.c b/drivers/base/class.c index b80d91cc8c3a..03243d4002fd 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -184,9 +184,9 @@ int __class_register(struct class *cls, struct lock_class_key *key) | |||
184 | if (!cp) | 184 | if (!cp) |
185 | return -ENOMEM; | 185 | return -ENOMEM; |
186 | klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put); | 186 | klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put); |
187 | INIT_LIST_HEAD(&cp->class_interfaces); | 187 | INIT_LIST_HEAD(&cp->interfaces); |
188 | kset_init(&cp->glue_dirs); | 188 | kset_init(&cp->glue_dirs); |
189 | __mutex_init(&cp->class_mutex, "struct class mutex", key); | 189 | __mutex_init(&cp->mutex, "subsys mutex", key); |
190 | error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); | 190 | error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); |
191 | if (error) { | 191 | if (error) { |
192 | kfree(cp); | 192 | kfree(cp); |
@@ -460,15 +460,15 @@ int class_interface_register(struct class_interface *class_intf) | |||
460 | if (!parent) | 460 | if (!parent) |
461 | return -EINVAL; | 461 | return -EINVAL; |
462 | 462 | ||
463 | mutex_lock(&parent->p->class_mutex); | 463 | mutex_lock(&parent->p->mutex); |
464 | list_add_tail(&class_intf->node, &parent->p->class_interfaces); | 464 | list_add_tail(&class_intf->node, &parent->p->interfaces); |
465 | if (class_intf->add_dev) { | 465 | if (class_intf->add_dev) { |
466 | class_dev_iter_init(&iter, parent, NULL, NULL); | 466 | class_dev_iter_init(&iter, parent, NULL, NULL); |
467 | while ((dev = class_dev_iter_next(&iter))) | 467 | while ((dev = class_dev_iter_next(&iter))) |
468 | class_intf->add_dev(dev, class_intf); | 468 | class_intf->add_dev(dev, class_intf); |
469 | class_dev_iter_exit(&iter); | 469 | class_dev_iter_exit(&iter); |
470 | } | 470 | } |
471 | mutex_unlock(&parent->p->class_mutex); | 471 | mutex_unlock(&parent->p->mutex); |
472 | 472 | ||
473 | return 0; | 473 | return 0; |
474 | } | 474 | } |
@@ -482,7 +482,7 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
482 | if (!parent) | 482 | if (!parent) |
483 | return; | 483 | return; |
484 | 484 | ||
485 | mutex_lock(&parent->p->class_mutex); | 485 | mutex_lock(&parent->p->mutex); |
486 | list_del_init(&class_intf->node); | 486 | list_del_init(&class_intf->node); |
487 | if (class_intf->remove_dev) { | 487 | if (class_intf->remove_dev) { |
488 | class_dev_iter_init(&iter, parent, NULL, NULL); | 488 | class_dev_iter_init(&iter, parent, NULL, NULL); |
@@ -490,7 +490,7 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
490 | class_intf->remove_dev(dev, class_intf); | 490 | class_intf->remove_dev(dev, class_intf); |
491 | class_dev_iter_exit(&iter); | 491 | class_dev_iter_exit(&iter); |
492 | } | 492 | } |
493 | mutex_unlock(&parent->p->class_mutex); | 493 | mutex_unlock(&parent->p->mutex); |
494 | 494 | ||
495 | class_put(parent); | 495 | class_put(parent); |
496 | } | 496 | } |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 1dfa1d616fa5..4a67cc0c8b37 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -118,6 +118,56 @@ static const struct sysfs_ops dev_sysfs_ops = { | |||
118 | .store = dev_attr_store, | 118 | .store = dev_attr_store, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | #define to_ext_attr(x) container_of(x, struct dev_ext_attribute, attr) | ||
122 | |||
123 | ssize_t device_store_ulong(struct device *dev, | ||
124 | struct device_attribute *attr, | ||
125 | const char *buf, size_t size) | ||
126 | { | ||
127 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
128 | char *end; | ||
129 | unsigned long new = simple_strtoul(buf, &end, 0); | ||
130 | if (end == buf) | ||
131 | return -EINVAL; | ||
132 | *(unsigned long *)(ea->var) = new; | ||
133 | /* Always return full write size even if we didn't consume all */ | ||
134 | return size; | ||
135 | } | ||
136 | EXPORT_SYMBOL_GPL(device_store_ulong); | ||
137 | |||
138 | ssize_t device_show_ulong(struct device *dev, | ||
139 | struct device_attribute *attr, | ||
140 | char *buf) | ||
141 | { | ||
142 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
143 | return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var)); | ||
144 | } | ||
145 | EXPORT_SYMBOL_GPL(device_show_ulong); | ||
146 | |||
147 | ssize_t device_store_int(struct device *dev, | ||
148 | struct device_attribute *attr, | ||
149 | const char *buf, size_t size) | ||
150 | { | ||
151 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
152 | char *end; | ||
153 | long new = simple_strtol(buf, &end, 0); | ||
154 | if (end == buf || new > INT_MAX || new < INT_MIN) | ||
155 | return -EINVAL; | ||
156 | *(int *)(ea->var) = new; | ||
157 | /* Always return full write size even if we didn't consume all */ | ||
158 | return size; | ||
159 | } | ||
160 | EXPORT_SYMBOL_GPL(device_store_int); | ||
161 | |||
162 | ssize_t device_show_int(struct device *dev, | ||
163 | struct device_attribute *attr, | ||
164 | char *buf) | ||
165 | { | ||
166 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
167 | |||
168 | return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var)); | ||
169 | } | ||
170 | EXPORT_SYMBOL_GPL(device_show_int); | ||
121 | 171 | ||
122 | /** | 172 | /** |
123 | * device_release - free device structure. | 173 | * device_release - free device structure. |
@@ -464,7 +514,7 @@ static ssize_t show_dev(struct device *dev, struct device_attribute *attr, | |||
464 | static struct device_attribute devt_attr = | 514 | static struct device_attribute devt_attr = |
465 | __ATTR(dev, S_IRUGO, show_dev, NULL); | 515 | __ATTR(dev, S_IRUGO, show_dev, NULL); |
466 | 516 | ||
467 | /* kset to create /sys/devices/ */ | 517 | /* /sys/devices/ */ |
468 | struct kset *devices_kset; | 518 | struct kset *devices_kset; |
469 | 519 | ||
470 | /** | 520 | /** |
@@ -711,6 +761,10 @@ static struct kobject *get_device_parent(struct device *dev, | |||
711 | return k; | 761 | return k; |
712 | } | 762 | } |
713 | 763 | ||
764 | /* subsystems can specify a default root directory for their devices */ | ||
765 | if (!parent && dev->bus && dev->bus->dev_root) | ||
766 | return &dev->bus->dev_root->kobj; | ||
767 | |||
714 | if (parent) | 768 | if (parent) |
715 | return &parent->kobj; | 769 | return &parent->kobj; |
716 | return NULL; | 770 | return NULL; |
@@ -731,14 +785,6 @@ static void cleanup_device_parent(struct device *dev) | |||
731 | cleanup_glue_dir(dev, dev->kobj.parent); | 785 | cleanup_glue_dir(dev, dev->kobj.parent); |
732 | } | 786 | } |
733 | 787 | ||
734 | static void setup_parent(struct device *dev, struct device *parent) | ||
735 | { | ||
736 | struct kobject *kobj; | ||
737 | kobj = get_device_parent(dev, parent); | ||
738 | if (kobj) | ||
739 | dev->kobj.parent = kobj; | ||
740 | } | ||
741 | |||
742 | static int device_add_class_symlinks(struct device *dev) | 788 | static int device_add_class_symlinks(struct device *dev) |
743 | { | 789 | { |
744 | int error; | 790 | int error; |
@@ -891,6 +937,7 @@ int device_private_init(struct device *dev) | |||
891 | int device_add(struct device *dev) | 937 | int device_add(struct device *dev) |
892 | { | 938 | { |
893 | struct device *parent = NULL; | 939 | struct device *parent = NULL; |
940 | struct kobject *kobj; | ||
894 | struct class_interface *class_intf; | 941 | struct class_interface *class_intf; |
895 | int error = -EINVAL; | 942 | int error = -EINVAL; |
896 | 943 | ||
@@ -914,6 +961,10 @@ int device_add(struct device *dev) | |||
914 | dev->init_name = NULL; | 961 | dev->init_name = NULL; |
915 | } | 962 | } |
916 | 963 | ||
964 | /* subsystems can specify simple device enumeration */ | ||
965 | if (!dev_name(dev) && dev->bus && dev->bus->dev_name) | ||
966 | dev_set_name(dev, "%s%u", dev->bus->dev_name, dev->id); | ||
967 | |||
917 | if (!dev_name(dev)) { | 968 | if (!dev_name(dev)) { |
918 | error = -EINVAL; | 969 | error = -EINVAL; |
919 | goto name_error; | 970 | goto name_error; |
@@ -922,7 +973,9 @@ int device_add(struct device *dev) | |||
922 | pr_debug("device: '%s': %s\n", dev_name(dev), __func__); | 973 | pr_debug("device: '%s': %s\n", dev_name(dev), __func__); |
923 | 974 | ||
924 | parent = get_device(dev->parent); | 975 | parent = get_device(dev->parent); |
925 | setup_parent(dev, parent); | 976 | kobj = get_device_parent(dev, parent); |
977 | if (kobj) | ||
978 | dev->kobj.parent = kobj; | ||
926 | 979 | ||
927 | /* use parent numa_node */ | 980 | /* use parent numa_node */ |
928 | if (parent) | 981 | if (parent) |
@@ -982,17 +1035,17 @@ int device_add(struct device *dev) | |||
982 | &parent->p->klist_children); | 1035 | &parent->p->klist_children); |
983 | 1036 | ||
984 | if (dev->class) { | 1037 | if (dev->class) { |
985 | mutex_lock(&dev->class->p->class_mutex); | 1038 | mutex_lock(&dev->class->p->mutex); |
986 | /* tie the class to the device */ | 1039 | /* tie the class to the device */ |
987 | klist_add_tail(&dev->knode_class, | 1040 | klist_add_tail(&dev->knode_class, |
988 | &dev->class->p->klist_devices); | 1041 | &dev->class->p->klist_devices); |
989 | 1042 | ||
990 | /* notify any interfaces that the device is here */ | 1043 | /* notify any interfaces that the device is here */ |
991 | list_for_each_entry(class_intf, | 1044 | list_for_each_entry(class_intf, |
992 | &dev->class->p->class_interfaces, node) | 1045 | &dev->class->p->interfaces, node) |
993 | if (class_intf->add_dev) | 1046 | if (class_intf->add_dev) |
994 | class_intf->add_dev(dev, class_intf); | 1047 | class_intf->add_dev(dev, class_intf); |
995 | mutex_unlock(&dev->class->p->class_mutex); | 1048 | mutex_unlock(&dev->class->p->mutex); |
996 | } | 1049 | } |
997 | done: | 1050 | done: |
998 | put_device(dev); | 1051 | put_device(dev); |
@@ -1107,15 +1160,15 @@ void device_del(struct device *dev) | |||
1107 | if (dev->class) { | 1160 | if (dev->class) { |
1108 | device_remove_class_symlinks(dev); | 1161 | device_remove_class_symlinks(dev); |
1109 | 1162 | ||
1110 | mutex_lock(&dev->class->p->class_mutex); | 1163 | mutex_lock(&dev->class->p->mutex); |
1111 | /* notify any interfaces that the device is now gone */ | 1164 | /* notify any interfaces that the device is now gone */ |
1112 | list_for_each_entry(class_intf, | 1165 | list_for_each_entry(class_intf, |
1113 | &dev->class->p->class_interfaces, node) | 1166 | &dev->class->p->interfaces, node) |
1114 | if (class_intf->remove_dev) | 1167 | if (class_intf->remove_dev) |
1115 | class_intf->remove_dev(dev, class_intf); | 1168 | class_intf->remove_dev(dev, class_intf); |
1116 | /* remove the device from the class list */ | 1169 | /* remove the device from the class list */ |
1117 | klist_del(&dev->knode_class); | 1170 | klist_del(&dev->knode_class); |
1118 | mutex_unlock(&dev->class->p->class_mutex); | 1171 | mutex_unlock(&dev->class->p->mutex); |
1119 | } | 1172 | } |
1120 | device_remove_file(dev, &uevent_attr); | 1173 | device_remove_file(dev, &uevent_attr); |
1121 | device_remove_attrs(dev); | 1174 | device_remove_attrs(dev); |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 251acea3d359..9a5578efbc93 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -1,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/base/cpu.c - basic CPU class support | 2 | * CPU subsystem support |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/sysdev.h> | ||
6 | #include <linux/module.h> | 5 | #include <linux/module.h> |
7 | #include <linux/init.h> | 6 | #include <linux/init.h> |
8 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
@@ -14,40 +13,40 @@ | |||
14 | 13 | ||
15 | #include "base.h" | 14 | #include "base.h" |
16 | 15 | ||
17 | static struct sysdev_class_attribute *cpu_sysdev_class_attrs[]; | 16 | struct bus_type cpu_subsys = { |
18 | |||
19 | struct sysdev_class cpu_sysdev_class = { | ||
20 | .name = "cpu", | 17 | .name = "cpu", |
21 | .attrs = cpu_sysdev_class_attrs, | 18 | .dev_name = "cpu", |
22 | }; | 19 | }; |
23 | EXPORT_SYMBOL(cpu_sysdev_class); | 20 | EXPORT_SYMBOL_GPL(cpu_subsys); |
24 | 21 | ||
25 | static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices); | 22 | static DEFINE_PER_CPU(struct device *, cpu_sys_devices); |
26 | 23 | ||
27 | #ifdef CONFIG_HOTPLUG_CPU | 24 | #ifdef CONFIG_HOTPLUG_CPU |
28 | static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr, | 25 | static ssize_t show_online(struct device *dev, |
26 | struct device_attribute *attr, | ||
29 | char *buf) | 27 | char *buf) |
30 | { | 28 | { |
31 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 29 | struct cpu *cpu = container_of(dev, struct cpu, dev); |
32 | 30 | ||
33 | return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id)); | 31 | return sprintf(buf, "%u\n", !!cpu_online(cpu->dev.id)); |
34 | } | 32 | } |
35 | 33 | ||
36 | static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr, | 34 | static ssize_t __ref store_online(struct device *dev, |
37 | const char *buf, size_t count) | 35 | struct device_attribute *attr, |
36 | const char *buf, size_t count) | ||
38 | { | 37 | { |
39 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 38 | struct cpu *cpu = container_of(dev, struct cpu, dev); |
40 | ssize_t ret; | 39 | ssize_t ret; |
41 | 40 | ||
42 | cpu_hotplug_driver_lock(); | 41 | cpu_hotplug_driver_lock(); |
43 | switch (buf[0]) { | 42 | switch (buf[0]) { |
44 | case '0': | 43 | case '0': |
45 | ret = cpu_down(cpu->sysdev.id); | 44 | ret = cpu_down(cpu->dev.id); |
46 | if (!ret) | 45 | if (!ret) |
47 | kobject_uevent(&dev->kobj, KOBJ_OFFLINE); | 46 | kobject_uevent(&dev->kobj, KOBJ_OFFLINE); |
48 | break; | 47 | break; |
49 | case '1': | 48 | case '1': |
50 | ret = cpu_up(cpu->sysdev.id); | 49 | ret = cpu_up(cpu->dev.id); |
51 | if (!ret) | 50 | if (!ret) |
52 | kobject_uevent(&dev->kobj, KOBJ_ONLINE); | 51 | kobject_uevent(&dev->kobj, KOBJ_ONLINE); |
53 | break; | 52 | break; |
@@ -60,44 +59,44 @@ static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribut | |||
60 | ret = count; | 59 | ret = count; |
61 | return ret; | 60 | return ret; |
62 | } | 61 | } |
63 | static SYSDEV_ATTR(online, 0644, show_online, store_online); | 62 | static DEVICE_ATTR(online, 0644, show_online, store_online); |
64 | 63 | ||
65 | static void __cpuinit register_cpu_control(struct cpu *cpu) | 64 | static void __cpuinit register_cpu_control(struct cpu *cpu) |
66 | { | 65 | { |
67 | sysdev_create_file(&cpu->sysdev, &attr_online); | 66 | device_create_file(&cpu->dev, &dev_attr_online); |
68 | } | 67 | } |
69 | void unregister_cpu(struct cpu *cpu) | 68 | void unregister_cpu(struct cpu *cpu) |
70 | { | 69 | { |
71 | int logical_cpu = cpu->sysdev.id; | 70 | int logical_cpu = cpu->dev.id; |
72 | 71 | ||
73 | unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); | 72 | unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); |
74 | 73 | ||
75 | sysdev_remove_file(&cpu->sysdev, &attr_online); | 74 | device_remove_file(&cpu->dev, &dev_attr_online); |
76 | 75 | ||
77 | sysdev_unregister(&cpu->sysdev); | 76 | device_unregister(&cpu->dev); |
78 | per_cpu(cpu_sys_devices, logical_cpu) = NULL; | 77 | per_cpu(cpu_sys_devices, logical_cpu) = NULL; |
79 | return; | 78 | return; |
80 | } | 79 | } |
81 | 80 | ||
82 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE | 81 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE |
83 | static ssize_t cpu_probe_store(struct sysdev_class *class, | 82 | static ssize_t cpu_probe_store(struct device *dev, |
84 | struct sysdev_class_attribute *attr, | 83 | struct device_attribute *attr, |
85 | const char *buf, | 84 | const char *buf, |
86 | size_t count) | 85 | size_t count) |
87 | { | 86 | { |
88 | return arch_cpu_probe(buf, count); | 87 | return arch_cpu_probe(buf, count); |
89 | } | 88 | } |
90 | 89 | ||
91 | static ssize_t cpu_release_store(struct sysdev_class *class, | 90 | static ssize_t cpu_release_store(struct device *dev, |
92 | struct sysdev_class_attribute *attr, | 91 | struct device_attribute *attr, |
93 | const char *buf, | 92 | const char *buf, |
94 | size_t count) | 93 | size_t count) |
95 | { | 94 | { |
96 | return arch_cpu_release(buf, count); | 95 | return arch_cpu_release(buf, count); |
97 | } | 96 | } |
98 | 97 | ||
99 | static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); | 98 | static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); |
100 | static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); | 99 | static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); |
101 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ | 100 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ |
102 | 101 | ||
103 | #else /* ... !CONFIG_HOTPLUG_CPU */ | 102 | #else /* ... !CONFIG_HOTPLUG_CPU */ |
@@ -109,15 +108,15 @@ static inline void register_cpu_control(struct cpu *cpu) | |||
109 | #ifdef CONFIG_KEXEC | 108 | #ifdef CONFIG_KEXEC |
110 | #include <linux/kexec.h> | 109 | #include <linux/kexec.h> |
111 | 110 | ||
112 | static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr, | 111 | static ssize_t show_crash_notes(struct device *dev, struct device_attribute *attr, |
113 | char *buf) | 112 | char *buf) |
114 | { | 113 | { |
115 | struct cpu *cpu = container_of(dev, struct cpu, sysdev); | 114 | struct cpu *cpu = container_of(dev, struct cpu, dev); |
116 | ssize_t rc; | 115 | ssize_t rc; |
117 | unsigned long long addr; | 116 | unsigned long long addr; |
118 | int cpunum; | 117 | int cpunum; |
119 | 118 | ||
120 | cpunum = cpu->sysdev.id; | 119 | cpunum = cpu->dev.id; |
121 | 120 | ||
122 | /* | 121 | /* |
123 | * Might be reading other cpu's data based on which cpu read thread | 122 | * Might be reading other cpu's data based on which cpu read thread |
@@ -129,7 +128,7 @@ static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute | |||
129 | rc = sprintf(buf, "%Lx\n", addr); | 128 | rc = sprintf(buf, "%Lx\n", addr); |
130 | return rc; | 129 | return rc; |
131 | } | 130 | } |
132 | static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | 131 | static DEVICE_ATTR(crash_notes, 0400, show_crash_notes, NULL); |
133 | #endif | 132 | #endif |
134 | 133 | ||
135 | /* | 134 | /* |
@@ -137,12 +136,12 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | |||
137 | */ | 136 | */ |
138 | 137 | ||
139 | struct cpu_attr { | 138 | struct cpu_attr { |
140 | struct sysdev_class_attribute attr; | 139 | struct device_attribute attr; |
141 | const struct cpumask *const * const map; | 140 | const struct cpumask *const * const map; |
142 | }; | 141 | }; |
143 | 142 | ||
144 | static ssize_t show_cpus_attr(struct sysdev_class *class, | 143 | static ssize_t show_cpus_attr(struct device *dev, |
145 | struct sysdev_class_attribute *attr, | 144 | struct device_attribute *attr, |
146 | char *buf) | 145 | char *buf) |
147 | { | 146 | { |
148 | struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); | 147 | struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); |
@@ -153,10 +152,10 @@ static ssize_t show_cpus_attr(struct sysdev_class *class, | |||
153 | return n; | 152 | return n; |
154 | } | 153 | } |
155 | 154 | ||
156 | #define _CPU_ATTR(name, map) \ | 155 | #define _CPU_ATTR(name, map) \ |
157 | { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } | 156 | { __ATTR(name, 0444, show_cpus_attr, NULL), map } |
158 | 157 | ||
159 | /* Keep in sync with cpu_sysdev_class_attrs */ | 158 | /* Keep in sync with cpu_subsys_attrs */ |
160 | static struct cpu_attr cpu_attrs[] = { | 159 | static struct cpu_attr cpu_attrs[] = { |
161 | _CPU_ATTR(online, &cpu_online_mask), | 160 | _CPU_ATTR(online, &cpu_online_mask), |
162 | _CPU_ATTR(possible, &cpu_possible_mask), | 161 | _CPU_ATTR(possible, &cpu_possible_mask), |
@@ -166,19 +165,19 @@ static struct cpu_attr cpu_attrs[] = { | |||
166 | /* | 165 | /* |
167 | * Print values for NR_CPUS and offlined cpus | 166 | * Print values for NR_CPUS and offlined cpus |
168 | */ | 167 | */ |
169 | static ssize_t print_cpus_kernel_max(struct sysdev_class *class, | 168 | static ssize_t print_cpus_kernel_max(struct device *dev, |
170 | struct sysdev_class_attribute *attr, char *buf) | 169 | struct device_attribute *attr, char *buf) |
171 | { | 170 | { |
172 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); | 171 | int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1); |
173 | return n; | 172 | return n; |
174 | } | 173 | } |
175 | static SYSDEV_CLASS_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); | 174 | static DEVICE_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL); |
176 | 175 | ||
177 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ | 176 | /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */ |
178 | unsigned int total_cpus; | 177 | unsigned int total_cpus; |
179 | 178 | ||
180 | static ssize_t print_cpus_offline(struct sysdev_class *class, | 179 | static ssize_t print_cpus_offline(struct device *dev, |
181 | struct sysdev_class_attribute *attr, char *buf) | 180 | struct device_attribute *attr, char *buf) |
182 | { | 181 | { |
183 | int n = 0, len = PAGE_SIZE-2; | 182 | int n = 0, len = PAGE_SIZE-2; |
184 | cpumask_var_t offline; | 183 | cpumask_var_t offline; |
@@ -205,7 +204,7 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, | |||
205 | n += snprintf(&buf[n], len - n, "\n"); | 204 | n += snprintf(&buf[n], len - n, "\n"); |
206 | return n; | 205 | return n; |
207 | } | 206 | } |
208 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); | 207 | static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL); |
209 | 208 | ||
210 | /* | 209 | /* |
211 | * register_cpu - Setup a sysfs device for a CPU. | 210 | * register_cpu - Setup a sysfs device for a CPU. |
@@ -218,57 +217,73 @@ static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); | |||
218 | int __cpuinit register_cpu(struct cpu *cpu, int num) | 217 | int __cpuinit register_cpu(struct cpu *cpu, int num) |
219 | { | 218 | { |
220 | int error; | 219 | int error; |
221 | cpu->node_id = cpu_to_node(num); | ||
222 | cpu->sysdev.id = num; | ||
223 | cpu->sysdev.cls = &cpu_sysdev_class; | ||
224 | |||
225 | error = sysdev_register(&cpu->sysdev); | ||
226 | 220 | ||
221 | cpu->node_id = cpu_to_node(num); | ||
222 | cpu->dev.id = num; | ||
223 | cpu->dev.bus = &cpu_subsys; | ||
224 | error = device_register(&cpu->dev); | ||
227 | if (!error && cpu->hotpluggable) | 225 | if (!error && cpu->hotpluggable) |
228 | register_cpu_control(cpu); | 226 | register_cpu_control(cpu); |
229 | if (!error) | 227 | if (!error) |
230 | per_cpu(cpu_sys_devices, num) = &cpu->sysdev; | 228 | per_cpu(cpu_sys_devices, num) = &cpu->dev; |
231 | if (!error) | 229 | if (!error) |
232 | register_cpu_under_node(num, cpu_to_node(num)); | 230 | register_cpu_under_node(num, cpu_to_node(num)); |
233 | 231 | ||
234 | #ifdef CONFIG_KEXEC | 232 | #ifdef CONFIG_KEXEC |
235 | if (!error) | 233 | if (!error) |
236 | error = sysdev_create_file(&cpu->sysdev, &attr_crash_notes); | 234 | error = device_create_file(&cpu->dev, &dev_attr_crash_notes); |
237 | #endif | 235 | #endif |
238 | return error; | 236 | return error; |
239 | } | 237 | } |
240 | 238 | ||
241 | struct sys_device *get_cpu_sysdev(unsigned cpu) | 239 | struct device *get_cpu_device(unsigned cpu) |
242 | { | 240 | { |
243 | if (cpu < nr_cpu_ids && cpu_possible(cpu)) | 241 | if (cpu < nr_cpu_ids && cpu_possible(cpu)) |
244 | return per_cpu(cpu_sys_devices, cpu); | 242 | return per_cpu(cpu_sys_devices, cpu); |
245 | else | 243 | else |
246 | return NULL; | 244 | return NULL; |
247 | } | 245 | } |
248 | EXPORT_SYMBOL_GPL(get_cpu_sysdev); | 246 | EXPORT_SYMBOL_GPL(get_cpu_device); |
247 | |||
248 | static struct attribute *cpu_root_attrs[] = { | ||
249 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE | ||
250 | &dev_attr_probe.attr, | ||
251 | &dev_attr_release.attr, | ||
252 | #endif | ||
253 | &cpu_attrs[0].attr.attr, | ||
254 | &cpu_attrs[1].attr.attr, | ||
255 | &cpu_attrs[2].attr.attr, | ||
256 | &dev_attr_kernel_max.attr, | ||
257 | &dev_attr_offline.attr, | ||
258 | NULL | ||
259 | }; | ||
260 | |||
261 | static struct attribute_group cpu_root_attr_group = { | ||
262 | .attrs = cpu_root_attrs, | ||
263 | }; | ||
264 | |||
265 | static const struct attribute_group *cpu_root_attr_groups[] = { | ||
266 | &cpu_root_attr_group, | ||
267 | NULL, | ||
268 | }; | ||
269 | |||
270 | bool cpu_is_hotpluggable(unsigned cpu) | ||
271 | { | ||
272 | struct device *dev = get_cpu_device(cpu); | ||
273 | return dev && container_of(dev, struct cpu, dev)->hotpluggable; | ||
274 | } | ||
275 | EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); | ||
249 | 276 | ||
250 | int __init cpu_dev_init(void) | 277 | int __init cpu_dev_init(void) |
251 | { | 278 | { |
252 | int err; | 279 | int err; |
253 | 280 | ||
254 | err = sysdev_class_register(&cpu_sysdev_class); | 281 | err = subsys_system_register(&cpu_subsys, cpu_root_attr_groups); |
282 | if (err) | ||
283 | return err; | ||
284 | |||
255 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) | 285 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) |
256 | if (!err) | 286 | err = sched_create_sysfs_power_savings_entries(cpu_subsys.dev_root); |
257 | err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); | ||
258 | #endif | 287 | #endif |
259 | |||
260 | return err; | 288 | return err; |
261 | } | 289 | } |
262 | |||
263 | static struct sysdev_class_attribute *cpu_sysdev_class_attrs[] = { | ||
264 | #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE | ||
265 | &attr_probe, | ||
266 | &attr_release, | ||
267 | #endif | ||
268 | &cpu_attrs[0].attr, | ||
269 | &cpu_attrs[1].attr, | ||
270 | &cpu_attrs[2].attr, | ||
271 | &attr_kernel_max, | ||
272 | &attr_offline, | ||
273 | NULL | ||
274 | }; | ||
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 393f450cf43c..8493536ea55b 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
@@ -413,10 +413,9 @@ static int devtmpfsd(void *p) | |||
413 | } | 413 | } |
414 | spin_lock(&req_lock); | 414 | spin_lock(&req_lock); |
415 | } | 415 | } |
416 | set_current_state(TASK_INTERRUPTIBLE); | 416 | __set_current_state(TASK_INTERRUPTIBLE); |
417 | spin_unlock(&req_lock); | 417 | spin_unlock(&req_lock); |
418 | schedule(); | 418 | schedule(); |
419 | __set_current_state(TASK_RUNNING); | ||
420 | } | 419 | } |
421 | return 0; | 420 | return 0; |
422 | out: | 421 | out: |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 06ed6b4e7df5..3719c94be19c 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -226,13 +226,13 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
226 | int loading = simple_strtol(buf, NULL, 10); | 226 | int loading = simple_strtol(buf, NULL, 10); |
227 | int i; | 227 | int i; |
228 | 228 | ||
229 | mutex_lock(&fw_lock); | ||
230 | |||
231 | if (!fw_priv->fw) | ||
232 | goto out; | ||
233 | |||
229 | switch (loading) { | 234 | switch (loading) { |
230 | case 1: | 235 | case 1: |
231 | mutex_lock(&fw_lock); | ||
232 | if (!fw_priv->fw) { | ||
233 | mutex_unlock(&fw_lock); | ||
234 | break; | ||
235 | } | ||
236 | firmware_free_data(fw_priv->fw); | 236 | firmware_free_data(fw_priv->fw); |
237 | memset(fw_priv->fw, 0, sizeof(struct firmware)); | 237 | memset(fw_priv->fw, 0, sizeof(struct firmware)); |
238 | /* If the pages are not owned by 'struct firmware' */ | 238 | /* If the pages are not owned by 'struct firmware' */ |
@@ -243,7 +243,6 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
243 | fw_priv->page_array_size = 0; | 243 | fw_priv->page_array_size = 0; |
244 | fw_priv->nr_pages = 0; | 244 | fw_priv->nr_pages = 0; |
245 | set_bit(FW_STATUS_LOADING, &fw_priv->status); | 245 | set_bit(FW_STATUS_LOADING, &fw_priv->status); |
246 | mutex_unlock(&fw_lock); | ||
247 | break; | 246 | break; |
248 | case 0: | 247 | case 0: |
249 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { | 248 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { |
@@ -274,7 +273,8 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
274 | fw_load_abort(fw_priv); | 273 | fw_load_abort(fw_priv); |
275 | break; | 274 | break; |
276 | } | 275 | } |
277 | 276 | out: | |
277 | mutex_unlock(&fw_lock); | ||
278 | return count; | 278 | return count; |
279 | } | 279 | } |
280 | 280 | ||
diff --git a/drivers/base/init.c b/drivers/base/init.c index c8a934e79421..c16f0b808a17 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c | |||
@@ -31,7 +31,6 @@ void __init driver_init(void) | |||
31 | * core core pieces. | 31 | * core core pieces. |
32 | */ | 32 | */ |
33 | platform_bus_init(); | 33 | platform_bus_init(); |
34 | system_bus_init(); | ||
35 | cpu_dev_init(); | 34 | cpu_dev_init(); |
36 | memory_dev_init(); | 35 | memory_dev_init(); |
37 | } | 36 | } |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8272d92d22c0..f17e3ea041c0 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/base/memory.c - basic Memory class support | 2 | * Memory subsystem support |
3 | * | 3 | * |
4 | * Written by Matt Tolentino <matthew.e.tolentino@intel.com> | 4 | * Written by Matt Tolentino <matthew.e.tolentino@intel.com> |
5 | * Dave Hansen <haveblue@us.ibm.com> | 5 | * Dave Hansen <haveblue@us.ibm.com> |
@@ -10,7 +10,6 @@ | |||
10 | * SPARSEMEM should be contained here, or in mm/memory_hotplug.c. | 10 | * SPARSEMEM should be contained here, or in mm/memory_hotplug.c. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/sysdev.h> | ||
14 | #include <linux/module.h> | 13 | #include <linux/module.h> |
15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
16 | #include <linux/topology.h> | 15 | #include <linux/topology.h> |
@@ -38,26 +37,9 @@ static inline int base_memory_block_id(int section_nr) | |||
38 | return section_nr / sections_per_block; | 37 | return section_nr / sections_per_block; |
39 | } | 38 | } |
40 | 39 | ||
41 | static struct sysdev_class memory_sysdev_class = { | 40 | static struct bus_type memory_subsys = { |
42 | .name = MEMORY_CLASS_NAME, | 41 | .name = MEMORY_CLASS_NAME, |
43 | }; | 42 | .dev_name = MEMORY_CLASS_NAME, |
44 | |||
45 | static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) | ||
46 | { | ||
47 | return MEMORY_CLASS_NAME; | ||
48 | } | ||
49 | |||
50 | static int memory_uevent(struct kset *kset, struct kobject *obj, | ||
51 | struct kobj_uevent_env *env) | ||
52 | { | ||
53 | int retval = 0; | ||
54 | |||
55 | return retval; | ||
56 | } | ||
57 | |||
58 | static const struct kset_uevent_ops memory_uevent_ops = { | ||
59 | .name = memory_uevent_name, | ||
60 | .uevent = memory_uevent, | ||
61 | }; | 43 | }; |
62 | 44 | ||
63 | static BLOCKING_NOTIFIER_HEAD(memory_chain); | 45 | static BLOCKING_NOTIFIER_HEAD(memory_chain); |
@@ -96,21 +78,21 @@ int register_memory(struct memory_block *memory) | |||
96 | { | 78 | { |
97 | int error; | 79 | int error; |
98 | 80 | ||
99 | memory->sysdev.cls = &memory_sysdev_class; | 81 | memory->dev.bus = &memory_subsys; |
100 | memory->sysdev.id = memory->start_section_nr / sections_per_block; | 82 | memory->dev.id = memory->start_section_nr / sections_per_block; |
101 | 83 | ||
102 | error = sysdev_register(&memory->sysdev); | 84 | error = device_register(&memory->dev); |
103 | return error; | 85 | return error; |
104 | } | 86 | } |
105 | 87 | ||
106 | static void | 88 | static void |
107 | unregister_memory(struct memory_block *memory) | 89 | unregister_memory(struct memory_block *memory) |
108 | { | 90 | { |
109 | BUG_ON(memory->sysdev.cls != &memory_sysdev_class); | 91 | BUG_ON(memory->dev.bus != &memory_subsys); |
110 | 92 | ||
111 | /* drop the ref. we got in remove_memory_block() */ | 93 | /* drop the ref. we got in remove_memory_block() */ |
112 | kobject_put(&memory->sysdev.kobj); | 94 | kobject_put(&memory->dev.kobj); |
113 | sysdev_unregister(&memory->sysdev); | 95 | device_unregister(&memory->dev); |
114 | } | 96 | } |
115 | 97 | ||
116 | unsigned long __weak memory_block_size_bytes(void) | 98 | unsigned long __weak memory_block_size_bytes(void) |
@@ -138,22 +120,22 @@ static unsigned long get_memory_block_size(void) | |||
138 | * uses. | 120 | * uses. |
139 | */ | 121 | */ |
140 | 122 | ||
141 | static ssize_t show_mem_start_phys_index(struct sys_device *dev, | 123 | static ssize_t show_mem_start_phys_index(struct device *dev, |
142 | struct sysdev_attribute *attr, char *buf) | 124 | struct device_attribute *attr, char *buf) |
143 | { | 125 | { |
144 | struct memory_block *mem = | 126 | struct memory_block *mem = |
145 | container_of(dev, struct memory_block, sysdev); | 127 | container_of(dev, struct memory_block, dev); |
146 | unsigned long phys_index; | 128 | unsigned long phys_index; |
147 | 129 | ||
148 | phys_index = mem->start_section_nr / sections_per_block; | 130 | phys_index = mem->start_section_nr / sections_per_block; |
149 | return sprintf(buf, "%08lx\n", phys_index); | 131 | return sprintf(buf, "%08lx\n", phys_index); |
150 | } | 132 | } |
151 | 133 | ||
152 | static ssize_t show_mem_end_phys_index(struct sys_device *dev, | 134 | static ssize_t show_mem_end_phys_index(struct device *dev, |
153 | struct sysdev_attribute *attr, char *buf) | 135 | struct device_attribute *attr, char *buf) |
154 | { | 136 | { |
155 | struct memory_block *mem = | 137 | struct memory_block *mem = |
156 | container_of(dev, struct memory_block, sysdev); | 138 | container_of(dev, struct memory_block, dev); |
157 | unsigned long phys_index; | 139 | unsigned long phys_index; |
158 | 140 | ||
159 | phys_index = mem->end_section_nr / sections_per_block; | 141 | phys_index = mem->end_section_nr / sections_per_block; |
@@ -163,13 +145,13 @@ static ssize_t show_mem_end_phys_index(struct sys_device *dev, | |||
163 | /* | 145 | /* |
164 | * Show whether the section of memory is likely to be hot-removable | 146 | * Show whether the section of memory is likely to be hot-removable |
165 | */ | 147 | */ |
166 | static ssize_t show_mem_removable(struct sys_device *dev, | 148 | static ssize_t show_mem_removable(struct device *dev, |
167 | struct sysdev_attribute *attr, char *buf) | 149 | struct device_attribute *attr, char *buf) |
168 | { | 150 | { |
169 | unsigned long i, pfn; | 151 | unsigned long i, pfn; |
170 | int ret = 1; | 152 | int ret = 1; |
171 | struct memory_block *mem = | 153 | struct memory_block *mem = |
172 | container_of(dev, struct memory_block, sysdev); | 154 | container_of(dev, struct memory_block, dev); |
173 | 155 | ||
174 | for (i = 0; i < sections_per_block; i++) { | 156 | for (i = 0; i < sections_per_block; i++) { |
175 | pfn = section_nr_to_pfn(mem->start_section_nr + i); | 157 | pfn = section_nr_to_pfn(mem->start_section_nr + i); |
@@ -182,11 +164,11 @@ static ssize_t show_mem_removable(struct sys_device *dev, | |||
182 | /* | 164 | /* |
183 | * online, offline, going offline, etc. | 165 | * online, offline, going offline, etc. |
184 | */ | 166 | */ |
185 | static ssize_t show_mem_state(struct sys_device *dev, | 167 | static ssize_t show_mem_state(struct device *dev, |
186 | struct sysdev_attribute *attr, char *buf) | 168 | struct device_attribute *attr, char *buf) |
187 | { | 169 | { |
188 | struct memory_block *mem = | 170 | struct memory_block *mem = |
189 | container_of(dev, struct memory_block, sysdev); | 171 | container_of(dev, struct memory_block, dev); |
190 | ssize_t len = 0; | 172 | ssize_t len = 0; |
191 | 173 | ||
192 | /* | 174 | /* |
@@ -324,13 +306,13 @@ out: | |||
324 | } | 306 | } |
325 | 307 | ||
326 | static ssize_t | 308 | static ssize_t |
327 | store_mem_state(struct sys_device *dev, | 309 | store_mem_state(struct device *dev, |
328 | struct sysdev_attribute *attr, const char *buf, size_t count) | 310 | struct device_attribute *attr, const char *buf, size_t count) |
329 | { | 311 | { |
330 | struct memory_block *mem; | 312 | struct memory_block *mem; |
331 | int ret = -EINVAL; | 313 | int ret = -EINVAL; |
332 | 314 | ||
333 | mem = container_of(dev, struct memory_block, sysdev); | 315 | mem = container_of(dev, struct memory_block, dev); |
334 | 316 | ||
335 | if (!strncmp(buf, "online", min((int)count, 6))) | 317 | if (!strncmp(buf, "online", min((int)count, 6))) |
336 | ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); | 318 | ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); |
@@ -351,41 +333,41 @@ store_mem_state(struct sys_device *dev, | |||
351 | * s.t. if I offline all of these sections I can then | 333 | * s.t. if I offline all of these sections I can then |
352 | * remove the physical device? | 334 | * remove the physical device? |
353 | */ | 335 | */ |
354 | static ssize_t show_phys_device(struct sys_device *dev, | 336 | static ssize_t show_phys_device(struct device *dev, |
355 | struct sysdev_attribute *attr, char *buf) | 337 | struct device_attribute *attr, char *buf) |
356 | { | 338 | { |
357 | struct memory_block *mem = | 339 | struct memory_block *mem = |
358 | container_of(dev, struct memory_block, sysdev); | 340 | container_of(dev, struct memory_block, dev); |
359 | return sprintf(buf, "%d\n", mem->phys_device); | 341 | return sprintf(buf, "%d\n", mem->phys_device); |
360 | } | 342 | } |
361 | 343 | ||
362 | static SYSDEV_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL); | 344 | static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL); |
363 | static SYSDEV_ATTR(end_phys_index, 0444, show_mem_end_phys_index, NULL); | 345 | static DEVICE_ATTR(end_phys_index, 0444, show_mem_end_phys_index, NULL); |
364 | static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); | 346 | static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state); |
365 | static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); | 347 | static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL); |
366 | static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); | 348 | static DEVICE_ATTR(removable, 0444, show_mem_removable, NULL); |
367 | 349 | ||
368 | #define mem_create_simple_file(mem, attr_name) \ | 350 | #define mem_create_simple_file(mem, attr_name) \ |
369 | sysdev_create_file(&mem->sysdev, &attr_##attr_name) | 351 | device_create_file(&mem->dev, &dev_attr_##attr_name) |
370 | #define mem_remove_simple_file(mem, attr_name) \ | 352 | #define mem_remove_simple_file(mem, attr_name) \ |
371 | sysdev_remove_file(&mem->sysdev, &attr_##attr_name) | 353 | device_remove_file(&mem->dev, &dev_attr_##attr_name) |
372 | 354 | ||
373 | /* | 355 | /* |
374 | * Block size attribute stuff | 356 | * Block size attribute stuff |
375 | */ | 357 | */ |
376 | static ssize_t | 358 | static ssize_t |
377 | print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr, | 359 | print_block_size(struct device *dev, struct device_attribute *attr, |
378 | char *buf) | 360 | char *buf) |
379 | { | 361 | { |
380 | return sprintf(buf, "%lx\n", get_memory_block_size()); | 362 | return sprintf(buf, "%lx\n", get_memory_block_size()); |
381 | } | 363 | } |
382 | 364 | ||
383 | static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); | 365 | static DEVICE_ATTR(block_size_bytes, 0444, print_block_size, NULL); |
384 | 366 | ||
385 | static int block_size_init(void) | 367 | static int block_size_init(void) |
386 | { | 368 | { |
387 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, | 369 | return device_create_file(memory_subsys.dev_root, |
388 | &attr_block_size_bytes.attr); | 370 | &dev_attr_block_size_bytes); |
389 | } | 371 | } |
390 | 372 | ||
391 | /* | 373 | /* |
@@ -396,7 +378,7 @@ static int block_size_init(void) | |||
396 | */ | 378 | */ |
397 | #ifdef CONFIG_ARCH_MEMORY_PROBE | 379 | #ifdef CONFIG_ARCH_MEMORY_PROBE |
398 | static ssize_t | 380 | static ssize_t |
399 | memory_probe_store(struct class *class, struct class_attribute *attr, | 381 | memory_probe_store(struct device *dev, struct device_attribute *attr, |
400 | const char *buf, size_t count) | 382 | const char *buf, size_t count) |
401 | { | 383 | { |
402 | u64 phys_addr; | 384 | u64 phys_addr; |
@@ -423,12 +405,11 @@ memory_probe_store(struct class *class, struct class_attribute *attr, | |||
423 | out: | 405 | out: |
424 | return ret; | 406 | return ret; |
425 | } | 407 | } |
426 | static CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store); | 408 | static DEVICE_ATTR(probe, S_IWUSR, NULL, memory_probe_store); |
427 | 409 | ||
428 | static int memory_probe_init(void) | 410 | static int memory_probe_init(void) |
429 | { | 411 | { |
430 | return sysfs_create_file(&memory_sysdev_class.kset.kobj, | 412 | return device_create_file(memory_subsys.dev_root, &dev_attr_probe); |
431 | &class_attr_probe.attr); | ||
432 | } | 413 | } |
433 | #else | 414 | #else |
434 | static inline int memory_probe_init(void) | 415 | static inline int memory_probe_init(void) |
@@ -444,8 +425,8 @@ static inline int memory_probe_init(void) | |||
444 | 425 | ||
445 | /* Soft offline a page */ | 426 | /* Soft offline a page */ |
446 | static ssize_t | 427 | static ssize_t |
447 | store_soft_offline_page(struct class *class, | 428 | store_soft_offline_page(struct device *dev, |
448 | struct class_attribute *attr, | 429 | struct device_attribute *attr, |
449 | const char *buf, size_t count) | 430 | const char *buf, size_t count) |
450 | { | 431 | { |
451 | int ret; | 432 | int ret; |
@@ -463,8 +444,8 @@ store_soft_offline_page(struct class *class, | |||
463 | 444 | ||
464 | /* Forcibly offline a page, including killing processes. */ | 445 | /* Forcibly offline a page, including killing processes. */ |
465 | static ssize_t | 446 | static ssize_t |
466 | store_hard_offline_page(struct class *class, | 447 | store_hard_offline_page(struct device *dev, |
467 | struct class_attribute *attr, | 448 | struct device_attribute *attr, |
468 | const char *buf, size_t count) | 449 | const char *buf, size_t count) |
469 | { | 450 | { |
470 | int ret; | 451 | int ret; |
@@ -478,18 +459,18 @@ store_hard_offline_page(struct class *class, | |||
478 | return ret ? ret : count; | 459 | return ret ? ret : count; |
479 | } | 460 | } |
480 | 461 | ||
481 | static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); | 462 | static DEVICE_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); |
482 | static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); | 463 | static DEVICE_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); |
483 | 464 | ||
484 | static __init int memory_fail_init(void) | 465 | static __init int memory_fail_init(void) |
485 | { | 466 | { |
486 | int err; | 467 | int err; |
487 | 468 | ||
488 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, | 469 | err = device_create_file(memory_subsys.dev_root, |
489 | &class_attr_soft_offline_page.attr); | 470 | &dev_attr_soft_offline_page); |
490 | if (!err) | 471 | if (!err) |
491 | err = sysfs_create_file(&memory_sysdev_class.kset.kobj, | 472 | err = device_create_file(memory_subsys.dev_root, |
492 | &class_attr_hard_offline_page.attr); | 473 | &dev_attr_hard_offline_page); |
493 | return err; | 474 | return err; |
494 | } | 475 | } |
495 | #else | 476 | #else |
@@ -509,31 +490,23 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) | |||
509 | return 0; | 490 | return 0; |
510 | } | 491 | } |
511 | 492 | ||
493 | /* | ||
494 | * A reference for the returned object is held and the reference for the | ||
495 | * hinted object is released. | ||
496 | */ | ||
512 | struct memory_block *find_memory_block_hinted(struct mem_section *section, | 497 | struct memory_block *find_memory_block_hinted(struct mem_section *section, |
513 | struct memory_block *hint) | 498 | struct memory_block *hint) |
514 | { | 499 | { |
515 | struct kobject *kobj; | ||
516 | struct sys_device *sysdev; | ||
517 | struct memory_block *mem; | ||
518 | char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1]; | ||
519 | int block_id = base_memory_block_id(__section_nr(section)); | 500 | int block_id = base_memory_block_id(__section_nr(section)); |
501 | struct device *hintdev = hint ? &hint->dev : NULL; | ||
502 | struct device *dev; | ||
520 | 503 | ||
521 | kobj = hint ? &hint->sysdev.kobj : NULL; | 504 | dev = subsys_find_device_by_id(&memory_subsys, block_id, hintdev); |
522 | 505 | if (hint) | |
523 | /* | 506 | put_device(&hint->dev); |
524 | * This only works because we know that section == sysdev->id | 507 | if (!dev) |
525 | * slightly redundant with sysdev_register() | ||
526 | */ | ||
527 | sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, block_id); | ||
528 | |||
529 | kobj = kset_find_obj_hinted(&memory_sysdev_class.kset, name, kobj); | ||
530 | if (!kobj) | ||
531 | return NULL; | 508 | return NULL; |
532 | 509 | return container_of(dev, struct memory_block, dev); | |
533 | sysdev = container_of(kobj, struct sys_device, kobj); | ||
534 | mem = container_of(sysdev, struct memory_block, sysdev); | ||
535 | |||
536 | return mem; | ||
537 | } | 510 | } |
538 | 511 | ||
539 | /* | 512 | /* |
@@ -542,7 +515,7 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section, | |||
542 | * this gets to be a real problem, we can always use a radix | 515 | * this gets to be a real problem, we can always use a radix |
543 | * tree or something here. | 516 | * tree or something here. |
544 | * | 517 | * |
545 | * This could be made generic for all sysdev classes. | 518 | * This could be made generic for all device subsystems. |
546 | */ | 519 | */ |
547 | struct memory_block *find_memory_block(struct mem_section *section) | 520 | struct memory_block *find_memory_block(struct mem_section *section) |
548 | { | 521 | { |
@@ -598,7 +571,7 @@ static int add_memory_section(int nid, struct mem_section *section, | |||
598 | mem = find_memory_block(section); | 571 | mem = find_memory_block(section); |
599 | if (mem) { | 572 | if (mem) { |
600 | mem->section_count++; | 573 | mem->section_count++; |
601 | kobject_put(&mem->sysdev.kobj); | 574 | kobject_put(&mem->dev.kobj); |
602 | } else | 575 | } else |
603 | ret = init_memory_block(&mem, section, state); | 576 | ret = init_memory_block(&mem, section, state); |
604 | 577 | ||
@@ -631,7 +604,7 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
631 | unregister_memory(mem); | 604 | unregister_memory(mem); |
632 | kfree(mem); | 605 | kfree(mem); |
633 | } else | 606 | } else |
634 | kobject_put(&mem->sysdev.kobj); | 607 | kobject_put(&mem->dev.kobj); |
635 | 608 | ||
636 | mutex_unlock(&mem_sysfs_mutex); | 609 | mutex_unlock(&mem_sysfs_mutex); |
637 | return 0; | 610 | return 0; |
@@ -664,8 +637,7 @@ int __init memory_dev_init(void) | |||
664 | int err; | 637 | int err; |
665 | unsigned long block_sz; | 638 | unsigned long block_sz; |
666 | 639 | ||
667 | memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; | 640 | ret = subsys_system_register(&memory_subsys, NULL); |
668 | ret = sysdev_class_register(&memory_sysdev_class); | ||
669 | if (ret) | 641 | if (ret) |
670 | goto out; | 642 | goto out; |
671 | 643 | ||
diff --git a/drivers/base/node.c b/drivers/base/node.c index 5693ecee9a40..44f427a66117 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -1,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/base/node.c - basic Node class support | 2 | * Basic Node interface support |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/sysdev.h> | ||
6 | #include <linux/module.h> | 5 | #include <linux/module.h> |
7 | #include <linux/init.h> | 6 | #include <linux/init.h> |
8 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
@@ -19,18 +18,16 @@ | |||
19 | #include <linux/swap.h> | 18 | #include <linux/swap.h> |
20 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
21 | 20 | ||
22 | static struct sysdev_class_attribute *node_state_attrs[]; | 21 | static struct bus_type node_subsys = { |
23 | |||
24 | static struct sysdev_class node_class = { | ||
25 | .name = "node", | 22 | .name = "node", |
26 | .attrs = node_state_attrs, | 23 | .dev_name = "node", |
27 | }; | 24 | }; |
28 | 25 | ||
29 | 26 | ||
30 | static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) | 27 | static ssize_t node_read_cpumap(struct device *dev, int type, char *buf) |
31 | { | 28 | { |
32 | struct node *node_dev = to_node(dev); | 29 | struct node *node_dev = to_node(dev); |
33 | const struct cpumask *mask = cpumask_of_node(node_dev->sysdev.id); | 30 | const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); |
34 | int len; | 31 | int len; |
35 | 32 | ||
36 | /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ | 33 | /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ |
@@ -44,23 +41,23 @@ static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) | |||
44 | return len; | 41 | return len; |
45 | } | 42 | } |
46 | 43 | ||
47 | static inline ssize_t node_read_cpumask(struct sys_device *dev, | 44 | static inline ssize_t node_read_cpumask(struct device *dev, |
48 | struct sysdev_attribute *attr, char *buf) | 45 | struct device_attribute *attr, char *buf) |
49 | { | 46 | { |
50 | return node_read_cpumap(dev, 0, buf); | 47 | return node_read_cpumap(dev, 0, buf); |
51 | } | 48 | } |
52 | static inline ssize_t node_read_cpulist(struct sys_device *dev, | 49 | static inline ssize_t node_read_cpulist(struct device *dev, |
53 | struct sysdev_attribute *attr, char *buf) | 50 | struct device_attribute *attr, char *buf) |
54 | { | 51 | { |
55 | return node_read_cpumap(dev, 1, buf); | 52 | return node_read_cpumap(dev, 1, buf); |
56 | } | 53 | } |
57 | 54 | ||
58 | static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); | 55 | static DEVICE_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); |
59 | static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); | 56 | static DEVICE_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); |
60 | 57 | ||
61 | #define K(x) ((x) << (PAGE_SHIFT - 10)) | 58 | #define K(x) ((x) << (PAGE_SHIFT - 10)) |
62 | static ssize_t node_read_meminfo(struct sys_device * dev, | 59 | static ssize_t node_read_meminfo(struct device *dev, |
63 | struct sysdev_attribute *attr, char * buf) | 60 | struct device_attribute *attr, char *buf) |
64 | { | 61 | { |
65 | int n; | 62 | int n; |
66 | int nid = dev->id; | 63 | int nid = dev->id; |
@@ -157,10 +154,10 @@ static ssize_t node_read_meminfo(struct sys_device * dev, | |||
157 | } | 154 | } |
158 | 155 | ||
159 | #undef K | 156 | #undef K |
160 | static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); | 157 | static DEVICE_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); |
161 | 158 | ||
162 | static ssize_t node_read_numastat(struct sys_device * dev, | 159 | static ssize_t node_read_numastat(struct device *dev, |
163 | struct sysdev_attribute *attr, char * buf) | 160 | struct device_attribute *attr, char *buf) |
164 | { | 161 | { |
165 | return sprintf(buf, | 162 | return sprintf(buf, |
166 | "numa_hit %lu\n" | 163 | "numa_hit %lu\n" |
@@ -176,10 +173,10 @@ static ssize_t node_read_numastat(struct sys_device * dev, | |||
176 | node_page_state(dev->id, NUMA_LOCAL), | 173 | node_page_state(dev->id, NUMA_LOCAL), |
177 | node_page_state(dev->id, NUMA_OTHER)); | 174 | node_page_state(dev->id, NUMA_OTHER)); |
178 | } | 175 | } |
179 | static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); | 176 | static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); |
180 | 177 | ||
181 | static ssize_t node_read_vmstat(struct sys_device *dev, | 178 | static ssize_t node_read_vmstat(struct device *dev, |
182 | struct sysdev_attribute *attr, char *buf) | 179 | struct device_attribute *attr, char *buf) |
183 | { | 180 | { |
184 | int nid = dev->id; | 181 | int nid = dev->id; |
185 | int i; | 182 | int i; |
@@ -191,10 +188,10 @@ static ssize_t node_read_vmstat(struct sys_device *dev, | |||
191 | 188 | ||
192 | return n; | 189 | return n; |
193 | } | 190 | } |
194 | static SYSDEV_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL); | 191 | static DEVICE_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL); |
195 | 192 | ||
196 | static ssize_t node_read_distance(struct sys_device * dev, | 193 | static ssize_t node_read_distance(struct device *dev, |
197 | struct sysdev_attribute *attr, char * buf) | 194 | struct device_attribute *attr, char * buf) |
198 | { | 195 | { |
199 | int nid = dev->id; | 196 | int nid = dev->id; |
200 | int len = 0; | 197 | int len = 0; |
@@ -212,7 +209,7 @@ static ssize_t node_read_distance(struct sys_device * dev, | |||
212 | len += sprintf(buf + len, "\n"); | 209 | len += sprintf(buf + len, "\n"); |
213 | return len; | 210 | return len; |
214 | } | 211 | } |
215 | static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL); | 212 | static DEVICE_ATTR(distance, S_IRUGO, node_read_distance, NULL); |
216 | 213 | ||
217 | #ifdef CONFIG_HUGETLBFS | 214 | #ifdef CONFIG_HUGETLBFS |
218 | /* | 215 | /* |
@@ -230,7 +227,7 @@ static node_registration_func_t __hugetlb_unregister_node; | |||
230 | static inline bool hugetlb_register_node(struct node *node) | 227 | static inline bool hugetlb_register_node(struct node *node) |
231 | { | 228 | { |
232 | if (__hugetlb_register_node && | 229 | if (__hugetlb_register_node && |
233 | node_state(node->sysdev.id, N_HIGH_MEMORY)) { | 230 | node_state(node->dev.id, N_HIGH_MEMORY)) { |
234 | __hugetlb_register_node(node); | 231 | __hugetlb_register_node(node); |
235 | return true; | 232 | return true; |
236 | } | 233 | } |
@@ -266,17 +263,17 @@ int register_node(struct node *node, int num, struct node *parent) | |||
266 | { | 263 | { |
267 | int error; | 264 | int error; |
268 | 265 | ||
269 | node->sysdev.id = num; | 266 | node->dev.id = num; |
270 | node->sysdev.cls = &node_class; | 267 | node->dev.bus = &node_subsys; |
271 | error = sysdev_register(&node->sysdev); | 268 | error = device_register(&node->dev); |
272 | 269 | ||
273 | if (!error){ | 270 | if (!error){ |
274 | sysdev_create_file(&node->sysdev, &attr_cpumap); | 271 | device_create_file(&node->dev, &dev_attr_cpumap); |
275 | sysdev_create_file(&node->sysdev, &attr_cpulist); | 272 | device_create_file(&node->dev, &dev_attr_cpulist); |
276 | sysdev_create_file(&node->sysdev, &attr_meminfo); | 273 | device_create_file(&node->dev, &dev_attr_meminfo); |
277 | sysdev_create_file(&node->sysdev, &attr_numastat); | 274 | device_create_file(&node->dev, &dev_attr_numastat); |
278 | sysdev_create_file(&node->sysdev, &attr_distance); | 275 | device_create_file(&node->dev, &dev_attr_distance); |
279 | sysdev_create_file(&node->sysdev, &attr_vmstat); | 276 | device_create_file(&node->dev, &dev_attr_vmstat); |
280 | 277 | ||
281 | scan_unevictable_register_node(node); | 278 | scan_unevictable_register_node(node); |
282 | 279 | ||
@@ -296,17 +293,17 @@ int register_node(struct node *node, int num, struct node *parent) | |||
296 | */ | 293 | */ |
297 | void unregister_node(struct node *node) | 294 | void unregister_node(struct node *node) |
298 | { | 295 | { |
299 | sysdev_remove_file(&node->sysdev, &attr_cpumap); | 296 | device_remove_file(&node->dev, &dev_attr_cpumap); |
300 | sysdev_remove_file(&node->sysdev, &attr_cpulist); | 297 | device_remove_file(&node->dev, &dev_attr_cpulist); |
301 | sysdev_remove_file(&node->sysdev, &attr_meminfo); | 298 | device_remove_file(&node->dev, &dev_attr_meminfo); |
302 | sysdev_remove_file(&node->sysdev, &attr_numastat); | 299 | device_remove_file(&node->dev, &dev_attr_numastat); |
303 | sysdev_remove_file(&node->sysdev, &attr_distance); | 300 | device_remove_file(&node->dev, &dev_attr_distance); |
304 | sysdev_remove_file(&node->sysdev, &attr_vmstat); | 301 | device_remove_file(&node->dev, &dev_attr_vmstat); |
305 | 302 | ||
306 | scan_unevictable_unregister_node(node); | 303 | scan_unevictable_unregister_node(node); |
307 | hugetlb_unregister_node(node); /* no-op, if memoryless node */ | 304 | hugetlb_unregister_node(node); /* no-op, if memoryless node */ |
308 | 305 | ||
309 | sysdev_unregister(&node->sysdev); | 306 | device_unregister(&node->dev); |
310 | } | 307 | } |
311 | 308 | ||
312 | struct node node_devices[MAX_NUMNODES]; | 309 | struct node node_devices[MAX_NUMNODES]; |
@@ -317,41 +314,41 @@ struct node node_devices[MAX_NUMNODES]; | |||
317 | int register_cpu_under_node(unsigned int cpu, unsigned int nid) | 314 | int register_cpu_under_node(unsigned int cpu, unsigned int nid) |
318 | { | 315 | { |
319 | int ret; | 316 | int ret; |
320 | struct sys_device *obj; | 317 | struct device *obj; |
321 | 318 | ||
322 | if (!node_online(nid)) | 319 | if (!node_online(nid)) |
323 | return 0; | 320 | return 0; |
324 | 321 | ||
325 | obj = get_cpu_sysdev(cpu); | 322 | obj = get_cpu_device(cpu); |
326 | if (!obj) | 323 | if (!obj) |
327 | return 0; | 324 | return 0; |
328 | 325 | ||
329 | ret = sysfs_create_link(&node_devices[nid].sysdev.kobj, | 326 | ret = sysfs_create_link(&node_devices[nid].dev.kobj, |
330 | &obj->kobj, | 327 | &obj->kobj, |
331 | kobject_name(&obj->kobj)); | 328 | kobject_name(&obj->kobj)); |
332 | if (ret) | 329 | if (ret) |
333 | return ret; | 330 | return ret; |
334 | 331 | ||
335 | return sysfs_create_link(&obj->kobj, | 332 | return sysfs_create_link(&obj->kobj, |
336 | &node_devices[nid].sysdev.kobj, | 333 | &node_devices[nid].dev.kobj, |
337 | kobject_name(&node_devices[nid].sysdev.kobj)); | 334 | kobject_name(&node_devices[nid].dev.kobj)); |
338 | } | 335 | } |
339 | 336 | ||
340 | int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) | 337 | int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) |
341 | { | 338 | { |
342 | struct sys_device *obj; | 339 | struct device *obj; |
343 | 340 | ||
344 | if (!node_online(nid)) | 341 | if (!node_online(nid)) |
345 | return 0; | 342 | return 0; |
346 | 343 | ||
347 | obj = get_cpu_sysdev(cpu); | 344 | obj = get_cpu_device(cpu); |
348 | if (!obj) | 345 | if (!obj) |
349 | return 0; | 346 | return 0; |
350 | 347 | ||
351 | sysfs_remove_link(&node_devices[nid].sysdev.kobj, | 348 | sysfs_remove_link(&node_devices[nid].dev.kobj, |
352 | kobject_name(&obj->kobj)); | 349 | kobject_name(&obj->kobj)); |
353 | sysfs_remove_link(&obj->kobj, | 350 | sysfs_remove_link(&obj->kobj, |
354 | kobject_name(&node_devices[nid].sysdev.kobj)); | 351 | kobject_name(&node_devices[nid].dev.kobj)); |
355 | 352 | ||
356 | return 0; | 353 | return 0; |
357 | } | 354 | } |
@@ -393,15 +390,15 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid) | |||
393 | continue; | 390 | continue; |
394 | if (page_nid != nid) | 391 | if (page_nid != nid) |
395 | continue; | 392 | continue; |
396 | ret = sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj, | 393 | ret = sysfs_create_link_nowarn(&node_devices[nid].dev.kobj, |
397 | &mem_blk->sysdev.kobj, | 394 | &mem_blk->dev.kobj, |
398 | kobject_name(&mem_blk->sysdev.kobj)); | 395 | kobject_name(&mem_blk->dev.kobj)); |
399 | if (ret) | 396 | if (ret) |
400 | return ret; | 397 | return ret; |
401 | 398 | ||
402 | return sysfs_create_link_nowarn(&mem_blk->sysdev.kobj, | 399 | return sysfs_create_link_nowarn(&mem_blk->dev.kobj, |
403 | &node_devices[nid].sysdev.kobj, | 400 | &node_devices[nid].dev.kobj, |
404 | kobject_name(&node_devices[nid].sysdev.kobj)); | 401 | kobject_name(&node_devices[nid].dev.kobj)); |
405 | } | 402 | } |
406 | /* mem section does not span the specified node */ | 403 | /* mem section does not span the specified node */ |
407 | return 0; | 404 | return 0; |
@@ -434,10 +431,10 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, | |||
434 | continue; | 431 | continue; |
435 | if (node_test_and_set(nid, *unlinked_nodes)) | 432 | if (node_test_and_set(nid, *unlinked_nodes)) |
436 | continue; | 433 | continue; |
437 | sysfs_remove_link(&node_devices[nid].sysdev.kobj, | 434 | sysfs_remove_link(&node_devices[nid].dev.kobj, |
438 | kobject_name(&mem_blk->sysdev.kobj)); | 435 | kobject_name(&mem_blk->dev.kobj)); |
439 | sysfs_remove_link(&mem_blk->sysdev.kobj, | 436 | sysfs_remove_link(&mem_blk->dev.kobj, |
440 | kobject_name(&node_devices[nid].sysdev.kobj)); | 437 | kobject_name(&node_devices[nid].dev.kobj)); |
441 | } | 438 | } |
442 | NODEMASK_FREE(unlinked_nodes); | 439 | NODEMASK_FREE(unlinked_nodes); |
443 | return 0; | 440 | return 0; |
@@ -468,7 +465,7 @@ static int link_mem_sections(int nid) | |||
468 | } | 465 | } |
469 | 466 | ||
470 | if (mem_blk) | 467 | if (mem_blk) |
471 | kobject_put(&mem_blk->sysdev.kobj); | 468 | kobject_put(&mem_blk->dev.kobj); |
472 | return err; | 469 | return err; |
473 | } | 470 | } |
474 | 471 | ||
@@ -596,19 +593,19 @@ static ssize_t print_nodes_state(enum node_states state, char *buf) | |||
596 | } | 593 | } |
597 | 594 | ||
598 | struct node_attr { | 595 | struct node_attr { |
599 | struct sysdev_class_attribute attr; | 596 | struct device_attribute attr; |
600 | enum node_states state; | 597 | enum node_states state; |
601 | }; | 598 | }; |
602 | 599 | ||
603 | static ssize_t show_node_state(struct sysdev_class *class, | 600 | static ssize_t show_node_state(struct device *dev, |
604 | struct sysdev_class_attribute *attr, char *buf) | 601 | struct device_attribute *attr, char *buf) |
605 | { | 602 | { |
606 | struct node_attr *na = container_of(attr, struct node_attr, attr); | 603 | struct node_attr *na = container_of(attr, struct node_attr, attr); |
607 | return print_nodes_state(na->state, buf); | 604 | return print_nodes_state(na->state, buf); |
608 | } | 605 | } |
609 | 606 | ||
610 | #define _NODE_ATTR(name, state) \ | 607 | #define _NODE_ATTR(name, state) \ |
611 | { _SYSDEV_CLASS_ATTR(name, 0444, show_node_state, NULL), state } | 608 | { __ATTR(name, 0444, show_node_state, NULL), state } |
612 | 609 | ||
613 | static struct node_attr node_state_attr[] = { | 610 | static struct node_attr node_state_attr[] = { |
614 | _NODE_ATTR(possible, N_POSSIBLE), | 611 | _NODE_ATTR(possible, N_POSSIBLE), |
@@ -620,17 +617,26 @@ static struct node_attr node_state_attr[] = { | |||
620 | #endif | 617 | #endif |
621 | }; | 618 | }; |
622 | 619 | ||
623 | static struct sysdev_class_attribute *node_state_attrs[] = { | 620 | static struct attribute *node_state_attrs[] = { |
624 | &node_state_attr[0].attr, | 621 | &node_state_attr[0].attr.attr, |
625 | &node_state_attr[1].attr, | 622 | &node_state_attr[1].attr.attr, |
626 | &node_state_attr[2].attr, | 623 | &node_state_attr[2].attr.attr, |
627 | &node_state_attr[3].attr, | 624 | &node_state_attr[3].attr.attr, |
628 | #ifdef CONFIG_HIGHMEM | 625 | #ifdef CONFIG_HIGHMEM |
629 | &node_state_attr[4].attr, | 626 | &node_state_attr[4].attr.attr, |
630 | #endif | 627 | #endif |
631 | NULL | 628 | NULL |
632 | }; | 629 | }; |
633 | 630 | ||
631 | static struct attribute_group memory_root_attr_group = { | ||
632 | .attrs = node_state_attrs, | ||
633 | }; | ||
634 | |||
635 | static const struct attribute_group *cpu_root_attr_groups[] = { | ||
636 | &memory_root_attr_group, | ||
637 | NULL, | ||
638 | }; | ||
639 | |||
634 | #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ | 640 | #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ |
635 | static int __init register_node_type(void) | 641 | static int __init register_node_type(void) |
636 | { | 642 | { |
@@ -639,7 +645,7 @@ static int __init register_node_type(void) | |||
639 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); | 645 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); |
640 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES); | 646 | BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES); |
641 | 647 | ||
642 | ret = sysdev_class_register(&node_class); | 648 | ret = subsys_system_register(&node_subsys, cpu_root_attr_groups); |
643 | if (!ret) { | 649 | if (!ret) { |
644 | hotplug_memory_notifier(node_memory_callback, | 650 | hotplug_memory_notifier(node_memory_callback, |
645 | NODE_CALLBACK_PRI); | 651 | NODE_CALLBACK_PRI); |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 7a24895543e7..a7c06374062e 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -383,7 +383,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); | |||
383 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | 383 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. |
384 | */ | 384 | */ |
385 | struct platform_device *platform_device_register_full( | 385 | struct platform_device *platform_device_register_full( |
386 | struct platform_device_info *pdevinfo) | 386 | const struct platform_device_info *pdevinfo) |
387 | { | 387 | { |
388 | int ret = -ENOMEM; | 388 | int ret = -ENOMEM; |
389 | struct platform_device *pdev; | 389 | struct platform_device *pdev; |
diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 9dff77bfe1e3..409f5ce78829 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c | |||
@@ -126,7 +126,7 @@ void sysdev_class_remove_file(struct sysdev_class *c, | |||
126 | } | 126 | } |
127 | EXPORT_SYMBOL_GPL(sysdev_class_remove_file); | 127 | EXPORT_SYMBOL_GPL(sysdev_class_remove_file); |
128 | 128 | ||
129 | static struct kset *system_kset; | 129 | extern struct kset *system_kset; |
130 | 130 | ||
131 | int sysdev_class_register(struct sysdev_class *cls) | 131 | int sysdev_class_register(struct sysdev_class *cls) |
132 | { | 132 | { |
@@ -331,14 +331,6 @@ void sysdev_unregister(struct sys_device *sysdev) | |||
331 | EXPORT_SYMBOL_GPL(sysdev_register); | 331 | EXPORT_SYMBOL_GPL(sysdev_register); |
332 | EXPORT_SYMBOL_GPL(sysdev_unregister); | 332 | EXPORT_SYMBOL_GPL(sysdev_unregister); |
333 | 333 | ||
334 | int __init system_bus_init(void) | ||
335 | { | ||
336 | system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj); | ||
337 | if (!system_kset) | ||
338 | return -ENOMEM; | ||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | #define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr) | 334 | #define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr) |
343 | 335 | ||
344 | ssize_t sysdev_store_ulong(struct sys_device *sysdev, | 336 | ssize_t sysdev_store_ulong(struct sys_device *sysdev, |
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index f6f37a05a0c3..ae989c57cd5e 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -23,7 +23,6 @@ | |||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include <linux/sysdev.h> | ||
27 | #include <linux/init.h> | 26 | #include <linux/init.h> |
28 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
29 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
@@ -32,14 +31,14 @@ | |||
32 | #include <linux/topology.h> | 31 | #include <linux/topology.h> |
33 | 32 | ||
34 | #define define_one_ro_named(_name, _func) \ | 33 | #define define_one_ro_named(_name, _func) \ |
35 | static SYSDEV_ATTR(_name, 0444, _func, NULL) | 34 | static DEVICE_ATTR(_name, 0444, _func, NULL) |
36 | 35 | ||
37 | #define define_one_ro(_name) \ | 36 | #define define_one_ro(_name) \ |
38 | static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) | 37 | static DEVICE_ATTR(_name, 0444, show_##_name, NULL) |
39 | 38 | ||
40 | #define define_id_show_func(name) \ | 39 | #define define_id_show_func(name) \ |
41 | static ssize_t show_##name(struct sys_device *dev, \ | 40 | static ssize_t show_##name(struct device *dev, \ |
42 | struct sysdev_attribute *attr, char *buf) \ | 41 | struct device_attribute *attr, char *buf) \ |
43 | { \ | 42 | { \ |
44 | unsigned int cpu = dev->id; \ | 43 | unsigned int cpu = dev->id; \ |
45 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ | 44 | return sprintf(buf, "%d\n", topology_##name(cpu)); \ |
@@ -65,16 +64,16 @@ static ssize_t show_cpumap(int type, const struct cpumask *mask, char *buf) | |||
65 | 64 | ||
66 | #ifdef arch_provides_topology_pointers | 65 | #ifdef arch_provides_topology_pointers |
67 | #define define_siblings_show_map(name) \ | 66 | #define define_siblings_show_map(name) \ |
68 | static ssize_t show_##name(struct sys_device *dev, \ | 67 | static ssize_t show_##name(struct device *dev, \ |
69 | struct sysdev_attribute *attr, char *buf) \ | 68 | struct device_attribute *attr, char *buf) \ |
70 | { \ | 69 | { \ |
71 | unsigned int cpu = dev->id; \ | 70 | unsigned int cpu = dev->id; \ |
72 | return show_cpumap(0, topology_##name(cpu), buf); \ | 71 | return show_cpumap(0, topology_##name(cpu), buf); \ |
73 | } | 72 | } |
74 | 73 | ||
75 | #define define_siblings_show_list(name) \ | 74 | #define define_siblings_show_list(name) \ |
76 | static ssize_t show_##name##_list(struct sys_device *dev, \ | 75 | static ssize_t show_##name##_list(struct device *dev, \ |
77 | struct sysdev_attribute *attr, \ | 76 | struct device_attribute *attr, \ |
78 | char *buf) \ | 77 | char *buf) \ |
79 | { \ | 78 | { \ |
80 | unsigned int cpu = dev->id; \ | 79 | unsigned int cpu = dev->id; \ |
@@ -83,15 +82,15 @@ static ssize_t show_##name##_list(struct sys_device *dev, \ | |||
83 | 82 | ||
84 | #else | 83 | #else |
85 | #define define_siblings_show_map(name) \ | 84 | #define define_siblings_show_map(name) \ |
86 | static ssize_t show_##name(struct sys_device *dev, \ | 85 | static ssize_t show_##name(struct device *dev, \ |
87 | struct sysdev_attribute *attr, char *buf) \ | 86 | struct device_attribute *attr, char *buf) \ |
88 | { \ | 87 | { \ |
89 | return show_cpumap(0, topology_##name(dev->id), buf); \ | 88 | return show_cpumap(0, topology_##name(dev->id), buf); \ |
90 | } | 89 | } |
91 | 90 | ||
92 | #define define_siblings_show_list(name) \ | 91 | #define define_siblings_show_list(name) \ |
93 | static ssize_t show_##name##_list(struct sys_device *dev, \ | 92 | static ssize_t show_##name##_list(struct device *dev, \ |
94 | struct sysdev_attribute *attr, \ | 93 | struct device_attribute *attr, \ |
95 | char *buf) \ | 94 | char *buf) \ |
96 | { \ | 95 | { \ |
97 | return show_cpumap(1, topology_##name(dev->id), buf); \ | 96 | return show_cpumap(1, topology_##name(dev->id), buf); \ |
@@ -124,16 +123,16 @@ define_one_ro_named(book_siblings_list, show_book_cpumask_list); | |||
124 | #endif | 123 | #endif |
125 | 124 | ||
126 | static struct attribute *default_attrs[] = { | 125 | static struct attribute *default_attrs[] = { |
127 | &attr_physical_package_id.attr, | 126 | &dev_attr_physical_package_id.attr, |
128 | &attr_core_id.attr, | 127 | &dev_attr_core_id.attr, |
129 | &attr_thread_siblings.attr, | 128 | &dev_attr_thread_siblings.attr, |
130 | &attr_thread_siblings_list.attr, | 129 | &dev_attr_thread_siblings_list.attr, |
131 | &attr_core_siblings.attr, | 130 | &dev_attr_core_siblings.attr, |
132 | &attr_core_siblings_list.attr, | 131 | &dev_attr_core_siblings_list.attr, |
133 | #ifdef CONFIG_SCHED_BOOK | 132 | #ifdef CONFIG_SCHED_BOOK |
134 | &attr_book_id.attr, | 133 | &dev_attr_book_id.attr, |
135 | &attr_book_siblings.attr, | 134 | &dev_attr_book_siblings.attr, |
136 | &attr_book_siblings_list.attr, | 135 | &dev_attr_book_siblings_list.attr, |
137 | #endif | 136 | #endif |
138 | NULL | 137 | NULL |
139 | }; | 138 | }; |
@@ -146,16 +145,16 @@ static struct attribute_group topology_attr_group = { | |||
146 | /* Add/Remove cpu_topology interface for CPU device */ | 145 | /* Add/Remove cpu_topology interface for CPU device */ |
147 | static int __cpuinit topology_add_dev(unsigned int cpu) | 146 | static int __cpuinit topology_add_dev(unsigned int cpu) |
148 | { | 147 | { |
149 | struct sys_device *sys_dev = get_cpu_sysdev(cpu); | 148 | struct device *dev = get_cpu_device(cpu); |
150 | 149 | ||
151 | return sysfs_create_group(&sys_dev->kobj, &topology_attr_group); | 150 | return sysfs_create_group(&dev->kobj, &topology_attr_group); |
152 | } | 151 | } |
153 | 152 | ||
154 | static void __cpuinit topology_remove_dev(unsigned int cpu) | 153 | static void __cpuinit topology_remove_dev(unsigned int cpu) |
155 | { | 154 | { |
156 | struct sys_device *sys_dev = get_cpu_sysdev(cpu); | 155 | struct device *dev = get_cpu_device(cpu); |
157 | 156 | ||
158 | sysfs_remove_group(&sys_dev->kobj, &topology_attr_group); | 157 | sysfs_remove_group(&dev->kobj, &topology_attr_group); |
159 | } | 158 | } |
160 | 159 | ||
161 | static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, | 160 | static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, |