]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/pciehp_ctrl.c
PCI hotplug: pciehp: message refinement
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / pciehp_ctrl.c
index 96a5d55a49835e43caadb3b2b0cd52210fd2fce9..fead63c6b49ec676fda835c2fa04b2b6fd348d22 100644 (file)
@@ -58,14 +58,15 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
 u8 pciehp_handle_attention_button(struct slot *p_slot)
 {
        u32 event_type;
+       struct controller *ctrl = p_slot->ctrl;
 
        /* Attention Button Change */
-       dbg("pciehp:  Attention button interrupt received.\n");
+       ctrl_dbg(ctrl, "Attention button interrupt received\n");
 
        /*
         *  Button pressed - See if need to TAKE ACTION!!!
         */
-       info("Button pressed on Slot(%s)\n", p_slot->name);
+       ctrl_info(ctrl, "Button pressed on Slot(%s)\n", slot_name(p_slot));
        event_type = INT_BUTTON_PRESS;
 
        queue_interrupt_event(p_slot, event_type);
@@ -77,22 +78,23 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
 {
        u8 getstatus;
        u32 event_type;
+       struct controller *ctrl = p_slot->ctrl;
 
        /* Switch Change */
-       dbg("pciehp:  Switch interrupt received.\n");
+       ctrl_dbg(ctrl, "Switch interrupt received\n");
 
        p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
        if (getstatus) {
                /*
                 * Switch opened
                 */
-               info("Latch open on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Latch open on Slot(%s)\n", slot_name(p_slot));
                event_type = INT_SWITCH_OPEN;
        } else {
                /*
                 *  Switch closed
                 */
-               info("Latch close on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Latch close on Slot(%s)\n", slot_name(p_slot));
                event_type = INT_SWITCH_CLOSE;
        }
 
@@ -105,9 +107,10 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
 {
        u32 event_type;
        u8 presence_save;
+       struct controller *ctrl = p_slot->ctrl;
 
        /* Presence Change */
-       dbg("pciehp:  Presence/Notify input change.\n");
+       ctrl_dbg(ctrl, "Presence/Notify input change\n");
 
        /* Switch is open, assume a presence change
         * Save the presence state
@@ -117,13 +120,14 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
                /*
                 * Card Present
                 */
-               info("Card present on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Card present on Slot(%s)\n", slot_name(p_slot));
                event_type = INT_PRESENCE_ON;
        } else {
                /*
                 * Not Present
                 */
-               info("Card not present on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Card not present on Slot(%s)\n",
+                         slot_name(p_slot));
                event_type = INT_PRESENCE_OFF;
        }
 
@@ -135,23 +139,25 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
 u8 pciehp_handle_power_fault(struct slot *p_slot)
 {
        u32 event_type;
+       struct controller *ctrl = p_slot->ctrl;
 
        /* power fault */
-       dbg("pciehp:  Power fault interrupt received.\n");
+       ctrl_dbg(ctrl, "Power fault interrupt received\n");
 
        if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
                /*
                 * power fault Cleared
                 */
-               info("Power fault cleared on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n",
+                         slot_name(p_slot));
                event_type = INT_POWER_FAULT_CLEAR;
        } else {
                /*
                 *   power fault
                 */
-               info("Power fault on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Power fault on Slot(%s)\n", slot_name(p_slot));
                event_type = INT_POWER_FAULT;
-               info("power fault bit %x set\n", 0);
+               ctrl_info(ctrl, "Power fault bit %x set\n", 0);
        }
 
        queue_interrupt_event(p_slot, event_type);
@@ -168,8 +174,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
        /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
        if (POWER_CTRL(ctrl)) {
                if (pslot->hpc_ops->power_off_slot(pslot)) {
-                       err("%s: Issue of Slot Power Off command failed\n",
-                           __func__);
+                       ctrl_err(ctrl,
+                                "Issue of Slot Power Off command failed\n");
                        return;
                }
        }
@@ -186,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
 
        if (ATTN_LED(ctrl)) {
                if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
-                       err("%s: Issue of Set Attention Led command failed\n",
-                           __func__);
+                       ctrl_err(ctrl,
+                                "Issue of Set Attention Led command failed\n");
                        return;
                }
        }
@@ -204,10 +210,11 @@ static int board_added(struct slot *p_slot)
 {
        int retval = 0;
        struct controller *ctrl = p_slot->ctrl;
+       struct pci_bus *parent = ctrl->pci_dev->subordinate;
 
-       dbg("%s: slot device, slot offset, hp slot = %d, %d ,%d\n",
-                       __func__, p_slot->device,
-                       ctrl->slot_device_offset, p_slot->hp_slot);
+       ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d, %d\n",
+                __func__, p_slot->device, ctrl->slot_device_offset,
+                p_slot->hp_slot);
 
        if (POWER_CTRL(ctrl)) {
                /* Power on slot */
@@ -219,28 +226,25 @@ static int board_added(struct slot *p_slot)
        if (PWR_LED(ctrl))
                p_slot->hpc_ops->green_led_blink(p_slot);
 
-       /* Wait for ~1 second */
-       msleep(1000);
-
        /* Check link training status */
        retval = p_slot->hpc_ops->check_lnk_status(ctrl);
        if (retval) {
-               err("%s: Failed to check link status\n", __func__);
+               ctrl_err(ctrl, "Failed to check link status\n");
                set_slot_off(ctrl, p_slot);
                return retval;
        }
 
        /* Check for a power fault */
        if (p_slot->hpc_ops->query_power_fault(p_slot)) {
-               dbg("%s: power fault detected\n", __func__);
+               ctrl_dbg(ctrl, "Power fault detected\n");
                retval = POWER_FAILURE;
                goto err_exit;
        }
 
        retval = pciehp_configure_device(p_slot);
        if (retval) {
-               err("Cannot add device 0x%x:%x\n", p_slot->bus,
-                   p_slot->device);
+               ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n",
+                        pci_domain_nr(parent), p_slot->bus, p_slot->device);
                goto err_exit;
        }
 
@@ -272,14 +276,14 @@ static int remove_board(struct slot *p_slot)
        if (retval)
                return retval;
 
-       dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot);
+       ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, p_slot->hp_slot);
 
        if (POWER_CTRL(ctrl)) {
                /* power off slot */
                retval = p_slot->hpc_ops->power_off_slot(p_slot);
                if (retval) {
-                       err("%s: Issue of Slot Disable command failed\n",
-                           __func__);
+                       ctrl_err(ctrl,
+                                "Issue of Slot Disable command failed\n");
                        return retval;
                }
        }
