aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-01-20 11:23:16 -0500
committerGuenter Roeck <linux@roeck-us.net>2013-02-06 12:58:00 -0500
commitc2a583519dacf89fb4231e062e9804355ae2326b (patch)
tree775d84eaca8a715dae376e09d7ec7a6a7dfbf7ed /drivers/hwmon/pmbus
parent973018b1b75abd696304207f016875d1fce2dbf4 (diff)
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>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index b9ba8ce1f3f1..97eca0340dc0 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1691,7 +1691,8 @@ static int pmbus_identify_common(struct i2c_client *client,
1691int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 1691int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1692 struct pmbus_driver_info *info) 1692 struct pmbus_driver_info *info)
1693{ 1693{
1694 const struct pmbus_platform_data *pdata = client->dev.platform_data; 1694 struct device *dev = &client->dev;
1695 const struct pmbus_platform_data *pdata = dev->platform_data;
1695 struct pmbus_data *data; 1696 struct pmbus_data *data;
1696 int ret; 1697 int ret;
1697 1698
@@ -1703,7 +1704,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1703 | I2C_FUNC_SMBUS_WORD_DATA)) 1704 | I2C_FUNC_SMBUS_WORD_DATA))
1704 return -ENODEV; 1705 return -ENODEV;
1705 1706
1706 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); 1707 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
1707 if (!data) 1708 if (!data)
1708 return -ENOMEM; 1709 return -ENOMEM;
1709 1710
@@ -1712,7 +1713,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1712 1713
1713 /* Bail out if PMBus status register does not exist. */ 1714 /* Bail out if PMBus status register does not exist. */
1714 if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) { 1715 if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) {
1715 dev_err(&client->dev, "PMBus status register not found\n"); 1716 dev_err(dev, "PMBus status register not found\n");
1716 return -ENODEV; 1717 return -ENODEV;
1717 } 1718 }
1718 1719
@@ -1725,40 +1726,38 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1725 if (info->identify) { 1726 if (info->identify) {
1726 ret = (*info->identify)(client, info); 1727 ret = (*info->identify)(client, info);
1727 if (ret < 0) { 1728 if (ret < 0) {
1728 dev_err(&client->dev, "Chip identification failed\n"); 1729 dev_err(dev, "Chip identification failed\n");
1729 return ret; 1730 return ret;
1730 } 1731 }
1731 } 1732 }
1732 1733
1733 if (info->pages <= 0 || info->pages > PMBUS_PAGES) { 1734 if (info->pages <= 0 || info->pages > PMBUS_PAGES) {
1734 dev_err(&client->dev, "Bad number of PMBus pages: %d\n", 1735 dev_err(dev, "Bad number of PMBus pages: %d\n", info->pages);
1735 info->pages);
1736 return -ENODEV; 1736 return -ENODEV;
1737 } 1737 }
1738 1738
1739 ret = pmbus_identify_common(client, data); 1739 ret = pmbus_identify_common(client, data);
1740 if (ret < 0) { 1740 if (ret < 0) {
1741 dev_err(&client->dev, "Failed to identify chip capabilities\n"); 1741 dev_err(dev, "Failed to identify chip capabilities\n");
1742 return ret; 1742 return ret;
1743 } 1743 }
1744 1744
1745 ret = -ENOMEM; 1745 data->sensors = devm_kzalloc(dev, sizeof(struct pmbus_sensor)
1746 data->sensors = devm_kzalloc(&client->dev, sizeof(struct pmbus_sensor)
1747 * data->max_sensors, GFP_KERNEL); 1746 * data->max_sensors, GFP_KERNEL);
1748 if (!data->sensors) 1747 if (!data->sensors)
1749 return -ENOMEM; 1748 return -ENOMEM;
1750 1749
1751 data->booleans = devm_kzalloc(&client->dev, sizeof(struct pmbus_boolean) 1750 data->booleans = devm_kzalloc(dev, sizeof(struct pmbus_boolean)
1752 * data->max_booleans, GFP_KERNEL); 1751 * data->max_booleans, GFP_KERNEL);
1753 if (!data->booleans) 1752 if (!data->booleans)
1754 return -ENOMEM; 1753 return -ENOMEM;
1755 1754
1756 data->labels = devm_kzalloc(&client->dev, sizeof(struct pmbus_label) 1755 data->labels = devm_kzalloc(dev, sizeof(struct pmbus_label)
1757 * data->max_labels, GFP_KERNEL); 1756 * data->max_labels, GFP_KERNEL);
1758 if (!data->labels) 1757 if (!data->labels)
1759 return -ENOMEM; 1758 return -ENOMEM;
1760 1759
1761 data->attributes = devm_kzalloc(&client->dev, sizeof(struct attribute *) 1760 data->attributes = devm_kzalloc(dev, sizeof(struct attribute *)
1762 * data->max_attributes, GFP_KERNEL); 1761 * data->max_attributes, GFP_KERNEL);
1763 if (!data->attributes) 1762 if (!data->attributes)
1764 return -ENOMEM; 1763 return -ENOMEM;
@@ -1770,27 +1769,27 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
1770 * Bail out instead of trying to register nothing. 1769 * Bail out instead of trying to register nothing.
1771 */ 1770 */
1772 if (!data->num_attributes) { 1771 if (!data->num_attributes) {
1773 dev_err(&client->dev, "No attributes found\n"); 1772 dev_err(dev, "No attributes found\n");
1774 return -ENODEV; 1773 return -ENODEV;
1775 } 1774 }
1776 1775
1777 /* Register sysfs hooks */ 1776 /* Register sysfs hooks */
1778 data->group.attrs = data->attributes; 1777 data->group.attrs = data->attributes;
1779 ret = sysfs_create_group(&client->dev.kobj, &data->group); 1778 ret = sysfs_create_group(&dev->kobj, &data->group);
1780 if (ret) { 1779 if (ret) {
1781 dev_err(&client->dev, "Failed to create sysfs entries\n"); 1780 dev_err(dev, "Failed to create sysfs entries\n");
1782 return ret; 1781 return ret;
1783 } 1782 }
1784 data->hwmon_dev = hwmon_device_register(&client->dev); 1783 data->hwmon_dev = hwmon_device_register(dev);
1785 if (IS_ERR(data->hwmon_dev)) { 1784 if (IS_ERR(data->hwmon_dev)) {
1786 ret = PTR_ERR(data->hwmon_dev); 1785 ret = PTR_ERR(data->hwmon_dev);
1787 dev_err(&client->dev, "Failed to register hwmon device\n"); 1786 dev_err(dev, "Failed to register hwmon device\n");
1788 goto out_hwmon_device_register; 1787 goto out_hwmon_device_register;
1789 } 1788 }
1790 return 0; 1789 return 0;
1791 1790
1792out_hwmon_device_register: 1791out_hwmon_device_register:
1793 sysfs_remove_group(&client->dev.kobj, &data->group); 1792 sysfs_remove_group(&dev->kobj, &data->group);
1794 return ret; 1793 return ret;
1795} 1794}
1796EXPORT_SYMBOL_GPL(pmbus_do_probe); 1795EXPORT_SYMBOL_GPL(pmbus_do_probe);