Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376154
b: refs/heads/master
c: 3ccfc1b
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed May 20, 2013
1 parent 9880e5f commit 4a65e55
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 58 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: ba7c96bec59d1c11cf9eaf6489e70e22f53da31b
refs/heads/master: 3ccfc1b1d2fa78f8ece83646027982916fcc794b
6 changes: 3 additions & 3 deletions trunk/drivers/isdn/capi/kcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)

static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
{
if (contr - 1 >= CAPI_MAXCONTR)
if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)
return NULL;

return capi_controller[contr - 1];
Expand All @@ -103,15 +103,15 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
{
lockdep_assert_held(&capi_controller_lock);

if (applid - 1 >= CAPI_MAXAPPL)
if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
return NULL;

return capi_applications[applid - 1];
}

static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
{
if (applid - 1 >= CAPI_MAXAPPL)
if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
return NULL;

return rcu_dereference(capi_applications[applid - 1]);
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/ethernet/realtek/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ static void cp_clean_rings (struct cp_private *cp)
cp->dev->stats.tx_dropped++;
}
}
netdev_reset_queue(cp->dev);

memset(cp->rx_ring, 0, sizeof(struct cp_desc) * CP_RX_RING_SIZE);
memset(cp->tx_ring, 0, sizeof(struct cp_desc) * CP_TX_RING_SIZE);
Expand Down
100 changes: 46 additions & 54 deletions trunk/drivers/net/usb/rtl8150.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,23 @@ struct rtl8150 {
struct usb_device *udev;
struct tasklet_struct tl;
struct net_device *netdev;
struct urb *rx_urb, *tx_urb, *intr_urb, *ctrl_urb;
struct urb *rx_urb, *tx_urb, *intr_urb;
struct sk_buff *tx_skb, *rx_skb;
struct sk_buff *rx_skb_pool[RX_SKB_POOL_SIZE];
spinlock_t rx_pool_lock;
struct usb_ctrlrequest dr;
int intr_interval;
__le16 rx_creg;
u8 *intr_buff;
u8 phy;
};

typedef struct rtl8150 rtl8150_t;

struct async_req {
struct usb_ctrlrequest dr;
u16 rx_creg;
};

static const char driver_name [] = "rtl8150";

