Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121857
b: refs/heads/master
c: cda2836
h: refs/heads/master
i:
  121855: 189b7f7
v: v3
  • Loading branch information
David Brownell authored and David S. Miller committed Nov 16, 2008
1 parent 85d32cf commit 55454e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 74ad0a5421edc6ef13a4059c6076cd7a4f3a1fd5
refs/heads/master: cda2836dc66f814aecc58370251566e1c225c8d3
36 changes: 26 additions & 10 deletions trunk/drivers/net/usb/pegasus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ static void pegasus_set_multicast(struct net_device *net)
pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST;
pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
if (netif_msg_link(pegasus))
pr_info("%s: set allmulti\n", net->name);
pr_debug("%s: set allmulti\n", net->name);
} else {
pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST;
pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
Expand Down Expand Up @@ -1273,6 +1273,7 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
}


static int pegasus_count;
static struct workqueue_struct *pegasus_workqueue = NULL;
#define CARRIER_CHECK_DELAY (2 * HZ)

Expand Down Expand Up @@ -1301,6 +1302,18 @@ static int pegasus_blacklisted(struct usb_device *udev)
return 0;
}

/* we rely on probe() and remove() being serialized so we
* don't need extra locking on pegasus_count.
*/
static void pegasus_dec_workqueue(void)
{
pegasus_count--;
if (pegasus_count == 0) {
destroy_workqueue(pegasus_workqueue);
pegasus_workqueue = NULL;
}
}

static int pegasus_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
Expand All @@ -1310,12 +1323,17 @@ static int pegasus_probe(struct usb_interface *intf,
int dev_index = id - pegasus_ids;
int res = -ENOMEM;

usb_get_dev(dev);
if (pegasus_blacklisted(dev))
return -ENODEV;

if (pegasus_blacklisted(dev)) {
res = -ENODEV;
goto out;
if (pegasus_count == 0) {
pegasus_workqueue = create_singlethread_workqueue("pegasus");
if (!pegasus_workqueue)
return -ENOMEM;
}
pegasus_count++;

usb_get_dev(dev);

net = alloc_etherdev(sizeof(struct pegasus));
if (!net) {
Expand Down Expand Up @@ -1400,6 +1418,7 @@ static int pegasus_probe(struct usb_interface *intf,
free_netdev(net);
out:
usb_put_dev(dev);
pegasus_dec_workqueue();
return res;
}

Expand All @@ -1425,6 +1444,7 @@ static void pegasus_disconnect(struct usb_interface *intf)
pegasus->rx_skb = NULL;
}
free_netdev(pegasus->net);
pegasus_dec_workqueue();
}

static int pegasus_suspend (struct usb_interface *intf, pm_message_t message)
Expand Down Expand Up @@ -1468,7 +1488,7 @@ static struct usb_driver pegasus_driver = {
.resume = pegasus_resume,
};

static void parse_id(char *id)
static void __init parse_id(char *id)
{
unsigned int vendor_id=0, device_id=0, flags=0, i=0;
char *token, *name=NULL;
Expand Down Expand Up @@ -1504,15 +1524,11 @@ static int __init pegasus_init(void)
pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION);
if (devid)
parse_id(devid);
pegasus_workqueue = create_singlethread_workqueue("pegasus");
if (!pegasus_workqueue)
return -ENOMEM;
return usb_register(&pegasus_driver);
}

static void __exit pegasus_exit(void)
{
destroy_workqueue(pegasus_workqueue);
usb_deregister(&pegasus_driver);
}

Expand Down

0 comments on commit 55454e0

Please sign in to comment.