linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus/bpa-rs600): Support BPD-RS600
@ 2021-07-08 22:06 Chris Packham
  2021-07-09 20:55 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Packham @ 2021-07-08 22:06 UTC (permalink / raw)
  To: linux, jdelvare; +Cc: linux-hwmon, linux-kernel, Chris Packham

The BPD-RS600 is the DC version of the BPA-RS600. The PMBUS interface is
the same between the two models. Keep the same compatible string but
accept either BPA-RS600 or BPD-RS600 in the PMBUS_MFR_MODEL.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 drivers/hwmon/pmbus/bpa-rs600.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/pmbus/bpa-rs600.c b/drivers/hwmon/pmbus/bpa-rs600.c
index 2be69fedfa36..d205b41540ce 100644
--- a/drivers/hwmon/pmbus/bpa-rs600.c
+++ b/drivers/hwmon/pmbus/bpa-rs600.c
@@ -21,6 +21,8 @@
 #define BPARS600_MFR_IOUT_MAX	0xa6
 #define BPARS600_MFR_POUT_MAX	0xa7
 
+enum chips { bpa_rs600, bpd_rs600 };
+
 static int bpa_rs600_read_byte_data(struct i2c_client *client, int page, int reg)
 {
 	int ret;
@@ -146,11 +148,19 @@ static struct pmbus_driver_info bpa_rs600_info = {
 	.read_word_data = bpa_rs600_read_word_data,
 };
 
+static const struct i2c_device_id bpa_rs600_id[] = {
+	{ "bpa-rs600", bpa_rs600 },
+	{ "bpd-rs600", bpd_rs600 },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, bpa_rs600_id);
+
 static int bpa_rs600_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
 	int ret;
+	const struct i2c_device_id *mid;
 
 	if (!i2c_check_functionality(client->adapter,
 				     I2C_FUNC_SMBUS_READ_BYTE_DATA
@@ -164,7 +174,11 @@ static int bpa_rs600_probe(struct i2c_client *client)
 		return ret;
 	}
 
-	if (strncmp(buf, "BPA-RS600", 8)) {
+	for (mid = bpa_rs600_id; mid->name[0]; mid++) {
+		if (!strncasecmp(buf, mid->name, strlen(mid->name)))
+			break;
+	}
+	if (!mid->name[0]) {
 		buf[ret] = '\0';
 		dev_err(dev, "Unsupported Manufacturer Model '%s'\n", buf);
 		return -ENODEV;
@@ -173,12 +187,6 @@ static int bpa_rs600_probe(struct i2c_client *client)
 	return pmbus_do_probe(client, &bpa_rs600_info);
 }
 
-static const struct i2c_device_id bpa_rs600_id[] = {
-	{ "bpars600", 0 },
-	{},
-};
-MODULE_DEVICE_TABLE(i2c, bpa_rs600_id);
-
 static const struct of_device_id __maybe_unused bpa_rs600_of_match[] = {
 	{ .compatible = "blutek,bpa-rs600" },
 	{},
-- 
2.32.0


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

* Re: [PATCH] hwmon: (pmbus/bpa-rs600): Support BPD-RS600
  2021-07-08 22:06 [PATCH] hwmon: (pmbus/bpa-rs600): Support BPD-RS600 Chris Packham
@ 2021-07-09 20:55 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-07-09 20:55 UTC (permalink / raw)
  To: Chris Packham; +Cc: jdelvare, linux-hwmon, linux-kernel

On Fri, Jul 09, 2021 at 10:06:18AM +1200, Chris Packham wrote:
> The BPD-RS600 is the DC version of the BPA-RS600. The PMBUS interface is
> the same between the two models. Keep the same compatible string but
> accept either BPA-RS600 or BPD-RS600 in the PMBUS_MFR_MODEL.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/bpa-rs600.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/bpa-rs600.c b/drivers/hwmon/pmbus/bpa-rs600.c
> index 2be69fedfa36..d205b41540ce 100644
> --- a/drivers/hwmon/pmbus/bpa-rs600.c
> +++ b/drivers/hwmon/pmbus/bpa-rs600.c
> @@ -21,6 +21,8 @@
>  #define BPARS600_MFR_IOUT_MAX	0xa6
>  #define BPARS600_MFR_POUT_MAX	0xa7
>  
> +enum chips { bpa_rs600, bpd_rs600 };
> +
>  static int bpa_rs600_read_byte_data(struct i2c_client *client, int page, int reg)
>  {
>  	int ret;
> @@ -146,11 +148,19 @@ static struct pmbus_driver_info bpa_rs600_info = {
>  	.read_word_data = bpa_rs600_read_word_data,
>  };
>  
> +static const struct i2c_device_id bpa_rs600_id[] = {
> +	{ "bpa-rs600", bpa_rs600 },
> +	{ "bpd-rs600", bpd_rs600 },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(i2c, bpa_rs600_id);
> +
>  static int bpa_rs600_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
>  	u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
>  	int ret;
> +	const struct i2c_device_id *mid;
>  
>  	if (!i2c_check_functionality(client->adapter,
>  				     I2C_FUNC_SMBUS_READ_BYTE_DATA
> @@ -164,7 +174,11 @@ static int bpa_rs600_probe(struct i2c_client *client)
>  		return ret;
>  	}
>  
> -	if (strncmp(buf, "BPA-RS600", 8)) {
> +	for (mid = bpa_rs600_id; mid->name[0]; mid++) {
> +		if (!strncasecmp(buf, mid->name, strlen(mid->name)))
> +			break;
> +	}
> +	if (!mid->name[0]) {
>  		buf[ret] = '\0';
>  		dev_err(dev, "Unsupported Manufacturer Model '%s'\n", buf);
>  		return -ENODEV;
> @@ -173,12 +187,6 @@ static int bpa_rs600_probe(struct i2c_client *client)
>  	return pmbus_do_probe(client, &bpa_rs600_info);
>  }
>  
> -static const struct i2c_device_id bpa_rs600_id[] = {
> -	{ "bpars600", 0 },
> -	{},
> -};
> -MODULE_DEVICE_TABLE(i2c, bpa_rs600_id);
> -
>  static const struct of_device_id __maybe_unused bpa_rs600_of_match[] = {
>  	{ .compatible = "blutek,bpa-rs600" },
>  	{},

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

end of thread, other threads:[~2021-07-09 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 22:06 [PATCH] hwmon: (pmbus/bpa-rs600): Support BPD-RS600 Chris Packham
2021-07-09 20:55 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).