Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -57,6 +57,19 @@ extern struct workqueue_struct *pciehp_wq;
#define warn(format, 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
struct slot {
	u8 bus;
@@ -171,7 +184,7 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
			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;
}

+46 −29
Original line number Diff line number Diff line
@@ -144,9 +144,10 @@ set_lock_exit:
 * sysfs interface which allows the user to toggle the Electro Mechanical
 * 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,
		size_t count)
static ssize_t lock_write_file(struct hotplug_slot *hotplug_slot,
		const char *buf, size_t count)
{
	struct slot *slot = hotplug_slot->private;
	unsigned long llock;
	u8 lock;
	int retval = 0;
@@ -157,10 +158,11 @@ static ssize_t lock_write_file(struct hotplug_slot *slot, const char *buf,
	switch (lock) {
		case 0:
		case 1:
			retval = set_lock_status(slot, lock);
			retval = set_lock_status(hotplug_slot, lock);
			break;
		default:
			err ("%d is an invalid lock value\n", lock);
			ctrl_err(slot->ctrl, "%d is an invalid lock value\n",
				 lock);
			retval = -EINVAL;
	}
	if (retval)
@@ -180,7 +182,10 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = {
 */
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);
@@ -215,7 +220,7 @@ static int init_slots(struct controller *ctrl)
		get_adapter_status(hotplug_slot, &info->adapter_status);
		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->hp_slot, slot->number, ctrl->slot_device_offset);
duplicate_name:
@@ -233,9 +238,11 @@ duplicate_name:
				if (len < SLOT_NAME_SIZE)
					goto duplicate_name;
				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;
		}
		/* create additional sysfs entries */
@@ -244,7 +251,8 @@ duplicate_name:
				&hotplug_slot_attr_lock.attr);
			if (retval) {
				pci_hp_deregister(hotplug_slot);
				err("cannot create additional sysfs entries\n");
				ctrl_err(ctrl, "cannot create additional sysfs "
					 "entries\n");
				goto error_info;
			}
		}
@@ -278,7 +286,8 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
{
	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;

@@ -293,7 +302,8 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
{
	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);
}
@@ -303,7 +313,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
{
	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);
}
@@ -313,7 +324,8 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
	struct slot *slot = hotplug_slot->private;
	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);
	if (retval < 0)
@@ -327,7 +339,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
	struct slot *slot = hotplug_slot->private;
	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);
	if (retval < 0)
@@ -341,7 +354,8 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
	struct slot *slot = hotplug_slot->private;
	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);
	if (retval < 0)
@@ -355,7 +369,8 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
	struct slot *slot = hotplug_slot->private;
	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);
	if (retval < 0)
@@ -370,7 +385,8 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
	struct slot *slot = hotplug_slot->private;
	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);
	if (retval < 0)
@@ -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;
	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);
	if (retval < 0)
@@ -402,14 +419,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
	struct pci_dev *pdev = dev->port;

	if (pciehp_force)
		dbg("Bypassing BIOS check for pciehp use on %s\n",
		dev_info(&dev->device,
			 "Bypassing BIOS check for pciehp use on %s\n",
			 pci_name(pdev));
	else if (pciehp_get_hp_hw_control_from_firmware(pdev))
		goto err_out_none;

	ctrl = pcie_init(dev);
	if (!ctrl) {
		dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME);
		dev_err(&dev->device, "controller initialization failed\n");
		goto err_out_none;
	}
	set_service_data(dev, ctrl);
@@ -418,11 +436,10 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
	rc = init_slots(ctrl);
	if (rc) {
		if (rc == -EBUSY)
			warn("%s: slot already registered by another "
				"hotplug driver\n", PCIE_MODULE_NAME);
			ctrl_warn(ctrl, "slot already registered by another "
				  "hotplug driver\n");
		else
			err("%s: slot initialization failed\n",
				PCIE_MODULE_NAME);
			ctrl_err(ctrl, "slot initialization failed\n");
		goto err_out_release_ctlr;
	}

@@ -461,13 +478,13 @@ static void pciehp_remove (struct pcie_device *dev)
#ifdef CONFIG_PM
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;
}

static int pciehp_resume (struct pcie_device *dev)
{
	printk("%s ENTRY\n", __func__);
	dev_info(&dev->device, "%s ENTRY\n", __func__);
	if (pciehp_force) {
		struct controller *ctrl = get_service_data(dev);
		struct slot *t_slot;
+75 −61
Original line number Diff line number Diff line
@@ -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", p_slot->name);
	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", p_slot->name);
		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", p_slot->name);
		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,13 @@ 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", p_slot->name);
		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", p_slot->name);
		event_type = INT_PRESENCE_OFF;
	}

@@ -135,23 +138,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",
			  p_slot->name);
		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", p_slot->name);
		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,7 +173,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",
			ctrl_err(ctrl,
				 "%s: Issue of Slot Power Off command failed\n",
				 __func__);
			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, "%s: Issue of Set Attention "
				 "Led command failed\n", __func__);
			return;
		}
	}
@@ -205,9 +211,9 @@ static int board_added(struct slot *p_slot)
	int retval = 0;
	struct controller *ctrl = p_slot->ctrl;

	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 */
