Skip to content

Commit e1acb24

Browse files
Alex Chiangjbarnes993
authored andcommitted
PCI: pciehp: remove 'name' parameter
We do not need to manage our own name parameter, especially since the PCI core can change it on our behalf, in the case of duplicate slot names. Remove 'name' from pciehp's version of struct slot, and remove unused 'task_list' as well. Cc: kristen.c.accardi@intel.com Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent a32615a commit e1acb24

4 files changed

Lines changed: 52 additions & 44 deletions

File tree

‎drivers/pci/hotplug/pciehp.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,13 @@ extern struct workqueue_struct *pciehp_wq;
7474
struct slot {
7575
u8 bus;
7676
u8 device;
77-
u32 number;
7877
u8 state;
79-
struct timer_list task_event;
8078
u8 hp_slot;
79+
u32 number;
8180
struct controller *ctrl;
8281
struct hpc_ops *hpc_ops;
8382
struct hotplug_slot *hotplug_slot;
8483
struct list_head slot_list;
85-
char name[SLOT_NAME_SIZE];
8684
unsigned long last_emi_toggle;
8785
struct delayed_work work; /* work for button event */
8886
struct mutex lock;
@@ -175,6 +173,11 @@ int pciehp_enable_slot(struct slot *p_slot);
175173
int pciehp_disable_slot(struct slot *p_slot);
176174
int pcie_enable_notification(struct controller *ctrl);
177175

176+
static inline const char *slot_name(struct slot *slot)
177+
{
178+
return hotplug_slot_name(slot->hotplug_slot);
179+
}
180+
178181
static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
179182
{
180183
struct slot *slot;

‎drivers/pci/hotplug/pciehp_core.c‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
185185
struct slot *slot = hotplug_slot->private;
186186

187187
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
188-
__func__, hotplug_slot->name);
188+
__func__, hotplug_slot_name(hotplug_slot));
189189

190190
kfree(hotplug_slot->info);
191191
kfree(hotplug_slot);
@@ -196,6 +196,7 @@ static int init_slots(struct controller *ctrl)
196196
struct slot *slot;
197197
struct hotplug_slot *hotplug_slot;
198198
struct hotplug_slot_info *info;
199+
char name[SLOT_NAME_SIZE];
199200
int retval = -ENOMEM;
200201

201202
list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
@@ -209,28 +210,28 @@ static int init_slots(struct controller *ctrl)
209210

210211
/* register this slot with the hotplug pci core */
211212
hotplug_slot->info = info;
212-
hotplug_slot->name = slot->name;
213213
hotplug_slot->private = slot;
214214
hotplug_slot->release = &release_slot;
215215
hotplug_slot->ops = &pciehp_hotplug_slot_ops;
216-
get_power_status(hotplug_slot, &info->power_status);
217-
get_attention_status(hotplug_slot, &info->attention_status);
218-
get_latch_status(hotplug_slot, &info->latch_status);
219-
get_adapter_status(hotplug_slot, &info->adapter_status);
220216
slot->hotplug_slot = hotplug_slot;
217+
snprintf(name, SLOT_NAME_SIZE, "%u", slot->number);
221218

222219
ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x "
223220
"slot_device_offset=%x\n", slot->bus, slot->device,
224221
slot->hp_slot, slot->number, ctrl->slot_device_offset);
225222
retval = pci_hp_register(hotplug_slot,
226223
ctrl->pci_dev->subordinate,
227224
slot->device,
228-
slot->name);
225+
name);
229226
if (retval) {
230227
ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
231228
retval);
232229
goto error_info;
233230
}
231+
get_power_status(hotplug_slot, &info->power_status);
232+
get_attention_status(hotplug_slot, &info->attention_status);
233+
get_latch_status(hotplug_slot, &info->latch_status);
234+
get_adapter_status(hotplug_slot, &info->adapter_status);
234235
/* create additional sysfs entries */
235236
if (EMI(ctrl)) {
236237
retval = sysfs_create_file(&hotplug_slot->pci_slot->kobj,
@@ -273,7 +274,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
273274
struct slot *slot = hotplug_slot->private;
274275

275276
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
276-
__func__, hotplug_slot->name);
277+
__func__, slot_name(slot));
277278

278279
hotplug_slot->info->attention_status = status;
279280

@@ -289,7 +290,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
289290
struct slot *slot = hotplug_slot->private;
290291

291292
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
292-
__func__, hotplug_slot->name);
293+
__func__, slot_name(slot));
293294

294295
return pciehp_sysfs_enable_slot(slot);
295296
}
@@ -300,7 +301,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
300301
struct slot *slot = hotplug_slot->private;
301302

302303
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
303-
__func__, hotplug_slot->name);
304+
__func__, slot_name(slot));
304305

305306
return pciehp_sysfs_disable_slot(slot);
306307
}
@@ -311,7 +312,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
311312
int retval;
312313

313314
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
314-
__func__, hotplug_slot->name);
315+
__func__, slot_name(slot));
315316

316317
retval = slot->hpc_ops->get_power_status(slot, value);
317318
if (retval < 0)
@@ -326,7 +327,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
326327
int retval;
327328

