Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04b9665b authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Kevin Hilman
Browse files

ARM: davinci: only use NVMEM when available



The davinci platform contains code that calls into the nvmem
subsystem, but that might be a loadable module, causing a
link error:

arch/arm/mach-davinci/built-in.o: In function `davinci_get_mac_addr':
:(.text+0x1088): undefined reference to `nvmem_device_read'
arch/arm/mach-davinci/built-in.o: In function `read_factory_config':
:(.text+0x214c): undefined reference to `nvmem_device_read'

Also, when NVMEM is completely disabled, the functions fail with
nonobvious error messages.

This ensures we only call the API functions when the code is actually
reachable from the board file, and otherwise prints a unique log
message.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Fixes: bec3c11b ("misc: at24: replace memory_accessor with nvmem_device_read")
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@baylibre.com>
parent 63831902
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -121,6 +121,11 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
	const char *partnum = NULL;
	struct davinci_soc_info *soc_info = &davinci_soc_info;

	if (!IS_BUILTIN(CONFIG_NVMEM)) {
		pr_warn("Factory Config not available without CONFIG_NVMEM\n");
		goto bad_config;
	}

	ret = nvmem_device_read(nvmem, 0, sizeof(factory_config),
				&factory_config);
	if (ret != sizeof(struct factory_config)) {
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
	off_t offset = (off_t)context;

	if (!IS_BUILTIN(CONFIG_NVMEM)) {
		pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
		return;
	}

	/* Read MAC addr from EEPROM */
	if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);