diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-01-11 04:50:26 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:21:49 -0500 |
commit | b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821 (patch) | |
tree | 5375363cc6087d74196efc0ded6dae9a8a4c2ad5 /drivers/i2c/chips | |
parent | 2488a39d233a758d41ab7de70a220bc956f3c96c (diff) |
[PATCH] I2C: Convert i2c to mutexes
The patch below converts a few i2c semaphores to mutexes
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/chips')
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 11 | ||||
-rw-r--r-- | drivers/i2c/chips/m41t00.c | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0710b9da9d54..03d09ed5ec2c 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
27 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
28 | #include <linux/bcd.h> | 28 | #include <linux/bcd.h> |
29 | #include <linux/mutex.h> | ||
29 | 30 | ||
30 | #define DS1374_REG_TOD0 0x00 | 31 | #define DS1374_REG_TOD0 0x00 |
31 | #define DS1374_REG_TOD1 0x01 | 32 | #define DS1374_REG_TOD1 0x01 |
@@ -41,7 +42,7 @@ | |||
41 | 42 | ||
42 | #define DS1374_DRV_NAME "ds1374" | 43 | #define DS1374_DRV_NAME "ds1374" |
43 | 44 | ||
44 | static DECLARE_MUTEX(ds1374_mutex); | 45 | static DEFINE_MUTEX(ds1374_mutex); |
45 | 46 | ||
46 | static struct i2c_driver ds1374_driver; | 47 | static struct i2c_driver ds1374_driver; |
47 | static struct i2c_client *save_client; | 48 | static struct i2c_client *save_client; |
@@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void) | |||
114 | ulong t1, t2; | 115 | ulong t1, t2; |
115 | int limit = 10; /* arbitrary retry limit */ | 116 | int limit = 10; /* arbitrary retry limit */ |
116 | 117 | ||
117 | down(&ds1374_mutex); | 118 | mutex_lock(&ds1374_mutex); |
118 | 119 | ||
119 | /* | 120 | /* |
120 | * Since the reads are being performed one byte at a time using | 121 | * Since the reads are being performed one byte at a time using |
@@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void) | |||
127 | t2 = ds1374_read_rtc(); | 128 | t2 = ds1374_read_rtc(); |
128 | } while (t1 != t2 && limit--); | 129 | } while (t1 != t2 && limit--); |
129 | 130 | ||
130 | up(&ds1374_mutex); | 131 | mutex_unlock(&ds1374_mutex); |
131 | 132 | ||
132 | if (t1 != t2) { | 133 | if (t1 != t2) { |
133 | dev_warn(&save_client->dev, | 134 | dev_warn(&save_client->dev, |
@@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg) | |||
145 | 146 | ||
146 | t1 = *(ulong *) arg; | 147 | t1 = *(ulong *) arg; |
147 | 148 | ||
148 | down(&ds1374_mutex); | 149 | mutex_lock(&ds1374_mutex); |
149 | 150 | ||
150 | /* | 151 | /* |
151 | * Since the writes are being performed one byte at a time using | 152 | * Since the writes are being performed one byte at a time using |
@@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg) | |||
158 | t2 = ds1374_read_rtc(); | 159 | t2 = ds1374_read_rtc(); |
159 | } while (t1 != t2 && limit--); | 160 | } while (t1 != t2 && limit--); |
160 | 161 | ||
161 | up(&ds1374_mutex); | 162 | mutex_unlock(&ds1374_mutex); |
162 | 163 | ||
163 | if (t1 != t2) | 164 | if (t1 != t2) |
164 | dev_warn(&save_client->dev, | 165 | dev_warn(&save_client->dev, |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dc3d48375fc..b5aabe7cf792 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -24,13 +24,14 @@ | |||
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/rtc.h> | 25 | #include <linux/rtc.h> |
26 | #include <linux/bcd.h> | 26 | #include <linux/bcd.h> |
27 | #include <linux/mutex.h> | ||
27 | 28 | ||
28 | #include <asm/time.h> | 29 | #include <asm/time.h> |
29 | #include <asm/rtc.h> | 30 | #include <asm/rtc.h> |
30 | 31 | ||
31 | #define M41T00_DRV_NAME "m41t00" | 32 | #define M41T00_DRV_NAME "m41t00" |
32 | 33 | ||
33 | static DECLARE_MUTEX(m41t00_mutex); | 34 | static DEFINE_MUTEX(m41t00_mutex); |
34 | 35 | ||
35 | static struct i2c_driver m41t00_driver; | 36 | static struct i2c_driver m41t00_driver; |
36 | static struct i2c_client *save_client; | 37 | static struct i2c_client *save_client; |
@@ -54,7 +55,7 @@ m41t00_get_rtc_time(void) | |||
54 | sec = min = hour = day = mon = year = 0; | 55 | sec = min = hour = day = mon = year = 0; |
55 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; | 56 | sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; |
56 | 57 | ||
57 | down(&m41t00_mutex); | 58 | mutex_lock(&m41t00_mutex); |
58 | do { | 59 | do { |
59 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) | 60 | if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) |
60 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) | 61 | && ((min = i2c_smbus_read_byte_data(save_client, 1)) |
@@ -80,7 +81,7 @@ m41t00_get_rtc_time(void) | |||
80 | mon1 = mon; | 81 | mon1 = mon; |
81 | year1 = year; | 82 | year1 = year; |
82 | } while (--limit > 0); | 83 | } while (--limit > 0); |
83 | up(&m41t00_mutex); | 84 | mutex_unlock(&m41t00_mutex); |
84 | 85 | ||
85 | if (limit == 0) { | 86 | if (limit == 0) { |
86 | dev_warn(&save_client->dev, | 87 | dev_warn(&save_client->dev, |
@@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg) | |||
125 | BIN_TO_BCD(tm.tm_mday); | 126 | BIN_TO_BCD(tm.tm_mday); |
126 | BIN_TO_BCD(tm.tm_year); | 127 | BIN_TO_BCD(tm.tm_year); |
127 | 128 | ||
128 | down(&m41t00_mutex); | 129 | mutex_lock(&m41t00_mutex); |
129 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) | 130 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) |
130 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) | 131 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) |
131 | < 0) | 132 | < 0) |
@@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg) | |||
140 | 141 | ||
141 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); | 142 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); |
142 | 143 | ||
143 | up(&m41t00_mutex); | 144 | mutex_unlock(&m41t00_mutex); |
144 | return; | 145 | return; |
145 | } | 146 | } |
146 | 147 | ||