Skip to contentSkip to conversation

hwmon: (occ) Move common code to a separate module

PATCH In review Jean Delvare 3 participants 7 messages Apr 10, 2019 – Apr 11, 2019 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 hwmon: (occ) Move common code to a separate module

Instead of duplicating the common code into the 2 (binary) drivers, move the common code to a separate module. This is cleaner.

Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

---
Eddie, can you please give it a try and confirm it works?

Note: I kept the module names as they were before, hence the extra "*-objs :=" statements. They could be removed if we rename the source files, but that's better done in git directly. I don't mind either way personally.

 drivers/hwmon/occ/Kconfig  |    3 +--
 drivers/hwmon/occ/Makefile |    6 ++++--
 drivers/hwmon/occ/common.c |    7 +++++++
 drivers/hwmon/occ/sysfs.c  |    2 ++
 4 files changed, 14 insertions(+), 4 deletions(-)
drivers/hwmon/occ/Kconfig +1 -2
@@ -27,5 +27,4 @@ config SENSORS_OCC_P9_SBE
 	 called occ-p9-hwmon.
 
 config SENSORS_OCC
-	bool "POWER On-Chip Controller"
-	depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE
+	tristate
drivers/hwmon/occ/Makefile +4 -2
@@ -1,5 +1,7 @@
-occ-p8-hwmon-objs := common.o sysfs.o p8_i2c.o
-occ-p9-hwmon-objs := common.o sysfs.o p9_sbe.o
+occ-hwmon-common-objs := common.o sysfs.o
+occ-p8-hwmon-objs := p8_i2c.o
+occ-p9-hwmon-objs := p9_sbe.o
 
+obj-$(CONFIG_SENSORS_OCC) += occ-hwmon-common.o
 obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o
 obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o
drivers/hwmon/occ/common.c +7 -0
@@ -1,11 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/math64.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
 #include <asm/unaligned.h>
@@ -1096,3 +1098,8 @@ int occ_setup(struct occ *occ, const cha
 
 	return rc;
 }
+EXPORT_SYMBOL_GPL(occ_setup);
+
+MODULE_AUTHOR("Eddie James <[email protected]>");
+MODULE_DESCRIPTION("Common OCC hwmon code");
+MODULE_LICENSE("GPL");
drivers/hwmon/occ/sysfs.c +2 -0
@@ -12,6 +12,7 @@
 
 #include <linux/bitops.h>
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
@@ -186,3 +187,4 @@ void occ_shutdown(struct occ *occ)
 {
 	sysfs_remove_group(&occ->bus_dev->kobj, &occ_sysfs);
 }
+EXPORT_SYMBOL_GPL(occ_shutdown);
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw

PATCH v2 2/2 hwmon: OCC drivers are ARM-only

These drivers are for a BMC inside PowerPC servers. The BMC runs on ARM hardware, so only propose the drivers on this architecture, unless build-testing.

Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

---
If PowerPC BMCs are ever based on another architecture and these drivers are compatible with them, then the list can be extended.

 drivers/hwmon/occ/Kconfig |    2 ++
 1 file changed, 2 insertions(+)
drivers/hwmon/occ/Kconfig +2 -0
@@ -5,6 +5,7 @@
 config SENSORS_OCC_P8_I2C
 	tristate "POWER8 OCC through I2C"
 	depends on I2C
+	depends on ARM || ARM64 || COMPILE_TEST
 	select SENSORS_OCC
 	help
 	 This option enables support for monitoring sensors provided by the
@@ -17,6 +18,7 @@ config SENSORS_OCC_P8_I2C
 config SENSORS_OCC_P9_SBE
 	tristate "POWER9 OCC through SBE"
 	depends on FSI_OCC
+	depends on ARM || ARM64 || COMPILE_TEST
 	select SENSORS_OCC
 	help
 	 This option enables support for monitoring sensors provided by the
Signature · 2 lines
Jean Delvare
SUSE L3 Support
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] hwmon: OCC drivers are ARM-only

Quoted 3 lines · Jean Delvare

These drivers are for a BMC inside PowerPC servers. The BMC runs on ARM hardware, so only propose the drivers on this architecture, unless build-testing.

Thanks!

Quoted 30 lines
Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

---
If PowerPC BMCs are ever based on another architecture and these drivers are compatible with them, then the list can be extended.

  drivers/hwmon/occ/Kconfig |    2 ++
  1 file changed, 2 insertions(+)
drivers/hwmon/occ/Kconfig +2 -0
@@ -5,6 +5,7 @@
  config SENSORS_OCC_P8_I2C
  	tristate "POWER8 OCC through I2C"
  	depends on I2C
+	depends on ARM || ARM64 || COMPILE_TEST
  	select SENSORS_OCC
  	help
  	 This option enables support for monitoring sensors provided by the
@@ -17,6 +18,7 @@ config SENSORS_OCC_P8_I2C
  config SENSORS_OCC_P9_SBE
  	tristate "POWER9 OCC through SBE"
  	depends on FSI_OCC
