diff mbox series

[2/3] hwmon: Add convience macro to define simple static sensors

Message ID 20190320145818.30644-2-ckeepax@opensource.cirrus.com (mailing list archive)
State Accepted
Headers show
Series [1/3] hwmon: lochnagar: Add device tree binding document | expand

Commit Message

Charles Keepax March 20, 2019, 2:58 p.m. UTC
It takes a fair amount of boiler plate code to add new sensors, add a
macro that can be used to specify simple static sensors.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 include/linux/hwmon.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Guenter Roeck March 20, 2019, 5:38 p.m. UTC | #1
On Wed, Mar 20, 2019 at 02:58:17PM +0000, Charles Keepax wrote:
> It takes a fair amount of boiler plate code to add new sensors, add a
> macro that can be used to specify simple static sensors.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Great idea!

Applied to hwmon-next; no need to resend.

Thanks,
Guenter

> ---
>  include/linux/hwmon.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
> index 99e0c1b0b5fb3..7a8cc06a0d61d 100644
> --- a/include/linux/hwmon.h
> +++ b/include/linux/hwmon.h
> @@ -365,6 +365,14 @@ struct hwmon_channel_info {
>  	const u32 *config;
>  };
>  
> +#define HWMON_CHANNEL_INFO(stype, ...)	\
> +	(&(struct hwmon_channel_info) {	\
> +		.type = hwmon_##stype,	\
> +		.config = (u32 []) {	\
> +			__VA_ARGS__, 0	\
> +		}			\
> +	})
> +
>  /**
>   * Chip configuration
>   * @ops:	Pointer to hwmon operations.
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 99e0c1b0b5fb3..7a8cc06a0d61d 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -365,6 +365,14 @@  struct hwmon_channel_info {
 	const u32 *config;
 };
 
+#define HWMON_CHANNEL_INFO(stype, ...)	\
+	(&(struct hwmon_channel_info) {	\
+		.type = hwmon_##stype,	\
+		.config = (u32 []) {	\
+			__VA_ARGS__, 0	\
+		}			\
+	})
+
 /**
  * Chip configuration
  * @ops:	Pointer to hwmon operations.