31 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/slab.h>
35 #include <linux/pci.h>
39 #define SLOT_NAME_SIZE 10
49 #define MY_NAME "pcihp_skeleton"
51 #define dbg(format, arg...) \
54 printk (KERN_DEBUG "%s: " format "\n", \
57 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
58 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
59 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
65 #define DRIVER_VERSION "0.3"
67 #define DRIVER_DESC "Hot Plug PCI Controller Skeleton Driver"
75 static int enable_slot (
struct hotplug_slot *
slot);
76 static int disable_slot (
struct hotplug_slot *
slot);
77 static int set_attention_status (
struct hotplug_slot *
slot,
u8 value);
78 static int hardware_test (
struct hotplug_slot *
slot,
u32 value);
79 static int get_power_status (
struct hotplug_slot *
slot,
u8 *
value);
80 static int get_attention_status (
struct hotplug_slot *
slot,
u8 *
value);
81 static int get_latch_status (
struct hotplug_slot *
slot,
u8 *
value);
82 static int get_adapter_status (
struct hotplug_slot *
slot,
u8 *
value);
95 static int enable_slot(
struct hotplug_slot *hotplug_slot)
97 struct slot *
slot = hotplug_slot->private;
100 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
111 struct slot *
slot = hotplug_slot->private;
114 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
125 struct slot *
slot = hotplug_slot->private;
128 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
148 static int hardware_test(
struct hotplug_slot *hotplug_slot,
u32 value)
150 struct slot *slot = hotplug_slot->private;
153 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
167 static int get_power_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
169 struct slot *slot = hotplug_slot->private;
172 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
182 static int get_attention_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
184 struct slot *slot = hotplug_slot->private;
187 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
197 static int get_latch_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
199 struct slot *slot = hotplug_slot->private;
202 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
212 static int get_adapter_status(
struct hotplug_slot *hotplug_slot,
u8 *value)
214 struct slot *slot = hotplug_slot->private;
217 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
227 static void release_slot(
struct hotplug_slot *hotplug_slot)
229 struct slot *slot = hotplug_slot->private;
231 dbg(
"%s - physical_slot = %s\n", __func__, hotplug_slot->name);
237 static void make_slot_name(
struct slot *slot)
250 static int __init init_slots(
void)
253 struct hotplug_slot *hotplug_slot;
269 hotplug_slot = kzalloc(
sizeof(*hotplug_slot),
GFP_KERNEL);
281 hotplug_slot->info =
info;
285 hotplug_slot->name = slot->
name;
286 hotplug_slot->private =
slot;
287 hotplug_slot->release = &release_slot;
288 make_slot_name(slot);
289 hotplug_slot->ops = &skel_hotplug_slot_ops;
300 dbg(
"registering slot %d\n", i);
303 err(
"pci_hp_register failed with error %d\n", retval);
322 static void __exit cleanup_slots(
void)
340 static int __init pcihp_skel_init(
void)
356 static void __exit pcihp_skel_exit(
void)