Commit b6585ded authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6: (36 commits)
  [PATCH] hwmon: add required idr locking
  [PATCH] I2C: hwmon: Rename register parameters
  [PATCH] I2C: Drop unneeded i2c-dev.h includes
  [PATCH] I2C: i2c-ixp4xx: Add hwmon class
  [PATCH] I2C: i2c-piix4: Add Broadcom HT-1000 support
  [PATCH] I2C: i2c-amd756-s4882: Improve static mutex initialization
  [PATCH] I2C: i2c-ali1535: Drop redundant mutex
  [PATCH] i2c: Cleanup isp1301_omap
  [PATCH] i2c: Fix i2c-ite name initialization
  [PATCH] i2c: Drop the i2c-frodo bus driver
  [PATCH] i2c: Optimize core_lists mutex usage
  [PATCH] w83781d: Don't reset the chip by default
  [PATCH] w83781d: Document the alarm and beep bits
  [PATCH] w83627ehf: Refactor the sysfs interface
  [PATCH] hwmon: Support the Pentium M VID code
  [PATCH] hwmon: Add support for the Winbond W83687THF
  [PATCH] hwmon: f71805f semaphore to mutex conversions
  [PATCH] hwmon: Semaphore to mutex conversions
  [PATCH] i2c: Semaphore to mutex conversions, part 3
  [PATCH] i2c: Semaphore to mutex conversions, part 2
  ...
