diff options
author | Jacopo Mondi <jacopo+renesas@jmondi.org> | 2017-09-28 09:01:44 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-10-06 18:03:14 -0400 |
commit | d327a224ba2cbe234d82fd560ff8e5bb38b0bb4b (patch) | |
tree | dbc2c02afc0944051f97c219c915c34f81768abe /tools/gpio/gpio-utils.c | |
parent | a3c1295280c8ac0823d0cac06f88a53928781a37 (diff) |
tools: gpio: Print error string on IOCTL failures
Add to error messages the error description by concatenating
output of strerror() function to error messages print out by
gpio-utils.c on IOCTL failures.
Rationalize error messages, while at there, making all of them
look the same.
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'tools/gpio/gpio-utils.c')
-rw-r--r-- | tools/gpio/gpio-utils.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c index b86a32d90d88..cf7e2f3419ee 100644 --- a/tools/gpio/gpio-utils.c +++ b/tools/gpio/gpio-utils.c | |||
@@ -76,7 +76,8 @@ int gpiotools_request_linehandle(const char *device_name, unsigned int *lines, | |||
76 | fd = open(chrdev_name, 0); | 76 | fd = open(chrdev_name, 0); |
77 | if (fd == -1) { | 77 | if (fd == -1) { |
78 | ret = -errno; | 78 | ret = -errno; |
79 | fprintf(stderr, "Failed to open %s\n", chrdev_name); | 79 | fprintf(stderr, "Failed to open %s, %s\n", |
80 | chrdev_name, strerror(errno)); | ||
80 | goto exit_close_error; | 81 | goto exit_close_error; |
81 | } | 82 | } |
82 | 83 | ||
@@ -92,8 +93,8 @@ int gpiotools_request_linehandle(const char *device_name, unsigned int *lines, | |||
92 | ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req); | 93 | ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req); |
93 | if (ret == -1) { | 94 | if (ret == -1) { |
94 | ret = -errno; | 95 | ret = -errno; |
95 | fprintf(stderr, "Failed to issue GET LINEHANDLE IOCTL (%d)\n", | 96 | fprintf(stderr, "Failed to issue %s (%d), %s\n", |
96 | ret); | 97 | "GPIO_GET_LINEHANDLE_IOCTL", ret, strerror(errno)); |
97 | } | 98 | } |
98 | 99 | ||
99 | exit_close_error: | 100 | exit_close_error: |
@@ -118,8 +119,9 @@ int gpiotools_set_values(const int fd, struct gpiohandle_data *data) | |||
118 | ret = ioctl(fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, data); | 119 | ret = ioctl(fd, GPIOHANDLE_SET_LINE_VALUES_IOCTL, data); |
119 | if (ret == -1) { | 120 | if (ret == -1) { |
120 | ret = -errno; | 121 | ret = -errno; |
121 | fprintf(stderr, "Failed to issue %s (%d)\n", | 122 | fprintf(stderr, "Failed to issue %s (%d), %s\n", |
122 | "GPIOHANDLE_SET_LINE_VALUES_IOCTL", ret); | 123 | "GPIOHANDLE_SET_LINE_VALUES_IOCTL", ret, |
124 | strerror(errno)); | ||
123 | } | 125 | } |
124 | 126 | ||
125 | return ret; | 127 | return ret; |
@@ -141,8 +143,9 @@ int gpiotools_get_values(const int fd, struct gpiohandle_data *data) | |||
141 | ret = ioctl(fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, data); | 143 | ret = ioctl(fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, data); |
142 | if (ret == -1) { | 144 | if (ret == -1) { |
143 | ret = -errno; | 145 | ret = -errno; |
144 | fprintf(stderr, "Failed to issue %s (%d)\n", | 146 | fprintf(stderr, "Failed to issue %s (%d), %s\n", |
145 | "GPIOHANDLE_GET_LINE_VALUES_IOCTL", ret); | 147 | "GPIOHANDLE_GET_LINE_VALUES_IOCTL", ret, |
148 | strerror(errno)); | ||
146 | } | 149 | } |
147 | 150 | ||
148 | return ret; | 151 | return ret; |