328329
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
329-
__func__, hotplug_slot->name);
330+
__func__, slot_name(slot));
330331

331332
retval = slot->hpc_ops->get_attention_status(slot, value);
332333
if (retval < 0)
@@ -341,7 +342,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
341342
int retval;
342343

343344
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
344-
__func__, hotplug_slot->name);
345+
__func__, slot_name(slot));
345346

346347
retval = slot->hpc_ops->get_latch_status(slot, value);
347348
if (retval < 0)
@@ -356,7 +357,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
356357
int retval;
357358

358359
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
359-
__func__, hotplug_slot->name);
360+
__func__, slot_name(slot));
360361

361362
retval = slot->hpc_ops->get_adapter_status(slot, value);
362363
if (retval < 0)
@@ -372,7 +373,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
372373
int retval;
373374

374375
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
375-
__func__, hotplug_slot->name);
376+
__func__, slot_name(slot));
376377

377378
retval = slot->hpc_ops->get_max_bus_speed(slot, value);
378379
if (retval < 0)
@@ -387,7 +388,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
387388
int retval;
388389

389390
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
390-
__func__, hotplug_slot->name);
391+
__func__, slot_name(slot));
391392

392393
retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
393394
if (retval < 0)

‎drivers/pci/hotplug/pciehp_ctrl.c‎

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot)
6666
/*
6767
* Button pressed - See if need to TAKE ACTION!!!
6868
*/
69-
ctrl_info(ctrl, "Button pressed on Slot(%s)\n", p_slot->name);
69+
ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot));
7070
event_type = INT_BUTTON_PRESS;
7171

7272
queue_interrupt_event(p_slot, event_type);
@@ -88,13 +88,13 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
8888
/*
8989
* Switch opened
9090
*/
91-
ctrl_info(ctrl, "Latch open on Slot(%s)\n", p_slot->name);
91+
ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot));
9292
event_type = INT_SWITCH_OPEN;
9393
} else {
9494
/*
9595
* Switch closed
9696
*/
97-
ctrl_info(ctrl, "Latch close on Slot(%s)\n", p_slot->name);
97+
ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot));
9898
event_type = INT_SWITCH_CLOSE;
9999
}
100100

@@ -120,13 +120,14 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
120120
/*
121121
* Card Present
122122
*/
123-
ctrl_info(ctrl, "Card present on Slot(%s)\n", p_slot->name);
123+
ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot));
124124
event_type = INT_PRESENCE_ON;
125125
} else {
126126
/*
127127
* Not Present
128128
*/
129-
ctrl_info(ctrl, "Card not present on Slot(%s)\n", p_slot->name);
129+
ctrl_info(ctrl, "Card not present on Slot(%s)\n",
130+
slot_name(p_slot));
130131
event_type = INT_PRESENCE_OFF;
131132
}
132133

