]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tools: gpio: rename nlines to num_lines
authorKent Gibson <warthog618@gmail.com>
Mon, 28 Sep 2020 00:28:03 +0000 (08:28 +0800)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 30 Sep 2020 08:57:17 +0000 (10:57 +0200)
Rename nlines to num_lines to be consistent with other usage for fields
describing the number of entries in an array.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
tools/gpio/gpio-hammer.c
tools/gpio/gpio-utils.c
tools/gpio/gpio-utils.h

index 9fd926e8cb5248377c775012786b1dafaeb092ab..a2c7577fad5c5263f2826871b4b22bfc44f92583 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/gpio.h>
 #include "gpio-utils.h"
 
-int hammer_device(const char *device_name, unsigned int *lines, int nlines,
+int hammer_device(const char *device_name, unsigned int *lines, int num_lines,
                  unsigned int loops)
 {
        struct gpiohandle_data data;
@@ -33,7 +33,7 @@ int hammer_device(const char *device_name, unsigned int *lines, int nlines,
        unsigned int iteration = 0;
 
        memset(&data.values, 0, sizeof(data.values));
-       ret = gpiotools_request_linehandle(device_name, lines, nlines,
+       ret = gpiotools_request_linehandle(device_name, lines, num_lines,
                                           GPIOHANDLE_REQUEST_OUTPUT, &data,
                                           "gpio-hammer");
        if (ret < 0)
@@ -46,15 +46,15 @@ int hammer_device(const char *device_name, unsigned int *lines, int nlines,
                goto exit_close_error;
 
        fprintf(stdout, "Hammer lines [");
-       for (i = 0; i < nlines; i++) {
+       for (i = 0; i < num_lines; i++) {
                fprintf(stdout, "%d", lines[i]);
-               if (i != (nlines - 1))
+               if (i != (num_lines - 1))
                        fprintf(stdout, ", ");
        }
        fprintf(stdout, "] on %s, initial states: [", device_name);
-       for (i = 0; i < nlines; i++) {
+       for (i = 0; i < num_lines; i++) {
                fprintf(stdout, "%d", data.values[i]);
-               if (i != (nlines - 1))
+               if (i != (num_lines - 1))
                        fprintf(stdout, ", ");
        }
        fprintf(stdout, "]\n");
@@ -63,7 +63,7 @@ int hammer_device(const char *device_name, unsigned int *lines, int nlines,
        j = 0;
        while (1) {
                /* Invert all lines so we blink */
-               for (i = 0; i < nlines; i++)
+               for (i = 0; i < num_lines; i++)
                        data.values[i] = !data.values[i];
 
                ret = gpiotools_set_values(fd, &data);
@@ -81,9 +81,9 @@ int hammer_device(const char *device_name, unsigned int *lines, int nlines,
                        j = 0;
 
                fprintf(stdout, "[");
-               for (i = 0; i < nlines; i++) {
+               for (i = 0; i < num_lines; i++) {
                        fprintf(stdout, "%d: %d", lines[i], data.values[i]);
-                       if (i != (nlines - 1))
+                       if (i != (num_lines - 1))
                                fprintf(stdout, ", ");
                }
                fprintf(stdout, "]\r");
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
        const char *device_name = NULL;
        unsigned int lines[GPIOHANDLES_MAX];
        unsigned int loops = 0;
-       int nlines;
+       int num_lines;
        int c;
        int i;
 
@@ -158,11 +158,11 @@ int main(int argc, char **argv)
                return -1;
        }
 
-       nlines = i;
+       num_lines = i;
 
-       if (!device_name || !nlines) {
+       if (!device_name || !num_lines) {
                print_usage();
                return -1;
        }
-       return hammer_device(device_name, lines, nlines, loops);
+       return hammer_device(device_name, lines, num_lines, loops);
 }
index 16a5d9cb9da280073ea7892ab342b8ded46a4370..d527980bcb940a1b935dcb7c47eacf1fb95774d4 100644 (file)
@@ -38,7 +38,7 @@
  *                     such as "gpiochip0"
  * @lines:             An array desired lines, specified by offset
  *                     index for the associated GPIO device.
- * @nline:             The number of lines to request.
+ * @num_lines:         The number of lines to request.
  * @flag:              The new flag for requsted gpio. Reference
  *                     "linux/gpio.h" for the meaning of flag.
  * @data:              Default value will be set to gpio when flag is
@@ -56,7 +56,7 @@
  *                     On failure return the errno.
  */
 int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
-                                unsigned int nlines, unsigned int flag,
+                                unsigned int num_lines, unsigned int flag,
                                 struct gpiohandle_data *data,
                                 const char *consumer_label)
 {
@@ -78,12 +78,12 @@ int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
                goto exit_free_name;
        }
 
-       for (i = 0; i < nlines; i++)
+       for (i = 0; i < num_lines; i++)
                req.lineoffsets[i] = lines[i];
 
        req.flags = flag;
        strcpy(req.consumer_label, consumer_label);
-       req.lines = nlines;
+       req.lines = num_lines;
        if (flag & GPIOHANDLE_REQUEST_OUTPUT)
                memcpy(req.default_values, data, sizeof(req.default_values));
 
@@ -194,20 +194,20 @@ int gpiotools_get(const char *device_name, unsigned int line)
  *                     such as "gpiochip0".
  * @lines:             An array desired lines, specified by offset
  *                     index for the associated GPIO device.
- * @nline:             The number of lines to request.
+ * @num_lines:         The number of lines to request.
  * @data:              The array of values get from gpiochip.
  *
  * Return:             On success return 0;
  *                     On failure return the errno.
  */
 int gpiotools_gets(const char *device_name, unsigned int *lines,
-                  unsigned int nlines, struct gpiohandle_data *data)
+                  unsigned int num_lines, struct gpiohandle_data *data)
 {
        int fd;
        int ret;
        int ret_close;
 
-       ret = gpiotools_request_linehandle(device_name, lines, nlines,
+       ret = gpiotools_request_linehandle(device_name, lines, num_lines,
                                           GPIOHANDLE_REQUEST_INPUT, data,
                                           CONSUMER);
        if (ret < 0)
@@ -245,7 +245,7 @@ int gpiotools_set(const char *device_name, unsigned int line,
  *                     such as "gpiochip0".
  * @lines:             An array desired lines, specified by offset
  *                     index for the associated GPIO device.
- * @nline:             The number of lines to request.
+ * @num_lines:         The number of lines to request.
  * @data:              The array of values set to gpiochip, must be
  *                     0(low) or 1(high).
  *
@@ -253,11 +253,11 @@ int gpiotools_set(const char *device_name, unsigned int line,
  *                     On failure return the errno.
  */
 int gpiotools_sets(const char *device_name, unsigned int *lines,
-                  unsigned int nlines, struct gpiohandle_data *data)
+                  unsigned int num_lines, struct gpiohandle_data *data)
 {
        int ret;
 
-       ret = gpiotools_request_linehandle(device_name, lines, nlines,
+       ret = gpiotools_request_linehandle(device_name, lines, num_lines,
                                           GPIOHANDLE_REQUEST_OUTPUT, data,
                                           CONSUMER);
        if (ret < 0)
index cf37f13f3dcbcdeaf9b4cb219077f9bd04788153..3247295778651d26dea39a1ee32e23f0c9d45499 100644 (file)
@@ -23,7 +23,7 @@ static inline int check_prefix(const char *str, const char *prefix)
 }
 
 int gpiotools_request_linehandle(const char *device_name, unsigned int *lines,
-                                unsigned int nlines, unsigned int flag,
+                                unsigned int num_lines, unsigned int flag,
                                 struct gpiohandle_data *data,
                                 const char *consumer_label);
 int gpiotools_set_values(const int fd, struct gpiohandle_data *data);
@@ -32,10 +32,10 @@ int gpiotools_release_linehandle(const int fd);
 
 int gpiotools_get(const char *device_name, unsigned int line);
 int gpiotools_gets(const char *device_name, unsigned int *lines,
-                  unsigned int nlines, struct gpiohandle_data *data);
+                  unsigned int num_lines, struct gpiohandle_data *data);
 int gpiotools_set(const char *device_name, unsigned int line,
                  unsigned int value);
 int gpiotools_sets(const char *device_name, unsigned int *lines,
-                  unsigned int nlines, struct gpiohandle_data *data);
+                  unsigned int num_lines, struct gpiohandle_data *data);
 
 #endif /* _GPIO_UTILS_H_ */