ChangeSet 1.1587.12.26, 2004/04/29 16:04:49-07:00, eike-hotplug@sf-tec.de [PATCH] PCI Hotplug skeleton: final cleanups Some final fixes for the skeleton driver: -spaces before opening brace -add a better example for hardware_test function -remove a "int retval" in a void function -some more coding style changes -changed enough stuff: increase version number -fix a typo in a comment drivers/pci/hotplug/pcihp_skeleton.c | 47 ++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 22 deletions(-) diff -Nru a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c --- a/drivers/pci/hotplug/pcihp_skeleton.c Mon May 17 17:03:54 2004 +++ b/drivers/pci/hotplug/pcihp_skeleton.c Mon May 17 17:03:54 2004 @@ -37,7 +37,6 @@ #include #include "pci_hotplug.h" - struct slot { u8 number; struct hotplug_slot *hotplug_slot; @@ -64,7 +63,7 @@ static int debug; static int num_slots; -#define DRIVER_VERSION "0.2" +#define DRIVER_VERSION "0.3" #define DRIVER_AUTHOR "Greg Kroah-Hartman " #define DRIVER_DESC "Hot Plug PCI Controller Skeleton Driver" @@ -156,10 +155,15 @@ dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); - retval = -ENODEV; + switch (value) { + case 0: + /* Specify a test here */ + break; + case 1: + /* Specify another test here */ + break; + } - /* Or specify a test if you have one */ - return retval; } @@ -223,10 +227,9 @@ return retval; } -static void release_slots(struct hotplug_slot *hotplug_slot) +static void release_slot(struct hotplug_slot *hotplug_slot) { struct slot *slot = hotplug_slot->private; - int retval = 0; dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); kfree(slot->hotplug_slot->info); @@ -236,7 +239,7 @@ } #define SLOT_NAME_SIZE 10 -static void __init make_slot_name(struct slot *slot) +static void make_slot_name(struct slot *slot) { /* * Stupid way to make a filename out of the slot name. @@ -245,6 +248,10 @@ snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", slot->number); } +/** + * init_slots - initialize 'struct slot' structures for each slot + * + */ static int __init init_slots(void) { struct slot *slot; @@ -259,18 +266,19 @@ * with the pci_hotplug subsystem. */ for (i = 0; i < num_slots; ++i) { - slot = kmalloc(sizeof (struct slot), GFP_KERNEL); + slot = kmalloc(sizeof(struct slot), GFP_KERNEL); if (!slot) goto error; memset(slot, 0, sizeof(struct slot)); - hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL); + hotplug_slot = kmalloc(sizeof(struct hotplug_slot), + GFP_KERNEL); if (!hotplug_slot) goto error_slot; memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); slot->hotplug_slot = hotplug_slot; - info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); + info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); if (!info) goto error_hpslot; memset(info, 0, sizeof (struct hotplug_slot_info)); @@ -305,7 +313,7 @@ } /* add slot to our internal list */ - list_add (&slot->slot_list, &slot_list); + list_add(&slot->slot_list, &slot_list); } return 0; @@ -332,9 +340,9 @@ * Memory will be freed in release_slot() callback after slot's * lifespan is finished. */ - list_for_each_safe (tmp, next, &slot_list) { + list_for_each_safe(tmp, next, &slot_list) { slot = list_entry(tmp, struct slot, slot_list); - list_del (&slot->slot_list); + list_del(&slot->slot_list); pci_hp_deregister(slot->hotplug_slot); } } @@ -343,20 +351,16 @@ { int retval; + info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); /* * Do specific initialization stuff for your driver here - * Like initilizing your controller hardware (if any) and + * Like initializing your controller hardware (if any) and * determining the number of slots you have in the system * right now. */ num_slots = 5; - retval = init_slots(); - if (retval) - return retval; - - info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); - return 0; + return init_slots(); } static void __exit pcihp_skel_exit(void) @@ -369,4 +373,3 @@ module_init(pcihp_skel_init); module_exit(pcihp_skel_exit); -