mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
w1: ds2406: use crc16() instead of crc16_byte() loop
Instead of looping through each byte and calling crc16_byte(), instead just call crc16() on the whole buffer. No functional change. Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Acked-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20250513022115.39109-2-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
@@ -29,8 +29,6 @@ static ssize_t w1_f12_read_state(
|
||||
{
|
||||
u8 w1_buf[6] = {W1_F12_FUNC_READ_STATUS, 7, 0, 0, 0, 0};
|
||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||
u16 crc = 0;
|
||||
int i;
|
||||
ssize_t rtnval = 1;
|
||||
|
||||
if (off != 0)
|
||||
@@ -47,9 +45,7 @@ static ssize_t w1_f12_read_state(
|
||||
|
||||
w1_write_block(sl->master, w1_buf, 3);
|
||||
w1_read_block(sl->master, w1_buf+3, 3);
|
||||
for (i = 0; i < 6; i++)
|
||||
crc = crc16_byte(crc, w1_buf[i]);
|
||||
if (crc == 0xb001) /* good read? */
|
||||
if (crc16(0, w1_buf, sizeof(w1_buf)) == 0xb001) /* good read? */
|
||||
*buf = ((w1_buf[3]>>5)&3)|0x30;
|
||||
else
|
||||
rtnval = -EIO;
|
||||
@@ -66,8 +62,6 @@ static ssize_t w1_f12_write_output(
|
||||
{
|
||||
struct w1_slave *sl = kobj_to_w1_slave(kobj);
|
||||
u8 w1_buf[6] = {W1_F12_FUNC_WRITE_STATUS, 7, 0, 0, 0, 0};
|
||||
u16 crc = 0;
|
||||
int i;
|
||||
ssize_t rtnval = 1;
|
||||
|
||||
if (count != 1 || off != 0)
|
||||
@@ -83,9 +77,7 @@ static ssize_t w1_f12_write_output(
|
||||
w1_buf[3] = (((*buf)&3)<<5)|0x1F;
|
||||
w1_write_block(sl->master, w1_buf, 4);
|
||||
w1_read_block(sl->master, w1_buf+4, 2);
|
||||
for (i = 0; i < 6; i++)
|
||||
crc = crc16_byte(crc, w1_buf[i]);
|
||||
if (crc == 0xb001) /* good read? */
|
||||
if (crc16(0, w1_buf, sizeof(w1_buf)) == 0xb001) /* good read? */
|
||||
w1_write_8(sl->master, 0xFF);
|
||||
else
|
||||
rtnval = -EIO;
|
||||
|
||||
Reference in New Issue
Block a user