lp486e.c: check region removal
PATCH 1/1 lp486e.c: check region removal
Hi all,
patch for lp486e.c network driver attached.
Changes: check_region() call removed, added missing __init and __exit.
Best regards.
Signature · 2 lines
Andrey Panin | Embedded systems software engineer [email protected] | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
linux/drivers/net/lp486e.c renamed from drivers/net/lp486e.c +17 -12
@@ -971,16 +971,17 @@volatile struct i596_private *lp;unsigned char eth_addr[6 ] = {0 ,0xaa ,0 ,0 ,0 ,0 };unsigned char *bios; -int i,j; -static int probed =0 ; +int i, j; +int ret = -ENOMEM ; +static int probed;if (probed)return -ENODEV ; probed++; -if (check_region (IOADDR ,LP486E_TOTAL_SIZE )) { -printk ("lp486e: IO address 0x%x in use\n" ,IOADDR ); -return -ENODEV ; +if (!request_region (IOADDR ,LP486E_TOTAL_SIZE , dev->name)) { +printk (KERN_ERR "lp486e: IO address 0x%x in use\n" ,IOADDR ); +return -EBUSY ; }/*
@@ -989,7 +990,7 @@ dev->mem_start = (unsigned long )kmalloc (sizeof (struct i596_private ) +0x0f ,GFP_KERNEL );if (!dev->mem_start) -return -ENOMEM ; + goto err_out; dev->priv = (void *)((dev->mem_start +0xf ) &0xfffffff0 ); lp = (struct i596_private *) dev->priv;memset ((void *)lp,0 ,sizeof (struct i596_private ));
@@ -998,12 +999,10 @@* Do we really have this thing? */ if (i596_scp_setup (dev)) { -kfree ((void *) dev->mem_start); -return -ENODEV ; + ret = -ENODEV ; + goto err_out_kfree; } -request_region (IOADDR ,LP486E_TOTAL_SIZE ,"lp486e" ); - dev->base_addr =IOADDR ; dev->irq =IRQ ;
@@ -1053,6 +1052,12 @@i596_port_do (dev,PORT_DUMP ,"dump" );#endif return 0 ; + +err_out_kfree: +kfree ((void *) dev->mem_start); +err_out: +release_region (IOADDR ,LP486E_TOTAL_SIZE ); +return ret; } static void inline
@@ -1330,7 +1335,7 @@static int io =IOADDR ;static int irq =IRQ ; -static int lp486e_init_module (void ) { +static int __init lp486e_init_module (void ) {struct net_device *dev = &dev_lp486e; dev->irq = irq; dev->base_addr = io;
@@ -1342,7 +1347,7 @@return 0 ; } -static void lp486e_cleanup_module (void ) { +static void __exit lp486e_cleanup_module(void) {unregister_netdev (&dev_lp486e);kfree ((void *)dev_lp486e.mem_start); dev_lp486e.priv =NULL ;