mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data()
@ 2023-11-15 20:57 Rob Herring
  2023-11-15 20:57 ` [PATCH v2 2/3] hwmon: nct6775-i2c: " Rob Herring
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rob Herring @ 2023-11-15 20:57 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, linux-kernel

Use preferred i2c_get_match_data() instead of of_match_device() and
i2c_match_id() to get the driver match data. With this, adjust the
includes to explicitly include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Split up per driver
---
 drivers/hwmon/max6650.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index cc8428a3045d..9649c6611d5f 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -26,7 +26,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/thermal.h>
 
 /*
@@ -763,8 +763,6 @@ static int max6650_probe(struct i2c_client *client)
 {
 	struct thermal_cooling_device *cooling_dev;
 	struct device *dev = &client->dev;
-	const struct of_device_id *of_id =
-		of_match_device(of_match_ptr(max6650_dt_match), dev);
 	struct max6650_data *data;
 	struct device *hwmon_dev;
 	int err;
@@ -776,8 +774,8 @@ static int max6650_probe(struct i2c_client *client)
 	data->client = client;
 	i2c_set_clientdata(client, data);
 	mutex_init(&data->update_lock);
-	data->nr_fans = of_id ? (int)(uintptr_t)of_id->data :
-				i2c_match_id(max6650_id, client)->driver_data;
+
+	data->nr_fans = (uintptr_t)i2c_get_match_data(client);
 
 	/*
 	 * Initialize the max6650 chip
-- 
2.42.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] hwmon: nct6775-i2c: Use i2c_get_match_data()
  2023-11-15 20:57 [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data() Rob Herring
@ 2023-11-15 20:57 ` Rob Herring
  2023-11-15 22:23   ` Guenter Roeck
  2023-11-15 20:57 ` [PATCH v2 3/3] hwmon: lm25066: " Rob Herring
  2023-11-15 22:22 ` [PATCH v2 1/3] hwmon: max6650: " Guenter Roeck
  2 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2023-11-15 20:57 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Zev Weiss; +Cc: linux-hwmon, linux-kernel

Use preferred i2c_get_match_data() instead of of_match_device() and
i2c_match_id() to get the driver match data. With this, adjust the
includes to explicitly include the correct headers.

Adjust the 'kinds' enum to not use 0, so that no match data can be
distinguished from a valid enum value.

Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Split up per driver
---
 drivers/hwmon/nct6775-i2c.c | 14 ++------------
 drivers/hwmon/nct6775.h     |  2 +-
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/nct6775-i2c.c b/drivers/hwmon/nct6775-i2c.c
index 87a4fc78c571..63b669d511f4 100644
--- a/drivers/hwmon/nct6775-i2c.c
+++ b/drivers/hwmon/nct6775-i2c.c
@@ -21,7 +21,7 @@
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/err.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/regmap.h>
 #include "nct6775.h"
 
@@ -155,23 +155,13 @@ static const struct regmap_config nct6775_i2c_regmap_config = {
 static int nct6775_i2c_probe(struct i2c_client *client)
 {
 	struct nct6775_data *data;
-	const struct of_device_id *of_id;
-	const struct i2c_device_id *i2c_id;
 	struct device *dev = &client->dev;
 
-	of_id = of_match_device(nct6775_i2c_of_match, dev);
-	i2c_id = i2c_match_id(nct6775_i2c_id, client);
-
-	if (of_id && (unsigned long)of_id->data != i2c_id->driver_data)
-		dev_notice(dev, "Device mismatch: %s in device tree, %s detected\n",
-			   of_id->name, i2c_id->name);
-
 	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	data->kind = i2c_id->driver_data;
-
+	data->kind = (enum kinds)i2c_get_match_data(client);
 	data->read_only = true;
 	data->driver_data = client;
 	data->driver_init = nct6775_i2c_probe_init;
diff --git a/drivers/hwmon/nct6775.h b/drivers/hwmon/nct6775.h
index 296eff99d003..d31e7a030216 100644
--- a/drivers/hwmon/nct6775.h
+++ b/drivers/hwmon/nct6775.h
@@ -4,7 +4,7 @@
 
 #include <linux/types.h>
 
-enum kinds { nct6106, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792,
+enum kinds { nct6106 = 1, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792,
 	     nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 };
 enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 };
 
-- 
2.42.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] hwmon: lm25066: Use i2c_get_match_data()
  2023-11-15 20:57 [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data() Rob Herring
  2023-11-15 20:57 ` [PATCH v2 2/3] hwmon: nct6775-i2c: " Rob Herring
