Commit af5ca3f4ec5cc4432a42a73b050dd8898ce8fd00
Committed by
Greg Kroah-Hartman
1 parent
528a4bf1d5
Exists in
master
and in
4 other branches
Driver core: change sysdev classes to use dynamic kobject names
All kobjects require a dynamically allocated name now. We no longer need to keep track if the name is statically assigned, we can just unconditionally free() all kobject names on cleanup. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 55 changed files with 62 additions and 73 deletions Side-by-side Diff
- arch/arm/kernel/time.c
- arch/arm/mach-integrator/integrator_ap.c
- arch/arm/mach-pxa/cm-x270.c
- arch/arm/mach-pxa/lpd270.c
- arch/arm/mach-pxa/lubbock.c
- arch/arm/mach-pxa/mainstone.c
- arch/arm/mach-s3c2410/s3c2410.c
- arch/arm/mach-s3c2412/s3c2412.c
- arch/arm/mach-s3c2440/mach-osiris.c
- arch/arm/mach-s3c2443/s3c2443.c
- arch/arm/mach-sa1100/irq.c
- arch/arm/oprofile/common.c
- arch/arm/plat-omap/gpio.c
- arch/arm/plat-s3c24xx/dma.c
- arch/arm/plat-s3c24xx/s3c244x.c
- arch/avr32/kernel/time.c
- arch/mips/kernel/i8259.c
- arch/powerpc/platforms/cell/spu_base.c
- arch/powerpc/platforms/powermac/pic.c
- arch/powerpc/sysdev/ipic.c
- arch/powerpc/sysdev/mpic.c
- arch/powerpc/sysdev/qe_lib/qe_ic.c
- arch/ppc/syslib/ipic.c
- arch/ppc/syslib/open_pic.c
- arch/ppc/syslib/open_pic2.c
- arch/s390/kernel/time.c
- arch/sh/drivers/dma/dma-sysfs.c
- arch/sh/kernel/time.c
- arch/x86/kernel/apic_32.c
- arch/x86/kernel/apic_64.c
- arch/x86/kernel/cpu/mcheck/mce_64.c
- arch/x86/kernel/i8237.c
- arch/x86/kernel/i8259_32.c
- arch/x86/kernel/i8259_64.c
- arch/x86/kernel/io_apic_32.c
- arch/x86/kernel/io_apic_64.c
- arch/x86/kernel/nmi_32.c
- arch/x86/kernel/nmi_64.c
- arch/x86/oprofile/nmi_int.c
- drivers/acpi/pci_link.c
- drivers/base/class.c
- drivers/base/cpu.c
- drivers/base/memory.c
- drivers/base/node.c
- drivers/base/sys.c
- drivers/edac/edac_module.c
- drivers/kvm/kvm_main.c
- drivers/macintosh/via-pmu.c
- drivers/scsi/libsas/sas_scsi_host.c
- include/linux/kobject.h
- include/linux/sysdev.h
- kernel/rtmutex-tester.c
- kernel/time/clocksource.c
- kernel/time/timekeeping.c
- lib/kobject.c
arch/arm/kernel/time.c
| ... | ... | @@ -195,7 +195,7 @@ |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | static struct sysdev_class leds_sysclass = { |
| 198 | - set_kset_name("leds"), | |
| 198 | + .name = "leds", | |
| 199 | 199 | .shutdown = leds_shutdown, |
| 200 | 200 | .suspend = leds_suspend, |
| 201 | 201 | .resume = leds_resume, |
| ... | ... | @@ -369,7 +369,7 @@ |
| 369 | 369 | #endif |
| 370 | 370 | |
| 371 | 371 | static struct sysdev_class timer_sysclass = { |
| 372 | - set_kset_name("timer"), | |
| 372 | + .name = "timer", | |
| 373 | 373 | .suspend = timer_suspend, |
| 374 | 374 | .resume = timer_resume, |
| 375 | 375 | }; |
arch/arm/mach-integrator/integrator_ap.c
arch/arm/mach-pxa/cm-x270.c
arch/arm/mach-pxa/lpd270.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-s3c2410/s3c2410.c
arch/arm/mach-s3c2412/s3c2412.c
arch/arm/mach-s3c2440/mach-osiris.c
arch/arm/mach-s3c2443/s3c2443.c
arch/arm/mach-sa1100/irq.c
arch/arm/oprofile/common.c
arch/arm/plat-omap/gpio.c
arch/arm/plat-s3c24xx/dma.c
arch/arm/plat-s3c24xx/s3c244x.c
| ... | ... | @@ -151,13 +151,13 @@ |
| 151 | 151 | /* Since the S3C2442 and S3C2440 share items, put both sysclasses here */ |
| 152 | 152 | |
| 153 | 153 | struct sysdev_class s3c2440_sysclass = { |
| 154 | - set_kset_name("s3c2440-core"), | |
| 154 | + .name = "s3c2440-core", | |
| 155 | 155 | .suspend = s3c244x_suspend, |
| 156 | 156 | .resume = s3c244x_resume |
| 157 | 157 | }; |
| 158 | 158 | |
| 159 | 159 | struct sysdev_class s3c2442_sysclass = { |
| 160 | - set_kset_name("s3c2442-core"), | |
| 160 | + .name = "s3c2442-core", | |
| 161 | 161 | .suspend = s3c244x_suspend, |
| 162 | 162 | .resume = s3c244x_resume |
| 163 | 163 | }; |
arch/avr32/kernel/time.c
arch/mips/kernel/i8259.c
arch/powerpc/platforms/cell/spu_base.c
arch/powerpc/platforms/powermac/pic.c
arch/powerpc/sysdev/ipic.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/qe_lib/qe_ic.c
arch/ppc/syslib/ipic.c
arch/ppc/syslib/open_pic.c
arch/ppc/syslib/open_pic2.c
arch/s390/kernel/time.c
arch/sh/drivers/dma/dma-sysfs.c
arch/sh/kernel/time.c
arch/x86/kernel/apic_32.c
arch/x86/kernel/apic_64.c
arch/x86/kernel/cpu/mcheck/mce_64.c
arch/x86/kernel/i8237.c
arch/x86/kernel/i8259_32.c
arch/x86/kernel/i8259_64.c
arch/x86/kernel/io_apic_32.c
arch/x86/kernel/io_apic_64.c
arch/x86/kernel/nmi_32.c
arch/x86/kernel/nmi_64.c
arch/x86/oprofile/nmi_int.c
drivers/acpi/pci_link.c
| ... | ... | @@ -911,7 +911,7 @@ |
| 911 | 911 | |
| 912 | 912 | /* FIXME: we will remove this interface after all drivers call pci_disable_device */ |
| 913 | 913 | static struct sysdev_class irqrouter_sysdev_class = { |
| 914 | - set_kset_name("irqrouter"), | |
| 914 | + .name = "irqrouter", | |
| 915 | 915 | .resume = irqrouter_resume, |
| 916 | 916 | }; |
| 917 | 917 |
drivers/base/class.c
| ... | ... | @@ -466,7 +466,6 @@ |
| 466 | 466 | * entirely soon. |
| 467 | 467 | */ |
| 468 | 468 | static struct kset class_obj_subsys = { |
| 469 | - .kobj = { .k_name = "class_obj", }, | |
| 470 | 469 | .uevent_ops = &class_uevent_ops, |
| 471 | 470 | }; |
| 472 | 471 | |
| ... | ... | @@ -872,6 +871,7 @@ |
| 872 | 871 | /* ick, this is ugly, the things we go through to keep from showing up |
| 873 | 872 | * in sysfs... */ |
| 874 | 873 | kset_init(&class_obj_subsys); |
| 874 | + kobject_set_name(&class_obj_subsys.kobj, "class_obj"); | |
| 875 | 875 | if (!class_obj_subsys.kobj.parent) |
| 876 | 876 | class_obj_subsys.kobj.parent = &class_obj_subsys.kobj; |
| 877 | 877 | return 0; |
drivers/base/cpu.c
drivers/base/memory.c
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | #define MEMORY_CLASS_NAME "memory" |
| 27 | 27 | |
| 28 | 28 | static struct sysdev_class memory_sysdev_class = { |
| 29 | - set_kset_name(MEMORY_CLASS_NAME), | |
| 29 | + .name = MEMORY_CLASS_NAME, | |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) |
drivers/base/node.c
drivers/base/sys.c
drivers/edac/edac_module.c
drivers/kvm/kvm_main.c
drivers/macintosh/via-pmu.c
drivers/scsi/libsas/sas_scsi_host.c
| ... | ... | @@ -464,7 +464,7 @@ |
| 464 | 464 | res = sas_phy_reset(phy, 1); |
| 465 | 465 | if (res) |
| 466 | 466 | SAS_DPRINTK("Bus reset of %s failed 0x%x\n", |
| 467 | - phy->dev.kobj.k_name, | |
| 467 | + kobject_name(&phy->dev.kobj), | |
| 468 | 468 | res); |
| 469 | 469 | if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE) |
| 470 | 470 | return SUCCESS; |
include/linux/kobject.h
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | struct kobject { |
| 64 | - const char * k_name; | |
| 64 | + const char *name; | |
| 65 | 65 | struct kref kref; |
| 66 | 66 | struct list_head entry; |
| 67 | 67 | struct kobject * parent; |
| ... | ... | @@ -69,7 +69,6 @@ |
| 69 | 69 | struct kobj_type * ktype; |
| 70 | 70 | struct sysfs_dirent * sd; |
| 71 | 71 | unsigned int state_initialized:1; |
| 72 | - unsigned int state_name_set:1; | |
| 73 | 72 | unsigned int state_in_sysfs:1; |
| 74 | 73 | unsigned int state_add_uevent_sent:1; |
| 75 | 74 | unsigned int state_remove_uevent_sent:1; |
| ... | ... | @@ -80,7 +79,7 @@ |
| 80 | 79 | |
| 81 | 80 | static inline const char * kobject_name(const struct kobject * kobj) |
| 82 | 81 | { |
| 83 | - return kobj->k_name; | |
| 82 | + return kobj->name; | |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); |
| ... | ... | @@ -188,14 +187,6 @@ |
| 188 | 187 | } |
| 189 | 188 | |
| 190 | 189 | extern struct kobject * kset_find_obj(struct kset *, const char *); |
| 191 | - | |
| 192 | - | |
| 193 | -/* | |
| 194 | - * Use this when initializing an embedded kset with no other | |
| 195 | - * fields to initialize. | |
| 196 | - */ | |
| 197 | -#define set_kset_name(str) .kset = { .kobj = { .k_name = str } } | |
| 198 | - | |
| 199 | 190 | |
| 200 | 191 | /* The global /sys/kernel/ kobject for people to chain off of */ |
| 201 | 192 | extern struct kobject *kernel_kobj; |
include/linux/sysdev.h
kernel/rtmutex-tester.c
kernel/time/clocksource.c
kernel/time/timekeeping.c
| ... | ... | @@ -335,9 +335,9 @@ |
| 335 | 335 | |
| 336 | 336 | /* sysfs resume/suspend bits for timekeeping */ |
| 337 | 337 | static struct sysdev_class timekeeping_sysclass = { |
| 338 | + .name = "timekeeping", | |
| 338 | 339 | .resume = timekeeping_resume, |
| 339 | 340 | .suspend = timekeeping_suspend, |
| 340 | - set_kset_name("timekeeping"), | |
| 341 | 341 | }; |
| 342 | 342 | |
| 343 | 343 | static struct sys_device device_timer = { |
lib/kobject.c
| ... | ... | @@ -165,7 +165,7 @@ |
| 165 | 165 | if (!kobj) |
| 166 | 166 | return -ENOENT; |
| 167 | 167 | |
| 168 | - if (!kobj->k_name || !kobj->k_name[0]) { | |
| 168 | + if (!kobj->name || !kobj->name[0]) { | |
| 169 | 169 | pr_debug("kobject: (%p): attempted to be registered with empty " |
| 170 | 170 | "name!\n", kobj); |
| 171 | 171 | WARN_ON(1); |
| 172 | 172 | |
| 173 | 173 | |
| ... | ... | @@ -228,13 +228,11 @@ |
| 228 | 228 | if (!name) |
| 229 | 229 | return -ENOMEM; |
| 230 | 230 | |
| 231 | - | |
| 232 | 231 | /* Free the old name, if necessary. */ |
| 233 | - kfree(kobj->k_name); | |
| 232 | + kfree(kobj->name); | |
| 234 | 233 | |
| 235 | 234 | /* Now, set the new name */ |
| 236 | - kobj->k_name = name; | |
| 237 | - kobj->state_name_set = 1; | |
| 235 | + kobj->name = name; | |
| 238 | 236 | |
| 239 | 237 | return 0; |
| 240 | 238 | } |
| ... | ... | @@ -295,7 +293,6 @@ |
| 295 | 293 | kref_init(&kobj->kref); |
| 296 | 294 | INIT_LIST_HEAD(&kobj->entry); |
| 297 | 295 | kobj->ktype = ktype; |
| 298 | - kobj->state_name_set = 0; | |
| 299 | 296 | kobj->state_in_sysfs = 0; |
| 300 | 297 | kobj->state_add_uevent_sent = 0; |
| 301 | 298 | kobj->state_remove_uevent_sent = 0; |
| ... | ... | @@ -551,8 +548,7 @@ |
| 551 | 548 | static void kobject_cleanup(struct kobject *kobj) |
| 552 | 549 | { |
| 553 | 550 | struct kobj_type *t = get_ktype(kobj); |
| 554 | - const char *name = kobj->k_name; | |
| 555 | - int name_set = kobj->state_name_set; | |
| 551 | + const char *name = kobj->name; | |
| 556 | 552 | |
| 557 | 553 | pr_debug("kobject: '%s' (%p): %s\n", |
| 558 | 554 | kobject_name(kobj), kobj, __FUNCTION__); |
| ... | ... | @@ -583,7 +579,7 @@ |
| 583 | 579 | } |
| 584 | 580 | |
| 585 | 581 | /* free name if we allocated it */ |
| 586 | - if (name_set && name) { | |
| 582 | + if (name) { | |
| 587 | 583 | pr_debug("kobject: '%s': free name\n", name); |
| 588 | 584 | kfree(name); |
| 589 | 585 | } |