From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH v2 4/6] commands: Add 'hwmon' command
Date: Fri, 6 May 2016 07:09:28 -0700 [thread overview]
Message-ID: <1462543770-4619-5-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1462543770-4619-1-git-send-email-andrew.smirnov@gmail.com>
Add 'hwmon' command which allows to display the readings of all
hardware monitoring sensors registered with Barebox.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
commands/Kconfig | 8 ++++++++
commands/Makefile | 1 +
commands/hwmon.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 commands/hwmon.c
diff --git a/commands/Kconfig b/commands/Kconfig
index 57f2878..44a457b 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1830,6 +1830,14 @@ config CMD_HWCLOCK
help
The hwclock command allows to query or set the hardware clock (RTC).
+config CMD_HWMON
+ bool
+ depends on AIODEV
+ prompt "hwmon command"
+ default y
+ help
+ The hwmon command allows to query hardware sensors.
+
config CMD_I2C
bool
depends on I2C
diff --git a/commands/Makefile b/commands/Makefile
index 065d649..3c8ad77 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -107,6 +107,7 @@ obj-$(CONFIG_CMD_REGULATOR) += regulator.o
obj-$(CONFIG_CMD_LSPCI) += lspci.o
obj-$(CONFIG_CMD_IMD) += imd.o
obj-$(CONFIG_CMD_HWCLOCK) += hwclock.o
+obj-$(CONFIG_CMD_HWMON) += hwmon.o
obj-$(CONFIG_CMD_USBGADGET) += usbgadget.o
obj-$(CONFIG_CMD_FIRMWARELOAD) += firmwareload.o
obj-$(CONFIG_CMD_CMP) += cmp.o
diff --git a/commands/hwmon.c b/commands/hwmon.c
new file mode 100644
index 0000000..ace4503
--- /dev/null
+++ b/commands/hwmon.c
@@ -0,0 +1,35 @@
+#include <common.h>
+#include <command.h>
+#include <getopt.h>
+#include <linux/err.h>
+#include <linux/ctype.h>
+#include <string.h>
+#include <environment.h>
+#include <aiodev.h>
+
+static int do_hwmon(int argc, char *argv[])
+{
+ int i;
+ struct aiodevice *aiodev;
+
+ for_each_aiodevice(aiodev) {
+ for (i = 0; i < aiodev->num_channels; i++) {
+ struct aiochannel *chan = aiodev->channels[i];
+ int value;
+ int ret = aiochannel_get_value(chan, &value);
+
+ if (!ret)
+ printf("%s: %d %s\n", chan->name, value, chan->unit);
+ else
+ printf("%s: failed to read (%d)\n", chan->name, ret);
+ }
+ }
+
+ return 0;
+}
+
+BAREBOX_CMD_START(hwmon)
+ .cmd = do_hwmon,
+ BAREBOX_CMD_DESC("query hardware sensors (HWMON)")
+ BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
+BAREBOX_CMD_END
--
2.5.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-05-06 14:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 14:09 [PATCH v2 0/6] AIODEV subsystem Andrey Smirnov
2016-05-06 14:09 ` [PATCH v2 1/6] drivers: add nvmem framework from kernel Andrey Smirnov
2016-05-06 14:09 ` [PATCH v2 2/6] ocotp: Register OCOTP with 'nvmem' Andrey Smirnov
2016-05-06 14:09 ` [PATCH v2 3/6] drivers: Introduce AIODEV subsystem Andrey Smirnov
2016-05-06 14:09 ` Andrey Smirnov [this message]
2016-05-06 14:09 ` [PATCH v2 5/6] aiodev: Add TEMPMON driver Andrey Smirnov
2016-05-10 6:02 ` Sascha Hauer
2016-05-13 15:44 ` Andrey Smirnov
2016-05-06 14:09 ` [PATCH v2 6/6] aiodev: Add basic LM75 temperature driver Andrey Smirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462543770-4619-5-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox