PCI: cpci_hotplug: stop managing hotplug_slot->name

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: kristen.c.accardi@intel.com
Cc: scottm@somanetworks.com
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
Alex Chiang 2008-10-20 17:41:17 -06:00 committed by Jesse Barnes
parent df77cd1007
commit d6c479e0b7
3 changed files with 37 additions and 49 deletions

View File

@ -30,6 +30,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci_hotplug.h>
/* PICMG 2.1 R2.0 HS CSR bits: */ /* PICMG 2.1 R2.0 HS CSR bits: */
#define HS_CSR_INS 0x0080 #define HS_CSR_INS 0x0080
@ -69,6 +70,11 @@ struct cpci_hp_controller {
struct cpci_hp_controller_ops *ops; struct cpci_hp_controller_ops *ops;
}; };
static inline const char *slot_name(struct slot *slot)
{
return hotplug_slot_name(slot->hotplug_slot);
}
extern int cpci_hp_register_controller(struct cpci_hp_controller *controller); extern int cpci_hp_register_controller(struct cpci_hp_controller *controller);
extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller); extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last); extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);

View File

@ -108,7 +108,7 @@ enable_slot(struct hotplug_slot *hotplug_slot)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval = 0; int retval = 0;
dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); dbg("%s - physical_slot = %s", __func__, slot_name(slot));
if (controller->ops->set_power) if (controller->ops->set_power)
retval = controller->ops->set_power(slot, 1); retval = controller->ops->set_power(slot, 1);
@ -121,25 +121,23 @@ disable_slot(struct hotplug_slot *hotplug_slot)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
int retval = 0; int retval = 0;
dbg("%s - physical_slot = %s", __func__, hotplug_slot->name); dbg("%s - physical_slot = %s", __func__, slot_name(slot));
down_write(&list_rwsem); down_write(&list_rwsem);
/* Unconfigure device */ /* Unconfigure device */
dbg("%s - unconfiguring slot %s", dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
__func__, slot->hotplug_slot->name);
if ((retval = cpci_unconfigure_slot(slot))) { if ((retval = cpci_unconfigure_slot(slot))) {
err("%s - could not unconfigure slot %s", err("%s - could not unconfigure slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
goto disable_error; goto disable_error;
} }
dbg("%s - finished unconfiguring slot %s", dbg("%s - finished unconfiguring slot %s", __func__, slot_name(slot));
__func__, slot->hotplug_slot->name);
/* Clear EXT (by setting it) */ /* Clear EXT (by setting it) */
if (cpci_clear_ext(slot)) { if (cpci_clear_ext(slot)) {
err("%s - could not clear EXT for slot %s", err("%s - could not clear EXT for slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
retval = -ENODEV; retval = -ENODEV;
goto disable_error; goto disable_error;
} }
@ -214,7 +212,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
struct slot *slot = hotplug_slot->private; struct slot *slot = hotplug_slot->private;
kfree(slot->hotplug_slot->info); kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot); kfree(slot->hotplug_slot);
if (slot->dev) if (slot->dev)
pci_dev_put(slot->dev); pci_dev_put(slot->dev);
@ -222,12 +219,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
} }
#define SLOT_NAME_SIZE 6 #define SLOT_NAME_SIZE 6
static void
make_slot_name(struct slot *slot)
{
snprintf(slot->hotplug_slot->name,
SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
}
int int
cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
@ -235,7 +226,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
struct slot *slot; struct slot *slot;
struct hotplug_slot *hotplug_slot; struct hotplug_slot *hotplug_slot;
struct hotplug_slot_info *info; struct hotplug_slot_info *info;
char *name; char name[SLOT_NAME_SIZE];
int status = -ENOMEM; int status = -ENOMEM;
int i; int i;
@ -262,35 +253,31 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
goto error_hpslot; goto error_hpslot;
hotplug_slot->info = info; hotplug_slot->info = info;
name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!name)
goto error_info;
hotplug_slot->name = name;
slot->bus = bus; slot->bus = bus;
slot->number = i; slot->number = i;
slot->devfn = PCI_DEVFN(i, 0); slot->devfn = PCI_DEVFN(i, 0);
snprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
hotplug_slot->private = slot; hotplug_slot->private = slot;
hotplug_slot->release = &release_slot; hotplug_slot->release = &release_slot;
make_slot_name(slot);
hotplug_slot->ops = &cpci_hotplug_slot_ops; hotplug_slot->ops = &cpci_hotplug_slot_ops;
/* /*
* Initialize the slot info structure with some known * Initialize the slot info structure with some known
* good values. * good values.
*/ */
dbg("initializing slot %s", slot->hotplug_slot->name); dbg("initializing slot %s", name);
info->power_status = cpci_get_power_status(slot); info->power_status = cpci_get_power_status(slot);
info->attention_status = cpci_get_attention_status(slot); info->attention_status = cpci_get_attention_status(slot);
dbg("registering slot %s", slot->hotplug_slot->name); dbg("registering slot %s", name);
status = pci_hp_register(slot->hotplug_slot, bus, i, status = pci_hp_register(slot->hotplug_slot, bus, i, name);
slot->hotplug_slot->name);
if (status) { if (status) {
err("pci_hp_register failed with error %d", status); err("pci_hp_register failed with error %d", status);
goto error_name; goto error_info;
} }
dbg("slot registered with name: %s", slot_name(slot));
/* Add slot to our internal list */ /* Add slot to our internal list */
down_write(&list_rwsem); down_write(&list_rwsem);
@ -299,8 +286,6 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
up_write(&list_rwsem); up_write(&list_rwsem);
} }
return 0; return 0;
error_name:
kfree(name);
error_info: error_info:
kfree(info); kfree(info);
error_hpslot: error_hpslot:
@ -328,7 +313,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
list_del(&slot->slot_list); list_del(&slot->slot_list);
slots--; slots--;
dbg("deregistering slot %s", slot->hotplug_slot->name); dbg("deregistering slot %s", slot_name(slot));
status = pci_hp_deregister(slot->hotplug_slot); status = pci_hp_deregister(slot->hotplug_slot);
if (status) { if (status) {
err("pci_hp_deregister failed with error %d", err("pci_hp_deregister failed with error %d",
@ -380,11 +365,10 @@ init_slots(int clear_ins)
return -1; return -1;
} }
list_for_each_entry(slot, &slot_list, slot_list) { list_for_each_entry(slot, &slot_list, slot_list) {
dbg("%s - looking at slot %s", dbg("%s - looking at slot %s", __func__, slot_name(slot));
__func__, slot->hotplug_slot->name);
if (clear_ins && cpci_check_and_clear_ins(slot)) if (clear_ins && cpci_check_and_clear_ins(slot))
dbg("%s - cleared INS for slot %s", dbg("%s - cleared INS for slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0)); dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
if (dev) { if (dev) {
if (update_adapter_status(slot->hotplug_slot, 1)) if (update_adapter_status(slot->hotplug_slot, 1))
@ -415,8 +399,7 @@ check_slots(void)
} }
extracted = inserted = 0; extracted = inserted = 0;
list_for_each_entry(slot, &slot_list, slot_list) { list_for_each_entry(slot, &slot_list, slot_list) {
dbg("%s - looking at slot %s", dbg("%s - looking at slot %s", __func__, slot_name(slot));
__func__, slot->hotplug_slot->name);
if (cpci_check_and_clear_ins(slot)) { if (cpci_check_and_clear_ins(slot)) {
/* /*
* Some broken hardware (e.g. PLX 9054AB) asserts * Some broken hardware (e.g. PLX 9054AB) asserts
@ -424,35 +407,34 @@ check_slots(void)
*/ */
if (slot->dev) { if (slot->dev) {
warn("slot %s already inserted", warn("slot %s already inserted",
slot->hotplug_slot->name); slot_name(slot));
inserted++; inserted++;
continue; continue;
} }
/* Process insertion */ /* Process insertion */
dbg("%s - slot %s inserted", dbg("%s - slot %s inserted", __func__, slot_name(slot));
__func__, slot->hotplug_slot->name);
/* GSM, debug */ /* GSM, debug */
hs_csr = cpci_get_hs_csr(slot); hs_csr = cpci_get_hs_csr(slot);
dbg("%s - slot %s HS_CSR (1) = %04x", dbg("%s - slot %s HS_CSR (1) = %04x",
__func__, slot->hotplug_slot->name, hs_csr); __func__, slot_name(slot), hs_csr);
/* Configure device */ /* Configure device */
dbg("%s - configuring slot %s", dbg("%s - configuring slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
if (cpci_configure_slot(slot)) { if (cpci_configure_slot(slot)) {
err("%s - could not configure slot %s", err("%s - could not configure slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
continue; continue;
} }
dbg("%s - finished configuring slot %s", dbg("%s - finished configuring slot %s",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
/* GSM, debug */ /* GSM, debug */
hs_csr = cpci_get_hs_csr(slot); hs_csr = cpci_get_hs_csr(slot);
dbg("%s - slot %s HS_CSR (2) = %04x", dbg("%s - slot %s HS_CSR (2) = %04x",
__func__, slot->hotplug_slot->name, hs_csr); __func__, slot_name(slot), hs_csr);
if (update_latch_status(slot->hotplug_slot, 1)) if (update_latch_status(slot->hotplug_slot, 1))
warn("failure to update latch file"); warn("failure to update latch file");
@ -465,18 +447,18 @@ check_slots(void)
/* GSM, debug */ /* GSM, debug */
hs_csr = cpci_get_hs_csr(slot); hs_csr = cpci_get_hs_csr(slot);
dbg("%s - slot %s HS_CSR (3) = %04x", dbg("%s - slot %s HS_CSR (3) = %04x",
__func__, slot->hotplug_slot->name, hs_csr); __func__, slot_name(slot), hs_csr);
inserted++; inserted++;
} else if (cpci_check_ext(slot)) { } else if (cpci_check_ext(slot)) {
/* Process extraction request */ /* Process extraction request */
dbg("%s - slot %s extracted", dbg("%s - slot %s extracted",
__func__, slot->hotplug_slot->name); __func__, slot_name(slot));
/* GSM, debug */ /* GSM, debug */
hs_csr = cpci_get_hs_csr(slot); hs_csr = cpci_get_hs_csr(slot);
dbg("%s - slot %s HS_CSR = %04x", dbg("%s - slot %s HS_CSR = %04x",
__func__, slot->hotplug_slot->name, hs_csr); __func__, slot_name(slot), hs_csr);
if (!slot->extracting) { if (!slot->extracting) {
if (update_latch_status(slot->hotplug_slot, 0)) { if (update_latch_status(slot->hotplug_slot, 0)) {
@ -494,7 +476,7 @@ check_slots(void)
* bother trying to tell the driver or not? * bother trying to tell the driver or not?
*/ */
err("card in slot %s was improperly removed", err("card in slot %s was improperly removed",
slot->hotplug_slot->name); slot_name(slot));
if (update_adapter_status(slot->hotplug_slot, 0)) if (update_adapter_status(slot->hotplug_slot, 0))
warn("failure to update adapter file"); warn("failure to update adapter file");
slot->extracting = 0; slot->extracting = 0;

View File

@ -209,7 +209,7 @@ int cpci_led_on(struct slot* slot)
hs_cap + 2, hs_cap + 2,
hs_csr)) { hs_csr)) {
err("Could not set LOO for slot %s", err("Could not set LOO for slot %s",
slot->hotplug_slot->name); hotplug_slot_name(slot->hotplug_slot));
return -ENODEV; return -ENODEV;
} }
} }
@ -238,7 +238,7 @@ int cpci_led_off(struct slot* slot)
hs_cap + 2, hs_cap + 2,
hs_csr)) { hs_csr)) {
err("Could not clear LOO for slot %s", err("Could not clear LOO for slot %s",
slot->hotplug_slot->name); hotplug_slot_name(slot->hotplug_slot));
return -ENODEV; return -ENODEV;
} }
} }