mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 5/7] commands: Add 'hwmon' command
Date: Thu, 10 Dec 2015 14:20:32 +0300	[thread overview]
Message-ID: <20151210142032.6f0963858a89c7e3d2d8b061@gmail.com> (raw)
In-Reply-To: <1449474763-14099-5-git-send-email-andrew.smirnov@gmail.com>

On Sun,  6 Dec 2015 23:52:41 -0800
Andrey Smirnov <andrew.smirnov@gmail.com> wrote:

> 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  | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
>  create mode 100644 commands/hwmon.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 1743670..a338efd 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -1799,6 +1799,14 @@ config CMD_HWCLOCK
>  	help
>  	  The hwclock command allows to query or set the hardware clock (RTC).
> 
> +config CMD_HWMON
> +	bool
> +	depends on HWMON
> +	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 d985341..6c5158c 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -105,6 +105,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..84c0c70
> --- /dev/null
> +++ b/commands/hwmon.c
> @@ -0,0 +1,47 @@
> +#include <common.h>
> +#include <command.h>
> +#include <getopt.h>
> +#include <linux/err.h>
> +#include <linux/ctype.h>
> +#include <string.h>
> +#include <environment.h>
> +#include <hwmon.h>
> +
> +static int do_hwmon(int argc, char *argv[])
> +{
> +	struct hwmon_sensor *s;
> +
> +	for_each_hwmon_sensor(s) {
> +		s32 value;
> +		int ret = hwmon_sensor_read(s, &value);
> +
> +		if (ret < 0) {
> +			printf("%s -- failed to read the sensor (%d)\n", s->name, ret);
> +			continue;
> +		}
> +
> +		switch (s->type) {
> +		case SENSOR_TEMPERATURE:
> +			printf("name: %s, reading: %d.%03d C\n",
> +			       s->name, (int)(value / 1000), (int)abs(value % 1000));
> +			break;
> +		default:
> +			printf("%s -- unknow type of sensor\n", s->name);
> +			break;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +#if 0
> +BAREBOX_CMD_HELP_START(hwmon)
> +BAREBOX_CMD_HELP_END
> +#endif
> +

Please complete help stuff.


-- 
-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-12-10 10:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07  7:52 [PATCH 1/7] imx: ocotp: Add code to initialize 'cdev->device_node' Andrey Smirnov
2015-12-07  7:52 ` [PATCH 2/7] drivers: bus: Match against id_table first Andrey Smirnov
2015-12-07  7:52 ` [PATCH 3/7] i2c: Port two utility functions from Linux kernel Andrey Smirnov
2015-12-07  7:52 ` [PATCH 4/7] drivers: Introduce hardware monitoring subsystem Andrey Smirnov
2015-12-07  7:52 ` [PATCH 5/7] commands: Add 'hwmon' command Andrey Smirnov
2015-12-10 11:20   ` Antony Pavlov [this message]
2015-12-07  7:52 ` [PATCH 6/7] hwmon: Port Linux driver for LM75 sensor Andrey Smirnov
2015-12-07  7:52 ` [PATCH 7/7] hwmon: Port TEMPMON sensor driver Andrey Smirnov
2015-12-07 19:05   ` Trent Piepho
2015-12-07 19:40     ` Andrey Smirnov
2015-12-07 19:52       ` Trent Piepho
2015-12-07 19:56         ` Andrey Smirnov
2015-12-07 10:23 ` [PATCH 1/7] imx: ocotp: Add code to initialize 'cdev->device_node' Sascha Hauer
2015-12-07 19:35   ` 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=20151210142032.6f0963858a89c7e3d2d8b061@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=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