Skip to content

Commit 445f798

Browse files
kkaneshigejbarnes993
authored andcommitted
PCI: pciehp: return error on read/write failure
Current pciehp returns successfully on read/write failure with dummy state values. It should return error instead. With this patch, pciehp no longer uses hotplug_slot_info data structure. So this also removes hotplug_slot_info related code. But note that it still allocates hotplug_slot_info because it is required by pci hotplug core. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent 586f1d6 commit 445f798

3 files changed

Lines changed: 22 additions & 92 deletions

File tree

‎drivers/pci/hotplug/pciehp_core.c‎

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,9 @@ static int init_slot(struct controller *ctrl)
135135
ctrl->pcie->port->subordinate->number, PSN(ctrl));
136136
retval = pci_hp_register(hotplug,
137137
ctrl->pcie->port->subordinate, 0, name);
138-
if (retval) {
138+
if (retval)
139139
ctrl_err(ctrl,
140140
"pci_hp_register failed with error %d\n", retval);
141-
goto out;
142-
}
143-
get_power_status(hotplug, &info->power_status);
144-
get_attention_status(hotplug, &info->attention_status);
145-
get_latch_status(hotplug, &info->latch_status);
146-
get_adapter_status(hotplug, &info->adapter_status);
147141
out:
148142
if (retval) {
149143
kfree(ops);
@@ -168,10 +162,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
168162
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
169163
__func__, slot_name(slot));
170164

171-
hotplug_slot->info->attention_status = status;
172-
pciehp_set_attention_status(slot, status);
173-
174-
return 0;
165+
return pciehp_set_attention_status(slot, status);
175166
}
176167

177168

@@ -199,92 +190,62 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
199190
static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
200191
{
201192
struct slot *slot = hotplug_slot->private;
202-
int retval;
203193

204194
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
205195
__func__, slot_name(slot));
206196

207-
retval = pciehp_get_power_status(slot, value);
208-
if (retval < 0)
209-
*value = hotplug_slot->info->power_status;
210-
211-
return 0;
197+
return pciehp_get_power_status(slot, value);
212198
}
213199

214200
static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
215201
{
216202
struct slot *slot = hotplug_slot->private;
217-
int retval;
218203

219204
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
220205
__func__, slot_name(slot));
221206

222-
retval = pciehp_get_attention_status(slot, value);
223-
if (retval < 0)
224-
*value = hotplug_slot->info->attention_status;
225-
226-
return 0;
207+
return pciehp_get_attention_status(slot, value);
227208
}
228209

229210
static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
230211
{
231212
struct slot *slot = hotplug_slot->private;
232-
int retval;
233213

234214
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
235215
__func__, slot_name(slot));
236216

237-
retval = pciehp_get_latch_status(slot, value);
238-
if (retval < 0)
239-
*value = hotplug_slot->info->latch_status;
240-
241-
return 0;
217+
return pciehp_get_latch_status(slot, value);
242218
}
243219

244220
static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
245221
{
246222
struct slot *slot = hotplug_slot->private;
247-
int retval;
248223

249224
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
250225
__func__, slot_name(slot));
251226

252-
retval = pciehp_get_adapter_status(slot, value);
253-
if (retval < 0)
254-
*value = hotplug_slot->info->adapter_status;
255-
256-
return 0;
227+
return pciehp_get_adapter_status(slot, value);
257228
}
258229

259230
static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
260231
enum pci_bus_speed *value)
261232
{
262233
struct slot *slot = hotplug_slot->private;
263-
int retval;
264234

265235
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
266236
__func__, slot_name(slot));
267237

268-
retval = pciehp_get_max_link_speed(slot, value);
269-
if (retval < 0)
270-
*value = PCI_SPEED_UNKNOWN;
271-
272-
return 0;
238+
return pciehp_get_max_link_speed(slot, value);
273239
}
274240

275241
static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
276242
{
277243
struct slot *slot = hotplug_slot->private;
278-
int retval;
279244

280245
ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
281246
__func__, slot_name(slot));
282247