+	depends on ARM || ARM64 || COMPILE_TEST
  	select SENSORS_OCC
  	help
  	 This option enables support for monitoring sensors provided by the
Reviewed-by Tested-by on v2 1/2
#3 lore raw
In reply to Jean Delvare
Quoted 8 lines · Jean Delvare

Instead of duplicating the common code into the 2 (binary) drivers, move the common code to a separate module. This is cleaner.

Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

---
Eddie, can you please give it a try and confirm it works?

Yes, this works well.

Quoted 75 lines

Note: I kept the module names as they were before, hence the extra "*-objs :=" statements. They could be removed if we rename the source files, but that's better done in git directly. I don't mind either way personally.

  drivers/hwmon/occ/Kconfig  |    3 +--
  drivers/hwmon/occ/Makefile |    6 ++++--
  drivers/hwmon/occ/common.c |    7 +++++++
  drivers/hwmon/occ/sysfs.c  |    2 ++
  4 files changed, 14 insertions(+), 4 deletions(-)
drivers/hwmon/occ/Kconfig +1 -2
@@ -27,5 +27,4 @@ config SENSORS_OCC_P9_SBE
  	 called occ-p9-hwmon.
 
  config SENSORS_OCC
-	bool "POWER On-Chip Controller"
-	depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE
+	tristate
drivers/hwmon/occ/Makefile +4 -2
@@ -1,5 +1,7 @@
-occ-p8-hwmon-objs := common.o sysfs.o p8_i2c.o
-occ-p9-hwmon-objs := common.o sysfs.o p9_sbe.o
+occ-hwmon-common-objs := common.o sysfs.o
+occ-p8-hwmon-objs := p8_i2c.o
+occ-p9-hwmon-objs := p9_sbe.o
 
+obj-$(CONFIG_SENSORS_OCC) += occ-hwmon-common.o
  obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o
  obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o
drivers/hwmon/occ/common.c +7 -0
@@ -1,11 +1,13 @@
  // SPDX-License-Identifier: GPL-2.0
 
  #include <linux/device.h>
+#include <linux/export.h>
  #include <linux/hwmon.h>
  #include <linux/hwmon-sysfs.h>
  #include <linux/jiffies.h>
  #include <linux/kernel.h>
  #include <linux/math64.h>
+#include <linux/module.h>
  #include <linux/mutex.h>
  #include <linux/sysfs.h>
  #include <asm/unaligned.h>
@@ -1096,3 +1098,8 @@ int occ_setup(struct occ *occ, const cha
 
  	return rc;
  }
+EXPORT_SYMBOL_GPL(occ_setup);
+
+MODULE_AUTHOR("Eddie James <[email protected]>");
+MODULE_DESCRIPTION("Common OCC hwmon code");
+MODULE_LICENSE("GPL");
drivers/hwmon/occ/sysfs.c +2 -0
@@ -12,6 +12,7 @@
 
  #include <linux/bitops.h>
  #include <linux/device.h>
+#include <linux/export.h>
  #include <linux/hwmon-sysfs.h>
  #include <linux/kernel.h>
  #include <linux/sysfs.h>
@@ -186,3 +187,4 @@ void occ_shutdown(struct occ *occ)
  {
  	sysfs_remove_group(&occ->bus_dev->kobj, &occ_sysfs);
  }
+EXPORT_SYMBOL_GPL(occ_shutdown);
#4 lore raw
Quoted 11 lines · Eddie James
Quoted 8 lines · Jean Delvare

Instead of duplicating the common code into the 2 (binary) drivers, move the common code to a separate module. This is cleaner.

Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

---
Eddie, can you please give it a try and confirm it works?

Quoted 5 lines

Yes, this works well.

Thanks. Can you please send a patch on top of that updating the help texts in Kconfig to explain that the drivers are for the BMC and not for the PowerPC host OS, as discussed before?

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
maintainer
#5 lore raw
In reply to Jean Delvare

Jean,

Quoted 6 lines · Jean Delvare

Instead of duplicating the common code into the 2 (binary) drivers, move the common code to a separate module. This is cleaner.

Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

what is the parent release for this patch ? I tried to apply it to mainline and to hwmon-next using git am, but both failed.

Thanks,
Guenter

Quoted 80 lines

---
Eddie, can you please give it a try and confirm it works?

Note: I kept the module names as they were before, hence the extra "*-objs :=" statements. They could be removed if we rename the source files, but that's better done in git directly. I don't mind either way personally.

 drivers/hwmon/occ/Kconfig  |    3 +--
 drivers/hwmon/occ/Makefile |    6 ++++--
 drivers/hwmon/occ/common.c |    7 +++++++
 drivers/hwmon/occ/sysfs.c  |    2 ++
 4 files changed, 14 insertions(+), 4 deletions(-)
