aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47b397.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/smsc47b397.c')
-rw-r--r--drivers/hwmon/smsc47b397.c48
1 files changed, 12 insertions, 36 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 0f965921b8ed..dddc94a7649b 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -32,25 +32,13 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-isa.h> 34#include <linux/i2c-isa.h>
35#include <linux/i2c-sensor.h>
36#include <linux/hwmon.h> 35#include <linux/hwmon.h>
37#include <linux/err.h> 36#include <linux/err.h>
38#include <linux/init.h> 37#include <linux/init.h>
39#include <asm/io.h> 38#include <asm/io.h>
40 39
41static unsigned short normal_i2c[] = { I2C_CLIENT_END };
42/* Address is autodetected, there is no default value */ 40/* Address is autodetected, there is no default value */
43static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; 41static unsigned short address;
44static struct i2c_force_data forces[] = {{NULL}};
45
46enum chips { any_chip, smsc47b397 };
47static struct i2c_address_data addr_data = {
48 .normal_i2c = normal_i2c,
49 .normal_isa = normal_isa,
50 .probe = normal_i2c, /* cheat */
51 .ignore = normal_i2c, /* cheat */
52 .forces = forces,
53};
54 42
55/* Super-I/0 registers and commands */ 43/* Super-I/0 registers and commands */
56 44
@@ -219,15 +207,6 @@ sysfs_fan(4);
219#define device_create_file_fan(client, num) \ 207#define device_create_file_fan(client, num) \
220 device_create_file(&client->dev, &dev_attr_fan##num##_input) 208 device_create_file(&client->dev, &dev_attr_fan##num##_input)
221 209
222static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind);
223
224static int smsc47b397_attach_adapter(struct i2c_adapter *adapter)
225{
226 if (!(adapter->class & I2C_CLASS_HWMON))
227 return 0;
228 return i2c_detect(adapter, &addr_data, smsc47b397_detect);
229}
230
231static int smsc47b397_detach_client(struct i2c_client *client) 210static int smsc47b397_detach_client(struct i2c_client *client)
232{ 211{
233 struct smsc47b397_data *data = i2c_get_clientdata(client); 212 struct smsc47b397_data *data = i2c_get_clientdata(client);
@@ -247,27 +226,24 @@ static int smsc47b397_detach_client(struct i2c_client *client)
247 return 0; 226 return 0;
248} 227}
249 228
229static int smsc47b397_detect(struct i2c_adapter *adapter);
230
250static struct i2c_driver smsc47b397_driver = { 231static struct i2c_driver smsc47b397_driver = {
251 .owner = THIS_MODULE, 232 .owner = THIS_MODULE,
252 .name = "smsc47b397", 233 .name = "smsc47b397",
253 .id = I2C_DRIVERID_SMSC47B397, 234 .attach_adapter = smsc47b397_detect,
254 .flags = I2C_DF_NOTIFY,
255 .attach_adapter = smsc47b397_attach_adapter,
256 .detach_client = smsc47b397_detach_client, 235 .detach_client = smsc47b397_detach_client,
257}; 236};
258 237
259static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) 238static int smsc47b397_detect(struct i2c_adapter *adapter)
260{ 239{
261 struct i2c_client *new_client; 240 struct i2c_client *new_client;
262 struct smsc47b397_data *data; 241 struct smsc47b397_data *data;
263 int err = 0; 242 int err = 0;
264 243
265 if (!i2c_is_isa_adapter(adapter)) { 244 if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) {
266 return 0; 245 dev_err(&adapter->dev, "Region 0x%x already in use!\n",
267 } 246 address);
268
269 if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) {
270 dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr);
271 return -EBUSY; 247 return -EBUSY;
272 } 248 }
273 249
@@ -279,7 +255,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
279 255
280 new_client = &data->client; 256 new_client = &data->client;
281 i2c_set_clientdata(new_client, data); 257 i2c_set_clientdata(new_client, data);
282 new_client->addr = addr; 258 new_client->addr = address;
283 init_MUTEX(&data->lock); 259 init_MUTEX(&data->lock);
284 new_client->adapter = adapter; 260 new_client->adapter = adapter;
285 new_client->driver = &smsc47b397_driver; 261 new_client->driver = &smsc47b397_driver;
@@ -315,11 +291,11 @@ error_detach:
315error_free: 291error_free:
316 kfree(data); 292 kfree(data);
317error_release: 293error_release:
318 release_region(addr, SMSC_EXTENT); 294 release_region(address, SMSC_EXTENT);
319 return err; 295 return err;
320} 296}
321 297
322static int __init smsc47b397_find(unsigned int *addr) 298static int __init smsc47b397_find(unsigned short *addr)
323{ 299{
324 u8 id, rev; 300 u8 id, rev;
325 301
@@ -348,7 +324,7 @@ static int __init smsc47b397_init(void)
348{ 324{
349 int ret; 325 int ret;
350 326
351 if ((ret = smsc47b397_find(normal_isa))) 327 if ((ret = smsc47b397_find(&address)))
352 return ret; 328 return ret;
353 329
354 return i2c_isa_add_driver(&smsc47b397_driver); 330 return i2c_isa_add_driver(&smsc47b397_driver);