@@ -320,8 +324,10 @@ static void pciehp_power_thread(struct work_struct *work)
        switch (p_slot->state) {
        case POWEROFF_STATE:
                mutex_unlock(&p_slot->lock);
-               dbg("%s: disabling bus:device(%x:%x)\n",
-                   __func__, p_slot->bus, p_slot->device);
+               ctrl_dbg(p_slot->ctrl,
+                        "Disabling domain:bus:device=%04x:%02x:%02x\n",
+                        pci_domain_nr(p_slot->ctrl->pci_dev->subordinate),
+                        p_slot->bus, p_slot->device);
                pciehp_disable_slot(p_slot);
                mutex_lock(&p_slot->lock);
                p_slot->state = STATIC_STATE;
@@ -349,7 +355,8 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
 
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
-               err("%s: Cannot allocate memory\n", __func__);
+               ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
+                        __func__);
                return;
        }
        info->p_slot = p_slot;
@@ -403,12 +410,14 @@ static void handle_button_press_event(struct slot *p_slot)
                p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (getstatus) {
                        p_slot->state = BLINKINGOFF_STATE;
-                       info("PCI slot #%s - powering off due to button "
-                            "press.\n", p_slot->name);
+                       ctrl_info(ctrl,
+                                 "PCI slot #%s - powering off due to button "
+                                 "press.\n", slot_name(p_slot));
                } else {
                        p_slot->state = BLINKINGON_STATE;
-                       info("PCI slot #%s - powering on due to button "
-                            "press.\n", p_slot->name);
+                       ctrl_info(ctrl,
+                                 "PCI slot #%s - powering on due to button "
+                                 "press.\n", slot_name(p_slot));
                }
                /* blink green LED and turn off amber */
                if (PWR_LED(ctrl))
