aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/eeprom.c')
-rw-r--r--drivers/i2c/chips/eeprom.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 41116b7947f6..13c108269a6d 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -33,6 +33,7 @@
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/jiffies.h> 34#include <linux/jiffies.h>
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36#include <linux/mutex.h>
36 37
37/* Addresses to scan */ 38/* Addresses to scan */
38static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54, 39static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
@@ -54,7 +55,7 @@ enum eeprom_nature {
54/* Each client has this additional data */ 55/* Each client has this additional data */
55struct eeprom_data { 56struct eeprom_data {
56 struct i2c_client client; 57 struct i2c_client client;
57 struct semaphore update_lock; 58 struct mutex update_lock;
58 u8 valid; /* bitfield, bit!=0 if slice is valid */ 59 u8 valid; /* bitfield, bit!=0 if slice is valid */
59 unsigned long last_updated[8]; /* In jiffies, 8 slices */ 60 unsigned long last_updated[8]; /* In jiffies, 8 slices */
60 u8 data[EEPROM_SIZE]; /* Register values */ 61 u8 data[EEPROM_SIZE]; /* Register values */
@@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
81 struct eeprom_data *data = i2c_get_clientdata(client); 82 struct eeprom_data *data = i2c_get_clientdata(client);
82 int i, j; 83 int i, j;
83 84
84 down(&data->update_lock); 85 mutex_lock(&data->update_lock);
85 86
86 if (!(data->valid & (1 << slice)) || 87 if (!(data->valid & (1 << slice)) ||
87 time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { 88 time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
@@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
107 data->valid |= (1 << slice); 108 data->valid |= (1 << slice);
108 } 109 }
109exit: 110exit:
110 up(&data->update_lock); 111 mutex_unlock(&data->update_lock);
111} 112}
112 113
113static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 114static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
187 /* Fill in the remaining client fields */ 188 /* Fill in the remaining client fields */
188 strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); 189 strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
189 data->valid = 0; 190 data->valid = 0;
190 init_MUTEX(&data->update_lock); 191 mutex_init(&data->update_lock);
191 data->nature = UNKNOWN; 192 data->nature = UNKNOWN;
192 193
193 /* Tell the I2C layer a new client has arrived */ 194 /* Tell the I2C layer a new client has arrived */