From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugen.Hristev at microchip.com Date: Tue, 23 Oct 2018 07:07:34 +0000 Subject: [U-Boot] [PATCH] w1: fix build without CONFIG_W1_EEPROM In-Reply-To: <1540227116-25592-1-git-send-email-martin.fuzzey@flowbird.group> References: <1540227116-25592-1-git-send-email-martin.fuzzey@flowbird.group> Message-ID: <4102be14-84c6-7984-5dd4-20df126818dc@microchip.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 22.10.2018 19:51, Martin Fuzzey wrote: > 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. I would prefer if you let the w1 read command to be accessible regardless if CONFIG_W1_EEPROM is defined or not. Hence have only the w1 eeprom reads under the ifdef... The w1_read checks for devices anyway and for the bus, so it should print invalid bus/device if nothing is present there. Any opinion on this ? Thanks, Eugen > > Signed-off-by: Martin Fuzzey > --- > 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 [ [ [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 > } > } > >