From 7663a4aac625268674060d78ee00f97a36a03af7 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Wed, 10 Jun 2015 21:51:20 +0200 Subject: tools:iio: adjust coding style Fix various coding style issues, including: * have spaces around operators * indentation * consolidate parameters in same line * required braces * adjust/drop comments * multiline comment style * delete unnecessary empty lines * add empty lines to visualize logial code blocks * typos Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/lsiio.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tools/iio/lsiio.c') diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c index b59ee1733924..f5b3bd0267d5 100644 --- a/tools/iio/lsiio.c +++ b/tools/iio/lsiio.c @@ -20,7 +20,6 @@ #include #include "iio_utils.h" - static enum verbosity { VERBLEVEL_DEFAULT, /* 0 gives lspci behaviour */ VERBLEVEL_SENSORS, /* 1 lists sensors */ @@ -29,17 +28,16 @@ static enum verbosity { const char *type_device = "iio:device"; const char *type_trigger = "trigger"; - static inline int check_prefix(const char *str, const char *prefix) { return strlen(str) > strlen(prefix) && - strncmp(str, prefix, strlen(prefix)) == 0; + strncmp(str, prefix, strlen(prefix)) == 0; } static inline int check_postfix(const char *str, const char *postfix) { return strlen(str) > strlen(postfix) && - strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; + strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; } static int dump_channels(const char *dev_dir_name) @@ -50,11 +48,11 @@ static int dump_channels(const char *dev_dir_name) dp = opendir(dev_dir_name); if (dp == NULL) return -errno; + while (ent = readdir(dp), ent != NULL) if (check_prefix(ent->d_name, "in_") && - check_postfix(ent->d_name, "_raw")) { + check_postfix(ent->d_name, "_raw")) printf(" %-10s\n", ent->d_name); - } return (closedir(dp) == -1) ? -errno : 0; } @@ -69,6 +67,7 @@ static int dump_one_device(const char *dev_dir_name) "%i", &dev_idx); if (retval != 1) return -EINVAL; + retval = read_sysfs_string("name", dev_dir_name, name); if (retval) return retval; @@ -77,6 +76,7 @@ static int dump_one_device(const char *dev_dir_name) if (verblevel >= VERBLEVEL_SENSORS) return dump_channels(dev_dir_name); + return 0; } @@ -90,11 +90,13 @@ static int dump_one_trigger(const char *dev_dir_name) "%i", &dev_idx); if (retval != 1) return -EINVAL; + retval = read_sysfs_string("name", dev_dir_name, name); if (retval) return retval; printf("Trigger %03d: %s\n", dev_idx, name); + return 0; } @@ -151,6 +153,7 @@ static int dump_devices(void) free(dev_dir_name); } } + return (closedir(dp) == -1) ? -errno : 0; error_close_dir: -- cgit v1.2.3