Commit aed0b60e authored by David S. Miller's avatar David S. Miller

Merge nuts.ninka.net:/home/davem/src/BK/network-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 5c9e7fc0 599d98aa
...@@ -795,7 +795,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -795,7 +795,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
memset(catc, 0, sizeof(struct catc)); memset(catc, 0, sizeof(struct catc));
netdev = init_etherdev(0, 0); netdev = alloc_etherdev(0);
if (!netdev) { if (!netdev) {
kfree(catc); kfree(catc);
return -EIO; return -EIO;
...@@ -933,6 +933,17 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -933,6 +933,17 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
for (i = 0; i < 5; i++) printk("%2.2x:", netdev->dev_addr[i]); for (i = 0; i < 5; i++) printk("%2.2x:", netdev->dev_addr[i]);
printk("%2.2x.\n", netdev->dev_addr[i]); printk("%2.2x.\n", netdev->dev_addr[i]);
usb_set_intfdata(intf, catc); usb_set_intfdata(intf, catc);
if (register_netdev(netdev) != 0) {
usb_set_intfdata(intf, NULL);
usb_free_urb(catc->ctrl_urb);
usb_free_urb(catc->tx_urb);
usb_free_urb(catc->rx_urb);
usb_free_urb(catc->irq_urb);
kfree(netdev);
kfree(catc);
return -EIO;
}
return 0; return 0;
} }
......
...@@ -1216,7 +1216,7 @@ static int CDCEther_probe( struct usb_interface *intf, ...@@ -1216,7 +1216,7 @@ static int CDCEther_probe( struct usb_interface *intf,
} }
// Now we need to get a kernel Ethernet interface. // Now we need to get a kernel Ethernet interface.
net = init_etherdev( NULL, 0 ); net = alloc_etherdev(0);
if ( !net ) { if ( !net ) {
// Hmm... The kernel is not sharing today... // Hmm... The kernel is not sharing today...
// Fine, we didn't want it anyway... // Fine, we didn't want it anyway...
...@@ -1263,6 +1263,11 @@ static int CDCEther_probe( struct usb_interface *intf, ...@@ -1263,6 +1263,11 @@ static int CDCEther_probe( struct usb_interface *intf,
// TODO - last minute HACK // TODO - last minute HACK
ether_dev->comm_ep_in = 5; ether_dev->comm_ep_in = 5;
if (register_netdev(net) != 0) {
usb_put_dev(usb);
goto out;
}
/* FIXME!!! This driver needs to be fixed to work with the new USB interface logic /* FIXME!!! This driver needs to be fixed to work with the new USB interface logic
* this is not the correct thing to be doing here, we need to set the interface * this is not the correct thing to be doing here, we need to set the interface
* driver specific data field. * driver specific data field.
...@@ -1270,6 +1275,13 @@ static int CDCEther_probe( struct usb_interface *intf, ...@@ -1270,6 +1275,13 @@ static int CDCEther_probe( struct usb_interface *intf,
// Okay, we are finally done... // Okay, we are finally done...
return 0; return 0;
out:
usb_driver_release_interface( &CDCEther_driver,
&(usb->config[ether_dev->configuration_num].interface[ether_dev->comm_interface]) );
usb_driver_release_interface( &CDCEther_driver,
&(usb->config[ether_dev->configuration_num].interface[ether_dev->data_interface]) );
// bailing out with our tail between our knees // bailing out with our tail between our knees
error_all: error_all:
usb_free_urb(ether_dev->tx_urb); usb_free_urb(ether_dev->tx_urb);
......
...@@ -1016,7 +1016,7 @@ static int kaweth_probe( ...@@ -1016,7 +1016,7 @@ static int kaweth_probe(
kaweth_dbg("Initializing net device."); kaweth_dbg("Initializing net device.");
if(!(netdev = kmalloc(sizeof(struct net_device), GFP_KERNEL))) { if (!(netdev = alloc_etherdev(0))) {
kfree(kaweth); kfree(kaweth);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1054,18 +1054,21 @@ static int kaweth_probe( ...@@ -1054,18 +1054,21 @@ static int kaweth_probe(
SET_MODULE_OWNER(netdev); SET_MODULE_OWNER(netdev);
if (!init_etherdev(netdev, 0)) { usb_set_intfdata(intf, kaweth);
if (register_netdev(netdev) != 0) {
kaweth_err("Error calling init_etherdev."); kaweth_err("Error calling init_etherdev.");
goto err_tx_and_rx; goto err_intfdata;
} }
kaweth_info("kaweth interface created at %s", kaweth->net->name); kaweth_info("kaweth interface created at %s", kaweth->net->name);
kaweth_dbg("Kaweth probe returning."); kaweth_dbg("Kaweth probe returning.");
usb_set_intfdata(intf, kaweth);
return 0; return 0;
err_intfdata:
usb_set_intfdata(intf, NULL);
err_tx_and_rx: err_tx_and_rx:
usb_free_urb(kaweth->rx_urb); usb_free_urb(kaweth->rx_urb);
err_only_tx: err_only_tx:
...@@ -1113,6 +1116,7 @@ static void kaweth_disconnect(struct usb_interface *intf) ...@@ -1113,6 +1116,7 @@ static void kaweth_disconnect(struct usb_interface *intf)
kaweth_dbg("Unregistering net device"); kaweth_dbg("Unregistering net device");
unregister_netdev(kaweth->net); unregister_netdev(kaweth->net);
kfree(kaweth->net);
} }
usb_free_urb(kaweth->rx_urb); usb_free_urb(kaweth->rx_urb);
......
...@@ -865,8 +865,6 @@ static int pegasus_open(struct net_device *net) ...@@ -865,8 +865,6 @@ static int pegasus_open(struct net_device *net)
if (!pegasus->rx_skb) if (!pegasus->rx_skb)
return -ENOMEM; return -ENOMEM;
down(&pegasus->sem);
set_registers(pegasus, EthID, 6, net->dev_addr); set_registers(pegasus, EthID, 6, net->dev_addr);
usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
...@@ -894,8 +892,6 @@ static int pegasus_open(struct net_device *net) ...@@ -894,8 +892,6 @@ static int pegasus_open(struct net_device *net)
set_carrier(net); set_carrier(net);
res = 0; res = 0;
exit: exit:
up(&pegasus->sem);
return res; return res;
} }
...@@ -903,13 +899,11 @@ static int pegasus_close(struct net_device *net) ...@@ -903,13 +899,11 @@ static int pegasus_close(struct net_device *net)
{ {
pegasus_t *pegasus = net->priv; pegasus_t *pegasus = net->priv;
down(&pegasus->sem);
pegasus->flags &= ~PEGASUS_RUNNING; pegasus->flags &= ~PEGASUS_RUNNING;
netif_stop_queue(net); netif_stop_queue(net);
if (!(pegasus->flags & PEGASUS_UNPLUG)) if (!(pegasus->flags & PEGASUS_UNPLUG))
disable_net_traffic(pegasus); disable_net_traffic(pegasus);
unlink_all_urbs(pegasus); unlink_all_urbs(pegasus);
up(&pegasus->sem);
return 0; return 0;
} }
...@@ -1068,7 +1062,6 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ...@@ -1068,7 +1062,6 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
pegasus_t *pegasus = net->priv; pegasus_t *pegasus = net->priv;
int res; int res;
down(&pegasus->sem);
switch (cmd) { switch (cmd) {
case SIOCETHTOOL: case SIOCETHTOOL:
res = pegasus_ethtool_ioctl(net, rq->ifr_data); res = pegasus_ethtool_ioctl(net, rq->ifr_data);
...@@ -1080,17 +1073,14 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ...@@ -1080,17 +1073,14 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
res = 0; res = 0;
break; break;
case SIOCDEVPRIVATE + 2: case SIOCDEVPRIVATE + 2:
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN))
up(&pegasus->sem);
return -EPERM; return -EPERM;
}
write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, data[2]); write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, data[2]);
res = 0; res = 0;
break; break;
default: default:
res = -EOPNOTSUPP; res = -EOPNOTSUPP;
} }
up(&pegasus->sem);
return res; return res;
} }
...@@ -1170,33 +1160,27 @@ static int pegasus_probe(struct usb_interface *intf, ...@@ -1170,33 +1160,27 @@ static int pegasus_probe(struct usb_interface *intf,
struct net_device *net; struct net_device *net;
pegasus_t *pegasus; pegasus_t *pegasus;
int dev_index = id - pegasus_ids; int dev_index = id - pegasus_ids;
int res = -ENOMEM;
usb_get_dev(dev);
if (!(pegasus = kmalloc(sizeof (struct pegasus), GFP_KERNEL))) { if (!(pegasus = kmalloc(sizeof (struct pegasus), GFP_KERNEL))) {
err("out of memory allocating device structure"); err("out of memory allocating device structure");
return -ENOMEM; goto out;
} }
usb_get_dev(dev);
memset(pegasus, 0, sizeof (struct pegasus)); memset(pegasus, 0, sizeof (struct pegasus));
pegasus->dev_index = dev_index; pegasus->dev_index = dev_index;
init_waitqueue_head(&pegasus->ctrl_wait); init_waitqueue_head(&pegasus->ctrl_wait);
if (!alloc_urbs(pegasus)) { if (!alloc_urbs(pegasus))
kfree(pegasus); goto out1;
return -ENOMEM;
}
net = init_etherdev(NULL, 0); net = alloc_etherdev(0);
if (!net) { if (!net)
free_all_urbs(pegasus); goto out2;
kfree(pegasus);
return -ENODEV;
}
init_MUTEX(&pegasus->sem);
tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
down(&pegasus->sem);
pegasus->usb = dev; pegasus->usb = dev;
pegasus->net = net; pegasus->net = net;
SET_MODULE_OWNER(net); SET_MODULE_OWNER(net);
...@@ -1221,12 +1205,8 @@ static int pegasus_probe(struct usb_interface *intf, ...@@ -1221,12 +1205,8 @@ static int pegasus_probe(struct usb_interface *intf,
get_interrupt_interval(pegasus); get_interrupt_interval(pegasus);
if (reset_mac(pegasus)) { if (reset_mac(pegasus)) {
err("can't reset MAC"); err("can't reset MAC");
unregister_netdev(pegasus->net); res = -EIO;
free_all_urbs(pegasus); goto out3;
kfree(pegasus->net);
kfree(pegasus);
pegasus = NULL;
goto exit;
} }
set_ethernet_addr(pegasus); set_ethernet_addr(pegasus);
fill_skb_pool(pegasus); fill_skb_pool(pegasus);
...@@ -1240,13 +1220,24 @@ static int pegasus_probe(struct usb_interface *intf, ...@@ -1240,13 +1220,24 @@ static int pegasus_probe(struct usb_interface *intf,
warn("can't locate MII phy, using default"); warn("can't locate MII phy, using default");
pegasus->phy = 1; pegasus->phy = 1;
} }
exit: usb_set_intfdata(intf, pegasus);
up(&pegasus->sem); res = register_netdev(net);
if (pegasus) { if (res)
usb_set_intfdata(intf, pegasus); goto out4;
return 0; return 0;
}
return -EIO; out4:
usb_set_intfdata(intf, NULL);
free_skb_pool(pegasus);
out3:
kfree(net);
out2:
free_all_urbs(pegasus);
out1:
kfree(pegasus);
out:
usb_put_dev(dev);
return res;
} }
static void pegasus_disconnect(struct usb_interface *intf) static void pegasus_disconnect(struct usb_interface *intf)
...@@ -1269,7 +1260,6 @@ static void pegasus_disconnect(struct usb_interface *intf) ...@@ -1269,7 +1260,6 @@ static void pegasus_disconnect(struct usb_interface *intf)
dev_kfree_skb(pegasus->rx_skb); dev_kfree_skb(pegasus->rx_skb);
kfree(pegasus->net); kfree(pegasus->net);
kfree(pegasus); kfree(pegasus);
pegasus = NULL;
} }
static struct usb_driver pegasus_driver = { static struct usb_driver pegasus_driver = {
......
...@@ -98,7 +98,6 @@ typedef struct pegasus { ...@@ -98,7 +98,6 @@ typedef struct pegasus {
struct sk_buff *rx_skb; struct sk_buff *rx_skb;
struct usb_ctrlrequest dr; struct usb_ctrlrequest dr;
wait_queue_head_t ctrl_wait; wait_queue_head_t ctrl_wait;
struct semaphore sem;
spinlock_t rx_pool_lock; spinlock_t rx_pool_lock;
int chip; int chip;
unsigned char intr_buff[8]; unsigned char intr_buff[8];
......
...@@ -88,7 +88,6 @@ MODULE_DEVICE_TABLE(usb, rtl8150_table); ...@@ -88,7 +88,6 @@ MODULE_DEVICE_TABLE(usb, rtl8150_table);
struct rtl8150 { struct rtl8150 {
unsigned long flags; unsigned long flags;
struct usb_device *udev; struct usb_device *udev;
struct semaphore sem;
struct tasklet_struct tl; struct tasklet_struct tl;
struct net_device_stats stats; struct net_device_stats stats;
struct net_device *netdev; struct net_device *netdev;
...@@ -638,8 +637,6 @@ static int rtl8150_open(struct net_device *netdev) ...@@ -638,8 +637,6 @@ static int rtl8150_open(struct net_device *netdev)
if (!dev->rx_skb) if (!dev->rx_skb)
return -ENOMEM; return -ENOMEM;
down(&dev->sem);
set_registers(dev, IDR, 6, netdev->dev_addr); set_registers(dev, IDR, 6, netdev->dev_addr);
usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
...@@ -653,7 +650,6 @@ static int rtl8150_open(struct net_device *netdev) ...@@ -653,7 +650,6 @@ static int rtl8150_open(struct net_device *netdev)
warn("%s: intr_urb submit failed: %d", __FUNCTION__, res); warn("%s: intr_urb submit failed: %d", __FUNCTION__, res);
netif_start_queue(netdev); netif_start_queue(netdev);
enable_net_traffic(dev); enable_net_traffic(dev);
up(&dev->sem);
return res; return res;
} }
...@@ -667,12 +663,10 @@ static int rtl8150_close(struct net_device *netdev) ...@@ -667,12 +663,10 @@ static int rtl8150_close(struct net_device *netdev)
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
down(&dev->sem);
netif_stop_queue(netdev); netif_stop_queue(netdev);
if (!test_bit(RTL8150_UNPLUG, &dev->flags)) if (!test_bit(RTL8150_UNPLUG, &dev->flags))
disable_net_traffic(dev); disable_net_traffic(dev);
unlink_all_urbs(dev); unlink_all_urbs(dev);
up(&dev->sem);
return res; return res;
} }
...@@ -760,7 +754,6 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ...@@ -760,7 +754,6 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
data = (u16 *) & rq->ifr_data; data = (u16 *) & rq->ifr_data;
res = 0; res = 0;
down(&dev->sem);
switch (cmd) { switch (cmd) {
case SIOCETHTOOL: case SIOCETHTOOL:
res = rtl8150_ethtool_ioctl(netdev, rq->ifr_data); res = rtl8150_ethtool_ioctl(netdev, rq->ifr_data);
...@@ -771,16 +764,13 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ...@@ -771,16 +764,13 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]); read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]);
break; break;
case SIOCDEVPRIVATE + 2: case SIOCDEVPRIVATE + 2:
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN))
up(&dev->sem);
return -EPERM; return -EPERM;
}
write_mii_word(dev, dev->phy, (data[1] & 0x1f), data[2]); write_mii_word(dev, dev->phy, (data[1] & 0x1f), data[2]);
break; break;
default: default:
res = -EOPNOTSUPP; res = -EOPNOTSUPP;
} }
up(&dev->sem);
return res; return res;
} }
...@@ -798,18 +788,16 @@ static int rtl8150_probe(struct usb_interface *intf, ...@@ -798,18 +788,16 @@ static int rtl8150_probe(struct usb_interface *intf,
} else } else
memset(dev, 0, sizeof(rtl8150_t)); memset(dev, 0, sizeof(rtl8150_t));
netdev = init_etherdev(NULL, 0); netdev = alloc_etherdev(0);
if (!netdev) { if (!netdev) {
kfree(dev); kfree(dev);
err("Oh boy, out of memory again?!?"); err("Oh boy, out of memory again?!?");
return -ENOMEM; return -ENOMEM;
} }
init_MUTEX(&dev->sem);
tasklet_init(&dev->tl, rx_fixup, (unsigned long)dev); tasklet_init(&dev->tl, rx_fixup, (unsigned long)dev);
spin_lock_init(&dev->rx_pool_lock); spin_lock_init(&dev->rx_pool_lock);
down(&dev->sem);
dev->udev = udev; dev->udev = udev;
dev->netdev = netdev; dev->netdev = netdev;
SET_MODULE_OWNER(netdev); SET_MODULE_OWNER(netdev);
...@@ -828,23 +816,30 @@ static int rtl8150_probe(struct usb_interface *intf, ...@@ -828,23 +816,30 @@ static int rtl8150_probe(struct usb_interface *intf,
if (!alloc_all_urbs(dev)) { if (!alloc_all_urbs(dev)) {
err("out of memory"); err("out of memory");
goto err; goto out;
} }
if (!rtl8150_reset(dev)) { if (!rtl8150_reset(dev)) {
err("couldn't reset the device"); err("couldn't reset the device");
free_all_urbs(dev); goto out1;
goto err;
} }
fill_skb_pool(dev); fill_skb_pool(dev);
set_ethernet_addr(dev); set_ethernet_addr(dev);
info("%s: rtl8150 is detected", netdev->name); info("%s: rtl8150 is detected", netdev->name);
up(&dev->sem);
usb_set_intfdata(intf, dev); usb_set_intfdata(intf, dev);
if (register_netdev(netdev) != 0) {
err("couldn't register the device");
goto out2;
}
return 0; return 0;
err:
unregister_netdev(dev->netdev); out2:
up(&dev->sem); usb_set_intfdata(intf, NULL);
free_skb_pool(dev);
out1:
free_all_urbs(dev);
out:
kfree(netdev); kfree(netdev);
kfree(dev); kfree(dev);
return -EIO; return -EIO;
...@@ -865,8 +860,6 @@ static void rtl8150_disconnect(struct usb_interface *intf) ...@@ -865,8 +860,6 @@ static void rtl8150_disconnect(struct usb_interface *intf)
dev_kfree_skb(dev->rx_skb); dev_kfree_skb(dev->rx_skb);
kfree(dev->netdev); kfree(dev->netdev);
kfree(dev); kfree(dev);
dev->netdev = NULL;
dev = NULL;
} }
} }
......
This diff is collapsed.
...@@ -333,6 +333,7 @@ struct net_device ...@@ -333,6 +333,7 @@ struct net_device
void *dn_ptr; /* DECnet specific data */ void *dn_ptr; /* DECnet specific data */
void *ip6_ptr; /* IPv6 specific data */ void *ip6_ptr; /* IPv6 specific data */
void *ec_ptr; /* Econet specific data */ void *ec_ptr; /* Econet specific data */
void *ax25_ptr; /* AX.25 specific data */
struct list_head poll_list; /* Link to poll list */ struct list_head poll_list; /* Link to poll list */
int quota; int quota;
......
...@@ -233,7 +233,12 @@ extern void ax25_digi_invert(ax25_digi *, ax25_digi *); ...@@ -233,7 +233,12 @@ extern void ax25_digi_invert(ax25_digi *, ax25_digi *);
/* ax25_dev.c */ /* ax25_dev.c */
extern ax25_dev *ax25_dev_list; extern ax25_dev *ax25_dev_list;
extern spinlock_t ax25_dev_lock; extern spinlock_t ax25_dev_lock;
extern ax25_dev *ax25_dev_ax25dev(struct net_device *);
static inline ax25_dev *ax25_dev_ax25dev(struct net_device *dev)
{
return dev->ax25_ptr;
}
extern ax25_dev *ax25_addr_ax25dev(ax25_address *); extern ax25_dev *ax25_addr_ax25dev(ax25_address *);
extern void ax25_dev_device_up(struct net_device *); extern void ax25_dev_device_up(struct net_device *);
extern void ax25_dev_device_down(struct net_device *); extern void ax25_dev_device_down(struct net_device *);
......
...@@ -34,21 +34,6 @@ ...@@ -34,21 +34,6 @@
ax25_dev *ax25_dev_list; ax25_dev *ax25_dev_list;
spinlock_t ax25_dev_lock = SPIN_LOCK_UNLOCKED; spinlock_t ax25_dev_lock = SPIN_LOCK_UNLOCKED;
ax25_dev *ax25_dev_ax25dev(struct net_device *dev)
{
ax25_dev *ax25_dev, *res = NULL;
spin_lock_bh(&ax25_dev_lock);
for (ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
if (ax25_dev->dev == dev) {
res = ax25_dev;
break;
}
spin_unlock_bh(&ax25_dev_lock);
return res;
}
ax25_dev *ax25_addr_ax25dev(ax25_address *addr) ax25_dev *ax25_addr_ax25dev(ax25_address *addr)
{ {
ax25_dev *ax25_dev, *res = NULL; ax25_dev *ax25_dev, *res = NULL;
...@@ -80,6 +65,7 @@ void ax25_dev_device_up(struct net_device *dev) ...@@ -80,6 +65,7 @@ void ax25_dev_device_up(struct net_device *dev)
memset(ax25_dev, 0x00, sizeof(*ax25_dev)); memset(ax25_dev, 0x00, sizeof(*ax25_dev));
dev->ax25_ptr = ax25_dev;
ax25_dev->dev = dev; ax25_dev->dev = dev;
ax25_dev->forward = NULL; ax25_dev->forward = NULL;
...@@ -152,6 +138,7 @@ void ax25_dev_device_down(struct net_device *dev) ...@@ -152,6 +138,7 @@ void ax25_dev_device_down(struct net_device *dev)
s = s->next; s = s->next;
} }
spin_unlock_bh(&ax25_dev_lock); spin_unlock_bh(&ax25_dev_lock);
dev->ax25_ptr = NULL;
ax25_register_sysctl(); ax25_register_sysctl();
} }
......
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