diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/usb/dm9601.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/usb/dm9601.c')
-rw-r--r-- | drivers/net/usb/dm9601.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index a2b30a10064f..5dfed9297b22 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
22 | #include <linux/crc32.h> | 22 | #include <linux/crc32.h> |
23 | #include <linux/usb/usbnet.h> | 23 | #include <linux/usb/usbnet.h> |
24 | #include <linux/slab.h> | ||
24 | 25 | ||
25 | /* datasheet: | 26 | /* datasheet: |
26 | http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf | 27 | http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf |
@@ -58,7 +59,7 @@ static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) | |||
58 | void *buf; | 59 | void *buf; |
59 | int err = -ENOMEM; | 60 | int err = -ENOMEM; |
60 | 61 | ||
61 | devdbg(dev, "dm_read() reg=0x%02x length=%d", reg, length); | 62 | netdev_dbg(dev->net, "dm_read() reg=0x%02x length=%d\n", reg, length); |
62 | 63 | ||
63 | buf = kmalloc(length, GFP_KERNEL); | 64 | buf = kmalloc(length, GFP_KERNEL); |
64 | if (!buf) | 65 | if (!buf) |
@@ -89,7 +90,7 @@ static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) | |||
89 | void *buf = NULL; | 90 | void *buf = NULL; |
90 | int err = -ENOMEM; | 91 | int err = -ENOMEM; |
91 | 92 | ||
92 | devdbg(dev, "dm_write() reg=0x%02x, length=%d", reg, length); | 93 | netdev_dbg(dev->net, "dm_write() reg=0x%02x, length=%d\n", reg, length); |
93 | 94 | ||
94 | if (data) { | 95 | if (data) { |
95 | buf = kmalloc(length, GFP_KERNEL); | 96 | buf = kmalloc(length, GFP_KERNEL); |
@@ -112,7 +113,8 @@ static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) | |||
112 | 113 | ||
113 | static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) | 114 | static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) |
114 | { | 115 | { |
115 | devdbg(dev, "dm_write_reg() reg=0x%02x, value=0x%02x", reg, value); | 116 | netdev_dbg(dev->net, "dm_write_reg() reg=0x%02x, value=0x%02x\n", |
117 | reg, value); | ||
116 | return usb_control_msg(dev->udev, | 118 | return usb_control_msg(dev->udev, |
117 | usb_sndctrlpipe(dev->udev, 0), | 119 | usb_sndctrlpipe(dev->udev, 0), |
118 | DM_WRITE_REG, | 120 | DM_WRITE_REG, |
@@ -142,13 +144,13 @@ static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value, | |||
142 | 144 | ||
143 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 145 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
144 | if (!urb) { | 146 | if (!urb) { |
145 | deverr(dev, "Error allocating URB in dm_write_async_helper!"); | 147 | netdev_err(dev->net, "Error allocating URB in dm_write_async_helper!\n"); |
146 | return; | 148 | return; |
147 | } | 149 | } |
148 | 150 | ||
149 | req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); | 151 | req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); |
150 | if (!req) { | 152 | if (!req) { |
151 | deverr(dev, "Failed to allocate memory for control request"); | 153 | netdev_err(dev->net, "Failed to allocate memory for control request\n"); |
152 | usb_free_urb(urb); | 154 | usb_free_urb(urb); |
153 | return; | 155 | return; |
154 | } | 156 | } |
@@ -166,8 +168,8 @@ static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value, | |||
166 | 168 | ||
167 | status = usb_submit_urb(urb, GFP_ATOMIC); | 169 | status = usb_submit_urb(urb, GFP_ATOMIC); |
168 | if (status < 0) { | 170 | if (status < 0) { |
169 | deverr(dev, "Error submitting the control message: status=%d", | 171 | netdev_err(dev->net, "Error submitting the control message: status=%d\n", |
170 | status); | 172 | status); |
171 | kfree(req); | 173 | kfree(req); |
172 | usb_free_urb(urb); | 174 | usb_free_urb(urb); |
173 | } | 175 | } |
@@ -175,15 +177,15 @@ static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value, | |||
175 | 177 | ||
176 | static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) | 178 | static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) |
177 | { | 179 | { |
178 | devdbg(dev, "dm_write_async() reg=0x%02x length=%d", reg, length); | 180 | netdev_dbg(dev->net, "dm_write_async() reg=0x%02x length=%d\n", reg, length); |
179 | 181 | ||
180 | dm_write_async_helper(dev, reg, 0, length, data); | 182 | dm_write_async_helper(dev, reg, 0, length, data); |
181 | } | 183 | } |
182 | 184 | ||
183 | static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) | 185 | static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) |
184 | { | 186 | { |
185 | devdbg(dev, "dm_write_reg_async() reg=0x%02x value=0x%02x", | 187 | netdev_dbg(dev->net, "dm_write_reg_async() reg=0x%02x value=0x%02x\n", |
186 | reg, value); | 188 | reg, value); |
187 | 189 | ||
188 | dm_write_async_helper(dev, reg, value, 0, NULL); | 190 | dm_write_async_helper(dev, reg, value, 0, NULL); |
189 | } | 191 | } |
@@ -211,7 +213,7 @@ static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *valu | |||
211 | } | 213 | } |
212 | 214 | ||
213 | if (i == DM_TIMEOUT) { | 215 | if (i == DM_TIMEOUT) { |
214 | deverr(dev, "%s read timed out!", phy ? "phy" : "eeprom"); | 216 | netdev_err(dev->net, "%s read timed out!\n", phy ? "phy" : "eeprom"); |
215 | ret = -EIO; | 217 | ret = -EIO; |
216 | goto out; | 218 | goto out; |
217 | } | 219 | } |
@@ -219,8 +221,8 @@ static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *valu | |||
219 | dm_write_reg(dev, DM_SHARED_CTRL, 0x0); | 221 | dm_write_reg(dev, DM_SHARED_CTRL, 0x0); |
220 | ret = dm_read(dev, DM_SHARED_DATA, 2, value); | 222 | ret = dm_read(dev, DM_SHARED_DATA, 2, value); |
221 | 223 | ||
222 | devdbg(dev, "read shared %d 0x%02x returned 0x%04x, %d", | 224 | netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", |
223 | phy, reg, *value, ret); | 225 | phy, reg, *value, ret); |
224 | 226 | ||
225 | out: | 227 | out: |
226 | mutex_unlock(&dev->phy_mutex); | 228 | mutex_unlock(&dev->phy_mutex); |
@@ -238,7 +240,7 @@ static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 valu | |||
238 | goto out; | 240 | goto out; |
239 | 241 | ||
240 | dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); | 242 | dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); |
241 | dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1c : 0x14); | 243 | dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1a : 0x12); |
242 | 244 | ||
243 | for (i = 0; i < DM_TIMEOUT; i++) { | 245 | for (i = 0; i < DM_TIMEOUT; i++) { |
244 | u8 tmp; | 246 | u8 tmp; |
@@ -254,7 +256,7 @@ static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 valu | |||
254 | } | 256 | } |
255 | 257 | ||
256 | if (i == DM_TIMEOUT) { | 258 | if (i == DM_TIMEOUT) { |
257 | deverr(dev, "%s write timed out!", phy ? "phy" : "eeprom"); | 259 | netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); |
258 | ret = -EIO; | 260 | ret = -EIO; |
259 | goto out; | 261 | goto out; |
260 | } | 262 | } |
@@ -304,15 +306,15 @@ static int dm9601_mdio_read(struct net_device *netdev, int phy_id, int loc) | |||
304 | __le16 res; | 306 | __le16 res; |
305 | 307 | ||
306 | if (phy_id) { | 308 | if (phy_id) { |
307 | devdbg(dev, "Only internal phy supported"); | 309 | netdev_dbg(dev->net, "Only internal phy supported\n"); |
308 | return 0; | 310 | return 0; |
309 | } | 311 | } |
310 | 312 | ||
311 | dm_read_shared_word(dev, 1, loc, &res); | 313 | dm_read_shared_word(dev, 1, loc, &res); |
312 | 314 | ||
313 | devdbg(dev, | 315 | netdev_dbg(dev->net, |
314 | "dm9601_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", | 316 | "dm9601_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", |
315 | phy_id, loc, le16_to_cpu(res)); | 317 | phy_id, loc, le16_to_cpu(res)); |
316 | 318 | ||
317 | return le16_to_cpu(res); | 319 | return le16_to_cpu(res); |
318 | } | 320 | } |
@@ -324,12 +326,12 @@ static void dm9601_mdio_write(struct net_device *netdev, int phy_id, int loc, | |||
324 | __le16 res = cpu_to_le16(val); | 326 | __le16 res = cpu_to_le16(val); |
325 | 327 | ||
326 | if (phy_id) { | 328 | if (phy_id) { |
327 | devdbg(dev, "Only internal phy supported"); | 329 | netdev_dbg(dev->net, "Only internal phy supported\n"); |
328 | return; | 330 | return; |
329 | } | 331 | } |
330 | 332 | ||
331 | devdbg(dev,"dm9601_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", | 333 | netdev_dbg(dev->net, "dm9601_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", |
332 | phy_id, loc, val); | 334 | phy_id, loc, val); |
333 | 335 | ||
334 | dm_write_shared_word(dev, 1, loc, res); | 336 | dm_write_shared_word(dev, 1, loc, res); |
335 | } | 337 | } |
@@ -381,13 +383,13 @@ static void dm9601_set_multicast(struct net_device *net) | |||
381 | 383 | ||
382 | if (net->flags & IFF_PROMISC) { | 384 | if (net->flags & IFF_PROMISC) { |
383 | rx_ctl |= 0x02; | 385 | rx_ctl |= 0x02; |
384 | } else if (net->flags & IFF_ALLMULTI || net->mc_count > DM_MAX_MCAST) { | 386 | } else if (net->flags & IFF_ALLMULTI || |
387 | netdev_mc_count(net) > DM_MAX_MCAST) { | ||
385 | rx_ctl |= 0x04; | 388 | rx_ctl |= 0x04; |
386 | } else if (net->mc_count) { | 389 | } else if (!netdev_mc_empty(net)) { |
387 | struct dev_mc_list *mc_list = net->mc_list; | 390 | struct dev_mc_list *mc_list; |
388 | int i; | ||
389 | 391 | ||
390 | for (i = 0; i < net->mc_count; i++, mc_list = mc_list->next) { | 392 | netdev_for_each_mc_addr(mc_list, net) { |
391 | u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; | 393 | u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; |
392 | hashes[crc >> 3] |= 1 << (crc & 0x7); | 394 | hashes[crc >> 3] |= 1 << (crc & 0x7); |
393 | } | 395 | } |
@@ -592,7 +594,7 @@ static void dm9601_status(struct usbnet *dev, struct urb *urb) | |||
592 | } | 594 | } |
593 | else | 595 | else |
594 | netif_carrier_off(dev->net); | 596 | netif_carrier_off(dev->net); |
595 | devdbg(dev, "Link Status is: %d", link); | 597 | netdev_dbg(dev->net, "Link Status is: %d\n", link); |
596 | } | 598 | } |
597 | } | 599 | } |
598 | 600 | ||
@@ -603,15 +605,15 @@ static int dm9601_link_reset(struct usbnet *dev) | |||
603 | mii_check_media(&dev->mii, 1, 1); | 605 | mii_check_media(&dev->mii, 1, 1); |
604 | mii_ethtool_gset(&dev->mii, &ecmd); | 606 | mii_ethtool_gset(&dev->mii, &ecmd); |
605 | 607 | ||
606 | devdbg(dev, "link_reset() speed: %d duplex: %d", | 608 | netdev_dbg(dev->net, "link_reset() speed: %d duplex: %d\n", |
607 | ecmd.speed, ecmd.duplex); | 609 | ecmd.speed, ecmd.duplex); |
608 | 610 | ||
609 | return 0; | 611 | return 0; |
610 | } | 612 | } |
611 | 613 | ||
612 | static const struct driver_info dm9601_info = { | 614 | static const struct driver_info dm9601_info = { |
613 | .description = "Davicom DM9601 USB Ethernet", | 615 | .description = "Davicom DM9601 USB Ethernet", |
614 | .flags = FLAG_ETHER, | 616 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
615 | .bind = dm9601_bind, | 617 | .bind = dm9601_bind, |
616 | .rx_fixup = dm9601_rx_fixup, | 618 | .rx_fixup = dm9601_rx_fixup, |
617 | .tx_fixup = dm9601_tx_fixup, | 619 | .tx_fixup = dm9601_tx_fixup, |