hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/pci/hotplug/ibmphp_core.c
....@@ -247,11 +247,8 @@
247247 break;
248248 }
249249 if (rc == 0) {
250
- pslot = hotplug_slot->private;
251
- if (pslot)
252
- rc = ibmphp_hpc_writeslot(pslot, cmd);
253
- else
254
- rc = -ENODEV;
250
+ pslot = to_slot(hotplug_slot);
251
+ rc = ibmphp_hpc_writeslot(pslot, cmd);
255252 }
256253 } else
257254 rc = -ENODEV;
....@@ -273,19 +270,15 @@
273270
274271 ibmphp_lock_operations();
275272 if (hotplug_slot) {
276
- pslot = hotplug_slot->private;
277
- if (pslot) {
278
- memcpy(&myslot, pslot, sizeof(struct slot));
279
- rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
280
- &(myslot.status));
281
- if (!rc)
282
- rc = ibmphp_hpc_readslot(pslot,
283
- READ_EXTSLOTSTATUS,
284
- &(myslot.ext_status));
285
- if (!rc)
286
- *value = SLOT_ATTN(myslot.status,
287
- myslot.ext_status);
288
- }
273
+ pslot = to_slot(hotplug_slot);
274
+ memcpy(&myslot, pslot, sizeof(struct slot));
275
+ rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
276
+ &myslot.status);
277
+ if (!rc)
278
+ rc = ibmphp_hpc_readslot(pslot, READ_EXTSLOTSTATUS,
279
+ &myslot.ext_status);
280
+ if (!rc)
281
+ *value = SLOT_ATTN(myslot.status, myslot.ext_status);
289282 }
290283
291284 ibmphp_unlock_operations();
....@@ -303,14 +296,12 @@
303296 (ulong) hotplug_slot, (ulong) value);
304297 ibmphp_lock_operations();
305298 if (hotplug_slot) {
306
- pslot = hotplug_slot->private;
307
- if (pslot) {
308
- memcpy(&myslot, pslot, sizeof(struct slot));
309
- rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
310
- &(myslot.status));
311
- if (!rc)
312
- *value = SLOT_LATCH(myslot.status);
313
- }
299
+ pslot = to_slot(hotplug_slot);
300
+ memcpy(&myslot, pslot, sizeof(struct slot));
301
+ rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
302
+ &myslot.status);
303
+ if (!rc)
304
+ *value = SLOT_LATCH(myslot.status);
314305 }
315306
316307 ibmphp_unlock_operations();
....@@ -330,14 +321,12 @@
330321 (ulong) hotplug_slot, (ulong) value);
331322 ibmphp_lock_operations();
332323 if (hotplug_slot) {
333
- pslot = hotplug_slot->private;
334
- if (pslot) {
335
- memcpy(&myslot, pslot, sizeof(struct slot));
336
- rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
337
- &(myslot.status));
338
- if (!rc)
339
- *value = SLOT_PWRGD(myslot.status);
340
- }
324
+ pslot = to_slot(hotplug_slot);
325
+ memcpy(&myslot, pslot, sizeof(struct slot));
326
+ rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
327
+ &myslot.status);
328
+ if (!rc)
329
+ *value = SLOT_PWRGD(myslot.status);
341330 }
342331
343332 ibmphp_unlock_operations();
....@@ -357,18 +346,16 @@
357346 (ulong) hotplug_slot, (ulong) value);
358347 ibmphp_lock_operations();
359348 if (hotplug_slot) {
360
- pslot = hotplug_slot->private;
361
- if (pslot) {
362
- memcpy(&myslot, pslot, sizeof(struct slot));
363
- rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
364
- &(myslot.status));
365
- if (!rc) {
366
- present = SLOT_PRESENT(myslot.status);
367
- if (present == HPC_SLOT_EMPTY)
368
- *value = 0;
369
- else
370
- *value = 1;
371
- }
349
+ pslot = to_slot(hotplug_slot);
350
+ memcpy(&myslot, pslot, sizeof(struct slot));
351
+ rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS,
352
+ &myslot.status);
353
+ if (!rc) {
354
+ present = SLOT_PRESENT(myslot.status);
355
+ if (present == HPC_SLOT_EMPTY)
356
+ *value = 0;
357
+ else
358
+ *value = 1;
372359 }
373360 }
374361
....@@ -382,7 +369,7 @@
382369 int rc = 0;
383370 u8 mode = 0;
384371 enum pci_bus_speed speed;
385
- struct pci_bus *bus = slot->hotplug_slot->pci_slot->bus;
372
+ struct pci_bus *bus = slot->hotplug_slot.pci_slot->bus;
386373
387374 debug("%s - Entry slot[%p]\n", __func__, slot);
388375
....@@ -582,28 +569,9 @@
582569 ****************************************************************************/
583570 int ibmphp_update_slot_info(struct slot *slot_cur)
584571 {
585
- struct hotplug_slot_info *info;
586
- struct pci_bus *bus = slot_cur->hotplug_slot->pci_slot->bus;
587
- int rc;
572
+ struct pci_bus *bus = slot_cur->hotplug_slot.pci_slot->bus;
588573 u8 bus_speed;
589574 u8 mode;
590
-
591
- info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
592
- if (!info)
593
- return -ENOMEM;
594
-
595
- info->power_status = SLOT_PWRGD(slot_cur->status);
596
- info->attention_status = SLOT_ATTN(slot_cur->status,
597
- slot_cur->ext_status);
598
- info->latch_status = SLOT_LATCH(slot_cur->status);
599
- if (!SLOT_PRESENT(slot_cur->status)) {
600
- info->adapter_status = 0;
601
-/* info->max_adapter_speed_status = MAX_ADAPTER_NONE; */
602
- } else {
603
- info->adapter_status = 1;
604
-/* get_max_adapter_speed_1(slot_cur->hotplug_slot,
605
- &info->max_adapter_speed_status, 0); */
606
- }
607575
608576 bus_speed = slot_cur->bus_on->current_speed;
609577 mode = slot_cur->bus_on->current_bus_mode;
....@@ -630,9 +598,7 @@
630598 bus->cur_bus_speed = bus_speed;
631599 // To do: bus_names
632600
633
- rc = pci_hp_change_slot_info(slot_cur->hotplug_slot, info);
634
- kfree(info);
635
- return rc;
601
+ return 0;
636602 }
637603
638604
....@@ -673,7 +639,7 @@
673639
674640 list_for_each_entry_safe(slot_cur, next, &ibmphp_slot_head,
675641 ibm_slot_list) {
676
- pci_hp_del(slot_cur->hotplug_slot);
642
+ pci_hp_del(&slot_cur->hotplug_slot);
677643 slot_cur->ctrl = NULL;
678644 slot_cur->bus_on = NULL;
679645
....@@ -683,9 +649,7 @@
683649 */
684650 ibmphp_unconfigure_card(&slot_cur, -1);
685651
686
- pci_hp_destroy(slot_cur->hotplug_slot);
687
- kfree(slot_cur->hotplug_slot->info);
688
- kfree(slot_cur->hotplug_slot);
652
+ pci_hp_destroy(&slot_cur->hotplug_slot);
689653 kfree(slot_cur);
690654 }
691655 debug("%s -- exit\n", __func__);
....@@ -1007,7 +971,7 @@
1007971 ibmphp_lock_operations();
1008972
1009973 debug("ENABLING SLOT........\n");
1010
- slot_cur = hs->private;
974
+ slot_cur = to_slot(hs);
1011975
1012976 rc = validate(slot_cur, ENABLE);
1013977 if (rc) {
....@@ -1095,8 +1059,7 @@
10951059
10961060 slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
10971061 if (!slot_cur->func) {
1098
- /* We cannot do update_slot_info here, since no memory for
1099
- * kmalloc n.e.ways, and update_slot_info allocates some */
1062
+ /* do update_slot_info here? */
11001063 rc = -ENOMEM;
11011064 goto error_power;
11021065 }
....@@ -1169,7 +1132,7 @@
11691132 **************************************************************/
11701133 static int ibmphp_disable_slot(struct hotplug_slot *hotplug_slot)
11711134 {
1172
- struct slot *slot = hotplug_slot->private;
1135
+ struct slot *slot = to_slot(hotplug_slot);
11731136 int rc;
11741137
11751138 ibmphp_lock_operations();
....@@ -1259,7 +1222,7 @@
12591222 goto exit;
12601223 }
12611224
1262
-struct hotplug_slot_ops ibmphp_hotplug_slot_ops = {
1225
+const struct hotplug_slot_ops ibmphp_hotplug_slot_ops = {
12631226 .set_attention_status = set_attention_status,
12641227 .enable_slot = enable_slot,
12651228 .disable_slot = ibmphp_disable_slot,
....@@ -1313,8 +1276,6 @@
13131276 memcpy(ibmphp_pci_bus, bus, sizeof(*ibmphp_pci_bus));
13141277
13151278 ibmphp_debug = debug;
1316
-
1317
- ibmphp_hpc_initvars();
13181279
13191280 for (i = 0; i < 16; i++)
13201281 irqs[i] = 0;