diff options
Diffstat (limited to 'drivers/hwmon/gl518sm.c')
-rw-r--r-- | drivers/hwmon/gl518sm.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index bb58d9866a37..842252eccdaa 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c | |||
@@ -30,10 +30,6 @@ | |||
30 | * We did not keep that part of the original driver in the Linux 2.6 | 30 | * We did not keep that part of the original driver in the Linux 2.6 |
31 | * version, since it was making the driver significantly more complex | 31 | * version, since it was making the driver significantly more complex |
32 | * with no real benefit. | 32 | * with no real benefit. |
33 | * | ||
34 | * History: | ||
35 | * 2004-01-28 Original port. (Hong-Gunn Chew) | ||
36 | * 2004-01-31 Code review and approval. (Jean Delvare) | ||
37 | */ | 33 | */ |
38 | 34 | ||
39 | #include <linux/module.h> | 35 | #include <linux/module.h> |
@@ -129,7 +125,6 @@ struct gl518_data { | |||
129 | u8 voltage_in[4]; /* Register values; [0] = VDD */ | 125 | u8 voltage_in[4]; /* Register values; [0] = VDD */ |
130 | u8 voltage_min[4]; /* Register values; [0] = VDD */ | 126 | u8 voltage_min[4]; /* Register values; [0] = VDD */ |
131 | u8 voltage_max[4]; /* Register values; [0] = VDD */ | 127 | u8 voltage_max[4]; /* Register values; [0] = VDD */ |
132 | u8 iter_voltage_in[4]; /* Register values; [0] = VDD */ | ||
133 | u8 fan_in[2]; | 128 | u8 fan_in[2]; |
134 | u8 fan_min[2]; | 129 | u8 fan_min[2]; |
135 | u8 fan_div[2]; /* Register encoding, shifted right */ | 130 | u8 fan_div[2]; /* Register encoding, shifted right */ |
@@ -138,7 +133,7 @@ struct gl518_data { | |||
138 | u8 temp_max; /* Register values */ | 133 | u8 temp_max; /* Register values */ |
139 | u8 temp_hyst; /* Register values */ | 134 | u8 temp_hyst; /* Register values */ |
140 | u8 alarms; /* Register value */ | 135 | u8 alarms; /* Register value */ |
141 | u8 alarm_mask; /* Register value */ | 136 | u8 alarm_mask; |
142 | u8 beep_mask; /* Register value */ | 137 | u8 beep_mask; /* Register value */ |
143 | u8 beep_enable; /* Boolean */ | 138 | u8 beep_enable; /* Boolean */ |
144 | }; | 139 | }; |
@@ -156,7 +151,6 @@ static struct i2c_driver gl518_driver = { | |||
156 | .driver = { | 151 | .driver = { |
157 | .name = "gl518sm", | 152 | .name = "gl518sm", |
158 | }, | 153 | }, |
159 | .id = I2C_DRIVERID_GL518, | ||
160 | .attach_adapter = gl518_attach_adapter, | 154 | .attach_adapter = gl518_attach_adapter, |
161 | .detach_client = gl518_detach_client, | 155 | .detach_client = gl518_detach_client, |
162 | }; | 156 | }; |
@@ -391,7 +385,7 @@ static int gl518_attach_adapter(struct i2c_adapter *adapter) | |||
391 | static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | 385 | static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) |
392 | { | 386 | { |
393 | int i; | 387 | int i; |
394 | struct i2c_client *new_client; | 388 | struct i2c_client *client; |
395 | struct gl518_data *data; | 389 | struct gl518_data *data; |
396 | int err = 0; | 390 | int err = 0; |
397 | 391 | ||
@@ -408,25 +402,24 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
408 | goto exit; | 402 | goto exit; |
409 | } | 403 | } |
410 | 404 | ||
411 | new_client = &data->client; | 405 | client = &data->client; |
412 | i2c_set_clientdata(new_client, data); | 406 | i2c_set_clientdata(client, data); |
413 | 407 | ||
414 | new_client->addr = address; | 408 | client->addr = address; |
415 | new_client->adapter = adapter; | 409 | client->adapter = adapter; |
416 | new_client->driver = &gl518_driver; | 410 | client->driver = &gl518_driver; |
417 | new_client->flags = 0; | ||
418 | 411 | ||
419 | /* Now, we do the remaining detection. */ | 412 | /* Now, we do the remaining detection. */ |
420 | 413 | ||
421 | if (kind < 0) { | 414 | if (kind < 0) { |
422 | if ((gl518_read_value(new_client, GL518_REG_CHIP_ID) != 0x80) | 415 | if ((gl518_read_value(client, GL518_REG_CHIP_ID) != 0x80) |
423 | || (gl518_read_value(new_client, GL518_REG_CONF) & 0x80)) | 416 | || (gl518_read_value(client, GL518_REG_CONF) & 0x80)) |
424 | goto exit_free; | 417 | goto exit_free; |
425 | } | 418 | } |
426 | 419 | ||
427 | /* Determine the chip type. */ | 420 | /* Determine the chip type. */ |
428 | if (kind <= 0) { | 421 | if (kind <= 0) { |
429 | i = gl518_read_value(new_client, GL518_REG_REVISION); | 422 | i = gl518_read_value(client, GL518_REG_REVISION); |
430 | if (i == 0x00) { | 423 | if (i == 0x00) { |
431 | kind = gl518sm_r00; | 424 | kind = gl518sm_r00; |
432 | } else if (i == 0x80) { | 425 | } else if (i == 0x80) { |
@@ -442,25 +435,24 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
442 | } | 435 | } |
443 | 436 | ||
444 | /* Fill in the remaining client fields */ | 437 | /* Fill in the remaining client fields */ |
445 | strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE); | 438 | strlcpy(client->name, "gl518sm", I2C_NAME_SIZE); |
446 | data->type = kind; | 439 | data->type = kind; |
447 | data->valid = 0; | ||
448 | mutex_init(&data->update_lock); | 440 | mutex_init(&data->update_lock); |
449 | 441 | ||
450 | /* Tell the I2C layer a new client has arrived */ | 442 | /* Tell the I2C layer a new client has arrived */ |
451 | if ((err = i2c_attach_client(new_client))) | 443 | if ((err = i2c_attach_client(client))) |
452 | goto exit_free; | 444 | goto exit_free; |
453 | 445 | ||
454 | /* Initialize the GL518SM chip */ | 446 | /* Initialize the GL518SM chip */ |
455 | data->alarm_mask = 0xff; | 447 | data->alarm_mask = 0xff; |
456 | data->voltage_in[0]=data->voltage_in[1]=data->voltage_in[2]=0; | 448 | data->voltage_in[0]=data->voltage_in[1]=data->voltage_in[2]=0; |
457 | gl518_init_client((struct i2c_client *) new_client); | 449 | gl518_init_client(client); |
458 | 450 | ||
459 | /* Register sysfs hooks */ | 451 | /* Register sysfs hooks */ |
460 | if ((err = sysfs_create_group(&new_client->dev.kobj, &gl518_group))) | 452 | if ((err = sysfs_create_group(&client->dev.kobj, &gl518_group))) |
461 | goto exit_detach; | 453 | goto exit_detach; |
462 | 454 | ||
463 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 455 | data->hwmon_dev = hwmon_device_register(&client->dev); |
464 | if (IS_ERR(data->hwmon_dev)) { | 456 | if (IS_ERR(data->hwmon_dev)) { |
465 | err = PTR_ERR(data->hwmon_dev); | 457 | err = PTR_ERR(data->hwmon_dev); |
466 | goto exit_remove_files; | 458 | goto exit_remove_files; |
@@ -469,9 +461,9 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind) | |||
469 | return 0; | 461 | return 0; |
470 | 462 | ||
471 | exit_remove_files: | 463 | exit_remove_files: |
472 | sysfs_remove_group(&new_client->dev.kobj, &gl518_group); | 464 | sysfs_remove_group(&client->dev.kobj, &gl518_group); |
473 | exit_detach: | 465 | exit_detach: |
474 | i2c_detach_client(new_client); | 466 | i2c_detach_client(client); |
475 | exit_free: | 467 | exit_free: |
476 | kfree(data); | 468 | kfree(data); |
477 | exit: | 469 | exit: |
@@ -512,9 +504,9 @@ static int gl518_detach_client(struct i2c_client *client) | |||
512 | return 0; | 504 | return 0; |
513 | } | 505 | } |
514 | 506 | ||
515 | /* Registers 0x07 to 0x0c are word-sized, others are byte-sized | 507 | /* Registers 0x07 to 0x0c are word-sized, others are byte-sized |
516 | GL518 uses a high-byte first convention, which is exactly opposite to | 508 | GL518 uses a high-byte first convention, which is exactly opposite to |
517 | the usual practice. */ | 509 | the SMBus standard. */ |
518 | static int gl518_read_value(struct i2c_client *client, u8 reg) | 510 | static int gl518_read_value(struct i2c_client *client, u8 reg) |
519 | { | 511 | { |
520 | if ((reg >= 0x07) && (reg <= 0x0c)) | 512 | if ((reg >= 0x07) && (reg <= 0x0c)) |
@@ -523,9 +515,6 @@ static int gl518_read_value(struct i2c_client *client, u8 reg) | |||
523 | return i2c_smbus_read_byte_data(client, reg); | 515 | return i2c_smbus_read_byte_data(client, reg); |
524 | } | 516 | } |
525 | 517 | ||
526 | /* Registers 0x07 to 0x0c are word-sized, others are byte-sized | ||
527 | GL518 uses a high-byte first convention, which is exactly opposite to | ||
528 | the usual practice. */ | ||
529 | static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value) | 518 | static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value) |
530 | { | 519 | { |
531 | if ((reg >= 0x07) && (reg <= 0x0c)) | 520 | if ((reg >= 0x07) && (reg <= 0x0c)) |