Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 369799
b: refs/heads/master
c: 313a58e
h: refs/heads/master
i:
  369797: 2bbecd9
  369795: 766bc02
  369791: cfd3648
v: v3
  • Loading branch information
Petko Manolov authored and David S. Miller committed Apr 29, 2013
1 parent f65e1da commit 0dedc77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 68 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: 5f5624cf156283687e11ea329c7a0523c677ea0e
refs/heads/master: 313a58e487ab3eb80e7e1f9baddc75968288aad9
73 changes: 9 additions & 64 deletions trunk/drivers/net/usb/pegasus.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,51 +575,6 @@ static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)
return ret;
}

static void fill_skb_pool(pegasus_t *pegasus)
{
int i;

for (i = 0; i < RX_SKBS; i++) {
if (pegasus->rx_pool[i])
continue;
pegasus->rx_pool[i] = dev_alloc_skb(PEGASUS_MTU + 2);
/*
** we give up if the allocation fail. the tasklet will be
** rescheduled again anyway...
*/
if (pegasus->rx_pool[i] == NULL)
return;
skb_reserve(pegasus->rx_pool[i], 2);
}
}

static void free_skb_pool(pegasus_t *pegasus)
{
int i;

for (i = 0; i < RX_SKBS; i++) {
if (pegasus->rx_pool[i]) {
dev_kfree_skb(pegasus->rx_pool[i]);
pegasus->rx_pool[i] = NULL;
}
}
}

static inline struct sk_buff *pull_skb(pegasus_t * pegasus)
{
int i;
struct sk_buff *skb;

for (i = 0; i < RX_SKBS; i++) {
if (likely(pegasus->rx_pool[i] != NULL)) {
skb = pegasus->rx_pool[i];
pegasus->rx_pool[i] = NULL;
return skb;
}
}
return NULL;
}

static void read_bulk_callback(struct urb *urb)
{
pegasus_t *pegasus = urb->context;
Expand Down Expand Up @@ -704,9 +659,8 @@ static void read_bulk_callback(struct urb *urb)
if (pegasus->flags & PEGASUS_UNPLUG)
return;

spin_lock(&pegasus->rx_pool_lock);
pegasus->rx_skb = pull_skb(pegasus);
spin_unlock(&pegasus->rx_pool_lock);
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, PEGASUS_MTU,
GFP_ATOMIC);

if (pegasus->rx_skb == NULL)
goto tl_sched;
Expand Down Expand Up @@ -734,24 +688,23 @@ static void read_bulk_callback(struct urb *urb)
static void rx_fixup(unsigned long data)
{
pegasus_t *pegasus;
unsigned long flags;
int status;

pegasus = (pegasus_t *) data;
if (pegasus->flags & PEGASUS_UNPLUG)
return;

spin_lock_irqsave(&pegasus->rx_pool_lock, flags);
fill_skb_pool(pegasus);
if (pegasus->flags & PEGASUS_RX_URB_FAIL)
if (pegasus->rx_skb)
goto try_again;
if (pegasus->rx_skb == NULL)
pegasus->rx_skb = pull_skb(pegasus);
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net,
PEGASUS_MTU,
GFP_ATOMIC);
if (pegasus->rx_skb == NULL) {
netif_warn(pegasus, rx_err, pegasus->net, "low on memory\n");
tasklet_schedule(&pegasus->rx_tl);
goto done;
return;
}
usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
usb_rcvbulkpipe(pegasus->usb, 1),
Expand All @@ -767,8 +720,6 @@ static void rx_fixup(unsigned long data)
} else {
pegasus->flags &= ~PEGASUS_RX_URB_FAIL;
}
done:
spin_unlock_irqrestore(&pegasus->rx_pool_lock, flags);
}

static void write_bulk_callback(struct urb *urb)
Expand Down Expand Up @@ -1007,10 +958,9 @@ static int pegasus_open(struct net_device *net)
int res;

if (pegasus->rx_skb == NULL)
pegasus->rx_skb = pull_skb(pegasus);
/*
** Note: no point to free the pool. it is empty :-)
*/
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net,
PEGASUS_MTU,
GFP_KERNEL);
if (!pegasus->rx_skb)
return -ENOMEM;

Expand Down Expand Up @@ -1044,7 +994,6 @@ static int pegasus_open(struct net_device *net)
res = -EIO;
usb_kill_urb(pegasus->rx_urb);
usb_kill_urb(pegasus->intr_urb);
free_skb_pool(pegasus);
goto exit;
}
set_carrier(net);
Expand Down Expand Up @@ -1364,7 +1313,6 @@ static int pegasus_probe(struct usb_interface *intf,
pegasus->mii.mdio_write = mdio_write;
pegasus->mii.phy_id_mask = 0x1f;
pegasus->mii.reg_num_mask = 0x1f;
spin_lock_init(&pegasus->rx_pool_lock);
pegasus->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV
| NETIF_MSG_PROBE | NETIF_MSG_LINK);

Expand All @@ -1376,7 +1324,6 @@ static int pegasus_probe(struct usb_interface *intf,
goto out2;
}
set_ethernet_addr(pegasus);
fill_skb_pool(pegasus);
if (pegasus->features & PEGASUS_II) {
dev_info(&intf->dev, "setup Pegasus II specific registers\n");
setup_pegasus_II(pegasus);
Expand Down Expand Up @@ -1404,7 +1351,6 @@ static int pegasus_probe(struct usb_interface *intf,

out3:
usb_set_intfdata(intf, NULL);
free_skb_pool(pegasus);
out2:
free_all_urbs(pegasus);
out1:
Expand All @@ -1429,7 +1375,6 @@ static void pegasus_disconnect(struct usb_interface *intf)
unregister_netdev(pegasus->net);
unlink_all_urbs(pegasus);
free_all_urbs(pegasus);
free_skb_pool(pegasus);
if (pegasus->rx_skb != NULL) {
dev_kfree_skb(pegasus->rx_skb);
pegasus->rx_skb = NULL;
Expand Down
3 changes: 0 additions & 3 deletions trunk/drivers/net/usb/pegasus.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define HAS_HOME_PNA 0x40000000

#define PEGASUS_MTU 1536
#define RX_SKBS 4

#define EPROM_WRITE 0x01
#define EPROM_READ 0x02
Expand Down Expand Up @@ -97,11 +96,9 @@ typedef struct pegasus {
struct tasklet_struct rx_tl;
struct delayed_work carrier_check;
struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
struct sk_buff *rx_pool[RX_SKBS];
struct sk_buff *rx_skb;
struct usb_ctrlrequest dr;
wait_queue_head_t ctrl_wait;
spinlock_t rx_pool_lock;
int chip;
unsigned char intr_buff[8];
__u8 tx_buff[PEGASUS_MTU];
Expand Down

0 comments on commit 0dedc77

Please sign in to comment.