diff options
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r-- | drivers/hwmon/lm75.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 5be164ed278e..9a3ebdf583f4 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -23,17 +23,17 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/jiffies.h> | 24 | #include <linux/jiffies.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/i2c-sensor.h> | 26 | #include <linux/hwmon.h> |
27 | #include <linux/err.h> | ||
27 | #include "lm75.h" | 28 | #include "lm75.h" |
28 | 29 | ||
29 | 30 | ||
30 | /* Addresses to scan */ | 31 | /* Addresses to scan */ |
31 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 32 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
32 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | 33 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
33 | static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; | ||
34 | 34 | ||
35 | /* Insmod parameters */ | 35 | /* Insmod parameters */ |
36 | SENSORS_INSMOD_1(lm75); | 36 | I2C_CLIENT_INSMOD_1(lm75); |
37 | 37 | ||
38 | /* Many LM75 constants specified below */ | 38 | /* Many LM75 constants specified below */ |
39 | 39 | ||
@@ -46,6 +46,7 @@ SENSORS_INSMOD_1(lm75); | |||
46 | /* Each client has this additional data */ | 46 | /* Each client has this additional data */ |
47 | struct lm75_data { | 47 | struct lm75_data { |
48 | struct i2c_client client; | 48 | struct i2c_client client; |
49 | struct class_device *class_dev; | ||
49 | struct semaphore update_lock; | 50 | struct semaphore update_lock; |
50 | char valid; /* !=0 if following fields are valid */ | 51 | char valid; /* !=0 if following fields are valid */ |
51 | unsigned long last_updated; /* In jiffies */ | 52 | unsigned long last_updated; /* In jiffies */ |
@@ -107,10 +108,10 @@ static int lm75_attach_adapter(struct i2c_adapter *adapter) | |||
107 | { | 108 | { |
108 | if (!(adapter->class & I2C_CLASS_HWMON)) | 109 | if (!(adapter->class & I2C_CLASS_HWMON)) |
109 | return 0; | 110 | return 0; |
110 | return i2c_detect(adapter, &addr_data, lm75_detect); | 111 | return i2c_probe(adapter, &addr_data, lm75_detect); |
111 | } | 112 | } |
112 | 113 | ||
113 | /* This function is called by i2c_detect */ | 114 | /* This function is called by i2c_probe */ |
114 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | 115 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) |
115 | { | 116 | { |
116 | int i; | 117 | int i; |
@@ -119,16 +120,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
119 | int err = 0; | 120 | int err = 0; |
120 | const char *name = ""; | 121 | const char *name = ""; |
121 | 122 | ||
122 | /* Make sure we aren't probing the ISA bus!! This is just a safety check | ||
123 | at this moment; i2c_detect really won't call us. */ | ||
124 | #ifdef DEBUG | ||
125 | if (i2c_is_isa_adapter(adapter)) { | ||
126 | dev_dbg(&adapter->dev, | ||
127 | "lm75_detect called for an ISA bus adapter?!?\n"); | ||
128 | goto exit; | ||
129 | } | ||
130 | #endif | ||
131 | |||
132 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 123 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
133 | I2C_FUNC_SMBUS_WORD_DATA)) | 124 | I2C_FUNC_SMBUS_WORD_DATA)) |
134 | goto exit; | 125 | goto exit; |
@@ -208,12 +199,20 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
208 | lm75_init_client(new_client); | 199 | lm75_init_client(new_client); |
209 | 200 | ||
210 | /* Register sysfs hooks */ | 201 | /* Register sysfs hooks */ |
202 | data->class_dev = hwmon_device_register(&new_client->dev); | ||
203 | if (IS_ERR(data->class_dev)) { | ||
204 | err = PTR_ERR(data->class_dev); | ||
205 | goto exit_detach; | ||
206 | } | ||
207 | |||
211 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 208 | device_create_file(&new_client->dev, &dev_attr_temp1_max); |
212 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 209 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); |
213 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 210 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
214 | 211 | ||
215 | return 0; | 212 | return 0; |
216 | 213 | ||
214 | exit_detach: | ||
215 | i2c_detach_client(new_client); | ||
217 | exit_free: | 216 | exit_free: |
218 | kfree(data); | 217 | kfree(data); |
219 | exit: | 218 | exit: |
@@ -222,8 +221,10 @@ exit: | |||
222 | 221 | ||
223 | static int lm75_detach_client(struct i2c_client *client) | 222 | static int lm75_detach_client(struct i2c_client *client) |
224 | { | 223 | { |
224 | struct lm75_data *data = i2c_get_clientdata(client); | ||
225 | hwmon_device_unregister(data->class_dev); | ||
225 | i2c_detach_client(client); | 226 | i2c_detach_client(client); |
226 | kfree(i2c_get_clientdata(client)); | 227 | kfree(data); |
227 | return 0; | 228 | return 0; |
228 | } | 229 | } |
229 | 230 | ||
@@ -251,8 +252,12 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) | |||
251 | 252 | ||
252 | static void lm75_init_client(struct i2c_client *client) | 253 | static void lm75_init_client(struct i2c_client *client) |
253 | { | 254 | { |
254 | /* Initialize the LM75 chip */ | 255 | int reg; |
255 | lm75_write_value(client, LM75_REG_CONF, 0); | 256 | |
257 | /* Enable if in shutdown mode */ | ||
258 | reg = lm75_read_value(client, LM75_REG_CONF); | ||
259 | if (reg >= 0 && (reg & 0x01)) | ||
260 | lm75_write_value(client, LM75_REG_CONF, reg & 0xfe); | ||
256 | } | 261 | } |
257 | 262 | ||
258 | static struct lm75_data *lm75_update_device(struct device *dev) | 263 | static struct lm75_data *lm75_update_device(struct device *dev) |