All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>, Guenter Roeck <linux@roeck-us.net>,
	Tim Harvey <tharvey@gateworks.com>
Subject: [PATCH 04/10] hwmon: (gsc-hwmon) Drop platform data support
Date: Tue, 10 Nov 2026 10:34:27 -0800	[thread overview]
Message-ID: <20261110183434.181711-5-linux@roeck-us.net> (raw)
In-Reply-To: <20261110183434.181711-1-linux@roeck-us.net>

There are no in-tree users providing gsc_hwmon_platform_data. Channel
descriptions and the fan controller base address are already obtained
from devicetree / fwnode properties.

Move enum gsc_hwmon_mode and struct gsc_hwmon_channel into the driver,
fold the channel array and fan_base into struct gsc_hwmon_data, drop
platform data support, and remove the unused platform_data header file.

Cc: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 MAINTAINERS                             |  1 -
 drivers/hwmon/gsc-hwmon.c               | 72 +++++++++++++++----------
 include/linux/platform_data/gsc_hwmon.h | 45 ----------------
 3 files changed, 45 insertions(+), 73 deletions(-)
 delete mode 100644 include/linux/platform_data/gsc_hwmon.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 476bcd5d0e1c..15d70b72d9a2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11169,7 +11169,6 @@ F:	Documentation/hwmon/gsc-hwmon.rst
 F:	drivers/hwmon/gsc-hwmon.c
 F:	drivers/mfd/gateworks-gsc.c
 F:	include/linux/mfd/gsc.h
-F:	include/linux/platform_data/gsc_hwmon.h
 
 GCC PLUGINS
 M:	Kees Cook <kees@kernel.org>
diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
index 83005d8ae47e..9424deb98590 100644
--- a/drivers/hwmon/gsc-hwmon.c
+++ b/drivers/hwmon/gsc-hwmon.c
@@ -10,11 +10,10 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
-#include <linux/platform_data/gsc_hwmon.h>
-
 #define GSC_HWMON_MAX_TEMP_CH	16
 #define GSC_HWMON_MAX_IN_CH	16
 #define GSC_HWMON_MAX_FAN_CH	16
@@ -22,10 +21,35 @@
 #define GSC_HWMON_RESOLUTION	12
 #define GSC_HWMON_VREF		2500
 
