diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-03-18 19:21:22 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 11:01:01 -0400 |
commit | 1e2b980fdfb6189baa779ba7de93f7dba70aa3fd (patch) | |
tree | cd3188ada5197acb52c8322b560915524c797f16 /drivers/net/mipsnet.c | |
parent | a5f8f3b6c91b07ee9aa2445a92a1d6c00a71a3cd (diff) |
MIPSnet: Modernize use platform_device API.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/mipsnet.c')
-rw-r--r-- | drivers/net/mipsnet.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c index 403f63afd201..638a279ec505 100644 --- a/drivers/net/mipsnet.c +++ b/drivers/net/mipsnet.c | |||
@@ -26,8 +26,6 @@ struct mipsnet_priv { | |||
26 | struct net_device_stats stats; | 26 | struct net_device_stats stats; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | static struct platform_device *mips_plat_dev; | ||
30 | |||
31 | static char mipsnet_string[] = "mipsnet"; | 29 | static char mipsnet_string[] = "mipsnet"; |
32 | 30 | ||
33 | /* | 31 | /* |
@@ -297,64 +295,17 @@ static struct device_driver mipsnet_driver = { | |||
297 | .remove = __devexit_p(mipsnet_device_remove), | 295 | .remove = __devexit_p(mipsnet_device_remove), |
298 | }; | 296 | }; |
299 | 297 | ||
300 | static void mipsnet_platform_release(struct device *device) | ||
301 | { | ||
302 | struct platform_device *pldev; | ||
303 | |||
304 | /* free device */ | ||
305 | pldev = to_platform_device(device); | ||
306 | kfree(pldev); | ||
307 | } | ||
308 | |||
309 | static int __init mipsnet_init_module(void) | 298 | static int __init mipsnet_init_module(void) |
310 | { | 299 | { |
311 | struct platform_device *pldev; | ||
312 | int err; | 300 | int err; |
313 | 301 | ||
314 | printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. " | 302 | printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. " |
315 | "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION); | 303 | "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION); |
316 | 304 | ||
317 | if (driver_register(&mipsnet_driver)) { | 305 | err = driver_register(&mipsnet_driver); |
306 | if (err) | ||
318 | printk(KERN_ERR "Driver registration failed\n"); | 307 | printk(KERN_ERR "Driver registration failed\n"); |
319 | err = -ENODEV; | ||
320 | goto out; | ||
321 | } | ||
322 | |||
323 | if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) { | ||
324 | err = -ENOMEM; | ||
325 | goto out_unregister_driver; | ||
326 | } | ||
327 | |||
328 | memset (pldev, 0, sizeof (*pldev)); | ||
329 | pldev->name = mipsnet_string; | ||
330 | pldev->id = 0; | ||
331 | pldev->dev.release = mipsnet_platform_release; | ||
332 | 308 | ||
333 | if (platform_device_register(pldev)) { | ||
334 | err = -ENODEV; | ||
335 | goto out_free_pldev; | ||
336 | } | ||
337 | |||
338 | if (!pldev->dev.driver) { | ||
339 | /* | ||
340 | * The driver was not bound to this device, there was | ||
341 | * no hardware at this address. Unregister it, as the | ||
342 | * release fuction will take care of freeing the | ||
343 | * allocated structure | ||
344 | */ | ||
345 | platform_device_unregister (pldev); | ||
346 | } | ||
347 | |||
348 | mips_plat_dev = pldev; | ||
349 | |||
350 | return 0; | ||
351 | |||
352 | out_free_pldev: | ||
353 | kfree(pldev); | ||
354 | |||
355 | out_unregister_driver: | ||
356 | driver_unregister(&mipsnet_driver); | ||
357 | out: | ||
358 | return err; | 309 | return err; |
359 | } | 310 | } |
360 | 311 | ||