[U-Boot] [PATCH] w1: fix build without CONFIG_W1_EEPROM

Martin Fuzzey martin.fuzzey at flowbird.group
Mon Oct 22 16:51:49 UTC 2018


Building with CONFIG_W1 and CONFIG_CMD_W1 but without CONFIG_W1_EEPROM
fails with
	drivers/w1/w1-uclass.c:104: undefined reference to `w1_eeprom_register_new_device'
	cmd/w1.c:93: undefined reference to `w1_eeprom_read_buf'

Fix this.

Signed-off-by: Martin Fuzzey <martin.fuzzey at flowbird.group>
---
 cmd/w1.c               | 9 ++++++++-
 drivers/w1/w1-uclass.c | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmd/w1.c b/cmd/w1.c
index 9c95fcf..9765bd6 100644
--- a/cmd/w1.c
+++ b/cmd/w1.c
@@ -41,6 +41,7 @@ static int w1_bus(void)
 	return CMD_RET_SUCCESS;
 }
 
+#ifdef CONFIG_W1_EEPROM
 static int w1_read(int argc, char *const argv[])
 {
 	int bus_n = 0, dev_n = 0, offset = 0, len = 512;
@@ -102,6 +103,7 @@ static int w1_read(int argc, char *const argv[])
 
 	return CMD_RET_SUCCESS;
 }
+#endif
 
 int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -111,8 +113,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	if (!strcmp(argv[1], "bus"))
 		return w1_bus();
 
+#ifdef CONFIG_W1_EEPROM
 	if (!strcmp(argv[1], "read"))
 		return w1_read(argc, argv);
+#endif
 
 	return CMD_RET_SUCCESS;
 }
@@ -120,7 +124,10 @@ int do_w1(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 U_BOOT_CMD(w1, 6, 0, do_w1,
 	   "onewire interface utility commands",
 	   "bus - show onewire bus info (all)\n"
+#ifdef CONFIG_W1_EEPROM
 	   "w1 read [<bus> [<dev> [offset [length]]]]"
 	   "    - read from onewire device 'dev' on onewire bus 'bus'"
 	   " starting from offset 'offset' and length 'length'\n"
-	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes.");
+	   "      defaults: bus 0, dev 0, offset 0, length 512 bytes."
+#endif
+	   );
diff --git a/drivers/w1/w1-uclass.c b/drivers/w1/w1-uclass.c
index cb41b68..5544b19 100644
--- a/drivers/w1/w1-uclass.c
+++ b/drivers/w1/w1-uclass.c
@@ -100,8 +100,10 @@ static int w1_enumerate(struct udevice *bus)
 			debug("%s: Detected new device 0x%llx (family 0x%x)\n",
 			      bus->name, rn, (u8)(rn & 0xff));
 
+#ifdef CONFIG_W1_EEPROM
 			/* attempt to register as w1-eeprom device */
 			w1_eeprom_register_new_device(rn);
+#endif
 		}
 	}
 
-- 
1.9.1



More information about the U-Boot mailing list