parents a3ea9b58 ded2b666
......@@ -18,6 +18,10 @@ Supported chips:
Prefix: 'w83637hf'
Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf
* Winbond W83687THF
Prefix: 'w83687thf'
Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: Provided by Winbond on request
Authors:
Frodo Looijaard <frodol@dds.nl>,
......
......@@ -36,6 +36,11 @@ Module parameters
Use 'init=0' to bypass initializing the chip.
Try this if your computer crashes when you load the module.
* reset int
(default 0)
The driver used to reset the chip on load, but does no more. Use
'reset=1' to restore the old behavior. Report if you need to do this.
force_subclients=bus,caddr,saddr,saddr
This is used to force the i2c addresses for subclients of
a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'
......@@ -123,6 +128,25 @@ When an alarm goes off, you can be warned by a beeping signal through
your computer speaker. It is possible to enable all beeping globally,
or only the beeping for some alarms.
Individual alarm and beep bits:
0x000001: in0
0x000002: in1
0x000004: in2
0x000008: in3
0x000010: temp1
0x000020: temp2 (+temp3 on W83781D)
0x000040: fan1
0x000080: fan2
0x000100: in4
0x000200: in5
0x000400: in6
0x000800: fan3
0x001000: chassis
0x002000: temp3 (W83782D and W83627HF only)
0x010000: in7 (W83782D and W83627HF only)
0x020000: in8 (W83782D and W83627HF only)
If an alarm triggers, it will remain triggered until the hardware register
is read at least once. This means that the cause for the alarm may
already have disappeared! Note that in the current implementation, all
......
......@@ -4,7 +4,7 @@ Supported adapters:
* Intel 82371AB PIIX4 and PIIX4E
* Intel 82443MX (440MX)
Datasheet: Publicly available at the Intel website
* ServerWorks OSB4, CSB5 and CSB6 southbridges
* ServerWorks OSB4, CSB5, CSB6 and HT-1000 southbridges
Datasheet: Only available via NDA from ServerWorks
* Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
Datasheet: Publicly available at the SMSC website http://www.smsc.com
......
......@@ -6,9 +6,10 @@ Module Parameters
-----------------
* base: int
Base addresses for the ACCESS.bus controllers
Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices
Description
-----------
Enable the use of the ACCESS.bus controllers of a SCx200 processor.
Enable the use of the ACCESS.bus controller on the Geode SCx200 and
SC1100 processors and the CS5535 and CS5536 Geode companion devices.
......@@ -406,13 +406,14 @@ config SENSORS_W83L785TS
will be called w83l785ts.
config SENSORS_W83627HF
tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
depends on HWMON && I2C && EXPERIMENTAL
tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF"
depends on HWMON && I2C
select I2C_ISA
select HWMON_VID
help
If you say yes here you get support for the Winbond W836X7 series
of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and
W83697HF.
This driver can also be built as a module. If so, the module
will be called w83627hf.
......
......@@ -26,6 +26,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
......@@ -92,7 +93,7 @@ struct adm1021_data {
struct class_device *class_dev;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct adm1021_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(temp); \
adm1021_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
set(temp_max, ADM1021_REG_TOS_W);
......@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -53,6 +53,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = {
struct adm1025_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
data->in_min[offset]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
......@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
data->in_max[offset]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
......@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->temp_min[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
data->temp_min[offset-1]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
......@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->temp_max[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
data->temp_max[offset-1]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
......@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int i;
......@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
This diff is collapsed.
......@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Following macros takes channel parameter starting from 0 to 2 */
#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
......@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2];
struct adm1031_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
int chip_type;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
old_fan_mode = data->conf1;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) {
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return ret;
}
if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^
......@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
}
data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
data->auto_temp[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr)
......@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]);
adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
data->temp_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
int val = simple_strtol(buf, NULL, 10);
int reg;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) &&
(((val>>4) & 0xf) != 5)) {
/* In automatic mode, the only PWM accepted is 33% */
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
data->pwm[nr] = PWM_TO_REG(val);
......@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
adm1031_write_value(client, ADM1031_REG_PWM,
nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf)
: (data->pwm[nr] & 0xf) | (reg & 0xf0));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (val) {
data->fan_min[nr] =
FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr]));
......@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
data->fan_min[nr] = 0xff;
}
adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
......@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
if (tmp == 0xff)
return -EINVAL;
down(&data->update_lock);
mutex_lock(&data->update_lock);
old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]);
new_min = data->fan_min[nr] * old_div /
......@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
data->fan_div[nr]);
adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr),
data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_min[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
data->temp_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
......@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
data->temp_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
......@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_crit[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
data->temp_crit[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
struct adm1031_data *data = i2c_get_clientdata(client);
int chan;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -49,6 +49,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
......@@ -150,7 +151,7 @@ struct adm9240_data {
enum chips type;
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid;
unsigned long last_updated_measure;
unsigned long last_updated_config;
......@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
struct adm9240_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max[attr->index] = TEMP_TO_REG(val);
i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
data->temp_max[attr->index]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[attr->index] = IN_TO_REG(val, attr->index);
i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
data->in_min[attr->index]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[attr->index] = IN_TO_REG(val, attr->index);
i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
data->in_max[attr->index]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev,
int nr = attr->index;
u8 new_div;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (!val) {
data->fan_min[nr] = 255;
......@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev,
i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val);
i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
......@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
/* fill in the remaining client fields and attach */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->type = kind;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
if ((err = i2c_attach_client(new_client)))
goto exit_free;
......@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
struct adm9240_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
/* minimum measurement cycle: 1.75 seconds */
if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
......@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
data->last_updated_config = jiffies;
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -44,6 +44,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include "lm75.h"
/*
......@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val)
struct asb100_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
unsigned long last_updated; /* In jiffies */
/* array of 2 pointers to subclients */
......@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \
struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct asb100_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10);
int reg;
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
......@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
switch (nr) { \
case 1: case 2: \
data->reg[nr] = LM75_TEMP_TO_REG(val); \
......@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
} \
asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
data->reg[nr]); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm &= 0x80; /* keep the enable bit */
data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm &= 0x0f; /* keep the duty cycle bits */
data->pwm |= (val ? 0x80 : 0x00);
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
}
new_client = &data->client;
init_MUTEX(&data->lock);
mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
......@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
struct i2c_client *cl;
int res, bank;
down(&data->lock);
mutex_lock(&data->lock);
bank = (reg >> 8) & 0x0f;
if (bank > 2)
......@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
if (bank > 2)
i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
up(&data->lock);
mutex_unlock(&data->lock);
return res;
}
......@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
struct i2c_client *cl;
int bank;
down(&data->lock);
mutex_lock(&data->lock);
bank = (reg >> 8) & 0x0f;
if (bank > 2)
......@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
if (bank > 2)
i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
up(&data->lock);
mutex_unlock(&data->lock);
}
static void asb100_init_client(struct i2c_client *client)
......@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
struct asb100_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
dev_dbg(&client->dev, "... device update complete\n");
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -26,6 +26,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
......@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = {
struct atxp1_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
unsigned long last_updated;
u8 valid;
struct {
......@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
client = to_i2c_client(dev);
data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
......@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return(data);
}
......@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
err = i2c_attach_client(new_client);
......
......@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include "lm75.h"
/* Addresses to scan */
......@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
struct ds1621_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
struct ds1621_data *data = ds1621_update_client(dev); \
u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = val; \
ds1621_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address,
/* Fill in remaining client fields and put it into the global list */
strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
struct ds1621_data *data = i2c_get_clientdata(client);
u8 new_conf;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
This diff is collapsed.
......@@ -33,6 +33,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = {
struct fscher_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
* global list */
strlcpy(new_client->name, "fscher", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct fscher_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
......@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat
/* bits 0..1, 3..7 reserved => mask with 0x04 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v;
fscher_write_value(client, reg, v);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data,
{
unsigned long v = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v;
fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data,
return -EINVAL;
}
down(&data->update_lock);
mutex_lock(&data->update_lock);
/* bits 2..7 reserved => mask with 0x03 */
data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03;
data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v;
fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da
/* bits 2..7 reserved, 0 read only => mask with 0x02 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v;
fscher_write_value(client, reg, v);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data,
/* bits 1..7 reserved => mask with 0x01 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->global_control &= ~v;
fscher_write_value(client, reg, v);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct
/* bits 0..3 reserved => mask with 0xf0 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->watchdog[2] &= ~0xf0;
data->watchdog[2] |= v;
fscher_write_value(client, reg, data->watchdog[2]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data
/* bits 0, 2..7 reserved => mask with 0x02 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->watchdog[1] &= ~v;
fscher_write_value(client, reg, v);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data
{
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->watchdog[0] = v;
fscher_write_value(client, reg, data->watchdog[0]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......
......@@ -37,6 +37,7 @@
#include <linux/init.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter);
static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind);
static int fscpos_detach_client(struct i2c_client *client);
static int fscpos_read_value(struct i2c_client *client, u8 register);
static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value);
static int fscpos_read_value(struct i2c_client *client, u8 reg);
static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct fscpos_data *fscpos_update_device(struct device *dev);
static void fscpos_init_client(struct i2c_client *client);
......@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = {
struct fscpos_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* 0 until following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data
return -EINVAL;
}
down(&data->update_lock);
mutex_lock(&data->update_lock);
/* bits 2..7 reserved => mask with 0x03 */
data->fan_ripple[nr - 1] &= ~0x03;
data->fan_ripple[nr - 1] |= v;
fscpos_write_value(client, reg, data->fan_ripple[nr - 1]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data,
if (v < 0) v = 0;
if (v > 255) v = 255;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm[nr - 1] = v;
fscpos_write_value(client, reg, data->pwm[nr - 1]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data
/* bits 0..3 reserved => mask with 0xf0 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->wdog_control &= ~0xf0;
data->wdog_control |= v;
fscpos_write_value(client, reg, data->wdog_control);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data
return -EINVAL;
}
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->wdog_state &= ~v;
fscpos_write_value(client, reg, v);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
{
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->wdog_preset = v;
fscpos_write_value(client, reg, data->wdog_preset);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct fscpos_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
int i;
......@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
data->last_updated = jiffies;
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -43,6 +43,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
......@@ -120,7 +121,7 @@ struct gl518_data {
struct class_device *class_dev;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
struct gl518_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = type##_TO_REG(val); \
gl518_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
int regvalue; \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
regvalue = gl518_read_value(client, reg); \
data->value = type##_TO_REG(val); \
regvalue = (regvalue & ~mask) | (data->value << shift); \
gl518_write_value(client, reg, regvalue); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
int regvalue;
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
data->fan_min[0] = FAN_TO_REG(val,
DIV_FROM_REG(data->fan_div[0]));
......@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
data->beep_mask &= data->alarm_mask;
gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
int regvalue;
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
data->fan_min[1] = FAN_TO_REG(val,
DIV_FROM_REG(data->fan_div[1]));
......@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
data->beep_mask &= data->alarm_mask;
gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
struct gl518_data *data = i2c_get_clientdata(client);
int val;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -29,6 +29,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Type of the extra sensor */
static unsigned short extra_sensor_type;
......@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = {
struct gl520_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until the following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
long v = simple_strtol(buf, NULL, 10);
u8 r;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (n == 0)
r = VDD_TO_REG(v);
......@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
else
gl520_write_value(client, reg, r);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
else
r = IN_TO_REG(v);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[n] = r;
......@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
else
gl520_write_value(client, reg, r);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
unsigned long v = simple_strtoul(buf, NULL, 10);
u8 r;
down(&data->update_lock);
mutex_lock(&data->update_lock);
r = FAN_TO_REG(v, data->fan_div[n - 1]);
data->fan_min[n - 1] = r;
......@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
data->beep_mask &= data->alarm_mask;
gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
return -EINVAL;
}
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_div[n - 1] = r;
if (n == 1)
......@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
else
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c
{
u8 r = simple_strtoul(buf, NULL, 10)?1:0;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_off = r;
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data,
{
long v = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max[n - 1] = TEMP_TO_REG(v);;
gl520_write_value(client, reg, data->temp_max[n - 1]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d
{
long v = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max_hyst[n - 1] = TEMP_TO_REG(v);
gl520_write_value(client, reg, data->temp_max_hyst[n - 1]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat
{
u8 r = simple_strtoul(buf, NULL, 10)?0:1;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->beep_enable = !r;
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data,
{
u8 r = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
r &= data->alarm_mask;
data->beep_mask = r;
gl520_write_value(client, reg, r);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
struct gl520_data *data = i2c_get_clientdata(client);
int val;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
......@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -33,6 +33,7 @@
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/dmi.h>
#include <linux/mutex.h>
#include <asm/io.h>
#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
......@@ -70,10 +71,10 @@ static u8 km_activity;
static int rest_x;
static int rest_y;
static DECLARE_MUTEX(hdaps_sem);
static DEFINE_MUTEX(hdaps_mutex);
/*
* __get_latch - Get the value from a given port. Callers must hold hdaps_sem.
* __get_latch - Get the value from a given port. Callers must hold hdaps_mutex.
*/
static inline u8 __get_latch(u16 port)
{
......@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port)
/*
* __check_latch - Check a port latch for a given value. Returns zero if the
* port contains the given value. Callers must hold hdaps_sem.
* port contains the given value. Callers must hold hdaps_mutex.
*/
static inline int __check_latch(u16 port, u8 val)
{
......@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val)
/*
* __wait_latch - Wait up to 100us for a port latch to get a certain value,
* returning zero if the value is obtained. Callers must hold hdaps_sem.
* returning zero if the value is obtained. Callers must hold hdaps_mutex.
*/
static int __wait_latch(u16 port, u8 val)
{
......@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val)
/*
* __device_refresh - request a refresh from the accelerometer. Does not wait
* for refresh to complete. Callers must hold hdaps_sem.
* for refresh to complete. Callers must hold hdaps_mutex.
*/
static void __device_refresh(void)
{
......@@ -124,7 +125,7 @@ static void __device_refresh(void)
/*
* __device_refresh_sync - request a synchronous refresh from the
* accelerometer. We wait for the refresh to complete. Returns zero if
* successful and nonzero on error. Callers must hold hdaps_sem.
* successful and nonzero on error. Callers must hold hdaps_mutex.
*/
static int __device_refresh_sync(void)
{
......@@ -134,7 +135,7 @@ static int __device_refresh_sync(void)
/*
* __device_complete - indicate to the accelerometer that we are done reading
* data, and then initiate an async refresh. Callers must hold hdaps_sem.
* data, and then initiate an async refresh. Callers must hold hdaps_mutex.
*/
static inline void __device_complete(void)
{
......@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
{
int ret;
down(&hdaps_sem);
mutex_lock(&hdaps_mutex);
/* do a sync refresh -- we need to be sure that we read fresh data */
ret = __device_refresh_sync();
......@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
__device_complete();
out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mutex);
return ret;
}
......@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
{
int ret;
down(&hdaps_sem);
mutex_lock(&hdaps_mutex);
ret = __hdaps_read_pair(port1, port2, val1, val2);
up(&hdaps_sem);
mutex_unlock(&hdaps_mutex);
return ret;
}
......@@ -213,7 +214,7 @@ static int hdaps_device_init(void)
{
int total, ret = -ENXIO;
down(&hdaps_sem);
mutex_lock(&hdaps_mutex);
outb(0x13, 0x1610);
outb(0x01, 0x161f);
......@@ -279,7 +280,7 @@ static int hdaps_device_init(void)
}
out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mutex);
return ret;
}
......@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = {
};
/*
* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem.
* hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex.
*/
static void hdaps_calibrate(void)
{
......@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
int x, y;
/* Cannot sleep. Try nonblockingly. If we fail, try again later. */
if (down_trylock(&hdaps_sem)) {
if (!mutex_trylock(&hdaps_mutex)) {
mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
return;
}
......@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
out:
up(&hdaps_sem);
mutex_unlock(&hdaps_mutex);
}
......@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
down(&hdaps_sem);
mutex_lock(&hdaps_mutex);
hdaps_calibrate();
up(&hdaps_sem);
mutex_unlock(&hdaps_mutex);
return count;
}
......
......@@ -54,6 +54,10 @@
(IMVP-II). You can find more information in the datasheet of Max1718
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452
The 13 specification corresponds to the Intel Pentium M series. There
doesn't seem to be any named specification for these. The conversion
tables are detailed directly in the various Pentium M datasheets:
http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm
*/
/* vrm is the VRM/VRD document version multiplied by 10.
......@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm)
case 17: /* Intel IMVP-II */
return(val & 0x10 ? 975 - (val & 0xF) * 25 :
1750 - val * 50);
case 13:
return(1708 - (val & 0x3f) * 16);
default: /* report 0 for unknown */
printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
return 0;
......@@ -129,8 +135,9 @@ struct vrm_model {
static struct vrm_model vrm_models[] = {
{X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */
{X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */
{X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */
{X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */
{X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */
{X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */
{X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */
{X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */
{X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */
......
......@@ -17,6 +17,7 @@
#include <linux/idr.h>
#include <linux/hwmon.h>
#include <linux/gfp.h>
#include <linux/spinlock.h>
#define HWMON_ID_PREFIX "hwmon"
#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
......@@ -24,6 +25,7 @@
static struct class *hwmon_class;
static DEFINE_IDR(hwmon_idr);
static DEFINE_SPINLOCK(idr_lock);
/**
* hwmon_device_register - register w/ hwmon sysfs class
......@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr);
struct class_device *hwmon_device_register(struct device *dev)
{
struct class_device *cdev;
int id;
int id, err;
if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)
again:
if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
return ERR_PTR(-ENOMEM);
if (idr_get_new(&hwmon_idr, NULL, &id) < 0)
return ERR_PTR(-ENOMEM);
spin_lock(&idr_lock);
err = idr_get_new(&hwmon_idr, NULL, &id);
spin_unlock(&idr_lock);
if (unlikely(err == -EAGAIN))
goto again;
else if (unlikely(err))
return ERR_PTR(err);
id = id & MAX_ID_MASK;
cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev,
HWMON_ID_FORMAT, id);
if (IS_ERR(cdev))
if (IS_ERR(cdev)) {
spin_lock(&idr_lock);
idr_remove(&hwmon_idr, id);
spin_unlock(&idr_lock);
}
return cdev;
}
......@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev)
{
int id;
if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) {
if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) {
class_device_unregister(cdev);
spin_lock(&idr_lock);
idr_remove(&hwmon_idr, id);
spin_unlock(&idr_lock);
} else
dev_dbg(cdev->dev,
"hwmon_device_unregister() failed: bad class ID!\n");
......
......@@ -41,6 +41,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <asm/io.h>
......@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val)
struct it87_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
static int it87_detach_client(struct i2c_client *client);
static int it87_read_value(struct i2c_client *client, u8 register);
static int it87_write_value(struct i2c_client *client, u8 register,
u8 value);
static int it87_read_value(struct i2c_client *client, u8 reg);
static int it87_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct it87_data *it87_update_device(struct device *dev);
static int it87_check_pwm(struct i2c_client *client);
static void it87_init_client(struct i2c_client *client, struct it87_data *data);
......@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MIN(nr),
data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
......@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MAX(nr),
data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
......@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_offset(offset) \
......@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->sensor &= ~(1 << nr);
data->sensor &= ~(8 << nr);
......@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
else if (val == 2)
data->sensor |= 8 << nr;
else if (val != 0) {
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_sensor_offset(offset) \
......@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
int val = simple_strtol(buf, NULL, 10);
u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
down(&data->update_lock);
mutex_lock(&data->update_lock);
switch (nr) {
case 0: data->fan_div[nr] = reg & 0x07; break;
case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
......@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
......@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
int i, min[3];
u8 old;
down(&data->update_lock);
mutex_lock(&data->update_lock);
old = it87_read_value(client, IT87_REG_FAN_DIV);
for (i = 0; i < 3; i++)
......@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i]));
it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]);
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_pwm_enable(struct device *dev,
......@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (val == 0) {
int tmp;
......@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev,
/* set saved pwm value, clear FAN_CTLX PWM mode bit */
it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
} else {
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
......@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
if (val < 0 || val > 255)
return -EINVAL;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->manual_pwm_ctl[nr] = val;
if (data->fan_main_ctrl & (1 << nr))
it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
new_client = &data->client;
if (is_isa)
init_MUTEX(&data->lock);
mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
......@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg)
int res;
if (i2c_is_isa_client(client)) {
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return res;
} else
return i2c_smbus_read_byte_data(client, reg);
......@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
struct it87_data *data = i2c_get_clientdata(client);
if (i2c_is_isa_client(client)) {
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return 0;
} else
return i2c_smbus_write_byte_data(client, reg, value);
......@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev)
struct it87_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -45,6 +45,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = {
struct lm63_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
struct lm63_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan[1] = FAN_TO_REG(val);
i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
data->fan[1] & 0xFF);
i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
data->fan[1] >> 8);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
return -EPERM;
val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm1_value = val <= 0 ? 0 :
val >= 255 ? 2 * data->pwm1_freq :
(val * data->pwm1_freq * 2 + 127) / 255;
i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
struct lm63_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp8[1] = TEMP8_TO_REG(val);
i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp11[nr] = TEMP11_TO_REG(val);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
data->temp11[nr] >> 8);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
data->temp11[nr] & 0xff);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
long val = simple_strtol(buf, NULL, 10);
long hyst;
down(&data->update_lock);
mutex_lock(&data->update_lock);
hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
HYST_TO_REG(hyst));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm63_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
if (data->config & 0x04) { /* tachometer enabled */
......@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -25,6 +25,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include "lm75.h"
......@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75);
struct lm75_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
u16 temp_input; /* Register values */
......@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm75_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = LM75_TEMP_TO_REG(temp); \
lm75_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
set(temp_max, LM75_REG_TEMP_OS);
......@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm75_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -32,6 +32,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
......@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77);
struct lm77_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid;
unsigned long last_updated; /* In jiffies */
int temp_input; /* Temperatures */
......@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm77_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = val; \
lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a
struct lm77_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_hyst = data->temp_crit - val;
lm77_write_value(client, LM77_REG_TEMP_HYST,
LM77_TEMP_TO_REG(data->temp_hyst));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
long val = simple_strtoul(buf, NULL, 10);
int oldcrithyst;
down(&data->update_lock);
mutex_lock(&data->update_lock);
oldcrithyst = data->temp_crit - data->temp_hyst;
data->temp_crit = val;
data->temp_hyst = data->temp_crit - oldcrithyst;
......@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
LM77_TEMP_TO_REG(data->temp_crit));
lm77_write_value(client, LM77_REG_TEMP_HYST,
LM77_TEMP_TO_REG(data->temp_hyst));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm77_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -27,6 +27,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <asm/io.h>
/* Addresses to scan */
......@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
struct lm78_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
static int lm78_detach_client(struct i2c_client *client);
static int lm78_read_value(struct i2c_client *client, u8 register);
static int lm78_write_value(struct i2c_client *client, u8 register, u8 value);
static int lm78_read_value(struct i2c_client *client, u8 reg);
static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct lm78_data *lm78_update_device(struct device *dev);
static void lm78_init_client(struct i2c_client *client);
......@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
struct lm78_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_over = TEMP_TO_REG(val);
lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
struct lm78_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_hyst = TEMP_TO_REG(val);
lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long min;
u8 reg;
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
......@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
......@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] =
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
new_client = &data->client;
if (is_isa)
init_MUTEX(&data->lock);
mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
......@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
int res;
if (i2c_is_isa_client(client)) {
struct lm78_data *data = i2c_get_clientdata(client);
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return res;
} else
return i2c_smbus_read_byte_data(client, reg);
......@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
{
if (i2c_is_isa_client(client)) {
struct lm78_data *data = i2c_get_clientdata(client);
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return 0;
} else
return i2c_smbus_write_byte_data(client, reg, value);
......@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
struct lm78_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
data->fan_div[2] = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
......@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
struct lm80_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock);\
mutex_lock(&data->update_lock);\
data->value = IN_TO_REG(val); \
lm80_write_value(client, reg, data->value); \
up(&data->update_lock);\
mutex_unlock(&data->update_lock);\
return count; \
}
set_in(min0, in_min[0], LM80_REG_IN_MIN(0));
......@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock);\
mutex_lock(&data->update_lock);\
data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \
lm80_write_value(client, reg, data->value); \
up(&data->update_lock);\
mutex_unlock(&data->update_lock);\
return count; \
}
set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
......@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
u8 reg;
/* Save fan_min */
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
......@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
......@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
/* Restore fan_min */
data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = TEMP_LIMIT_TO_REG(val); \
lm80_write_value(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
......@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
struct lm80_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
dev_dbg(&client->dev, "Starting lm80 update\n");
......@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -35,6 +35,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = {
struct lm83_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp[nr] = TEMP_TO_REG(val);
i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
data->temp[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm83_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;
......@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -31,6 +31,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
......@@ -331,10 +332,10 @@ struct lm85_autofan {
struct lm85_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
enum chips type;
struct semaphore update_lock;
struct mutex update_lock;
int valid; /* !=0 if following fields are valid */
unsigned long last_reading; /* In jiffies */
unsigned long last_config; /* In jiffies */
......@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
int kind);
static int lm85_detach_client(struct i2c_client *client);
static int lm85_read_value(struct i2c_client *client, u8 register);
static int lm85_write_value(struct i2c_client *client, u8 register, int value);
static int lm85_read_value(struct i2c_client *client, u8 reg);
static int lm85_write_value(struct i2c_client *client, u8 reg, int value);
static struct lm85_data *lm85_update_device(struct device *dev);
static void lm85_init_client(struct i2c_client *client);
......@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val);
lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm[nr] = PWM_TO_REG(val);
lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
......@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = INS_TO_REG(nr, val);
lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_in_max(struct device *dev, char *buf, int nr)
......@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = INS_TO_REG(nr, val);
lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_in_reg(offset) \
......@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_min[nr] = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
......@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_max[nr] = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_reg(offset) \
......@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
| ZONE_TO_REG(val) ;
lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
data->autofan[nr].config);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
......@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->autofan[nr].min_pwm = PWM_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
data->autofan[nr].min_pwm);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
......@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->autofan[nr].min_off = val;
lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
| data->syncpwm3
......@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
| (data->autofan[1].min_off ? 0x40 : 0)
| (data->autofan[2].min_off ? 0x80 : 0)
);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
......@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->autofan[nr].freq = FREQ_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
(data->zone[nr].range << 4)
| data->autofan[nr].freq
);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define pwm_auto(offset) \
......@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
int min;
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = TEMP_FROM_REG(data->zone[nr].limit);
data->zone[nr].off_desired = TEMP_TO_REG(val);
data->zone[nr].hyst = HYST_TO_REG(min - val);
......@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
(data->zone[2].hyst << 4)
);
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
......@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->zone[nr].limit = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
data->zone[nr].limit);
......@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
(data->zone[2].hyst << 4)
);
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
......@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
int min;
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = TEMP_FROM_REG(data->zone[nr].limit);
data->zone[nr].max_desired = TEMP_TO_REG(val);
data->zone[nr].range = RANGE_TO_REG(
......@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
((data->zone[nr].range & 0x0f) << 4)
| (data->autofan[nr].freq & 0x07));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
......@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->zone[nr].critical = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
data->zone[nr].critical);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define temp_auto(offset) \
......@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
/* Fill in the remaining client fields */
data->type = kind;
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
struct lm85_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if ( !data->valid ||
time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
......@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
data->valid = 1;
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -60,6 +60,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = {
struct lm87_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}
static void set_in_max(struct device *dev, const char *buf, int nr)
......@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}
#define set_in(offset) \
......@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val);
lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}
static void set_temp_high(struct device *dev, const char *buf, int nr)
......@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val);
lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}
#define set_temp(offset) \
......@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val,
FAN_DIV_FROM_REG(data->fan_div[nr]));
lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}
/* Note: we save and restore the fan minimum here, because its value is
......@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long min;
u8 reg;
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
FAN_DIV_FROM_REG(data->fan_div[nr]));
......@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
case 4: data->fan_div[nr] = 2; break;
case 8: data->fan_div[nr] = 3; break;
default:
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
......@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] = FAN_TO_REG(min, val);
lm87_write_value(client, LM87_REG_FAN_MIN(nr),
data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val);
lm87_write_value(client, LM87_REG_AOUT, data->aout);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
......@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm87_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
int i, j;
......@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -78,6 +78,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/*
* Addresses to scan
......@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = {
struct lm90_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
int kind;
......@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (data->kind == adt7461)
data->temp8[nr] = TEMP1_TO_REG_ADT7461(val);
else
data->temp8[nr] = TEMP1_TO_REG(val);
i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (data->kind == adt7461)
data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);
else
......@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
data->temp11[nr] >> 8);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
data->temp11[nr] & 0xff);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
long val = simple_strtol(buf, NULL, 10);
long hyst;
down(&data->update_lock);
mutex_lock(&data->update_lock);
hyst = TEMP1_FROM_REG(data->temp8[3]) - val;
i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
HYST_TO_REG(hyst));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
data->kind = kind;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
u8 oldh, newh, l;
......@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -46,6 +46,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* The LM92 and MAX6635 have 2 two-state pins for address selection,
resulting in 4 possible addresses. */
......@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver;
struct lm92_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm92_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ)
|| !data->valid) {
......@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm92_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_word_data(client, reg, swab16(data->value)); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
......@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
struct lm92_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST,
swab16(TEMP_TO_REG(data->temp1_hyst)));
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the i2c subsystem a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......
......@@ -33,6 +33,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/mutex.h>
static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
0x29, 0x2a, 0x2b,
......@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = {
struct max1619_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct max1619_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
down(&data->update_lock); \
mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, reg, data->value); \
up(&data->update_lock); \
mutex_unlock(&data->update_lock); \
return count; \
}
......@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct max1619_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
dev_dbg(&client->dev, "Updating max1619 data.\n");
......@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
This diff is collapsed.
......@@ -60,6 +60,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <asm/io.h>
......@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val)
struct sis5595_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
char maxins; /* == 3 if temp enabled, otherwise == 4 */
......@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
static int sis5595_detect(struct i2c_adapter *adapter);
static int sis5595_detach_client(struct i2c_client *client);
static int sis5595_read_value(struct i2c_client *client, u8 register);
static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value);
static int sis5595_read_value(struct i2c_client *client, u8 reg);
static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct sis5595_data *sis5595_update_device(struct device *dev);
static void sis5595_init_client(struct i2c_client *client);
......@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
struct sis5595_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_over = TEMP_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
struct sis5595_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_hyst = TEMP_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10);
int reg;
down(&data->update_lock);
mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
......@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
......@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] =
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->adapter = adapter;
new_client->driver = &sis5595_driver;
......@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
......@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg)
int res;
struct sis5595_data *data = i2c_get_clientdata(client);
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return res;
}
static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
{
struct sis5595_data *data = i2c_get_clientdata(client);
down(&data->lock);
mutex_lock(&data->lock);
outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
up(&data->lock);
mutex_unlock(&data->lock);
return 0;
}
......@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
struct sis5595_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -35,6 +35,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/io.h>
/* Address is autodetected, there is no default value */
......@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
struct smsc47b397_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
struct semaphore update_lock;
struct mutex update_lock;
unsigned long last_updated; /* in jiffies */
int valid;
......@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg)
struct smsc47b397_data *data = i2c_get_clientdata(client);
int res;
down(&data->lock);
mutex_lock(&data->lock);
outb(reg, client->addr);
res = inb_p(client->addr + 1);
up(&data->lock);
mutex_unlock(&data->lock);
return res;
}
......@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
struct smsc47b397_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
dev_dbg(&client->dev, "starting device update...\n");
......@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
dev_dbg(&client->dev, "... device update complete\n");
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
init_MUTEX(&data->lock);
mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = &smsc47b397_driver;
new_client->flags = 0;
strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE);
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
if ((err = i2c_attach_client(new_client)))
goto error_free;
......
......@@ -34,6 +34,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/io.h>
/* Address is autodetected, there is no default value */
......@@ -102,9 +103,9 @@ superio_exit(void)
struct smsc47m1_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore lock;
struct mutex lock;
struct semaphore update_lock;
struct mutex update_lock;
unsigned long last_updated; /* In jiffies */
u8 fan[2]; /* Register value */
......@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct smsc47m1_data *data = i2c_get_clientdata(client);
long rpmdiv, val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]);
if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) {
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv);
smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
data->fan_preload[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
if (new_div == old_div) /* No change */
return count;
down(&data->update_lock);
mutex_lock(&data->update_lock);
switch (new_div) {
case 1: data->fan_div[nr] = 0; break;
case 2: data->fan_div[nr] = 1; break;
case 4: data->fan_div[nr] = 2; break;
case 8: data->fan_div[nr] = 3; break;
default:
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return -EINVAL;
}
......@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191);
smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
data->fan_preload[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
if (val < 0 || val > 255)
return -EINVAL;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm[nr] &= 0x81; /* Preserve additional bits */
data->pwm[nr] |= PWM_TO_REG(val);
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
data->pwm[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf,
if (val != 0 && val != 1)
return -EINVAL;
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->pwm[nr] &= 0xFE; /* preserve the other bits */
data->pwm[nr] |= !val;
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
data->pwm[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
init_MUTEX(&data->lock);
mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = &smsc47m1_driver;
new_client->flags = 0;
strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE);
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* If no function is properly configured, there's no point in
actually registering the chip. */
......@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg)
{
int res;
down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
res = inb_p(client->addr + reg);
up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
return res;
}
static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value)
{
down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
outb_p(value, client->addr + reg);
up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
}
static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
......@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
struct i2c_client *client = to_i2c_client(dev);
struct smsc47m1_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) {
int i;
......@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
data->last_updated = jiffies;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -39,6 +39,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/mutex.h>
#include <asm/io.h>
......@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val)
struct via686a_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
......@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MIN(nr),
data->in_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_in_max(struct device *dev, const char *buf,
......@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MAX(nr),
data->in_max[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_in_offset(offset) \
......@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_over[nr] = TEMP_TO_REG(val);
via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr],
data->temp_over[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_hyst(struct device *dev, const char *buf,
......@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->temp_hyst[nr] = TEMP_TO_REG(val);
via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr],
data->temp_hyst[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_offset(offset) \
......@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
down(&data->update_lock);
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_fan_div(struct device *dev, const char *buf,
......@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
int val = simple_strtol(buf, NULL, 10);
int old;
down(&data->update_lock);
mutex_lock(&data->update_lock);
old = via686a_read_value(client, VIA686A_REG_FANDIV);
data->fan_div[nr] = DIV_TO_REG(val);
old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
via686a_write_value(client, VIA686A_REG_FANDIV, old);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}
......@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter)
strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto exit_free;
......@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
struct via686a_data *data = i2c_get_clientdata(client);
int i;
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
......@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -39,6 +39,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
/* How many retries on register read error */
#define MAX_RETRIES 5
......@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = {
struct w83l785ts_data {
struct i2c_client client;
struct class_device *class_dev;
struct semaphore update_lock;
struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
......@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields. */
strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
/* Default values in case the first read fails (unlikely). */
data->temp[1] = data->temp[0] = 0;
......@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct w83l785ts_data *data = i2c_get_clientdata(client);
down(&data->update_lock);
mutex_lock(&data->update_lock);
if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
dev_dbg(&client->dev, "Updating w83l785ts data.\n");
......@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
data->valid = 1;
}
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return data;
}
......
......@@ -168,12 +168,14 @@ config I2C_PIIX4
help
If you say yes to this option, support will be included for the Intel
PIIX4 family of mainboard I2C interfaces. Specifically, the following
versions of the chipset are supported:
versions of the chipset are supported (note that Serverworks is part
of Broadcom):
Intel PIIX4
Intel 440MX
Serverworks OSB4
Serverworks CSB5
Serverworks CSB6
Serverworks HT-1000
SMSC Victory66
This driver can also be built as a module. If so, the module
......@@ -389,10 +391,11 @@ config SCx200_I2C_SDA
also be specified with a module parameter.
config SCx200_ACB
tristate "NatSemi SCx200 ACCESS.bus"
depends on I2C && PCI
tristate "Geode ACCESS.bus support"
depends on X86_32 && I2C && PCI
help
Enable the use of the ACCESS.bus controllers of a SCx200 processor.
Enable the use of the ACCESS.bus controllers on the Geode SCx200 and
SC1100 processors and the CS5535 and CS5536 Geode companion devices.
If you don't know what to do here, say N.
......
......@@ -63,7 +63,6 @@
#include <linux/i2c.h>
#include <linux/init.h>
#include <asm/io.h>
#include <asm/semaphore.h>
/* ALI1535 SMBus address offsets */
......@@ -136,7 +135,6 @@
static struct pci_driver ali1535_driver;
static unsigned short ali1535_smba;
static DECLARE_MUTEX(i2c_ali1535_sem);
/* Detect whether a ALI1535 can be found, and initialize it, where necessary.
Note the differences between kernels with the old PCI BIOS interface and
......@@ -345,7 +343,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
int timeout;
s32 result = 0;
down(&i2c_ali1535_sem);
/* make sure SMBus is idle */
temp = inb_p(SMBHSTSTS);
for (timeout = 0;
......@@ -460,7 +457,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
break;
}
EXIT:
up(&i2c_ali1535_sem);
return result;
}
......
......@@ -38,6 +38,7 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
extern struct i2c_adapter amd756_smbus;
......@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter;
static struct i2c_algorithm *s4882_algo;
/* Wrapper access functions for multiplexed SMBus */
static struct semaphore amd756_lock;
static DEFINE_MUTEX(amd756_lock);
static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
unsigned short flags, char read_write,
......@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
|| addr == 0x18)
return -1;
down(&amd756_lock);
mutex_lock(&amd756_lock);
error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write,
command, size, data);
up(&amd756_lock);
mutex_unlock(&amd756_lock);
return error;
}
......@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
return -1;
down(&amd756_lock);
mutex_lock(&amd756_lock);
if (last_channels != channels) {
union i2c_smbus_data mplxdata;
......@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
command, size, data);
UNLOCK:
up(&amd756_lock);
mutex_unlock(&amd756_lock);
return error;
}
......@@ -166,8 +167,6 @@ static int __init amd756_s4882_init(void)
}
printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
init_MUTEX(&amd756_lock);
/* Define the 5 virtual adapters and algorithms structures */
if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
GFP_KERNEL))) {
......
This diff is collapsed.
......@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
static int __init i2c_isa_init(void)
{
init_MUTEX(&isa_adapter.clist_lock);
mutex_init(&isa_adapter.clist_lock);
INIT_LIST_HEAD(&isa_adapter.clients);
isa_adapter.nr = ANY_I2C_ISA_BUS;
......
......@@ -200,9 +200,7 @@ static struct i2c_adapter iic_ite_ops = {
.owner = THIS_MODULE,
.id = I2C_HW_I_IIC,
.algo_data = &iic_ite_data,
.dev = {
.name = "ITE IIC adapter",
},
};
/* Called when the module is loaded. This function starts the
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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