[PATCH] hwmon: w83792d misc cleanups
Cleanup the w83792d driver a bit: * Discard unused lock and irrelevant comments inherited from the w83781d driver. * Simplify w83792d_{read,write}_value functions. * Drop useless address test during detection. * Drop useless bitmasking. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Yuan Mu <Ymu@winbond.com.tw> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
79472132f5
commit
c9152deaa6
1 changed files with 9 additions and 20 deletions
|
@ -269,7 +269,6 @@ DIV_TO_REG(long val)
|
||||||
struct w83792d_data {
|
struct w83792d_data {
|
||||||
struct i2c_client client;
|
struct i2c_client client;
|
||||||
struct class_device *class_dev;
|
struct class_device *class_dev;
|
||||||
struct semaphore lock;
|
|
||||||
enum chips type;
|
enum chips type;
|
||||||
|
|
||||||
struct semaphore update_lock;
|
struct semaphore update_lock;
|
||||||
|
@ -1192,7 +1191,6 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
new_client = &data->client;
|
new_client = &data->client;
|
||||||
i2c_set_clientdata(new_client, data);
|
i2c_set_clientdata(new_client, data);
|
||||||
new_client->addr = address;
|
new_client->addr = address;
|
||||||
init_MUTEX(&data->lock);
|
|
||||||
new_client->adapter = adapter;
|
new_client->adapter = adapter;
|
||||||
new_client->driver = &w83792d_driver;
|
new_client->driver = &w83792d_driver;
|
||||||
new_client->flags = 0;
|
new_client->flags = 0;
|
||||||
|
@ -1243,7 +1241,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
|
||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
}
|
}
|
||||||
val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
|
val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
|
||||||
if (val1 == 0x7a && address >= 0x2c) {
|
if (val1 == 0x7a) {
|
||||||
kind = w83792d;
|
kind = w83792d;
|
||||||
} else {
|
} else {
|
||||||
if (kind == 0)
|
if (kind == 0)
|
||||||
|
@ -1416,26 +1414,17 @@ w83792d_detach_client(struct i2c_client *client)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The SMBus locks itself, usually, but nothing may access the Winbond between
|
/* The SMBus locks itself. The Winbond W83792D chip has a bank register,
|
||||||
bank switches. ISA access must always be locked explicitly!
|
but the driver only accesses registers in bank 0, so we don't have
|
||||||
We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks,
|
to switch banks and lock access between switches. */
|
||||||
would slow down the W83792D access and should not be necessary.
|
static int w83792d_read_value(struct i2c_client *client, u8 reg)
|
||||||
There are some ugly typecasts here, but the good news is - they should
|
|
||||||
nowhere else be necessary! */
|
|
||||||
static int
|
|
||||||
w83792d_read_value(struct i2c_client *client, u8 reg)
|
|
||||||
{
|
{
|
||||||
int res=0;
|
return i2c_smbus_read_byte_data(client, reg);
|
||||||
res = i2c_smbus_read_byte_data(client, reg);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||||
w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
|
|
||||||
{
|
{
|
||||||
i2c_smbus_write_byte_data(client, reg, value);
|
return i2c_smbus_write_byte_data(client, reg, value);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1506,7 +1495,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
|
||||||
pwm_array_tmp[i] = w83792d_read_value(client,
|
pwm_array_tmp[i] = w83792d_read_value(client,
|
||||||
W83792D_REG_PWM[i]);
|
W83792D_REG_PWM[i]);
|
||||||
data->pwm[i] = pwm_array_tmp[i] & 0x0f;
|
data->pwm[i] = pwm_array_tmp[i] & 0x0f;
|
||||||
data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01;
|
data->pwm_mode[i] = pwm_array_tmp[i] >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG);
|
reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG);
|
||||||
|
|
Loading…
Reference in a new issue