drivers/hwmon/occ/Kconfig +1 -2
@@ -27,5 +27,4 @@ config SENSORS_OCC_P9_SBE
 	 called occ-p9-hwmon.
 
 config SENSORS_OCC
-	bool "POWER On-Chip Controller"
-	depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE
+	tristate
drivers/hwmon/occ/Makefile +4 -2
@@ -1,5 +1,7 @@
-occ-p8-hwmon-objs := common.o sysfs.o p8_i2c.o
-occ-p9-hwmon-objs := common.o sysfs.o p9_sbe.o
+occ-hwmon-common-objs := common.o sysfs.o
+occ-p8-hwmon-objs := p8_i2c.o
+occ-p9-hwmon-objs := p9_sbe.o
 
+obj-$(CONFIG_SENSORS_OCC) += occ-hwmon-common.o
 obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o
 obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o
drivers/hwmon/occ/common.c +7 -0
@@ -1,11 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/math64.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
 #include <asm/unaligned.h>
@@ -1096,3 +1098,8 @@ int occ_setup(struct occ *occ, const cha
 
 	return rc;
 }
+EXPORT_SYMBOL_GPL(occ_setup);
+
+MODULE_AUTHOR("Eddie James <[email protected]>");
+MODULE_DESCRIPTION("Common OCC hwmon code");
+MODULE_LICENSE("GPL");
drivers/hwmon/occ/sysfs.c +2 -0
@@ -12,6 +12,7 @@
 
 #include <linux/bitops.h>
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
@@ -186,3 +187,4 @@ void occ_shutdown(struct occ *occ)
 {
 	sysfs_remove_group(&occ->bus_dev->kobj, &occ_sysfs);
 }
+EXPORT_SYMBOL_GPL(occ_shutdown);
Signature · 3 lines
-- 
Jean Delvare
SUSE L3 Support
maintainer
#6 lore raw
Quoted 6 lines · Guenter Roeck

Jean,

Quoted 3 lines · Jean Delvare

Instead of duplicating the common code into the 2 (binary) drivers, move the common code to a separate module. This is cleaner.

Quoted 7 lines
Quoted 3 lines
Cc Eddie James <[email protected]>
Cc Guenter Roeck <[email protected]>

what is the parent release for this patch ? I tried to apply it to mainline and to hwmon-next using git am, but both failed.

Never mind, found it - v5.0. Both patches applied to hwmon-next.

Thanks,
Guenter

Quoted 83 lines

Thanks,
Guenter

Quoted 80 lines

---
Eddie, can you please give it a try and confirm it works?

Note: I kept the module names as they were before, hence the extra "*-objs :=" statements. They could be removed if we rename the source files, but that's better done in git directly. I don't mind either way personally.

 drivers/hwmon/occ/Kconfig  |    3 +--
 drivers/hwmon/occ/Makefile |    6 ++++--
 drivers/hwmon/occ/common.c |    7 +++++++
 drivers/hwmon/occ/sysfs.c  |    2 ++
 4 files changed, 14 insertions(+), 4 deletions(-)
drivers/hwmon/occ/Kconfig +1 -2
@@ -27,5 +27,4 @@ config SENSORS_OCC_P9_SBE
 	 called occ-p9-hwmon.
 
 config SENSORS_OCC
-	bool "POWER On-Chip Controller"
-	depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE
+	tristate
drivers/hwmon/occ/Makefile +4 -2
@@ -1,5 +1,7 @@
-occ-p8-hwmon-objs := common.o sysfs.o p8_i2c.o
-occ-p9-hwmon-objs := common.o sysfs.o p9_sbe.o
+occ-hwmon-common-objs := common.o sysfs.o
+occ-p8-hwmon-objs := p8_i2c.o
+occ-p9-hwmon-objs := p9_sbe.o
 
+obj-$(CONFIG_SENSORS_OCC) += occ-hwmon-common.o
 obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o
 obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o
drivers/hwmon/occ/common.c +7 -0
@@ -1,11 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/math64.h>
+#include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/sysfs.h>
 #include <asm/unaligned.h>
@@ -1096,3 +1098,8 @@ int occ_setup(struct occ *occ, const cha
 
 	return rc;
 }
+EXPORT_SYMBOL_GPL(occ_setup);
+
+MODULE_AUTHOR("Eddie James <[email protected]>");
+MODULE_DESCRIPTION("Common OCC hwmon code");
+MODULE_LICENSE("GPL");
drivers/hwmon/occ/sysfs.c +2 -0
@@ -12,6 +12,7 @@
 
 #include <linux/bitops.h>
 #include <linux/device.h>
+#include <linux/export.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/kernel.h>
 #include <linux/sysfs.h>
@@ -186,3 +187,4 @@ void occ_shutdown(struct occ *occ)
 {
 	sysfs_remove_group(&occ->bus_dev->kobj, &occ_sysfs);
 }
+EXPORT_SYMBOL_GPL(occ_shutdown);
Signature · 3 lines
-- 
Jean Delvare
SUSE L3 Support