aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/dm9601.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-10 22:45:50 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-10 22:45:50 -0500
commite8b722f487589a1f60ca27adc695494f188d404e (patch)
treebe3897dceb9b7c0949a8917ab11eea2752375e3b /drivers/net/usb/dm9601.c
parent01d07820a0df6b6134c1bb75b1e84c9d0cdab3be (diff)
parentc59765042f53a79a7a65585042ff463b69cb248c (diff)
Merge commit 'v2.6.29-rc1' into irq/urgent
Diffstat (limited to 'drivers/net/usb/dm9601.c')
-rw-r--r--drivers/net/usb/dm9601.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index edd244f3acb5..5b67bbf1987e 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -23,7 +23,7 @@
23#include <linux/usb/usbnet.h> 23#include <linux/usb/usbnet.h>
24 24
25/* datasheet: 25/* datasheet:
26 http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-P01-930914.pdf 26 http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf
27*/ 27*/
28 28
29/* control requests */ 29/* control requests */
@@ -397,16 +397,24 @@ static void dm9601_set_multicast(struct net_device *net)
397 dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); 397 dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl);
398} 398}
399 399
400static void __dm9601_set_mac_address(struct usbnet *dev)
401{
402 dm_write_async(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr);
403}
404
400static int dm9601_set_mac_address(struct net_device *net, void *p) 405static int dm9601_set_mac_address(struct net_device *net, void *p)
401{ 406{
402 struct sockaddr *addr = p; 407 struct sockaddr *addr = p;
403 struct usbnet *dev = netdev_priv(net); 408 struct usbnet *dev = netdev_priv(net);
404 409
405 if (!is_valid_ether_addr(addr->sa_data)) 410 if (!is_valid_ether_addr(addr->sa_data)) {
411 dev_err(&net->dev, "not setting invalid mac address %pM\n",
412 addr->sa_data);
406 return -EINVAL; 413 return -EINVAL;
414 }
407 415
408 memcpy(net->dev_addr, addr->sa_data, net->addr_len); 416 memcpy(net->dev_addr, addr->sa_data, net->addr_len);
409 dm_write_async(dev, DM_PHY_ADDR, net->addr_len, net->dev_addr); 417 __dm9601_set_mac_address(dev);
410 418
411 return 0; 419 return 0;
412} 420}
@@ -414,6 +422,7 @@ static int dm9601_set_mac_address(struct net_device *net, void *p)
414static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) 422static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
415{ 423{
416 int ret; 424 int ret;
425 u8 mac[ETH_ALEN];
417 426
418 ret = usbnet_get_endpoints(dev, intf); 427 ret = usbnet_get_endpoints(dev, intf);
419 if (ret) 428 if (ret)
@@ -438,12 +447,24 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
438 udelay(20); 447 udelay(20);
439 448
440 /* read MAC */ 449 /* read MAC */
441 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr) < 0) { 450 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) {
442 printk(KERN_ERR "Error reading MAC address\n"); 451 printk(KERN_ERR "Error reading MAC address\n");
443 ret = -ENODEV; 452 ret = -ENODEV;
444 goto out; 453 goto out;
445 } 454 }
446 455
456 /*
457 * Overwrite the auto-generated address only with good ones.
458 */
459 if (is_valid_ether_addr(mac))
460 memcpy(dev->net->dev_addr, mac, ETH_ALEN);
461 else {
462 printk(KERN_WARNING
463 "dm9601: No valid MAC address in EEPROM, using %pM\n",
464 dev->net->dev_addr);
465 __dm9601_set_mac_address(dev);
466 }
467
447 /* power up phy */ 468 /* power up phy */
448 dm_write_reg(dev, DM_GPR_CTRL, 1); 469 dm_write_reg(dev, DM_GPR_CTRL, 1);
449 dm_write_reg(dev, DM_GPR_DATA, 0); 470 dm_write_reg(dev, DM_GPR_DATA, 0);