Message ID | 20180625080108.32441-1-marcel@ziswiler.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
SGkgRGF2aWQNCg0KT24gTW9uLCAyMDE4LTA2LTI1IGF0IDEwOjAxICswMjAwLCBNYXJjZWwgWmlz d2lsZXIgd3JvdGU6DQo+IEZyb206IE1hcmNlbCBaaXN3aWxlciA8bWFyY2VsLnppc3dpbGVyQHRv cmFkZXguY29tPg0KPiANCj4gRm9yIEVtYmVkZGVkIHVzZSB3aGVyZSBlLmcuIEFYODg3NzJCIGNo aXBzIG1heSBiZSB1c2VkIHdpdGhvdXQNCj4gZXh0ZXJuYWwNCj4gRUVQUk9NcyB0aGUgYm9vdCBs b2FkZXIgbWF5IGNob29zZSB0byBwYXNzIHRoZSBNQUMgYWRkcmVzcyB0byBiZSB1c2VkDQo+IHZp YSBkZXZpY2UgdHJlZS4gVGhlcmVmb3JlLCBhbGxvdyBmb3Igb3B0aW9uYWxseSBnZXR0aW5nIHRo ZSBNQUMNCj4gYWRkcmVzcyBmcm9tIGRldmljZSB0cmVlIGRhdGEgZS5nLiBhcyBmb2xsb3dzIChl eGNlcnB0IGZyb20gYSBUMzANCj4gYmFzZWQNCj4gYm9hcmQsIGxvY2FsLW1hYy1hZGRyZXNzIHRv IGJlIGZpbGxlZCBpbiBieSBib290IGxvYWRlcik6DQo+IA0KPiAvKiBFSENJIGluc3RhbmNlIDE6 IFVTQjJfRFAvTiAtPiBBWDg4NzcyQiAqLw0KPiB1c2JAN2QwMDQwMDAgew0KPiAJc3RhdHVzID0g Im9rYXkiOw0KPiAJI2FkZHJlc3MtY2VsbHMgPSA8MT47DQo+IAkjc2l6ZS1jZWxscyA9IDwwPjsN Cj4gCWFzaXhAMSB7DQo+IAkJcmVnID0gPDE+Ow0KPiAJCWxvY2FsLW1hYy1hZGRyZXNzID0gWzAw IDAwIDAwIDAwIDAwIDAwXTsNCj4gCX07DQo+IH07DQo+IA0KPiBTaWduZWQtb2ZmLWJ5OiBNYXJj ZWwgWml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TsNCj4gKwkJCXJldHVybiByZXQ7DQo+ ICsJCX0NCj4gIAl9DQo+ICANCj4gIAlhc2l4X3NldF9uZXRkZXZfZGV2X2FkZHIoZGV2LCBidWYp Ow0KDQpOb3cgdGhhdCB5b3UgbWVudGlvbmVkIGV0aF9wbGF0Zm9ybV9nZXRfbWFjX2FkZHJlc3Mo KSBvbiBteSBpZ2IgYXR0ZW1wdCBJIGFtDQp3b25kZXJpbmcgd2hldGhlciB0aGF0IHdvdWxkIG5v dCBhbHNvIGJlIHRoZSBiZXR0ZXIgYXBwcm9hY2ggZm9yIEFTSVggVVNCIG5ldA0KdXNlLiBMb29r cyBsaWtlIGF0IGxlYXN0IGxhbjc4eHggYWxyZWFkeSBkb2VzIGl0IHRoYXQgd2F5IGFzIHdlbGwu DQoNCldoYXQgZG8geW91IHRoaW5rPw0KDQpDaGVlcnMNCg0KTWFyY2Vs -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> Now that you mentioned eth_platform_get_mac_address() on my igb attempt I am > wondering whether that would not also be the better approach for ASIX USB net > use. Looks like at least lan78xx already does it that way as well. > > What do you think? Hi Marcel eth_platform_get_mac_address() is preferred, since it will try DT, ACPI, and anything else the platform supports. Andrew -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h index 9a4171b90947..c8161960cef2 100644 --- a/drivers/net/usb/asix.h +++ b/drivers/net/usb/asix.h @@ -37,6 +37,7 @@ #include <linux/usb/usbnet.h> #include <linux/slab.h> #include <linux/if_vlan.h> +#include <linux/of_net.h> #define DRIVER_VERSION "22-Dec-2011" #define DRIVER_NAME "asix" diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index 3d4f7959dabb..a88d65dfc64c 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -690,25 +690,34 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) u8 buf[ETH_ALEN], chipcode = 0; u32 phyid; struct asix_common_private *priv; + const u8 *mac_addr; - usbnet_get_endpoints(dev,intf); + usbnet_get_endpoints(dev, intf); - /* Get the MAC address */ - if (dev->driver_info->data & FLAG_EEPROM_MAC) { - for (i = 0; i < (ETH_ALEN >> 1); i++) { - ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, - 0, 2, buf + i * 2, 0); - if (ret < 0) - break; - } + /* Maybe the boot loader passed the MAC address via device tree */ + mac_addr = of_get_mac_address(dev->udev->dev.of_node); + if (mac_addr) { + memcpy(buf, mac_addr, ETH_ALEN); } else { - ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, - 0, 0, ETH_ALEN, buf, 0); - } + /* Try getting the MAC address from EEPROM */ + if (dev->driver_info->data & FLAG_EEPROM_MAC) { + for (i = 0; i < (ETH_ALEN >> 1); i++) { + ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, + 0x04 + i, 0, 2, buf + i * 2, + 0); + if (ret < 0) + break; + } + } else { + ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, + 0, 0, ETH_ALEN, buf, 0); + } - if (ret < 0) { - netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); - return ret; + if (ret < 0) { + netdev_dbg(dev->net, "Failed to read MAC address: %d\n", + ret); + return ret; + } } asix_set_netdev_dev_addr(dev, buf);