PCI Hotplug changes for 2.5.59
Subsystems (2)
PATCH 1/1 PCI Hotplug changes for 2.5.59
Hi,
Here's a series of PCI Hotplug patches, a few related PCI core patches, and two small, related sysfs patches.
The hotplug driver patches consist of a lot of bug fixes due to problems found by the smatch and checker projects, and a big patch to remove pcihpfs and use sysfs instead from Stanley Wang. I've also moved the few functions in drivers/hotplug/pci_hotplug_util.c to drivers/pci/hotplug.c which is a better place for them.
There are some sysfs updates for pci devices from Dan Stekloff and a new function was added to sysfs to support the move from pcihpfs to sysfs. This sysfs patch was blessed by Pat Mochel.
Please pull from: bk://kernel.bkbits.net/gregkh/linux/pci_hp-2.5
thanks,
greg k-h
drivers/hotplug/pci_hotplug_util.c | 217 ------ drivers/hotplug/Makefile | 3 drivers/hotplug/acpiphp_glue.c | 5 drivers/hotplug/cpci_hotplug_core.c | 4 drivers/hotplug/cpci_hotplug_pci.c | 2 drivers/hotplug/cpqphp_core.c | 2 drivers/hotplug/cpqphp_ctrl.c | 16 drivers/hotplug/cpqphp_nvram.c | 67 +- drivers/hotplug/cpqphp_pci.c | 4 drivers/hotplug/cpqphp_proc.c | 2 drivers/hotplug/ibmphp_core.c | 10 drivers/hotplug/ibmphp_ebda.c | 209 ++---- drivers/hotplug/ibmphp_pci.c | 25 drivers/hotplug/pci_hotplug.h | 43 - drivers/hotplug/pci_hotplug_core.c | 1177 ++++++++---------------------------- drivers/pci/Makefile | 3 drivers/pci/hotplug.c | 180 +++++ drivers/pci/pci-sysfs.c | 84 ++ drivers/pci/pci.h | 2 drivers/pci/proc.c | 28 fs/sysfs/inode.c | 42 + include/linux/pci.h | 31 include/linux/sysfs.h | 3 23 files changed, 773 insertions(+), 1386 deletions(-)
-----
[email protected], 2003-02-06 14:49:36+11:00, [email protected]
sysfs: remember to add EXPORT_SYMBOL() for sysfs_update_file.
fs/sysfs/inode.c | 1 + 1 files changed, 1 insertion(+)
------
[email protected], 2003-02-06 13:33:46+11:00, [email protected]
[PATCH] IBM PCI Hotplug: fix a load of memory leak errors found by the checker project.
drivers/hotplug/ibmphp_ebda.c | 132 ++++++++++++++++++++---------------------- 1 files changed, 65 insertions(+), 67 deletions(-)
------
[email protected], 2003-02-06 11:23:20+11:00, [email protected]
[PATCH] IBM PCI Hotplug: fix memory leak found by checker project.
drivers/hotplug/ibmphp_pci.c | 1 + 1 files changed, 1 insertion(+)
------
[email protected], 2003-02-06 11:09:25+11:00, [email protected]
[PATCH] Compaq PCI Hotplug: fix checker memory leak bugs.
drivers/hotplug/cpqphp_nvram.c | 67 ++++++++++++++++++++++++----------------- 1 files changed, 40 insertions(+), 27 deletions(-)
------
[email protected], 2003-02-06 10:14:04+11:00, [email protected]
[PATCH] PCI Hotplug: memory leaks in acpiphp_glue
Here's the memory leaks patch for acpiphp_glue.c.
drivers/hotplug/acpiphp_glue.c | 5 +++++ 1 files changed, 5 insertions(+)
------
[email protected], 2003-02-06 10:04:49+11:00, [email protected]
[PATCH] PCI: put proper field sizes on sysfs files, and add class file.
drivers/pci/pci-sysfs.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
------
[email protected], 2003-02-06 10:03:53+11:00, [email protected]
[PATCH] pci patch for sysfs files
The patch is modeled after your method for creating files for usb. It makes a single file for pci sysfs files (except for pool, which I haven't touched yet). It also exposes more pci information to User Space through sysfs. Finally, it removes the dependence on the proc pci code for sysfs files.
drivers/pci/Makefile | 3 + drivers/pci/hotplug.c | 2 + drivers/pci/pci-sysfs.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 2 - drivers/pci/proc.c | 28 ------------------ 5 files changed, 79 insertions(+), 30 deletions(-)
------
[email protected], 2003-02-05 17:20:29+11:00, [email protected]
[PATCH] PCI Hotplug: checker patches
Fixes problems found by the CHECKER program in the pci hotplug drivers
drivers/hotplug/cpqphp_pci.c | 2 +- drivers/hotplug/ibmphp_pci.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-)
------
[email protected], 2003-02-05 17:19:49+11:00, [email protected]
[PATCH] PCI Hotplug: moved the some stuff into the pci core
Moved functions from drivers/hotplug/pci_hotplug_util.c to drivers/pci/hotplug.c, which is a better place for them.
drivers/hotplug/pci_hotplug_util.c | 217 ------------------------------------- drivers/hotplug/Makefile | 3 drivers/hotplug/pci_hotplug.h | 32 ----- drivers/pci/hotplug.c | 178 ++++++++++++++++++++++++++++++ include/linux/pci.h | 31 +++++ 5 files changed, 208 insertions(+), 253 deletions(-)
------
[email protected], 2003-02-05 17:19:09+11:00, [email protected]
[PATCH] PCI Hotplug: Make pci_hp_change_slot_info() work again
Relies on sysfs_update_file() to be present in the kernel.
drivers/hotplug/pci_hotplug_core.c | 130 +++++++++++++++++++++++++++++++------ 1 files changed, 111 insertions(+), 19 deletions(-)
------
[email protected], 2003-02-05 17:18:17+11:00, [email protected]
[PATCH] sysfs: add sysfs_update_file() function.
fs/sysfs/inode.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/sysfs.h | 3 +++ 2 files changed, 44 insertions(+)
------
[email protected], 2003-02-05 17:17:39+11:00, [email protected]
[PATCH] PCI Hotplug: change pci_hp_change_slot_info() to take a hotplug_slot and not a string.
drivers/hotplug/cpci_hotplug_core.c | 4 ++-- drivers/hotplug/cpqphp_ctrl.c | 4 +--- drivers/hotplug/ibmphp_core.c | 4 +--- drivers/hotplug/pci_hotplug.h | 2 +- drivers/hotplug/pci_hotplug_core.c | 6 +++--- 5 files changed, 8 insertions(+), 12 deletions(-)
------
[email protected], 2003-02-05 17:17:06+11:00, [email protected]
[PATCH] PCI Hotplug: Remove procfs stuff from pci_hotplug_core
Here is a little patch that remove procfs stuff in pci_hotplug_core.c Remove /proc entry for pci_hotplug_core.
drivers/hotplug/pci_hotplug_core.c | 17 ----------------- 1 files changed, 17 deletions(-)
------
[email protected], 2003-02-05 17:16:30+11:00, [email protected]
[PATCH] PCI Hotplug: Replace pcihpfs with sysfs.
drivers/hotplug/pci_hotplug.h | 9 drivers/hotplug/pci_hotplug_core.c | 1024 +++++-------------------------------- 2 files changed, 160 insertions(+), 873 deletions(-)
------
[email protected], 2003-02-05 17:15:55+11:00, [email protected]
[PATCH] IBM PCI Hotplug driver: Clean up the slot filename generation logic a lot.
drivers/hotplug/ibmphp_ebda.c | 77 +++--------------------------------------- 1 files changed, 6 insertions(+), 71 deletions(-)
------
[email protected], 2003-02-05 17:15:13+11:00, [email protected]
[PATCH] PCI Hotplug: dereference null variable cleanup patches.
These were pointed out by "dan carpenter" <[email protected]> from his smatch tool.
drivers/hotplug/cpci_hotplug_pci.c | 2 ++ drivers/hotplug/cpqphp_core.c | 2 ++ drivers/hotplug/cpqphp_ctrl.c | 12 ++++++++++++ drivers/hotplug/cpqphp_pci.c | 2 ++ drivers/hotplug/cpqphp_proc.c | 2 ++ drivers/hotplug/ibmphp_core.c | 6 ++++++ 6 files changed, 26 insertions(+)
------
PATCH 1/1 PCI Hotplug changes for 2.5.59
ChangeSet 1.947.23.1, 2003/02/05 17:15:13+11:00, [email protected]
[PATCH] PCI Hotplug: dereference null variable cleanup patches.
These were pointed out by "dan carpenter" <[email protected]> from his smatch tool.
drivers/hotplug/cpci_hotplug_pci.c +2 -0
@@ -395,6 +395,8 @@/* Scan behind bridge */ n =pci_scan_bridge (bus, dev, max,2 ); child =pci_find_bus (max +1 ); +if (!child) +return -ENODEV ;#ifdef CONFIG_PROC_FS pci_proc_attach_bus (child);#endif
drivers/hotplug/cpqphp_core.c +2 -0
@@ -488,6 +488,8 @@ bridgeSlot =0xFF ; PCIIRQRoutingInfoLength =pcibios_get_irq_routing_table (); +if (!PCIIRQRoutingInfoLength) +return -1 ; len = (PCIIRQRoutingInfoLength->size -sizeof (struct irq_routing_table )) /sizeof (struct irq_info );
drivers/hotplug/cpqphp_ctrl.c +12 -0
@@ -188,6 +188,8 @@ rc++; p_slot =find_slot (ctrl, hp_slot + (readb (ctrl->hpc_reg +SLOT_MASK ) >>4 )); +if (!p_slot) +return 0 ;// If the switch closed, must be a button // If not in button mode, nevermind
@@ -1799,8 +1801,12 @@ hp_slot = ctrl->event_queue[loop].hp_slot; func =cpqhp_slot_find (ctrl->bus, (hp_slot + ctrl->slot_device_offset),0 ); +if (!func) +return ; p_slot =find_slot (ctrl, hp_slot + ctrl->slot_device_offset); +if (!p_slot) +return ;dbg ("hp_slot %d, func %p, p_slot %p\n" , hp_slot, func, p_slot);
@@ -2511,8 +2517,14 @@// Setup the IO, memory, and prefetchable windows io_node =get_max_resource (&(resources->io_head),0x1000 ); +if (!io_node) +return -ENOMEM ; mem_node =get_max_resource (&(resources->mem_head),0x100000 ); +if (!mem_node) +return -ENOMEM ; p_mem_node =get_max_resource (&(resources->p_mem_head),0x100000 ); +if (!p_mem_node) +return -ENOMEM ;dbg ("Setup the IO, memory, and prefetchable windows\n" );dbg ("io_node\n" );dbg ("(base, len, next) (%x, %x, %p)\n" , io_node->base, io_node->length, io_node->next);
drivers/hotplug/cpqphp_pci.c +2 -0
@@ -435,6 +435,8 @@u8 tbus, tdevice, tslot; PCIIRQRoutingInfoLength =pcibios_get_irq_routing_table (); +if (!PCIIRQRoutingInfoLength) +return -1 ; len = (PCIIRQRoutingInfoLength->size -sizeof (struct irq_routing_table )) /sizeof (struct irq_info );
drivers/hotplug/cpqphp_proc.c +2 -0
@@ -113,6 +113,8 @@while (slot) { new_slot =cpqhp_slot_find (slot->bus, slot->device,0 ); +if (!new_slot) +break ; out +=sprintf (out,"assigned resources: memory\n" ); index =11 ; res = new_slot->mem_head;
drivers/hotplug/ibmphp_core.c +6 -0
@@ -1057,6 +1057,8 @@if (func->dev ==NULL ) { dev0.bus =ibmphp_find_bus (func->busno); +if (!dev0.bus) +return 0 ; dev0.devfn = ((func->device <<3 ) + (func->function &0x7 )); dev0.sysdata = dev0.bus->sysdata;
@@ -1097,6 +1099,8 @@continue ; } tmp_slot =ibmphp_get_slot_from_physical_num (i); +if (!tmp_slot) +return 0 ; rc =slot_update (&tmp_slot);if (rc)return 0 ;
@@ -1219,6 +1223,8 @@for (i = slot_cur->bus_on->slot_min; i <= slot_cur->bus_on->slot_max; i++) { tmp_slot =ibmphp_get_slot_from_physical_num (i); +if (!tmp_slot) +return -ENODEV ;if ((SLOT_PWRGD (tmp_slot->status)) && !(SLOT_CONNECT (tmp_slot->status))) count++; }
ChangeSet 1.947.23.2, 2003/02/05 17:15:55+11:00, [email protected]
[PATCH] IBM PCI Hotplug driver: Clean up the slot filename generation logic a lot.
drivers/hotplug/ibmphp_ebda.c +6 -71
@@ -65,8 +65,6 @@static LIST_HEAD (opt_lo_head);static void *io_mem; -char *chassis_str, *rxe_str, *str; -/* Local functions */ static int ebda_rsrc_controller (void );static int ebda_rsrc_rsrc (void );
@@ -591,32 +589,6 @@return 0 ; } -static char *convert_2digits_to_char (int var) -{ -int bit; -char *str1; - - str = (char *)kmalloc (3 ,GFP_KERNEL ); -memset (str,0 ,3 ); - str1 = (char *)kmalloc (2 ,GFP_KERNEL ); -memset (str,0 ,3 ); - bit = (int )(var /10 ); -switch (bit) { -case 0 : -//one digit number - *str = (char )(var +48 ); -return str; -default : -//2 digits number - *str1 = (char )(bit +48 ); -strncpy (str, str1,1 ); -memset (str1,0 ,3 ); - *str1 = (char )((var %10 ) +48 ); -strcat (str, str1); -return str; - } -return NULL ; -}/* Since we don't know the max slot number per each chassis, hence go * through the list of all chassis to find out the range
@@ -701,7 +673,7 @@ {struct opt_rio *opt_vg_ptr =NULL ;struct opt_rio_lo *opt_lo_ptr =NULL ; -char *ptr_chassis_num, *ptr_rxe_num, *ptr_slot_num; +static char str[30 ];int which =0 ;/* rxe = 1, chassis = 0 */ u8 number =1 ;/* either chassis or rxe # */ u8 first_slot =1 ;
@@ -715,19 +687,7 @@ slot_num = slot_cur->number; - chassis_str = (char *)kmalloc (30 ,GFP_KERNEL ); -memset (chassis_str,0 ,30 ); - rxe_str = (char *)kmalloc (30 ,GFP_KERNEL ); -memset (rxe_str,0 ,30 ); - ptr_chassis_num = (char *)kmalloc (3 ,GFP_KERNEL ); -memset (ptr_chassis_num,0 ,3 ); - ptr_rxe_num = (char *)kmalloc (3 ,GFP_KERNEL ); -memset (ptr_rxe_num,0 ,3 ); - ptr_slot_num = (char *)kmalloc (3 ,GFP_KERNEL ); -memset (ptr_slot_num,0 ,3 ); - -strcpy (chassis_str,"chassis" ); -strcpy (rxe_str,"rxe" ); +memset (str,0 ,sizeof (str));if (rio_table_ptr) {if (rio_table_ptr->ver_num ==3 ) {
@@ -772,31 +732,10 @@ } } -switch (which) { -case 0 : -/* Chassis */ - *ptr_chassis_num = (char )(number +48 ); -strcat (chassis_str, ptr_chassis_num); -kfree (ptr_chassis_num); -strcat (chassis_str,"slot" ); - ptr_slot_num =convert_2digits_to_char (slot_num - first_slot +1 ); -strcat (chassis_str, ptr_slot_num); -kfree (ptr_slot_num); -return chassis_str; -break ; -case 1 : -/* RXE */ - *ptr_rxe_num = (char )(number +48 ); -strcat (rxe_str, ptr_rxe_num); -kfree (ptr_rxe_num); -strcat (rxe_str,"slot" ); - ptr_slot_num =convert_2digits_to_char (slot_num - first_slot +1 ); -strcat (rxe_str, ptr_slot_num); -kfree (ptr_slot_num); -return rxe_str; -break ; - } -return NULL ; +sprintf (str,"%s%dslot%d" , + which ==0 ?"chassis" :"rxe" , + number, slot_num - first_slot +1 ); +return str; }static struct pci_driver ibmphp_driver;
@@ -1060,10 +999,6 @@ slot_cur = list_entry (list, struct slot, ibm_slot_list);snprintf (slot_cur->hotplug_slot->name,30 ,"%s" ,create_file_name (slot_cur)); -if (chassis_str) -kfree (chassis_str); -if (rxe_str) -kfree (rxe_str);pci_hp_register (slot_cur->hotplug_slot); }
ChangeSet 1.947.23.3, 2003/02/05 17:16:30+11:00, [email protected]
[PATCH] PCI Hotplug: Replace pcihpfs with sysfs.
drivers/hotplug/pci_hotplug.h +6 -3
@@ -46,8 +46,11 @@ };struct hotplug_slot ; -struct hotplug_slot_core ; - +struct hotplug_slot_attribute { +struct attribute attr; +ssize_t (*show)(struct hotplug_slot *,char *); +ssize_t (*store)(struct hotplug_slot *,const char *,size_t ); +};/** * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use * @owner: The module owner of this structure
@@ -131,7 +134,7 @@/* Variables below this are for use only by the hotplug pci core. */ struct list_head slot_list; -struct hotplug_slot_core *core_priv; +struct kobject kobj; };extern int pci_hp_register (struct hotplug_slot *slot);
drivers/hotplug/pci_hotplug_core.c +154 -870
1,263 lines not on this page · raw message
ChangeSet 1.947.23.4, 2003/02/05 17:17:06+11:00, [email protected]
[PATCH] PCI Hotplug: Remove procfs stuff from pci_hotplug_core
Here is a little patch that remove procfs stuff in pci_hotplug_core.c Remove /proc entry for pci_hotplug_core.
drivers/hotplug/pci_hotplug_core.c +0 -17
@@ -40,7 +40,6 @@#include <linux/namei.h> #include <linux/pci.h> #include <linux/dnotify.h> -#include <linux/proc_fs.h> #include <asm/uaccess.h> #include <linux/kobject.h> #include <linux/sysfs.h>
@@ -131,12 +130,6 @@ "133 MHz PCIX 533", /* 0x13 */ }; -#ifdef CONFIG_PROC_FS -extern struct proc_dir_entry *proc_bus_pci_dir; -static struct proc_dir_entry *slotdir =NULL ; -static const char *slotdir_name ="slots" ; -#endif -#ifdef CONFIG_HOTPLUG_PCI_CPCI extern int cpci_hotplug_init (int debug);extern void cpci_hotplug_exit (void );
@@ -568,11 +561,6 @@ goto err_subsys; } -#ifdef CONFIG_PROC_FS -/* create mount point for pcihpfs */ - slotdir =proc_mkdir (slotdir_name, proc_bus_pci_dir); -#endif -info (DRIVER_DESC " version: " DRIVER_VERSION "\n" ); goto exit;
@@ -584,11 +572,6 @@ static void __exit pci_hotplug_exit (void) { -#ifdef CONFIG_PROC_FS -if (slotdir) -remove_proc_entry (slotdir_name, proc_bus_pci_dir); -#endif -cpci_hotplug_exit ();subsystem_unregister (&hotplug_slots_subsys); }
ChangeSet 1.947.23.5, 2003/02/05 17:17:39+11:00, [email protected]
[PATCH] PCI Hotplug: change pci_hp_change_slot_info() to take a hotplug_slot and not a string.
drivers/hotplug/cpci_hotplug_core.c +2 -2
@@ -130,7 +130,7 @@return -EINVAL ;memcpy (&info, hotplug_slot->info,sizeof (struct hotplug_slot_info )); info.latch_status = value; -return pci_hp_change_slot_info (hotplug_slot->name, &info); +return pci_hp_change_slot_info (hotplug_slot, &info); } static int
@@ -142,7 +142,7 @@return -EINVAL ;memcpy (&info, hotplug_slot->info,sizeof (struct hotplug_slot_info )); info.adapter_status = value; -return pci_hp_change_slot_info (hotplug_slot->name, &info); +return pci_hp_change_slot_info (hotplug_slot, &info); } static int
drivers/hotplug/cpqphp_ctrl.c +1 -3
@@ -1767,19 +1767,17 @@static int update_slot_info (struct controller *ctrl,struct slot *slot) {struct hotplug_slot_info *info; -char buffer[SLOT_NAME_SIZE ];int result; info =kmalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL );if (!info)return -ENOMEM ; -make_slot_name (&buffer[0 ],SLOT_NAME_SIZE , slot); info->power_status =get_slot_enabled (ctrl, slot); info->attention_status =cpq_get_attention_status (ctrl, slot); info->latch_status =cpq_get_latch_status (ctrl, slot); info->adapter_status =get_presence_status (ctrl, slot); - result =pci_hp_change_slot_info (buffer, info); + result =pci_hp_change_slot_info (slot->hotplug_slot, info);kfree (info);return result; }
drivers/hotplug/ibmphp_core.c +1 -3
@@ -686,7 +686,6 @@int ibmphp_update_slot_info (struct slot *slot_cur) {struct hotplug_slot_info *info; -char buffer[30 ];int rc;u8 bus_speed;u8 mode;
@@ -697,7 +696,6 @@return -ENOMEM ; } -strncpy (buffer, slot_cur->hotplug_slot->name,30 ); info->power_status =SLOT_PWRGD (slot_cur->status); info->attention_status =SLOT_ATTN (slot_cur->status, slot_cur->ext_status); info->latch_status =SLOT_LATCH (slot_cur->status);
@@ -735,7 +733,7 @@ info->max_bus_speed = slot_cur->hotplug_slot->info->max_bus_speed;// To do: bus_names - rc =pci_hp_change_slot_info (buffer, info); + rc =pci_hp_change_slot_info (slot_cur->hotplug_slot, info);kfree (info);return rc; }
drivers/hotplug/pci_hotplug.h +1 -1
@@ -139,7 +139,7 @@extern int pci_hp_register (struct hotplug_slot *slot);extern int pci_hp_deregister (struct hotplug_slot *slot); -extern int pci_hp_change_slot_info (const char *name, +extern int pci_hp_change_slot_info (struct hotplug_slot *slot,struct hotplug_slot_info *info);struct pci_dev_wrapped {
drivers/hotplug/pci_hotplug_core.c +3 -3
@@ -529,16 +529,16 @@/** * pci_hp_change_slot_info - changes the slot's information structure in the core -* @name: the name of the slot whose info has changed +* @slot: pointer to the slot whose info has changed * @info: pointer to the info copy into the slot's info structure * -* A slot with @name must have been registered with the pci +* @slot must have been registered with the pci * hotplug subsystem previously with a call to pci_hp_register(). * * Returns 0 if successful, anything else for an error. * Not supported by sysfs now. */ -int pci_hp_change_slot_info (const char *name,struct hotplug_slot_info *info) +int pci_hp_change_slot_info (struct hotplug_slot *slot,struct hotplug_slot_info *info) {return 0 ; }
ChangeSet 1.947.23.6, 2003/02/05 17:18:17+11:00, [email protected]
[PATCH] sysfs: add sysfs_update_file() function.
fs/sysfs/inode.c +41 -0
@@ -37,6 +37,7 @@#include <linux/backing-dev.h> #include <linux/kobject.h> #include <linux/mount.h> +#include <linux/dnotify.h> #include <asm/uaccess.h> /* Random magic number */
@@ -714,6 +715,46 @@dput (victim); }up (&dir->d_inode->i_sem); +} + +/** +* sysfs_update_file - update the modified timestamp on an object attribute. +* @kobj: object we're acting for. +* @attr: attribute descriptor. +* +* Also call dnotify for the dentry, which lots of userspace programs +* use. +*/ +int sysfs_update_file (struct kobject * kobj,struct attribute * attr) +{ +struct dentry * dir = kobj->dentry; +struct dentry * victim; +int res = -ENOENT ; + +down (&dir->d_inode->i_sem); + victim =get_dentry (dir, attr->name); +if (!IS_ERR (victim)) { +/* make sure dentry is really there */ +if (victim->d_inode && + (victim->d_parent->d_inode == dir->d_inode)) { + victim->d_inode->i_mtime =CURRENT_TIME ; +dnotify_parent (victim,DN_MODIFY ); + +/** +* Drop reference from initial get_dentry(). +*/ +dput (victim); + res =0 ; + } + +/** +* Drop the reference acquired from get_dentry() above. +*/ +dput (victim); + } +up (&dir->d_inode->i_sem); + +return res; }
include/linux/sysfs.h +3 -0
@@ -30,6 +30,9 @@extern int sysfs_create_file (struct kobject *,struct attribute *); +extern int +sysfs_update_file (struct kobject *,struct attribute *); +extern void sysfs_remove_file (struct kobject *,struct attribute *);
ChangeSet 1.947.23.7, 2003/02/05 17:19:09+11:00, [email protected]
[PATCH] PCI Hotplug: Make pci_hp_change_slot_info() work again
Relies on sysfs_update_file() to be present in the kernel.
drivers/hotplug/pci_hotplug_core.c +111 -19
@@ -39,7 +39,6 @@#include <linux/mount.h> #include <linux/namei.h> #include <linux/pci.h> -#include <linux/dnotify.h> #include <asm/uaccess.h> #include <linux/kobject.h> #include <linux/sysfs.h>
@@ -385,58 +384,119 @@ .store = test_write_file }; -static int fs_add_slot (struct hotplug_slot *slot) +static int has_power_file (struct hotplug_slot *slot) { +if ((!slot) || (!slot->ops)) +return -ENODEV ;if ((slot->ops->enable_slot) || (slot->ops->disable_slot) || (slot->ops->get_power_status)) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_power.attr); +return 0 ; +return -ENOENT ; +} +static int has_attention_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if ((slot->ops->set_attention_status) || (slot->ops->get_attention_status)) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_attention.attr); +return 0 ; +return -ENOENT ; +} +static int has_latch_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if (slot->ops->get_latch_status) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_latch.attr); +return 0 ; +return -ENOENT ; +} +static int has_adapter_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if (slot->ops->get_adapter_status) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_presence.attr); +return 0 ; +return -ENOENT ; +} +static int has_max_bus_speed_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if (slot->ops->get_max_bus_speed) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); +return 0 ; +return -ENOENT ; +} +static int has_cur_bus_speed_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if (slot->ops->get_cur_bus_speed) -sysfs_create_file (&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); +return 0 ; +return -ENOENT ; +} +static int has_test_file (struct hotplug_slot *slot) +{ +if ((!slot) || (!slot->ops)) +return -ENODEV ;if (slot->ops->hardware_test) +return 0 ; +return -ENOENT ; +} + +static int fs_add_slot (struct hotplug_slot *slot) +{ +if (has_power_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_power.attr); + +if (has_attention_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_attention.attr); + +if (has_latch_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_latch.attr); + +if (has_adapter_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_presence.attr); + +if (has_max_bus_speed_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); + +if (has_cur_bus_speed_file (slot) ==0 ) +sysfs_create_file (&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); + +if (has_test_file (slot) ==0 )sysfs_create_file (&slot->kobj, &hotplug_slot_attr_test.attr); +return 0 ; }static void fs_remove_slot (struct hotplug_slot *slot) { -if ((slot->ops->enable_slot) || - (slot->ops->disable_slot) || - (slot->ops->get_power_status)) +if (has_power_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_power.attr); -if ((slot->ops->set_attention_status) || - (slot->ops->get_attention_status)) +if (has_attention_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_attention.attr); -if (slot->ops->get_latch_status) +if (has_latch_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_latch.attr); -if (slot->ops->get_adapter_status) +if (has_adapter_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_presence.attr); -if (slot->ops->get_max_bus_speed) +if (has_max_bus_speed_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); -if (slot->ops->get_cur_bus_speed) +if (has_cur_bus_speed_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); -if (slot->ops->hardware_test) +if (has_test_file (slot) ==0 )sysfs_remove_file (&slot->kobj, &hotplug_slot_attr_test.attr); }
@@ -536,10 +596,42 @@* hotplug subsystem previously with a call to pci_hp_register(). * * Returns 0 if successful, anything else for an error. -* Not supported by sysfs now. */ int pci_hp_change_slot_info (struct hotplug_slot *slot,struct hotplug_slot_info *info) { +if ((slot ==NULL ) || (info ==NULL )) +return -ENODEV ; + +/* +* check all fields in the info structure, and update timestamps +* for the files referring to the fields that have now changed. +*/ +if ((has_power_file (slot) ==0 ) && + (slot->info->power_status != info->power_status)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_power.attr); + +if ((has_attention_file (slot) ==0 ) && + (slot->info->attention_status != info->attention_status)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_attention.attr); + +if ((has_latch_file (slot) ==0 ) && + (slot->info->latch_status != info->latch_status)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_latch.attr); + +if ((has_adapter_file (slot) ==0 ) && + (slot->info->adapter_status != info->adapter_status)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_presence.attr); + +if ((has_max_bus_speed_file (slot) ==0 ) && + (slot->info->max_bus_speed != info->max_bus_speed)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); + +if ((has_cur_bus_speed_file (slot) ==0 ) && + (slot->info->cur_bus_speed != info->cur_bus_speed)) +sysfs_update_file (&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); + +memcpy (slot->info, info,sizeof (struct hotplug_slot_info )); +return 0 ; }
ChangeSet 1.947.23.8, 2003/02/05 17:19:49+11:00, [email protected]
[PATCH] PCI Hotplug: moved the some stuff into the pci core
Moved functions from drivers/hotplug/pci_hotplug_util.c to drivers/pci/hotplug.c, which is a better place for them.
drivers/hotplug/Makefile +1 -2
@@ -9,8 +9,7 @@ obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o -pci_hotplug-objs := pci_hotplug_core.o \ - pci_hotplug_util.o +pci_hotplug-objs := pci_hotplug_core.o ifdef CONFIG_HOTPLUG_PCI_CPCI pci_hotplug-objs += cpci_hotplug_core.o \
drivers/hotplug/pci_hotplug.h +0 -32
@@ -142,37 +142,5 @@extern int pci_hp_change_slot_info (struct hotplug_slot *slot,struct hotplug_slot_info *info); -struct pci_dev_wrapped { -struct pci_dev *dev; -void *data; -}; - -struct pci_bus_wrapped { -struct pci_bus *bus; -void *data; -}; - -struct pci_visit { -int (* pre_visit_pci_bus) (struct pci_bus_wrapped *, -struct pci_dev_wrapped *); -int (* post_visit_pci_bus) (struct pci_bus_wrapped *, -struct pci_dev_wrapped *); - -int (* pre_visit_pci_dev) (struct pci_dev_wrapped *, -struct pci_bus_wrapped *); -int (* visit_pci_dev) (struct pci_dev_wrapped *, -struct pci_bus_wrapped *); -int (* post_visit_pci_dev) (struct pci_dev_wrapped *, -struct pci_bus_wrapped *); -}; - -extern int pci_visit_dev (struct pci_visit *fn, -struct pci_dev_wrapped *wrapped_dev, -struct pci_bus_wrapped *wrapped_parent); - -int pci_is_dev_in_use (struct pci_dev *dev); - -int pci_remove_device_safe (struct pci_dev *dev); -#endif
drivers/hotplug/pci_hotplug_util.c deleted +0 -217
217 lines not on this page · raw message
drivers/pci/hotplug.c +176 -2
195 lines not on this page · raw message
include/linux/pci.h +31 -0
@@ -671,6 +671,37 @@extern struct pci_dev *isa_bridge;#endif +/* Some worker functions that PCI Hotplug drivers find useful */ +struct pci_dev_wrapped { +struct pci_dev *dev; +void *data; +}; + +struct pci_bus_wrapped { +struct pci_bus *bus; +void *data; +}; + +struct pci_visit { +int (* pre_visit_pci_bus) (struct pci_bus_wrapped *, +struct pci_dev_wrapped *); +int (* post_visit_pci_bus) (struct pci_bus_wrapped *, +struct pci_dev_wrapped *); + +int (* pre_visit_pci_dev) (struct pci_dev_wrapped *, +struct pci_bus_wrapped *); +int (* visit_pci_dev) (struct pci_dev_wrapped *, +struct pci_bus_wrapped *); +int (* post_visit_pci_dev) (struct pci_dev_wrapped *, +struct pci_bus_wrapped *); +}; + +extern int pci_visit_dev (struct pci_visit *fn, +struct pci_dev_wrapped *wrapped_dev, +struct pci_bus_wrapped *wrapped_parent); +extern int pci_is_dev_in_use (struct pci_dev *dev); +extern int pci_remove_device_safe (struct pci_dev *dev); +#endif /* CONFIG_PCI */ /* Include architecture-dependent settings and functions */
ChangeSet 1.947.23.9, 2003/02/05 17:20:29+11:00, [email protected]
[PATCH] PCI Hotplug: checker patches
Fixes problems found by the CHECKER program in the pci hotplug drivers
drivers/hotplug/cpqphp_pci.c +1 -1
@@ -1193,7 +1193,7 @@if (temp != func->config_space[cloop >>2 ]) {dbg ("Config space compare failure!!! offset = %x\n" , cloop);dbg ("bus = %x, device = %x, function = %x\n" , func->bus, func->device, func->function); -dbg ("temp = %x, config space = %x\n\n" , temp, func->config_space[cloop]); +dbg ("temp = %x, config space = %x\n\n" , temp, func->config_space[cloop >>2 ]);return 1 ; } }
drivers/hotplug/ibmphp_pci.c +12 -12
@@ -1621,23 +1621,23 @@ }for (i =0 ; i < count; i++) { -if (cur_func->io[count]) { -debug ("io[%d] exists \n" , count); +if (cur_func->io[i]) { +debug ("io[%d] exists \n" , i);if (the_end >0 ) -ibmphp_remove_resource (cur_func->io[count]); - cur_func->io[count] =NULL ; +ibmphp_remove_resource (cur_func->io[i]); + cur_func->io[i] =NULL ; } -if (cur_func->mem[count]) { -debug ("mem[%d] exists \n" , count); +if (cur_func->mem[i]) { +debug ("mem[%d] exists \n" , i);if (the_end >0 ) -ibmphp_remove_resource (cur_func->mem[count]); - cur_func->mem[count] =NULL ; +ibmphp_remove_resource (cur_func->mem[i]); + cur_func->mem[i] =NULL ; } -if (cur_func->pfmem[count]) { -debug ("pfmem[%d] exists \n" , count); +if (cur_func->pfmem[i]) { +debug ("pfmem[%d] exists \n" , i);if (the_end >0 ) -ibmphp_remove_resource (cur_func->pfmem[count]); - cur_func->pfmem[count] =NULL ; +ibmphp_remove_resource (cur_func->pfmem[i]); + cur_func->pfmem[i] =NULL ; } }
ChangeSet 1.947.23.10, 2003/02/06 10:03:53+11:00, [email protected]
[PATCH] pci patch for sysfs files
The patch is modeled after your method for creating files for usb. It makes a single file for pci sysfs files (except for pool, which I haven't touched yet). It also exposes more pci information to User Space through sysfs. Finally, it removes the dependence on the proc pci code for sysfs files.
drivers/pci/Makefile +2 -1
@@ -3,7 +3,8 @@ # obj-y += access.o probe.o pci.o pool.o quirks.o \ - names.o pci-driver.o search.o hotplug.o + names.o pci-driver.o search.o hotplug.o \ + pci-sysfs.o obj-$(CONFIG_PM) += power.o obj-$(CONFIG_PROC_FS) += proc.o
drivers/pci/hotplug.c +2 -0
@@ -255,6 +255,8 @@#ifdef CONFIG_PROC_FS pci_proc_attach_device (dev);#endif +/* add sysfs device files */ +pci_create_sysfs_dev_files (dev); } static void
drivers/pci/pci-sysfs.c new file +74 -0
74 lines not on this page · raw message
drivers/pci/pci.h +1 -1
@@ -2,4 +2,4 @@extern int pci_hotplug (struct device *dev,char **envp,int num_envp,char *buffer,int buffer_size); - +extern void pci_create_sysfs_dev_files (struct pci_dev *pdev);
drivers/pci/proc.c +0 -28
@@ -373,32 +373,6 @@struct proc_dir_entry *proc_bus_pci_dir; -/* driverfs files */ -static ssize_t pci_show_irq (struct device * dev,char * buf) -{ -struct pci_dev * pci_dev =to_pci_dev (dev); -return sprintf (buf,"%u\n" ,pci_dev->irq); -} - -static DEVICE_ATTR(irq,S_IRUGO,pci_show_irq,NULL); - -static ssize_t pci_show_resources (struct device * dev,char * buf) -{ -struct pci_dev * pci_dev =to_pci_dev (dev); -char * str = buf; -int i; - -for (i =0 ; i <DEVICE_COUNT_RESOURCE &&pci_resource_start (pci_dev,i); i++) { - str += sprintf(str,LONG_FORMAT LONG_FORMAT LONG_FORMAT "\n", -pci_resource_start (pci_dev,i), -pci_resource_end (pci_dev,i), -pci_resource_flags (pci_dev,i)); - } -return (str - buf); -} - -static DEVICE_ATTR(resource,S_IRUGO,pci_show_resources,NULL); -int pci_proc_attach_device (struct pci_dev *dev) {struct pci_bus *bus = dev->bus;
@@ -422,8 +396,6 @@ e->data = dev; e->size =PCI_CFG_SPACE_SIZE ; -device_create_file (&dev->dev,&dev_attr_irq); -device_create_file (&dev->dev,&dev_attr_resource);return 0 ; }
ChangeSet 1.947.23.11, 2003/02/06 10:04:49+11:00, [email protected]
[PATCH] PCI: put proper field sizes on sysfs files, and add class file.
drivers/pci/pci-sysfs.c +6 -4
@@ -35,10 +35,11 @@ } \ static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); -pci_config_attr (vendor,"%x\n" ); -pci_config_attr (device,"%x\n" ); -pci_config_attr (subsystem_vendor,"%x\n" ); -pci_config_attr (subsystem_device,"%x\n" ); +pci_config_attr (vendor,"%04x\n" ); +pci_config_attr (device,"%04x\n" ); +pci_config_attr (subsystem_vendor,"%04x\n" ); +pci_config_attr (subsystem_device,"%04x\n" ); +pci_config_attr (class,"%06x\n" );pci_config_attr (irq,"%u\n" );/* show resources */
@@ -69,6 +70,7 @@device_create_file (dev, &dev_attr_device);device_create_file (dev, &dev_attr_subsystem_vendor);device_create_file (dev, &dev_attr_subsystem_device); +device_create_file (dev, &dev_attr_class);device_create_file (dev, &dev_attr_irq);device_create_file (dev, &dev_attr_resource); }
ChangeSet 1.947.23.12, 2003/02/06 10:14:04+11:00, [email protected]
[PATCH] PCI Hotplug: memory leaks in acpiphp_glue
Here's the memory leaks patch for acpiphp_glue.c.
drivers/hotplug/acpiphp_glue.c +5 -0
@@ -578,6 +578,7 @@ bridge->io_head =acpiphp_make_resource ((u64 )base, limit - base +1 );if (!bridge->io_head) {err ("out of memory\n" ); +kfree (bridge);return ; } dbg("16bit I/O range: %04x-%04x\n",
@@ -592,6 +593,7 @@ bridge->io_head =acpiphp_make_resource ((u64 )base, limit - base +1 );if (!bridge->io_head) {err ("out of memory\n" ); +kfree (bridge);return ; } dbg("32bit I/O range: %08x-%08x\n",
@@ -613,6 +615,7 @@ bridge->mem_head =acpiphp_make_resource ((u64 )base, limit - base +1 );if (!bridge->mem_head) {err ("out of memory\n" ); +kfree (bridge);return ; } dbg("32bit Memory range: %08x-%08x\n",
@@ -632,6 +635,7 @@ bridge->p_mem_head =acpiphp_make_resource ((u64 )base, limit - base +1 );if (!bridge->p_mem_head) {err ("out of memory\n" ); +kfree (bridge);return ; } dbg("32bit Prefetchable memory range: %08x-%08x\n",
@@ -647,6 +651,7 @@ bridge->p_mem_head =acpiphp_make_resource (base64, limit64 - base64 +1 );if (!bridge->p_mem_head) {err ("out of memory\n" ); +kfree (bridge);return ; } dbg("64bit Prefetchable memory range: %08x%08x-%08x%08x\n",
ChangeSet 1.947.23.13, 2003/02/06 11:09:25+11:00, [email protected]
[PATCH] Compaq PCI Hotplug: fix checker memory leak bugs.
drivers/hotplug/cpqphp_nvram.c +40 -27
@@ -473,7 +473,7 @@ p_byte +=3 ;if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +return 2 ; bus = p_ev_ctrl->bus; device = p_ev_ctrl->device;
@@ -490,20 +490,20 @@ p_byte +=4 ;if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +return 2 ;// Skip forward to the next entry p_byte += (nummem + numpmem + numio + numbus) *8 ;if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +return 2 ; p_ev_ctrl = (struct ev_hrt_ctrl *) p_byte; p_byte +=3 ;if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +return 2 ; bus = p_ev_ctrl->bus; device = p_ev_ctrl->device;
@@ -518,7 +518,7 @@ p_byte +=4 ;if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +return 2 ;while (nummem--) { mem_node = (struct pci_resource *)kmalloc (sizeof (struct pci_resource ),GFP_KERNEL );
@@ -530,15 +530,19 @@dbg ("mem base = %8.8x\n" ,mem_node->base); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (mem_node); +return 2 ; + } mem_node->length = *(u32 *)p_byte;dbg ("mem length = %8.8x\n" ,mem_node->length); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (mem_node); +return 2 ; + } mem_node->next = ctrl->mem_head; ctrl->mem_head = mem_node;
@@ -554,15 +558,19 @@dbg ("pre-mem base = %8.8x\n" ,p_mem_node->base); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (p_mem_node); +return 2 ; + } p_mem_node->length = *(u32 *)p_byte;dbg ("pre-mem length = %8.8x\n" ,p_mem_node->length); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (p_mem_node); +return 2 ; + } p_mem_node->next = ctrl->p_mem_head; ctrl->p_mem_head = p_mem_node;
@@ -578,15 +586,19 @@dbg ("io base = %8.8x\n" ,io_node->base); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (io_node); +return 2 ; + } io_node->length = *(u32 *)p_byte;dbg ("io length = %8.8x\n" ,io_node->length); p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (io_node); +return 2 ; + } io_node->next = ctrl->io_head; ctrl->io_head = io_node;
@@ -601,15 +613,18 @@ bus_node->base = *(u32 *)p_byte; p_byte +=4 ; -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (bus_node); +return 2 ; + } bus_node->length = *(u32 *)p_byte; p_byte +=4 ; - -if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) -return (2 ); +if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) { +kfree (bus_node); +return 2 ; + } bus_node->next = ctrl->bus_head; ctrl->bus_head = bus_node;
@@ -623,13 +638,11 @@ rc &=cpqhp_resource_sort_and_combine (&(ctrl->io_head)); rc &=cpqhp_resource_sort_and_combine (&(ctrl->bus_head)); -if (rc) { +if (rc)return (rc); - } }else { -if ((evbuffer[0 ] !=0 ) && (!ctrl->push_flag)) { -return (1 ); - } +if ((evbuffer[0 ] !=0 ) && (!ctrl->push_flag)) +return 1 ; }return 0 ;
ChangeSet 1.947.23.14, 2003/02/06 11:23:20+11:00, [email protected]
[PATCH] IBM PCI Hotplug: fix memory leak found by checker project.
drivers/hotplug/ibmphp_pci.c +1 -0
@@ -951,6 +951,7 @@if (rc) {if (rc == -ENOMEM ) {ibmphp_remove_bus (bus, func->busno); +kfree (amount_needed);return rc; } retval = rc;
ChangeSet 1.947.23.15, 2003/02/06 13:33:46+11:00, [email protected]
[PATCH] IBM PCI Hotplug: fix a load of memory leak errors found by the checker project.
drivers/hotplug/ibmphp_ebda.c +65 -67
@@ -70,17 +70,6 @@static int ebda_rsrc_rsrc (void );static int ebda_rio_table (void ); -static struct slot *alloc_ibm_slot (void ) -{ -struct slot *slot; - - slot =kmalloc (sizeof (struct slot ),GFP_KERNEL ); -if (!slot) -return NULL ; -memset (slot,0 ,sizeof (*slot)); -return slot; -} -static struct ebda_hpc_list *__init alloc_ebda_hpc_list (void ) {struct ebda_hpc_list *list;
@@ -757,8 +746,7 @@struct ebda_hpc_slot *slot_ptr;struct bus_info *bus_info_ptr1, *bus_info_ptr2;int rc; -int retval; -struct slot *slot_cur; +struct slot *tmp_slot;struct list_head *list; addr = hpc_list_ptr->phys_addr;
@@ -783,8 +771,8 @@/* init hpc structure */ hpc_ptr =alloc_ebda_hpc (slot_num, bus_num);if (!hpc_ptr ) { -iounmap (io_mem); -return -ENOMEM ; + rc = -ENOMEM ; + goto error_no_hpc; } hpc_ptr->ctlr_id = ctlr_id; hpc_ptr->ctlr_relative_id = ctlr;
@@ -810,8 +798,8 @@if (!bus_info_ptr2) { bus_info_ptr1 = (struct bus_info *)kmalloc (sizeof (struct bus_info ),GFP_KERNEL );if (!bus_info_ptr1) { -iounmap (io_mem); -return -ENOMEM ; + rc = -ENOMEM ; + goto error_no_hp_slot; }memset (bus_info_ptr1,0 ,sizeof (struct bus_info )); bus_info_ptr1->slot_min = slot_ptr->slot_num;
@@ -871,16 +859,20 @@ hpc_ptr->u.pci_ctlr.dev_fun =readb (io_mem + addr +1 ); hpc_ptr->irq =readb (io_mem + addr +2 ); addr +=3 ; -debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n" , hpc_ptr->u.pci_ctlr.bus, hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); +debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n" , + hpc_ptr->u.pci_ctlr.bus, + hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq);break ;case 0 : hpc_ptr->u.isa_ctlr.io_start =readw (io_mem + addr); hpc_ptr->u.isa_ctlr.io_end =readw (io_mem + addr +2 ); - retval =check_region (hpc_ptr->u.isa_ctlr.io_start, (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start +1 )); -if (retval) -return -ENODEV ; -request_region (hpc_ptr->u.isa_ctlr.io_start, (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start +1 ),"ibmphp" ); +if (!request_region (hpc_ptr->u.isa_ctlr.io_start, + (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start +1 ), +"ibmphp" )) { + rc = -ENODEV ; + goto error_no_hp_slot; + } hpc_ptr->irq =readb (io_mem + addr +4 ); addr +=5 ;break ;
@@ -893,8 +885,8 @@ addr +=6 ;break ;default : -iounmap (io_mem); -return -ENODEV ; + rc = -ENODEV ; + goto error_no_hp_slot; }//reorganize chassis' linked list
@@ -910,79 +902,71 @@ hp_slot_ptr = (struct hotplug_slot *)kmalloc (sizeof (struct hotplug_slot ),GFP_KERNEL );if (!hp_slot_ptr) { -iounmap (io_mem); -return -ENOMEM ; + rc = -ENOMEM ; + goto error_no_hp_slot; }memset (hp_slot_ptr,0 ,sizeof (struct hotplug_slot )); hp_slot_ptr->info = (struct hotplug_slot_info *)kmalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL );if (!hp_slot_ptr->info) { -iounmap (io_mem); -kfree (hp_slot_ptr); -return -ENOMEM ; + rc = -ENOMEM ; + goto error_no_hp_info; }memset (hp_slot_ptr->info,0 ,sizeof (struct hotplug_slot_info )); hp_slot_ptr->name = (char *)kmalloc (30 ,GFP_KERNEL );if (!hp_slot_ptr->name) { -iounmap (io_mem); -kfree (hp_slot_ptr->info); -kfree (hp_slot_ptr); -return -ENOMEM ; + rc = -ENOMEM ; + goto error_no_hp_name; } - hp_slot_ptr->private =alloc_ibm_slot (); -if (!hp_slot_ptr->private) { -iounmap (io_mem); -kfree (hp_slot_ptr->name); -kfree (hp_slot_ptr->info); -kfree (hp_slot_ptr); -return -ENOMEM ; + tmp_slot =kmalloc (sizeof (struct slot ),GFP_KERNEL ); +if (!tmp_slot) { + rc = -ENOMEM ; + goto error_no_slot; } +memset (tmp_slot,0 ,sizeof (*tmp_slot)); - ((struct slot *)hp_slot_ptr->private)->flag = TRUE; + tmp_slot->flag = TRUE; - ((struct slot *) hp_slot_ptr->private)->capabilities = hpc_ptr->slots[index].slot_cap; + tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap;if ((hpc_ptr->slots[index].slot_cap &EBDA_SLOT_133_MAX ) ==EBDA_SLOT_133_MAX ) - ((struct slot *) hp_slot_ptr->private)->supported_speed =3 ; + tmp_slot->supported_speed =3 ;else if ((hpc_ptr->slots[index].slot_cap &EBDA_SLOT_100_MAX ) ==EBDA_SLOT_100_MAX ) - ((struct slot *) hp_slot_ptr->private)->supported_speed =2 ; + tmp_slot->supported_speed =2 ;else if ((hpc_ptr->slots[index].slot_cap &EBDA_SLOT_66_MAX ) ==EBDA_SLOT_66_MAX ) - ((struct slot *) hp_slot_ptr->private)->supported_speed =1 ; + tmp_slot->supported_speed =1 ;if ((hpc_ptr->slots[index].slot_cap &EBDA_SLOT_PCIX_CAP ) ==EBDA_SLOT_PCIX_CAP ) - ((struct slot *) hp_slot_ptr->private)->supported_bus_mode =1 ; + tmp_slot->supported_bus_mode =1 ;else - ((struct slot *) hp_slot_ptr->private)->supported_bus_mode =0 ; + tmp_slot->supported_bus_mode =0 ; - ((struct slot *) hp_slot_ptr->private)->bus = hpc_ptr->slots[index].slot_bus_num; + tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num; bus_info_ptr1 =ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num);if (!bus_info_ptr1) { -iounmap (io_mem); -return -ENODEV ; + rc = -ENODEV ; + goto error; } - ((struct slot *) hp_slot_ptr->private)->bus_on = bus_info_ptr1; + tmp_slot->bus_on = bus_info_ptr1; bus_info_ptr1 =NULL ; - ((struct slot *) hp_slot_ptr->private)->ctrl = hpc_ptr; + tmp_slot->ctrl = hpc_ptr; + tmp_slot->ctlr_index = hpc_ptr->slots[index].ctl_index; + tmp_slot->number = hpc_ptr->slots[index].slot_num; + tmp_slot->hotplug_slot = hp_slot_ptr; + + hp_slot_ptr->private = tmp_slot; - ((struct slot *) hp_slot_ptr->private)->ctlr_index = hpc_ptr->slots[index].ctl_index; - ((struct slot *) hp_slot_ptr->private)->number = hpc_ptr->slots[index].slot_num; - - ((struct slot *) hp_slot_ptr->private)->hotplug_slot = hp_slot_ptr; rc =ibmphp_hpc_fillhpslotinfo (hp_slot_ptr); -if (rc) { -iounmap (io_mem); -return rc; - } +if (rc) + goto error; rc =ibmphp_init_devno ((struct slot **) &hp_slot_ptr->private); -if (rc) { -iounmap (io_mem); -return rc; - } +if (rc) + goto error; hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops;// end of registering ibm slot with hotplug core
@@ -996,15 +980,29 @@ }/* each hpc */ list_for_each (list, &ibmphp_slot_head) { - slot_cur = list_entry (list, struct slot, ibm_slot_list); + tmp_slot = list_entry (list, struct slot, ibm_slot_list); -snprintf (slot_cur->hotplug_slot->name,30 ,"%s" ,create_file_name (slot_cur)); -pci_hp_register (slot_cur->hotplug_slot); +snprintf (tmp_slot->hotplug_slot->name,30 ,"%s" ,create_file_name (tmp_slot)); +pci_hp_register (tmp_slot->hotplug_slot); }print_ebda_hpc ();print_ibm_slot ();return 0 ; + +error: +kfree (hp_slot_ptr->private); +error_no_slot: +kfree (hp_slot_ptr->name); +error_no_hp_name: +kfree (hp_slot_ptr->info); +error_no_hp_info: +kfree (hp_slot_ptr); +error_no_hp_slot: +free_ebda_hpc (hpc_ptr); +error_no_hpc: +iounmap (io_mem); +return rc; }/*
ChangeSet 1.970, 2003/02/06 14:49:36+11:00, [email protected]
sysfs: remember to add EXPORT_SYMBOL() for sysfs_update_file.
fs/sysfs/inode.c +1 -0
@@ -855,6 +855,7 @@ }EXPORT_SYMBOL (sysfs_create_file); +EXPORT_SYMBOL (sysfs_update_file);EXPORT_SYMBOL (sysfs_remove_file);EXPORT_SYMBOL (sysfs_create_link);EXPORT_SYMBOL (sysfs_remove_link);