MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
-module_param(debug, int, 0644);
+module_param(debug, bool, 0644);
static int enable_slot(struct hotplug_slot *slot);
static int disable_slot(struct hotplug_slot *slot);
static int get_attention_status(struct hotplug_slot *slot, u8 * value);
static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value);
-static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value);
struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
.owner = THIS_MODULE,
.get_attention_status = get_attention_status,
.get_adapter_status = get_adapter_status,
.get_max_bus_speed = get_max_bus_speed,
- .get_cur_bus_speed = get_cur_bus_speed,
};
-static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const char *function)
-{
- if (!hotplug_slot) {
- dbg("%s - hotplug_slot == NULL\n", function);
- return NULL;
- }
- return (struct slot *)hotplug_slot->private;
-}
-
static int rpaphp_get_attention_status(struct slot *slot)
{
return slot->hotplug_slot->info->attention_status;
*/
static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
{
- int retval = 0;
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ int retval;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
down(&rpaphp_sem);
switch (value) {
static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
{
int retval;
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
down(&rpaphp_sem);
retval = rpaphp_get_power_status(slot, value);
static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
{
int retval = 0;
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
down(&rpaphp_sem);
*value = rpaphp_get_attention_status(slot);
static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
{
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+ struct slot *slot = (struct slot *)hotplug_slot->private;
int retval = 0;
- if (slot == NULL)
- return -ENODEV;
down(&rpaphp_sem);
/* have to go through this */
switch (slot->dev_type) {
static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
{
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
down(&rpaphp_sem);
switch (slot->type) {
return 0;
}
-/* return dummy value because not sure if PRA provides any method... */
-static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
-{
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
-
- *value = PCI_SPEED_UNKNOWN;
- return 0;
-}
-
int rpaphp_remove_slot(struct slot *slot)
{
int retval = 0;
{
*indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL);
if (!*indexes)
- return (0);
+ return 0;
/* &names[1] contains NULL terminated slot names */
*names = (int *) get_property(dn, "ibm,drc-names", NULL);
if (!*names)
- return (0);
+ return 0;
/* &types[1] contains NULL terminated slot types */
*types = (int *) get_property(dn, "ibm,drc-types", NULL);
if (!*types)
- return (0);
+ return 0;
/* power_domains[1...n] are the slot power domains */
*power_domains = (int *) get_property(dn,
"ibm,drc-power-domains", NULL);
if (!*power_domains)
- return (0);
+ return 0;
if (strcmp(dn->name, "pci") == 0 &&
- !get_property(dn, "ibm,fw-pci-hot-plug-ctrl", NULL))
- return (0);
- return (1);
+ !get_property(dn, "ibm,fw-pci-hot-plug-ctrl", NULL))
+ return 0;
+ return 1;
}
static inline int is_vdevice_root(struct device_node *dn)
return !strcmp(dn->name, "vdevice");
}
-/*************************************
- * Add Hot Plug slot(s) to sysfs
+/**
+ * rpaphp_add_slot: Add Hot Plug slot(s) to sysfs
*
- ************************************/
+ */
int rpaphp_add_slot(struct device_node *dn)
{
struct slot *slot;
name = (char *) &names[1];
type = (char *) &types[1];
for (i = 0; i < indexes[0];
- i++,
- name += (strlen(name) + 1), type += (strlen(type) + 1)) {
+ i++,
+ name += (strlen(name) + 1),
+ type += (strlen(type) + 1)) {
if (!(slot = alloc_slot_struct(dn, indexes[i + 1], name,
power_domains[i + 1]))) {
retval = -ENOMEM;
} /* for indexes */
} /* end of PCI device_node */
- exit:
+exit:
dbg("%s - Exit: num_slots=%d rc[%d]\n",
__FUNCTION__, num_slots, retval);
return retval;
}
-/*
- * init_slots - initialize 'struct slot' structures for each slot
- *
- */
-static void init_slots(void)
+static int __init init_rpa(void)
{
struct device_node *dn;
- for (dn = find_all_nodes(); dn; dn = dn->next)
- rpaphp_add_slot(dn);
-}
-
-static int init_rpa(void)
-{
-
init_MUTEX(&rpaphp_sem);
/* initialize internal data structure etc. */
- init_slots();
+ for (dn = find_all_nodes(); dn; dn = dn->next)
+ rpaphp_add_slot(dn);
if (!num_slots)
return -ENODEV;
return 0;
}
-static void cleanup_slots(void)
+static void __exit cleanup_slots(void)
{
struct list_head *tmp, *n;
struct slot *slot;
static int enable_slot(struct hotplug_slot *hotplug_slot)
{
int retval = 0;
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
if (slot->state == CONFIGURED) {
dbg("%s: %s is already enabled\n", __FUNCTION__, slot->name);
static int disable_slot(struct hotplug_slot *hotplug_slot)
{
int retval;
- struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
-
- if (slot == NULL)
- return -ENODEV;
+ struct slot *slot = (struct slot *)hotplug_slot->private;
dbg("%s - Entry: slot[%s]\n", __FUNCTION__, slot->name);