Commit af9ab791 authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: pciehp: Move Attention & Power Indicator support tests to accessors

Previously, the caller checked ATTN_LED() or PWR_LED() to see whether the
slot has indicators before setting the indicator state.  That clutters the
caller unnecessarily, so this moves the test inside the callees.  The test
may not even be necessary; per spec it should be harmless to try to turn on
a non-existent LED.  But checking first does avoid unnecessary hotplug
commands.

No functional change.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent e7b4f0d7
...@@ -168,11 +168,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -168,11 +168,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
msleep(1000); msleep(1000);
} }
if (PWR_LED(ctrl)) pciehp_green_led_off(pslot);
pciehp_green_led_off(pslot); pciehp_set_attention_status(pslot, 1);
if (ATTN_LED(ctrl))
pciehp_set_attention_status(pslot, 1);
} }
/** /**
...@@ -195,8 +192,7 @@ static int board_added(struct slot *p_slot) ...@@ -195,8 +192,7 @@ static int board_added(struct slot *p_slot)
return retval; return retval;
} }
if (PWR_LED(ctrl)) pciehp_green_led_blink(p_slot);
pciehp_green_led_blink(p_slot);
/* Check link training status */ /* Check link training status */
retval = pciehp_check_link_status(ctrl); retval = pciehp_check_link_status(ctrl);
...@@ -219,9 +215,7 @@ static int board_added(struct slot *p_slot) ...@@ -219,9 +215,7 @@ static int board_added(struct slot *p_slot)
goto err_exit; goto err_exit;
} }
if (PWR_LED(ctrl)) pciehp_green_led_on(p_slot);
pciehp_green_led_on(p_slot);
return 0; return 0;
err_exit: err_exit:
...@@ -254,9 +248,7 @@ static int remove_board(struct slot *p_slot) ...@@ -254,9 +248,7 @@ static int remove_board(struct slot *p_slot)
} }
/* turn off Green LED */ /* turn off Green LED */
if (PWR_LED(ctrl)) pciehp_green_led_off(p_slot);
pciehp_green_led_off(p_slot);
return 0; return 0;
} }
...@@ -292,7 +284,7 @@ static void pciehp_power_thread(struct work_struct *work) ...@@ -292,7 +284,7 @@ static void pciehp_power_thread(struct work_struct *work)
break; break;
case POWERON_STATE: case POWERON_STATE:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl)) if (pciehp_enable_slot(p_slot))
pciehp_green_led_off(p_slot); pciehp_green_led_off(p_slot);
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -359,11 +351,8 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -359,11 +351,8 @@ static void handle_button_press_event(struct slot *p_slot)
"press.\n", slot_name(p_slot)); "press.\n", slot_name(p_slot));
} }
/* blink green LED and turn off amber */ /* blink green LED and turn off amber */
if (PWR_LED(ctrl)) pciehp_green_led_blink(p_slot);
pciehp_green_led_blink(p_slot); pciehp_set_attention_status(p_slot, 0);
if (ATTN_LED(ctrl))
pciehp_set_attention_status(p_slot, 0);
queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ); queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
break; break;
case BLINKINGOFF_STATE: case BLINKINGOFF_STATE:
...@@ -376,14 +365,11 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -376,14 +365,11 @@ static void handle_button_press_event(struct slot *p_slot)
ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot)); ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
cancel_delayed_work(&p_slot->work); cancel_delayed_work(&p_slot->work);
if (p_slot->state == BLINKINGOFF_STATE) { if (p_slot->state == BLINKINGOFF_STATE) {
if (PWR_LED(ctrl)) pciehp_green_led_on(p_slot);
pciehp_green_led_on(p_slot);
} else { } else {
if (PWR_LED(ctrl)) pciehp_green_led_off(p_slot);
pciehp_green_led_off(p_slot);
} }
if (ATTN_LED(ctrl)) pciehp_set_attention_status(p_slot, 0);
pciehp_set_attention_status(p_slot, 0);
ctrl_info(ctrl, "PCI slot #%s - action canceled " ctrl_info(ctrl, "PCI slot #%s - action canceled "
"due to button press\n", slot_name(p_slot)); "due to button press\n", slot_name(p_slot));
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -443,10 +429,8 @@ static void interrupt_event_handler(struct work_struct *work) ...@@ -443,10 +429,8 @@ static void interrupt_event_handler(struct work_struct *work)
case INT_POWER_FAULT: case INT_POWER_FAULT:
if (!POWER_CTRL(ctrl)) if (!POWER_CTRL(ctrl))
break; break;
if (ATTN_LED(ctrl)) pciehp_set_attention_status(p_slot, 1);
pciehp_set_attention_status(p_slot, 1); pciehp_green_led_off(p_slot);
if (PWR_LED(ctrl))
pciehp_green_led_off(p_slot);
break; break;
case INT_PRESENCE_ON: case INT_PRESENCE_ON:
case INT_PRESENCE_OFF: case INT_PRESENCE_OFF:
......
...@@ -418,6 +418,9 @@ void pciehp_set_attention_status(struct slot *slot, u8 value) ...@@ -418,6 +418,9 @@ void pciehp_set_attention_status(struct slot *slot, u8 value)
struct controller *ctrl = slot->ctrl; struct controller *ctrl = slot->ctrl;
u16 slot_cmd; u16 slot_cmd;
if (!ATTN_LED(ctrl))
return;
switch (value) { switch (value) {
case 0 : /* turn off */ case 0 : /* turn off */
slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_OFF; slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_OFF;
...@@ -440,6 +443,9 @@ void pciehp_green_led_on(struct slot *slot) ...@@ -440,6 +443,9 @@ void pciehp_green_led_on(struct slot *slot)
{ {
struct controller *ctrl = slot->ctrl; struct controller *ctrl = slot->ctrl;
if (!PWR_LED(ctrl))
return;
pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, PCI_EXP_SLTCTL_PIC); pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_ON, PCI_EXP_SLTCTL_PIC);
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
...@@ -450,6 +456,9 @@ void pciehp_green_led_off(struct slot *slot) ...@@ -450,6 +456,9 @@ void pciehp_green_led_off(struct slot *slot)
{ {
struct controller *ctrl = slot->ctrl; struct controller *ctrl = slot->ctrl;
if (!PWR_LED(ctrl))
return;
pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, PCI_EXP_SLTCTL_PIC); pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_OFF, PCI_EXP_SLTCTL_PIC);
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
...@@ -460,6 +469,9 @@ void pciehp_green_led_blink(struct slot *slot) ...@@ -460,6 +469,9 @@ void pciehp_green_led_blink(struct slot *slot)
{ {
struct controller *ctrl = slot->ctrl; struct controller *ctrl = slot->ctrl;
if (!PWR_LED(ctrl))
return;
pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, PCI_EXP_SLTCTL_PIC); pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK, PCI_EXP_SLTCTL_PIC);
ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL, pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment