aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pcihp_skeleton.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/pcihp_skeleton.c')
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c33
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
40struct slot { 41struct 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
46static LIST_HEAD(slot_list); 48static 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
242static void make_slot_name(struct slot *slot) 242static 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;
320error_name:
321 kfree(name);
322error_info: 311error_info:
323 kfree(info); 312 kfree(info);
324error_hpslot: 313error_hpslot: