Skip to content

Commit

Permalink
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare…
Browse files Browse the repository at this point in the history
…-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
  Add i2c_board_info for RiscPC PCF8583
  i2c: Make sure i2c_algo_bit_data.timeout is HZ-independent
  i2c-dev: Clarify the unit of ioctl I2C_TIMEOUT
  i2c: Timeouts reach -1
  i2c: Fix misplaced parentheses
  • Loading branch information
torvalds committed Feb 24, 2009
2 parents a792cd1 + 531660e commit 21209b6
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 11 deletions.
6 changes: 6 additions & 0 deletions arch/arm/mach-rpc/riscpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/serial_8250.h>
#include <linux/ata_platform.h>
#include <linux/io.h>
#include <linux/i2c.h>

#include <asm/elf.h>
#include <asm/mach-types.h>
Expand Down Expand Up @@ -201,8 +202,13 @@ static struct platform_device *devs[] __initdata = {
&pata_device,
};

static struct i2c_board_info i2c_rtc = {
I2C_BOARD_INFO("pcf8583", 0x50)
};

static int __init rpc_init(void)
{
i2c_register_board_info(0, &i2c_rtc, 1);
return platform_add_devices(devs, ARRAY_SIZE(devs));
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/i2c/busses/i2c-acorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,19 @@ static struct i2c_algo_bit_data ioc_data = {
.getsda = ioc_getsda,
.getscl = ioc_getscl,
.udelay = 80,
.timeout = 100
.timeout = HZ,
};

static struct i2c_adapter ioc_ops = {
.nr = 0,
.algo_data = &ioc_data,
};

static int __init i2c_ioc_init(void)
{
force_ones = FORCE_ONES | SCL | SDA;

return i2c_bit_add_bus(&ioc_ops);
return i2c_bit_add_numbered_bus(&ioc_ops);
}

module_init(i2c_ioc_init);
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-amd8111.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
{
int timeout = 500;

while (timeout-- && (inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_IBF))
while ((inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_IBF) && --timeout)
udelay(1);

if (!timeout) {
Expand All @@ -88,7 +88,7 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
{
int timeout = 500;

while (timeout-- && (~inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_OBF))
while ((~inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_OBF) && --timeout)
udelay(1);

if (!timeout) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-ixp2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static int ixp2000_i2c_probe(struct platform_device *plat_dev)
drv_data->algo_data.getsda = ixp2000_bit_getsda;
drv_data->algo_data.getscl = ixp2000_bit_getscl;
drv_data->algo_data.udelay = 6;
drv_data->algo_data.timeout = 100;
drv_data->algo_data.timeout = HZ;

strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
sizeof(drv_data->adapter.name));
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/i2c-pxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c,

i2c_pxa_start_message(i2c);

while (timeout-- && i2c->msg_num > 0) {
while (i2c->msg_num > 0 && --timeout) {
i2c_pxa_handler(0, i2c);
udelay(10);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/busses/scx200_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static struct i2c_algo_bit_data scx200_i2c_data = {
.getsda = scx200_i2c_getsda,
.getscl = scx200_i2c_getscl,
.udelay = 10,
.timeout = 100,
.timeout = HZ,
};

static struct i2c_adapter scx200_i2c_ops = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
case I2C_SMBUS_QUICK:
msg[0].len = 0;
/* Special case: The read/write field is used as data */
msg[0].flags = flags | (read_write==I2C_SMBUS_READ)?I2C_M_RD:0;
msg[0].flags = flags | (read_write == I2C_SMBUS_READ ?
I2C_M_RD : 0);
num = 1;
break;
case I2C_SMBUS_BYTE:
Expand Down
6 changes: 5 additions & 1 deletion drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/smp_lock.h>
#include <linux/jiffies.h>
#include <asm/uaccess.h>

static struct i2c_driver i2cdev_driver;
Expand Down Expand Up @@ -422,7 +423,10 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
client->adapter->retries = arg;
break;
case I2C_TIMEOUT:
client->adapter->timeout = arg;
/* For historical reasons, user-space sets the timeout
* value in units of 10 ms.
*/
client->adapter->timeout = msecs_to_jiffies(arg * 10);
break;
default:
/* NOTE: returning a fault code here could cause trouble
Expand Down
2 changes: 1 addition & 1 deletion include/linux/i2c-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
#define I2C_RETRIES 0x0701 /* number of times a device address should
be polled when not acknowledging */
#define I2C_TIMEOUT 0x0702 /* set timeout in jiffies - call with int */
#define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */

/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
* are NOT supported! (due to code brokenness)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ struct i2c_adapter {
struct mutex bus_lock;
struct mutex clist_lock;

int timeout;
int timeout; /* in jiffies */
int retries;
struct device dev; /* the adapter device */

Expand Down

0 comments on commit 21209b6

Please sign in to comment.