diff --git a/kernel/chips/lm78.c b/kernel/chips/lm78.c index 98c60afa..e7196f75 100644 --- a/kernel/chips/lm78.c +++ b/kernel/chips/lm78.c @@ -294,12 +294,13 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) int err=0; const char *type_name = ""; const char *client_name = ""; + int is_isa = i2c_is_isa_adapter(adapter); if (kind < 0) { /* We need address registration for the I2C bus too. That is not yet implemented. */ - if (i2c_is_isa_adapter(adapter)) { + if (is_isa) { #define REALLY_SLOW_IO /* We need the timeouts for at least some LM78-like chips. But only @@ -329,16 +330,15 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) client structure, even though we cannot fill it completely yet. But it allows us to access lm78_{read,write}_value. */ - if (! (new_client = kmalloc((i2c_is_isa_adapter(adapter)? - sizeof(struct isa_client): + if (! (new_client = kmalloc((is_isa?sizeof(struct isa_client): sizeof(struct i2c_client)) + - sizeof(struct lm78_data), + sizeof(struct lm78_data), GFP_KERNEL))) { err = -ENOMEM; goto ERROR0; } - if (i2c_is_isa_adapter(adapter)) { + if (is_isa) { data = (struct lm78_data *) (((struct isa_client *) new_client) + 1); new_client->addr = 0; ((struct isa_client *) new_client)->isa_addr = address; @@ -356,32 +356,37 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind) if (kind < 0) { if (lm78_read_value(new_client,LM78_REG_CONFIG) & 0x80) goto ERROR1; - if (!i2c_is_isa_adapter(adapter) && - (lm78_read_value(new_client,LM78_REG_I2C_ADDR) != address)) + if (!is_isa && (lm78_read_value(new_client,LM78_REG_I2C_ADDR) != address)) goto ERROR1; } /* Determine the chip type. */ if (kind <= 0) { i = lm78_read_value(new_client,LM78_REG_CHIPID); - if (i == 0x00) { + if (i == 0x00) kind = lm78; - type_name = "lm78"; - client_name = "LM78 chip"; - } else if (i == 0x40) { + else if (i == 0x40) kind = lm78j; - type_name = "lm78-j"; - client_name = "LM78-J chip"; - } else if ((i & 0xfe) == 0xc0) { + else if ((i & 0xfe) == 0xc0) kind = lm79; - type_name = "lm79"; - client_name = "LM79 chip"; - } else + else goto ERROR1; } + if (kind == lm78) { + type_name = "lm78"; + client_name = "LM78 chip"; + } else if (kind == lm78j) { + type_name = "lm78-j"; + client_name = "LM78-J chip"; + } else if (kind == lm79) { + type_name = "lm79"; + client_name = "LM79 chip"; + } else + goto ERROR1; + /* Reserve the ISA region */ - if i2c_is_isa_adapter(adapter) + if (is_isa) request_region(address, LM78_EXTENT, type_name); /* Fill in the remaining client fields and put it into the global list */ @@ -429,7 +434,7 @@ ERROR3: if (new_client == lm78_list[i]) lm78_list[i] = NULL; ERROR2: - if i2c_is_isa_adapter(adapter) + if (is_isa) release_region(address,LM78_EXTENT); ERROR1: kfree(new_client); diff --git a/kernel/sensors.c b/kernel/sensors.c index 6ebdb424..326ee2b1 100644 --- a/kernel/sensors.c +++ b/kernel/sensors.c @@ -588,12 +588,11 @@ int sensors_detect(struct i2c_adapter *adapter, { int addr,i,found,j,err; struct sensors_force_data *this_force; - int adapter_id = i2c_is_isa_adapter(adapter)?SENSORS_ISA_BUS: - i2c_adapter_id(adapter); + int is_isa = i2c_is_isa_adapter(adapter); + int adapter_id = is_isa?SENSORS_ISA_BUS:i2c_adapter_id(adapter); -printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],address_data->ignore[1],address_data->ignore[2],address_data->ignore[3],address_data->ignore[4],address_data->ignore[5]); for (addr = 0x00; - addr <= (i2c_is_isa_adapter(adapter)?0xffff:0x7f); + addr <= (is_isa?0xffff:0x7f); addr ++) { /* If it is in one of the force entries, we don't do any detection @@ -604,9 +603,9 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a i++) { for (j = 0; !found && (this_force->force[j] != SENSORS_I2C_END) ; - i += 2) { + j += 2) { if (((adapter_id == this_force->force[j]) || - (this_force->force[j] == SENSORS_ANY_I2C_BUS)) && + ((this_force->force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) && (addr == this_force->force[j+1])) { if ((err = found_proc(adapter,addr,this_force->kind))) return err; @@ -623,7 +622,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a !found && (address_data->ignore[i] != SENSORS_I2C_END); i += 2) { if (((adapter_id == address_data->ignore[i]) || - (address_data->ignore[i] == SENSORS_ANY_I2C_BUS)) && + ((address_data->ignore[i] == SENSORS_ANY_I2C_BUS) && !is_isa)) && (addr == address_data->ignore[i+1])) { found = 1; } @@ -632,7 +631,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a !found && (address_data->ignore_range[i] != SENSORS_I2C_END); i += 3) { if (((adapter_id == address_data->ignore_range[i]) || - (address_data->ignore_range[i] == SENSORS_ANY_I2C_BUS)) && + ((address_data->ignore_range[i]==SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr >= address_data->ignore_range[i+1]) && (addr <= address_data->ignore_range[i+2])) found = 1; @@ -642,7 +641,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a /* Now, we will do a detection, but only if it is in the normal or probe entries */ - if (i2c_is_isa_adapter(adapter)) { + if (is_isa) { for (i = 0; !found && (address_data->normal_isa[i] != SENSORS_ISA_END); i += 1) { @@ -680,7 +679,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a !found && (address_data->probe[i] != SENSORS_I2C_END); i += 2) { if (((adapter_id == address_data->probe[i]) || - (address_data->probe[i] == SENSORS_ANY_I2C_BUS)) && + ((address_data->probe[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr == address_data->probe[i+1])) { found = 1; } @@ -688,7 +687,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a !found && (address_data->probe_range[i] != SENSORS_I2C_END); i += 3) { if (((adapter_id == address_data->probe_range[i]) || - (address_data->probe_range[i] == SENSORS_ANY_I2C_BUS)) && + ((address_data->probe_range[i] == SENSORS_ANY_I2C_BUS) & !is_isa)) && (addr >= address_data->probe_range[i+1]) && (addr <= address_data->probe_range[i+2])) found = 1; @@ -699,8 +698,7 @@ printk("IGNORE: %04hx %04hx %04hx %04hx %04hx %04hx\n",address_data->ignore[0],a /* OK, so we really should examine this address. First check whether there is some client here at all! */ - if (i2c_is_isa_adapter(adapter) || - (smbus_read_byte(adapter,addr) >= 0)) + if (is_isa || (smbus_read_byte(adapter,addr) >= 0)) if ((err = found_proc(adapter,addr,-1))) return err; }