@@ -148,13 +149,13 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
148149
* power fault Cleared
149150
*/
150151
ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n",
151-
p_slot->name);
152+
slot_name(p_slot));
152153
event_type = INT_POWER_FAULT_CLEAR;
153154
} else {
154155
/*
155156
* power fault
156157
*/
157-
ctrl_info(ctrl, "Power fault on Slot(%s)\n", p_slot->name);
158+
ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot));
158159
event_type = INT_POWER_FAULT;
159160
ctrl_info(ctrl, "power fault bit %x set\n", 0);
160161
}
@@ -412,12 +413,12 @@ static void handle_button_press_event(struct slot *p_slot)
412413
p_slot->state = BLINKINGOFF_STATE;
413414
ctrl_info(ctrl,
414415
"PCI slot #%s - powering off due to button "
415-
"press.\n", p_slot->name);
416+
"press.\n", slot_name(p_slot));
416417
} else {
417418
p_slot->state = BLINKINGON_STATE;
418419
ctrl_info(ctrl,
419420
"PCI slot #%s - powering on due to button "
420-
"press.\n", p_slot->name);
421+
"press.\n", slot_name(p_slot));
421422
}
422423
/* blink green LED and turn off amber */
423424
if (PWR_LED(ctrl))
@@ -434,7 +435,7 @@ static void handle_button_press_event(struct slot *p_slot)
434435
* press the attention again before the 5 sec. limit
435436
* expires to cancel hot-add or hot-remove
436437
*/
437-
ctrl_info(ctrl, "Button cancel on Slot(%s)\n", p_slot->name);
438+
ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
438439
ctrl_dbg(ctrl, "%s: button cancel\n", __func__);
439440
cancel_delayed_work(&p_slot->work);
440441
if (p_slot->state == BLINKINGOFF_STATE) {
@@ -447,7 +448,7 @@ static void handle_button_press_event(struct slot *p_slot)
447448
if (ATTN_LED(ctrl))
448449
p_slot->hpc_ops->set_attention_status(p_slot, 0);
449450
ctrl_info(ctrl, "PCI slot #%s - action canceled "
450-
"due to button press\n", p_slot->name);
451+
"due to button press\n", slot_name(p_slot));
451452
p_slot->state = STATIC_STATE;
452453
break;
453454
case POWEROFF_STATE:
@@ -457,7 +458,7 @@ static void handle_button_press_event(struct slot *p_slot)
457458
* this means that the previous attention button action
458459
* to hot-add or hot-remove is undergoing
459460
*/
460-
ctrl_info(ctrl, "Button ignore on Slot(%s)\n", p_slot->name);
461+
ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot));
461462
update_slot_info(p_slot);
462463
break;
463464
default:
@@ -540,15 +541,15 @@ int pciehp_enable_slot(struct slot *p_slot)
540541
rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
541542
if (rc || !getstatus) {
542543
ctrl_info(ctrl, "%s: no adapter on slot(%s)\n",
543-
__func__, p_slot->name);
544+
__func__, slot_name(p_slot));
544545
mutex_unlock(&p_slot->ctrl->crit_sect);
545546
return -ENODEV;
546547
}
547548
if (MRL_SENS(p_slot->ctrl)) {
548549
rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
549550
if (rc || getstatus) {
550551
ctrl_info(ctrl, "%s: latch open on slot(%s)\n",
551-
__func__, p_slot->name);
552+
__func__, slot_name(p_slot));
552553
mutex_unlock(&p_slot->ctrl->crit_sect);
553554
return -ENODEV;
554555
}
@@ -558,7 +559,7 @@ int pciehp_enable_slot(struct slot *p_slot)
558559
rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
559560
if (rc || getstatus) {
560561
ctrl_info(ctrl, "%s: already enabled on slot(%s)\n",
561-
__func__, p_slot->name);
562+
__func__, slot_name(p_slot));
562563
mutex_unlock(&p_slot->ctrl->crit_sect);
563564
return -EINVAL;
564565
}
@@ -594,7 +595,7 @@ int pciehp_disable_slot(struct slot *p_slot)
594595
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
595596
if (ret || !getstatus) {
596597
ctrl_info(ctrl, "%s: no adapter on slot(%s)\n",
597-
__func__, p_slot->name);
598+
__func__, slot_name(p_slot));
598599
mutex_unlock(&p_slot->ctrl->crit_sect);
599600
return -ENODEV;
600601
}
@@ -604,7 +605,7 @@ int pciehp_disable_slot(struct slot *p_slot)
604605
ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
605606
if (ret || getstatus) {
606607
ctrl_info(ctrl, "%s: latch open on slot(%s)\n",
607-
__func__, p_slot->name);
608+
__func__, slot_name(p_slot));
608609
mutex_unlock(&p_slot->ctrl->crit_sect);
609610
return -ENODEV;
610611
}
@@ -614,7 +615,7 @@ int pciehp_disable_slot(struct slot *p_slot)
614615
ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
615616
if (ret || !getstatus) {
616617
ctrl_info(ctrl, "%s: already disabled slot(%s)\n",
617-
__func__, p_slot->name);
618+
__func__, slot_name(p_slot));
618619
mutex_unlock(&p_slot->ctrl->crit_sect);
619620
return -EINVAL;
620621
}
@@ -645,14 +646,16 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
645646
break;
646647
case POWERON_STATE:
647648
ctrl_info(ctrl, "Slot %s is already in powering on state\n",
648-
p_slot->name);
649+
slot_name(p_slot));
649650
break;
650651
case BLINKINGOFF_STATE:
651652
case POWEROFF_STATE:
652-
ctrl_info(ctrl, "Already enabled on slot %s\n", p_slot->name);
653+
ctrl_info(ctrl, "Already enabled on slot %s\n",
654+
slot_name(p_slot));
653655
break;
654656
default:
655-
ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name);
657+
ctrl_err(ctrl, "Not a valid state on slot %s\n",
658+
slot_name(p_slot));
656659
break;
657660
}
658661
mutex_unlock(&p_slot->lock);
@@ -678,14 +681,16 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
678681
break;
679682
case POWEROFF_STATE:
680683
ctrl_info(ctrl, "Slot %s is already in powering off state\n",
681-
p_slot->name);
684+
slot_name(p_slot));
682685
break;
683686
case BLINKINGON_STATE:
684687
case POWERON_STATE:
685-
ctrl_info(ctrl, "Already disabled on slot %s\n", p_slot->name);
688+
ctrl_info(ctrl, "Already disabled on slot %s\n",
689+
slot_name(p_slot));
686690
break;
687691
default:
688-
ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name);
692+
ctrl_err(ctrl, "Not a valid state on slot %s\n",
693+
slot_name(p_slot));
689694
break;
690695
}
691696
mutex_unlock(&p_slot->lock);

‎drivers/pci/hotplug/pciehp_hpc.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ static int pcie_init_slot(struct controller *ctrl)
10611061
slot->device = ctrl->slot_device_offset + slot->hp_slot;
10621062
slot->hpc_ops = ctrl->hpc_ops;
10631063
slot->number = ctrl->first_slot;
1064-
snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
10651064
mutex_init(&slot->lock);
10661065
INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
10671066
list_add(&slot->slot_list, &ctrl->slot_list);

0 commit comments

Comments
 (0)