aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1026.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-12-01 05:24:17 -0500
committerMark M. Hoffman <mhoffman@lightlink.com>2008-02-07 20:39:42 -0500
commitf67fdabfb94b0bb96623a4b48d22be5329a06277 (patch)
tree5947d33eaddce3ce50e21a300913d89dbc67cf1e /drivers/hwmon/adm1026.c
parentcb01a2312f56c93d2740e827718966b92b7cbb91 (diff)
hwmon: (adm1026) More cleanups (updated)
Various cleanups: * Drop an unused define. * Drop unused struct member "type". * Drop one useless instruction. * Drop redundant initializations to 0. * Rename new_client to client. * Drop a useless cast. * Minor code cleanup. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r--drivers/hwmon/adm1026.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index 9f44ed7ebb7b..a20af03f4fc6 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -232,9 +232,6 @@ static int adm1026_scaling[] = { /* .001 Volts */
232#define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255)) 232#define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255))
233#define DAC_FROM_REG(val) (((val)*2500)/255) 233#define DAC_FROM_REG(val) (((val)*2500)/255)
234 234
235/* Typically used with systems using a v9.1 VRM spec ? */
236#define ADM1026_INIT_VRM 91
237
238/* Chip sampling rates 235/* Chip sampling rates
239 * 236 *
240 * Some sensors are not updated more frequently than once per second 237 * Some sensors are not updated more frequently than once per second
@@ -264,7 +261,6 @@ struct pwm_data {
264struct adm1026_data { 261struct adm1026_data {
265 struct i2c_client client; 262 struct i2c_client client;
266 struct device *hwmon_dev; 263 struct device *hwmon_dev;
267 enum chips type;
268 264
269 struct mutex update_lock; 265 struct mutex update_lock;
270 int valid; /* !=0 if following fields are valid */ 266 int valid; /* !=0 if following fields are valid */
@@ -387,7 +383,6 @@ static void adm1026_init_client(struct i2c_client *client)
387 "and temp limits enabled.\n"); 383 "and temp limits enabled.\n");
388 } 384 }
389 385
390 value = data->config3;
391 if (data->config3 & CFG3_GPIO16_ENABLE) { 386 if (data->config3 & CFG3_GPIO16_ENABLE) {
392 dev_dbg(&client->dev, "GPIO16 enabled. THERM " 387 dev_dbg(&client->dev, "GPIO16 enabled. THERM "
393 "pin disabled.\n"); 388 "pin disabled.\n");
@@ -1230,8 +1225,7 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, c
1230static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, 1225static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
1231 size_t count) 1226 size_t count)
1232{ 1227{
1233 struct i2c_client *client = to_i2c_client(dev); 1228 struct adm1026_data *data = dev_get_drvdata(dev);
1234 struct adm1026_data *data = i2c_get_clientdata(client);
1235 1229
1236 data->vrm = simple_strtol(buf, NULL, 10); 1230 data->vrm = simple_strtol(buf, NULL, 10);
1237 return count; 1231 return count;
@@ -1242,7 +1236,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
1242static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 1236static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
1243{ 1237{
1244 struct adm1026_data *data = adm1026_update_device(dev); 1238 struct adm1026_data *data = adm1026_update_device(dev);
1245 return sprintf(buf, "%ld\n", (long) (data->alarms)); 1239 return sprintf(buf, "%ld\n", data->alarms);
1246} 1240}
1247 1241
1248static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 1242static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
@@ -1641,7 +1635,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1641 int kind) 1635 int kind)
1642{ 1636{
1643 int company, verstep; 1637 int company, verstep;
1644 struct i2c_client *new_client; 1638 struct i2c_client *client;
1645 struct adm1026_data *data; 1639 struct adm1026_data *data;
1646 int err = 0; 1640 int err = 0;
1647 const char *type_name = ""; 1641 const char *type_name = "";
@@ -1660,26 +1654,25 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1660 goto exit; 1654 goto exit;
1661 } 1655 }
1662 1656
1663 new_client = &data->client; 1657 client = &data->client;
1664 i2c_set_clientdata(new_client, data); 1658 i2c_set_clientdata(client, data);
1665 new_client->addr = address; 1659 client->addr = address;
1666 new_client->adapter = adapter; 1660 client->adapter = adapter;
1667 new_client->driver = &adm1026_driver; 1661 client->driver = &adm1026_driver;
1668 new_client->flags = 0;
1669 1662
1670 /* Now, we do the remaining detection. */ 1663 /* Now, we do the remaining detection. */
1671 1664
1672 company = adm1026_read_value(new_client, ADM1026_REG_COMPANY); 1665 company = adm1026_read_value(client, ADM1026_REG_COMPANY);
1673 verstep = adm1026_read_value(new_client, ADM1026_REG_VERSTEP); 1666 verstep = adm1026_read_value(client, ADM1026_REG_VERSTEP);
1674 1667
1675 dev_dbg(&new_client->dev, "Detecting device at %d,0x%02x with" 1668 dev_dbg(&client->dev, "Detecting device at %d,0x%02x with"
1676 " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", 1669 " COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
1677 i2c_adapter_id(new_client->adapter), new_client->addr, 1670 i2c_adapter_id(client->adapter), client->addr,
1678 company, verstep); 1671 company, verstep);
1679 1672
1680 /* If auto-detecting, Determine the chip type. */ 1673 /* If auto-detecting, Determine the chip type. */
1681 if (kind <= 0) { 1674 if (kind <= 0) {
1682 dev_dbg(&new_client->dev, "Autodetecting device at %d,0x%02x " 1675 dev_dbg(&client->dev, "Autodetecting device at %d,0x%02x "
1683 "...\n", i2c_adapter_id(adapter), address); 1676 "...\n", i2c_adapter_id(adapter), address);
1684 if (company == ADM1026_COMPANY_ANALOG_DEV 1677 if (company == ADM1026_COMPANY_ANALOG_DEV
1685 && verstep == ADM1026_VERSTEP_ADM1026) { 1678 && verstep == ADM1026_VERSTEP_ADM1026) {
@@ -1695,7 +1688,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1695 verstep); 1688 verstep);
1696 kind = any_chip; 1689 kind = any_chip;
1697 } else { 1690 } else {
1698 dev_dbg(&new_client->dev, ": Autodetection " 1691 dev_dbg(&client->dev, ": Autodetection "
1699 "failed\n"); 1692 "failed\n");
1700 /* Not an ADM1026 ... */ 1693 /* Not an ADM1026 ... */
1701 if (kind == 0) { /* User used force=x,y */ 1694 if (kind == 0) { /* User used force=x,y */
@@ -1704,7 +1697,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1704 "force_adm1026.\n", 1697 "force_adm1026.\n",
1705 i2c_adapter_id(adapter), address); 1698 i2c_adapter_id(adapter), address);
1706 } 1699 }
1707 err = 0;
1708 goto exitfree; 1700 goto exitfree;
1709 } 1701 }
1710 } 1702 }
@@ -1723,28 +1715,26 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1723 err = -EFAULT; 1715 err = -EFAULT;
1724 goto exitfree; 1716 goto exitfree;
1725 } 1717 }
1726 strlcpy(new_client->name, type_name, I2C_NAME_SIZE); 1718 strlcpy(client->name, type_name, I2C_NAME_SIZE);
1727 1719
1728 /* Fill in the remaining client fields */ 1720 /* Fill in the remaining client fields */
1729 data->type = kind;
1730 data->valid = 0;
1731 mutex_init(&data->update_lock); 1721 mutex_init(&data->update_lock);
1732 1722
1733 /* Tell the I2C layer a new client has arrived */ 1723 /* Tell the I2C layer a new client has arrived */
1734 if ((err = i2c_attach_client(new_client))) 1724 if ((err = i2c_attach_client(client)))
1735 goto exitfree; 1725 goto exitfree;
1736 1726
1737 /* Set the VRM version */ 1727 /* Set the VRM version */
1738 data->vrm = vid_which_vrm(); 1728 data->vrm = vid_which_vrm();
1739 1729
1740 /* Initialize the ADM1026 chip */ 1730 /* Initialize the ADM1026 chip */
1741 adm1026_init_client(new_client); 1731 adm1026_init_client(client);
1742 1732
1743 /* Register sysfs hooks */ 1733 /* Register sysfs hooks */
1744 if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1026_group))) 1734 if ((err = sysfs_create_group(&client->dev.kobj, &adm1026_group)))
1745 goto exitdetach; 1735 goto exitdetach;
1746 1736
1747 data->hwmon_dev = hwmon_device_register(&new_client->dev); 1737 data->hwmon_dev = hwmon_device_register(&client->dev);
1748 if (IS_ERR(data->hwmon_dev)) { 1738 if (IS_ERR(data->hwmon_dev)) {
1749 err = PTR_ERR(data->hwmon_dev); 1739 err = PTR_ERR(data->hwmon_dev);
1750 goto exitremove; 1740 goto exitremove;
@@ -1754,9 +1744,9 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1754 1744
1755 /* Error out and cleanup code */ 1745 /* Error out and cleanup code */
1756exitremove: 1746exitremove:
1757 sysfs_remove_group(&new_client->dev.kobj, &adm1026_group); 1747 sysfs_remove_group(&client->dev.kobj, &adm1026_group);
1758exitdetach: 1748exitdetach:
1759 i2c_detach_client(new_client); 1749 i2c_detach_client(client);
1760exitfree: 1750exitfree:
1761 kfree(data); 1751 kfree(data);
1762exit: 1752exit: