From patchwork Tue Jan 6 06:14:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Fengguang X-Patchwork-Id: 16773 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id BEBF9474C3 for ; Tue, 6 Jan 2009 17:14:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751303AbZAFGOS (ORCPT ); Tue, 6 Jan 2009 01:14:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751205AbZAFGOR (ORCPT ); Tue, 6 Jan 2009 01:14:17 -0500 Received: from mga12.intel.com ([143.182.124.36]:51842 "EHLO azsmga102.ch.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751167AbZAFGOR (ORCPT ); Tue, 6 Jan 2009 01:14:17 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 05 Jan 2009 22:14:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.36,336,1228118400"; d="scan'208";a="96791782" Received: from unknown (HELO localhost) ([10.239.48.23]) by azsmga001.ch.intel.com with ESMTP; 05 Jan 2009 22:14:16 -0800 Received: from wfg by localhost with local (Exim 4.69) (envelope-from ) id 1LK5Cg-0000xi-OP; Tue, 06 Jan 2009 14:14:14 +0800 Date: Tue, 6 Jan 2009 14:14:14 +0800 From: Wu Fengguang To: netdev@vger.kernel.org Cc: Peter Korsgaard Subject: [PATCH] dm9601: handle corrupt mac address Message-ID: <20090106061414.GA3677@localhost> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some cheap devices ship with dangling EEPROM pins! They always return invalid address ff:ff:ff:ff:ff:ff. Inherit the auto-generated address in this case, so that these products can work with zero configuration. Signed-off-by: Wu Fengguang Signed-off-by: Peter Korsgaard --- drivers/net/usb/dm9601.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- linux-2.6.orig/drivers/net/usb/dm9601.c +++ linux-2.6/drivers/net/usb/dm9601.c @@ -413,6 +413,7 @@ static int dm9601_set_mac_address(struct static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) { int ret; + u8 mac[ETH_ALEN]; ret = usbnet_get_endpoints(dev, intf); if (ret) @@ -437,12 +438,18 @@ static int dm9601_bind(struct usbnet *de udelay(20); /* read MAC */ - if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr) < 0) { + if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) { printk(KERN_ERR "Error reading MAC address\n"); ret = -ENODEV; goto out; } + /* + * Overwrite the auto-generated address only with good ones. + */ + if (is_valid_ether_addr(mac)) + memcpy(dev->net->dev_addr, mac, ETH_ALEN); + /* power up phy */ dm_write_reg(dev, DM_GPR_CTRL, 1); dm_write_reg(dev, DM_GPR_DATA, 0);