diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2006-01-25 20:01:35 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:11 -0500 |
commit | 287588b3537d0ce56a83f54d0e6ffcd60e54b569 (patch) | |
tree | 1c0747a10543f327de97ff90728bb445055423e4 /drivers/pci | |
parent | ef3be54777901e570185089f21fbe4498453f67e (diff) |
[PATCH] pcihp_skeleton.c cleanup
This patch cleans up pcihp_skelton.c as follows.
o Move slot name area into struct slot.
o Replace kmalloc with kzalloc and clean up the arg of sizeof()
o Fix the wrong use of get_*_status() functions.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/pcihp_skeleton.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c index 3194d51c6ec9..0a46f549676a 100644 --- a/drivers/pci/hotplug/pcihp_skeleton.c +++ b/drivers/pci/hotplug/pcihp_skeleton.c | |||
@@ -37,10 +37,12 @@ | |||
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include "pci_hotplug.h" | 38 | #include "pci_hotplug.h" |
39 | 39 | ||
40 | #define SLOT_NAME_SIZE 10 | ||
40 | struct slot { | 41 | struct slot { |
41 | u8 number; | 42 | u8 number; |
42 | struct hotplug_slot *hotplug_slot; | 43 | struct hotplug_slot *hotplug_slot; |
43 | struct list_head slot_list; | 44 | struct list_head slot_list; |
45 | char name[SLOT_NAME_SIZE]; | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | static LIST_HEAD(slot_list); | 48 | static LIST_HEAD(slot_list); |
@@ -233,12 +235,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot) | |||
233 | 235 | ||
234 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); | 236 | dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); |
235 | kfree(slot->hotplug_slot->info); | 237 | kfree(slot->hotplug_slot->info); |
236 | kfree(slot->hotplug_slot->name); | ||
237 | kfree(slot->hotplug_slot); | 238 | kfree(slot->hotplug_slot); |
238 | kfree(slot); | 239 | kfree(slot); |
239 | } | 240 | } |
240 | 241 | ||
241 | #define SLOT_NAME_SIZE 10 | ||
242 | static void make_slot_name(struct slot *slot) | 242 | static void make_slot_name(struct slot *slot) |
243 | { | 243 | { |
244 | /* | 244 | /* |
@@ -257,7 +257,6 @@ static int __init init_slots(void) | |||
257 | struct slot *slot; | 257 | struct slot *slot; |
258 | struct hotplug_slot *hotplug_slot; | 258 | struct hotplug_slot *hotplug_slot; |
259 | struct hotplug_slot_info *info; | 259 | struct hotplug_slot_info *info; |
260 | char *name; | ||
261 | int retval = -ENOMEM; | 260 | int retval = -ENOMEM; |
262 | int i; | 261 | int i; |
263 | 262 | ||
@@ -266,31 +265,23 @@ static int __init init_slots(void) | |||
266 | * with the pci_hotplug subsystem. | 265 | * with the pci_hotplug subsystem. |
267 | */ | 266 | */ |
268 | for (i = 0; i < num_slots; ++i) { | 267 | for (i = 0; i < num_slots; ++i) { |
269 | slot = kmalloc(sizeof(struct slot), GFP_KERNEL); | 268 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); |
270 | if (!slot) | 269 | if (!slot) |
271 | goto error; | 270 | goto error; |
272 | memset(slot, 0, sizeof(struct slot)); | ||
273 | 271 | ||
274 | hotplug_slot = kmalloc(sizeof(struct hotplug_slot), | 272 | hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); |
275 | GFP_KERNEL); | ||
276 | if (!hotplug_slot) | 273 | if (!hotplug_slot) |
277 | goto error_slot; | 274 | goto error_slot; |
278 | memset(hotplug_slot, 0, sizeof (struct hotplug_slot)); | ||
279 | slot->hotplug_slot = hotplug_slot; | 275 | slot->hotplug_slot = hotplug_slot; |
280 | 276 | ||
281 | info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); | 277 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
282 | if (!info) | 278 | if (!info) |
283 | goto error_hpslot; | 279 | goto error_hpslot; |
284 | memset(info, 0, sizeof (struct hotplug_slot_info)); | ||
285 | hotplug_slot->info = info; | 280 | hotplug_slot->info = info; |
286 | 281 | ||
287 | name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); | ||
288 | if (!name) | ||
289 | goto error_info; | ||
290 | hotplug_slot->name = name; | ||
291 | |||
292 | slot->number = i; | 282 | slot->number = i; |
293 | 283 | ||
284 | hotplug_slot->name = slot->name; | ||
294 | hotplug_slot->private = slot; | 285 | hotplug_slot->private = slot; |
295 | hotplug_slot->release = &release_slot; | 286 | hotplug_slot->release = &release_slot; |
296 | make_slot_name(slot); | 287 | make_slot_name(slot); |
@@ -300,16 +291,16 @@ static int __init init_slots(void) | |||
300 | * Initialize the slot info structure with some known | 291 | * Initialize the slot info structure with some known |
301 | * good values. | 292 | * good values. |
302 | */ | 293 | */ |
303 | info->power_status = get_power_status(slot); | 294 | get_power_status(hotplug_slot, &info->power_status); |
304 | info->attention_status = get_attention_status(slot); | 295 | get_attention_status(hotplug_slot, &info->attention_status); |
305 | info->latch_status = get_latch_status(slot); | 296 | get_latch_status(hotplug_slot, &info->latch_status); |
306 | info->adapter_status = get_adapter_status(slot); | 297 | get_adapter_status(hotplug_slot, &info->adapter_status); |
307 | 298 | ||
308 | dbg("registering slot %d\n", i); | 299 | dbg("registering slot %d\n", i); |
309 | retval = pci_hp_register(slot->hotplug_slot); | 300 | retval = pci_hp_register(slot->hotplug_slot); |
310 | if (retval) { | 301 | if (retval) { |
311 | err("pci_hp_register failed with error %d\n", retval); | 302 | err("pci_hp_register failed with error %d\n", retval); |
312 | goto error_name; | 303 | goto error_info; |
313 | } | 304 | } |
314 | 305 | ||
315 | /* add slot to our internal list */ | 306 | /* add slot to our internal list */ |
@@ -317,8 +308,6 @@ static int __init init_slots(void) | |||
317 | } | 308 | } |
318 | 309 | ||
319 | return 0; | 310 | return 0; |
320 | error_name: | ||
321 | kfree(name); | ||
322 | error_info: | 311 | error_info: |
323 | kfree(info); | 312 | kfree(info); |
324 | error_hpslot: | 313 | error_hpslot: |