283-
retval = pciehp_get_cur_link_speed(slot, value);
284-
if (retval < 0)
285-
*value = PCI_SPEED_UNKNOWN;
286-
287-
return 0;
248+
return pciehp_get_cur_link_speed(slot, value);
288249
}
289250

290251
static int pciehp_probe(struct pcie_device *dev)

‎drivers/pci/hotplug/pciehp_ctrl.c‎

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -363,25 +363,6 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
363363
mutex_unlock(&p_slot->lock);
364364
}
365365

366-
static int update_slot_info(struct slot *slot)
367-
{
368-
struct hotplug_slot_info *info;
369-
int result;
370-
371-
info = kmalloc(sizeof(*info), GFP_KERNEL);
372-
if (!info)
373-
return -ENOMEM;
374-
375-
pciehp_get_power_status(slot, &info->power_status);
376-
pciehp_get_attention_status(slot, &info->attention_status);
377-
pciehp_get_latch_status(slot, &info->latch_status);
378-
pciehp_get_adapter_status(slot, &info->adapter_status);
379-
380-
result = pci_hp_change_slot_info(slot->hotplug_slot, info);
381-
kfree (info);
382-
return result;
383-
}
384-
385366
/*
386367
* Note: This function must be called with slot->lock held
387368
*/
@@ -442,7 +423,6 @@ static void handle_button_press_event(struct slot *p_slot)
442423
* to hot-add or hot-remove is undergoing
443424
*/
444425
ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot));
445-
update_slot_info(p_slot);
446426
break;
447427
default:
448428
ctrl_warn(ctrl, "Not a valid state\n");
@@ -500,11 +480,9 @@ static void interrupt_event_handler(struct work_struct *work)
500480
if (!HP_SUPR_RM(ctrl))
501481
break;
502482
ctrl_dbg(ctrl, "Surprise Removal\n");
503-
update_slot_info(p_slot);
504483
handle_surprise_event(p_slot);
505484
break;
506485
default:
507-
update_slot_info(p_slot);
508486
break;
509487
}
510488
mutex_unlock(&p_slot->lock);
@@ -547,9 +525,6 @@ int pciehp_enable_slot(struct slot *p_slot)
547525
if (rc) {
548526
pciehp_get_latch_status(p_slot, &getstatus);
549527
}
550-
551-
update_slot_info(p_slot);
552-
553528
return rc;
554529
}
555530

@@ -590,10 +565,7 @@ int pciehp_disable_slot(struct slot *p_slot)
590565
}
591566
}
592567

593-
ret = remove_board(p_slot);
594-
update_slot_info(p_slot);
595-
596-
return ret;
568+
return remove_board(p_slot);
597569
}
598570

599571
int pciehp_sysfs_enable_slot(struct slot *p_slot)

‎drivers/pci/hotplug/pciehp_hpc.c‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -427,27 +427,24 @@ int pciehp_set_attention_status(struct slot *slot, u8 value)
427427
struct controller *ctrl = slot->ctrl;
428428
u16 slot_cmd;
429429
u16 cmd_mask;
430-
int rc;
431430

432431
cmd_mask = PCI_EXP_SLTCTL_AIC;
433432
switch (value) {
434-
case 0 : /* turn off */
435-
slot_cmd = 0x00C0;
436-
break;
437-
case 1: /* turn on */
438-
slot_cmd = 0x0040;
439-
break;
440-
case 2: /* turn blink */
441-
slot_cmd = 0x0080;
442-
break;
443-
default:
444-
return -1;
445-
}
446-
rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
433+
case 0 : /* turn off */
434+
slot_cmd = 0x00C0;
435+
break;
436+
case 1: /* turn on */
437+
slot_cmd = 0x0040;
438+
break;
439+
case 2: /* turn blink */
440+
slot_cmd = 0x0080;
441+
break;
442+
default:
443+
return -EINVAL;
444+
}
447445
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
448446
__func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
449-
450-
return rc;
447+
return pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
451448
}
452449

453450
void pciehp_green_led_on(struct slot *slot)

0 commit comments

Comments
 (0)