@@ -93,6 +93,7 @@ static const char version[] =
9393#include <linux/errno.h>
9494#include <linux/init.h>
9595#include <linux/netdevice.h>
96+ #include <linux/platform_device.h>
9697#include <linux/etherdevice.h>
9798#include <linux/skbuff.h>
9899#include <linux/delay.h>
@@ -105,6 +106,10 @@ static const char version[] =
105106
106107#include "cs89x0.h"
107108
109+ static int debug ;
110+ module_param (debug , int , 0 );
111+ MODULE_PARM_DESC (debug , "CS89[02]0 debug level (0-5)" );
112+
108113static unsigned int net_debug = NET_DEBUG ;
109114
110115/* Information that need to be kept for each board. */
@@ -167,10 +172,9 @@ static const struct net_device_ops mac89x0_netdev_ops = {
167172
168173/* Probe for the CS8900 card in slot E. We won't bother looking
169174 anywhere else until we have a really good reason to do so. */
170- struct net_device * __init mac89x0_probe ( int unit )
175+ static int mac89x0_device_probe ( struct platform_device * pdev )
171176{
172177 struct net_device * dev ;
173- static int once_is_enough ;
174178 struct net_local * lp ;
175179 static unsigned version_printed ;
176180 int i , slot ;
@@ -180,21 +184,11 @@ struct net_device * __init mac89x0_probe(int unit)
180184 int err = - ENODEV ;
181185 struct nubus_rsrc * fres ;
182186
183- if (!MACH_IS_MAC )
184- return ERR_PTR (- ENODEV );
187+ net_debug = debug ;
185188
186189 dev = alloc_etherdev (sizeof (struct net_local ));
187190 if (!dev )
188- return ERR_PTR (- ENOMEM );
189-
190- if (unit >= 0 ) {
191- sprintf (dev -> name , "eth%d" , unit );
192- netdev_boot_setup_check (dev );
193- }
194-
195- if (once_is_enough )
196- goto out ;
197- once_is_enough = 1 ;
191+ return - ENOMEM ;
198192
199193 /* We might have to parameterize this later */
200194 slot = 0xE ;
@@ -221,6 +215,8 @@ struct net_device * __init mac89x0_probe(int unit)
221215 if (sig != swab16 (CHIP_EISA_ID_SIG ))
222216 goto out ;
223217
218+ SET_NETDEV_DEV (dev , & pdev -> dev );
219+
224220 /* Initialize the net_device structure. */
225221 lp = netdev_priv (dev );
226222
@@ -280,12 +276,14 @@ struct net_device * __init mac89x0_probe(int unit)
280276 err = register_netdev (dev );
281277 if (err )
282278 goto out1 ;
283- return NULL ;
279+
280+ platform_set_drvdata (pdev , dev );
281+ return 0 ;
284282out1 :
285283 nubus_writew (0 , dev -> base_addr + ADD_PORT );
286284out :
287285 free_netdev (dev );
288- return ERR_PTR ( err ) ;
286+ return err ;
289287}
290288
291289/* Open/initialize the board. This is called (in the current kernel)
@@ -571,32 +569,24 @@ static int set_mac_address(struct net_device *dev, void *addr)
571569 return 0 ;
572570}
573571
574- #ifdef MODULE
575-
576- static struct net_device * dev_cs89x0 ;
577- static int debug ;
578-
579- module_param (debug , int , 0 );
580- MODULE_PARM_DESC (debug , "CS89[02]0 debug level (0-5)" );
581572MODULE_LICENSE ("GPL" );
582573
583- int __init
584- init_module (void )
574+ static int mac89x0_device_remove (struct platform_device * pdev )
585575{
586- net_debug = debug ;
587- dev_cs89x0 = mac89x0_probe (-1 );
588- if (IS_ERR (dev_cs89x0 )) {
589- printk (KERN_WARNING "mac89x0.c: No card found\n" );
590- return PTR_ERR (dev_cs89x0 );
591- }
576+ struct net_device * dev = platform_get_drvdata (pdev );
577+
578+ unregister_netdev (dev );
579+ nubus_writew (0 , dev -> base_addr + ADD_PORT );
580+ free_netdev (dev );
592581 return 0 ;
593582}
594583
595- void
596- cleanup_module (void )
597- {
598- unregister_netdev (dev_cs89x0 );
599- nubus_writew (0 , dev_cs89x0 -> base_addr + ADD_PORT );
600- free_netdev (dev_cs89x0 );
601- }
602- #endif /* MODULE */
584+ static struct platform_driver mac89x0_platform_driver = {
585+ .probe = mac89x0_device_probe ,
586+ .remove = mac89x0_device_remove ,
587+ .driver = {
588+ .name = "mac89x0" ,
589+ },
590+ };
591+
592+ module_platform_driver (mac89x0_platform_driver );
0 commit comments