/*
Expand All @@ -164,51 +168,47 @@ static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
indx, 0, data, size, 500);
}

static void ctrl_callback(struct urb *urb)
static void async_set_reg_cb(struct urb *urb)
{
rtl8150_t *dev;
struct async_req *req = (struct async_req *)urb->context;
int status = urb->status;

switch (status) {
case 0:
break;
case -EINPROGRESS:
break;
case -ENOENT:
break;
default:
if (printk_ratelimit())
dev_warn(&urb->dev->dev, "ctrl urb status %d\n", status);
}
dev = urb->context;
clear_bit(RX_REG_SET, &dev->flags);
if (status < 0)
dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status);
kfree(req);
usb_free_urb(urb);
}

static int async_set_registers(rtl8150_t * dev, u16 indx, u16 size)
static int async_set_registers(rtl8150_t *dev, u16 indx, u16 size, u16 reg)
{
int ret;

if (test_bit(RX_REG_SET, &dev->flags))
return -EAGAIN;
int res = -ENOMEM;
struct urb *async_urb;
struct async_req *req;

dev->dr.bRequestType = RTL8150_REQT_WRITE;
dev->dr.bRequest = RTL8150_REQ_SET_REGS;
dev->dr.wValue = cpu_to_le16(indx);
dev->dr.wIndex = 0;
dev->dr.wLength = cpu_to_le16(size);
dev->ctrl_urb->transfer_buffer_length = size;
usb_fill_control_urb(dev->ctrl_urb, dev->udev,
usb_sndctrlpipe(dev->udev, 0), (char *) &dev->dr,
&dev->rx_creg, size, ctrl_callback, dev);
if ((ret = usb_submit_urb(dev->ctrl_urb, GFP_ATOMIC))) {
if (ret == -ENODEV)
req = kmalloc(sizeof(struct async_req), GFP_ATOMIC);
if (req == NULL)
return res;
async_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (async_urb == NULL) {
kfree(req);
return res;
}
req->rx_creg = cpu_to_le16(reg);
req->dr.bRequestType = RTL8150_REQT_WRITE;
req->dr.bRequest = RTL8150_REQ_SET_REGS;
req->dr.wIndex = 0;
req->dr.wValue = cpu_to_le16(indx);
req->dr.wLength = cpu_to_le16(size);
usb_fill_control_urb(async_urb, dev->udev,
usb_sndctrlpipe(dev->udev, 0), (void *)&req->dr,
&req->rx_creg, size, async_set_reg_cb, req);
res = usb_submit_urb(async_urb, GFP_ATOMIC);
if (res) {
if (res == -ENODEV)
netif_device_detach(dev->netdev);
dev_err(&dev->udev->dev,
"control request submission failed: %d\n", ret);
} else
set_bit(RX_REG_SET, &dev->flags);

return ret;
dev_err(&dev->udev->dev, "%s failed with %d\n", __func__, res);
}
return res;
}

static int read_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 * reg)
Expand Down Expand Up @@ -330,13 +330,6 @@ static int alloc_all_urbs(rtl8150_t * dev)
usb_free_urb(dev->tx_urb);
return 0;
}
dev->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->ctrl_urb) {
usb_free_urb(dev->rx_urb);
usb_free_urb(dev->tx_urb);
usb_free_urb(dev->intr_urb);
return 0;
}

return 1;
}
Expand All @@ -346,15 +339,13 @@ static void free_all_urbs(rtl8150_t * dev)
usb_free_urb(dev->rx_urb);
usb_free_urb(dev->tx_urb);
usb_free_urb(dev->intr_urb);
usb_free_urb(dev->ctrl_urb);
}

static void unlink_all_urbs(rtl8150_t * dev)
{
usb_kill_urb(dev->rx_urb);
usb_kill_urb(dev->tx_urb);
usb_kill_urb(dev->intr_urb);
usb_kill_urb(dev->ctrl_urb);
}

static inline struct sk_buff *pull_skb(rtl8150_t *dev)
Expand Down Expand Up @@ -629,7 +620,6 @@ static int enable_net_traffic(rtl8150_t * dev)
}
/* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */
rcr = 0x9e;
dev->rx_creg = cpu_to_le16(rcr);
tcr = 0xd8;
cr = 0x0c;
if (!(rcr & 0x80))
Expand Down Expand Up @@ -662,20 +652,22 @@ static void rtl8150_tx_timeout(struct net_device *netdev)
static void rtl8150_set_multicast(struct net_device *netdev)
{
rtl8150_t *dev = netdev_priv(netdev);
u16 rx_creg = 0x9e;

netif_stop_queue(netdev);
if (netdev->flags & IFF_PROMISC) {
dev->rx_creg |= cpu_to_le16(0x0001);
rx_creg |= 0x0001;
dev_info(&netdev->dev, "%s: promiscuous mode\n", netdev->name);
} else if (!netdev_mc_empty(netdev) ||
(netdev->flags & IFF_ALLMULTI)) {
dev->rx_creg &= cpu_to_le16(0xfffe);
dev->rx_creg |= cpu_to_le16(0x0002);
rx_creg &= 0xfffe;
rx_creg |= 0x0002;
dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name);
} else {
/* ~RX_MULTICAST, ~RX_PROMISCUOUS */
dev->rx_creg &= cpu_to_le16(0x00fc);
rx_creg &= 0x00fc;
}
async_set_registers(dev, RCR, 2);
async_set_registers(dev, RCR, sizeof(rx_creg), rx_creg);
netif_wake_queue(netdev);
}

Expand Down

0 comments on commit 4a65e55

Please sign in to comment.