Commit 591eb992 authored by Stephen Hemminger's avatar Stephen Hemminger

[IRDA]: Convert sir to alloc_irdadev().

parent f414d1e6
...@@ -538,28 +538,6 @@ static int sirdev_close(struct net_device *ndev) ...@@ -538,28 +538,6 @@ static int sirdev_close(struct net_device *ndev)
/* ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- */
static int sirdev_init(struct net_device *ndev)
{
struct sir_dev *dev = ndev->priv;
SET_MODULE_OWNER(ndev);
/* Set up to be a normal IrDA network device driver */
irda_device_setup(ndev);
dev->flags = IFF_SIR | IFF_PIO;
/* Override the network functions we need to use */
ndev->hard_start_xmit = sirdev_hard_xmit;
ndev->open = sirdev_open;
ndev->stop = sirdev_close;
ndev->get_stats = sirdev_get_stats;
ndev->do_ioctl = sirdev_ioctl;
return 0;
}
struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *name) struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *name)
{ {
struct net_device *ndev; struct net_device *ndev;
...@@ -577,12 +555,12 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -577,12 +555,12 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
/* /*
* Allocate new instance of the device * Allocate new instance of the device
*/ */
dev = kmalloc(sizeof(*dev), GFP_KERNEL); ndev = alloc_irdadev(sizeof(*dev));
if (dev == NULL) { if (ndev == NULL) {
ERROR("%s - Can't allocate memory for IrDA control block!\n", __FUNCTION__); ERROR("%s - Can't allocate memory for IrDA control block!\n", __FUNCTION__);
goto out; goto out;
} }
memset(dev, 0, sizeof(*dev)); dev = ndev->priv;
irda_init_max_qos_capabilies(&dev->qos); irda_init_max_qos_capabilies(&dev->qos);
dev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|IR_115200; dev->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
...@@ -591,11 +569,6 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -591,11 +569,6 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
strncpy(dev->hwname, name, sizeof(dev->hwname)-1); strncpy(dev->hwname, name, sizeof(dev->hwname)-1);
ndev = kmalloc(sizeof(*ndev), GFP_KERNEL);
if (ndev == NULL)
goto out_freedev;
memset(ndev, 0, sizeof(*ndev));
atomic_set(&dev->enable_rx, 0); atomic_set(&dev->enable_rx, 0);
dev->tx_skb = NULL; dev->tx_skb = NULL;
...@@ -609,10 +582,17 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -609,10 +582,17 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
dev->drv = drv; dev->drv = drv;
dev->netdev = ndev; dev->netdev = ndev;
ndev->priv = (void *) dev; SET_MODULE_OWNER(ndev);
ndev->init = sirdev_init;
dev->flags = IFF_SIR | IFF_PIO;
/* Override the network functions we need to use */
ndev->hard_start_xmit = sirdev_hard_xmit;
ndev->open = sirdev_open;
ndev->stop = sirdev_close;
ndev->get_stats = sirdev_get_stats;
ndev->do_ioctl = sirdev_ioctl;
strcpy(ndev->name, "irda%d");
if (register_netdev(ndev)) { if (register_netdev(ndev)) {
ERROR("%s(), register_netdev() failed!\n", __FUNCTION__); ERROR("%s(), register_netdev() failed!\n", __FUNCTION__);
goto out_freenetdev; goto out_freenetdev;
...@@ -621,9 +601,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n ...@@ -621,9 +601,7 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
return dev; return dev;
out_freenetdev: out_freenetdev:
kfree(ndev); free_netdev(ndev);
out_freedev:
kfree(dev);
out: out:
return NULL; return NULL;
} }
...@@ -653,10 +631,9 @@ int sirdev_put_instance(struct sir_dev *dev) ...@@ -653,10 +631,9 @@ int sirdev_put_instance(struct sir_dev *dev)
up(&dev->fsm.sem); up(&dev->fsm.sem);
/* Remove netdevice */ /* Remove netdevice */
if (dev->netdev) unregister_netdev(dev->netdev);
unregister_netdev(dev->netdev);
kfree(dev); free_netdev(dev->netdev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment