[PATCH] hwmon: (ina2xx) drop unused platform data

Bartosz Golaszewski posted 1 patch 1 week ago
drivers/hwmon/ina209.c               |  9 +--------
drivers/iio/adc/ina2xx-adc.c         | 14 ++------------
include/linux/platform_data/ina2xx.h | 16 ----------------
3 files changed, 3 insertions(+), 36 deletions(-)
[PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Bartosz Golaszewski 1 week ago
Nobody defines struct ina2xx_platform_data. Remove platform data support
from the drivers which still have it (it's effectively dead code) and
remove the header.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/hwmon/ina209.c               |  9 +--------
 drivers/iio/adc/ina2xx-adc.c         | 14 ++------------
 include/linux/platform_data/ina2xx.h | 16 ----------------
 3 files changed, 3 insertions(+), 36 deletions(-)

diff --git a/drivers/hwmon/ina209.c b/drivers/hwmon/ina209.c
index bd7b3380d847af4439327f0753745fd832e3e22c..eec529e26d6912ad39924420b4c23d2cb91cc81d 100644
--- a/drivers/hwmon/ina209.c
+++ b/drivers/hwmon/ina209.c
@@ -27,8 +27,6 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 
-#include <linux/platform_data/ina2xx.h>
-
 /* register definitions */
 #define INA209_CONFIGURATION		0x00
 #define INA209_STATUS			0x01
@@ -487,7 +485,6 @@ static void ina209_restore_conf(struct i2c_client *client,
 static int ina209_init_client(struct i2c_client *client,
 			      struct ina209_data *data)
 {
-	struct ina2xx_platform_data *pdata = dev_get_platdata(&client->dev);
 	u32 shunt;
 	int reg;
 
@@ -501,11 +498,7 @@ static int ina209_init_client(struct i2c_client *client,
 		return reg;
 	data->config_orig = reg;
 
-	if (pdata) {
-		if (pdata->shunt_uohms <= 0)
-			return -EINVAL;
-		shunt = pdata->shunt_uohms;
-	} else if (!of_property_read_u32(client->dev.of_node, "shunt-resistor",
+	if (!of_property_read_u32(client->dev.of_node, "shunt-resistor",
 					 &shunt)) {
 		if (shunt == 0)
 			return -EINVAL;
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index 857e1b69d6cd4d65d7ebe5de222fe92875eccdcc..c6cded508738f95e5001ebd276edfa07890e217c 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -33,8 +33,6 @@
 #include <linux/sched/task.h>
 #include <linux/util_macros.h>
 
-#include <linux/platform_data/ina2xx.h>
-
 /* INA2XX registers definition */
 #define INA2XX_CONFIG                   0x00
 #define INA2XX_SHUNT_VOLTAGE            0x01	/* readonly */
@@ -980,16 +978,8 @@ static int ina2xx_probe(struct i2c_client *client)
 
 	mutex_init(&chip->state_lock);
 
-	if (of_property_read_u32(client->dev.of_node,
-				 "shunt-resistor", &val) < 0) {
-		struct ina2xx_platform_data *pdata =
-		    dev_get_platdata(&client->dev);
-
-		if (pdata)
-			val = pdata->shunt_uohms;
-		else
-			val = INA2XX_RSHUNT_DEFAULT;
-	}
+	if (of_property_read_u32(client->dev.of_node, "shunt-resistor", &val) < 0)
+		val = INA2XX_RSHUNT_DEFAULT;
 
 	ret = set_shunt_resistor(chip, val);
 	if (ret)
diff --git a/include/linux/platform_data/ina2xx.h b/include/linux/platform_data/ina2xx.h
deleted file mode 100644
index 2aa5ee9a90507e8233bde3cb9be257dda23cd52c..0000000000000000000000000000000000000000
--- a/include/linux/platform_data/ina2xx.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Driver for Texas Instruments INA219, INA226 power monitor chips
- *
- * Copyright (C) 2012 Lothar Felten <lothar.felten@gmail.com>
- *
- * For further information, see the Documentation/hwmon/ina2xx.rst file.
- */
-
-/**
- * struct ina2xx_platform_data - ina2xx info
- * @shunt_uohms		shunt resistance in microohms
- */
-struct ina2xx_platform_data {
-	long shunt_uohms;
-};

---
base-commit: 66ba480978ce390e631e870b740a3406e3eb6b01
change-id: 20260326-drop-ina2xx-pdata-167cd72977aa

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Guenter Roeck 6 days, 21 hours ago
On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> Nobody defines struct ina2xx_platform_data. Remove platform data support
> from the drivers which still have it (it's effectively dead code) and
> remove the header.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com>

Applied.

Thanks,
Guenter
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Guenter Roeck 1 week ago
Hi,

On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> Nobody defines struct ina2xx_platform_data. Remove platform data support
> from the drivers which still have it (it's effectively dead code) and
> remove the header.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

Thanks a lot for your patch. Checkpatch complains:

CHECK: Alignment should match open parenthesis

No need to resend, I'll fix that up.

Applied.

Guenter
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Guenter Roeck 1 week ago
On Thu, Mar 26, 2026 at 04:28:16AM -0700, Guenter Roeck wrote:
> Hi,
> 
> On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> > Nobody defines struct ina2xx_platform_data. Remove platform data support
> > from the drivers which still have it (it's effectively dead code) and
> > remove the header.
> > 
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> 
> Thanks a lot for your patch. Checkpatch complains:
> 
> CHECK: Alignment should match open parenthesis
> 
> No need to resend, I'll fix that up.
> 
> Applied.
> 

Ah, no, I can not do that. You also touched drivers/iio/adc/ina2xx-adc.c,
meaning I'll either need an Ack from Jonathan or the patch will need to be
split.

Guenter
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Bartosz Golaszewski 1 week ago
On Thu, Mar 26, 2026 at 12:33 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> On Thu, Mar 26, 2026 at 04:28:16AM -0700, Guenter Roeck wrote:
> > Hi,
> >
> > On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> > > Nobody defines struct ina2xx_platform_data. Remove platform data support
> > > from the drivers which still have it (it's effectively dead code) and
> > > remove the header.
> > >
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> >
> > Thanks a lot for your patch. Checkpatch complains:
> >
> > CHECK: Alignment should match open parenthesis
> >
> > No need to resend, I'll fix that up.
> >
> > Applied.
> >
>
> Ah, no, I can not do that. You also touched drivers/iio/adc/ina2xx-adc.c,
> meaning I'll either need an Ack from Jonathan or the patch will need to be
> split.
>
> Guenter

Yes, sorry I should have mentioned it. This should go through the
hwmon tree with an Ack from iio maintainers.

Bart
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Jonathan Cameron 1 week ago
On Thu, 26 Mar 2026 14:24:20 +0100
Bartosz Golaszewski <brgl@kernel.org> wrote:

> On Thu, Mar 26, 2026 at 12:33 PM Guenter Roeck <linux@roeck-us.net> wrote:
> >
> > On Thu, Mar 26, 2026 at 04:28:16AM -0700, Guenter Roeck wrote:  
> > > Hi,
> > >
> > > On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:  
> > > > Nobody defines struct ina2xx_platform_data. Remove platform data support
> > > > from the drivers which still have it (it's effectively dead code) and
> > > > remove the header.
> > > >
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>  
> > >
> > > Thanks a lot for your patch. Checkpatch complains:
> > >
> > > CHECK: Alignment should match open parenthesis
> > >
> > > No need to resend, I'll fix that up.
> > >
> > > Applied.
> > >  
> >
> > Ah, no, I can not do that. You also touched drivers/iio/adc/ina2xx-adc.c,
> > meaning I'll either need an Ack from Jonathan or the patch will need to be
> > split.
> >
> > Guenter  
> 
> Yes, sorry I should have mentioned it. This should go through the
> hwmon tree with an Ack from iio maintainers.
Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com>

I have one patch on this driver queued on this driver, but the patch seems
to apply just fine on top of that so hopefully the merge will be automatic
/ trivial.
https://lore.kernel.org/all/20260315182304.613783-1-git@chuang.cz/


> 
> Bart
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Andy Shevchenko 1 week ago
On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> Nobody defines struct ina2xx_platform_data. Remove platform data support
> from the drivers which still have it (it's effectively dead code) and
> remove the header.

Would be nice to see a follow up to convert to use device properties.
But again, I already asked this Q: why do we have two drivers for the
same part? (Probably not to you, Bart)

Anyways, the change looks great!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Guenter Roeck 1 week ago
On Thu, Mar 26, 2026 at 12:23:20PM +0200, Andy Shevchenko wrote:
> On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> > Nobody defines struct ina2xx_platform_data. Remove platform data support
> > from the drivers which still have it (it's effectively dead code) and
> > remove the header.
> 
> Would be nice to see a follow up to convert to use device properties.
> But again, I already asked this Q: why do we have two drivers for the
> same part? (Probably not to you, Bart)

Because the person introducing the iio driver claimed that they needed
the iio ABI and were unwilling to create a generic hwmon->iio bridge.

Guenter
Re: [PATCH] hwmon: (ina2xx) drop unused platform data
Posted by Andy Shevchenko 1 week ago
On Thu, Mar 26, 2026 at 07:12:16AM -0700, Guenter Roeck wrote:
> On Thu, Mar 26, 2026 at 12:23:20PM +0200, Andy Shevchenko wrote:
> > On Thu, Mar 26, 2026 at 10:30:00AM +0100, Bartosz Golaszewski wrote:
> > > Nobody defines struct ina2xx_platform_data. Remove platform data support
> > > from the drivers which still have it (it's effectively dead code) and
> > > remove the header.
> > 
> > Would be nice to see a follow up to convert to use device properties.
> > But again, I already asked this Q: why do we have two drivers for the
> > same part? (Probably not to you, Bart)
> 
> Because the person introducing the iio driver claimed that they needed
> the iio ABI and were unwilling to create a generic hwmon->iio bridge.

Okay, but why did we allow that? I fell uncomfortable to bear two drivers
of the same when the whole idea of the kernel is reduce duplication. Yes,
I know that there are more cross-subsystem examples that we have IIO vs.
other subsystem cases (usually in drivers/input), but I believe it was
historical and for new devices I would like to have a stricter rules. IIO
hwmon bridge is exactly for that and if it lacks something we rather should
discuss improving that instead of duplications.

-- 
With Best Regards,
Andy Shevchenko