Commit 19f2c05964dc428ef639fcda1cce7c8c3075c9cc
Committed by
Guenter Roeck
1 parent
91efffe26a
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 44 additions and 35 deletions Side-by-side Diff
drivers/hwmon/ds1621.c
1 | 1 | /* |
2 | - ds1621.c - Part of lm_sensors, Linux kernel modules for hardware | |
3 | - monitoring | |
4 | - Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23 | |
5 | - based on lm75.c by Frodo Looijaard <frodol@dds.nl> | |
6 | - Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with | |
7 | - the help of Jean Delvare <khali@linux-fr.org> | |
2 | + * ds1621.c - Part of lm_sensors, Linux kernel modules for hardware | |
3 | + * monitoring | |
4 | + * Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23 | |
5 | + * based on lm75.c by Frodo Looijaard <frodol@dds.nl> | |
6 | + * Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with | |
7 | + * the help of Jean Delvare <khali@linux-fr.org> | |
8 | + * | |
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 | |
11 | + * the Free Software Foundation; either version 2 of the License, or | |
12 | + * (at your option) any later version. | |
13 | + * | |
14 | + * This program is distributed in the hope that it will be useful, | |
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | + * GNU General Public License for more details. | |
18 | + * | |
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 | |
21 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | + */ | |
8 | 23 | |
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 | |
11 | - the Free Software Foundation; either version 2 of the License, or | |
12 | - (at your option) any later version. | |
13 | - | |
14 | - This program is distributed in the hope that it will be useful, | |
15 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | - GNU General Public License for more details. | |
18 | - | |
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 | |
21 | - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | -*/ | |
23 | - | |
24 | 24 | #include <linux/module.h> |
25 | 25 | #include <linux/init.h> |
26 | 26 | #include <linux/slab.h> |
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | |
68 | 68 | /* Conversions */ |
69 | 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 | 72 | /* Each client has this additional data */ |
73 | 73 | struct ds1621_data { |
74 | 74 | |
... | ... | @@ -93,10 +93,10 @@ |
93 | 93 | new_conf &= ~DS1621_REG_CONFIG_POLARITY; |
94 | 94 | else if (polarity == 1) |
95 | 95 | new_conf |= DS1621_REG_CONFIG_POLARITY; |
96 | - | |
96 | + | |
97 | 97 | if (conf != new_conf) |
98 | 98 | i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf); |
99 | - | |
99 | + | |
100 | 100 | /* start conversion */ |
101 | 101 | i2c_smbus_write_byte(client, DS1621_COM_START); |
102 | 102 | } |
103 | 103 | |
104 | 104 | |
... | ... | @@ -155,10 +155,15 @@ |
155 | 155 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
156 | 156 | struct i2c_client *client = to_i2c_client(dev); |
157 | 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; | |
159 | 160 | |
161 | + err = kstrtol(buf, 10, &val); | |
162 | + if (err) | |
163 | + return err; | |
164 | + | |
160 | 165 | mutex_lock(&data->update_lock); |
161 | - data->temp[attr->index] = val; | |
166 | + data->temp[attr->index] = LM75_TEMP_TO_REG(val); | |
162 | 167 | i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index], |
163 | 168 | data->temp[attr->index]); |
164 | 169 | mutex_unlock(&data->update_lock); |
165 | 170 | |
... | ... | @@ -212,14 +217,17 @@ |
212 | 217 | int conf, temp; |
213 | 218 | int i; |
214 | 219 | |
215 | - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
216 | - | I2C_FUNC_SMBUS_WORD_DATA | |
220 | + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
221 | + | I2C_FUNC_SMBUS_WORD_DATA | |
217 | 222 | | I2C_FUNC_SMBUS_WRITE_BYTE)) |
218 | 223 | return -ENODEV; |
219 | 224 | |
220 | - /* Now, we do the remaining detection. It is lousy. */ | |
221 | - /* The NVB bit should be low if no EEPROM write has been requested | |
222 | - during the latest 10ms, which is highly improbable in our case. */ | |
225 | + /* | |
226 | + * Now, we do the remaining detection. It is lousy. | |
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 | 231 | conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); |
224 | 232 | if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) |
225 | 233 | return -ENODEV; |
... | ... | @@ -254,7 +262,8 @@ |
254 | 262 | ds1621_init_client(client); |
255 | 263 | |
256 | 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 | 267 | goto exit_free; |
259 | 268 | |
260 | 269 | data->hwmon_dev = hwmon_device_register(&client->dev); |
261 | 270 | |
262 | 271 | |
... | ... | @@ -265,11 +274,11 @@ |
265 | 274 | |
266 | 275 | return 0; |
267 | 276 | |
268 | - exit_remove_files: | |
277 | + exit_remove_files: | |
269 | 278 | sysfs_remove_group(&client->dev.kobj, &ds1621_group); |
270 | - exit_free: | |
279 | + exit_free: | |
271 | 280 | kfree(data); |
272 | - exit: | |
281 | + exit: | |
273 | 282 | return err; |
274 | 283 | } |
275 | 284 |