Loading drivers/hwmon/w83781d.c +53 −78 Original line number Original line Diff line number Diff line Loading @@ -1054,11 +1054,11 @@ static int w83781d_detect(struct i2c_client *client, int kind, w83781d_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) struct i2c_board_info *info) { { int val1 = 0, val2; int val1, val2; struct w83781d_data *isa = w83781d_data_if_isa(); struct w83781d_data *isa = w83781d_data_if_isa(); struct i2c_adapter *adapter = client->adapter; struct i2c_adapter *adapter = client->adapter; int address = client->addr; int address = client->addr; const char *client_name = ""; const char *client_name; enum vendor { winbond, asus } vendid; enum vendor { winbond, asus } vendid; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) Loading @@ -1070,98 +1070,73 @@ w83781d_detect(struct i2c_client *client, int kind, if (isa) if (isa) mutex_lock(&isa->update_lock); mutex_lock(&isa->update_lock); /* The w8378?d may be stuck in some other bank than bank 0. This may if (i2c_smbus_read_byte_data(client, W83781D_REG_CONFIG) & 0x80) { make reading other information impossible. Specify a force=... or dev_dbg(&adapter->dev, force_*=... parameter, and the Winbond will be reset to the right "Detection of w83781d chip failed at step 3\n"); bank. */ if (kind < 0) { if (i2c_smbus_read_byte_data (client, W83781D_REG_CONFIG) & 0x80) { dev_dbg(&adapter->dev, "Detection of w83781d chip " "failed at step 3\n"); goto err_nodev; goto err_nodev; } } val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); /* Check for Winbond or Asus ID if in bank 0 */ /* Check for Winbond or Asus ID if in bank 0 */ if ((!(val1 & 0x07)) && if (!(val1 & 0x07) && (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) ((!(val1 & 0x80) && val2 != 0xa3 && val2 != 0xc3) || || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { ( (val1 & 0x80) && val2 != 0x5c && val2 != 0x12))) { dev_dbg(&adapter->dev, "Detection of w83781d chip " dev_dbg(&adapter->dev, "failed at step 4\n"); "Detection of w83781d chip failed at step 4\n"); goto err_nodev; goto err_nodev; } } /* If Winbond SMBus, check address at 0x48. /* If Winbond SMBus, check address at 0x48. Asus doesn't support, except for as99127f rev.2 */ Asus doesn't support, except for as99127f rev.2 */ if ((!(val1 & 0x80) && (val2 == 0xa3)) || if ((!(val1 & 0x80) && val2 == 0xa3) || ((val1 & 0x80) && (val2 == 0x5c))) { ( (val1 & 0x80) && val2 == 0x5c)) { if (i2c_smbus_read_byte_data if (i2c_smbus_read_byte_data(client, W83781D_REG_I2C_ADDR) (client, W83781D_REG_I2C_ADDR) != address) { != address) { dev_dbg(&adapter->dev, "Detection of w83781d " dev_dbg(&adapter->dev, "chip failed at step 5\n"); "Detection of w83781d chip failed at step 5\n"); goto err_nodev; goto err_nodev; } } } } } /* We have either had a force parameter, or we have already detected the /* Put it now into bank 0 and Vendor ID High Byte */ Winbond. Put it now into bank 0 and Vendor ID High Byte */ i2c_smbus_write_byte_data(client, W83781D_REG_BANK, i2c_smbus_write_byte_data(client, W83781D_REG_BANK, (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) & 0x78) | 0x80); & 0x78) | 0x80); /* Determine the chip type. */ /* Get the vendor ID */ if (kind <= 0) { /* get vendor ID */ val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); if (val2 == 0x5c) if (val2 == 0x5c) vendid = winbond; vendid = winbond; else if (val2 == 0x12) else if (val2 == 0x12) vendid = asus; vendid = asus; else { else { dev_dbg(&adapter->dev, "w83781d chip vendor is " dev_dbg(&adapter->dev, "neither Winbond nor Asus\n"); "w83781d chip vendor is neither Winbond nor Asus\n"); goto err_nodev; goto err_nodev; } } /* Determine the chip type. */ val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) kind = w83781d; client_name = "w83781d"; else if (val1 == 0x30 && vendid == winbond) else if (val1 == 0x30 && vendid == winbond) kind = w83782d; client_name = "w83782d"; else if (val1 == 0x40 && vendid == winbond && address == 0x2d) else if (val1 == 0x40 && vendid == winbond && address == 0x2d) kind = w83783s; client_name = "w83783s"; else if (val1 == 0x31) else if (val1 == 0x31) kind = as99127f; client_name = "as99127f"; else { else if (kind == 0) dev_warn(&adapter->dev, "Ignoring 'force' " "parameter for unknown chip at " "address 0x%02x\n", address); goto err_nodev; goto err_nodev; } if ((kind == w83781d || kind == w83782d) if (val1 <= 0x30 && w83781d_alias_detect(client, val1)) { && w83781d_alias_detect(client, val1)) { dev_dbg(&adapter->dev, "Device at 0x%02x appears to " dev_dbg(&adapter->dev, "Device at 0x%02x appears to " "be the same as ISA device\n", address); "be the same as ISA device\n", address); goto err_nodev; goto err_nodev; } } } if (isa) if (isa) mutex_unlock(&isa->update_lock); mutex_unlock(&isa->update_lock); if (kind == w83781d) { client_name = "w83781d"; } else if (kind == w83782d) { client_name = "w83782d"; } else if (kind == w83783s) { client_name = "w83783s"; } else if (kind == as99127f) { client_name = "as99127f"; } strlcpy(info->type, client_name, I2C_NAME_SIZE); strlcpy(info->type, client_name, I2C_NAME_SIZE); return 0; return 0; Loading Loading
drivers/hwmon/w83781d.c +53 −78 Original line number Original line Diff line number Diff line Loading @@ -1054,11 +1054,11 @@ static int w83781d_detect(struct i2c_client *client, int kind, w83781d_detect(struct i2c_client *client, int kind, struct i2c_board_info *info) struct i2c_board_info *info) { { int val1 = 0, val2; int val1, val2; struct w83781d_data *isa = w83781d_data_if_isa(); struct w83781d_data *isa = w83781d_data_if_isa(); struct i2c_adapter *adapter = client->adapter; struct i2c_adapter *adapter = client->adapter; int address = client->addr; int address = client->addr; const char *client_name = ""; const char *client_name; enum vendor { winbond, asus } vendid; enum vendor { winbond, asus } vendid; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) Loading @@ -1070,98 +1070,73 @@ w83781d_detect(struct i2c_client *client, int kind, if (isa) if (isa) mutex_lock(&isa->update_lock); mutex_lock(&isa->update_lock); /* The w8378?d may be stuck in some other bank than bank 0. This may if (i2c_smbus_read_byte_data(client, W83781D_REG_CONFIG) & 0x80) { make reading other information impossible. Specify a force=... or dev_dbg(&adapter->dev, force_*=... parameter, and the Winbond will be reset to the right "Detection of w83781d chip failed at step 3\n"); bank. */ if (kind < 0) { if (i2c_smbus_read_byte_data (client, W83781D_REG_CONFIG) & 0x80) { dev_dbg(&adapter->dev, "Detection of w83781d chip " "failed at step 3\n"); goto err_nodev; goto err_nodev; } } val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); val1 = i2c_smbus_read_byte_data(client, W83781D_REG_BANK); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); /* Check for Winbond or Asus ID if in bank 0 */ /* Check for Winbond or Asus ID if in bank 0 */ if ((!(val1 & 0x07)) && if (!(val1 & 0x07) && (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) ((!(val1 & 0x80) && val2 != 0xa3 && val2 != 0xc3) || || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { ( (val1 & 0x80) && val2 != 0x5c && val2 != 0x12))) { dev_dbg(&adapter->dev, "Detection of w83781d chip " dev_dbg(&adapter->dev, "failed at step 4\n"); "Detection of w83781d chip failed at step 4\n"); goto err_nodev; goto err_nodev; } } /* If Winbond SMBus, check address at 0x48. /* If Winbond SMBus, check address at 0x48. Asus doesn't support, except for as99127f rev.2 */ Asus doesn't support, except for as99127f rev.2 */ if ((!(val1 & 0x80) && (val2 == 0xa3)) || if ((!(val1 & 0x80) && val2 == 0xa3) || ((val1 & 0x80) && (val2 == 0x5c))) { ( (val1 & 0x80) && val2 == 0x5c)) { if (i2c_smbus_read_byte_data if (i2c_smbus_read_byte_data(client, W83781D_REG_I2C_ADDR) (client, W83781D_REG_I2C_ADDR) != address) { != address) { dev_dbg(&adapter->dev, "Detection of w83781d " dev_dbg(&adapter->dev, "chip failed at step 5\n"); "Detection of w83781d chip failed at step 5\n"); goto err_nodev; goto err_nodev; } } } } } /* We have either had a force parameter, or we have already detected the /* Put it now into bank 0 and Vendor ID High Byte */ Winbond. Put it now into bank 0 and Vendor ID High Byte */ i2c_smbus_write_byte_data(client, W83781D_REG_BANK, i2c_smbus_write_byte_data(client, W83781D_REG_BANK, (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) (i2c_smbus_read_byte_data(client, W83781D_REG_BANK) & 0x78) | 0x80); & 0x78) | 0x80); /* Determine the chip type. */ /* Get the vendor ID */ if (kind <= 0) { /* get vendor ID */ val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); val2 = i2c_smbus_read_byte_data(client, W83781D_REG_CHIPMAN); if (val2 == 0x5c) if (val2 == 0x5c) vendid = winbond; vendid = winbond; else if (val2 == 0x12) else if (val2 == 0x12) vendid = asus; vendid = asus; else { else { dev_dbg(&adapter->dev, "w83781d chip vendor is " dev_dbg(&adapter->dev, "neither Winbond nor Asus\n"); "w83781d chip vendor is neither Winbond nor Asus\n"); goto err_nodev; goto err_nodev; } } /* Determine the chip type. */ val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); val1 = i2c_smbus_read_byte_data(client, W83781D_REG_WCHIPID); if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) if ((val1 == 0x10 || val1 == 0x11) && vendid == winbond) kind = w83781d; client_name = "w83781d"; else if (val1 == 0x30 && vendid == winbond) else if (val1 == 0x30 && vendid == winbond) kind = w83782d; client_name = "w83782d"; else if (val1 == 0x40 && vendid == winbond && address == 0x2d) else if (val1 == 0x40 && vendid == winbond && address == 0x2d) kind = w83783s; client_name = "w83783s"; else if (val1 == 0x31) else if (val1 == 0x31) kind = as99127f; client_name = "as99127f"; else { else if (kind == 0) dev_warn(&adapter->dev, "Ignoring 'force' " "parameter for unknown chip at " "address 0x%02x\n", address); goto err_nodev; goto err_nodev; } if ((kind == w83781d || kind == w83782d) if (val1 <= 0x30 && w83781d_alias_detect(client, val1)) { && w83781d_alias_detect(client, val1)) { dev_dbg(&adapter->dev, "Device at 0x%02x appears to " dev_dbg(&adapter->dev, "Device at 0x%02x appears to " "be the same as ISA device\n", address); "be the same as ISA device\n", address); goto err_nodev; goto err_nodev; } } } if (isa) if (isa) mutex_unlock(&isa->update_lock); mutex_unlock(&isa->update_lock); if (kind == w83781d) { client_name = "w83781d"; } else if (kind == w83782d) { client_name = "w83782d"; } else if (kind == w83783s) { client_name = "w83783s"; } else if (kind == as99127f) { client_name = "as99127f"; } strlcpy(info->type, client_name, I2C_NAME_SIZE); strlcpy(info->type, client_name, I2C_NAME_SIZE); return 0; return 0; Loading