@ 2023-11-15 20:57 ` Rob Herring
  2023-11-15 22:24   ` Guenter Roeck
  2023-11-15 22:22 ` [PATCH v2 1/3] hwmon: max6650: " Guenter Roeck
  2 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2023-11-15 20:57 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, linux-kernel

Use preferred i2c_get_match_data() instead of of_match_device() and
i2c_match_id() to get the driver match data. With this, adjust the
includes to explicitly include the correct headers.

Adjust the 'chips' enum to not use 0, so that no match data can be
distinguished from a valid enum value.

Signed-off-by: Rob Herring <robh@kernel.org>
---
v2:
 - Split up per driver
---
 drivers/hwmon/pmbus/lm25066.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 929fa6d34efd..bd43457094a6 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -14,10 +14,10 @@
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/log2.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include "pmbus.h"
 
-enum chips { lm25056, lm25066, lm5064, lm5066, lm5066i };
+enum chips { lm25056 = 1, lm25066, lm5064, lm5066, lm5066i };
 
 #define LM25066_READ_VAUX		0xd0
 #define LM25066_MFR_READ_IIN		0xd1
@@ -468,8 +468,6 @@ static int lm25066_probe(struct i2c_client *client)
 	struct lm25066_data *data;
 	struct pmbus_driver_info *info;
 	const struct __coeff *coeff;
-	const struct of_device_id *of_id;
-	const struct i2c_device_id *i2c_id;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_READ_BYTE_DATA))
@@ -484,14 +482,8 @@ static int lm25066_probe(struct i2c_client *client)
 	if (config < 0)
 		return config;
 
-	i2c_id = i2c_match_id(lm25066_id, client);
+	data->id = (enum chips)i2c_get_match_data(client);
 
-	of_id = of_match_device(lm25066_of_match, &client->dev);
-	if (of_id && (unsigned long)of_id->data != i2c_id->driver_data)
-		dev_notice(&client->dev, "Device mismatch: %s in device tree, %s detected\n",
-			   of_id->name, i2c_id->name);
-
-	data->id = i2c_id->driver_data;
 	info = &data->info;
 
 	info->pages = 1;
-- 
2.42.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data()
  2023-11-15 20:57 [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data() Rob Herring
  2023-11-15 20:57 ` [PATCH v2 2/3] hwmon: nct6775-i2c: " Rob Herring
  2023-11-15 20:57 ` [PATCH v2 3/3] hwmon: lm25066: " Rob Herring
@ 2023-11-15 22:22 ` Guenter Roeck
  2 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-11-15 22:22 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Wed, Nov 15, 2023 at 02:57:00PM -0600, Rob Herring wrote:
> Use preferred i2c_get_match_data() instead of of_match_device() and
> i2c_match_id() to get the driver match data. With this, adjust the
> includes to explicitly include the correct headers.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Applied.

Guenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] hwmon: nct6775-i2c: Use i2c_get_match_data()
  2023-11-15 20:57 ` [PATCH v2 2/3] hwmon: nct6775-i2c: " Rob Herring
@ 2023-11-15 22:23   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-11-15 22:23 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jean Delvare, Zev Weiss, linux-hwmon, linux-kernel

On Wed, Nov 15, 2023 at 02:57:01PM -0600, Rob Herring wrote:
> Use preferred i2c_get_match_data() instead of of_match_device() and
> i2c_match_id() to get the driver match data. With this, adjust the
> includes to explicitly include the correct headers.
> 
> Adjust the 'kinds' enum to not use 0, so that no match data can be
> distinguished from a valid enum value.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Applied.

Guenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] hwmon: lm25066: Use i2c_get_match_data()
  2023-11-15 20:57 ` [PATCH v2 3/3] hwmon: lm25066: " Rob Herring
@ 2023-11-15 22:24   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-11-15 22:24 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jean Delvare, linux-hwmon, linux-kernel

On Wed, Nov 15, 2023 at 02:57:02PM -0600, Rob Herring wrote:
> Use preferred i2c_get_match_data() instead of of_match_device() and
> i2c_match_id() to get the driver match data. With this, adjust the
> includes to explicitly include the correct headers.
> 
> Adjust the 'chips' enum to not use 0, so that no match data can be
> distinguished from a valid enum value.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Applied.

Guenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-15 22:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 20:57 [PATCH v2 1/3] hwmon: max6650: Use i2c_get_match_data() Rob Herring
2023-11-15 20:57 ` [PATCH v2 2/3] hwmon: nct6775-i2c: " Rob Herring
2023-11-15 22:23   ` Guenter Roeck
2023-11-15 20:57 ` [PATCH v2 3/3] hwmon: lm25066: " Rob Herring
2023-11-15 22:24   ` Guenter Roeck
2023-11-15 22:22 ` [PATCH v2 1/3] hwmon: max6650: " Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®