@@ -326,6 +326,7 @@ config NVMEM_U_BOOT_ENV
tristate "U-Boot environment variables support"
depends on OF && MTD
select CRC32
+ select GENERIC_NET_UTILS
help
U-Boot stores its setup as environment variables. This driver adds
support for verifying & exporting such data. It also exposes variables
@@ -4,6 +4,8 @@
*/
#include <linux/crc32.h>
+#include <linux/etherdevice.h>
+#include <linux/if_ether.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
@@ -70,6 +72,22 @@ static int u_boot_env_read(void *context, unsigned int offset, void *val,
return 0;
}
+static int u_boot_env_cell_post_process(void *context, struct nvmem_cell_entry *cell,
+ const char *id, void *buf, size_t *len)
+{
+ if (!strcmp(cell->name, "ethaddr")) {
+ u8 mac[ETH_ALEN];
+
+ if (mac_pton(buf, mac)) {
+ ether_addr_copy(buf, mac);
+ if (len)
+ *len = ETH_ALEN;
+ }
+ }
+
+ return 0;
+}
+
static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
size_t data_offset, size_t data_len)
{
@@ -179,6 +197,7 @@ static int u_boot_env_probe(struct platform_device *pdev)
struct nvmem_config config = {
.name = "u-boot-env",
.reg_read = u_boot_env_read,
+ .cell_post_process = u_boot_env_cell_post_process,
};
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;