diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:09 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:40 -0400 |
commit | efd2d117aeb5f01cc9c90e56fff29d4a5f535580 (patch) | |
tree | d5ece2d9984eaa3a3520cb7611daf3a7bddc9513 /drivers/hwmon | |
parent | 13ac7a017678d9d7ee4dcc93a10947df0d3b5b12 (diff) |
hwmon: (lm77) Improve code readability
Rename new_client variable, and define new variable for client->dev.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/lm77.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 0fca8613e7d8..3ccc23a0c7f5 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -267,10 +267,9 @@ static const struct attribute_group lm77_group = { | |||
267 | }; | 267 | }; |
268 | 268 | ||
269 | /* Return 0 if detection is successful, -ENODEV otherwise */ | 269 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
270 | static int lm77_detect(struct i2c_client *new_client, | 270 | static int lm77_detect(struct i2c_client *client, struct i2c_board_info *info) |
271 | struct i2c_board_info *info) | ||
272 | { | 271 | { |
273 | struct i2c_adapter *adapter = new_client->adapter; | 272 | struct i2c_adapter *adapter = client->adapter; |
274 | int i, cur, conf, hyst, crit, min, max; | 273 | int i, cur, conf, hyst, crit, min, max; |
275 | 274 | ||
276 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 275 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
@@ -292,18 +291,18 @@ static int lm77_detect(struct i2c_client *new_client, | |||
292 | */ | 291 | */ |
293 | 292 | ||
294 | /* addresses cycling */ | 293 | /* addresses cycling */ |
295 | cur = i2c_smbus_read_word_data(new_client, 0); | 294 | cur = i2c_smbus_read_word_data(client, 0); |
296 | conf = i2c_smbus_read_byte_data(new_client, 1); | 295 | conf = i2c_smbus_read_byte_data(client, 1); |
297 | hyst = i2c_smbus_read_word_data(new_client, 2); | 296 | hyst = i2c_smbus_read_word_data(client, 2); |
298 | crit = i2c_smbus_read_word_data(new_client, 3); | 297 | crit = i2c_smbus_read_word_data(client, 3); |
299 | min = i2c_smbus_read_word_data(new_client, 4); | 298 | min = i2c_smbus_read_word_data(client, 4); |
300 | max = i2c_smbus_read_word_data(new_client, 5); | 299 | max = i2c_smbus_read_word_data(client, 5); |
301 | for (i = 8; i <= 0xff; i += 8) { | 300 | for (i = 8; i <= 0xff; i += 8) { |
302 | if (i2c_smbus_read_byte_data(new_client, i + 1) != conf | 301 | if (i2c_smbus_read_byte_data(client, i + 1) != conf |
303 | || i2c_smbus_read_word_data(new_client, i + 2) != hyst | 302 | || i2c_smbus_read_word_data(client, i + 2) != hyst |
304 | || i2c_smbus_read_word_data(new_client, i + 3) != crit | 303 | || i2c_smbus_read_word_data(client, i + 3) != crit |
305 | || i2c_smbus_read_word_data(new_client, i + 4) != min | 304 | || i2c_smbus_read_word_data(client, i + 4) != min |
306 | || i2c_smbus_read_word_data(new_client, i + 5) != max) | 305 | || i2c_smbus_read_word_data(client, i + 5) != max) |
307 | return -ENODEV; | 306 | return -ENODEV; |
308 | } | 307 | } |
309 | 308 | ||
@@ -320,17 +319,17 @@ static int lm77_detect(struct i2c_client *new_client, | |||
320 | return -ENODEV; | 319 | return -ENODEV; |
321 | 320 | ||
322 | /* 0x06 and 0x07 return the last read value */ | 321 | /* 0x06 and 0x07 return the last read value */ |
323 | cur = i2c_smbus_read_word_data(new_client, 0); | 322 | cur = i2c_smbus_read_word_data(client, 0); |
324 | if (i2c_smbus_read_word_data(new_client, 6) != cur | 323 | if (i2c_smbus_read_word_data(client, 6) != cur |
325 | || i2c_smbus_read_word_data(new_client, 7) != cur) | 324 | || i2c_smbus_read_word_data(client, 7) != cur) |
326 | return -ENODEV; | 325 | return -ENODEV; |
327 | hyst = i2c_smbus_read_word_data(new_client, 2); | 326 | hyst = i2c_smbus_read_word_data(client, 2); |
328 | if (i2c_smbus_read_word_data(new_client, 6) != hyst | 327 | if (i2c_smbus_read_word_data(client, 6) != hyst |
329 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | 328 | || i2c_smbus_read_word_data(client, 7) != hyst) |
330 | return -ENODEV; | 329 | return -ENODEV; |
331 | min = i2c_smbus_read_word_data(new_client, 4); | 330 | min = i2c_smbus_read_word_data(client, 4); |
332 | if (i2c_smbus_read_word_data(new_client, 6) != min | 331 | if (i2c_smbus_read_word_data(client, 6) != min |
333 | || i2c_smbus_read_word_data(new_client, 7) != min) | 332 | || i2c_smbus_read_word_data(client, 7) != min) |
334 | return -ENODEV; | 333 | return -ENODEV; |
335 | 334 | ||
336 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); | 335 | strlcpy(info->type, "lm77", I2C_NAME_SIZE); |
@@ -338,9 +337,9 @@ static int lm77_detect(struct i2c_client *new_client, | |||
338 | return 0; | 337 | return 0; |
339 | } | 338 | } |
340 | 339 | ||
341 | static int lm77_probe(struct i2c_client *new_client, | 340 | static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id) |
342 | const struct i2c_device_id *id) | ||
343 | { | 341 | { |
342 | struct device *dev = &client->dev; | ||
344 | struct lm77_data *data; | 343 | struct lm77_data *data; |
345 | int err; | 344 | int err; |
346 | 345 | ||
@@ -350,19 +349,19 @@ static int lm77_probe(struct i2c_client *new_client, | |||
350 | goto exit; | 349 | goto exit; |
351 | } | 350 | } |
352 | 351 | ||
353 | i2c_set_clientdata(new_client, data); | 352 | i2c_set_clientdata(client, data); |
354 | data->valid = 0; | 353 | data->valid = 0; |
355 | mutex_init(&data->update_lock); | 354 | mutex_init(&data->update_lock); |
356 | 355 | ||
357 | /* Initialize the LM77 chip */ | 356 | /* Initialize the LM77 chip */ |
358 | lm77_init_client(new_client); | 357 | lm77_init_client(client); |
359 | 358 | ||
360 | /* Register sysfs hooks */ | 359 | /* Register sysfs hooks */ |
361 | err = sysfs_create_group(&new_client->dev.kobj, &lm77_group); | 360 | err = sysfs_create_group(&dev->kobj, &lm77_group); |
362 | if (err) | 361 | if (err) |
363 | goto exit_free; | 362 | goto exit_free; |
364 | 363 | ||
365 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 364 | data->hwmon_dev = hwmon_device_register(dev); |
366 | if (IS_ERR(data->hwmon_dev)) { | 365 | if (IS_ERR(data->hwmon_dev)) { |
367 | err = PTR_ERR(data->hwmon_dev); | 366 | err = PTR_ERR(data->hwmon_dev); |
368 | goto exit_remove; | 367 | goto exit_remove; |
@@ -371,7 +370,7 @@ static int lm77_probe(struct i2c_client *new_client, | |||
371 | return 0; | 370 | return 0; |
372 | 371 | ||
373 | exit_remove: | 372 | exit_remove: |
374 | sysfs_remove_group(&new_client->dev.kobj, &lm77_group); | 373 | sysfs_remove_group(&dev->kobj, &lm77_group); |
375 | exit_free: | 374 | exit_free: |
376 | kfree(data); | 375 | kfree(data); |
377 | exit: | 376 | exit: |