From: Imre Kaloz Date: Fri, 4 Jan 2008 12:17:49 +0000 (+0000) Subject: Fixes the MAC address handling on avila NPE on startup X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3c77f8085200fbf2cd9ebb60a7ee78a16077879e;p=openwrt%2Fstaging%2Fkaloz.git Fixes the MAC address handling on avila NPE on startup Replaces/based-on 740-avila_loft_mac_platform.patch for 2.6.21 Signed-off-by: Harald Schioeberg SVN-Revision: 10114 --- diff --git a/target/linux/ixp4xx/patches-2.6.23/300-avila_fetch_mac.patch b/target/linux/ixp4xx/patches-2.6.23/300-avila_fetch_mac.patch new file mode 100644 index 0000000000..463383f382 --- /dev/null +++ b/target/linux/ixp4xx/patches-2.6.23/300-avila_fetch_mac.patch @@ -0,0 +1,72 @@ +diff -r -u linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c ../../../../trunk/build_dir/linux-ixp4xx_generic/linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c +--- linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-04 01:28:24.134925761 +0100 ++++ ../../../../trunk/build_dir/linux-ixp4xx_generic/linux-2.6.23.12/arch/arm/mach-ixp4xx/avila-setup.c 2008-01-04 01:23:27.874042817 +0100 +@@ -14,10 +14,18 @@ + #include + #include + #include ++#include ++#include ++#include + #include + #include + #include + #include ++#ifdef CONFIG_SENSORS_EEPROM ++# include ++# include ++#endif ++ + #include + + #include +@@ -194,9 +202,48 @@ + t->hdr.size = 0; + } + ++#ifdef CONFIG_SENSORS_EEPROM ++static int loft_eeprom_do(struct notifier_block *self, unsigned long event, void *t) ++{ ++ struct eeprom_data *data = t; ++ struct sockaddr address; ++ struct net_device * netdev ; ++ ++ char macs[12]; ++ ++ /* The MACs are the first 12 bytes in the eeprom at address 0x51 */ ++ if (event == EEPROM_REGISTER && data->client.addr == 0x51) { ++ data->attr->read(&data->client.dev.kobj, data->attr, macs, 0, 12); ++ /*eth0*/ ++ /* using dev_get_by_name here is really ugly and can cause ++ * confusion if other ethernet devices are present. FIXME */ ++ ++ memcpy(address.sa_data, macs, ETH_ALEN); ++ memcpy(&avila_plat_eth[0].hwaddr, macs, ETH_ALEN); ++ if ( (netdev = dev_get_by_name("eth0")) ) ++ netdev->set_mac_address(netdev, &address); ++ ++ /*same for eth1*/ ++ memcpy(address.sa_data, macs + ETH_ALEN, ETH_ALEN); ++ memcpy(&avila_plat_eth[1].hwaddr, macs + ETH_ALEN, ETH_ALEN); ++ if ( (netdev = dev_get_by_name("eth1")) ) ++ netdev->set_mac_address(netdev, &address); ++ } ++ ++ return NOTIFY_DONE; ++} ++ ++static struct notifier_block loft_eeprom_notifier = { ++ .notifier_call = loft_eeprom_do ++}; ++#endif ++ + static void __init avila_init(void) + { + ixp4xx_sys_init(); ++#ifdef CONFIG_SENSORS_EEPROM ++ register_eeprom_notifier(&loft_eeprom_notifier); ++#endif + + avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); + avila_flash_resource.end = +