w1: ds2438: fixing bug that would always get page0
authorLuiz Sampaio <sampaio.ime@gmail.com>
Wed, 19 May 2021 22:30:44 +0000 (19:30 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:17:49 +0000 (16:17 +0200)
[ Upstream commit 1f5e7518f063728aee0679c5086b92d8ea429e11 ]

The purpose of the w1_ds2438_get_page function is to get the register
values at the page passed as the pageno parameter. However, the page0 was
hardcoded, such that the function always returned the page0 contents. Fixed
so that the function can retrieve any page.

Signed-off-by: Luiz Sampaio <sampaio.ime@gmail.com>
Link: https://lore.kernel.org/r/20210519223046.13798-5-sampaio.ime@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/w1/slaves/w1_ds2438.c

index 7c4e33dbee4d5b332c3fd8cb5355b979faf3437d..b005dda9c69788461a482ff94a5b7b364a3d7e6d 100644 (file)
@@ -64,13 +64,13 @@ static int w1_ds2438_get_page(struct w1_slave *sl, int pageno, u8 *buf)
                if (w1_reset_select_slave(sl))
                        continue;
                w1_buf[0] = W1_DS2438_RECALL_MEMORY;
-               w1_buf[1] = 0x00;
+               w1_buf[1] = (u8)pageno;
                w1_write_block(sl->master, w1_buf, 2);
 
                if (w1_reset_select_slave(sl))
                        continue;
                w1_buf[0] = W1_DS2438_READ_SCRATCH;
-               w1_buf[1] = 0x00;
+               w1_buf[1] = (u8)pageno;
                w1_write_block(sl->master, w1_buf, 2);
 
                count = w1_read_block(sl->master, buf, DS2438_PAGE_SIZE + 1);