Commit f7d6ae35 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI Hotplug: ibmphp: add release() callback and other minor cleanups

parent 3fda6c8f
......@@ -7,7 +7,7 @@
* Written By: Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -398,7 +398,6 @@ extern int ibmphp_hpc_readslot (struct slot *, u8, u8 *);
extern int ibmphp_hpc_writeslot (struct slot *, u8);
extern void ibmphp_lock_operations (void);
extern void ibmphp_unlock_operations (void);
extern int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *);
extern int ibmphp_hpc_start_poll_thread (void);
extern void ibmphp_hpc_stop_poll_thread (void);
......
......@@ -3,8 +3,8 @@
*
* Written By: Chuck Cole, Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -739,26 +739,8 @@ static void free_slots (void)
debug ("%s -- enter\n", __FUNCTION__);
list_for_each_safe (tmp, next, &ibmphp_slot_head) {
slot_cur = list_entry (tmp, struct slot, ibm_slot_list);
pci_hp_deregister (slot_cur->hotplug_slot);
if (slot_cur->hotplug_slot) {
kfree (slot_cur->hotplug_slot);
slot_cur->hotplug_slot = NULL;
}
if (slot_cur->ctrl)
slot_cur->ctrl = NULL;
if (slot_cur->bus_on)
slot_cur->bus_on = NULL;
ibmphp_unconfigure_card (&slot_cur, -1); /* we don't want to actually remove the resources, since free_resources will do just that */
kfree (slot_cur);
slot_cur = NULL;
}
debug ("%s -- exit\n", __FUNCTION__);
}
......@@ -1221,7 +1203,6 @@ int ibmphp_do_disable_slot (struct slot *slot_cur)
{
int rc;
u8 flag;
int parm = 0;
debug ("DISABLING SLOT... \n");
......@@ -1270,7 +1251,7 @@ int ibmphp_do_disable_slot (struct slot *slot_cur)
return 0;
}
rc = ibmphp_unconfigure_card (&slot_cur, parm);
rc = ibmphp_unconfigure_card (&slot_cur, 0);
slot_cur->func = NULL;
debug ("in disable_slot. after unconfigure_card\n");
if (rc) {
......
......@@ -3,8 +3,8 @@
*
* Written By: Tong Yu, IBM Corporation
*
* Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001,2002 IBM Corp.
* Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -727,6 +727,64 @@ static char *create_file_name (struct slot * slot_cur)
return str;
}
static int fillslotinfo(struct hotplug_slot *hotplug_slot)
{
struct slot *slot;
int rc = 0;
if (!hotplug_slot || !hotplug_slot->private)
return -EINVAL;
slot = hotplug_slot->private;
rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL);
if (rc)
return rc;
// power - enabled:1 not:0
hotplug_slot->info->power_status = SLOT_POWER(slot->status);
// attention - off:0, on:1, blinking:2
hotplug_slot->info->attention_status = SLOT_ATTN(slot->status, slot->ext_status);
// latch - open:1 closed:0
hotplug_slot->info->latch_status = SLOT_LATCH(slot->status);
// pci board - present:1 not:0
if (SLOT_PRESENT (slot->status))
hotplug_slot->info->adapter_status = 1;
else
hotplug_slot->info->adapter_status = 0;
/*
if (slot->bus_on->supported_bus_mode
&& (slot->bus_on->supported_speed == BUS_SPEED_66))
hotplug_slot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
else
hotplug_slot->info->max_bus_speed_status = slot->bus_on->supported_speed;
*/
return rc;
}
static void release_slot(struct hotplug_slot *hotplug_slot)
{
struct slot *slot;
if (!hotplug_slot || !hotplug_slot->private)
return;
slot = hotplug_slot->private;
kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
slot->ctrl = NULL;
slot->bus_on = NULL;
/* we don't want to actually remove the resources, since free_resources will do just that */
ibmphp_unconfigure_card(&slot, -1);
kfree (slot);
}
static struct pci_driver ibmphp_driver;
/*
......@@ -900,32 +958,32 @@ static int __init ebda_rsrc_controller (void)
// register slots with hpc core as well as create linked list of ibm slot
for (index = 0; index < hpc_ptr->slot_count; index++) {
hp_slot_ptr = (struct hotplug_slot *) kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
if (!hp_slot_ptr) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
memset (hp_slot_ptr, 0, sizeof (struct hotplug_slot));
memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
hp_slot_ptr->info = (struct hotplug_slot_info *) kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!hp_slot_ptr->info) {
rc = -ENOMEM;
goto error_no_hp_info;
}
memset (hp_slot_ptr->info, 0, sizeof (struct hotplug_slot_info));
memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
hp_slot_ptr->name = (char *) kmalloc (30, GFP_KERNEL);
hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
if (!hp_slot_ptr->name) {
rc = -ENOMEM;
goto error_no_hp_name;
}
tmp_slot = kmalloc (sizeof (struct slot), GFP_KERNEL);
tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
if (!tmp_slot) {
rc = -ENOMEM;
goto error_no_slot;
}
memset (tmp_slot, 0, sizeof (*tmp_slot));
memset(tmp_slot, 0, sizeof(*tmp_slot));
tmp_slot->flag = TRUE;
......@@ -959,8 +1017,9 @@ static int __init ebda_rsrc_controller (void)
tmp_slot->hotplug_slot = hp_slot_ptr;
hp_slot_ptr->private = tmp_slot;
hp_slot_ptr->release = release_slot;
rc = ibmphp_hpc_fillhpslotinfo (hp_slot_ptr);
rc = fillslotinfo(hp_slot_ptr);
if (rc)
goto error;
......
......@@ -3,7 +3,7 @@
*
* Written By: Jyoti Shah, IBM Corporation
*
* Copyright (c) 2001-2002 IBM Corp.
* Copyright (c) 2001-2003 IBM Corp.
*
* All rights reserved.
*
......@@ -114,7 +114,6 @@ static u8 hpc_readcmdtoindex (u8, u8);
static void get_hpc_access (void);
static void free_hpc_access (void);
static void poll_hpc (void);
static int update_slot (struct slot *, u8);
static int process_changeinstatus (struct slot *, struct slot *);
static int process_changeinlatch (u8, u8, struct controller *);
static int hpc_poll_thread (void *);
......@@ -917,71 +916,6 @@ static void poll_hpc (void)
}
/* ----------------------------------------------------------------------
* Name: ibmphp_hpc_fillhpslotinfo(hotplug_slot * phpslot)
*
* Action: fill out the hotplug_slot info
*
* Input: pointer to hotplug_slot
*
* Return
* Value: 0 or error codes
*-----------------------------------------------------------------------*/
int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *phpslot)
{
int rc = 0;
struct slot *pslot;
if (phpslot && phpslot->private) {
pslot = (struct slot *) phpslot->private;
rc = update_slot (pslot, (u8) TRUE);
if (!rc) {
// power - enabled:1 not:0
phpslot->info->power_status = SLOT_POWER (pslot->status);
// attention - off:0, on:1, blinking:2
phpslot->info->attention_status = SLOT_ATTN (pslot->status, pslot->ext_status);
// latch - open:1 closed:0
phpslot->info->latch_status = SLOT_LATCH (pslot->status);
// pci board - present:1 not:0
if (SLOT_PRESENT (pslot->status))
phpslot->info->adapter_status = 1;
else
phpslot->info->adapter_status = 0;
/*
if (pslot->bus_on->supported_bus_mode
&& (pslot->bus_on->supported_speed == BUS_SPEED_66))
phpslot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
else
phpslot->info->max_bus_speed_status = pslot->bus_on->supported_speed;
*/ } else
rc = -EINVAL;
} else
rc = -EINVAL;
return rc;
}
/*----------------------------------------------------------------------
* Name: update_slot
*
* Action: fill out slot status and extended status, controller status
*
* Input: pointer to slot struct
*---------------------------------------------------------------------*/
static int update_slot (struct slot *pslot, u8 update)
{
int rc = 0;
debug ("%s - Entry pslot[%p]\n", __FUNCTION__, pslot);
rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL);
debug ("%s - Exit rc[%d]\n", __FUNCTION__, rc);
return rc;
}
/*----------------------------------------------------------------------
* Name: process_changeinstatus
*
......
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