|
|
@@ -75,36 +75,35 @@ Submitted-by: Yousong Zhou <[email protected]>
|
|
|
/**
|
|
|
* nvmem_get_mac_address - Obtain the MAC address from an nvmem cell named
|
|
|
* 'mac-address' associated with given device.
|
|
|
-@@ -551,19 +608,23 @@ int nvmem_get_mac_address(struct device
|
|
|
+@@ -549,21 +606,28 @@ EXPORT_SYMBOL(eth_platform_get_mac_addre
|
|
|
+ */
|
|
|
+ int nvmem_get_mac_address(struct device *dev, void *addrbuf)
|
|
|
{
|
|
|
++ struct nvmem_cell_mac_address_property *property;
|
|
|
struct nvmem_cell *cell;
|
|
|
const void *mac;
|
|
|
- size_t len;
|
|
|
-+ struct nvmem_cell_mac_address_property *property;
|
|
|
+ int i;
|
|
|
-
|
|
|
-- cell = nvmem_cell_get(dev, "mac-address");
|
|
|
-- if (IS_ERR(cell))
|
|
|
-- return PTR_ERR(cell);
|
|
|
--
|
|
|
-- mac = nvmem_cell_read(cell, &len);
|
|
|
-- nvmem_cell_put(cell);
|
|
|
--
|
|
|
-- if (IS_ERR(mac))
|
|
|
-- return PTR_ERR(mac);
|
|
|
++
|
|
|
+ for (i = 0; i < ARRAY_SIZE(nvmem_cell_mac_address_properties); i++) {
|
|
|
+ property = &nvmem_cell_mac_address_properties[i];
|
|
|
+ cell = nvmem_cell_get(dev, property->name);
|
|
|
-+ if (IS_ERR(cell)) {
|
|
|
-+ if (i == ARRAY_SIZE(nvmem_cell_mac_address_properties) - 1)
|
|
|
-+ return PTR_ERR(cell);
|
|
|
-+ continue;
|
|
|
-+ }
|
|
|
-+ mac = property->read(cell);
|
|
|
-+ nvmem_cell_put(cell);
|
|
|
-+ break;
|
|
|
++ /* For -EPROBE_DEFER don't try other properties. We'll get back to this one. */
|
|
|
++ if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
|
|
|
++ break;
|
|
|
+ }
|
|
|
|
|
|
+- cell = nvmem_cell_get(dev, "mac-address");
|
|
|
+ if (IS_ERR(cell))
|
|
|
+ return PTR_ERR(cell);
|
|
|
+
|
|
|
+- mac = nvmem_cell_read(cell, &len);
|
|
|
++ mac = property->read(cell);
|
|
|
+ nvmem_cell_put(cell);
|
|
|
+-
|
|
|
+ if (IS_ERR(mac))
|
|
|
+ return PTR_ERR(mac);
|
|
|
+
|
|
|
- if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
|
|
|
+ if (!is_valid_ether_addr(mac)) {
|
|
|
kfree(mac);
|