Commit 6f4a46f0 authored by Xiaoting Liu's avatar Xiaoting Liu Committed by Guenter Roeck

hwmon: (pmbus) associate PMBUS_SKIP_STATUS_CHECK with driver data

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: default avatarShunyong Yang <shunyong.yang@hxt-semitech.com>
Signed-off-by: default avatarXiaoting Liu <xiaoting.liu@hxt-semitech.com>
[groeck: Use designated structure initializers to improve readability]
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent c947e51c
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include <linux/pmbus.h> #include <linux/pmbus.h>
#include "pmbus.h" #include "pmbus.h"
struct pmbus_device_info {
int pages;
u32 flags;
};
/* /*
* Find sensor groups and status registers on each page. * Find sensor groups and status registers on each page.
*/ */
...@@ -172,13 +177,14 @@ static int pmbus_probe(struct i2c_client *client, ...@@ -172,13 +177,14 @@ static int pmbus_probe(struct i2c_client *client,
struct pmbus_driver_info *info; struct pmbus_driver_info *info;
struct pmbus_platform_data *pdata = NULL; struct pmbus_platform_data *pdata = NULL;
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct pmbus_device_info *device_info;
info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") || device_info = (struct pmbus_device_info *)id->driver_data;
!strcmp(id->name, "sgd009")) { if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
GFP_KERNEL); GFP_KERNEL);
if (!pdata) if (!pdata)
...@@ -187,36 +193,49 @@ static int pmbus_probe(struct i2c_client *client, ...@@ -187,36 +193,49 @@ static int pmbus_probe(struct i2c_client *client,
pdata->flags = PMBUS_SKIP_STATUS_CHECK; pdata->flags = PMBUS_SKIP_STATUS_CHECK;
} }
info->pages = id->driver_data; info->pages = device_info->pages;
info->identify = pmbus_identify; info->identify = pmbus_identify;
dev->platform_data = pdata; dev->platform_data = pdata;
return pmbus_do_probe(client, id, info); return pmbus_do_probe(client, id, info);
} }
static const struct pmbus_device_info pmbus_info_one = {
.pages = 1,
.flags = 0
};
static const struct pmbus_device_info pmbus_info_zero = {
.pages = 0,
.flags = 0
};
static const struct pmbus_device_info pmbus_info_one_skip = {
.pages = 1,
.flags = PMBUS_SKIP_STATUS_CHECK
};
/* /*
* Use driver_data to set the number of pages supported by the chip. * Use driver_data to set the number of pages supported by the chip.
*/ */
static const struct i2c_device_id pmbus_id[] = { static const struct i2c_device_id pmbus_id[] = {
{"adp4000", 1}, {"adp4000", (kernel_ulong_t)&pmbus_info_one},
{"bmr453", 1}, {"bmr453", (kernel_ulong_t)&pmbus_info_one},
{"bmr454", 1}, {"bmr454", (kernel_ulong_t)&pmbus_info_one},
{"dps460", 1}, {"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
{"dps800", 1}, {"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
{"mdt040", 1}, {"mdt040", (kernel_ulong_t)&pmbus_info_one},
{"ncp4200", 1}, {"ncp4200", (kernel_ulong_t)&pmbus_info_one},
{"ncp4208", 1}, {"ncp4208", (kernel_ulong_t)&pmbus_info_one},
{"pdt003", 1}, {"pdt003", (kernel_ulong_t)&pmbus_info_one},
{"pdt006", 1}, {"pdt006", (kernel_ulong_t)&pmbus_info_one},
{"pdt012", 1}, {"pdt012", (kernel_ulong_t)&pmbus_info_one},
{"pmbus", 0}, {"pmbus", (kernel_ulong_t)&pmbus_info_zero},
{"sgd009", 1}, {"sgd009", (kernel_ulong_t)&pmbus_info_one_skip},
{"tps40400", 1}, {"tps40400", (kernel_ulong_t)&pmbus_info_one},
{"tps544b20", 1}, {"tps544b20", (kernel_ulong_t)&pmbus_info_one},
{"tps544b25", 1}, {"tps544b25", (kernel_ulong_t)&pmbus_info_one},
{"tps544c20", 1}, {"tps544c20", (kernel_ulong_t)&pmbus_info_one},
{"tps544c25", 1}, {"tps544c25", (kernel_ulong_t)&pmbus_info_one},
{"udt020", 1}, {"udt020", (kernel_ulong_t)&pmbus_info_one},
{} {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment