Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23231
b: refs/heads/master
c: b3585e4
h: refs/heads/master
i:
  23229: f4e95dc
  23227: 6d98bfa
  23223: d456fce
  23215: 3ac8a25
  23199: 1c9f072
  23167: 03c9085
v: v3
  • Loading branch information
Arjan van de Ven authored and Greg Kroah-Hartman committed Mar 23, 2006
1 parent 4e2c886 commit ecfeade
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2488a39d233a758d41ab7de70a220bc956f3c96c
refs/heads/master: b3585e4f5b3e4ddb4d82ae50d0b844f619c6d821
7 changes: 4 additions & 3 deletions trunk/drivers/i2c/busses/i2c-ali1535.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
11 changes: 6 additions & 5 deletions trunk/drivers/i2c/chips/ds1374.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions trunk/drivers/i2c/chips/m41t00.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down
23 changes: 12 additions & 11 deletions trunk/drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
}

out_unlock:
up(&core_lists);
mutex_unlock(&core_lists);
return res;
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ecfeade

Please sign in to comment.