aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/m41t00.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 04:50:26 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:21:49 -0500
commitb3585e4f5b3e4ddb4d82ae50d0b844f619c6d821 (patch)
tree5375363cc6087d74196efc0ded6dae9a8a4c2ad5 /drivers/i2c/chips/m41t00.c
parent2488a39d233a758d41ab7de70a220bc956f3c96c (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/m41t00.c')
-rw-r--r--drivers/i2c/chips/m41t00.c11
1 files changed, 6 insertions, 5 deletions
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
33static DECLARE_MUTEX(m41t00_mutex); 34static DEFINE_MUTEX(m41t00_mutex);
34 35
35static struct i2c_driver m41t00_driver; 36static struct i2c_driver m41t00_driver;
36static struct i2c_client *save_client; 37static 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