diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-01-11 10:50:26 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 14:21:49 -0800 |
commit | b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821 (patch) | |
tree | 5375363cc6087d74196efc0ded6dae9a8a4c2ad5 /drivers/i2c | |
parent | 2488a39d233a758d41ab7de70a220bc956f3c96c (diff) | |
download | linux-3.10-b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821.tar.gz linux-3.10-b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821.tar.bz2 linux-3.10-b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821.zip |
[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')
-rw-r--r-- | drivers/i2c/busses/i2c-ali1535.c | 7 | ||||
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 11 | ||||
-rw-r--r-- | drivers/i2c/chips/m41t00.c | 11 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 23 |
4 files changed, 28 insertions, 24 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c index 3eb47890db4..26cf891762b 100644 --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c @@ -62,6 +62,7 @@ #include <linux/ioport.h> #include <linux/i2c.h> #include <linux/init.h> +#include <linux/mutex.h> #include <asm/io.h> #include <asm/semaphore.h> @@ -136,7 +137,7 @@ static struct pci_driver ali1535_driver; static unsigned short ali1535_smba; -static DECLARE_MUTEX(i2c_ali1535_sem); +static DEFINE_MUTEX(i2c_ali1535_mutex); /* Detect whether a ALI1535 can be found, and initialize it, where necessary. Note the differences between kernels with the old PCI BIOS interface and @@ -345,7 +346,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, int timeout; s32 result = 0; - down(&i2c_ali1535_sem); + mutex_lock(&i2c_ali1535_mutex); /* make sure SMBus is idle */ temp = inb_p(SMBHSTSTS); for (timeout = 0; @@ -460,7 +461,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, break; } EXIT: - up(&i2c_ali1535_sem); + mutex_unlock(&i2c_ali1535_mutex); return result; } diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 0710b9da9d5..03d09ed5ec2 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -26,6 +26,7 @@ #include <linux/i2c.h> #include <linux/rtc.h> #include <linux/bcd.h> +#include <linux/mutex.h> #define DS1374_REG_TOD0 0x00 #define DS1374_REG_TOD1 0x01 @@ -41,7 +42,7 @@ #define DS1374_DRV_NAME "ds1374" -static DECLARE_MUTEX(ds1374_mutex); +static DEFINE_MUTEX(ds1374_mutex); static struct i2c_driver ds1374_driver; static struct i2c_client *save_client; @@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void) ulong t1, t2; int limit = 10; /* arbitrary retry limit */ - down(&ds1374_mutex); + mutex_lock(&ds1374_mutex); /* * Since the reads are being performed one byte at a time using @@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void) t2 = ds1374_read_rtc(); } while (t1 != t2 && limit--); - up(&ds1374_mutex); + mutex_unlock(&ds1374_mutex); if (t1 != t2) { dev_warn(&save_client->dev, @@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg) t1 = *(ulong *) arg; - down(&ds1374_mutex); + mutex_lock(&ds1374_mutex); /* * Since the writes are being performed one byte at a time using @@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg) t2 = ds1374_read_rtc(); } while (t1 != t2 && limit--); - up(&ds1374_mutex); + mutex_unlock(&ds1374_mutex); if (t1 != t2) dev_warn(&save_client->dev, diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dc3d48375f..b5aabe7cf79 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -24,13 +24,14 @@ #include <linux/i2c.h> #include <linux/rtc.h> #include <linux/bcd.h> +#include <linux/mutex.h> #include <asm/time.h> #include <asm/rtc.h> #define M41T00_DRV_NAME "m41t00" -static DECLARE_MUTEX(m41t00_mutex); +static DEFINE_MUTEX(m41t00_mutex); static struct i2c_driver m41t00_driver; static struct i2c_client *save_client; @@ -54,7 +55,7 @@ m41t00_get_rtc_time(void) sec = min = hour = day = mon = year = 0; sec1 = min1 = hour1 = day1 = mon1 = year1 = 0; - down(&m41t00_mutex); + mutex_lock(&m41t00_mutex); do { if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0) && ((min = i2c_smbus_read_byte_data(save_client, 1)) @@ -80,7 +81,7 @@ m41t00_get_rtc_time(void) mon1 = mon; year1 = year; } while (--limit > 0); - up(&m41t00_mutex); + mutex_unlock(&m41t00_mutex); if (limit == 0) { dev_warn(&save_client->dev, @@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg) BIN_TO_BCD(tm.tm_mday); BIN_TO_BCD(tm.tm_year); - down(&m41t00_mutex); + mutex_lock(&m41t00_mutex); if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) < 0) @@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg) dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); - up(&m41t00_mutex); + mutex_unlock(&m41t00_mutex); return; } diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 1a2c9ab5d9e..97334433e53 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -31,12 +31,13 @@ #include <linux/idr.h> #include <linux/seq_file.h> #include <linux/platform_device.h> +#include <linux/mutex.h> #include <asm/uaccess.h> static LIST_HEAD(adapters); static LIST_HEAD(drivers); -static DECLARE_MUTEX(core_lists); +static DEFINE_MUTEX(core_lists); static DEFINE_IDR(i2c_adapter_idr); /* match always succeeds, as we want the probe() to tell if we really accept this match */ @@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) struct list_head *item; struct i2c_driver *driver; - down(&core_lists); + mutex_lock(&core_lists); if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { res = -ENOMEM; @@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) } out_unlock: - up(&core_lists); + mutex_unlock(&core_lists); return res; } @@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) struct i2c_client *client; int res = 0; - down(&core_lists); + mutex_lock(&core_lists); /* First make sure that this adapter was ever added */ list_for_each_entry(adap_from_list, &adapters, list) { @@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); out_unlock: - up(&core_lists); + mutex_unlock(&core_lists); return res; } @@ -289,7 +290,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) struct i2c_adapter *adapter; int res = 0; - down(&core_lists); + mutex_lock(&core_lists); /* add the driver to the list of i2c drivers in the driver core */ driver->driver.owner = owner; @@ -311,7 +312,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) } out_unlock: - up(&core_lists); + mutex_unlock(&core_lists); return res; } EXPORT_SYMBOL(i2c_register_driver); @@ -324,7 +325,7 @@ int i2c_del_driver(struct i2c_driver *driver) int res = 0; - down(&core_lists); + mutex_lock(&core_lists); /* Have a look at each adapter, if clients of this driver are still * attached. If so, detach them to be able to kill the driver @@ -363,7 +364,7 @@ int i2c_del_driver(struct i2c_driver *driver) pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); out_unlock: - up(&core_lists); + mutex_unlock(&core_lists); return 0; } @@ -779,12 +780,12 @@ struct i2c_adapter* i2c_get_adapter(int id) { struct i2c_adapter *adapter; - down(&core_lists); + mutex_lock(&core_lists); adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); if (adapter && !try_module_get(adapter->owner)) adapter = NULL; - up(&core_lists); + mutex_unlock(&core_lists); return adapter; } |