hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/pci/hotplug/acpiphp_core.c
....@@ -8,7 +8,7 @@
88 * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
99 * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
1010 * Copyright (C) 2002,2003 NEC Corporation
11
- * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com)
11
+ * Copyright (C) 2003-2005 Matthew Wilcox (willy@infradead.org)
1212 * Copyright (C) 2003-2005 Hewlett Packard
1313 *
1414 * All rights reserved.
....@@ -40,7 +40,7 @@
4040 static struct acpiphp_attention_info *attention_info;
4141
4242 #define DRIVER_VERSION "0.5"
43
-#define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kochi@bq.jp.nec.com>, Matthew Wilcox <willy@hp.com>"
43
+#define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@us.ibm.com>, Takayoshi Kochi <t-kochi@bq.jp.nec.com>, Matthew Wilcox <willy@infradead.org>"
4444 #define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver"
4545
4646 MODULE_AUTHOR(DRIVER_AUTHOR);
....@@ -57,7 +57,7 @@
5757 static int get_latch_status(struct hotplug_slot *slot, u8 *value);
5858 static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
5959
60
-static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
60
+static const struct hotplug_slot_ops acpi_hotplug_slot_ops = {
6161 .enable_slot = enable_slot,
6262 .disable_slot = disable_slot,
6363 .set_attention_status = set_attention_status,
....@@ -118,7 +118,7 @@
118118 */
119119 static int enable_slot(struct hotplug_slot *hotplug_slot)
120120 {
121
- struct slot *slot = hotplug_slot->private;
121
+ struct slot *slot = to_slot(hotplug_slot);
122122
123123 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
124124
....@@ -135,7 +135,7 @@
135135 */
136136 static int disable_slot(struct hotplug_slot *hotplug_slot)
137137 {
138
- struct slot *slot = hotplug_slot->private;
138
+ struct slot *slot = to_slot(hotplug_slot);
139139
140140 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
141141
....@@ -179,7 +179,7 @@
179179 */
180180 static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
181181 {
182
- struct slot *slot = hotplug_slot->private;
182
+ struct slot *slot = to_slot(hotplug_slot);
183183
184184 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
185185
....@@ -225,7 +225,7 @@
225225 */
226226 static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
227227 {
228
- struct slot *slot = hotplug_slot->private;
228
+ struct slot *slot = to_slot(hotplug_slot);
229229
230230 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
231231
....@@ -245,7 +245,7 @@
245245 */
246246 static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
247247 {
248
- struct slot *slot = hotplug_slot->private;
248
+ struct slot *slot = to_slot(hotplug_slot);
249249
250250 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
251251
....@@ -266,39 +266,26 @@
266266 if (!slot)
267267 goto error;
268268
269
- slot->hotplug_slot = kzalloc(sizeof(*slot->hotplug_slot), GFP_KERNEL);
270
- if (!slot->hotplug_slot)
271
- goto error_slot;
272
-
273
- slot->hotplug_slot->info = &slot->info;
274
-
275
- slot->hotplug_slot->private = slot;
276
- slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
269
+ slot->hotplug_slot.ops = &acpi_hotplug_slot_ops;
277270
278271 slot->acpi_slot = acpiphp_slot;
279
- slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
280
- slot->hotplug_slot->info->attention_status = 0;
281
- slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
282
- slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
283272
284273 acpiphp_slot->slot = slot;
285274 slot->sun = sun;
286275 snprintf(name, SLOT_NAME_SIZE, "%u", sun);
287276
288
- retval = pci_hp_register(slot->hotplug_slot, acpiphp_slot->bus,
277
+ retval = pci_hp_register(&slot->hotplug_slot, acpiphp_slot->bus,
289278 acpiphp_slot->device, name);
290279 if (retval == -EBUSY)
291
- goto error_hpslot;
280
+ goto error_slot;
292281 if (retval) {
293282 pr_err("pci_hp_register failed with error %d\n", retval);
294
- goto error_hpslot;
283
+ goto error_slot;
295284 }
296285
297286 pr_info("Slot [%s] registered\n", slot_name(slot));
298287
299288 return 0;
300
-error_hpslot:
301
- kfree(slot->hotplug_slot);
302289 error_slot:
303290 kfree(slot);
304291 error:
....@@ -312,8 +299,7 @@
312299
313300 pr_info("Slot [%s] unregistered\n", slot_name(slot));
314301
315
- pci_hp_deregister(slot->hotplug_slot);
316
- kfree(slot->hotplug_slot);
302
+ pci_hp_deregister(&slot->hotplug_slot);
317303 kfree(slot);
318304 }
319305