diff options
author | Mariusz Bialonczyk <manio@skyboo.net> | 2019-05-30 03:51:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-06 10:15:21 -0400 |
commit | aacd152ecd7b18af5d2d96dea9e7284c1c93abea (patch) | |
tree | 8f9cddd2386e64458cc32367c218f4baa1cc014f | |
parent | 7e706da35a458f4b0d4c565c7b71023d8bfe279b (diff) |
w1: ds2413: fix state byte comparision
This commit is fixing a smatch warning:
drivers/w1/slaves/w1_ds2413.c:61 state_read() warn: impossible condition '(*buf == 255) => ((-128)-127 == 255)'
by creating additional u8 variable for the bus reading and comparision
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 3856032a0628 ("w1: ds2413: when the slave is not responding during read, select it again")
Signed-off-by: Mariusz Bialonczyk <manio@skyboo.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/w1/slaves/w1_ds2413.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c index 21f08ac8a4e0..3364ad276b15 100644 --- a/drivers/w1/slaves/w1_ds2413.c +++ b/drivers/w1/slaves/w1_ds2413.c | |||
@@ -33,6 +33,7 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj, | |||
33 | struct w1_slave *sl = kobj_to_w1_slave(kobj); | 33 | struct w1_slave *sl = kobj_to_w1_slave(kobj); |
34 | unsigned int retries = W1_F3A_RETRIES; | 34 | unsigned int retries = W1_F3A_RETRIES; |
35 | ssize_t bytes_read = -EIO; | 35 | ssize_t bytes_read = -EIO; |
36 | u8 state; | ||
36 | 37 | ||
37 | dev_dbg(&sl->dev, | 38 | dev_dbg(&sl->dev, |
38 | "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", | 39 | "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", |
@@ -53,12 +54,13 @@ next: | |||
53 | while (retries--) { | 54 | while (retries--) { |
54 | w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ); | 55 | w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ); |
55 | 56 | ||
56 | *buf = w1_read_8(sl->master); | 57 | state = w1_read_8(sl->master); |
57 | if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) { | 58 | if ((state & 0x0F) == ((~state >> 4) & 0x0F)) { |
58 | /* complement is correct */ | 59 | /* complement is correct */ |
60 | *buf = state; | ||
59 | bytes_read = 1; | 61 | bytes_read = 1; |
60 | goto out; | 62 | goto out; |
61 | } else if (*buf == W1_F3A_INVALID_PIO_STATE) { | 63 | } else if (state == W1_F3A_INVALID_PIO_STATE) { |
62 | /* slave didn't respond, try to select it again */ | 64 | /* slave didn't respond, try to select it again */ |
63 | dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \ | 65 | dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \ |
64 | "reselecting, retries left: %d\n", retries); | 66 | "reselecting, retries left: %d\n", retries); |