Skip to content

Commit e91aef2

Browse files
Frans MeulenbroeksGuenter Roeck
authored andcommitted
hwmon: (ad7418) fix checkpatch issues
fixed: WARNING: simple_strtol is obsolete, use kstrtol instead + long temp = simple_strtol(buf, NULL, 10); ERROR: do not use assignment in if condition + if (!(data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL))) { ERROR: do not use assignment in if condition + if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs))) Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
1 parent 5996542 commit e91aef2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/hwmon/ad7418.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
167167
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
168168
struct i2c_client *client = to_i2c_client(dev);
169169
struct ad7418_data *data = i2c_get_clientdata(client);
170-
long temp = simple_strtol(buf, NULL, 10);
170+
long temp;
171+
int ret = kstrtol(buf, 10, &temp);
172+
173+
if (ret < 0)
174+
return ret;
171175

172176
mutex_lock(&data->lock);
173177
data->temp[attr->index] = LM75_TEMP_TO_REG(temp);
@@ -228,7 +232,8 @@ static int ad7418_probe(struct i2c_client *client,
228232
goto exit;
229233
}
230234

231-
if (!(data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL))) {
235+
data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL);
236+
if (!data) {
232237
err = -ENOMEM;
233238
goto exit;
234239
}
@@ -261,7 +266,8 @@ static int ad7418_probe(struct i2c_client *client,
261266
ad7418_init_client(client);
262267

263268
/* Register sysfs hooks */
264-
if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs)))
269+
err = sysfs_create_group(&client->dev.kobj, &data->attrs);
270+
if (err)
265271
goto exit_free;
266272

267273
data->hwmon_dev = hwmon_device_register(&client->dev);

0 commit comments

Comments
 (0)