diff options
author | David Lechner <dlechner@baylibre.com> | 2023-09-21 17:43:44 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2023-09-24 20:54:55 +0300 |
commit | c78a96ab0f52a12b344882241019dd9070aa988c (patch) | |
tree | a2f9ab75a0d4542c5d839287a0f6ee0f4a1af8f6 /drivers | |
parent | efea15e3c65d96bac17a4d8104e3fff7c07cc910 (diff) | |
download | linux-c78a96ab0f52a12b344882241019dd9070aa988c.tar.xz |
staging: iio: resolver: ad2s1210: fix ad2s1210_show_fault
When reading the fault attribute, an empty string was printed if the
fault register value was non-zero.
This is fixed by checking that the return value is less than zero
instead of not zero.
Also always print two hex digits while we are touching this line.
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20230921144400.62380-4-dlechner@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/resolver/ad2s1210.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 06de5823eb8e..7fb2d9e3196f 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -393,7 +393,7 @@ static ssize_t ad2s1210_show_fault(struct device *dev, ret = ad2s1210_config_read(st, AD2S1210_REG_FAULT); mutex_unlock(&st->lock); - return ret ? ret : sprintf(buf, "0x%x\n", ret); + return ret < 0 ? ret : sprintf(buf, "0x%02x\n", ret); } static ssize_t ad2s1210_clear_fault(struct device *dev, |