forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/pci/hotplug/shpchp_core.c
....@@ -51,7 +51,7 @@
5151 static int get_latch_status(struct hotplug_slot *slot, u8 *value);
5252 static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
5353
54
-static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
54
+static const struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
5555 .set_attention_status = set_attention_status,
5656 .enable_slot = enable_slot,
5757 .disable_slot = disable_slot,
....@@ -65,7 +65,6 @@
6565 {
6666 struct slot *slot;
6767 struct hotplug_slot *hotplug_slot;
68
- struct hotplug_slot_info *info;
6968 char name[SLOT_NAME_SIZE];
7069 int retval;
7170 int i;
....@@ -77,19 +76,7 @@
7776 goto error;
7877 }
7978
80
- hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
81
- if (!hotplug_slot) {
82
- retval = -ENOMEM;
83
- goto error_slot;
84
- }
85
- slot->hotplug_slot = hotplug_slot;
86
-
87
- info = kzalloc(sizeof(*info), GFP_KERNEL);
88
- if (!info) {
89
- retval = -ENOMEM;
90
- goto error_hpslot;
91
- }
92
- hotplug_slot->info = info;
79
+ hotplug_slot = &slot->hotplug_slot;
9380
9481 slot->hp_slot = i;
9582 slot->ctrl = ctrl;
....@@ -101,14 +88,13 @@
10188 slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number);
10289 if (!slot->wq) {
10390 retval = -ENOMEM;
104
- goto error_info;
91
+ goto error_slot;
10592 }
10693
10794 mutex_init(&slot->lock);
10895 INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work);
10996
11097 /* register this slot with the hotplug pci core */
111
- hotplug_slot->private = slot;
11298 snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
11399 hotplug_slot->ops = &shpchp_hotplug_slot_ops;
114100
....@@ -116,7 +102,7 @@
116102 pci_domain_nr(ctrl->pci_dev->subordinate),
117103 slot->bus, slot->device, slot->hp_slot, slot->number,
118104 ctrl->slot_device_offset);
119
- retval = pci_hp_register(slot->hotplug_slot,
105
+ retval = pci_hp_register(hotplug_slot,
120106 ctrl->pci_dev->subordinate, slot->device, name);
121107 if (retval) {
122108 ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
....@@ -124,10 +110,10 @@
124110 goto error_slotwq;
125111 }
126112
127
- get_power_status(hotplug_slot, &info->power_status);
128
- get_attention_status(hotplug_slot, &info->attention_status);
129
- get_latch_status(hotplug_slot, &info->latch_status);
130
- get_adapter_status(hotplug_slot, &info->adapter_status);
113
+ get_power_status(hotplug_slot, &slot->pwr_save);
114
+ get_attention_status(hotplug_slot, &slot->attention_save);
115
+ get_latch_status(hotplug_slot, &slot->latch_save);
116
+ get_adapter_status(hotplug_slot, &slot->presence_save);
131117
132118 list_add(&slot->slot_list, &ctrl->slot_list);
133119 }
....@@ -135,10 +121,6 @@
135121 return 0;
136122 error_slotwq:
137123 destroy_workqueue(slot->wq);
138
-error_info:
139
- kfree(info);
140
-error_hpslot:
141
- kfree(hotplug_slot);
142124 error_slot:
143125 kfree(slot);
144126 error:
....@@ -153,9 +135,7 @@
153135 list_del(&slot->slot_list);
154136 cancel_delayed_work(&slot->work);
155137 destroy_workqueue(slot->wq);
156
- pci_hp_deregister(slot->hotplug_slot);
157
- kfree(slot->hotplug_slot->info);
158
- kfree(slot->hotplug_slot);
138
+ pci_hp_deregister(&slot->hotplug_slot);
159139 kfree(slot);
160140 }
161141 }
....@@ -170,7 +150,7 @@
170150 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
171151 __func__, slot_name(slot));
172152
173
- hotplug_slot->info->attention_status = status;
153
+ slot->attention_save = status;
174154 slot->hpc_ops->set_attention_status(slot, status);
175155
176156 return 0;
....@@ -206,7 +186,7 @@
206186
207187 retval = slot->hpc_ops->get_power_status(slot, value);
208188 if (retval < 0)
209
- *value = hotplug_slot->info->power_status;
189
+ *value = slot->pwr_save;
210190
211191 return 0;
212192 }
....@@ -221,7 +201,7 @@
221201
222202 retval = slot->hpc_ops->get_attention_status(slot, value);
223203 if (retval < 0)
224
- *value = hotplug_slot->info->attention_status;
204
+ *value = slot->attention_save;
225205
226206 return 0;
227207 }
....@@ -236,7 +216,7 @@
236216
237217 retval = slot->hpc_ops->get_latch_status(slot, value);
238218 if (retval < 0)
239
- *value = hotplug_slot->info->latch_status;
219
+ *value = slot->latch_save;
240220
241221 return 0;
242222 }
....@@ -251,7 +231,7 @@
251231
252232 retval = slot->hpc_ops->get_adapter_status(slot, value);
253233 if (retval < 0)
254
- *value = hotplug_slot->info->adapter_status;
234
+ *value = slot->presence_save;
255235
256236 return 0;
257237 }