From patchwork Sun Jan 11 08:45:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Venzano X-Patchwork-Id: 17788 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 23218DDFB9 for ; Sun, 11 Jan 2009 19:55:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbZAKIzU (ORCPT ); Sun, 11 Jan 2009 03:55:20 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751065AbZAKIzT (ORCPT ); Sun, 11 Jan 2009 03:55:19 -0500 Received: from smtp1.infomaniak.ch ([84.16.68.89]:43203 "EHLO smtp1.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751006AbZAKIzS (ORCPT ); Sun, 11 Jan 2009 03:55:18 -0500 X-Greylist: delayed 600 seconds by postgrey-1.27 at vger.kernel.org; Sun, 11 Jan 2009 03:55:17 EST Received: from renditai.milesteg.arr (88-149-227-118.dynamic.ngi.it [88.149.227.118]) (authenticated bits=0) by smtp1.infomaniak.ch (8.14.2/8.14.2) with ESMTP id n0B8j6cr028544 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Sun, 11 Jan 2009 09:45:07 +0100 Received: from venza by renditai.milesteg.arr with local (Exim 4.69) (envelope-from ) id 1LLvwO-0003BY-UN; Sun, 11 Jan 2009 09:45:04 +0100 Date: Sun, 11 Jan 2009 09:45:04 +0100 From: Daniele Venzano To: netdev@vger.kernel.org Cc: akpm@linux-foundation.org, venza@brownhat.org Subject: [PATCH] SIS900 show warning if bogus MAC address Message-ID: <20090111084504.GB12226@brownhat.org> Mail-Followup-To: netdev@vger.kernel.org, akpm@linux-foundation.org MIME-Version: 1.0 Content-Disposition: inline X-Operating-System: Debian GNU/Linux on kernel Linux 2.6.26-1-powerpc X-Copyright: Forwarding or publishing without permission is prohibited. X-Truth: La vita e' una questione di culo, o ce l'hai o te lo fanno. X-GPG-Fingerprint: 642A A345 1CEF B6E3 925C 23CE DAB9 8764 25B3 57ED User-Agent: Mutt/1.5.18 (2008-05-17) X-Antivirus: Dr.Web (R) for Mail Servers on smtp1 host X-Antivirus-Code: 100000 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The attached patch modifies the sis900 driver to show a warning at boot or module load time to show a message when a null MAC address (00:00:00:00:00:00) is read from the the hardware. This seems to happen with newer usage of the sis900 chipset, since this never came up before. Signed-off-by: Daniele Venzano --- Daniele Venzano http://www.brownhat.org --- a/drivers/net/sis900.c 2008-12-31 09:15:17.000000000 +0100 +++ b/drivers/net/sis900.c 2008-12-31 09:24:47.000000000 +0100 @@ -382,6 +382,25 @@ static int __devinit sis96x_get_mac_addr } /** + * sis900_check_mac_addr - Check the MAc adress for validity + * @net_dev: the net device that has the address to check + * + * Return false (0) if the mac address read from the hardware is + * composed of all zeros. + */ + +static int __devinit sis900_check_mac_addr(struct net_device *net_dev) +{ + int i; + + for (i = 0; i < 6; i++) + if (net_dev->dev_addr[i] != 0) + return 1; + + return 0; +} + +/** * sis900_probe - Probe for sis900 device * @pci_dev: the sis900 pci device * @pci_id: the pci device ID @@ -504,6 +523,9 @@ static int __devinit sis900_probe(struct else ret = sis900_get_mac_addr(pci_dev, net_dev); + if (sis900_check_mac_addr(net_dev) == 0) + printk(KERN_WARNING "%s: Read an invalid MAC address, remember to set one manually\n", dev_name); + if (ret == 0) { printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name); ret = -ENODEV;