aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c13
-rw-r--r--drivers/i2c/busses/i2c-isa.c2
-rw-r--r--drivers/i2c/chips/eeprom.c9
-rw-r--r--drivers/i2c/chips/max6875.c10
-rw-r--r--drivers/i2c/chips/pcf8591.c13
-rw-r--r--drivers/i2c/chips/tps65010.c45
-rw-r--r--drivers/i2c/i2c-core.c34
-rw-r--r--include/linux/i2c.h6
8 files changed, 68 insertions, 64 deletions
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 56c7d987590f..f7b4cb4e9c75 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -38,6 +38,7 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/mutex.h>
41 42
42extern struct i2c_adapter amd756_smbus; 43extern struct i2c_adapter amd756_smbus;
43 44
@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter;
45static struct i2c_algorithm *s4882_algo; 46static struct i2c_algorithm *s4882_algo;
46 47
47/* Wrapper access functions for multiplexed SMBus */ 48/* Wrapper access functions for multiplexed SMBus */
48static struct semaphore amd756_lock; 49static struct mutex amd756_lock;
49 50
50static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr, 51static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
51 unsigned short flags, char read_write, 52 unsigned short flags, char read_write,
@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
59 || addr == 0x18) 60 || addr == 0x18)
60 return -1; 61 return -1;
61 62
62 down(&amd756_lock); 63 mutex_lock(&amd756_lock);
63 64
64 error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write, 65 error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write,
65 command, size, data); 66 command, size, data);
66 67
67 up(&amd756_lock); 68 mutex_unlock(&amd756_lock);
68 69
69 return error; 70 return error;
70} 71}
@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
87 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) 88 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
88 return -1; 89 return -1;
89 90
90 down(&amd756_lock); 91 mutex_lock(&amd756_lock);
91 92
92 if (last_channels != channels) { 93 if (last_channels != channels) {
93 union i2c_smbus_data mplxdata; 94 union i2c_smbus_data mplxdata;
@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
105 command, size, data); 106 command, size, data);
106 107
107UNLOCK: 108UNLOCK:
108 up(&amd756_lock); 109 mutex_unlock(&amd756_lock);
109 return error; 110 return error;
110} 111}
111 112
@@ -166,7 +167,7 @@ static int __init amd756_s4882_init(void)
166 } 167 }
167 168
168 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); 169 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
169 init_MUTEX(&amd756_lock); 170 mutex_init(&amd756_lock);
170 171
171 /* Define the 5 virtual adapters and algorithms structures */ 172 /* Define the 5 virtual adapters and algorithms structures */
172 if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), 173 if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 4344ae6b1fcb..c3e1d3e888d7 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
125 125
126static int __init i2c_isa_init(void) 126static int __init i2c_isa_init(void)
127{ 127{
128 init_MUTEX(&isa_adapter.clist_lock); 128 mutex_init(&isa_adapter.clist_lock);
129 INIT_LIST_HEAD(&isa_adapter.clients); 129 INIT_LIST_HEAD(&isa_adapter.clients);
130 130
131 isa_adapter.nr = ANY_I2C_ISA_BUS; 131 isa_adapter.nr = ANY_I2C_ISA_BUS;
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 */
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 6d3ff584155e..88d2ddee4490 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -31,7 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <asm/semaphore.h> 34#include <linux/mutex.h>
35 35
36/* Do not scan - the MAX6875 access method will write to some EEPROM chips */ 36/* Do not scan - the MAX6875 access method will write to some EEPROM chips */
37static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 37static unsigned short normal_i2c[] = {I2C_CLIENT_END};
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875);
54/* Each client has this additional data */ 54/* Each client has this additional data */
55struct max6875_data { 55struct max6875_data {
56 struct i2c_client client; 56 struct i2c_client client;
57 struct semaphore update_lock; 57 struct mutex update_lock;
58 58
59 u32 valid; 59 u32 valid;
60 u8 data[USER_EEPROM_SIZE]; 60 u8 data[USER_EEPROM_SIZE];
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
83 if (slice >= USER_EEPROM_SLICES) 83 if (slice >= USER_EEPROM_SLICES)
84 return; 84 return;
85 85
86 down(&data->update_lock); 86 mutex_lock(&data->update_lock);
87 87
88 buf = &data->data[slice << SLICE_BITS]; 88 buf = &data->data[slice << SLICE_BITS];
89 89
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
122 data->valid |= (1 << slice); 122 data->valid |= (1 << slice);
123 } 123 }
124exit_up: 124exit_up:
125 up(&data->update_lock); 125 mutex_unlock(&data->update_lock);
126} 126}
127 127
128static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, 128static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
@@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
196 real_client->driver = &max6875_driver; 196 real_client->driver = &max6875_driver;
197 real_client->flags = 0; 197 real_client->flags = 0;
198 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); 198 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
199 init_MUTEX(&data->update_lock); 199 mutex_init(&data->update_lock);
200 200
201 /* Init fake client data */ 201 /* Init fake client data */
202 /* set the client data to the i2c_client so that it will get freed */ 202 /* set the client data to the i2c_client so that it will get freed */
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 36cff09c678d..925a6b371fd2 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/mutex.h>
27 28
28/* Addresses to scan */ 29/* Addresses to scan */
29static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 30static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode,
74 75
75struct pcf8591_data { 76struct pcf8591_data {
76 struct i2c_client client; 77 struct i2c_client client;
77 struct semaphore update_lock; 78 struct mutex update_lock;
78 79
79 u8 control; 80 u8 control;
80 u8 aout; 81 u8 aout;
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
144 struct pcf8591_data *data = i2c_get_clientdata(client); 145 struct pcf8591_data *data = i2c_get_clientdata(client);
145 unsigned long val = simple_strtoul(buf, NULL, 10); 146 unsigned long val = simple_strtoul(buf, NULL, 10);
146 147
147 down(&data->update_lock); 148 mutex_lock(&data->update_lock);
148 if (val) 149 if (val)
149 data->control |= PCF8591_CONTROL_AOEF; 150 data->control |= PCF8591_CONTROL_AOEF;
150 else 151 else
151 data->control &= ~PCF8591_CONTROL_AOEF; 152 data->control &= ~PCF8591_CONTROL_AOEF;
152 i2c_smbus_write_byte(client, data->control); 153 i2c_smbus_write_byte(client, data->control);
153 up(&data->update_lock); 154 mutex_unlock(&data->update_lock);
154 return count; 155 return count;
155} 156}
156 157
@@ -200,7 +201,7 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
200 /* Fill in the remaining client fields and put it into the global 201 /* Fill in the remaining client fields and put it into the global
201 list */ 202 list */
202 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); 203 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE);
203 init_MUTEX(&data->update_lock); 204 mutex_init(&data->update_lock);
204 205
205 /* Tell the I2C layer a new client has arrived */ 206 /* Tell the I2C layer a new client has arrived */
206 if ((err = i2c_attach_client(new_client))) 207 if ((err = i2c_attach_client(new_client)))
@@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
265 struct i2c_client *client = to_i2c_client(dev); 266 struct i2c_client *client = to_i2c_client(dev);
266 struct pcf8591_data *data = i2c_get_clientdata(client); 267 struct pcf8591_data *data = i2c_get_clientdata(client);
267 268
268 down(&data->update_lock); 269 mutex_lock(&data->update_lock);
269 270
270 if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) { 271 if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
271 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) 272 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
@@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
278 } 279 }
279 value = i2c_smbus_read_byte(client); 280 value = i2c_smbus_read_byte(client);
280 281
281 up(&data->update_lock); 282 mutex_unlock(&data->update_lock);
282 283
283 if ((channel == 2 && input_mode == 2) || 284 if ((channel == 2 && input_mode == 2) ||
284 (channel != 3 && (input_mode == 1 || input_mode == 3))) 285 (channel != 3 && (input_mode == 1 || input_mode == 3)))
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 1af3dfbb8086..179b1e022d80 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -32,6 +32,7 @@
32#include <linux/suspend.h> 32#include <linux/suspend.h>
33#include <linux/debugfs.h> 33#include <linux/debugfs.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/mutex.h>
35 36
36#include <asm/irq.h> 37#include <asm/irq.h>
37#include <asm/mach-types.h> 38#include <asm/mach-types.h>
@@ -81,7 +82,7 @@ enum tps_model {
81 82
82struct tps65010 { 83struct tps65010 {
83 struct i2c_client client; 84 struct i2c_client client;
84 struct semaphore lock; 85 struct mutex lock;
85 int irq; 86 int irq;
86 struct work_struct work; 87 struct work_struct work;
87 struct dentry *file; 88 struct dentry *file;
@@ -218,7 +219,7 @@ static int dbg_show(struct seq_file *s, void *_)
218 seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", 219 seq_printf(s, "driver %s\nversion %s\nchip %s\n\n",
219 DRIVER_NAME, DRIVER_VERSION, chip); 220 DRIVER_NAME, DRIVER_VERSION, chip);
220 221
221 down(&tps->lock); 222 mutex_lock(&tps->lock);
222 223
223 /* FIXME how can we tell whether a battery is present? 224 /* FIXME how can we tell whether a battery is present?
224 * likely involves a charge gauging chip (like BQ26501). 225 * likely involves a charge gauging chip (like BQ26501).
@@ -300,7 +301,7 @@ static int dbg_show(struct seq_file *s, void *_)
300 (v2 & (1 << (4 + i))) ? "rising" : "falling"); 301 (v2 & (1 << (4 + i))) ? "rising" : "falling");
301 } 302 }
302 303
303 up(&tps->lock); 304 mutex_unlock(&tps->lock);
304 return 0; 305 return 0;
305} 306}
306 307
@@ -416,7 +417,7 @@ static void tps65010_work(void *_tps)
416{ 417{
417 struct tps65010 *tps = _tps; 418 struct tps65010 *tps = _tps;
418 419
419 down(&tps->lock); 420 mutex_lock(&tps->lock);
420 421
421 tps65010_interrupt(tps); 422 tps65010_interrupt(tps);
422 423
@@ -444,7 +445,7 @@ static void tps65010_work(void *_tps)
444 if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) 445 if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
445 enable_irq(tps->irq); 446 enable_irq(tps->irq);
446 447
447 up(&tps->lock); 448 mutex_unlock(&tps->lock);
448} 449}
449 450
450static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) 451static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)
@@ -505,7 +506,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
505 if (!tps) 506 if (!tps)
506 return 0; 507 return 0;
507 508
508 init_MUTEX(&tps->lock); 509 mutex_init(&tps->lock);
509 INIT_WORK(&tps->work, tps65010_work, tps); 510 INIT_WORK(&tps->work, tps65010_work, tps);
510 tps->irq = -1; 511 tps->irq = -1;
511 tps->client.addr = address; 512 tps->client.addr = address;
@@ -695,7 +696,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
695 if ((gpio < GPIO1) || (gpio > GPIO4)) 696 if ((gpio < GPIO1) || (gpio > GPIO4))
696 return -EINVAL; 697 return -EINVAL;
697 698
698 down(&the_tps->lock); 699 mutex_lock(&the_tps->lock);
699 700
700 defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); 701 defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);
701 702
@@ -720,7 +721,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
720 gpio, value ? "high" : "low", 721 gpio, value ? "high" : "low",
721 i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); 722 i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));
722 723
723 up(&the_tps->lock); 724 mutex_unlock(&the_tps->lock);
724 return status; 725 return status;
725} 726}
726EXPORT_SYMBOL(tps65010_set_gpio_out_value); 727EXPORT_SYMBOL(tps65010_set_gpio_out_value);
@@ -745,7 +746,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
745 led = LED2; 746 led = LED2;
746 } 747 }
747 748
748 down(&the_tps->lock); 749 mutex_lock(&the_tps->lock);
749 750
750 pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, 751 pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
751 i2c_smbus_read_byte_data(&the_tps->client, 752 i2c_smbus_read_byte_data(&the_tps->client,
@@ -771,7 +772,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
771 default: 772 default:
772 printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", 773 printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
773 DRIVER_NAME); 774 DRIVER_NAME);
774 up(&the_tps->lock); 775 mutex_unlock(&the_tps->lock);
775 return -EINVAL; 776 return -EINVAL;
776 } 777 }
777 778
@@ -781,7 +782,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
781 if (status != 0) { 782 if (status != 0) {
782 printk(KERN_ERR "%s: Failed to write led%i_on register\n", 783 printk(KERN_ERR "%s: Failed to write led%i_on register\n",
783 DRIVER_NAME, led); 784 DRIVER_NAME, led);
784 up(&the_tps->lock); 785 mutex_unlock(&the_tps->lock);
785 return status; 786 return status;
786 } 787 }
787 788
@@ -794,7 +795,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
794 if (status != 0) { 795 if (status != 0) {
795 printk(KERN_ERR "%s: Failed to write led%i_per register\n", 796 printk(KERN_ERR "%s: Failed to write led%i_per register\n",
796 DRIVER_NAME, led); 797 DRIVER_NAME, led);
797 up(&the_tps->lock); 798 mutex_unlock(&the_tps->lock);
798 return status; 799 return status;
799 } 800 }
800 801
@@ -802,7 +803,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
802 i2c_smbus_read_byte_data(&the_tps->client, 803 i2c_smbus_read_byte_data(&the_tps->client,
803 TPS_LED1_PER + offs)); 804 TPS_LED1_PER + offs));
804 805
805 up(&the_tps->lock); 806 mutex_unlock(&the_tps->lock);
806 807
807 return status; 808 return status;
808} 809}
@@ -820,7 +821,7 @@ int tps65010_set_vib(unsigned value)
820 if (!the_tps) 821 if (!the_tps)
821 return -ENODEV; 822 return -ENODEV;
822 823
823 down(&the_tps->lock); 824 mutex_lock(&the_tps->lock);
824 825
825 vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); 826 vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);
826 vdcdc2 &= ~(1 << 1); 827 vdcdc2 &= ~(1 << 1);
@@ -831,7 +832,7 @@ int tps65010_set_vib(unsigned value)
831 832
832 pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); 833 pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
833 834
834 up(&the_tps->lock); 835 mutex_unlock(&the_tps->lock);
835 return status; 836 return status;
836} 837}
837EXPORT_SYMBOL(tps65010_set_vib); 838EXPORT_SYMBOL(tps65010_set_vib);
@@ -848,7 +849,7 @@ int tps65010_set_low_pwr(unsigned mode)
848 if (!the_tps) 849 if (!the_tps)
849 return -ENODEV; 850 return -ENODEV;
850 851
851 down(&the_tps->lock); 852 mutex_lock(&the_tps->lock);
852 853
853 pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, 854 pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
854 mode ? "enable" : "disable", 855 mode ? "enable" : "disable",
@@ -876,7 +877,7 @@ int tps65010_set_low_pwr(unsigned mode)
876 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 877 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
877 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 878 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
878 879
879 up(&the_tps->lock); 880 mutex_unlock(&the_tps->lock);
880 881
881 return status; 882 return status;
882} 883}
@@ -894,7 +895,7 @@ int tps65010_config_vregs1(unsigned value)
894 if (!the_tps) 895 if (!the_tps)
895 return -ENODEV; 896 return -ENODEV;
896 897
897 down(&the_tps->lock); 898 mutex_lock(&the_tps->lock);
898 899
899 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 900 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
900 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 901 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
@@ -909,7 +910,7 @@ int tps65010_config_vregs1(unsigned value)
909 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 910 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
910 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 911 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
911 912
912 up(&the_tps->lock); 913 mutex_unlock(&the_tps->lock);
913 914
914 return status; 915 return status;
915} 916}
@@ -931,7 +932,7 @@ int tps65013_set_low_pwr(unsigned mode)
931 if (!the_tps || the_tps->por) 932 if (!the_tps || the_tps->por)
932 return -ENODEV; 933 return -ENODEV;
933 934
934 down(&the_tps->lock); 935 mutex_lock(&the_tps->lock);
935 936
936 pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", 937 pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
937 DRIVER_NAME, 938 DRIVER_NAME,
@@ -959,7 +960,7 @@ int tps65013_set_low_pwr(unsigned mode)
959 if (status != 0) { 960 if (status != 0) {
960 printk(KERN_ERR "%s: Failed to write chconfig register\n", 961 printk(KERN_ERR "%s: Failed to write chconfig register\n",
961 DRIVER_NAME); 962 DRIVER_NAME);
962 up(&the_tps->lock); 963 mutex_unlock(&the_tps->lock);
963 return status; 964 return status;
964 } 965 }
965 966
@@ -977,7 +978,7 @@ int tps65013_set_low_pwr(unsigned mode)
977 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 978 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
978 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 979 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
979 980
980 up(&the_tps->lock); 981 mutex_unlock(&the_tps->lock);
981 982
982 return status; 983 return status;
983} 984}
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2b0c555aa011..975cb647da10 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -169,8 +169,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
169 } 169 }
170 170
171 adap->nr = id & MAX_ID_MASK; 171 adap->nr = id & MAX_ID_MASK;
172 init_MUTEX(&adap->bus_lock); 172 mutex_init(&adap->bus_lock);
173 init_MUTEX(&adap->clist_lock); 173 mutex_init(&adap->clist_lock);
174 list_add_tail(&adap->list,&adapters); 174 list_add_tail(&adap->list,&adapters);
175 INIT_LIST_HEAD(&adap->clients); 175 INIT_LIST_HEAD(&adap->clients);
176 176
@@ -385,9 +385,9 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr)
385{ 385{
386 int rval; 386 int rval;
387 387
388 down(&adapter->clist_lock); 388 mutex_lock(&adapter->clist_lock);
389 rval = __i2c_check_addr(adapter, addr); 389 rval = __i2c_check_addr(adapter, addr);
390 up(&adapter->clist_lock); 390 mutex_unlock(&adapter->clist_lock);
391 391
392 return rval; 392 return rval;
393} 393}
@@ -396,13 +396,13 @@ int i2c_attach_client(struct i2c_client *client)
396{ 396{
397 struct i2c_adapter *adapter = client->adapter; 397 struct i2c_adapter *adapter = client->adapter;
398 398
399 down(&adapter->clist_lock); 399 mutex_lock(&adapter->clist_lock);
400 if (__i2c_check_addr(client->adapter, client->addr)) { 400 if (__i2c_check_addr(client->adapter, client->addr)) {
401 up(&adapter->clist_lock); 401 mutex_unlock(&adapter->clist_lock);
402 return -EBUSY; 402 return -EBUSY;
403 } 403 }
404 list_add_tail(&client->list,&adapter->clients); 404 list_add_tail(&client->list,&adapter->clients);
405 up(&adapter->clist_lock); 405 mutex_unlock(&adapter->clist_lock);
406 406
407 if (adapter->client_register) { 407 if (adapter->client_register) {
408 if (adapter->client_register(client)) { 408 if (adapter->client_register(client)) {
@@ -451,12 +451,12 @@ int i2c_detach_client(struct i2c_client *client)
451 } 451 }
452 } 452 }
453 453
454 down(&adapter->clist_lock); 454 mutex_lock(&adapter->clist_lock);
455 list_del(&client->list); 455 list_del(&client->list);
456 init_completion(&client->released); 456 init_completion(&client->released);
457 device_remove_file(&client->dev, &dev_attr_client_name); 457 device_remove_file(&client->dev, &dev_attr_client_name);
458 device_unregister(&client->dev); 458 device_unregister(&client->dev);
459 up(&adapter->clist_lock); 459 mutex_unlock(&adapter->clist_lock);
460 wait_for_completion(&client->released); 460 wait_for_completion(&client->released);
461 461
462 out: 462 out:
@@ -514,19 +514,19 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
514 struct list_head *item; 514 struct list_head *item;
515 struct i2c_client *client; 515 struct i2c_client *client;
516 516
517 down(&adap->clist_lock); 517 mutex_lock(&adap->clist_lock);
518 list_for_each(item,&adap->clients) { 518 list_for_each(item,&adap->clients) {
519 client = list_entry(item, struct i2c_client, list); 519 client = list_entry(item, struct i2c_client, list);
520 if (!try_module_get(client->driver->driver.owner)) 520 if (!try_module_get(client->driver->driver.owner))
521 continue; 521 continue;
522 if (NULL != client->driver->command) { 522 if (NULL != client->driver->command) {
523 up(&adap->clist_lock); 523 mutex_unlock(&adap->clist_lock);
524 client->driver->command(client,cmd,arg); 524 client->driver->command(client,cmd,arg);
525 down(&adap->clist_lock); 525 mutex_lock(&adap->clist_lock);
526 } 526 }
527 module_put(client->driver->driver.owner); 527 module_put(client->driver->driver.owner);
528 } 528 }
529 up(&adap->clist_lock); 529 mutex_unlock(&adap->clist_lock);
530} 530}
531 531
532static int __init i2c_init(void) 532static int __init i2c_init(void)
@@ -570,9 +570,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
570 } 570 }
571#endif 571#endif
572 572
573 down(&adap->bus_lock); 573 mutex_lock(&adap->bus_lock);
574 ret = adap->algo->master_xfer(adap,msgs,num); 574 ret = adap->algo->master_xfer(adap,msgs,num);
575 up(&adap->bus_lock); 575 mutex_unlock(&adap->bus_lock);
576 576
577 return ret; 577 return ret;
578 } else { 578 } else {
@@ -1116,10 +1116,10 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1116 flags &= I2C_M_TEN | I2C_CLIENT_PEC; 1116 flags &= I2C_M_TEN | I2C_CLIENT_PEC;
1117 1117
1118 if (adapter->algo->smbus_xfer) { 1118 if (adapter->algo->smbus_xfer) {
1119 down(&adapter->bus_lock); 1119 mutex_lock(&adapter->bus_lock);
1120 res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, 1120 res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write,
1121 command,size,data); 1121 command,size,data);
1122 up(&adapter->bus_lock); 1122 mutex_unlock(&adapter->bus_lock);
1123 } else 1123 } else
1124 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, 1124 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
1125 command,size,data); 1125 command,size,data);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 63f1d63cc1d8..1635ee25918f 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -32,7 +32,7 @@
32#include <linux/mod_devicetable.h> 32#include <linux/mod_devicetable.h>
33#include <linux/device.h> /* for struct device */ 33#include <linux/device.h> /* for struct device */
34#include <linux/sched.h> /* for completion */ 34#include <linux/sched.h> /* for completion */
35#include <asm/semaphore.h> 35#include <linux/mutex.h>
36 36
37/* --- For i2c-isa ---------------------------------------------------- */ 37/* --- For i2c-isa ---------------------------------------------------- */
38 38
@@ -225,8 +225,8 @@ struct i2c_adapter {
225 int (*client_unregister)(struct i2c_client *); 225 int (*client_unregister)(struct i2c_client *);
226 226
227 /* data fields that are valid for all devices */ 227 /* data fields that are valid for all devices */
228 struct semaphore bus_lock; 228 struct mutex bus_lock;
229 struct semaphore clist_lock; 229 struct mutex clist_lock;
230 230
231 int timeout; 231 int timeout;
232 int retries; 232 int retries;