+enum gsc_hwmon_mode {
+	mode_temperature,
+	mode_voltage_24bit,
+	mode_voltage_raw,
+	mode_voltage_16bit,
+	mode_fan,
+	mode_max,
+};
+
+/**
+ * struct gsc_hwmon_channel - configuration parameters
+ * @reg:  I2C register offset
+ * @mode: channel mode
+ * @name: channel name
+ * @mvoffset: voltage offset
+ * @vdiv: voltage divider array (2 resistor values in milli-ohms)
+ */
+struct gsc_hwmon_channel {
+	unsigned int reg;
+	unsigned int mode;
+	const char *name;
+	unsigned int mvoffset;
+	unsigned int vdiv[2];
+};
+
 struct gsc_hwmon_data {
 	struct gsc_dev *gsc;
-	struct gsc_hwmon_platform_data *pdata;
 	struct regmap *regmap;
+	u32 fan_base;
 	const struct gsc_hwmon_channel *temp_ch[GSC_HWMON_MAX_TEMP_CH];
 	const struct gsc_hwmon_channel *in_ch[GSC_HWMON_MAX_IN_CH];
 	const struct gsc_hwmon_channel *fan_ch[GSC_HWMON_MAX_FAN_CH];
@@ -37,6 +61,8 @@ struct gsc_hwmon_data {
 	struct hwmon_channel_info fan_info;
 	const struct hwmon_channel_info *info[4];
 	struct hwmon_chip_info chip;
+	int nchannels;
+	struct gsc_hwmon_channel channels[] __counted_by(nchannels);
 };
 
 static const struct regmap_bus gsc_hwmon_regmap_bus = {
@@ -55,7 +81,7 @@ static ssize_t pwm_auto_point_temp_show(struct device *dev,
 {
 	struct gsc_hwmon_data *hwmon = dev_get_drvdata(dev);
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	u8 reg = hwmon->pdata->fan_base + (2 * attr->index);
+	u8 reg = hwmon->fan_base + (2 * attr->index);
 	u8 regs[2];
 	int ret;
 
@@ -73,7 +99,7 @@ static ssize_t pwm_auto_point_temp_store(struct device *dev,
 {
 	struct gsc_hwmon_data *hwmon = dev_get_drvdata(dev);
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	u8 reg = hwmon->pdata->fan_base + (2 * attr->index);
+	u8 reg = hwmon->fan_base + (2 * attr->index);
 	u8 regs[2];
 	long temp;
 	int err;
@@ -236,10 +262,9 @@ static const struct hwmon_ops gsc_hwmon_ops = {
 	.read_string = gsc_hwmon_read_string,
 };
 
-static struct gsc_hwmon_platform_data *
-gsc_hwmon_get_devtree_pdata(struct device *dev)
+static struct gsc_hwmon_data *gsc_hwmon_get_devtree_data(struct device *dev)
 {
-	struct gsc_hwmon_platform_data *pdata;
+	struct gsc_hwmon_data *hwmon;
 	struct gsc_hwmon_channel *ch;
 	struct device_node *fan;
 	int nchannels;
@@ -248,15 +273,15 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
 	if (nchannels == 0)
 		return ERR_PTR(-ENODEV);
 
-	pdata = devm_kzalloc_flex(dev, *pdata, channels, nchannels);
-	if (!pdata)
+	hwmon = devm_kzalloc_flex(dev, *hwmon, channels, nchannels);
+	if (!hwmon)
 		return ERR_PTR(-ENOMEM);
-	pdata->nchannels = nchannels;
+	hwmon->nchannels = nchannels;
 
 	/* fan controller base address */
 	of_node_get(dev->parent->of_node);
 	fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
-	if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
+	if (fan && of_property_read_u32(fan, "reg", &hwmon->fan_base)) {
 		of_node_put(fan);
 		dev_err(dev, "fan node without base\n");
 		return ERR_PTR(-EINVAL);
@@ -264,7 +289,7 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
 
 	of_node_put(fan);
 
-	ch = pdata->channels;
+	ch = hwmon->channels;
 	/* allocate structures for channels and count instances of each type */
 	device_for_each_child_node_scoped(dev, child) {
 		if (fwnode_property_read_string(child, "label", &ch->name)) {
@@ -294,7 +319,7 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
 		ch++;
 	}
 
-	return pdata;
+	return hwmon;
 }
 
 static int gsc_hwmon_probe(struct platform_device *pdev)
@@ -302,22 +327,15 @@ static int gsc_hwmon_probe(struct platform_device *pdev)
 	struct gsc_dev *gsc = dev_get_drvdata(pdev->dev.parent);
 	struct device *dev = &pdev->dev;
 	struct device *hwmon_dev;
-	struct gsc_hwmon_platform_data *pdata = dev_get_platdata(dev);
 	struct gsc_hwmon_data *hwmon;
 	const struct attribute_group **groups;
 	int i, i_in, i_temp, i_fan;
 
-	if (!pdata) {
-		pdata = gsc_hwmon_get_devtree_pdata(dev);
-		if (IS_ERR(pdata))
-			return PTR_ERR(pdata);
-	}
+	hwmon = gsc_hwmon_get_devtree_data(dev);
+	if (IS_ERR(hwmon))
+		return PTR_ERR(hwmon);
 
-	hwmon = devm_kzalloc_obj(dev, *hwmon);
-	if (!hwmon)
-		return -ENOMEM;
 	hwmon->gsc = gsc;
-	hwmon->pdata = pdata;
 
 	hwmon->regmap = devm_regmap_init(dev, &gsc_hwmon_regmap_bus,
 					 gsc->i2c_hwmon,
@@ -325,8 +343,8 @@ static int gsc_hwmon_probe(struct platform_device *pdev)
 	if (IS_ERR(hwmon->regmap))
 		return PTR_ERR(hwmon->regmap);
 
-	for (i = 0, i_in = 0, i_temp = 0, i_fan = 0; i < hwmon->pdata->nchannels; i++) {
-		const struct gsc_hwmon_channel *ch = &pdata->channels[i];
+	for (i = 0, i_in = 0, i_temp = 0, i_fan = 0; i < hwmon->nchannels; i++) {
+		const struct gsc_hwmon_channel *ch = &hwmon->channels[i];
 
 		switch (ch->mode) {
 		case mode_temperature:
@@ -380,7 +398,7 @@ static int gsc_hwmon_probe(struct platform_device *pdev)
 	hwmon->fan_info.type = hwmon_fan;
 	hwmon->fan_info.config = hwmon->fan_config;
 
-	groups = pdata->fan_base ? gsc_hwmon_groups : NULL;
+	groups = hwmon->fan_base ? gsc_hwmon_groups : NULL;
 	hwmon_dev = devm_hwmon_device_register_with_info(dev,
 							 KBUILD_MODNAME, hwmon,
 							 &hwmon->chip, groups);
diff --git a/include/linux/platform_data/gsc_hwmon.h b/include/linux/platform_data/gsc_hwmon.h
deleted file mode 100644
index 70e8a6bec0f6..000000000000
--- a/include/linux/platform_data/gsc_hwmon.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _GSC_HWMON_H
-#define _GSC_HWMON_H
-
-enum gsc_hwmon_mode {
-	mode_temperature,
-	mode_voltage_24bit,
-	mode_voltage_raw,
-	mode_voltage_16bit,
-	mode_fan,
-	mode_max,
-};
-
-/**
- * struct gsc_hwmon_channel - configuration parameters
- * @reg:  I2C register offset
- * @mode: channel mode
- * @name: channel name
- * @mvoffset: voltage offset
- * @vdiv: voltage divider array (2 resistor values in milli-ohms)
- */
-struct gsc_hwmon_channel {
-	unsigned int reg;
-	unsigned int mode;
-	const char *name;
-	unsigned int mvoffset;
-	unsigned int vdiv[2];
-};
-
-/**
- * struct gsc_hwmon_platform_data - platform data for gsc_hwmon driver
- * @nchannels:	number of elements in @channels array
- * @vreference: voltage reference (mV)
- * @resolution: ADC bit resolution
- * @fan_base: register base for FAN controller
- * @channels:	array of gsc_hwmon_channel structures describing channels
- */
-struct gsc_hwmon_platform_data {
-	int nchannels;
-	unsigned int resolution;
-	unsigned int vreference;
-	unsigned int fan_base;
-	struct gsc_hwmon_channel channels[] __counted_by(nchannels);
-};
-#endif
-- 
2.45.2


  parent reply	other threads:[~2026-11-10 18:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 18:34 [PATCH 00/10] hwmon: Drop unused platform data support and max197 driver Guenter Roeck
2026-11-10 18:34 ` [PATCH 01/10] hwmon: (ads7828) Drop platform data support Guenter Roeck
2026-11-10 18:45   ` Arnd Bergmann
2026-11-10 19:40     ` Guenter Roeck
2026-11-10 19:49       ` Arnd Bergmann
2026-11-12 18:25     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 02/10] hwmon: (emc2305) " Guenter Roeck
2026-11-10 18:56   ` Arnd Bergmann
2026-11-12 19:06     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 03/10] hwmon: (g762) " Guenter Roeck
2026-11-10 19:09   ` Arnd Bergmann
2026-11-12 19:08     ` Guenter Roeck
2026-11-10 18:34 ` Guenter Roeck [this message]
2026-11-10 19:11   ` [PATCH 04/10] hwmon: (gsc-hwmon) " Arnd Bergmann
2026-11-12 19:09     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 05/10] hwmon: (ltc4245) " Guenter Roeck
2026-11-10 18:58   ` Arnd Bergmann
2026-11-12 19:11     ` Guenter Roeck
2026-11-11  9:54   ` Nuno Sá
2026-11-10 18:34 ` [PATCH 06/10] hwmon: (mcp3021) " Guenter Roeck
2026-11-10 19:12   ` Arnd Bergmann
2026-11-12 19:14     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 07/10] hwmon: (shtc1) " Guenter Roeck
2026-11-10 19:00   ` Arnd Bergmann
2026-11-12 19:18     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 08/10] hwmon: (max197) Remove driver Guenter Roeck
2026-11-10 19:02   ` Arnd Bergmann
2026-11-12 19:22     ` Guenter Roeck
2026-11-11  9:49   ` Nuno Sá
2026-11-10 18:34 ` [PATCH 09/10] hwmon: (f75375s) Drop platform data support Guenter Roeck
2026-11-10 19:18   ` Arnd Bergmann
2026-11-10 19:43     ` Guenter Roeck
2026-11-12 19:25     ` Guenter Roeck
2026-11-10 18:34 ` [PATCH 10/10] hwmon: (ds620) " Guenter Roeck
2026-11-10 19:07   ` Arnd Bergmann
2026-11-10 19:41     ` Guenter Roeck
2026-11-12 19:29     ` Guenter Roeck
2026-11-11  9:56   ` Nuno Sá
2026-11-10 19:24 ` [PATCH 00/10] hwmon: Drop unused platform data support and max197 driver Arnd Bergmann
2026-11-10 19:50   ` Guenter Roeck
2026-11-10 20:31     ` Arnd Bergmann
2026-11-12 19:31   ` Guenter Roeck

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=20261110183434.181711-5-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=arnd@arndb.de \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=tharvey@gateworks.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.