Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23244
b: refs/heads/master
c: 5c085d3
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar authored and Greg Kroah-Hartman committed Mar 23, 2006
1 parent eebb94c commit 91c4210
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7656032b904b936eca65a41afa1f2b3603195657
refs/heads/master: 5c085d369c2c4f18942ec8951466e186366d5c78
13 changes: 7 additions & 6 deletions trunk/drivers/i2c/busses/i2c-amd756-s4882.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/mutex.h>

extern struct i2c_adapter amd756_smbus;

static struct i2c_adapter *s4882_adapter;
static struct i2c_algorithm *s4882_algo;

/* Wrapper access functions for multiplexed SMBus */
static struct semaphore amd756_lock;
static struct mutex amd756_lock;

static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
unsigned short flags, char read_write,
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -166,7 +167,7 @@ static int __init amd756_s4882_init(void)
}

printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
init_MUTEX(&amd756_lock);
mutex_init(&amd756_lock);

/* Define the 5 virtual adapters and algorithms structures */
if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/i2c/busses/i2c-isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions trunk/drivers/i2c/chips/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/sched.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/mutex.h>

/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
Expand All @@ -54,7 +55,7 @@ enum eeprom_nature {
/* Each client has this additional data */
struct eeprom_data {
struct i2c_client client;
struct semaphore update_lock;
struct mutex update_lock;
u8 valid; /* bitfield, bit!=0 if slice is valid */
unsigned long last_updated[8]; /* In jiffies, 8 slices */
u8 data[EEPROM_SIZE]; /* Register values */
Expand All @@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
struct eeprom_data *data = i2c_get_clientdata(client);
int i, j;

down(&data->update_lock);
mutex_lock(&data->update_lock);

if (!(data->valid & (1 << slice)) ||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
Expand All @@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
data->valid |= (1 << slice);
}
exit:
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}

static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
Expand Down Expand Up @@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
data->valid = 0;
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);
data->nature = UNKNOWN;

/* Tell the I2C layer a new client has arrived */
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/i2c/chips/max6875.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <asm/semaphore.h>
#include <linux/mutex.h>

/* Do not scan - the MAX6875 access method will write to some EEPROM chips */
static unsigned short normal_i2c[] = {I2C_CLIENT_END};
Expand All @@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875);
/* Each client has this additional data */
struct max6875_data {
struct i2c_client client;
struct semaphore update_lock;
struct mutex update_lock;

u32 valid;
u8 data[USER_EEPROM_SIZE];
Expand Down Expand Up @@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
if (slice >= USER_EEPROM_SLICES)
return;

down(&data->update_lock);
mutex_lock(&data->update_lock);

buf = &data->data[slice << SLICE_BITS];

Expand Down Expand Up @@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
data->valid |= (1 << slice);
}
exit_up:
up(&data->update_lock);
mutex_unlock(&data->update_lock);
}

static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
Expand Down Expand Up @@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
real_client->driver = &max6875_driver;
real_client->flags = 0;
strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
init_MUTEX(&data->update_lock);
mutex_init(&data->update_lock);

/* Init fake client data */
/* set the client data to the i2c_client so that it will get freed */
Expand Down
13 changes: 7 additions & 6 deletions trunk/drivers/i2c/chips/pcf8591.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/mutex.h>

/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
Expand Down Expand Up @@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode,

struct pcf8591_data {
struct i2c_client client;
struct semaphore update_lock;
struct mutex update_lock;

u8 control;
u8 aout;
Expand Down Expand Up @@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
struct pcf8591_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);

down(&data->update_lock);
mutex_lock(&data->update_lock);
if (val)
data->control |= PCF8591_CONTROL_AOEF;
else
data->control &= ~PCF8591_CONTROL_AOEF;
i2c_smbus_write_byte(client, data->control);
up(&data->update_lock);
mutex_unlock(&data->update_lock);
return count;
}

Expand Down Expand Up @@ -200,7 +201,7 @@ static int pcf8591_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, "pcf8591", I2C_NAME_SIZE);
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)))
Expand Down Expand Up @@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
struct i2c_client *client = to_i2c_client(dev);
struct pcf8591_data *data = i2c_get_clientdata(client);

down(&data->update_lock);
mutex_lock(&data->update_lock);

if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
Expand All @@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
}
value = i2c_smbus_read_byte(client);

up(&data->update_lock);
mutex_unlock(&data->update_lock);

if ((channel == 2 && input_mode == 2) ||
(channel != 3 && (input_mode == 1 || input_mode == 3)))
Expand Down
Loading

0 comments on commit 91c4210

Please sign in to comment.