mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 09:14:19 +08:00
hwmon: (pmbus) Use dev variable to represent client->dev
This simplifies the code and makes it a bit smaller. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
973018b1b7
commit
c2a583519d
@ -1691,7 +1691,8 @@ static int pmbus_identify_common(struct i2c_client *client,
|
|||||||
int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
||||||
struct pmbus_driver_info *info)
|
struct pmbus_driver_info *info)
|
||||||
{
|
{
|
||||||
const struct pmbus_platform_data *pdata = client->dev.platform_data;
|
struct device *dev = &client->dev;
|
||||||
|
const struct pmbus_platform_data *pdata = dev->platform_data;
|
||||||
struct pmbus_data *data;
|
struct pmbus_data *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1703,7 +1704,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
|||||||
| I2C_FUNC_SMBUS_WORD_DATA))
|
| I2C_FUNC_SMBUS_WORD_DATA))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
|
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -1712,7 +1713,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
|||||||
|
|
||||||
/* Bail out if PMBus status register does not exist. */
|
/* Bail out if PMBus status register does not exist. */
|
||||||
if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
|
if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
|
||||||
dev_err(&client->dev, "PMBus status register not found\n");
|
dev_err(dev, "PMBus status register not found\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1725,40 +1726,38 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
|||||||
if (info->identify) {
|
if (info->identify) {
|
||||||
ret = (*info->identify)(client, info);
|
ret = (*info->identify)(client, info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&client->dev, "Chip identification failed\n");
|
dev_err(dev, "Chip identification failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
|
if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
|
||||||
dev_err(&client->dev, "Bad number of PMBus pages: %d\n",
|
dev_err(dev, "Bad number of PMBus pages: %d\n", info->pages);
|
||||||
info->pages);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pmbus_identify_common(client, data);
|
ret = pmbus_identify_common(client, data);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&client->dev, "Failed to identify chip capabilities\n");
|
dev_err(dev, "Failed to identify chip capabilities\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -ENOMEM;
|
data->sensors = devm_kzalloc(dev, sizeof(struct pmbus_sensor)
|
||||||
data->sensors = devm_kzalloc(&client->dev, sizeof(struct pmbus_sensor)
|
|
||||||
* data->max_sensors, GFP_KERNEL);
|
* data->max_sensors, GFP_KERNEL);
|
||||||
if (!data->sensors)
|
if (!data->sensors)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->booleans = devm_kzalloc(&client->dev, sizeof(struct pmbus_boolean)
|
data->booleans = devm_kzalloc(dev, sizeof(struct pmbus_boolean)
|
||||||
* data->max_booleans, GFP_KERNEL);
|
* data->max_booleans, GFP_KERNEL);
|
||||||
if (!data->booleans)
|
if (!data->booleans)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->labels = devm_kzalloc(&client->dev, sizeof(struct pmbus_label)
|
data->labels = devm_kzalloc(dev, sizeof(struct pmbus_label)
|
||||||
* data->max_labels, GFP_KERNEL);
|
* data->max_labels, GFP_KERNEL);
|
||||||
if (!data->labels)
|
if (!data->labels)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->attributes = devm_kzalloc(&client->dev, sizeof(struct attribute *)
|
data->attributes = devm_kzalloc(dev, sizeof(struct attribute *)
|
||||||
* data->max_attributes, GFP_KERNEL);
|
* data->max_attributes, GFP_KERNEL);
|
||||||
if (!data->attributes)
|
if (!data->attributes)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -1770,27 +1769,27 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
|
|||||||
* Bail out instead of trying to register nothing.
|
* Bail out instead of trying to register nothing.
|
||||||
*/
|
*/
|
||||||
if (!data->num_attributes) {
|
if (!data->num_attributes) {
|
||||||
dev_err(&client->dev, "No attributes found\n");
|
dev_err(dev, "No attributes found\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
data->group.attrs = data->attributes;
|
data->group.attrs = data->attributes;
|
||||||
ret = sysfs_create_group(&client->dev.kobj, &data->group);
|
ret = sysfs_create_group(&dev->kobj, &data->group);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&client->dev, "Failed to create sysfs entries\n");
|
dev_err(dev, "Failed to create sysfs entries\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
data->hwmon_dev = hwmon_device_register(dev);
|
||||||
if (IS_ERR(data->hwmon_dev)) {
|
if (IS_ERR(data->hwmon_dev)) {
|
||||||
ret = PTR_ERR(data->hwmon_dev);
|
ret = PTR_ERR(data->hwmon_dev);
|
||||||
dev_err(&client->dev, "Failed to register hwmon device\n");
|
dev_err(dev, "Failed to register hwmon device\n");
|
||||||
goto out_hwmon_device_register;
|
goto out_hwmon_device_register;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_hwmon_device_register:
|
out_hwmon_device_register:
|
||||||
sysfs_remove_group(&client->dev.kobj, &data->group);
|
sysfs_remove_group(&dev->kobj, &data->group);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pmbus_do_probe);
|
EXPORT_SYMBOL_GPL(pmbus_do_probe);
|
||||||
|
Loading…
Reference in New Issue
Block a user