@@ -425,8 +434,7 @@ static void handle_button_press_event(struct slot *p_slot)
                 * press the attention again before the 5 sec. limit
                 * expires to cancel hot-add or hot-remove
                 */
-               info("Button cancel on Slot(%s)\n", p_slot->name);
-               dbg("%s: button cancel\n", __func__);
+               ctrl_info(ctrl, "Button cancel on Slot(%s)\n", slot_name(p_slot));
                cancel_delayed_work(&p_slot->work);
                if (p_slot->state == BLINKINGOFF_STATE) {
                        if (PWR_LED(ctrl))
@@ -437,8 +445,8 @@ static void handle_button_press_event(struct slot *p_slot)
                }
                if (ATTN_LED(ctrl))
                        p_slot->hpc_ops->set_attention_status(p_slot, 0);
-               info("PCI slot #%s - action canceled due to button press\n",
-                    p_slot->name);
+               ctrl_info(ctrl, "PCI slot #%s - action canceled "
+                         "due to button press\n", slot_name(p_slot));
                p_slot->state = STATIC_STATE;
                break;
        case POWEROFF_STATE:
@@ -448,11 +456,11 @@ static void handle_button_press_event(struct slot *p_slot)
                 * this means that the previous attention button action
                 * to hot-add or hot-remove is undergoing
                 */
-               info("Button ignore on Slot(%s)\n", p_slot->name);
+               ctrl_info(ctrl, "Button ignore on Slot(%s)\n", slot_name(p_slot));
                update_slot_info(p_slot);
                break;
        default:
-               warn("Not a valid state\n");
+               ctrl_warn(ctrl, "Not a valid state\n");
                break;
        }
 }
@@ -467,7 +475,8 @@ static void handle_surprise_event(struct slot *p_slot)
 
        info = kmalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
-               err("%s: Cannot allocate memory\n", __func__);
+               ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
+                        __func__);
                return;
        }
        info->p_slot = p_slot;
@@ -505,7 +514,7 @@ static void interrupt_event_handler(struct work_struct *work)
        case INT_PRESENCE_OFF:
                if (!HP_SUPR_RM(ctrl))
                        break;
-               dbg("Surprise Removal\n");
+               ctrl_dbg(ctrl, "Surprise Removal\n");
                update_slot_info(p_slot);
                handle_surprise_event(p_slot);
                break;
