Commit 3371decd authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Christoph Hellwig

[PATCH] i2c: fix up it87.c check_region mess.

parent 5d9ccbf2
...@@ -224,7 +224,6 @@ static inline u8 FAN_TO_REG(long rpm, int div) ...@@ -224,7 +224,6 @@ static inline u8 FAN_TO_REG(long rpm, int div)
allocated. */ allocated. */
struct it87_data { struct it87_data {
struct semaphore lock; struct semaphore lock;
int sysctl_id;
enum chips type; enum chips type;
struct semaphore update_lock; struct semaphore update_lock;
...@@ -533,22 +532,21 @@ static int it87_attach_adapter(struct i2c_adapter *adapter) ...@@ -533,22 +532,21 @@ static int it87_attach_adapter(struct i2c_adapter *adapter)
int it87_detect(struct i2c_adapter *adapter, int address, int kind) int it87_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
int i; int i;
struct i2c_client *new_client; struct i2c_client *new_client = NULL;
struct it87_data *data; struct it87_data *data;
int err = 0; int err = 0;
const char *name = ""; const char *name = "";
const char *client_name = ""; const char *client_name = "";
int is_isa = i2c_is_isa_adapter(adapter); int is_isa = i2c_is_isa_adapter(adapter);
if (!is_isa if (!is_isa &&
&& !i2c_check_functionality(adapter, !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
I2C_FUNC_SMBUS_BYTE_DATA)) goto goto ERROR0;
ERROR0;
if (is_isa) { /* Reserve the ISA region */
if (check_region(address, IT87_EXTENT)) if (is_isa)
if (!request_region(address, IT87_EXTENT, name))
goto ERROR0; goto ERROR0;
}
/* Probe whether there is anything available on this address. Already /* Probe whether there is anything available on this address. Already
done for SMBus clients */ done for SMBus clients */
...@@ -560,11 +558,11 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -560,11 +558,11 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
if we read 'undefined' registers. */ if we read 'undefined' registers. */
i = inb_p(address + 1); i = inb_p(address + 1);
if (inb_p(address + 2) != i) if (inb_p(address + 2) != i)
goto ERROR0; goto ERROR1;
if (inb_p(address + 3) != i) if (inb_p(address + 3) != i)
goto ERROR0; goto ERROR1;
if (inb_p(address + 7) != i) if (inb_p(address + 7) != i)
goto ERROR0; goto ERROR1;
#undef REALLY_SLOW_IO #undef REALLY_SLOW_IO
/* Let's just hope nothing breaks here */ /* Let's just hope nothing breaks here */
...@@ -585,7 +583,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -585,7 +583,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
sizeof(struct it87_data), sizeof(struct it87_data),
GFP_KERNEL))) { GFP_KERNEL))) {
err = -ENOMEM; err = -ENOMEM;
goto ERROR0; goto ERROR1;
} }
data = (struct it87_data *) (new_client + 1); data = (struct it87_data *) (new_client + 1);
...@@ -635,10 +633,6 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -635,10 +633,6 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
goto ERROR1; goto ERROR1;
} }
/* Reserve the ISA region */
if (is_isa)
request_region(address, IT87_EXTENT, name);
/* Fill in the remaining client fields and put it into the global list */ /* Fill in the remaining client fields and put it into the global list */
strncpy(new_client->dev.name, name, DEVICE_NAME_SIZE); strncpy(new_client->dev.name, name, DEVICE_NAME_SIZE);
...@@ -650,7 +644,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -650,7 +644,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
/* Tell the I2C layer a new client has arrived */ /* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client))) if ((err = i2c_attach_client(new_client)))
goto ERROR2; goto ERROR1;
/* register sysfs hooks */ /* register sysfs hooks */
device_create_file(&new_client->dev, &dev_attr_in_input0); device_create_file(&new_client->dev, &dev_attr_in_input0);
...@@ -689,12 +683,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -689,12 +683,12 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
it87_init_client(new_client); it87_init_client(new_client);
return 0; return 0;
ERROR2: ERROR1:
kfree(new_client);
if (is_isa) if (is_isa)
release_region(address, IT87_EXTENT); release_region(address, IT87_EXTENT);
ERROR1: ERROR0:
kfree(new_client);
ERROR0:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment