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

convert 'memory' sysdev_class to a regular subsystem

This moves the 'memory sysdev_class' over to a regular 'memory' subsystem
and converts the devices to regular devices. The sysdev drivers are
implemented as subsystem interfaces now.

After all sysdev classes are ported to regular driver core entities, the
sysdev implementation will be entirely removed from the kernel.

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

authored by

Kay Sievers and committed by
Greg Kroah-Hartman
10fbcf4c 8a25a2fd

+177 -200
+2 -2
arch/powerpc/kernel/sysfs.c
··· 592 592 int sysfs_add_device_to_node(struct device *dev, int nid) 593 593 { 594 594 struct node *node = &node_devices[nid]; 595 - return sysfs_create_link(&node->sysdev.kobj, &dev->kobj, 595 + return sysfs_create_link(&node->dev.kobj, &dev->kobj, 596 596 kobject_name(&dev->kobj)); 597 597 } 598 598 EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); ··· 600 600 void sysfs_remove_device_from_node(struct device *dev, int nid) 601 601 { 602 602 struct node *node = &node_devices[nid]; 603 - sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj)); 603 + sysfs_remove_link(&node->dev.kobj, kobject_name(&dev->kobj)); 604 604 } 605 605 EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node); 606 606
+66 -94
drivers/base/memory.c
··· 1 1 /* 2 - * drivers/base/memory.c - basic Memory class support 2 + * Memory subsystem support 3 3 * 4 4 * Written by Matt Tolentino <matthew.e.tolentino@intel.com> 5 5 * Dave Hansen <haveblue@us.ibm.com> ··· 10 10 * SPARSEMEM should be contained here, or in mm/memory_hotplug.c. 11 11 */ 12 12 13 - #include <linux/sysdev.h> 14 13 #include <linux/module.h> 15 14 #include <linux/init.h> 16 15 #include <linux/topology.h> ··· 37 38 return section_nr / sections_per_block; 38 39 } 39 40 40 - static struct sysdev_class memory_sysdev_class = { 41 + static struct bus_type memory_subsys = { 41 42 .name = MEMORY_CLASS_NAME, 42 - }; 43 - 44 - static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) 45 - { 46 - return MEMORY_CLASS_NAME; 47 - } 48 - 49 - static int memory_uevent(struct kset *kset, struct kobject *obj, 50 - struct kobj_uevent_env *env) 51 - { 52 - int retval = 0; 53 - 54 - return retval; 55 - } 56 - 57 - static const struct kset_uevent_ops memory_uevent_ops = { 58 - .name = memory_uevent_name, 59 - .uevent = memory_uevent, 43 + .dev_name = MEMORY_CLASS_NAME, 60 44 }; 61 45 62 46 static BLOCKING_NOTIFIER_HEAD(memory_chain); ··· 78 96 { 79 97 int error; 80 98 81 - memory->sysdev.cls = &memory_sysdev_class; 82 - memory->sysdev.id = memory->start_section_nr / sections_per_block; 99 + memory->dev.bus = &memory_subsys; 100 + memory->dev.id = memory->start_section_nr / sections_per_block; 83 101 84 - error = sysdev_register(&memory->sysdev); 102 + error = device_register(&memory->dev); 85 103 return error; 86 104 } 87 105 88 106 static void 89 107 unregister_memory(struct memory_block *memory) 90 108 { 91 - BUG_ON(memory->sysdev.cls != &memory_sysdev_class); 109 + BUG_ON(memory->dev.bus != &memory_subsys); 92 110 93 111 /* drop the ref. we got in remove_memory_block() */ 94 - kobject_put(&memory->sysdev.kobj); 95 - sysdev_unregister(&memory->sysdev); 112 + kobject_put(&memory->dev.kobj); 113 + device_unregister(&memory->dev); 96 114 } 97 115 98 116 unsigned long __weak memory_block_size_bytes(void) ··· 120 138 * uses. 121 139 */ 122 140 123 - static ssize_t show_mem_start_phys_index(struct sys_device *dev, 124 - struct sysdev_attribute *attr, char *buf) 141 + static ssize_t show_mem_start_phys_index(struct device *dev, 142 + struct device_attribute *attr, char *buf) 125 143 { 126 144 struct memory_block *mem = 127 - container_of(dev, struct memory_block, sysdev); 145 + container_of(dev, struct memory_block, dev); 128 146 unsigned long phys_index; 129 147 130 148 phys_index = mem->start_section_nr / sections_per_block; 131 149 return sprintf(buf, "%08lx\n", phys_index); 132 150 } 133 151 134 - static ssize_t show_mem_end_phys_index(struct sys_device *dev, 135 - struct sysdev_attribute *attr, char *buf) 152 + static ssize_t show_mem_end_phys_index(struct device *dev, 153 + struct device_attribute *attr, char *buf) 136 154 { 137 155 struct memory_block *mem = 138 - container_of(dev, struct memory_block, sysdev); 156 + container_of(dev, struct memory_block, dev); 139 157 unsigned long phys_index; 140 158 141 159 phys_index = mem->end_section_nr / sections_per_block; ··· 145 163 /* 146 164 * Show whether the section of memory is likely to be hot-removable 147 165 */ 148 - static ssize_t show_mem_removable(struct sys_device *dev, 149 - struct sysdev_attribute *attr, char *buf) 166 + static ssize_t show_mem_removable(struct device *dev, 167 + struct device_attribute *attr, char *buf) 150 168 { 151 169 unsigned long i, pfn; 152 170 int ret = 1; 153 171 struct memory_block *mem = 154 - container_of(dev, struct memory_block, sysdev); 172 + container_of(dev, struct memory_block, dev); 155 173 156 174 for (i = 0; i < sections_per_block; i++) { 157 175 pfn = section_nr_to_pfn(mem->start_section_nr + i); ··· 164 182 /* 165 183 * online, offline, going offline, etc. 166 184 */ 167 - static ssize_t show_mem_state(struct sys_device *dev, 168 - struct sysdev_attribute *attr, char *buf) 185 + static ssize_t show_mem_state(struct device *dev, 186 + struct device_attribute *attr, char *buf) 169 187 { 170 188 struct memory_block *mem = 171 - container_of(dev, struct memory_block, sysdev); 189 + container_of(dev, struct memory_block, dev); 172 190 ssize_t len = 0; 173 191 174 192 /* ··· 306 324 } 307 325 308 326 static ssize_t 309 - store_mem_state(struct sys_device *dev, 310 - struct sysdev_attribute *attr, const char *buf, size_t count) 327 + store_mem_state(struct device *dev, 328 + struct device_attribute *attr, const char *buf, size_t count) 311 329 { 312 330 struct memory_block *mem; 313 331 int ret = -EINVAL; 314 332 315 - mem = container_of(dev, struct memory_block, sysdev); 333 + mem = container_of(dev, struct memory_block, dev); 316 334 317 335 if (!strncmp(buf, "online", min((int)count, 6))) 318 336 ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); ··· 333 351 * s.t. if I offline all of these sections I can then 334 352 * remove the physical device? 335 353 */ 336 - static ssize_t show_phys_device(struct sys_device *dev, 337 - struct sysdev_attribute *attr, char *buf) 354 + static ssize_t show_phys_device(struct device *dev, 355 + struct device_attribute *attr, char *buf) 338 356 { 339 357 struct memory_block *mem = 340 - container_of(dev, struct memory_block, sysdev); 358 + container_of(dev, struct memory_block, dev); 341 359 return sprintf(buf, "%d\n", mem->phys_device); 342 360 } 343 361 344 - static SYSDEV_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL); 345 - static SYSDEV_ATTR(end_phys_index, 0444, show_mem_end_phys_index, NULL); 346 - static SYSDEV_ATTR(state, 0644, show_mem_state, store_mem_state); 347 - static SYSDEV_ATTR(phys_device, 0444, show_phys_device, NULL); 348 - static SYSDEV_ATTR(removable, 0444, show_mem_removable, NULL); 362 + static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL); 363 + static DEVICE_ATTR(end_phys_index, 0444, show_mem_end_phys_index, NULL); 364 + static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state); 365 + static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL); 366 + static DEVICE_ATTR(removable, 0444, show_mem_removable, NULL); 349 367 350 368 #define mem_create_simple_file(mem, attr_name) \ 351 - sysdev_create_file(&mem->sysdev, &attr_##attr_name) 369 + device_create_file(&mem->dev, &dev_attr_##attr_name) 352 370 #define mem_remove_simple_file(mem, attr_name) \ 353 - sysdev_remove_file(&mem->sysdev, &attr_##attr_name) 371 + device_remove_file(&mem->dev, &dev_attr_##attr_name) 354 372 355 373 /* 356 374 * Block size attribute stuff 357 375 */ 358 376 static ssize_t 359 - print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr, 377 + print_block_size(struct device *dev, struct device_attribute *attr, 360 378 char *buf) 361 379 { 362 380 return sprintf(buf, "%lx\n", get_memory_block_size()); 363 381 } 364 382 365 - static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); 383 + static DEVICE_ATTR(block_size_bytes, 0444, print_block_size, NULL); 366 384 367 385 static int block_size_init(void) 368 386 { 369 - return sysfs_create_file(&memory_sysdev_class.kset.kobj, 370 - &attr_block_size_bytes.attr); 387 + return device_create_file(memory_subsys.dev_root, 388 + &dev_attr_block_size_bytes); 371 389 } 372 390 373 391 /* ··· 378 396 */ 379 397 #ifdef CONFIG_ARCH_MEMORY_PROBE 380 398 static ssize_t 381 - memory_probe_store(struct class *class, struct class_attribute *attr, 399 + memory_probe_store(struct device *dev, struct device_attribute *attr, 382 400 const char *buf, size_t count) 383 401 { 384 402 u64 phys_addr; ··· 405 423 out: 406 424 return ret; 407 425 } 408 - static CLASS_ATTR(probe, S_IWUSR, NULL, memory_probe_store); 426 + static DEVICE_ATTR(probe, S_IWUSR, NULL, memory_probe_store); 409 427 410 428 static int memory_probe_init(void) 411 429 { 412 - return sysfs_create_file(&memory_sysdev_class.kset.kobj, 413 - &class_attr_probe.attr); 430 + return device_create_file(memory_subsys.dev_root, &dev_attr_probe); 414 431 } 415 432 #else 416 433 static inline int memory_probe_init(void) ··· 425 444 426 445 /* Soft offline a page */ 427 446 static ssize_t 428 - store_soft_offline_page(struct class *class, 429 - struct class_attribute *attr, 447 + store_soft_offline_page(struct device *dev, 448 + struct device_attribute *attr, 430 449 const char *buf, size_t count) 431 450 { 432 451 int ret; ··· 444 463 445 464 /* Forcibly offline a page, including killing processes. */ 446 465 static ssize_t 447 - store_hard_offline_page(struct class *class, 448 - struct class_attribute *attr, 466 + store_hard_offline_page(struct device *dev, 467 + struct device_attribute *attr, 449 468 const char *buf, size_t count) 450 469 { 451 470 int ret; ··· 459 478 return ret ? ret : count; 460 479 } 461 480 462 - static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); 463 - static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); 481 + static DEVICE_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page); 482 + static DEVICE_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page); 464 483 465 484 static __init int memory_fail_init(void) 466 485 { 467 486 int err; 468 487 469 - err = sysfs_create_file(&memory_sysdev_class.kset.kobj, 470 - &class_attr_soft_offline_page.attr); 488 + err = device_create_file(memory_subsys.dev_root, 489 + &dev_attr_soft_offline_page); 471 490 if (!err) 472 - err = sysfs_create_file(&memory_sysdev_class.kset.kobj, 473 - &class_attr_hard_offline_page.attr); 491 + err = device_create_file(memory_subsys.dev_root, 492 + &dev_attr_hard_offline_page); 474 493 return err; 475 494 } 476 495 #else ··· 490 509 return 0; 491 510 } 492 511 512 + /* 513 + * A reference for the returned object is held and the reference for the 514 + * hinted object is released. 515 + */ 493 516 struct memory_block *find_memory_block_hinted(struct mem_section *section, 494 517 struct memory_block *hint) 495 518 { 496 - struct kobject *kobj; 497 - struct sys_device *sysdev; 498 - struct memory_block *mem; 499 - char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1]; 500 519 int block_id = base_memory_block_id(__section_nr(section)); 520 + struct device *hintdev = hint ? &hint->dev : NULL; 521 + struct device *dev; 501 522 502 - kobj = hint ? &hint->sysdev.kobj : NULL; 503 - 504 - /* 505 - * This only works because we know that section == sysdev->id 506 - * slightly redundant with sysdev_register() 507 - */ 508 - sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, block_id); 509 - 510 - kobj = kset_find_obj_hinted(&memory_sysdev_class.kset, name, kobj); 511 - if (!kobj) 523 + dev = subsys_find_device_by_id(&memory_subsys, block_id, hintdev); 524 + if (hint) 525 + put_device(&hint->dev); 526 + if (!dev) 512 527 return NULL; 513 - 514 - sysdev = container_of(kobj, struct sys_device, kobj); 515 - mem = container_of(sysdev, struct memory_block, sysdev); 516 - 517 - return mem; 528 + return container_of(dev, struct memory_block, dev); 518 529 } 519 530 520 531 /* ··· 515 542 * this gets to be a real problem, we can always use a radix 516 543 * tree or something here. 517 544 * 518 - * This could be made generic for all sysdev classes. 545 + * This could be made generic for all device subsystems. 519 546 */ 520 547 struct memory_block *find_memory_block(struct mem_section *section) 521 548 { ··· 571 598 mem = find_memory_block(section); 572 599 if (mem) { 573 600 mem->section_count++; 574 - kobject_put(&mem->sysdev.kobj); 601 + kobject_put(&mem->dev.kobj); 575 602 } else 576 603 ret = init_memory_block(&mem, section, state); 577 604 ··· 604 631 unregister_memory(mem); 605 632 kfree(mem); 606 633 } else 607 - kobject_put(&mem->sysdev.kobj); 634 + kobject_put(&mem->dev.kobj); 608 635 609 636 mutex_unlock(&mem_sysfs_mutex); 610 637 return 0; ··· 637 664 int err; 638 665 unsigned long block_sz; 639 666 640 - memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; 641 - ret = sysdev_class_register(&memory_sysdev_class); 667 + ret = subsys_system_register(&memory_subsys, NULL); 642 668 if (ret) 643 669 goto out; 644 670
+76 -70
drivers/base/node.c
··· 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 5 #include <linux/module.h> 7 6 #include <linux/init.h> 8 7 #include <linux/mm.h> ··· 18 19 #include <linux/swap.h> 19 20 #include <linux/slab.h> 20 21 21 - static struct sysdev_class_attribute *node_state_attrs[]; 22 - 23 - static struct sysdev_class node_class = { 22 + static struct bus_type node_subsys = { 24 23 .name = "node", 25 - .attrs = node_state_attrs, 24 + .dev_name = "node", 26 25 }; 27 26 28 27 29 - static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) 28 + static ssize_t node_read_cpumap(struct device *dev, int type, char *buf) 30 29 { 31 30 struct node *node_dev = to_node(dev); 32 - const struct cpumask *mask = cpumask_of_node(node_dev->sysdev.id); 31 + const struct cpumask *mask = cpumask_of_node(node_dev->dev.id); 33 32 int len; 34 33 35 34 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ ··· 41 44 return len; 42 45 } 43 46 44 - static inline ssize_t node_read_cpumask(struct sys_device *dev, 45 - struct sysdev_attribute *attr, char *buf) 47 + static inline ssize_t node_read_cpumask(struct device *dev, 48 + struct device_attribute *attr, char *buf) 46 49 { 47 50 return node_read_cpumap(dev, 0, buf); 48 51 } 49 - static inline ssize_t node_read_cpulist(struct sys_device *dev, 50 - struct sysdev_attribute *attr, char *buf) 52 + static inline ssize_t node_read_cpulist(struct device *dev, 53 + struct device_attribute *attr, char *buf) 51 54 { 52 55 return node_read_cpumap(dev, 1, buf); 53 56 } 54 57 55 - static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); 56 - static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); 58 + static DEVICE_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); 59 + static DEVICE_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); 57 60 58 61 #define K(x) ((x) << (PAGE_SHIFT - 10)) 59 - static ssize_t node_read_meminfo(struct sys_device * dev, 60 - struct sysdev_attribute *attr, char * buf) 62 + static ssize_t node_read_meminfo(struct device *dev, 63 + struct device_attribute *attr, char *buf) 61 64 { 62 65 int n; 63 66 int nid = dev->id; ··· 152 155 } 153 156 154 157 #undef K 155 - static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); 158 + static DEVICE_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL); 156 159 157 - static ssize_t node_read_numastat(struct sys_device * dev, 158 - struct sysdev_attribute *attr, char * buf) 160 + static ssize_t node_read_numastat(struct device *dev, 161 + struct device_attribute *attr, char *buf) 159 162 { 160 163 return sprintf(buf, 161 164 "numa_hit %lu\n" ··· 171 174 node_page_state(dev->id, NUMA_LOCAL), 172 175 node_page_state(dev->id, NUMA_OTHER)); 173 176 } 174 - static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 177 + static DEVICE_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 175 178 176 - static ssize_t node_read_vmstat(struct sys_device *dev, 177 - struct sysdev_attribute *attr, char *buf) 179 + static ssize_t node_read_vmstat(struct device *dev, 180 + struct device_attribute *attr, char *buf) 178 181 { 179 182 int nid = dev->id; 180 183 int i; ··· 186 189 187 190 return n; 188 191 } 189 - static SYSDEV_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL); 192 + static DEVICE_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL); 190 193 191 - static ssize_t node_read_distance(struct sys_device * dev, 192 - struct sysdev_attribute *attr, char * buf) 194 + static ssize_t node_read_distance(struct device *dev, 195 + struct device_attribute *attr, char * buf) 193 196 { 194 197 int nid = dev->id; 195 198 int len = 0; ··· 207 210 len += sprintf(buf + len, "\n"); 208 211 return len; 209 212 } 210 - static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL); 213 + static DEVICE_ATTR(distance, S_IRUGO, node_read_distance, NULL); 211 214 212 215 #ifdef CONFIG_HUGETLBFS 213 216 /* ··· 225 228 static inline bool hugetlb_register_node(struct node *node) 226 229 { 227 230 if (__hugetlb_register_node && 228 - node_state(node->sysdev.id, N_HIGH_MEMORY)) { 231 + node_state(node->dev.id, N_HIGH_MEMORY)) { 229 232 __hugetlb_register_node(node); 230 233 return true; 231 234 } ··· 261 264 { 262 265 int error; 263 266 264 - node->sysdev.id = num; 265 - node->sysdev.cls = &node_class; 266 - error = sysdev_register(&node->sysdev); 267 + node->dev.id = num; 268 + node->dev.bus = &node_subsys; 269 + error = device_register(&node->dev); 267 270 268 271 if (!error){ 269 - sysdev_create_file(&node->sysdev, &attr_cpumap); 270 - sysdev_create_file(&node->sysdev, &attr_cpulist); 271 - sysdev_create_file(&node->sysdev, &attr_meminfo); 272 - sysdev_create_file(&node->sysdev, &attr_numastat); 273 - sysdev_create_file(&node->sysdev, &attr_distance); 274 - sysdev_create_file(&node->sysdev, &attr_vmstat); 272 + device_create_file(&node->dev, &dev_attr_cpumap); 273 + device_create_file(&node->dev, &dev_attr_cpulist); 274 + device_create_file(&node->dev, &dev_attr_meminfo); 275 + device_create_file(&node->dev, &dev_attr_numastat); 276 + device_create_file(&node->dev, &dev_attr_distance); 277 + device_create_file(&node->dev, &dev_attr_vmstat); 275 278 276 279 scan_unevictable_register_node(node); 277 280 ··· 291 294 */ 292 295 void unregister_node(struct node *node) 293 296 { 294 - sysdev_remove_file(&node->sysdev, &attr_cpumap); 295 - sysdev_remove_file(&node->sysdev, &attr_cpulist); 296 - sysdev_remove_file(&node->sysdev, &attr_meminfo); 297 - sysdev_remove_file(&node->sysdev, &attr_numastat); 298 - sysdev_remove_file(&node->sysdev, &attr_distance); 299 - sysdev_remove_file(&node->sysdev, &attr_vmstat); 297 + device_remove_file(&node->dev, &dev_attr_cpumap); 298 + device_remove_file(&node->dev, &dev_attr_cpulist); 299 + device_remove_file(&node->dev, &dev_attr_meminfo); 300 + device_remove_file(&node->dev, &dev_attr_numastat); 301 + device_remove_file(&node->dev, &dev_attr_distance); 302 + device_remove_file(&node->dev, &dev_attr_vmstat); 300 303 301 304 scan_unevictable_unregister_node(node); 302 305 hugetlb_unregister_node(node); /* no-op, if memoryless node */ 303 306 304 - sysdev_unregister(&node->sysdev); 307 + device_unregister(&node->dev); 305 308 } 306 309 307 310 struct node node_devices[MAX_NUMNODES]; ··· 321 324 if (!obj) 322 325 return 0; 323 326 324 - ret = sysfs_create_link(&node_devices[nid].sysdev.kobj, 327 + ret = sysfs_create_link(&node_devices[nid].dev.kobj, 325 328 &obj->kobj, 326 329 kobject_name(&obj->kobj)); 327 330 if (ret) 328 331 return ret; 329 332 330 333 return sysfs_create_link(&obj->kobj, 331 - &node_devices[nid].sysdev.kobj, 332 - kobject_name(&node_devices[nid].sysdev.kobj)); 334 + &node_devices[nid].dev.kobj, 335 + kobject_name(&node_devices[nid].dev.kobj)); 333 336 } 334 337 335 338 int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) ··· 343 346 if (!obj) 344 347 return 0; 345 348 346 - sysfs_remove_link(&node_devices[nid].sysdev.kobj, 349 + sysfs_remove_link(&node_devices[nid].dev.kobj, 347 350 kobject_name(&obj->kobj)); 348 351 sysfs_remove_link(&obj->kobj, 349 - kobject_name(&node_devices[nid].sysdev.kobj)); 352 + kobject_name(&node_devices[nid].dev.kobj)); 350 353 351 354 return 0; 352 355 } ··· 388 391 continue; 389 392 if (page_nid != nid) 390 393 continue; 391 - ret = sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj, 392 - &mem_blk->sysdev.kobj, 393 - kobject_name(&mem_blk->sysdev.kobj)); 394 + ret = sysfs_create_link_nowarn(&node_devices[nid].dev.kobj, 395 + &mem_blk->dev.kobj, 396 + kobject_name(&mem_blk->dev.kobj)); 394 397 if (ret) 395 398 return ret; 396 399 397 - return sysfs_create_link_nowarn(&mem_blk->sysdev.kobj, 398 - &node_devices[nid].sysdev.kobj, 399 - kobject_name(&node_devices[nid].sysdev.kobj)); 400 + return sysfs_create_link_nowarn(&mem_blk->dev.kobj, 401 + &node_devices[nid].dev.kobj, 402 + kobject_name(&node_devices[nid].dev.kobj)); 400 403 } 401 404 /* mem section does not span the specified node */ 402 405 return 0; ··· 429 432 continue; 430 433 if (node_test_and_set(nid, *unlinked_nodes)) 431 434 continue; 432 - sysfs_remove_link(&node_devices[nid].sysdev.kobj, 433 - kobject_name(&mem_blk->sysdev.kobj)); 434 - sysfs_remove_link(&mem_blk->sysdev.kobj, 435 - kobject_name(&node_devices[nid].sysdev.kobj)); 435 + sysfs_remove_link(&node_devices[nid].dev.kobj, 436 + kobject_name(&mem_blk->dev.kobj)); 437 + sysfs_remove_link(&mem_blk->dev.kobj, 438 + kobject_name(&node_devices[nid].dev.kobj)); 436 439 } 437 440 NODEMASK_FREE(unlinked_nodes); 438 441 return 0; ··· 463 466 } 464 467 465 468 if (mem_blk) 466 - kobject_put(&mem_blk->sysdev.kobj); 469 + kobject_put(&mem_blk->dev.kobj); 467 470 return err; 468 471 } 469 472 ··· 591 594 } 592 595 593 596 struct node_attr { 594 - struct sysdev_class_attribute attr; 597 + struct device_attribute attr; 595 598 enum node_states state; 596 599 }; 597 600 598 - static ssize_t show_node_state(struct sysdev_class *class, 599 - struct sysdev_class_attribute *attr, char *buf) 601 + static ssize_t show_node_state(struct device *dev, 602 + struct device_attribute *attr, char *buf) 600 603 { 601 604 struct node_attr *na = container_of(attr, struct node_attr, attr); 602 605 return print_nodes_state(na->state, buf); 603 606 } 604 607 605 608 #define _NODE_ATTR(name, state) \ 606 - { _SYSDEV_CLASS_ATTR(name, 0444, show_node_state, NULL), state } 609 + { __ATTR(name, 0444, show_node_state, NULL), state } 607 610 608 611 static struct node_attr node_state_attr[] = { 609 612 _NODE_ATTR(possible, N_POSSIBLE), ··· 615 618 #endif 616 619 }; 617 620 618 - static struct sysdev_class_attribute *node_state_attrs[] = { 619 - &node_state_attr[0].attr, 620 - &node_state_attr[1].attr, 621 - &node_state_attr[2].attr, 622 - &node_state_attr[3].attr, 621 + static struct attribute *node_state_attrs[] = { 622 + &node_state_attr[0].attr.attr, 623 + &node_state_attr[1].attr.attr, 624 + &node_state_attr[2].attr.attr, 625 + &node_state_attr[3].attr.attr, 623 626 #ifdef CONFIG_HIGHMEM 624 - &node_state_attr[4].attr, 627 + &node_state_attr[4].attr.attr, 625 628 #endif 626 629 NULL 630 + }; 631 + 632 + static struct attribute_group memory_root_attr_group = { 633 + .attrs = node_state_attrs, 634 + }; 635 + 636 + static const struct attribute_group *cpu_root_attr_groups[] = { 637 + &memory_root_attr_group, 638 + NULL, 627 639 }; 628 640 629 641 #define NODE_CALLBACK_PRI 2 /* lower than SLAB */ ··· 643 637 BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); 644 638 BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES); 645 639 646 - ret = sysdev_class_register(&node_class); 640 + ret = subsys_system_register(&node_subsys, cpu_root_attr_groups); 647 641 if (!ret) { 648 642 hotplug_memory_notifier(node_memory_callback, 649 643 NODE_CALLBACK_PRI);
+1 -2
include/linux/memory.h
··· 15 15 #ifndef _LINUX_MEMORY_H_ 16 16 #define _LINUX_MEMORY_H_ 17 17 18 - #include <linux/sysdev.h> 19 18 #include <linux/node.h> 20 19 #include <linux/compiler.h> 21 20 #include <linux/mutex.h> ··· 37 38 int phys_device; /* to which fru does this belong? */ 38 39 void *hw; /* optional pointer to fw/hw data */ 39 40 int (*phys_callback)(struct memory_block *); 40 - struct sys_device sysdev; 41 + struct device dev; 41 42 }; 42 43 43 44 int arch_get_memory_phys_device(unsigned long start_pfn);
+3 -3
include/linux/node.h
··· 14 14 #ifndef _LINUX_NODE_H_ 15 15 #define _LINUX_NODE_H_ 16 16 17 - #include <linux/sysdev.h> 17 + #include <linux/device.h> 18 18 #include <linux/cpumask.h> 19 19 #include <linux/workqueue.h> 20 20 21 21 struct node { 22 - struct sys_device sysdev; 22 + struct device dev; 23 23 24 24 #if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS) 25 25 struct work_struct node_work; ··· 80 80 } 81 81 #endif 82 82 83 - #define to_node(sys_device) container_of(sys_device, struct node, sysdev) 83 + #define to_node(device) container_of(device, struct node, dev) 84 84 85 85 #endif /* _LINUX_NODE_H_ */
+5 -5
mm/compaction.c
··· 721 721 } 722 722 723 723 #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) 724 - ssize_t sysfs_compact_node(struct sys_device *dev, 725 - struct sysdev_attribute *attr, 724 + ssize_t sysfs_compact_node(struct device *dev, 725 + struct device_attribute *attr, 726 726 const char *buf, size_t count) 727 727 { 728 728 compact_node(dev->id); 729 729 730 730 return count; 731 731 } 732 - static SYSDEV_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); 732 + static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); 733 733 734 734 int compaction_register_node(struct node *node) 735 735 { 736 - return sysdev_create_file(&node->sysdev, &attr_compact); 736 + return device_create_file(&node->dev, &dev_attr_compact); 737 737 } 738 738 739 739 void compaction_unregister_node(struct node *node) 740 740 { 741 - return sysdev_remove_file(&node->sysdev, &attr_compact); 741 + return device_remove_file(&node->dev, &dev_attr_compact); 742 742 } 743 743 #endif /* CONFIG_SYSFS && CONFIG_NUMA */
+17 -17
mm/hugetlb.c
··· 1591 1591 1592 1592 /* 1593 1593 * node_hstate/s - associate per node hstate attributes, via their kobjects, 1594 - * with node sysdevs in node_devices[] using a parallel array. The array 1595 - * index of a node sysdev or _hstate == node id. 1596 - * This is here to avoid any static dependency of the node sysdev driver, in 1594 + * with node devices in node_devices[] using a parallel array. The array 1595 + * index of a node device or _hstate == node id. 1596 + * This is here to avoid any static dependency of the node device driver, in 1597 1597 * the base kernel, on the hugetlb module. 1598 1598 */ 1599 1599 struct node_hstate { ··· 1603 1603 struct node_hstate node_hstates[MAX_NUMNODES]; 1604 1604 1605 1605 /* 1606 - * A subset of global hstate attributes for node sysdevs 1606 + * A subset of global hstate attributes for node devices 1607 1607 */ 1608 1608 static struct attribute *per_node_hstate_attrs[] = { 1609 1609 &nr_hugepages_attr.attr, ··· 1617 1617 }; 1618 1618 1619 1619 /* 1620 - * kobj_to_node_hstate - lookup global hstate for node sysdev hstate attr kobj. 1620 + * kobj_to_node_hstate - lookup global hstate for node device hstate attr kobj. 1621 1621 * Returns node id via non-NULL nidp. 1622 1622 */ 1623 1623 static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp) ··· 1640 1640 } 1641 1641 1642 1642 /* 1643 - * Unregister hstate attributes from a single node sysdev. 1643 + * Unregister hstate attributes from a single node device. 1644 1644 * No-op if no hstate attributes attached. 1645 1645 */ 1646 1646 void hugetlb_unregister_node(struct node *node) 1647 1647 { 1648 1648 struct hstate *h; 1649 - struct node_hstate *nhs = &node_hstates[node->sysdev.id]; 1649 + struct node_hstate *nhs = &node_hstates[node->dev.id]; 1650 1650 1651 1651 if (!nhs->hugepages_kobj) 1652 1652 return; /* no hstate attributes */ ··· 1662 1662 } 1663 1663 1664 1664 /* 1665 - * hugetlb module exit: unregister hstate attributes from node sysdevs 1665 + * hugetlb module exit: unregister hstate attributes from node devices 1666 1666 * that have them. 1667 1667 */ 1668 1668 static void hugetlb_unregister_all_nodes(void) ··· 1670 1670 int nid; 1671 1671 1672 1672 /* 1673 - * disable node sysdev registrations. 1673 + * disable node device registrations. 1674 1674 */ 1675 1675 register_hugetlbfs_with_node(NULL, NULL); 1676 1676 ··· 1682 1682 } 1683 1683 1684 1684 /* 1685 - * Register hstate attributes for a single node sysdev. 1685 + * Register hstate attributes for a single node device. 1686 1686 * No-op if attributes already registered. 1687 1687 */ 1688 1688 void hugetlb_register_node(struct node *node) 1689 1689 { 1690 1690 struct hstate *h; 1691 - struct node_hstate *nhs = &node_hstates[node->sysdev.id]; 1691 + struct node_hstate *nhs = &node_hstates[node->dev.id]; 1692 1692 int err; 1693 1693 1694 1694 if (nhs->hugepages_kobj) 1695 1695 return; /* already allocated */ 1696 1696 1697 1697 nhs->hugepages_kobj = kobject_create_and_add("hugepages", 1698 - &node->sysdev.kobj); 1698 + &node->dev.kobj); 1699 1699 if (!nhs->hugepages_kobj) 1700 1700 return; 1701 1701 ··· 1706 1706 if (err) { 1707 1707 printk(KERN_ERR "Hugetlb: Unable to add hstate %s" 1708 1708 " for node %d\n", 1709 - h->name, node->sysdev.id); 1709 + h->name, node->dev.id); 1710 1710 hugetlb_unregister_node(node); 1711 1711 break; 1712 1712 } ··· 1715 1715 1716 1716 /* 1717 1717 * hugetlb init time: register hstate attributes for all registered node 1718 - * sysdevs of nodes that have memory. All on-line nodes should have 1719 - * registered their associated sysdev by this time. 1718 + * devices of nodes that have memory. All on-line nodes should have 1719 + * registered their associated device by this time. 1720 1720 */ 1721 1721 static void hugetlb_register_all_nodes(void) 1722 1722 { ··· 1724 1724 1725 1725 for_each_node_state(nid, N_HIGH_MEMORY) { 1726 1726 struct node *node = &node_devices[nid]; 1727 - if (node->sysdev.id == nid) 1727 + if (node->dev.id == nid) 1728 1728 hugetlb_register_node(node); 1729 1729 } 1730 1730 1731 1731 /* 1732 - * Let the node sysdev driver know we're here so it can 1732 + * Let the node device driver know we're here so it can 1733 1733 * [un]register hstate attributes on node hotplug. 1734 1734 */ 1735 1735 register_hugetlbfs_with_node(hugetlb_register_node,
+7 -7
mm/vmscan.c
··· 3475 3475 * a specified node's per zone unevictable lists for evictable pages. 3476 3476 */ 3477 3477 3478 - static ssize_t read_scan_unevictable_node(struct sys_device *dev, 3479 - struct sysdev_attribute *attr, 3478 + static ssize_t read_scan_unevictable_node(struct device *dev, 3479 + struct device_attribute *attr, 3480 3480 char *buf) 3481 3481 { 3482 3482 warn_scan_unevictable_pages(); 3483 3483 return sprintf(buf, "0\n"); /* always zero; should fit... */ 3484 3484 } 3485 3485 3486 - static ssize_t write_scan_unevictable_node(struct sys_device *dev, 3487 - struct sysdev_attribute *attr, 3486 + static ssize_t write_scan_unevictable_node(struct device *dev, 3487 + struct device_attribute *attr, 3488 3488 const char *buf, size_t count) 3489 3489 { 3490 3490 warn_scan_unevictable_pages(); ··· 3492 3492 } 3493 3493 3494 3494 3495 - static SYSDEV_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR, 3495 + static DEVICE_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR, 3496 3496 read_scan_unevictable_node, 3497 3497 write_scan_unevictable_node); 3498 3498 3499 3499 int scan_unevictable_register_node(struct node *node) 3500 3500 { 3501 - return sysdev_create_file(&node->sysdev, &attr_scan_unevictable_pages); 3501 + return device_create_file(&node->dev, &dev_attr_scan_unevictable_pages); 3502 3502 } 3503 3503 3504 3504 void scan_unevictable_unregister_node(struct node *node) 3505 3505 { 3506 - sysdev_remove_file(&node->sysdev, &attr_scan_unevictable_pages); 3506 + device_remove_file(&node->dev, &dev_attr_scan_unevictable_pages); 3507 3507 } 3508 3508 #endif