summaryrefslogtreecommitdiffstats
path: root/tools/iio/lsiio.c
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-06-10 21:51:20 +0200
committerJonathan Cameron <jic23@kernel.org>2015-06-13 18:49:43 +0100
commit7663a4aac625268674060d78ee00f97a36a03af7 (patch)
tree36e0b59f93717880690914e5265976f3a477878e /tools/iio/lsiio.c
parent4f3ca89351e62f72144ca592c1c482e529d31539 (diff)
downloadlinux-7663a4aac625268674060d78ee00f97a36a03af7.tar.bz2
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 <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio/lsiio.c')
-rw-r--r--tools/iio/lsiio.c15
1 files changed, 9 insertions, 6 deletions
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 <sys/dir.h>
#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: