aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/sis5595.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/sis5595.c')
-rw-r--r--drivers/hwmon/sis5595.c70
1 files changed, 29 insertions, 41 deletions
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 6bbfc8fb4f13..8610bce08244 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -55,7 +55,9 @@
55#include <linux/ioport.h> 55#include <linux/ioport.h>
56#include <linux/pci.h> 56#include <linux/pci.h>
57#include <linux/i2c.h> 57#include <linux/i2c.h>
58#include <linux/i2c-sensor.h> 58#include <linux/i2c-isa.h>
59#include <linux/hwmon.h>
60#include <linux/err.h>
59#include <linux/init.h> 61#include <linux/init.h>
60#include <linux/jiffies.h> 62#include <linux/jiffies.h>
61#include <asm/io.h> 63#include <asm/io.h>
@@ -68,14 +70,10 @@ module_param(force_addr, ushort, 0);
68MODULE_PARM_DESC(force_addr, 70MODULE_PARM_DESC(force_addr,
69 "Initialize the base address of the sensors"); 71 "Initialize the base address of the sensors");
70 72
71/* Addresses to scan. 73/* Device address
72 Note that we can't determine the ISA address until we have initialized 74 Note that we can't determine the ISA address until we have initialized
73 our module */ 75 our module */
74static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 76static unsigned short address;
75static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
76
77/* Insmod parameters */
78SENSORS_INSMOD_1(sis5595);
79 77
80/* Many SIS5595 constants specified below */ 78/* Many SIS5595 constants specified below */
81 79
@@ -168,6 +166,7 @@ static inline u8 DIV_TO_REG(int val)
168 allocated. */ 166 allocated. */
169struct sis5595_data { 167struct sis5595_data {
170 struct i2c_client client; 168 struct i2c_client client;
169 struct class_device *class_dev;
171 struct semaphore lock; 170 struct semaphore lock;
172 171
173 struct semaphore update_lock; 172 struct semaphore update_lock;
@@ -190,8 +189,7 @@ struct sis5595_data {
190 189
191static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ 190static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
192 191
193static int sis5595_attach_adapter(struct i2c_adapter *adapter); 192static int sis5595_detect(struct i2c_adapter *adapter);
194static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
195static int sis5595_detach_client(struct i2c_client *client); 193static int sis5595_detach_client(struct i2c_client *client);
196 194
197static int sis5595_read_value(struct i2c_client *client, u8 register); 195static int sis5595_read_value(struct i2c_client *client, u8 register);
@@ -202,9 +200,7 @@ static void sis5595_init_client(struct i2c_client *client);
202static struct i2c_driver sis5595_driver = { 200static struct i2c_driver sis5595_driver = {
203 .owner = THIS_MODULE, 201 .owner = THIS_MODULE,
204 .name = "sis5595", 202 .name = "sis5595",
205 .id = I2C_DRIVERID_SIS5595, 203 .attach_adapter = sis5595_detect,
206 .flags = I2C_DF_NOTIFY,
207 .attach_adapter = sis5595_attach_adapter,
208 .detach_client = sis5595_detach_client, 204 .detach_client = sis5595_detach_client,
209}; 205};
210 206
@@ -476,14 +472,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
476static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 472static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
477 473
478/* This is called when the module is loaded */ 474/* This is called when the module is loaded */
479static int sis5595_attach_adapter(struct i2c_adapter *adapter) 475static int sis5595_detect(struct i2c_adapter *adapter)
480{
481 if (!(adapter->class & I2C_CLASS_HWMON))
482 return 0;
483 return i2c_detect(adapter, &addr_data, sis5595_detect);
484}
485
486int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
487{ 476{
488 int err = 0; 477 int err = 0;
489 int i; 478 int i;
@@ -492,10 +481,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
492 char val; 481 char val;
493 u16 a; 482 u16 a;
494 483
495 /* Make sure we are probing the ISA bus!! */
496 if (!i2c_is_isa_adapter(adapter))
497 goto exit;
498
499 if (force_addr) 484 if (force_addr)
500 address = force_addr & ~(SIS5595_EXTENT - 1); 485 address = force_addr & ~(SIS5595_EXTENT - 1);
501 /* Reserve the ISA region */ 486 /* Reserve the ISA region */
@@ -578,6 +563,12 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
578 } 563 }
579 564
580 /* Register sysfs hooks */ 565 /* Register sysfs hooks */
566 data->class_dev = hwmon_device_register(&new_client->dev);
567 if (IS_ERR(data->class_dev)) {
568 err = PTR_ERR(data->class_dev);
569 goto exit_detach;
570 }
571
581 device_create_file(&new_client->dev, &dev_attr_in0_input); 572 device_create_file(&new_client->dev, &dev_attr_in0_input);
582 device_create_file(&new_client->dev, &dev_attr_in0_min); 573 device_create_file(&new_client->dev, &dev_attr_in0_min);
583 device_create_file(&new_client->dev, &dev_attr_in0_max); 574 device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -608,7 +599,9 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
608 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 599 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
609 } 600 }
610 return 0; 601 return 0;
611 602
603exit_detach:
604 i2c_detach_client(new_client);
612exit_free: 605exit_free:
613 kfree(data); 606 kfree(data);
614exit_release: 607exit_release:
@@ -619,18 +612,17 @@ exit:
619 612
620static int sis5595_detach_client(struct i2c_client *client) 613static int sis5595_detach_client(struct i2c_client *client)
621{ 614{
615 struct sis5595_data *data = i2c_get_clientdata(client);
622 int err; 616 int err;
623 617
624 if ((err = i2c_detach_client(client))) { 618 hwmon_device_unregister(data->class_dev);
625 dev_err(&client->dev, 619
626 "Client deregistration failed, client not detached.\n"); 620 if ((err = i2c_detach_client(client)))
627 return err; 621 return err;
628 }
629 622
630 if (i2c_is_isa_client(client)) 623 release_region(client->addr, SIS5595_EXTENT);
631 release_region(client->addr, SIS5595_EXTENT);
632 624
633 kfree(i2c_get_clientdata(client)); 625 kfree(data);
634 626
635 return 0; 627 return 0;
636} 628}
@@ -745,7 +737,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
745{ 737{
746 u16 val; 738 u16 val;
747 int *i; 739 int *i;
748 int addr = 0;
749 740
750 for (i = blacklist; *i != 0; i++) { 741 for (i = blacklist; *i != 0; i++) {
751 struct pci_dev *dev; 742 struct pci_dev *dev;
@@ -761,22 +752,19 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
761 pci_read_config_word(dev, SIS5595_BASE_REG, &val)) 752 pci_read_config_word(dev, SIS5595_BASE_REG, &val))
762 return -ENODEV; 753 return -ENODEV;
763 754
764 addr = val & ~(SIS5595_EXTENT - 1); 755 address = val & ~(SIS5595_EXTENT - 1);
765 if (addr == 0 && force_addr == 0) { 756 if (address == 0 && force_addr == 0) {
766 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 757 dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
767 return -ENODEV; 758 return -ENODEV;
768 } 759 }
769 if (force_addr)
770 addr = force_addr; /* so detect will get called */
771 760
772 if (!addr) { 761 if (!address) {
773 dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); 762 dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
774 return -ENODEV; 763 return -ENODEV;
775 } 764 }
776 normal_isa[0] = addr;
777 765
778 s_bridge = pci_dev_get(dev); 766 s_bridge = pci_dev_get(dev);
779 if (i2c_add_driver(&sis5595_driver)) { 767 if (i2c_isa_add_driver(&sis5595_driver)) {
780 pci_dev_put(s_bridge); 768 pci_dev_put(s_bridge);
781 s_bridge = NULL; 769 s_bridge = NULL;
782 } 770 }
@@ -803,7 +791,7 @@ static void __exit sm_sis5595_exit(void)
803{ 791{
804 pci_unregister_driver(&sis5595_pci_driver); 792 pci_unregister_driver(&sis5595_pci_driver);
805 if (s_bridge != NULL) { 793 if (s_bridge != NULL) {
806 i2c_del_driver(&sis5595_driver); 794 i2c_isa_del_driver(&sis5595_driver);
807 pci_dev_put(s_bridge); 795 pci_dev_put(s_bridge);
808 s_bridge = NULL; 796 s_bridge = NULL;
809 } 797 }