Commit 7ab60fc1 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[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
parent e189d815
......@@ -37,7 +37,6 @@
#include <linux/init.h>
#include "pci_hotplug.h"
struct slot {
u8 number;
struct hotplug_slot *hotplug_slot;
......@@ -64,7 +63,7 @@ static LIST_HEAD(slot_list);
static int debug;
static int num_slots;
#define DRIVER_VERSION "0.2"
#define DRIVER_VERSION "0.3"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
#define DRIVER_DESC "Hot Plug PCI Controller Skeleton Driver"
......@@ -156,10 +155,15 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
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 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
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 @@ static void release_slots(struct hotplug_slot *hotplug_slot)
}
#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 @@ static void __init make_slot_name(struct slot *slot)
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 @@ static int __init init_slots(void)
* 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 @@ static int __init init_slots(void)
}
/* 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 @@ static void __exit cleanup_slots(void)
* 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 @@ static int __init pcihp_skel_init(void)
{
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 @@ static void __exit pcihp_skel_exit(void)
module_init(pcihp_skel_init);
module_exit(pcihp_skel_exit);
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