Linux-Hwmon Archive on lore.kernel.org
 help / Atom feed
* [PATCH v3 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with
       [not found] <cover.1546918172.git.xiaoting.liu@hxt-semitech.com>
@ 2019-01-10  2:18 ` Xiaoting Liu
  2019-01-10  2:31 ` [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB Xiaoting Liu
  1 sibling, 0 replies; 4+ messages in thread
From: Xiaoting Liu @ 2019-01-10  2:18 UTC (permalink / raw)
  To: linux, jdelvare, dongsheng.wang
  Cc: linux-hwmon, linux-kernel, shunyong.yang, Xiaoting Liu

Current code compares device name with name in i2c_device_id to decide
whether PMBUS_SKIP_STATUS_CHECK should be set in pmbus_platform_data,
which makes adding new devices with PMBUS_SKIP_STATUS_CHECK should also
modify code in pmbus_probe().

This patch adds pmbus_device_info to save pages and flags. Its pointer
is put in driver_data of i2c_device_id, which makes adding new device
more straightforward.

Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
Signed-off-by: Xiaoting Liu <xiaoting.liu@hxt-semitech.com>
---
v3:
  Remove an empty line.
---
v2:
  Move struct pmbus_device_info definition location from pmbus.h to pmbus.c. 
  Change struct name from default_pmbus_info to pmbus_info_one.
  Change struct name from pmbus_info to pmbus_info_zero.
  Replace struct name dps460_pmbus_info and sgd009_pmbus_info with
  pmbus_info_one_skip.
---
 drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 7688dab32f6e..ef845a1310fa 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -28,6 +28,11 @@
 #include <linux/pmbus.h>
 #include "pmbus.h"
 
+struct pmbus_device_info {
+	int pages;
+	u32 flags;
+};
+
 /*
  * Find sensor groups and status registers on each page.
  */
@@ -172,13 +177,14 @@ static int pmbus_probe(struct i2c_client *client,
 	struct pmbus_driver_info *info;
 	struct pmbus_platform_data *pdata = NULL;
 	struct device *dev = &client->dev;
+	struct pmbus_device_info *device_info;
 
 	info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
 
-	if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") ||
-	    !strcmp(id->name, "sgd009")) {
+	device_info = (struct pmbus_device_info *)id->driver_data;
+	if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
 		pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
 				     GFP_KERNEL);
 		if (!pdata)
@@ -187,36 +193,40 @@ static int pmbus_probe(struct i2c_client *client,
 		pdata->flags = PMBUS_SKIP_STATUS_CHECK;
 	}
 
-	info->pages = id->driver_data;
+	info->pages = device_info->pages;
 	info->identify = pmbus_identify;
 	dev->platform_data = pdata;
 
 	return pmbus_do_probe(client, id, info);
 }
 
+static const struct pmbus_device_info pmbus_info_one = {1, 0};
+static const struct pmbus_device_info pmbus_info_zero = {0, 0};
+static const struct pmbus_device_info pmbus_info_one_skip = {
+				1, PMBUS_SKIP_STATUS_CHECK};
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
 static const struct i2c_device_id pmbus_id[] = {
-	{"adp4000", 1},
-	{"bmr453", 1},
-	{"bmr454", 1},
-	{"dps460", 1},
-	{"dps800", 1},
-	{"mdt040", 1},
-	{"ncp4200", 1},
-	{"ncp4208", 1},
-	{"pdt003", 1},
-	{"pdt006", 1},
-	{"pdt012", 1},
-	{"pmbus", 0},
-	{"sgd009", 1},
-	{"tps40400", 1},
-	{"tps544b20", 1},
-	{"tps544b25", 1},
-	{"tps544c20", 1},
-	{"tps544c25", 1},
-	{"udt020", 1},
+	{"adp4000", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr453", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr454", (kernel_ulong_t)&pmbus_info_one},
+	{"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
+	{"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
+	{"mdt040", (kernel_ulong_t)&pmbus_info_one},
+	{"ncp4200", (kernel_ulong_t)&pmbus_info_one},
+	{"ncp4208", (kernel_ulong_t)&pmbus_info_one},
+	{"pdt003", (kernel_ulong_t)&pmbus_info_one},
+	{"pdt006", (kernel_ulong_t)&pmbus_info_one},
+	{"pdt012", (kernel_ulong_t)&pmbus_info_one},
+	{"pmbus", (kernel_ulong_t)&pmbus_info_zero},
+	{"sgd009", (kernel_ulong_t)&pmbus_info_one_skip},
+	{"tps40400", (kernel_ulong_t)&pmbus_info_one},
+	{"tps544b20", (kernel_ulong_t)&pmbus_info_one},
+	{"tps544b25", (kernel_ulong_t)&pmbus_info_one},
+	{"tps544c20", (kernel_ulong_t)&pmbus_info_one},
+	{"tps544c25", (kernel_ulong_t)&pmbus_info_one},
+	{"udt020", (kernel_ulong_t)&pmbus_info_one},
 	{}
 };

-- 
1.8.3.1


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

* [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB
       [not found] <cover.1546918172.git.xiaoting.liu@hxt-semitech.com>
  2019-01-10  2:18 ` [PATCH v3 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with Xiaoting Liu
@ 2019-01-10  2:31 ` Xiaoting Liu
  2019-01-10 18:42   ` Guenter Roeck
  1 sibling, 1 reply; 4+ messages in thread
From: Xiaoting Liu @ 2019-01-10  2:31 UTC (permalink / raw)
  To: linux, jdelvare
  Cc: openbmc, linux-hwmon, linux-kernel, shunyong.yang,
	dongsheng.wang, Xiaoting Liu

Provide support for PSU DPS-650AB from Delta Electronics, INC.

Signed-off-by: Xiaoting Liu <xiaoting.liu@hxt-semitech.com>
---
v3:
  No change.
---
v2:
  Change the patch subject and commit message.
  Drop dps650ab.c file.
  Replace struct name dps650ab_pmbus_info with pmbus_info_one_skip.
---
 drivers/hwmon/pmbus/pmbus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index ef845a1310fa..e648ed8d926a 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -212,6 +212,7 @@ static int pmbus_probe(struct i2c_client *client,
 	{"bmr453", (kernel_ulong_t)&pmbus_info_one},
 	{"bmr454", (kernel_ulong_t)&pmbus_info_one},
 	{"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
+	{"dps650ab", (kernel_ulong_t)&pmbus_info_one_skip},
 	{"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
 	{"mdt040", (kernel_ulong_t)&pmbus_info_one},
 	{"ncp4200", (kernel_ulong_t)&pmbus_info_one},
-- 
1.8.3.1


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

* Re: [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB
  2019-01-10  2:31 ` [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB Xiaoting Liu
@ 2019-01-10 18:42   ` Guenter Roeck
  2019-01-11  8:27     ` Liu, Xiaoting
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2019-01-10 18:42 UTC (permalink / raw)
  To: Xiaoting Liu
  Cc: jdelvare, openbmc, linux-hwmon, linux-kernel, shunyong.yang,
	dongsheng.wang

On Thu, Jan 10, 2019 at 10:31:44AM +0800, Xiaoting Liu wrote:
> Provide support for PSU DPS-650AB from Delta Electronics, INC.
> 
> Signed-off-by: Xiaoting Liu <xiaoting.liu@hxt-semitech.com>

Applied to hwmon-next.

Thanks,
Guenter

> ---
> v3:
>   No change.
> ---
> v2:
>   Change the patch subject and commit message.
>   Drop dps650ab.c file.
>   Replace struct name dps650ab_pmbus_info with pmbus_info_one_skip.
> ---
>  drivers/hwmon/pmbus/pmbus.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
> index ef845a1310fa..e648ed8d926a 100644
> --- a/drivers/hwmon/pmbus/pmbus.c
> +++ b/drivers/hwmon/pmbus/pmbus.c
> @@ -212,6 +212,7 @@ static int pmbus_probe(struct i2c_client *client,
>  	{"bmr453", (kernel_ulong_t)&pmbus_info_one},
>  	{"bmr454", (kernel_ulong_t)&pmbus_info_one},
>  	{"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
> +	{"dps650ab", (kernel_ulong_t)&pmbus_info_one_skip},
>  	{"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
>  	{"mdt040", (kernel_ulong_t)&pmbus_info_one},
>  	{"ncp4200", (kernel_ulong_t)&pmbus_info_one},
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB
  2019-01-10 18:42   ` Guenter Roeck
@ 2019-01-11  8:27     ` Liu, Xiaoting
  0 siblings, 0 replies; 4+ messages in thread
From: Liu, Xiaoting @ 2019-01-11  8:27 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: jdelvare, openbmc, linux-hwmon, linux-kernel, Yang, Shunyong,
	Wang, Dongsheng

On 2019/1/11 2:42, Guenter Roeck wrote:
> On Thu, Jan 10, 2019 at 10:31:44AM +0800, Xiaoting Liu wrote:
>> Provide support for PSU DPS-650AB from Delta Electronics, INC.
>>
>> Signed-off-by: Xiaoting Liu <xiaoting.liu@hxt-semitech.com>
> Applied to hwmon-next.
>
> Thanks,
> Guenter

Thanks for your reply!

Xiaoting

>> ---
>> v3:
>>   No change.
>> ---
>> v2:
>>   Change the patch subject and commit message.
>>   Drop dps650ab.c file.
>>   Replace struct name dps650ab_pmbus_info with pmbus_info_one_skip.
>> ---
>>  drivers/hwmon/pmbus/pmbus.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
>> index ef845a1310fa..e648ed8d926a 100644
>> --- a/drivers/hwmon/pmbus/pmbus.c
>> +++ b/drivers/hwmon/pmbus/pmbus.c
>> @@ -212,6 +212,7 @@ static int pmbus_probe(struct i2c_client *client,
>>  	{"bmr453", (kernel_ulong_t)&pmbus_info_one},
>>  	{"bmr454", (kernel_ulong_t)&pmbus_info_one},
>>  	{"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
>> +	{"dps650ab", (kernel_ulong_t)&pmbus_info_one_skip},
>>  	{"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
>>  	{"mdt040", (kernel_ulong_t)&pmbus_info_one},
>>  	{"ncp4200", (kernel_ulong_t)&pmbus_info_one},
>> -- 
>> 1.8.3.1
>>


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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1546918172.git.xiaoting.liu@hxt-semitech.com>
2019-01-10  2:18 ` [PATCH v3 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with Xiaoting Liu
2019-01-10  2:31 ` [PATCH v3 4/4] hwmon: (pmbus) add support for DPS-650AB Xiaoting Liu
2019-01-10 18:42   ` Guenter Roeck
2019-01-11  8:27     ` Liu, Xiaoting

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox