aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ds1621.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-01-14 16:26:08 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:26:51 -0400
commit19f2c05964dc428ef639fcda1cce7c8c3075c9cc (patch)
tree95e23d69d398e7e77772a90b97fcca0d7023146a /drivers/hwmon/ds1621.c
parent91efffe26a809bc6660b91e21264f48e501bfb46 (diff)
hwmon: (ds1621) Fix checkpatch issues
Fixed: ERROR: code indent should use tabs where possible ERROR: do not use assignment in if condition ERROR: trailing whitespace WARNING: labels should not be indented WARNING: please, no spaces at the start of a line WARNING: simple_strtol is obsolete, use kstrtol instead Also modified multi-line comments to follow Documentation/CodingStyle. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/ds1621.c')
-rw-r--r--drivers/hwmon/ds1621.c79
1 files changed, 44 insertions, 35 deletions
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 9832ac53c4b7..f647a3307ebc 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -1,25 +1,25 @@
1/* 1/*
2 ds1621.c - Part of lm_sensors, Linux kernel modules for hardware 2 * ds1621.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 * monitoring
4 Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23 4 * Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23
5 based on lm75.c by Frodo Looijaard <frodol@dds.nl> 5 * based on lm75.c by Frodo Looijaard <frodol@dds.nl>
6 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with 6 * Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
7 the help of Jean Delvare <khali@linux-fr.org> 7 * the help of Jean Delvare <khali@linux-fr.org>
8 8 *
9 This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 12 * (at your option) any later version.
13 13 *
14 This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 * GNU General Public License for more details.
18 18 *
19 You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 22 */
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/init.h> 25#include <linux/init.h>
@@ -67,7 +67,7 @@ static const u8 DS1621_REG_TEMP[3] = {
67 67
68/* Conversions */ 68/* Conversions */
69#define ALARMS_FROM_REG(val) ((val) & \ 69#define ALARMS_FROM_REG(val) ((val) & \
70 (DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW)) 70 (DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW))
71 71
72/* Each client has this additional data */ 72/* Each client has this additional data */
73struct ds1621_data { 73struct ds1621_data {
@@ -93,10 +93,10 @@ static void ds1621_init_client(struct i2c_client *client)
93 new_conf &= ~DS1621_REG_CONFIG_POLARITY; 93 new_conf &= ~DS1621_REG_CONFIG_POLARITY;
94 else if (polarity == 1) 94 else if (polarity == 1)
95 new_conf |= DS1621_REG_CONFIG_POLARITY; 95 new_conf |= DS1621_REG_CONFIG_POLARITY;
96 96
97 if (conf != new_conf) 97 if (conf != new_conf)
98 i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf); 98 i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf);
99 99
100 /* start conversion */ 100 /* start conversion */
101 i2c_smbus_write_byte(client, DS1621_COM_START); 101 i2c_smbus_write_byte(client, DS1621_COM_START);
102} 102}
@@ -155,10 +155,15 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
155 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 155 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
156 struct i2c_client *client = to_i2c_client(dev); 156 struct i2c_client *client = to_i2c_client(dev);
157 struct ds1621_data *data = i2c_get_clientdata(client); 157 struct ds1621_data *data = i2c_get_clientdata(client);
158 u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10)); 158 long val;
159 int err;
160
161 err = kstrtol(buf, 10, &val);
162 if (err)
163 return err;
159 164
160 mutex_lock(&data->update_lock); 165 mutex_lock(&data->update_lock);
161 data->temp[attr->index] = val; 166 data->temp[attr->index] = LM75_TEMP_TO_REG(val);
162 i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index], 167 i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index],
163 data->temp[attr->index]); 168 data->temp[attr->index]);
164 mutex_unlock(&data->update_lock); 169 mutex_unlock(&data->update_lock);
@@ -212,14 +217,17 @@ static int ds1621_detect(struct i2c_client *client,
212 int conf, temp; 217 int conf, temp;
213 int i; 218 int i;
214 219
215 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA 220 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
216 | I2C_FUNC_SMBUS_WORD_DATA 221 | I2C_FUNC_SMBUS_WORD_DATA
217 | I2C_FUNC_SMBUS_WRITE_BYTE)) 222 | I2C_FUNC_SMBUS_WRITE_BYTE))
218 return -ENODEV; 223 return -ENODEV;
219 224
220 /* Now, we do the remaining detection. It is lousy. */ 225 /*
221 /* The NVB bit should be low if no EEPROM write has been requested 226 * Now, we do the remaining detection. It is lousy.
222 during the latest 10ms, which is highly improbable in our case. */ 227 *
228 * The NVB bit should be low if no EEPROM write has been requested
229 * during the latest 10ms, which is highly improbable in our case.
230 */
223 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); 231 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
224 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) 232 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
225 return -ENODEV; 233 return -ENODEV;
@@ -254,7 +262,8 @@ static int ds1621_probe(struct i2c_client *client,
254 ds1621_init_client(client); 262 ds1621_init_client(client);
255 263
256 /* Register sysfs hooks */ 264 /* Register sysfs hooks */
257 if ((err = sysfs_create_group(&client->dev.kobj, &ds1621_group))) 265 err = sysfs_create_group(&client->dev.kobj, &ds1621_group);
266 if (err)
258 goto exit_free; 267 goto exit_free;
259 268
260 data->hwmon_dev = hwmon_device_register(&client->dev); 269 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -265,11 +274,11 @@ static int ds1621_probe(struct i2c_client *client,
265 274
266 return 0; 275 return 0;
267 276
268 exit_remove_files: 277 exit_remove_files:
269 sysfs_remove_group(&client->dev.kobj, &ds1621_group); 278 sysfs_remove_group(&client->dev.kobj, &ds1621_group);
270 exit_free: 279 exit_free:
271 kfree(data); 280 kfree(data);
272 exit: 281 exit:
273 return err; 282 return err;
274} 283}
275 284