diff options
author | Paul Mackerras <paulus@samba.org> | 2008-01-30 19:25:51 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-01-30 19:25:51 -0500 |
commit | bd45ac0c5daae35e7c71138172e63df5cf644cf6 (patch) | |
tree | 5eb5a599bf6a9d7a8a34e802db932aa9e9555de4 /drivers/pci/hotplug | |
parent | 4eece4ccf997c0e6d8fdad3d842e37b16b8d705f (diff) | |
parent | 5bdeae46be6dfe9efa44a548bd622af325f4bdb4 (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r-- | drivers/pci/hotplug/acpiphp_ibm.c | 4 | ||||
-rw-r--r-- | drivers/pci/hotplug/pci_hotplug_core.c | 39 | ||||
-rw-r--r-- | drivers/pci/hotplug/rpadlpar_sysfs.c | 113 |
3 files changed, 66 insertions, 90 deletions
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c index 47d26b65e99a..750ebd7a4c10 100644 --- a/drivers/pci/hotplug/acpiphp_ibm.c +++ b/drivers/pci/hotplug/acpiphp_ibm.c | |||
@@ -429,7 +429,7 @@ static int __init ibm_acpiphp_init(void) | |||
429 | int retval = 0; | 429 | int retval = 0; |
430 | acpi_status status; | 430 | acpi_status status; |
431 | struct acpi_device *device; | 431 | struct acpi_device *device; |
432 | struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj; | 432 | struct kobject *sysdir = &pci_hotplug_slots_kset->kobj; |
433 | 433 | ||
434 | dbg("%s\n", __FUNCTION__); | 434 | dbg("%s\n", __FUNCTION__); |
435 | 435 | ||
@@ -476,7 +476,7 @@ init_return: | |||
476 | static void __exit ibm_acpiphp_exit(void) | 476 | static void __exit ibm_acpiphp_exit(void) |
477 | { | 477 | { |
478 | acpi_status status; | 478 | acpi_status status; |
479 | struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj; | 479 | struct kobject *sysdir = &pci_hotplug_slots_kset->kobj; |
480 | 480 | ||
481 | dbg("%s\n", __FUNCTION__); | 481 | dbg("%s\n", __FUNCTION__); |
482 | 482 | ||
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c index 01c351c176ac..47bb0e1ff3fa 100644 --- a/drivers/pci/hotplug/pci_hotplug_core.c +++ b/drivers/pci/hotplug/pci_hotplug_core.c | |||
@@ -61,7 +61,7 @@ static int debug; | |||
61 | 61 | ||
62 | static LIST_HEAD(pci_hotplug_slot_list); | 62 | static LIST_HEAD(pci_hotplug_slot_list); |
63 | 63 | ||
64 | struct kset pci_hotplug_slots_subsys; | 64 | struct kset *pci_hotplug_slots_kset; |
65 | 65 | ||
66 | static ssize_t hotplug_slot_attr_show(struct kobject *kobj, | 66 | static ssize_t hotplug_slot_attr_show(struct kobject *kobj, |
67 | struct attribute *attr, char *buf) | 67 | struct attribute *attr, char *buf) |
@@ -96,8 +96,6 @@ static struct kobj_type hotplug_slot_ktype = { | |||
96 | .release = &hotplug_slot_release, | 96 | .release = &hotplug_slot_release, |
97 | }; | 97 | }; |
98 | 98 | ||
99 | decl_subsys_name(pci_hotplug_slots, slots, &hotplug_slot_ktype, NULL); | ||
100 | |||
101 | /* these strings match up with the values in pci_bus_speed */ | 99 | /* these strings match up with the values in pci_bus_speed */ |
102 | static char *pci_bus_speed_strings[] = { | 100 | static char *pci_bus_speed_strings[] = { |
103 | "33 MHz PCI", /* 0x00 */ | 101 | "33 MHz PCI", /* 0x00 */ |
@@ -632,18 +630,19 @@ int pci_hp_register (struct hotplug_slot *slot) | |||
632 | return -EINVAL; | 630 | return -EINVAL; |
633 | } | 631 | } |
634 | 632 | ||
635 | kobject_set_name(&slot->kobj, "%s", slot->name); | ||
636 | kobj_set_kset_s(slot, pci_hotplug_slots_subsys); | ||
637 | |||
638 | /* this can fail if we have already registered a slot with the same name */ | 633 | /* this can fail if we have already registered a slot with the same name */ |
639 | if (kobject_register(&slot->kobj)) { | 634 | slot->kobj.kset = pci_hotplug_slots_kset; |
640 | err("Unable to register kobject"); | 635 | result = kobject_init_and_add(&slot->kobj, &hotplug_slot_ktype, NULL, |
636 | "%s", slot->name); | ||
637 | if (result) { | ||
638 | err("Unable to register kobject '%s'", slot->name); | ||
641 | return -EINVAL; | 639 | return -EINVAL; |
642 | } | 640 | } |
643 | 641 | ||
644 | list_add (&slot->slot_list, &pci_hotplug_slot_list); | 642 | list_add (&slot->slot_list, &pci_hotplug_slot_list); |
645 | 643 | ||
646 | result = fs_add_slot (slot); | 644 | result = fs_add_slot (slot); |
645 | kobject_uevent(&slot->kobj, KOBJ_ADD); | ||
647 | dbg ("Added slot %s to the list\n", slot->name); | 646 | dbg ("Added slot %s to the list\n", slot->name); |
648 | return result; | 647 | return result; |
649 | } | 648 | } |
@@ -672,7 +671,7 @@ int pci_hp_deregister (struct hotplug_slot *slot) | |||
672 | 671 | ||
673 | fs_remove_slot (slot); | 672 | fs_remove_slot (slot); |
674 | dbg ("Removed slot %s from the list\n", slot->name); | 673 | dbg ("Removed slot %s from the list\n", slot->name); |
675 | kobject_unregister(&slot->kobj); | 674 | kobject_put(&slot->kobj); |
676 | return 0; | 675 | return 0; |
677 | } | 676 | } |
678 | 677 | ||
@@ -700,11 +699,15 @@ int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot, | |||
700 | static int __init pci_hotplug_init (void) | 699 | static int __init pci_hotplug_init (void) |
701 | { | 700 | { |
702 | int result; | 701 | int result; |
702 | struct kset *pci_bus_kset; | ||
703 | 703 | ||
704 | kobj_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys); | 704 | pci_bus_kset = bus_get_kset(&pci_bus_type); |
705 | result = subsystem_register(&pci_hotplug_slots_subsys); | 705 | |
706 | if (result) { | 706 | pci_hotplug_slots_kset = kset_create_and_add("slots", NULL, |
707 | err("Register subsys with error %d\n", result); | 707 | &pci_bus_kset->kobj); |
708 | if (!pci_hotplug_slots_kset) { | ||
709 | result = -ENOMEM; | ||
710 | err("Register subsys error\n"); | ||
708 | goto exit; | 711 | goto exit; |
709 | } | 712 | } |
710 | result = cpci_hotplug_init(debug); | 713 | result = cpci_hotplug_init(debug); |
@@ -715,9 +718,9 @@ static int __init pci_hotplug_init (void) | |||
715 | 718 | ||
716 | info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 719 | info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
717 | goto exit; | 720 | goto exit; |
718 | 721 | ||
719 | err_subsys: | 722 | err_subsys: |
720 | subsystem_unregister(&pci_hotplug_slots_subsys); | 723 | kset_unregister(pci_hotplug_slots_kset); |
721 | exit: | 724 | exit: |
722 | return result; | 725 | return result; |
723 | } | 726 | } |
@@ -725,7 +728,7 @@ exit: | |||
725 | static void __exit pci_hotplug_exit (void) | 728 | static void __exit pci_hotplug_exit (void) |
726 | { | 729 | { |
727 | cpci_hotplug_exit(); | 730 | cpci_hotplug_exit(); |
728 | subsystem_unregister(&pci_hotplug_slots_subsys); | 731 | kset_unregister(pci_hotplug_slots_kset); |
729 | } | 732 | } |
730 | 733 | ||
731 | module_init(pci_hotplug_init); | 734 | module_init(pci_hotplug_init); |
@@ -737,7 +740,7 @@ MODULE_LICENSE("GPL"); | |||
737 | module_param(debug, bool, 0644); | 740 | module_param(debug, bool, 0644); |
738 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); | 741 | MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); |
739 | 742 | ||
740 | EXPORT_SYMBOL_GPL(pci_hotplug_slots_subsys); | 743 | EXPORT_SYMBOL_GPL(pci_hotplug_slots_kset); |
741 | EXPORT_SYMBOL_GPL(pci_hp_register); | 744 | EXPORT_SYMBOL_GPL(pci_hp_register); |
742 | EXPORT_SYMBOL_GPL(pci_hp_deregister); | 745 | EXPORT_SYMBOL_GPL(pci_hp_deregister); |
743 | EXPORT_SYMBOL_GPL(pci_hp_change_slot_info); | 746 | EXPORT_SYMBOL_GPL(pci_hp_change_slot_info); |
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c index a080fedf0332..e32148a8fa12 100644 --- a/drivers/pci/hotplug/rpadlpar_sysfs.c +++ b/drivers/pci/hotplug/rpadlpar_sysfs.c | |||
@@ -23,44 +23,13 @@ | |||
23 | 23 | ||
24 | #define MAX_DRC_NAME_LEN 64 | 24 | #define MAX_DRC_NAME_LEN 64 |
25 | 25 | ||
26 | /* Store return code of dlpar operation in attribute struct */ | ||
27 | struct dlpar_io_attr { | ||
28 | int rc; | ||
29 | struct attribute attr; | ||
30 | ssize_t (*store)(struct dlpar_io_attr *dlpar_attr, const char *buf, | ||
31 | size_t nbytes); | ||
32 | }; | ||
33 | 26 | ||
34 | /* Common show callback for all attrs, display the return code | 27 | static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, |
35 | * of the dlpar op */ | 28 | const char *buf, size_t nbytes) |
36 | static ssize_t | ||
37 | dlpar_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | ||
38 | { | ||
39 | struct dlpar_io_attr *dlpar_attr = container_of(attr, | ||
40 | struct dlpar_io_attr, attr); | ||
41 | return sprintf(buf, "%d\n", dlpar_attr->rc); | ||
42 | } | ||
43 | |||
44 | static ssize_t | ||
45 | dlpar_attr_store(struct kobject * kobj, struct attribute * attr, | ||
46 | const char *buf, size_t nbytes) | ||
47 | { | ||
48 | struct dlpar_io_attr *dlpar_attr = container_of(attr, | ||
49 | struct dlpar_io_attr, attr); | ||
50 | return dlpar_attr->store ? | ||
51 | dlpar_attr->store(dlpar_attr, buf, nbytes) : -EIO; | ||
52 | } | ||
53 | |||
54 | static struct sysfs_ops dlpar_attr_sysfs_ops = { | ||
55 | .show = dlpar_attr_show, | ||
56 | .store = dlpar_attr_store, | ||
57 | }; | ||
58 | |||
59 | static ssize_t add_slot_store(struct dlpar_io_attr *dlpar_attr, | ||
60 | const char *buf, size_t nbytes) | ||
61 | { | 29 | { |
62 | char drc_name[MAX_DRC_NAME_LEN]; | 30 | char drc_name[MAX_DRC_NAME_LEN]; |
63 | char *end; | 31 | char *end; |
32 | int rc; | ||
64 | 33 | ||
65 | if (nbytes >= MAX_DRC_NAME_LEN) | 34 | if (nbytes >= MAX_DRC_NAME_LEN) |
66 | return 0; | 35 | return 0; |
@@ -72,15 +41,25 @@ static ssize_t add_slot_store(struct dlpar_io_attr *dlpar_attr, | |||
72 | end = &drc_name[nbytes]; | 41 | end = &drc_name[nbytes]; |
73 | *end = '\0'; | 42 | *end = '\0'; |
74 | 43 | ||
75 | dlpar_attr->rc = dlpar_add_slot(drc_name); | 44 | rc = dlpar_add_slot(drc_name); |
45 | if (rc) | ||
46 | return rc; | ||
76 | 47 | ||
77 | return nbytes; | 48 | return nbytes; |
78 | } | 49 | } |
79 | 50 | ||
80 | static ssize_t remove_slot_store(struct dlpar_io_attr *dlpar_attr, | 51 | static ssize_t add_slot_show(struct kobject *kobj, |
81 | const char *buf, size_t nbytes) | 52 | struct kobj_attribute *attr, char *buf) |
53 | { | ||
54 | return sprintf(buf, "0\n"); | ||
55 | } | ||
56 | |||
57 | static ssize_t remove_slot_store(struct kobject *kobj, | ||
58 | struct kobj_attribute *attr, | ||
59 | const char *buf, size_t nbytes) | ||
82 | { | 60 | { |
83 | char drc_name[MAX_DRC_NAME_LEN]; | 61 | char drc_name[MAX_DRC_NAME_LEN]; |
62 | int rc; | ||
84 | char *end; | 63 | char *end; |
85 | 64 | ||
86 | if (nbytes >= MAX_DRC_NAME_LEN) | 65 | if (nbytes >= MAX_DRC_NAME_LEN) |
@@ -93,22 +72,24 @@ static ssize_t remove_slot_store(struct dlpar_io_attr *dlpar_attr, | |||
93 | end = &drc_name[nbytes]; | 72 | end = &drc_name[nbytes]; |
94 | *end = '\0'; | 73 | *end = '\0'; |
95 | 74 | ||
96 | dlpar_attr->rc = dlpar_remove_slot(drc_name); | 75 | rc = dlpar_remove_slot(drc_name); |
76 | if (rc) | ||
77 | return rc; | ||
97 | 78 | ||
98 | return nbytes; | 79 | return nbytes; |
99 | } | 80 | } |
100 | 81 | ||
101 | static struct dlpar_io_attr add_slot_attr = { | 82 | static ssize_t remove_slot_show(struct kobject *kobj, |
102 | .rc = 0, | 83 | struct kobj_attribute *attr, char *buf) |
103 | .attr = { .name = ADD_SLOT_ATTR_NAME, .mode = 0644, }, | 84 | { |
104 | .store = add_slot_store, | 85 | return sprintf(buf, "0\n"); |
105 | }; | 86 | } |
106 | 87 | ||
107 | static struct dlpar_io_attr remove_slot_attr = { | 88 | static struct kobj_attribute add_slot_attr = |
108 | .rc = 0, | 89 | __ATTR(ADD_SLOT_ATTR_NAME, 0644, add_slot_show, add_slot_store); |
109 | .attr = { .name = REMOVE_SLOT_ATTR_NAME, .mode = 0644}, | 90 | |
110 | .store = remove_slot_store, | 91 | static struct kobj_attribute remove_slot_attr = |
111 | }; | 92 | __ATTR(REMOVE_SLOT_ATTR_NAME, 0644, remove_slot_show, remove_slot_store); |
112 | 93 | ||
113 | static struct attribute *default_attrs[] = { | 94 | static struct attribute *default_attrs[] = { |
114 | &add_slot_attr.attr, | 95 | &add_slot_attr.attr, |
@@ -116,37 +97,29 @@ static struct attribute *default_attrs[] = { | |||
116 | NULL, | 97 | NULL, |
117 | }; | 98 | }; |
118 | 99 | ||
119 | static void dlpar_io_release(struct kobject *kobj) | 100 | static struct attribute_group dlpar_attr_group = { |
120 | { | 101 | .attrs = default_attrs, |
121 | /* noop */ | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | struct kobj_type ktype_dlpar_io = { | ||
126 | .release = dlpar_io_release, | ||
127 | .sysfs_ops = &dlpar_attr_sysfs_ops, | ||
128 | .default_attrs = default_attrs, | ||
129 | }; | 102 | }; |
130 | 103 | ||
131 | struct kset dlpar_io_kset = { | 104 | static struct kobject *dlpar_kobj; |
132 | .kobj = {.ktype = &ktype_dlpar_io, | ||
133 | .parent = &pci_hotplug_slots_subsys.kobj}, | ||
134 | .ktype = &ktype_dlpar_io, | ||
135 | }; | ||
136 | 105 | ||
137 | int dlpar_sysfs_init(void) | 106 | int dlpar_sysfs_init(void) |
138 | { | 107 | { |
139 | kobject_set_name(&dlpar_io_kset.kobj, DLPAR_KOBJ_NAME); | 108 | int error; |
140 | if (kset_register(&dlpar_io_kset)) { | 109 | |
141 | printk(KERN_ERR "rpadlpar_io: cannot register kset for %s\n", | 110 | dlpar_kobj = kobject_create_and_add(DLPAR_KOBJ_NAME, |
142 | kobject_name(&dlpar_io_kset.kobj)); | 111 | &pci_hotplug_slots_kset->kobj); |
112 | if (!dlpar_kobj) | ||
143 | return -EINVAL; | 113 | return -EINVAL; |
144 | } | ||
145 | 114 | ||
146 | return 0; | 115 | error = sysfs_create_group(dlpar_kobj, &dlpar_attr_group); |
116 | if (error) | ||
117 | kobject_put(dlpar_kobj); | ||
118 | return error; | ||
147 | } | 119 | } |
148 | 120 | ||
149 | void dlpar_sysfs_exit(void) | 121 | void dlpar_sysfs_exit(void) |
150 | { | 122 | { |
151 | kset_unregister(&dlpar_io_kset); | 123 | sysfs_remove_group(dlpar_kobj, &dlpar_attr_group); |
124 | kobject_put(dlpar_kobj); | ||
152 | } | 125 | } |