Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 4/5] hwmon: (max1668) Replace chip type with number of channels
Date: Thu, 25 Jul 2024 17:43:28 -0700	[thread overview]
Message-ID: <20240726004329.934763-5-linux@roeck-us.net> (raw)
In-Reply-To: <20240726004329.934763-1-linux@roeck-us.net>

The only difference between supported chips is the number of channels.
Drop enum chips and list the number of channels in struct i2c_device_id
directly.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/max1668.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index 48f247ca5d85..071c17604131 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -49,12 +49,10 @@ static bool read_only;
 module_param(read_only, bool, 0);
 MODULE_PARM_DESC(read_only, "Don't set any values, read only mode");
 
-enum chips { max1668, max1805, max1989 };
-
 struct max1668_data {
 	struct regmap *regmap;
 	const struct attribute_group *groups[3];
-	enum chips type;
+	int channels;
 };
 
 static ssize_t show_temp(struct device *dev,
@@ -393,11 +391,11 @@ static int max1668_probe(struct i2c_client *client)
 	if (IS_ERR(data->regmap))
 		return PTR_ERR(data->regmap);
 
-	data->type = (uintptr_t)i2c_get_match_data(client);
+	data->channels = (uintptr_t)i2c_get_match_data(client);
 
 	/* sysfs hooks */
 	data->groups[0] = &max1668_group_common;
-	if (data->type == max1668 || data->type == max1989)
+	if (data->channels == 5)
 		data->groups[1] = &max1668_group_unique;
 
 	hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
@@ -406,9 +404,9 @@ static int max1668_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id max1668_id[] = {
-	{ "max1668", max1668 },
-	{ "max1805", max1805 },
-	{ "max1989", max1989 },
+	{ "max1668", 5 },
+	{ "max1805", 3 },
+	{ "max1989", 5 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, max1668_id);
-- 
2.39.2


  parent reply	other threads:[~2024-07-26  0:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26  0:43 [PATCH 0/5] hwmon: (max1668) Modernize driver Guenter Roeck
2024-07-26  0:43 ` [PATCH 1/5] hwmon: (max1668) Reorder include files to alphabetic order Guenter Roeck
2024-07-26 15:20   ` Tzung-Bi Shih
2024-07-26  0:43 ` [PATCH 2/5] hwmon: (max1668) Use BIT macro Guenter Roeck
2024-07-26 15:20   ` Tzung-Bi Shih
2024-07-26  0:43 ` [PATCH 3/5] hwmon: (max1668) Convert to use regmap Guenter Roeck
2024-07-26 15:20   ` Tzung-Bi Shih
2024-07-26 16:43     ` Guenter Roeck
2024-07-26  0:43 ` Guenter Roeck [this message]
2024-07-26 15:20   ` [PATCH 4/5] hwmon: (max1668) Replace chip type with number of channels Tzung-Bi Shih
2024-07-26  0:43 ` [PATCH 5/5] hwmon: (max1668) Convert to use with_info hwmon API Guenter Roeck
2024-07-26 15:20   ` Tzung-Bi Shih

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=20240726004329.934763-5-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox