forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/pci/hotplug/pci_hotplug_core.c
....@@ -49,15 +49,13 @@
4949 #define GET_STATUS(name, type) \
5050 static int get_##name(struct hotplug_slot *slot, type *value) \
5151 { \
52
- struct hotplug_slot_ops *ops = slot->ops; \
52
+ const struct hotplug_slot_ops *ops = slot->ops; \
5353 int retval = 0; \
54
- if (!try_module_get(ops->owner)) \
54
+ if (!try_module_get(slot->owner)) \
5555 return -ENODEV; \
5656 if (ops->get_##name) \
5757 retval = ops->get_##name(slot, value); \
58
- else \
59
- *value = slot->info->name; \
60
- module_put(ops->owner); \
58
+ module_put(slot->owner); \
6159 return retval; \
6260 }
6361
....@@ -90,7 +88,7 @@
9088 power = (u8)(lpower & 0xff);
9189 dbg("power = %d\n", power);
9290
93
- if (!try_module_get(slot->ops->owner)) {
91
+ if (!try_module_get(slot->owner)) {
9492 retval = -ENODEV;
9593 goto exit;
9694 }
....@@ -109,7 +107,7 @@
109107 err("Illegal value specified for power\n");
110108 retval = -EINVAL;
111109 }
112
- module_put(slot->ops->owner);
110
+ module_put(slot->owner);
113111
114112 exit:
115113 if (retval)
....@@ -138,7 +136,8 @@
138136 static ssize_t attention_write_file(struct pci_slot *pci_slot, const char *buf,
139137 size_t count)
140138 {
141
- struct hotplug_slot_ops *ops = pci_slot->hotplug->ops;
139
+ struct hotplug_slot *slot = pci_slot->hotplug;
140
+ const struct hotplug_slot_ops *ops = slot->ops;
142141 unsigned long lattention;
143142 u8 attention;
144143 int retval = 0;
....@@ -147,13 +146,13 @@
147146 attention = (u8)(lattention & 0xff);
148147 dbg(" - attention = %d\n", attention);
149148
150
- if (!try_module_get(ops->owner)) {
149
+ if (!try_module_get(slot->owner)) {
151150 retval = -ENODEV;
152151 goto exit;
153152 }
154153 if (ops->set_attention_status)
155
- retval = ops->set_attention_status(pci_slot->hotplug, attention);
156
- module_put(ops->owner);
154
+ retval = ops->set_attention_status(slot, attention);
155
+ module_put(slot->owner);
157156
158157 exit:
159158 if (retval)
....@@ -213,13 +212,13 @@
213212 test = (u32)(ltest & 0xffffffff);
214213 dbg("test = %d\n", test);
215214
216
- if (!try_module_get(slot->ops->owner)) {
215
+ if (!try_module_get(slot->owner)) {
217216 retval = -ENODEV;
218217 goto exit;
219218 }
220219 if (slot->ops->hardware_test)
221220 retval = slot->ops->hardware_test(slot, test);
222
- module_put(slot->ops->owner);
221
+ module_put(slot->owner);
223222
224223 exit:
225224 if (retval)
....@@ -444,11 +443,11 @@
444443
445444 if (slot == NULL)
446445 return -ENODEV;
447
- if ((slot->info == NULL) || (slot->ops == NULL))
446
+ if (slot->ops == NULL)
448447 return -EINVAL;
449448
450
- slot->ops->owner = owner;
451
- slot->ops->mod_name = mod_name;
449
+ slot->owner = owner;
450
+ slot->mod_name = mod_name;
452451
453452 /*
454453 * No problems if we call this interface from both ACPI_PCI_SLOT
....@@ -558,28 +557,6 @@
558557 pci_destroy_slot(pci_slot);
559558 }
560559 EXPORT_SYMBOL_GPL(pci_hp_destroy);
561
-
562
-/**
563
- * pci_hp_change_slot_info - changes the slot's information structure in the core
564
- * @slot: pointer to the slot whose info has changed
565
- * @info: pointer to the info copy into the slot's info structure
566
- *
567
- * @slot must have been registered with the pci
568
- * hotplug subsystem previously with a call to pci_hp_register().
569
- *
570
- * Returns 0 if successful, anything else for an error.
571
- */
572
-int pci_hp_change_slot_info(struct hotplug_slot *slot,
573
- struct hotplug_slot_info *info)
574
-{
575
- if (!slot || !info)
576
- return -ENODEV;
577
-
578
- memcpy(slot->info, info, sizeof(struct hotplug_slot_info));
579
-
580
- return 0;
581
-}
582
-EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
583560
584561 static int __init pci_hotplug_init(void)
585562 {