@@ -225,22 +231,22 @@ static int board_added(struct slot *p_slot)
	/* 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, "%s: Failed to check link status\n", __func__);
		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, "%s: power fault detected\n", __func__);
		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 0x%x:%x\n",
			 p_slot->bus, p_slot->device);
		goto err_exit;
	}

@@ -272,14 +278,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, "In %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, "%s: Issue of Slot Disable command "
				 "failed\n", __func__);
			return retval;
		}
	}
@@ -320,7 +326,7 @@ 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",
		ctrl_dbg(p_slot->ctrl, "%s: disabling bus:device(%x:%x)\n",
			 __func__, p_slot->bus, p_slot->device);
		pciehp_disable_slot(p_slot);
		mutex_lock(&p_slot->lock);
@@ -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,11 +410,13 @@ 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 "
			ctrl_info(ctrl,
				  "PCI slot #%s - powering off due to button "
				  "press.\n", p_slot->name);
		} else {
			p_slot->state = BLINKINGON_STATE;
			info("PCI slot #%s - powering on due to button "
			ctrl_info(ctrl,
				  "PCI slot #%s - powering on due to button "
				  "press.\n", p_slot->name);
		}
		/* blink green LED and turn off amber */
@@ -425,8 +434,8 @@ 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", p_slot->name);
		ctrl_dbg(ctrl, "%s: button cancel\n", __func__);
		cancel_delayed_work(&p_slot->work);
		if (p_slot->state == BLINKINGOFF_STATE) {
			if (PWR_LED(ctrl))
@@ -437,8 +446,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", p_slot->name);
		p_slot->state = STATIC_STATE;
		break;
	case POWEROFF_STATE:
@@ -448,11 +457,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", p_slot->name);
		update_slot_info(p_slot);
		break;
	default:
		warn("Not a valid state\n");
		ctrl_warn(ctrl, "Not a valid state\n");
		break;
	}
}
@@ -467,7 +476,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 +515,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 +532,23 @@ 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, "%s: no adapter on slot(%s)\n",
			  __func__, p_slot->name);
		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, "%s: latch open on slot(%s)\n",
				  __func__, p_slot->name);
			mutex_unlock(&p_slot->ctrl->crit_sect);
			return -ENODEV;
		}
@@ -546,8 +557,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, "%s: already enabled on slot(%s)\n",
				  __func__, p_slot->name);
			mutex_unlock(&p_slot->ctrl->crit_sect);
			return -EINVAL;
		}
@@ -571,6 +582,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 +593,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, "%s: no adapter on slot(%s)\n",
				  __func__, p_slot->name);
			mutex_unlock(&p_slot->ctrl->crit_sect);
			return -ENODEV;
		}
@@ -591,8 +603,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, "%s: latch open on slot(%s)\n",
				  __func__, p_slot->name);
			mutex_unlock(&p_slot->ctrl->crit_sect);
			return -ENODEV;
		}
@@ -601,8 +613,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, "%s: already disabled slot(%s)\n",
				  __func__, p_slot->name);
			mutex_unlock(&p_slot->ctrl->crit_sect);
			return -EINVAL;
		}
@@ -618,6 +630,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 +644,15 @@ 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",
		ctrl_info(ctrl, "Slot %s is already in powering on state\n",
			  p_slot->name);
		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", p_slot->name);
		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", p_slot->name);
		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,15 @@ 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",
		ctrl_info(ctrl, "Slot %s is already in powering off state\n",
			  p_slot->name);
		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", p_slot->name);
		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", p_slot->name);
		break;
	}
	mutex_unlock(&p_slot->lock);
+113 −84

File changed.

Preview size limit exceeded, changes collapsed.

+15 −11
Original line number Diff line number Diff line
@@ -198,10 +198,12 @@ int pciehp_configure_device(struct slot *p_slot)
	struct pci_dev *dev;
	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
	int num, fn;
	struct controller *ctrl = p_slot->ctrl;

	dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
	if (dev) {
		err("Device %s already exists at %x:%x, cannot hot-add\n",
		ctrl_err(ctrl,
			 "Device %s already exists at %x:%x, cannot hot-add\n",
			 pci_name(dev), p_slot->bus, p_slot->device);
		pci_dev_put(dev);
		return -EINVAL;
@@ -209,7 +211,7 @@ int pciehp_configure_device(struct slot *p_slot)

	num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
	if (num == 0) {
		err("No new device found\n");
		ctrl_err(ctrl, "No new device found\n");
		return -ENODEV;
	}

@@ -218,7 +220,7 @@ int pciehp_configure_device(struct slot *p_slot)
		if (!dev)
			continue;
		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_dev_put(dev);
			continue;
@@ -244,9 +246,10 @@ int pciehp_unconfigure_device(struct slot *p_slot)
	u8 presence = 0;
	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
	u16 command;
	struct controller *ctrl = p_slot->ctrl;

	dbg("%s: bus/dev = %x/%x\n", __func__, p_slot->bus,
				p_slot->device);
	ctrl_dbg(ctrl, "%s: bus/dev = %x/%x\n", __func__,
		 p_slot->bus, p_slot->device);
	ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence);
	if (ret)
		presence = 0;
@@ -257,7 +260,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
		if (!temp)
			continue;
		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_dev_put(temp);
			continue;
@@ -265,7 +268,8 @@ int pciehp_unconfigure_device(struct slot *p_slot)
		if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
			pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
			if (bctl & PCI_BRIDGE_CTL_VGA) {
				err("Cannot remove display device %s\n",
				ctrl_err(ctrl,
					 "Cannot remove display device %s\n",
					 pci_name(temp));
				pci_dev_put(temp);
				continue;