mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
hwmon: (nct7904) Rely on subsystem locking
Attribute access is now serialized in the hardware monitoring core, so locking in the driver code is no longer necessary. Drop it. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
e1c4d5db9a
commit
9ad270bf4d
|
|
@ -21,7 +21,6 @@
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
#include <linux/mutex.h>
|
|
||||||
#include <linux/hwmon.h>
|
#include <linux/hwmon.h>
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
|
|
||||||
|
|
@ -128,7 +127,6 @@ static const unsigned short normal_i2c[] = {
|
||||||
struct nct7904_data {
|
struct nct7904_data {
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
struct watchdog_device wdt;
|
struct watchdog_device wdt;
|
||||||
struct mutex bank_lock;
|
|
||||||
int bank_sel;
|
int bank_sel;
|
||||||
u32 fanin_mask;
|
u32 fanin_mask;
|
||||||
u32 vsen_mask;
|
u32 vsen_mask;
|
||||||
|
|
@ -142,24 +140,19 @@ struct nct7904_data {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Access functions */
|
/* Access functions */
|
||||||
static int nct7904_bank_lock(struct nct7904_data *data, unsigned int bank)
|
static int nct7904_bank_select(struct nct7904_data *data, unsigned int bank)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&data->bank_lock);
|
|
||||||
if (data->bank_sel == bank)
|
if (data->bank_sel == bank)
|
||||||
return 0;
|
return 0;
|
||||||
ret = i2c_smbus_write_byte_data(data->client, BANK_SEL_REG, bank);
|
ret = i2c_smbus_write_byte_data(data->client, BANK_SEL_REG, bank);
|
||||||
if (ret == 0)
|
if (ret < 0) {
|
||||||
data->bank_sel = bank;
|
|
||||||
else
|
|
||||||
data->bank_sel = -1;
|
data->bank_sel = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
data->bank_sel = bank;
|
||||||
static inline void nct7904_bank_release(struct nct7904_data *data)
|
return 0;
|
||||||
{
|
|
||||||
mutex_unlock(&data->bank_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read 1-byte register. Returns unsigned reg or -ERRNO on error. */
|
/* Read 1-byte register. Returns unsigned reg or -ERRNO on error. */
|
||||||
|
|
@ -169,12 +162,10 @@ static int nct7904_read_reg(struct nct7904_data *data,
|
||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nct7904_bank_lock(data, bank);
|
ret = nct7904_bank_select(data, bank);
|
||||||
if (ret == 0)
|
if (ret < 0)
|
||||||
ret = i2c_smbus_read_byte_data(client, reg);
|
return ret;
|
||||||
|
return i2c_smbus_read_byte_data(client, reg);
|
||||||
nct7904_bank_release(data);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -187,19 +178,16 @@ static int nct7904_read_reg16(struct nct7904_data *data,
|
||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
int ret, hi;
|
int ret, hi;
|
||||||
|
|
||||||
ret = nct7904_bank_lock(data, bank);
|
ret = nct7904_bank_select(data, bank);
|
||||||
if (ret == 0) {
|
if (ret < 0)
|
||||||
ret = i2c_smbus_read_byte_data(client, reg);
|
return ret;
|
||||||
if (ret >= 0) {
|
hi = i2c_smbus_read_byte_data(client, reg);
|
||||||
hi = ret;
|
if (hi < 0)
|
||||||
ret = i2c_smbus_read_byte_data(client, reg + 1);
|
return hi;
|
||||||
if (ret >= 0)
|
ret = i2c_smbus_read_byte_data(client, reg + 1);
|
||||||
ret |= hi << 8;
|
if (ret < 0)
|
||||||
}
|
return ret;
|
||||||
}
|
return ret | (hi << 8);
|
||||||
|
|
||||||
nct7904_bank_release(data);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write 1-byte register. Returns 0 or -ERRNO on error. */
|
/* Write 1-byte register. Returns 0 or -ERRNO on error. */
|
||||||
|
|
@ -209,12 +197,10 @@ static int nct7904_write_reg(struct nct7904_data *data,
|
||||||
struct i2c_client *client = data->client;
|
struct i2c_client *client = data->client;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nct7904_bank_lock(data, bank);
|
ret = nct7904_bank_select(data, bank);
|
||||||
if (ret == 0)
|
if (ret < 0)
|
||||||
ret = i2c_smbus_write_byte_data(client, reg, val);
|
return ret;
|
||||||
|
return i2c_smbus_write_byte_data(client, reg, val);
|
||||||
nct7904_bank_release(data);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
|
static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
|
||||||
|
|
@ -1023,7 +1009,6 @@ static int nct7904_probe(struct i2c_client *client)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->client = client;
|
data->client = client;
|
||||||
mutex_init(&data->bank_lock);
|
|
||||||
data->bank_sel = -1;
|
data->bank_sel = -1;
|
||||||
|
|
||||||
/* Setup sensor groups. */
|
/* Setup sensor groups. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user