@@ -522,22 +531,22 @@ int pciehp_enable_slot(struct slot *p_slot)
 {
        u8 getstatus = 0;
        int rc;
+       struct controller *ctrl = p_slot->ctrl;
 
        /* Check to see if (latch closed, card present, power off) */
        mutex_lock(&p_slot->ctrl->crit_sect);
 
        rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
        if (rc || !getstatus) {
-               info("%s: no adapter on slot(%s)\n", __func__,
-                    p_slot->name);
+               ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
                mutex_unlock(&p_slot->ctrl->crit_sect);
                return -ENODEV;
        }
        if (MRL_SENS(p_slot->ctrl)) {
                rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
                if (rc || getstatus) {
-                       info("%s: latch open on slot(%s)\n", __func__,
-                            p_slot->name);
+                       ctrl_info(ctrl, "Latch open on slot(%s)\n",
+                                 slot_name(p_slot));
                        mutex_unlock(&p_slot->ctrl->crit_sect);
                        return -ENODEV;
                }
@@ -546,8 +555,8 @@ int pciehp_enable_slot(struct slot *p_slot)
        if (POWER_CTRL(p_slot->ctrl)) {
                rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (rc || getstatus) {
-                       info("%s: already enabled on slot(%s)\n", __func__,
-                            p_slot->name);
+                       ctrl_info(ctrl, "Already enabled on slot(%s)\n",
+                                 slot_name(p_slot));
                        mutex_unlock(&p_slot->ctrl->crit_sect);
                        return -EINVAL;
                }
@@ -571,6 +580,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 {
        u8 getstatus = 0;
        int ret = 0;
+       struct controller *ctrl = p_slot->ctrl;
 
        if (!p_slot->ctrl)
                return 1;
@@ -581,8 +591,8 @@ int pciehp_disable_slot(struct slot *p_slot)
        if (!HP_SUPR_RM(p_slot->ctrl)) {
                ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
                if (ret || !getstatus) {
-                       info("%s: no adapter on slot(%s)\n", __func__,
-                            p_slot->name);
+                       ctrl_info(ctrl, "No adapter on slot(%s)\n",
+                                 slot_name(p_slot));
                        mutex_unlock(&p_slot->ctrl->crit_sect);
                        return -ENODEV;
                }
@@ -591,8 +601,8 @@ int pciehp_disable_slot(struct slot *p_slot)
        if (MRL_SENS(p_slot->ctrl)) {
                ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
                if (ret || getstatus) {
-                       info("%s: latch open on slot(%s)\n", __func__,
-                            p_slot->name);
+                       ctrl_info(ctrl, "Latch open on slot(%s)\n",
+                                 slot_name(p_slot));
                        mutex_unlock(&p_slot->ctrl->crit_sect);
                        return -ENODEV;
                }
@@ -601,8 +611,8 @@ int pciehp_disable_slot(struct slot *p_slot)
        if (POWER_CTRL(p_slot->ctrl)) {
                ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (ret || !getstatus) {
-                       info("%s: already disabled slot(%s)\n", __func__,
-                            p_slot->name);
+                       ctrl_info(ctrl, "Already disabled on slot(%s)\n",
+                                 slot_name(p_slot));
                        mutex_unlock(&p_slot->ctrl->crit_sect);
                        return -EINVAL;
                }
@@ -618,6 +628,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 int pciehp_sysfs_enable_slot(struct slot *p_slot)
 {
        int retval = -ENODEV;
+       struct controller *ctrl = p_slot->ctrl;
 
        mutex_lock(&p_slot->lock);
        switch (p_slot->state) {
@@ -631,15 +642,17 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
                p_slot->state = STATIC_STATE;
                break;
        case POWERON_STATE:
-               info("Slot %s is already in powering on state\n",
-                    p_slot->name);
+               ctrl_info(ctrl, "Slot %s is already in powering on state\n",
+                         slot_name(p_slot));
                break;
        case BLINKINGOFF_STATE:
        case POWEROFF_STATE:
-               info("Already enabled on slot %s\n", p_slot->name);
+               ctrl_info(ctrl, "Already enabled on slot %s\n",
+                         slot_name(p_slot));
                break;
        default:
-               err("Not a valid state on slot %s\n", p_slot->name);
+               ctrl_err(ctrl, "Not a valid state on slot %s\n",
+                        slot_name(p_slot));
                break;
        }
        mutex_unlock(&p_slot->lock);
@@ -650,6 +663,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
 int pciehp_sysfs_disable_slot(struct slot *p_slot)
 {
        int retval = -ENODEV;
+       struct controller *ctrl = p_slot->ctrl;
 
        mutex_lock(&p_slot->lock);
        switch (p_slot->state) {
@@ -663,15 +677,17 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
                p_slot->state = STATIC_STATE;
                break;
        case POWEROFF_STATE:
-               info("Slot %s is already in powering off state\n",
-                    p_slot->name);
+               ctrl_info(ctrl, "Slot %s is already in powering off state\n",
+                         slot_name(p_slot));
                break;
        case BLINKINGON_STATE:
        case POWERON_STATE:
-               info("Already disabled on slot %s\n", p_slot->name);
+               ctrl_info(ctrl, "Already disabled on slot %s\n",
+                         slot_name(p_slot));
                break;
        default:
-               err("Not a valid state on slot %s\n", p_slot->name);
+               ctrl_err(ctrl, "Not a valid state on slot %s\n",
+                        slot_name(p_slot));
                break;
        }
        mutex_unlock(&p_slot->lock);