diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-11-04 17:44:23 -0500 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2008-02-07 20:39:41 -0500 |
commit | f28dc2f78bbcbf07b8a084fcd89cf6b4256f0664 (patch) | |
tree | ac051fe9264ff967cea12f96ac7dd58e52bca409 /drivers | |
parent | e0ae87a49cf3e721313bf8942299f3f140c6963c (diff) |
hwmon: (gl520sm) Various cleanups
* Drop trailing spaces
* Drop unused driver ID
* Drop stray backslashes in macros
* Rename new_client to client
* Drop redundant initializations to 0
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/gl520sm.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index 2d39d8fc2389..4fdfe820294b 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c | |||
@@ -43,9 +43,9 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | |||
43 | /* Insmod parameters */ | 43 | /* Insmod parameters */ |
44 | I2C_CLIENT_INSMOD_1(gl520sm); | 44 | I2C_CLIENT_INSMOD_1(gl520sm); |
45 | 45 | ||
46 | /* Many GL520 constants specified below | 46 | /* Many GL520 constants specified below |
47 | One of the inputs can be configured as either temp or voltage. | 47 | One of the inputs can be configured as either temp or voltage. |
48 | That's why _TEMP2 and _IN4 access the same register | 48 | That's why _TEMP2 and _IN4 access the same register |
49 | */ | 49 | */ |
50 | 50 | ||
51 | /* The GL520 registers */ | 51 | /* The GL520 registers */ |
@@ -114,7 +114,6 @@ static struct i2c_driver gl520_driver = { | |||
114 | .driver = { | 114 | .driver = { |
115 | .name = "gl520sm", | 115 | .name = "gl520sm", |
116 | }, | 116 | }, |
117 | .id = I2C_DRIVERID_GL520, | ||
118 | .attach_adapter = gl520_attach_adapter, | 117 | .attach_adapter = gl520_attach_adapter, |
119 | .detach_client = gl520_detach_client, | 118 | .detach_client = gl520_detach_client, |
120 | }; | 119 | }; |
@@ -194,7 +193,7 @@ sysfs_ro_n(cpu, n, _vid, GL520_REG_VID_INPUT) | |||
194 | #define sysfs_in(n) \ | 193 | #define sysfs_in(n) \ |
195 | sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \ | 194 | sysfs_ro_n(in, n, _input, GL520_REG_IN##n##INPUT) \ |
196 | sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \ | 195 | sysfs_rw_n(in, n, _min, GL520_REG_IN##n##_MIN) \ |
197 | sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX) \ | 196 | sysfs_rw_n(in, n, _max, GL520_REG_IN##n##_MAX) |
198 | 197 | ||
199 | #define sysfs_fan(n) \ | 198 | #define sysfs_fan(n) \ |
200 | sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \ | 199 | sysfs_ro_n(fan, n, _input, GL520_REG_FAN_INPUT) \ |
@@ -202,7 +201,7 @@ sysfs_rw_n(fan, n, _min, GL520_REG_FAN_MIN) \ | |||
202 | sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV) | 201 | sysfs_rw_n(fan, n, _div, GL520_REG_FAN_DIV) |
203 | 202 | ||
204 | #define sysfs_fan_off(n) \ | 203 | #define sysfs_fan_off(n) \ |
205 | sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF) \ | 204 | sysfs_rw_n(fan, n, _off, GL520_REG_FAN_OFF) |
206 | 205 | ||
207 | #define sysfs_temp(n) \ | 206 | #define sysfs_temp(n) \ |
208 | sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \ | 207 | sysfs_ro_n(temp, n, _input, GL520_REG_TEMP##n##_INPUT) \ |
@@ -477,7 +476,7 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat | |||
477 | static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg) | 476 | static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data, const char *buf, size_t count, int n, int reg) |
478 | { | 477 | { |
479 | u8 r = simple_strtoul(buf, NULL, 10); | 478 | u8 r = simple_strtoul(buf, NULL, 10); |
480 | 479 | ||
481 | mutex_lock(&data->update_lock); | 480 | mutex_lock(&data->update_lock); |
482 | r &= data->alarm_mask; | 481 | r &= data->alarm_mask; |
483 | data->beep_mask = r; | 482 | data->beep_mask = r; |
@@ -553,7 +552,7 @@ static int gl520_attach_adapter(struct i2c_adapter *adapter) | |||
553 | 552 | ||
554 | static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | 553 | static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) |
555 | { | 554 | { |
556 | struct i2c_client *new_client; | 555 | struct i2c_client *client; |
557 | struct gl520_data *data; | 556 | struct gl520_data *data; |
558 | int err = 0; | 557 | int err = 0; |
559 | 558 | ||
@@ -570,59 +569,57 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
570 | goto exit; | 569 | goto exit; |
571 | } | 570 | } |
572 | 571 | ||
573 | new_client = &data->client; | 572 | client = &data->client; |
574 | i2c_set_clientdata(new_client, data); | 573 | i2c_set_clientdata(client, data); |
575 | new_client->addr = address; | 574 | client->addr = address; |
576 | new_client->adapter = adapter; | 575 | client->adapter = adapter; |
577 | new_client->driver = &gl520_driver; | 576 | client->driver = &gl520_driver; |
578 | new_client->flags = 0; | ||
579 | 577 | ||
580 | /* Determine the chip type. */ | 578 | /* Determine the chip type. */ |
581 | if (kind < 0) { | 579 | if (kind < 0) { |
582 | if ((gl520_read_value(new_client, GL520_REG_CHIP_ID) != 0x20) || | 580 | if ((gl520_read_value(client, GL520_REG_CHIP_ID) != 0x20) || |
583 | ((gl520_read_value(new_client, GL520_REG_REVISION) & 0x7f) != 0x00) || | 581 | ((gl520_read_value(client, GL520_REG_REVISION) & 0x7f) != 0x00) || |
584 | ((gl520_read_value(new_client, GL520_REG_CONF) & 0x80) != 0x00)) { | 582 | ((gl520_read_value(client, GL520_REG_CONF) & 0x80) != 0x00)) { |
585 | dev_dbg(&new_client->dev, "Unknown chip type, skipping\n"); | 583 | dev_dbg(&client->dev, "Unknown chip type, skipping\n"); |
586 | goto exit_free; | 584 | goto exit_free; |
587 | } | 585 | } |
588 | } | 586 | } |
589 | 587 | ||
590 | /* Fill in the remaining client fields */ | 588 | /* Fill in the remaining client fields */ |
591 | strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE); | 589 | strlcpy(client->name, "gl520sm", I2C_NAME_SIZE); |
592 | data->valid = 0; | ||
593 | mutex_init(&data->update_lock); | 590 | mutex_init(&data->update_lock); |
594 | 591 | ||
595 | /* Tell the I2C layer a new client has arrived */ | 592 | /* Tell the I2C layer a new client has arrived */ |
596 | if ((err = i2c_attach_client(new_client))) | 593 | if ((err = i2c_attach_client(client))) |
597 | goto exit_free; | 594 | goto exit_free; |
598 | 595 | ||
599 | /* Initialize the GL520SM chip */ | 596 | /* Initialize the GL520SM chip */ |
600 | gl520_init_client(new_client); | 597 | gl520_init_client(client); |
601 | 598 | ||
602 | /* Register sysfs hooks */ | 599 | /* Register sysfs hooks */ |
603 | if ((err = sysfs_create_group(&new_client->dev.kobj, &gl520_group))) | 600 | if ((err = sysfs_create_group(&client->dev.kobj, &gl520_group))) |
604 | goto exit_detach; | 601 | goto exit_detach; |
605 | 602 | ||
606 | if (data->two_temps) { | 603 | if (data->two_temps) { |
607 | if ((err = device_create_file(&new_client->dev, | 604 | if ((err = device_create_file(&client->dev, |
608 | &dev_attr_temp2_input)) | 605 | &dev_attr_temp2_input)) |
609 | || (err = device_create_file(&new_client->dev, | 606 | || (err = device_create_file(&client->dev, |
610 | &dev_attr_temp2_max)) | 607 | &dev_attr_temp2_max)) |
611 | || (err = device_create_file(&new_client->dev, | 608 | || (err = device_create_file(&client->dev, |
612 | &dev_attr_temp2_max_hyst))) | 609 | &dev_attr_temp2_max_hyst))) |
613 | goto exit_remove_files; | 610 | goto exit_remove_files; |
614 | } else { | 611 | } else { |
615 | if ((err = device_create_file(&new_client->dev, | 612 | if ((err = device_create_file(&client->dev, |
616 | &dev_attr_in4_input)) | 613 | &dev_attr_in4_input)) |
617 | || (err = device_create_file(&new_client->dev, | 614 | || (err = device_create_file(&client->dev, |
618 | &dev_attr_in4_min)) | 615 | &dev_attr_in4_min)) |
619 | || (err = device_create_file(&new_client->dev, | 616 | || (err = device_create_file(&client->dev, |
620 | &dev_attr_in4_max))) | 617 | &dev_attr_in4_max))) |
621 | goto exit_remove_files; | 618 | goto exit_remove_files; |
622 | } | 619 | } |
623 | 620 | ||
624 | 621 | ||
625 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 622 | data->hwmon_dev = hwmon_device_register(&client->dev); |
626 | if (IS_ERR(data->hwmon_dev)) { | 623 | if (IS_ERR(data->hwmon_dev)) { |
627 | err = PTR_ERR(data->hwmon_dev); | 624 | err = PTR_ERR(data->hwmon_dev); |
628 | goto exit_remove_files; | 625 | goto exit_remove_files; |
@@ -631,10 +628,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind) | |||
631 | return 0; | 628 | return 0; |
632 | 629 | ||
633 | exit_remove_files: | 630 | exit_remove_files: |
634 | sysfs_remove_group(&new_client->dev.kobj, &gl520_group); | 631 | sysfs_remove_group(&client->dev.kobj, &gl520_group); |
635 | sysfs_remove_group(&new_client->dev.kobj, &gl520_group_opt); | 632 | sysfs_remove_group(&client->dev.kobj, &gl520_group_opt); |
636 | exit_detach: | 633 | exit_detach: |
637 | i2c_detach_client(new_client); | 634 | i2c_detach_client(client); |
638 | exit_free: | 635 | exit_free: |
639 | kfree(data); | 636 | kfree(data); |
640 | exit: | 637 | exit: |
@@ -697,7 +694,7 @@ static int gl520_detach_client(struct i2c_client *client) | |||
697 | } | 694 | } |
698 | 695 | ||
699 | 696 | ||
700 | /* Registers 0x07 to 0x0c are word-sized, others are byte-sized | 697 | /* Registers 0x07 to 0x0c are word-sized, others are byte-sized |
701 | GL520 uses a high-byte first convention */ | 698 | GL520 uses a high-byte first convention */ |
702 | static int gl520_read_value(struct i2c_client *client, u8 reg) | 699 | static int gl520_read_value(struct i2c_client *client, u8 reg) |
703 | { | 700 | { |