diff options
author | Alex Chiang <achiang@hp.com> | 2008-06-10 17:28:50 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-06-10 17:37:03 -0400 |
commit | f46753c5e354b857b20ab8e0fe7b2579831dc369 (patch) | |
tree | efffdb4dfec5e1f6fd624f17aa36d7d350bb1e6c /include/linux | |
parent | fe99740cac117f208707488c03f3789cf4904957 (diff) |
PCI: introduce pci_slot
Currently, /sys/bus/pci/slots/ only exposes hotplug attributes when a
hotplug driver is loaded, but PCI slots have attributes such as address,
speed, width, etc. that are not related to hotplug at all.
Introduce pci_slot as the primary data structure and kobject model.
Hotplug attributes described in hotplug_slot become a secondary
structure associated with the pci_slot.
This patch only creates the infrastructure that allows the separation of
PCI slot attributes and hotplug attributes. In this patch, the PCI
hotplug core remains the only user of this infrastructure, and thus,
/sys/bus/pci/slots/ will still only become populated when a hotplug
driver is loaded.
A later patch in this series will add a second user of this new
infrastructure and demonstrate splitting the task of exposing pci_slot
attributes from hotplug_slot attributes.
- Make pci_slot the primary sysfs entity. hotplug_slot becomes a
subsidiary structure.
o pci_create_slot() creates and registers a slot with the PCI core
o pci_slot_add_hotplug() gives it hotplug capability
- Change the prototype of pci_hp_register() to take the bus and
slot number (on parent bus) as parameters.
- Remove all the ->get_address methods since this functionality is
now handled by pci_slot directly.
[achiang@hp.com: rpaphp-correctly-pci_hp_register-for-empty-pci-slots]
Tested-by: Badari Pulavarty <pbadari@us.ibm.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: make headers_check happy]
[akpm@linux-foundation.org: nuther build fix]
[akpm@linux-foundation.org: fix typo in #include]
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Cc: Greg KH <greg@kroah.com>
Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Cc: Len Brown <lenb@kernel.org>
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/pci.h | 19 | ||||
-rw-r--r-- | include/linux/pci_hotplug.h | 12 |
2 files changed, 20 insertions, 11 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index 507ee52323cd..f1f73f79a180 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -17,8 +17,7 @@ | |||
17 | #ifndef LINUX_PCI_H | 17 | #ifndef LINUX_PCI_H |
18 | #define LINUX_PCI_H | 18 | #define LINUX_PCI_H |
19 | 19 | ||
20 | /* Include the pci register defines */ | 20 | #include <linux/pci_regs.h> /* The pci register defines */ |
21 | #include <linux/pci_regs.h> | ||
22 | 21 | ||
23 | /* | 22 | /* |
24 | * The PCI interface treats multi-function devices as independent | 23 | * The PCI interface treats multi-function devices as independent |
@@ -49,12 +48,22 @@ | |||
49 | #include <linux/list.h> | 48 | #include <linux/list.h> |
50 | #include <linux/compiler.h> | 49 | #include <linux/compiler.h> |
51 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
51 | #include <linux/kobject.h> | ||
52 | #include <asm/atomic.h> | 52 | #include <asm/atomic.h> |
53 | #include <linux/device.h> | 53 | #include <linux/device.h> |
54 | 54 | ||
55 | /* Include the ID list */ | 55 | /* Include the ID list */ |
56 | #include <linux/pci_ids.h> | 56 | #include <linux/pci_ids.h> |
57 | 57 | ||
58 | /* pci_slot represents a physical slot */ | ||
59 | struct pci_slot { | ||
60 | struct pci_bus *bus; /* The bus this slot is on */ | ||
61 | struct list_head list; /* node in list of slots on this bus */ | ||
62 | struct hotplug_slot *hotplug; /* Hotplug info (migrate over time) */ | ||
63 | unsigned char number; /* PCI_SLOT(pci_dev->devfn) */ | ||
64 | struct kobject kobj; | ||
65 | }; | ||
66 | |||
58 | /* File state for mmap()s on /proc/bus/pci/X/Y */ | 67 | /* File state for mmap()s on /proc/bus/pci/X/Y */ |
59 | enum pci_mmap_state { | 68 | enum pci_mmap_state { |
60 | pci_mmap_io, | 69 | pci_mmap_io, |
@@ -142,6 +151,7 @@ struct pci_dev { | |||
142 | 151 | ||
143 | void *sysdata; /* hook for sys-specific extension */ | 152 | void *sysdata; /* hook for sys-specific extension */ |
144 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ | 153 | struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */ |
154 | struct pci_slot *slot; /* Physical slot this device is in */ | ||
145 | 155 | ||
146 | unsigned int devfn; /* encoded device & function index */ | 156 | unsigned int devfn; /* encoded device & function index */ |
147 | unsigned short vendor; | 157 | unsigned short vendor; |
@@ -266,6 +276,7 @@ struct pci_bus { | |||
266 | struct list_head children; /* list of child buses */ | 276 | struct list_head children; /* list of child buses */ |
267 | struct list_head devices; /* list of devices on this bus */ | 277 | struct list_head devices; /* list of devices on this bus */ |
268 | struct pci_dev *self; /* bridge device as seen by parent */ | 278 | struct pci_dev *self; /* bridge device as seen by parent */ |
279 | struct list_head slots; /* list of slots on this bus */ | ||
269 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; | 280 | struct resource *resource[PCI_BUS_NUM_RESOURCES]; |
270 | /* address space routed to this bus */ | 281 | /* address space routed to this bus */ |
271 | 282 | ||
@@ -488,6 +499,10 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus, | |||
488 | struct pci_ops *ops, void *sysdata); | 499 | struct pci_ops *ops, void *sysdata); |
489 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, | 500 | struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, |
490 | int busnr); | 501 | int busnr); |
502 | struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, | ||
503 | const char *name); | ||
504 | void pci_destroy_slot(struct pci_slot *slot); | ||
505 | void pci_update_slot_number(struct pci_slot *slot, int slot_nr); | ||
491 | int pci_scan_slot(struct pci_bus *bus, int devfn); | 506 | int pci_scan_slot(struct pci_bus *bus, int devfn); |
492 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); | 507 | struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); |
493 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); | 508 | void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); |
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h index dbdcd1ad3c6a..a08cd06b541a 100644 --- a/include/linux/pci_hotplug.h +++ b/include/linux/pci_hotplug.h | |||
@@ -95,9 +95,6 @@ struct hotplug_slot_attribute { | |||
95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. | 95 | * @get_adapter_status: Called to get see if an adapter is present in the slot or not. |
96 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 96 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
97 | * will be used when this value is requested by a user. | 97 | * will be used when this value is requested by a user. |
98 | * @get_address: Called to get pci address of a slot. | ||
99 | * If this field is NULL, the value passed in the struct hotplug_slot_info | ||
100 | * will be used when this value is requested by a user. | ||
101 | * @get_max_bus_speed: Called to get the max bus speed for a slot. | 98 | * @get_max_bus_speed: Called to get the max bus speed for a slot. |
102 | * If this field is NULL, the value passed in the struct hotplug_slot_info | 99 | * If this field is NULL, the value passed in the struct hotplug_slot_info |
103 | * will be used when this value is requested by a user. | 100 | * will be used when this value is requested by a user. |
@@ -120,7 +117,6 @@ struct hotplug_slot_ops { | |||
120 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); | 117 | int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); |
121 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); | 118 | int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); |
122 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); | 119 | int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); |
123 | int (*get_address) (struct hotplug_slot *slot, u32 *value); | ||
124 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 120 | int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
125 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); | 121 | int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value); |
126 | }; | 122 | }; |
@@ -140,7 +136,6 @@ struct hotplug_slot_info { | |||
140 | u8 attention_status; | 136 | u8 attention_status; |
141 | u8 latch_status; | 137 | u8 latch_status; |
142 | u8 adapter_status; | 138 | u8 adapter_status; |
143 | u32 address; | ||
144 | enum pci_bus_speed max_bus_speed; | 139 | enum pci_bus_speed max_bus_speed; |
145 | enum pci_bus_speed cur_bus_speed; | 140 | enum pci_bus_speed cur_bus_speed; |
146 | }; | 141 | }; |
@@ -166,15 +161,14 @@ struct hotplug_slot { | |||
166 | 161 | ||
167 | /* Variables below this are for use only by the hotplug pci core. */ | 162 | /* Variables below this are for use only by the hotplug pci core. */ |
168 | struct list_head slot_list; | 163 | struct list_head slot_list; |
169 | struct kobject kobj; | 164 | struct pci_slot *pci_slot; |
170 | }; | 165 | }; |
171 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) | 166 | #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) |
172 | 167 | ||
173 | extern int pci_hp_register (struct hotplug_slot *slot); | 168 | extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr); |
174 | extern int pci_hp_deregister (struct hotplug_slot *slot); | 169 | extern int pci_hp_deregister(struct hotplug_slot *slot); |
175 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, | 170 | extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, |
176 | struct hotplug_slot_info *info); | 171 | struct hotplug_slot_info *info); |
177 | extern struct kset *pci_hotplug_slots_kset; | ||
178 | 172 | ||
179 | /* PCI Setting Record (Type 0) */ | 173 | /* PCI Setting Record (Type 0) */ |
180 | struct hpp_type0 { | 174 | struct hpp_type0 { |