Skip to content

Commit 5d8491a

Browse files
ngnbjorn-helgaas
authored andcommitted
PCI: shpchp: Remove hpc_ops
Remove the hpc_ops struct from shpchp. This struct is unnecessary and no other hotplug controller implements it. A similar thing has already been done in pciehp with 82a9e79 ("PCI: pciehp: remove hpc_ops"). Link: https://lore.kernel.org/r/Zp-XXVW4hlcMASEc@archbtw Signed-off-by: ngn <ngn@ngn.tf> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 8400291 commit 5d8491a

5 files changed

Lines changed: 82 additions & 118 deletions

File tree

drivers/pci/hotplug/TODO

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ ibmphp:
5151

5252
shpchp:
5353

54-
* There is only a single implementation of struct hpc_ops. Can the struct be
55-
removed and its functions invoked directly? This has already been done in
56-
pciehp with commit 82a9e79ef132 ("PCI: pciehp: remove hpc_ops"). Clarify
57-
if there was a specific reason not to apply the same change to shpchp.
58-
5954
* The hardirq handler shpc_isr() queues events on a workqueue. It can be
6055
simplified by converting it to threaded IRQ handling. Use pciehp as a
6156
template.

drivers/pci/hotplug/shpchp.h

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct slot {
7272
u8 latch_save;
7373
u8 pwr_save;
7474
struct controller *ctrl;
75-
const struct hpc_ops *hpc_ops;
7675
struct hotplug_slot hotplug_slot;
7776
struct list_head slot_list;
7877
struct delayed_work work; /* work for button event */
@@ -94,7 +93,6 @@ struct controller {
9493
int slot_num_inc; /* 1 or -1 */
9594
struct pci_dev *pci_dev;
9695
struct list_head slot_list;
97-
const struct hpc_ops *hpc_ops;
9896
wait_queue_head_t queue; /* sleep & wake process */
9997
u8 slot_device_offset;
10098
u32 pcix_misc2_reg; /* for amd pogo errata */
@@ -300,24 +298,22 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
300298
pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
301299
}
302300

303-
struct hpc_ops {
304-
int (*power_on_slot)(struct slot *slot);
305-
int (*slot_enable)(struct slot *slot);
306-
int (*slot_disable)(struct slot *slot);
307-
int (*set_bus_speed_mode)(struct slot *slot, enum pci_bus_speed speed);
308-
int (*get_power_status)(struct slot *slot, u8 *status);
309-
int (*get_attention_status)(struct slot *slot, u8 *status);
310-
int (*set_attention_status)(struct slot *slot, u8 status);
311-
int (*get_latch_status)(struct slot *slot, u8 *status);
312-
int (*get_adapter_status)(struct slot *slot, u8 *status);
313-
int (*get_adapter_speed)(struct slot *slot, enum pci_bus_speed *speed);
314-
int (*get_prog_int)(struct slot *slot, u8 *prog_int);
315-
int (*query_power_fault)(struct slot *slot);
316-
void (*green_led_on)(struct slot *slot);
317-
void (*green_led_off)(struct slot *slot);
318-
void (*green_led_blink)(struct slot *slot);
319-
void (*release_ctlr)(struct controller *ctrl);
320-
int (*check_cmd_status)(struct controller *ctrl);
321-
};
301+
int shpchp_power_on_slot(struct slot *slot);
302+
int shpchp_slot_enable(struct slot *slot);
303+
int shpchp_slot_disable(struct slot *slot);
304+
int shpchp_set_bus_speed_mode(struct slot *slot, enum pci_bus_speed speed);
305+
int shpchp_get_power_status(struct slot *slot, u8 *status);
306+
int shpchp_get_attention_status(struct slot *slot, u8 *status);
307+
int shpchp_set_attention_status(struct slot *slot, u8 status);
308+
int shpchp_get_latch_status(struct slot *slot, u8 *status);
309+
int shpchp_get_adapter_status(struct slot *slot, u8 *status);
310+
int shpchp_get_adapter_speed(struct slot *slot, enum pci_bus_speed *speed);
311+
int shpchp_get_prog_int(struct slot *slot, u8 *prog_int);
312+
int shpchp_query_power_fault(struct slot *slot);
313+
void shpchp_green_led_on(struct slot *slot);
314+
void shpchp_green_led_off(struct slot *slot);
315+
void shpchp_green_led_blink(struct slot *slot);
316+
void shpchp_release_ctlr(struct controller *ctrl);
317+
int shpchp_check_cmd_status(struct controller *ctrl);
322318

323319
#endif /* _SHPCHP_H */

drivers/pci/hotplug/shpchp_core.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ static int init_slots(struct controller *ctrl)
8181
slot->ctrl = ctrl;
8282
slot->bus = ctrl->pci_dev->subordinate->number;
8383
slot->device = ctrl->slot_device_offset + i;
84-
slot->hpc_ops = ctrl->hpc_ops;
8584
slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
8685

8786
slot->wq = alloc_workqueue("shpchp-%d", 0, 0, slot->number);
@@ -150,7 +149,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
150149
__func__, slot_name(slot));
151150

152151
slot->attention_save = status;
153-
slot->hpc_ops->set_attention_status(slot, status);
152+
shpchp_set_attention_status(slot, status);
154153

155154
return 0;
156155
}
@@ -183,7 +182,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
183182
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
184183
__func__, slot_name(slot));
185184

186-
retval = slot->hpc_ops->get_power_status(slot, value);
185+
retval = shpchp_get_power_status(slot, value);
187186
if (retval < 0)
188187
*value = slot->pwr_save;
189188

@@ -198,7 +197,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
198197
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
199198
__func__, slot_name(slot));
200199

201-
retval = slot->hpc_ops->get_attention_status(slot, value);
200+
retval = shpchp_get_attention_status(slot, value);
202201
if (retval < 0)
203202
*value = slot->attention_save;
204203

@@ -213,7 +212,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
213212
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
214213
__func__, slot_name(slot));
215214

216-
retval = slot->hpc_ops->get_latch_status(slot, value);
215+
retval = shpchp_get_latch_status(slot, value);
217216
if (retval < 0)
218217
*value = slot->latch_save;
219218

@@ -228,7 +227,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
228227
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
229228
__func__, slot_name(slot));
230229

231-
retval = slot->hpc_ops->get_adapter_status(slot, value);
230+
retval = shpchp_get_adapter_status(slot, value);
232231
if (retval < 0)
233232
*value = slot->presence_save;
234233

@@ -293,7 +292,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
293292
err_cleanup_slots:
294293
cleanup_slots(ctrl);
295294
err_out_release_ctlr:
296-
ctrl->hpc_ops->release_ctlr(ctrl);
295+
shpchp_release_ctlr(ctrl);
297296
err_out_free_ctrl:
298297
kfree(ctrl);
299298
err_out_none:
@@ -306,7 +305,7 @@ static void shpc_remove(struct pci_dev *dev)
306305

307306
dev->shpc_managed = 0;
308307
shpchp_remove_ctrl_files(ctrl);
309-
ctrl->hpc_ops->release_ctlr(ctrl);
308+
shpchp_release_ctlr(ctrl);
310309
kfree(ctrl);
311310
}
312311

0 commit comments

Comments
 (0)