Commit 7f2feec1 authored by Taku Izumi's avatar Taku Izumi Committed by Jesse Barnes

PCI: pciehp: replace printk with dev_printk

This patch replaces printks within pciehp module with dev_printks.
Signed-off-by: default avatarTaku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 83e9ad54
...@@ -57,6 +57,19 @@ extern struct workqueue_struct *pciehp_wq; ...@@ -57,6 +57,19 @@ extern struct workqueue_struct *pciehp_wq;
#define warn(format, arg...) \ #define warn(format, arg...) \
printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
#define ctrl_dbg(ctrl, format, arg...) \
do { \
if (pciehp_debug) \
dev_printk(, &ctrl->pcie->device, \
format, ## arg); \
} while (0)
#define ctrl_err(ctrl, format, arg...) \
dev_err(&ctrl->pcie->device, format, ## arg)
#define ctrl_info(ctrl, format, arg...) \
dev_info(&ctrl->pcie->device, format, ## arg)
#define ctrl_warn(ctrl, format, arg...) \
dev_warn(&ctrl->pcie->device, format, ## arg)
#define SLOT_NAME_SIZE 10 #define SLOT_NAME_SIZE 10
struct slot { struct slot {
u8 bus; u8 bus;
...@@ -171,7 +184,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) ...@@ -171,7 +184,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
return slot; return slot;
} }
err("%s: slot (device=0x%x) not found\n", __func__, device); ctrl_err(ctrl, "%s: slot (device=0x%x) not found\n", __func__, device);
return NULL; return NULL;
} }
......
...@@ -144,9 +144,10 @@ static int set_lock_status(struct hotplug_slot *hotplug_slot, u8 status) ...@@ -144,9 +144,10 @@ static int set_lock_status(struct hotplug_slot *hotplug_slot, u8 status)
* sysfs interface which allows the user to toggle the Electro Mechanical * sysfs interface which allows the user to toggle the Electro Mechanical
* Interlock. Valid values are either 0 or 1. 0 == unlock, 1 == lock * Interlock. Valid values are either 0 or 1. 0 == unlock, 1 == lock
*/ */
static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf, static ssize_t lock_write_file(struct hotplug_slot *hotplug_slot,
size_t count) const char *buf, size_t count)
{ {
struct slot *slot = hotplug_slot->private;
unsigned long llock; unsigned long llock;
u8 lock; u8 lock;
int retval = 0; int retval = 0;
...@@ -157,10 +158,11 @@ static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf, ...@@ -157,10 +158,11 @@ static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf,
switch (lock) { switch (lock) {
case 0: case 0:
case 1: case 1:
retval = set_lock_status(slot, lock); retval = set_lock_status(hotplug_slot, lock);
break; break;
default: default:
err ("%d is an invalid lock value\n", lock); ctrl_err(slot->ctrl, "%d is an invalid lock value\n",
lock);
retval = -EINVAL; retval = -EINVAL;
} }
if (retval) if (retval)
...@@ -180,7 +182,10 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = { ...@@ -180,7 +182,10 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = {
*/ */
static void release_slot(struct hotplug_slot *hotplug_slot) static void release_slot(struct hotplug_slot *hotplug_slot)
{ {
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); struct slot *slot = hotplug_slot->private;
ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
kfree(hotplug_slot->info); kfree(hotplug_slot->info);
kfree(hotplug_slot); kfree(hotplug_slot);
...@@ -215,9 +220,9 @@ static int init_slots(struct controller *ctrl) ...@@ -215,9 +220,9 @@ static int init_slots(struct controller *ctrl)
get_adapter_status(hotplug_slot, &info->adapter_status); get_adapter_status(hotplug_slot, &info->adapter_status);
slot->hotplug_slot = hotplug_slot; slot->hotplug_slot = hotplug_slot;
dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " ctrl_dbg(ctrl, "Registering bus=%x dev=%x hp_slot=%x sun=%x "
"slot_device_offset=%x\n", slot->bus, slot->device, "slot_device_offset=%x\n", slot->bus, slot->device,
slot->hp_slot, slot->number, ctrl->slot_device_offset); slot->hp_slot, slot->number, ctrl->slot_device_offset);
duplicate_name: duplicate_name:
retval = pci_hp_register(hotplug_slot, retval = pci_hp_register(hotplug_slot,
ctrl->pci_dev->subordinate, ctrl->pci_dev->subordinate,
...@@ -233,9 +238,11 @@ static int init_slots(struct controller *ctrl) ...@@ -233,9 +238,11 @@ static int init_slots(struct controller *ctrl)
if (len < SLOT_NAME_SIZE) if (len < SLOT_NAME_SIZE)
goto duplicate_name; goto duplicate_name;
else else
err("duplicate slot name overflow\n"); ctrl_err(ctrl, "duplicate slot name "
"overflow\n");
} }
err("pci_hp_register failed with error %d\n", retval); ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
retval);
goto error_info; goto error_info;
} }
/* create additional sysfs entries */ /* create additional sysfs entries */
...@@ -244,7 +251,8 @@ static int init_slots(struct controller *ctrl) ...@@ -244,7 +251,8 @@ static int init_slots(struct controller *ctrl)
&hotplug_slot_attr_lock.attr); &hotplug_slot_attr_lock.attr);
if (retval) { if (retval) {
pci_hp_deregister(hotplug_slot); pci_hp_deregister(hotplug_slot);
err("cannot create additional sysfs entries\n"); ctrl_err(ctrl, "cannot create additional sysfs "
"entries\n");
goto error_info; goto error_info;
} }
} }
...@@ -278,7 +286,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) ...@@ -278,7 +286,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
hotplug_slot->info->attention_status = status; hotplug_slot->info->attention_status = status;
...@@ -293,7 +302,8 @@ static int enable_slot(struct hotplug_slot *hotplug_slot) ...@@ -293,7 +302,8 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
return pciehp_sysfs_enable_slot(slot); return pciehp_sysfs_enable_slot(slot);
} }
...@@ -303,7 +313,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot) ...@@ -303,7 +313,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
{ {
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
return pciehp_sysfs_disable_slot(slot); return pciehp_sysfs_disable_slot(slot);
} }
...@@ -313,7 +324,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -313,7 +324,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_power_status(slot, value); retval = slot->hpc_ops->get_power_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -327,7 +339,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -327,7 +339,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_attention_status(slot, value); retval = slot->hpc_ops->get_attention_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -341,7 +354,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -341,7 +354,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_latch_status(slot, value); retval = slot->hpc_ops->get_latch_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -355,7 +369,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value) ...@@ -355,7 +369,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_adapter_status(slot, value); retval = slot->hpc_ops->get_adapter_status(slot, value);
if (retval < 0) if (retval < 0)
...@@ -370,7 +385,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, ...@@ -370,7 +385,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_max_bus_speed(slot, value); retval = slot->hpc_ops->get_max_bus_speed(slot, value);
if (retval < 0) if (retval < 0)
...@@ -384,7 +400,8 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe ...@@ -384,7 +400,8 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval; int retval;
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name); ctrl_dbg(slot->ctrl, "%s - physical_slot = %s\n",
__func__, hotplug_slot->name);
retval = slot->hpc_ops->get_cur_bus_speed(slot, value); retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
if (retval < 0) if (retval < 0)
...@@ -402,14 +419,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ ...@@ -402,14 +419,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
struct pci_dev *pdev = dev->port; struct pci_dev *pdev = dev->port;
if (pciehp_force) if (pciehp_force)
dbg("Bypassing BIOS check for pciehp use on %s\n", dev_info(&dev->device,
pci_name(pdev)); "Bypassing BIOS check for pciehp use on %s\n",
pci_name(pdev));
else if (pciehp_get_hp_hw_control_from_firmware(pdev)) else if (pciehp_get_hp_hw_control_from_firmware(pdev))
goto err_out_none; goto err_out_none;
ctrl = pcie_init(dev); ctrl = pcie_init(dev);
if (!ctrl) { if (!ctrl) {
dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME); dev_err(&dev->device, "controller initialization failed\n");
goto err_out_none; goto err_out_none;
} }
set_service_data(dev, ctrl); set_service_data(dev, ctrl);
...@@ -418,11 +436,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ ...@@ -418,11 +436,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
rc = init_slots(ctrl); rc = init_slots(ctrl);
if (rc) { if (rc) {
if (rc == -EBUSY) if (rc == -EBUSY)
warn("%s: slot already registered by another " ctrl_warn(ctrl, "slot already registered by another "
"hotplug driver\n", PCIE_MODULE_NAME); "hotplug driver\n");
else else
err("%s: slot initialization failed\n", ctrl_err(ctrl, "slot initialization failed\n");
PCIE_MODULE_NAME);
goto err_out_release_ctlr; goto err_out_release_ctlr;
} }
...@@ -461,13 +478,13 @@ static void pciehp_remove (struct pcie_device *dev) ...@@ -461,13 +478,13 @@ static void pciehp_remove (struct pcie_device *dev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int pciehp_suspend (struct pcie_device *dev, pm_message_t state) static int pciehp_suspend (struct pcie_device *dev, pm_message_t state)
{ {
printk("%s ENTRY\n", __func__); dev_info(&dev->device, "%s ENTRY\n", __func__);
return 0; return 0;
} }
static int pciehp_resume (struct pcie_device *dev) static int pciehp_resume (struct pcie_device *dev)
{ {
printk("%s ENTRY\n", __func__); dev_info(&dev->device, "%s ENTRY\n", __func__);
if (pciehp_force) { if (pciehp_force) {
struct controller *ctrl = get_service_data(dev); struct controller *ctrl = get_service_data(dev);
struct slot *t_slot; struct slot *t_slot;
......
...@@ -58,14 +58,15 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) ...@@ -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) u8 pciehp_handle_attention_button(struct slot *p_slot)
{ {
u32 event_type; u32 event_type;
struct controller *ctrl = p_slot->ctrl;
/* Attention Button Change */ /* 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!!! * 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", p_slot->name);
event_type = INT_BUTTON_PRESS; event_type = INT_BUTTON_PRESS;
queue_interrupt_event(p_slot, event_type); queue_interrupt_event(p_slot, event_type);
...@@ -77,22 +78,23 @@ u8 pciehp_handle_switch_change(struct slot *p_slot) ...@@ -77,22 +78,23 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
{ {
u8 getstatus; u8 getstatus;
u32 event_type; u32 event_type;
struct controller *ctrl = p_slot->ctrl;
/* Switch Change */ /* 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); p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (getstatus) { if (getstatus) {
/* /*
* Switch opened * Switch opened
*/ */
info("Latch open on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Latch open on Slot(%s)\n", p_slot->name);
event_type = INT_SWITCH_OPEN; event_type = INT_SWITCH_OPEN;
} else { } else {
/* /*
* Switch closed * Switch closed
*/ */
info("Latch close on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Latch close on Slot(%s)\n", p_slot->name);
event_type = INT_SWITCH_CLOSE; event_type = INT_SWITCH_CLOSE;
} }
...@@ -105,9 +107,10 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) ...@@ -105,9 +107,10 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
{ {
u32 event_type; u32 event_type;
u8 presence_save; u8 presence_save;
struct controller *ctrl = p_slot->ctrl;
/* Presence Change */ /* Presence Change */
dbg("pciehp: Presence/Notify input change.\n"); ctrl_dbg(ctrl, "Presence/Notify input change.\n");
/* Switch is open, assume a presence change /* Switch is open, assume a presence change
* Save the presence state * Save the presence state
...@@ -117,13 +120,13 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) ...@@ -117,13 +120,13 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
/* /*
* Card Present * Card Present
*/ */
info("Card present on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Card present on Slot(%s)\n", p_slot->name);
event_type = INT_PRESENCE_ON; event_type = INT_PRESENCE_ON;
} else { } else {
/* /*
* Not Present * Not Present
*/ */
info("Card not present on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Card not present on Slot(%s)\n", p_slot->name);
event_type = INT_PRESENCE_OFF; event_type = INT_PRESENCE_OFF;
} }
...@@ -135,23 +138,25 @@ u8 pciehp_handle_presence_change(struct slot *p_slot) ...@@ -135,23 +138,25 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
u8 pciehp_handle_power_fault(struct slot *p_slot) u8 pciehp_handle_power_fault(struct slot *p_slot)
{ {
u32 event_type; u32 event_type;
struct controller *ctrl = p_slot->ctrl;
/* power fault */ /* 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))) { if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
/* /*
* power fault Cleared * power fault Cleared
*/ */
info("Power fault cleared on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Power fault cleared on Slot(%s)\n",
p_slot->name);
event_type = INT_POWER_FAULT_CLEAR; event_type = INT_POWER_FAULT_CLEAR;
} else { } else {
/* /*
* power fault * power fault
*/ */
info("Power fault on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Power fault on Slot(%s)\n", p_slot->name);
event_type = INT_POWER_FAULT; 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); queue_interrupt_event(p_slot, event_type);
...@@ -168,8 +173,9 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -168,8 +173,9 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
/* turn off slot, turn on Amber LED, turn off Green LED if supported*/ /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
if (pslot->hpc_ops->power_off_slot(pslot)) { if (pslot->hpc_ops->power_off_slot(pslot)) {
err("%s: Issue of Slot Power Off command failed\n", ctrl_err(ctrl,
__func__); "%s: Issue of Slot Power Off command failed\n",
__func__);
return; return;
} }
} }
...@@ -186,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) ...@@ -186,8 +192,8 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
if (ATTN_LED(ctrl)) { if (ATTN_LED(ctrl)) {
if (pslot->hpc_ops->set_attention_status(pslot, 1)) { if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
err("%s: Issue of Set Attention Led command failed\n", ctrl_err(ctrl, "%s: Issue of Set Attention "
__func__); "Led command failed\n", __func__);
return; return;
} }
} }
...@@ -205,9 +211,9 @@ static int board_added(struct slot *p_slot) ...@@ -205,9 +211,9 @@ static int board_added(struct slot *p_slot)
int retval = 0; int retval = 0;
struct controller *ctrl = p_slot->ctrl; struct controller *ctrl = p_slot->ctrl;
dbg("%s: slot device, slot offset, hp slot = %d, %d ,%d\n", ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d ,%d\n",
__func__, p_slot->device, __func__, p_slot->device, ctrl->slot_device_offset,
ctrl->slot_device_offset, p_slot->hp_slot); p_slot->hp_slot);
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
/* Power on slot */ /* Power on slot */
...@@ -225,22 +231,22 @@ static int board_added(struct slot *p_slot) ...@@ -225,22 +231,22 @@ static int board_added(struct slot *p_slot)
/* Check link training status */ /* Check link training status */
retval = p_slot->hpc_ops->check_lnk_status(ctrl); retval = p_slot->hpc_ops->check_lnk_status(ctrl);
if (retval) { if (retval) {
err("%s: Failed to check link status\n", __func__); ctrl_err(ctrl, "%s: Failed to check link status\n", __func__);
set_slot_off(ctrl, p_slot); set_slot_off(ctrl, p_slot);
return retval; return retval;
} }
/* Check for a power fault */ /* Check for a power fault */
if (p_slot->hpc_ops->query_power_fault(p_slot)) { if (p_slot->hpc_ops->query_power_fault(p_slot)) {
dbg("%s: power fault detected\n", __func__); ctrl_dbg(ctrl, "%s: power fault detected\n", __func__);
retval = POWER_FAILURE; retval = POWER_FAILURE;
goto err_exit; goto err_exit;
} }
retval = pciehp_configure_device(p_slot); retval = pciehp_configure_device(p_slot);
if (retval) { if (retval) {
err("Cannot add device 0x%x:%x\n", p_slot->bus, ctrl_err(ctrl, "Cannot add device 0x%x:%x\n",
p_slot->device); p_slot->bus, p_slot->device);
goto err_exit; goto err_exit;
} }
...@@ -272,14 +278,14 @@ static int remove_board(struct slot *p_slot) ...@@ -272,14 +278,14 @@ static int remove_board(struct slot *p_slot)
if (retval) if (retval)
return retval; return retval;
dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); ctrl_dbg(ctrl, "In %s, hp_slot = %d\n", __func__, p_slot->hp_slot);
if (POWER_CTRL(ctrl)) { if (POWER_CTRL(ctrl)) {
/* power off slot */ /* power off slot */
retval = p_slot->hpc_ops->power_off_slot(p_slot); retval = p_slot->hpc_ops->power_off_slot(p_slot);
if (retval) { if (retval) {
err("%s: Issue of Slot Disable command failed\n", ctrl_err(ctrl, "%s: Issue of Slot Disable command "
__func__); "failed\n", __func__);
return retval; return retval;
} }
} }
...@@ -320,8 +326,8 @@ static void pciehp_power_thread(struct work_struct *work) ...@@ -320,8 +326,8 @@ static void pciehp_power_thread(struct work_struct *work)
switch (p_slot->state) { switch (p_slot->state) {
case POWEROFF_STATE: case POWEROFF_STATE:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
dbg("%s: disabling bus:device(%x:%x)\n", ctrl_dbg(p_slot->ctrl, "%s: disabling bus:device(%x:%x)\n",
__func__, p_slot->bus, p_slot->device); __func__, p_slot->bus, p_slot->device);
pciehp_disable_slot(p_slot); pciehp_disable_slot(p_slot);
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
...@@ -349,7 +355,8 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) ...@@ -349,7 +355,8 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
info = kmalloc(sizeof(*info), GFP_KERNEL); info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info) { if (!info) {
err("%s: Cannot allocate memory\n", __func__); ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
__func__);
return; return;
} }
info->p_slot = p_slot; info->p_slot = p_slot;
...@@ -403,12 +410,14 @@ static void handle_button_press_event(struct 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); p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (getstatus) { if (getstatus) {
p_slot->state = BLINKINGOFF_STATE; p_slot->state = BLINKINGOFF_STATE;
info("PCI slot #%s - powering off due to button " ctrl_info(ctrl,
"press.\n", p_slot->name); "PCI slot #%s - powering off due to button "
"press.\n", p_slot->name);
} else { } else {
p_slot->state = BLINKINGON_STATE; p_slot->state = BLINKINGON_STATE;
info("PCI slot #%s - powering on due to button " ctrl_info(ctrl,
"press.\n", p_slot->name); "PCI slot #%s - powering on due to button "
"press.\n", p_slot->name);
} }
/* blink green LED and turn off amber */ /* blink green LED and turn off amber */
if (PWR_LED(ctrl)) if (PWR_LED(ctrl))
...@@ -425,8 +434,8 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -425,8 +434,8 @@ static void handle_button_press_event(struct slot *p_slot)
* press the attention again before the 5 sec. limit * press the attention again before the 5 sec. limit
* expires to cancel hot-add or hot-remove * expires to cancel hot-add or hot-remove
*/ */
info("Button cancel on Slot(%s)\n", p_slot->name); ctrl_info(ctrl, "Button cancel on Slot(%s)\n", p_slot->name);
dbg("%s: button cancel\n", __func__); ctrl_dbg(ctrl, "%s: button cancel\n", __func__);
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)) if (PWR_LED(ctrl))
...@@ -437,8 +446,8 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -437,8 +446,8 @@ static void handle_button_press_event(struct slot *p_slot)
} }
if (ATTN_LED(ctrl)) if (ATTN_LED(ctrl))
p_slot->hpc_ops->set_attention_status(p_slot, 0); p_slot->hpc_ops->set_attention_status(p_slot, 0);
info("PCI slot #%s - action canceled due to button press\n", ctrl_info(ctrl, "PCI slot #%s - action canceled "
p_slot->name); "due to button press\n", p_slot->name);
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
break; break;
case POWEROFF_STATE: case POWEROFF_STATE:
...@@ -448,11 +457,11 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -448,11 +457,11 @@ static void handle_button_press_event(struct slot *p_slot)
* this means that the previous attention button action * this means that the previous attention button action
* to hot-add or hot-remove is undergoing * 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", p_slot->name);
update_slot_info(p_slot); update_slot_info(p_slot);
break; break;
default: default:
warn("Not a valid state\n"); ctrl_warn(ctrl, "Not a valid state\n");
break; break;
} }
} }
...@@ -467,7 +476,8 @@ static void handle_surprise_event(struct slot *p_slot) ...@@ -467,7 +476,8 @@ static void handle_surprise_event(struct slot *p_slot)
info = kmalloc(sizeof(*info), GFP_KERNEL); info = kmalloc(sizeof(*info), GFP_KERNEL);
if (!info) { if (!info) {
err("%s: Cannot allocate memory\n", __func__); ctrl_err(p_slot->ctrl, "%s: Cannot allocate memory\n",
__func__);
return; return;
} }
info->p_slot = p_slot; info->p_slot = p_slot;
...@@ -505,7 +515,7 @@ static void interrupt_event_handler(struct work_struct *work) ...@@ -505,7 +515,7 @@ static void interrupt_event_handler(struct work_struct *work)
case INT_PRESENCE_OFF: case INT_PRESENCE_OFF:
if (!HP_SUPR_RM(ctrl)) if (!HP_SUPR_RM(ctrl))
break; break;
dbg("Surprise Removal\n"); ctrl_dbg(ctrl, "Surprise Removal\n");
update_slot_info(p_slot); update_slot_info(p_slot);
handle_surprise_event(p_slot); handle_surprise_event(p_slot);
break; break;
...@@ -522,22 +532,23 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -522,22 +532,23 @@ int pciehp_enable_slot(struct slot *p_slot)
{ {
u8 getstatus = 0; u8 getstatus = 0;
int rc; int rc;
struct controller *ctrl = p_slot->ctrl;
/* Check to see if (latch closed, card present, power off) */ /* Check to see if (latch closed, card present, power off) */
mutex_lock(&p_slot->ctrl->crit_sect); mutex_lock(&p_slot->ctrl->crit_sect);
rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (rc || !getstatus) { if (rc || !getstatus) {
info("%s: no adapter on slot(%s)\n", __func__, ctrl_info(ctrl, "%s: no adapter on slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (rc || getstatus) { if (rc || getstatus) {
info("%s: latch open on slot(%s)\n", __func__, ctrl_info(ctrl, "%s: latch open on slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -546,8 +557,8 @@ int pciehp_enable_slot(struct slot *p_slot) ...@@ -546,8 +557,8 @@ int pciehp_enable_slot(struct slot *p_slot)
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (rc || getstatus) { if (rc || getstatus) {
info("%s: already enabled on slot(%s)\n", __func__, ctrl_info(ctrl, "%s: already enabled on slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -EINVAL; return -EINVAL;
} }
...@@ -571,6 +582,7 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -571,6 +582,7 @@ int pciehp_disable_slot(struct slot *p_slot)
{ {
u8 getstatus = 0; u8 getstatus = 0;
int ret = 0; int ret = 0;
struct controller *ctrl = p_slot->ctrl;
if (!p_slot->ctrl) if (!p_slot->ctrl)
return 1; return 1;
...@@ -581,8 +593,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -581,8 +593,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (!HP_SUPR_RM(p_slot->ctrl)) { if (!HP_SUPR_RM(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (ret || !getstatus) { if (ret || !getstatus) {
info("%s: no adapter on slot(%s)\n", __func__, ctrl_info(ctrl, "%s: no adapter on slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -591,8 +603,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -591,8 +603,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (MRL_SENS(p_slot->ctrl)) { if (MRL_SENS(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (ret || getstatus) { if (ret || getstatus) {
info("%s: latch open on slot(%s)\n", __func__, ctrl_info(ctrl, "%s: latch open on slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -ENODEV; return -ENODEV;
} }
...@@ -601,8 +613,8 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -601,8 +613,8 @@ int pciehp_disable_slot(struct slot *p_slot)
if (POWER_CTRL(p_slot->ctrl)) { if (POWER_CTRL(p_slot->ctrl)) {
ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (ret || !getstatus) { if (ret || !getstatus) {
info("%s: already disabled slot(%s)\n", __func__, ctrl_info(ctrl, "%s: already disabled slot(%s)\n",
p_slot->name); __func__, p_slot->name);
mutex_unlock(&p_slot->ctrl->crit_sect); mutex_unlock(&p_slot->ctrl->crit_sect);
return -EINVAL; return -EINVAL;
} }
...@@ -618,6 +630,7 @@ int pciehp_disable_slot(struct slot *p_slot) ...@@ -618,6 +630,7 @@ int pciehp_disable_slot(struct slot *p_slot)
int pciehp_sysfs_enable_slot(struct slot *p_slot) int pciehp_sysfs_enable_slot(struct slot *p_slot)
{ {
int retval = -ENODEV; int retval = -ENODEV;
struct controller *ctrl = p_slot->ctrl;
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
switch (p_slot->state) { switch (p_slot->state) {
...@@ -631,15 +644,15 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) ...@@ -631,15 +644,15 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
break; break;
case POWERON_STATE: case POWERON_STATE:
info("Slot %s is already in powering on state\n", ctrl_info(ctrl, "Slot %s is already in powering on state\n",
p_slot->name); p_slot->name);
break; break;
case BLINKINGOFF_STATE: case BLINKINGOFF_STATE:
case POWEROFF_STATE: case POWEROFF_STATE:
info("Already enabled on slot %s\n", p_slot->name); ctrl_info(ctrl, "Already enabled on slot %s\n", p_slot->name);
break; break;
default: default:
err("Not a valid state on slot %s\n", p_slot->name); ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name);
break; break;
} }
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
...@@ -650,6 +663,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) ...@@ -650,6 +663,7 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
int pciehp_sysfs_disable_slot(struct slot *p_slot) int pciehp_sysfs_disable_slot(struct slot *p_slot)
{ {
int retval = -ENODEV; int retval = -ENODEV;
struct controller *ctrl = p_slot->ctrl;
mutex_lock(&p_slot->lock); mutex_lock(&p_slot->lock);
switch (p_slot->state) { switch (p_slot->state) {
...@@ -663,15 +677,15 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot) ...@@ -663,15 +677,15 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
p_slot->state = STATIC_STATE; p_slot->state = STATIC_STATE;
break; break;
case POWEROFF_STATE: case POWEROFF_STATE:
info("Slot %s is already in powering off state\n", ctrl_info(ctrl, "Slot %s is already in powering off state\n",
p_slot->name); p_slot->name);
break; break;
case BLINKINGON_STATE: case BLINKINGON_STATE:
case POWERON_STATE: case POWERON_STATE:
info("Already disabled on slot %s\n", p_slot->name); ctrl_info(ctrl, "Already disabled on slot %s\n", p_slot->name);
break; break;
default: default:
err("Not a valid state on slot %s\n", p_slot->name); ctrl_err(ctrl, "Not a valid state on slot %s\n", p_slot->name);
break; break;
} }
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
......
...@@ -235,7 +235,8 @@ static inline int pciehp_request_irq(struct controller *ctrl) ...@@ -235,7 +235,8 @@ static inline int pciehp_request_irq(struct controller *ctrl)
/* Installs the interrupt handler */ /* Installs the interrupt handler */
retval = request_irq(irq, pcie_isr, IRQF_SHARED, MY_NAME, ctrl); retval = request_irq(irq, pcie_isr, IRQF_SHARED, MY_NAME, ctrl);
if (retval) if (retval)
err("Cannot get irq %d for the hotplug controller\n", irq); ctrl_err(ctrl, "Cannot get irq %d for the hotplug controller\n",
irq);
return retval; return retval;
} }
...@@ -282,7 +283,7 @@ static void pcie_wait_cmd(struct controller *ctrl, int poll) ...@@ -282,7 +283,7 @@ static void pcie_wait_cmd(struct controller *ctrl, int poll)
else else
rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout); rc = wait_event_timeout(ctrl->queue, !ctrl->cmd_busy, timeout);
if (!rc) if (!rc)
dbg("Command not completed in 1000 msec\n"); ctrl_dbg(ctrl, "Command not completed in 1000 msec\n");
} }
/** /**
...@@ -301,7 +302,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ...@@ -301,7 +302,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s: Cannot read SLOTSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
__func__);
goto out; goto out;
} }
...@@ -312,26 +314,28 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ...@@ -312,26 +314,28 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
* proceed forward to issue the next command according * proceed forward to issue the next command according
* to spec. Just print out the error message. * to spec. Just print out the error message.
*/ */
dbg("%s: CMD_COMPLETED not clear after 1 sec.\n", ctrl_dbg(ctrl,
__func__); "%s: CMD_COMPLETED not clear after 1 sec.\n",
__func__);
} else if (!NO_CMD_CMPL(ctrl)) { } else if (!NO_CMD_CMPL(ctrl)) {
/* /*
* This controller semms to notify of command completed * This controller semms to notify of command completed
* event even though it supports none of power * event even though it supports none of power
* controller, attention led, power led and EMI. * controller, attention led, power led and EMI.
*/ */
dbg("%s: Unexpected CMD_COMPLETED. Need to wait for " ctrl_dbg(ctrl, "%s: Unexpected CMD_COMPLETED. Need to "
"command completed event.\n", __func__); "wait for command completed event.\n",
__func__);
ctrl->no_cmd_complete = 0; ctrl->no_cmd_complete = 0;
} else { } else {
dbg("%s: Unexpected CMD_COMPLETED. Maybe the " ctrl_dbg(ctrl, "%s: Unexpected CMD_COMPLETED. Maybe "
"controller is broken.\n", __func__); "the controller is broken.\n", __func__);
} }
} }
retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
if (retval) { if (retval) {
err("%s: Cannot read SLOTCTRL register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
goto out; goto out;
} }
...@@ -341,7 +345,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) ...@@ -341,7 +345,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
smp_mb(); smp_mb();
retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl);
if (retval) if (retval)
err("%s: Cannot write to SLOTCTRL register\n", __func__); ctrl_err(ctrl, "%s: Cannot write to SLOTCTRL register\n",
__func__);
/* /*
* Wait for command completion. * Wait for command completion.
...@@ -370,14 +375,15 @@ static int hpc_check_lnk_status(struct controller *ctrl) ...@@ -370,14 +375,15 @@ static int hpc_check_lnk_status(struct controller *ctrl)
retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
if (retval) { if (retval) {
err("%s: Cannot read LNKSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
__func__);
return retval; return retval;
} }
dbg("%s: lnk_status = %x\n", __func__, lnk_status); ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) || if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) ||
!(lnk_status & NEG_LINK_WD)) { !(lnk_status & NEG_LINK_WD)) {
err("%s : Link Training Error occurs \n", __func__); ctrl_err(ctrl, "%s : Link Training Error occurs \n", __func__);
retval = -1; retval = -1;
return retval; return retval;
} }
...@@ -394,12 +400,12 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status) ...@@ -394,12 +400,12 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
if (retval) { if (retval) {
err("%s: Cannot read SLOTCTRL register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
return retval; return retval;
} }
dbg("%s: SLOTCTRL %x, value read %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6;
...@@ -433,11 +439,11 @@ static int hpc_get_power_status(struct slot *slot, u8 *status) ...@@ -433,11 +439,11 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl);
if (retval) { if (retval) {
err("%s: Cannot read SLOTCTRL register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
return retval; return retval;
} }
dbg("%s: SLOTCTRL %x value read %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl);
pwr_state = (slot_ctrl & PWR_CTRL) >> 10; pwr_state = (slot_ctrl & PWR_CTRL) >> 10;
...@@ -464,7 +470,8 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status) ...@@ -464,7 +470,8 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s: Cannot read SLOTSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
__func__);
return retval; return retval;
} }
...@@ -482,7 +489,8 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status) ...@@ -482,7 +489,8 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s: Cannot read SLOTSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
__func__);
return retval; return retval;
} }
card_state = (u8)((slot_status & PRSN_STATE) >> 6); card_state = (u8)((slot_status & PRSN_STATE) >> 6);
...@@ -500,7 +508,7 @@ static int hpc_query_power_fault(struct slot *slot) ...@@ -500,7 +508,7 @@ static int hpc_query_power_fault(struct slot *slot)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s: Cannot check for power fault\n", __func__); ctrl_err(ctrl, "%s: Cannot check for power fault\n", __func__);
return retval; return retval;
} }
pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1);
...@@ -516,7 +524,7 @@ static int hpc_get_emi_status(struct slot *slot, u8 *status) ...@@ -516,7 +524,7 @@ static int hpc_get_emi_status(struct slot *slot, u8 *status)
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s : Cannot check EMI status\n", __func__); ctrl_err(ctrl, "%s : Cannot check EMI status\n", __func__);
return retval; return retval;
} }
*status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT;
...@@ -560,8 +568,8 @@ static int hpc_set_attention_status(struct slot *slot, u8 value) ...@@ -560,8 +568,8 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
return -1; return -1;
} }
rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
return rc; return rc;
} }
...@@ -575,8 +583,8 @@ static void hpc_set_green_led_on(struct slot *slot) ...@@ -575,8 +583,8 @@ static void hpc_set_green_led_on(struct slot *slot)
slot_cmd = 0x0100; slot_cmd = 0x0100;
cmd_mask = PWR_LED_CTRL; cmd_mask = PWR_LED_CTRL;
pcie_write_cmd(ctrl, slot_cmd, cmd_mask); pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
} }
static void hpc_set_green_led_off(struct slot *slot) static void hpc_set_green_led_off(struct slot *slot)
...@@ -588,8 +596,8 @@ static void hpc_set_green_led_off(struct slot *slot) ...@@ -588,8 +596,8 @@ static void hpc_set_green_led_off(struct slot *slot)
slot_cmd = 0x0300; slot_cmd = 0x0300;
cmd_mask = PWR_LED_CTRL; cmd_mask = PWR_LED_CTRL;
pcie_write_cmd(ctrl, slot_cmd, cmd_mask); pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
} }
static void hpc_set_green_led_blink(struct slot *slot) static void hpc_set_green_led_blink(struct slot *slot)
...@@ -601,8 +609,8 @@ static void hpc_set_green_led_blink(struct slot *slot) ...@@ -601,8 +609,8 @@ static void hpc_set_green_led_blink(struct slot *slot)
slot_cmd = 0x0200; slot_cmd = 0x0200;
cmd_mask = PWR_LED_CTRL; cmd_mask = PWR_LED_CTRL;
pcie_write_cmd(ctrl, slot_cmd, cmd_mask); pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
} }
static int hpc_power_on_slot(struct slot * slot) static int hpc_power_on_slot(struct slot * slot)
...@@ -613,20 +621,22 @@ static int hpc_power_on_slot(struct slot * slot) ...@@ -613,20 +621,22 @@ static int hpc_power_on_slot(struct slot * slot)
u16 slot_status; u16 slot_status;
int retval = 0; int retval = 0;
dbg("%s: slot->hp_slot %x\n", __func__, slot->hp_slot); ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
/* Clear sticky power-fault bit from previous power failures */ /* Clear sticky power-fault bit from previous power failures */
retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status);
if (retval) { if (retval) {
err("%s: Cannot read SLOTSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
__func__);
return retval; return retval;
} }
slot_status &= PWR_FAULT_DETECTED; slot_status &= PWR_FAULT_DETECTED;
if (slot_status) { if (slot_status) {
retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status); retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status);
if (retval) { if (retval) {
err("%s: Cannot write to SLOTSTATUS register\n", ctrl_err(ctrl,
__func__); "%s: Cannot write to SLOTSTATUS register\n",
__func__);
return retval; return retval;
} }
} }
...@@ -644,11 +654,12 @@ static int hpc_power_on_slot(struct slot * slot) ...@@ -644,11 +654,12 @@ static int hpc_power_on_slot(struct slot * slot)
retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
if (retval) { if (retval) {
err("%s: Write %x command failed!\n", __func__, slot_cmd); ctrl_err(ctrl, "%s: Write %x command failed!\n",
__func__, slot_cmd);
return -1; return -1;
} }
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
return retval; return retval;
} }
...@@ -694,7 +705,7 @@ static int hpc_power_off_slot(struct slot * slot) ...@@ -694,7 +705,7 @@ static int hpc_power_off_slot(struct slot * slot)
int retval = 0; int retval = 0;
int changed; int changed;
dbg("%s: slot->hp_slot %x\n", __func__, slot->hp_slot); ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
/* /*
* Set Bad DLLP Mask bit in Correctable Error Mask * Set Bad DLLP Mask bit in Correctable Error Mask
...@@ -722,12 +733,12 @@ static int hpc_power_off_slot(struct slot * slot) ...@@ -722,12 +733,12 @@ static int hpc_power_off_slot(struct slot * slot)
retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
if (retval) { if (retval) {
err("%s: Write command failed!\n", __func__); ctrl_err(ctrl, "%s: Write command failed!\n", __func__);
retval = -1; retval = -1;
goto out; goto out;
} }
dbg("%s: SLOTCTRL %x write cmd %x\n", ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
__func__, ctrl->cap_base + SLOTCTRL, slot_cmd); __func__, ctrl->cap_base + SLOTCTRL, slot_cmd);
out: out:
if (changed) if (changed)
pcie_unmask_bad_dllp(ctrl); pcie_unmask_bad_dllp(ctrl);
...@@ -749,7 +760,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) ...@@ -749,7 +760,8 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
intr_loc = 0; intr_loc = 0;
do { do {
if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) {
err("%s: Cannot read SLOTSTATUS\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n",
__func__);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -760,12 +772,13 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) ...@@ -760,12 +772,13 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
if (!intr_loc) if (!intr_loc)
return IRQ_NONE; return IRQ_NONE;
if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) {
err("%s: Cannot write to SLOTSTATUS\n", __func__); ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n",
__func__);
return IRQ_NONE; return IRQ_NONE;
} }
} while (detected); } while (detected);
dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc);
/* Check Command Complete Interrupt Pending */ /* Check Command Complete Interrupt Pending */
if (intr_loc & CMD_COMPLETED) { if (intr_loc & CMD_COMPLETED) {
...@@ -807,7 +820,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -807,7 +820,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap);
if (retval) { if (retval) {
err("%s: Cannot read LNKCAP register\n", __func__); ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
return retval; return retval;
} }
...@@ -821,7 +834,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -821,7 +834,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
} }
*value = lnk_speed; *value = lnk_speed;
dbg("Max link speed = %d\n", lnk_speed); ctrl_dbg(ctrl, "Max link speed = %d\n", lnk_speed);
return retval; return retval;
} }
...@@ -836,7 +849,7 @@ static int hpc_get_max_lnk_width(struct slot *slot, ...@@ -836,7 +849,7 @@ static int hpc_get_max_lnk_width(struct slot *slot,
retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap);
if (retval) { if (retval) {
err("%s: Cannot read LNKCAP register\n", __func__); ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
return retval; return retval;
} }
...@@ -871,7 +884,7 @@ static int hpc_get_max_lnk_width(struct slot *slot, ...@@ -871,7 +884,7 @@ static int hpc_get_max_lnk_width(struct slot *slot,
} }
*value = lnk_wdth; *value = lnk_wdth;
dbg("Max link width = %d\n", lnk_wdth); ctrl_dbg(ctrl, "Max link width = %d\n", lnk_wdth);
return retval; return retval;
} }
...@@ -885,7 +898,8 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -885,7 +898,8 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
if (retval) { if (retval) {
err("%s: Cannot read LNKSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
__func__);
return retval; return retval;
} }
...@@ -899,7 +913,7 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) ...@@ -899,7 +913,7 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
} }
*value = lnk_speed; *value = lnk_speed;
dbg("Current link speed = %d\n", lnk_speed); ctrl_dbg(ctrl, "Current link speed = %d\n", lnk_speed);
return retval; return retval;
} }
...@@ -914,7 +928,8 @@ static int hpc_get_cur_lnk_width(struct slot *slot, ...@@ -914,7 +928,8 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status);
if (retval) { if (retval) {
err("%s: Cannot read LNKSTATUS register\n", __func__); ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
__func__);
return retval; return retval;
} }
...@@ -949,7 +964,7 @@ static int hpc_get_cur_lnk_width(struct slot *slot, ...@@ -949,7 +964,7 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
} }
*value = lnk_wdth; *value = lnk_wdth;
dbg("Current link width = %d\n", lnk_wdth); ctrl_dbg(ctrl, "Current link width = %d\n", lnk_wdth);
return retval; return retval;
} }
...@@ -998,7 +1013,8 @@ int pcie_enable_notification(struct controller *ctrl) ...@@ -998,7 +1013,8 @@ int pcie_enable_notification(struct controller *ctrl)
PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE;
if (pcie_write_cmd(ctrl, cmd, mask)) { if (pcie_write_cmd(ctrl, cmd, mask)) {
err("%s: Cannot enable software notification\n", __func__); ctrl_err(ctrl, "%s: Cannot enable software notification\n",
__func__);
return -1; return -1;
} }
return 0; return 0;
...@@ -1010,7 +1026,8 @@ static void pcie_disable_notification(struct controller *ctrl) ...@@ -1010,7 +1026,8 @@ static void pcie_disable_notification(struct controller *ctrl)
mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE |
PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE;
if (pcie_write_cmd(ctrl, 0, mask)) if (pcie_write_cmd(ctrl, 0, mask))
warn("%s: Cannot disable software notification\n", __func__); ctrl_warn(ctrl, "%s: Cannot disable software notification\n",
__func__);
} }
static int pcie_init_notification(struct controller *ctrl) static int pcie_init_notification(struct controller *ctrl)
...@@ -1071,34 +1088,45 @@ static inline void dbg_ctrl(struct controller *ctrl) ...@@ -1071,34 +1088,45 @@ static inline void dbg_ctrl(struct controller *ctrl)
if (!pciehp_debug) if (!pciehp_debug)
return; return;
dbg("Hotplug Controller:\n"); ctrl_info(ctrl, "Hotplug Controller:\n");
dbg(" Seg/Bus/Dev/Func/IRQ : %s IRQ %d\n", pci_name(pdev), pdev->irq); ctrl_info(ctrl, " Seg/Bus/Dev/Func/IRQ : %s IRQ %d\n",
dbg(" Vendor ID : 0x%04x\n", pdev->vendor); pci_name(pdev), pdev->irq);
dbg(" Device ID : 0x%04x\n", pdev->device); ctrl_info(ctrl, " Vendor ID : 0x%04x\n", pdev->vendor);
dbg(" Subsystem ID : 0x%04x\n", pdev->subsystem_device); ctrl_info(ctrl, " Device ID : 0x%04x\n", pdev->device);
dbg(" Subsystem Vendor ID : 0x%04x\n", pdev->subsystem_vendor); ctrl_info(ctrl, " Subsystem ID : 0x%04x\n",
dbg(" PCIe Cap offset : 0x%02x\n", ctrl->cap_base); pdev->subsystem_device);
ctrl_info(ctrl, " Subsystem Vendor ID : 0x%04x\n",
pdev->subsystem_vendor);
ctrl_info(ctrl, " PCIe Cap offset : 0x%02x\n", ctrl->cap_base);
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
if (!pci_resource_len(pdev, i)) if (!pci_resource_len(pdev, i))
continue; continue;
dbg(" PCI resource [%d] : 0x%llx@0x%llx\n", i, ctrl_info(ctrl, " PCI resource [%d] : 0x%llx@0x%llx\n",
(unsigned long long)pci_resource_len(pdev, i), i, (unsigned long long)pci_resource_len(pdev, i),
(unsigned long long)pci_resource_start(pdev, i)); (unsigned long long)pci_resource_start(pdev, i));
} }
dbg("Slot Capabilities : 0x%08x\n", ctrl->slot_cap); ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
dbg(" Physical Slot Number : %d\n", ctrl->first_slot); ctrl_info(ctrl, " Physical Slot Number : %d\n", ctrl->first_slot);
dbg(" Attention Button : %3s\n", ATTN_BUTTN(ctrl) ? "yes" : "no"); ctrl_info(ctrl, " Attention Button : %3s\n",
dbg(" Power Controller : %3s\n", POWER_CTRL(ctrl) ? "yes" : "no"); ATTN_BUTTN(ctrl) ? "yes" : "no");
dbg(" MRL Sensor : %3s\n", MRL_SENS(ctrl) ? "yes" : "no"); ctrl_info(ctrl, " Power Controller : %3s\n",
dbg(" Attention Indicator : %3s\n", ATTN_LED(ctrl) ? "yes" : "no"); POWER_CTRL(ctrl) ? "yes" : "no");
dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); ctrl_info(ctrl, " MRL Sensor : %3s\n",
dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); MRL_SENS(ctrl) ? "yes" : "no");
dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); ctrl_info(ctrl, " Attention Indicator : %3s\n",
dbg(" Command Completed : %3s\n", NO_CMD_CMPL(ctrl)? "no" : "yes"); ATTN_LED(ctrl) ? "yes" : "no");
ctrl_info(ctrl, " Power Indicator : %3s\n",
PWR_LED(ctrl) ? "yes" : "no");
ctrl_info(ctrl, " Hot-Plug Surprise : %3s\n",
HP_SUPR_RM(ctrl) ? "yes" : "no");
ctrl_info(ctrl, " EMI Present : %3s\n",
EMI(ctrl) ? "yes" : "no");
ctrl_info(ctrl, " Command Completed : %3s\n",
NO_CMD_CMPL(ctrl) ? "no" : "yes");
pciehp_readw(ctrl, SLOTSTATUS, &reg16); pciehp_readw(ctrl, SLOTSTATUS, &reg16);
dbg("Slot Status : 0x%04x\n", reg16); ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16);
pciehp_readw(ctrl, SLOTCTRL, &reg16); pciehp_readw(ctrl, SLOTCTRL, &reg16);
dbg("Slot Control : 0x%04x\n", reg16); ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16);
} }
struct controller *pcie_init(struct pcie_device *dev) struct controller *pcie_init(struct pcie_device *dev)
...@@ -1109,7 +1137,7 @@ struct controller *pcie_init(struct pcie_device *dev) ...@@ -1109,7 +1137,7 @@ struct controller *pcie_init(struct pcie_device *dev)
ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) { if (!ctrl) {
err("%s : out of memory\n", __func__); dev_err(&dev->device, "%s : out of memory\n", __func__);
goto abort; goto abort;
} }
INIT_LIST_HEAD(&ctrl->slot_list); INIT_LIST_HEAD(&ctrl->slot_list);
...@@ -1118,11 +1146,12 @@ struct controller *pcie_init(struct pcie_device *dev) ...@@ -1118,11 +1146,12 @@ struct controller *pcie_init(struct pcie_device *dev)
ctrl->pci_dev = pdev; ctrl->pci_dev = pdev;
ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP);
if (!ctrl->cap_base) { if (!ctrl->cap_base) {
err("%s: Cannot find PCI Express capability\n", __func__); ctrl_err(ctrl, "%s: Cannot find PCI Express capability\n",
__func__);
goto abort; goto abort;
} }
if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) {
err("%s: Cannot read SLOTCAP register\n", __func__); ctrl_err(ctrl, "%s: Cannot read SLOTCAP register\n", __func__);
goto abort; goto abort;
} }
...@@ -1162,9 +1191,9 @@ struct controller *pcie_init(struct pcie_device *dev) ...@@ -1162,9 +1191,9 @@ struct controller *pcie_init(struct pcie_device *dev)
goto abort_ctrl; goto abort_ctrl;
} }
info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n",
pdev->vendor, pdev->device, pdev->vendor, pdev->device, pdev->subsystem_vendor,
pdev->subsystem_vendor, pdev->subsystem_device); pdev->subsystem_device);
if (pcie_init_slot(ctrl)) if (pcie_init_slot(ctrl))
goto abort_ctrl; goto abort_ctrl;
......
...@@ -198,18 +198,20 @@ int pciehp_configure_device(struct slot *p_slot) ...@@ -198,18 +198,20 @@ int pciehp_configure_device(struct slot *p_slot)
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
int num, fn; int num, fn;
struct controller *ctrl = p_slot->ctrl;
dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
if (dev) { if (dev) {
err("Device %s already exists at %x:%x, cannot hot-add\n", ctrl_err(ctrl,
pci_name(dev), p_slot->bus, p_slot->device); "Device %s already exists at %x:%x, cannot hot-add\n",
pci_name(dev), p_slot->bus, p_slot->device);
pci_dev_put(dev); pci_dev_put(dev);
return -EINVAL; return -EINVAL;
} }
num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
if (num == 0) { if (num == 0) {
err("No new device found\n"); ctrl_err(ctrl, "No new device found\n");
return -ENODEV; return -ENODEV;
} }
...@@ -218,8 +220,8 @@ int pciehp_configure_device(struct slot *p_slot) ...@@ -218,8 +220,8 @@ int pciehp_configure_device(struct slot *p_slot)
if (!dev) if (!dev)
continue; continue;
if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
err("Cannot hot-add display device %s\n", ctrl_err(ctrl, "Cannot hot-add display device %s\n",
pci_name(dev)); pci_name(dev));
pci_dev_put(dev); pci_dev_put(dev);
continue; continue;
} }
...@@ -244,9 +246,10 @@ int pciehp_unconfigure_device(struct slot *p_slot) ...@@ -244,9 +246,10 @@ int pciehp_unconfigure_device(struct slot *p_slot)
u8 presence = 0; u8 presence = 0;
struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
u16 command; u16 command;
struct controller *ctrl = p_slot->ctrl;
dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus, ctrl_dbg(ctrl, "%s: bus/dev = %x/%x\n", __func__,
p_slot->device); p_slot->bus, p_slot->device);
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence);
if (ret) if (ret)
presence = 0; presence = 0;
...@@ -257,16 +260,17 @@ int pciehp_unconfigure_device(struct slot *p_slot) ...@@ -257,16 +260,17 @@ int pciehp_unconfigure_device(struct slot *p_slot)
if (!temp) if (!temp)
continue; continue;
if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
err("Cannot remove display device %s\n", ctrl_err(ctrl, "Cannot remove display device %s\n",
pci_name(temp)); pci_name(temp));
pci_dev_put(temp); pci_dev_put(temp);
continue; continue;
} }
if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) { if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl); pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
if (bctl & PCI_BRIDGE_CTL_VGA) { if (bctl & PCI_BRIDGE_CTL_VGA) {
err("Cannot remove display device %s\n", ctrl_err(ctrl,
pci_name(temp)); "Cannot remove display device %s\n",
pci_name(temp));
pci_dev_put(temp); pci_dev_put(temp);
continue; continue;
} }
......
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