2022-08-25 22:20:12

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 0/2] hwmon: Add include stubs

Currently, hwmon.h and hwmon-vid.h provide no stub definitions
in case hwmon/hwmon-vid support was disabled. This forces drivers
using those functions to either select CONFIG_HWMON or to use
lots of #ifdef to avoid compilation errors in such a case.
One example is the ath10k driver, but radeon and amdgpu
would also profit from being able to no longer having to select
CONFIG_HWMON.

The first patch adds include stubs to hwmon.h and hwmon-vid.h
so that drivers can omit such workarounds.

The second patch fixes a minor issue in hwmon.h.

Both patches where tested with CONFIG_HWMON set to y, m and n,
and the resulting kernel was able to boot successfully.

Armin Wolf (2):
hwmon: Add include stubs
hwmon: Use struct definitions from header files

include/linux/hwmon-vid.h | 18 +++++++++
include/linux/hwmon.h | 81 +++++++++++++++++++++++++++++++++++++--
2 files changed, 95 insertions(+), 4 deletions(-)

--
2.30.2


2022-08-25 22:44:35

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 2/2] hwmon: Use struct definitions from header files

The structs attribute_group and device are provided
by linux/sysfs.h and linux/device.h.
Use those definitions.

Signed-off-by: Armin Wolf <[email protected]>
---
include/linux/hwmon.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 281387ee03bc..e8acc35af12d 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -13,12 +13,11 @@
#define _HWMON_H_

#include <linux/bitops.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/kconfig.h>
-
-struct device;
-struct attribute_group;
+#include <linux/sysfs.h>

enum hwmon_sensor_types {
hwmon_chip,
--
2.30.2

2022-08-26 12:37:18

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 2/2] hwmon: Use struct definitions from header files

On Thu, Aug 25, 2022 at 11:43:41PM +0200, Armin Wolf wrote:
> The structs attribute_group and device are provided
> by linux/sysfs.h and linux/device.h.
> Use those definitions.
>

No. The limited definitions are on purpose, meaning the details
are not needed in this header file and that drivers using the
structures must include the necessary files directly. That is what
struct declarations without details are to be used for in C, and
there is neither a desire nor need to change that code.

Guenter

> Signed-off-by: Armin Wolf <[email protected]>
> ---
> include/linux/hwmon.h | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
> index 281387ee03bc..e8acc35af12d 100644
> --- a/include/linux/hwmon.h
> +++ b/include/linux/hwmon.h
> @@ -13,12 +13,11 @@
> #define _HWMON_H_
>
> #include <linux/bitops.h>
> +#include <linux/device.h>
> #include <linux/err.h>
> #include <linux/errno.h>
> #include <linux/kconfig.h>
> -
> -struct device;
> -struct attribute_group;
> +#include <linux/sysfs.h>
>
> enum hwmon_sensor_types {
> hwmon_chip,
> --
> 2.30.2
>