mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-04 13:21:45 +00:00
i2c: Whitespace cleanups
Remove extraneous whitespace from various i2c headers and core files, like space-before-tab and whitespace at end of line. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
2c003e8e1c
commit
438d6c2c01
6 changed files with 89 additions and 89 deletions
|
@ -127,7 +127,7 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att
|
||||||
return sprintf(buf, "%s\n", client->name);
|
return sprintf(buf, "%s\n", client->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't use the DEVICE_ATTR() macro here as we want the same filename for a
|
* We can't use the DEVICE_ATTR() macro here as we want the same filename for a
|
||||||
* different type of a device. So beware if the DEVICE_ATTR() macro ever
|
* different type of a device. So beware if the DEVICE_ATTR() macro ever
|
||||||
* changes, this definition will also have to change.
|
* changes, this definition will also have to change.
|
||||||
|
@ -139,8 +139,8 @@ static struct device_attribute dev_attr_client_name = {
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------
|
/* ---------------------------------------------------
|
||||||
* registering functions
|
* registering functions
|
||||||
* ---------------------------------------------------
|
* ---------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* -----
|
/* -----
|
||||||
|
@ -314,7 +314,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
|
||||||
res = driver_register(&driver->driver);
|
res = driver_register(&driver->driver);
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
mutex_lock(&core_lists);
|
mutex_lock(&core_lists);
|
||||||
|
|
||||||
list_add_tail(&driver->list,&drivers);
|
list_add_tail(&driver->list,&drivers);
|
||||||
|
@ -338,13 +338,13 @@ int i2c_del_driver(struct i2c_driver *driver)
|
||||||
struct list_head *item1, *item2, *_n;
|
struct list_head *item1, *item2, *_n;
|
||||||
struct i2c_client *client;
|
struct i2c_client *client;
|
||||||
struct i2c_adapter *adap;
|
struct i2c_adapter *adap;
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
mutex_lock(&core_lists);
|
mutex_lock(&core_lists);
|
||||||
|
|
||||||
/* Have a look at each adapter, if clients of this driver are still
|
/* 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
|
* attached. If so, detach them to be able to kill the driver
|
||||||
* afterwards.
|
* afterwards.
|
||||||
*/
|
*/
|
||||||
list_for_each(item1,&adapters) {
|
list_for_each(item1,&adapters) {
|
||||||
|
@ -419,14 +419,14 @@ int i2c_attach_client(struct i2c_client *client)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
list_add_tail(&client->list,&adapter->clients);
|
list_add_tail(&client->list,&adapter->clients);
|
||||||
|
|
||||||
client->usage_count = 0;
|
client->usage_count = 0;
|
||||||
|
|
||||||
client->dev.parent = &client->adapter->dev;
|
client->dev.parent = &client->adapter->dev;
|
||||||
client->dev.driver = &client->driver->driver;
|
client->dev.driver = &client->driver->driver;
|
||||||
client->dev.bus = &i2c_bus_type;
|
client->dev.bus = &i2c_bus_type;
|
||||||
client->dev.release = &i2c_client_release;
|
client->dev.release = &i2c_client_release;
|
||||||
|
|
||||||
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
|
snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
|
||||||
"%d-%04x", i2c_adapter_id(adapter), client->addr);
|
"%d-%04x", i2c_adapter_id(adapter), client->addr);
|
||||||
dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
|
dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
|
||||||
|
@ -467,7 +467,7 @@ int i2c_detach_client(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct i2c_adapter *adapter = client->adapter;
|
struct i2c_adapter *adapter = client->adapter;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (client->usage_count > 0) {
|
if (client->usage_count > 0) {
|
||||||
dev_warn(&client->dev, "Client [%s] still busy, "
|
dev_warn(&client->dev, "Client [%s] still busy, "
|
||||||
"can't detach\n", client->name);
|
"can't detach\n", client->name);
|
||||||
|
@ -535,10 +535,10 @@ int i2c_release_client(struct i2c_client *client)
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
client->usage_count--;
|
client->usage_count--;
|
||||||
i2c_dec_use_client(client);
|
i2c_dec_use_client(client);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
|
||||||
msg.flags = client->flags & I2C_M_TEN;
|
msg.flags = client->flags & I2C_M_TEN;
|
||||||
msg.len = count;
|
msg.len = count;
|
||||||
msg.buf = (char *)buf;
|
msg.buf = (char *)buf;
|
||||||
|
|
||||||
ret = i2c_transfer(adap, &msg, 1);
|
ret = i2c_transfer(adap, &msg, 1);
|
||||||
|
|
||||||
/* If everything went ok (i.e. 1 msg transmitted), return #bytes
|
/* If everything went ok (i.e. 1 msg transmitted), return #bytes
|
||||||
|
@ -757,7 +757,7 @@ int i2c_probe(struct i2c_adapter *adapter,
|
||||||
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
|
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
|
||||||
if (address_data->probe[0] == I2C_CLIENT_END
|
if (address_data->probe[0] == I2C_CLIENT_END
|
||||||
&& address_data->normal_i2c[0] == I2C_CLIENT_END)
|
&& address_data->normal_i2c[0] == I2C_CLIENT_END)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dev_warn(&adapter->dev, "SMBus Quick command not supported, "
|
dev_warn(&adapter->dev, "SMBus Quick command not supported, "
|
||||||
"can't probe for chips\n");
|
"can't probe for chips\n");
|
||||||
|
@ -817,7 +817,7 @@ int i2c_probe(struct i2c_adapter *adapter,
|
||||||
struct i2c_adapter* i2c_get_adapter(int id)
|
struct i2c_adapter* i2c_get_adapter(int id)
|
||||||
{
|
{
|
||||||
struct i2c_adapter *adapter;
|
struct i2c_adapter *adapter;
|
||||||
|
|
||||||
mutex_lock(&core_lists);
|
mutex_lock(&core_lists);
|
||||||
adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
|
adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
|
||||||
if (adapter && !try_module_get(adapter->owner))
|
if (adapter && !try_module_get(adapter->owner))
|
||||||
|
@ -834,14 +834,14 @@ void i2c_put_adapter(struct i2c_adapter *adap)
|
||||||
|
|
||||||
/* The SMBus parts */
|
/* The SMBus parts */
|
||||||
|
|
||||||
#define POLY (0x1070U << 3)
|
#define POLY (0x1070U << 3)
|
||||||
static u8
|
static u8
|
||||||
crc8(u16 data)
|
crc8(u16 data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 8; i++) {
|
for(i = 0; i < 8; i++) {
|
||||||
if (data & 0x8000)
|
if (data & 0x8000)
|
||||||
data = data ^ POLY;
|
data = data ^ POLY;
|
||||||
data = data << 1;
|
data = data << 1;
|
||||||
}
|
}
|
||||||
|
@ -891,13 +891,13 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
|
||||||
rpec, cpec);
|
rpec, cpec);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value)
|
s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value)
|
||||||
{
|
{
|
||||||
return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
|
return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
|
||||||
value,0,I2C_SMBUS_QUICK,NULL);
|
value,0,I2C_SMBUS_QUICK,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 i2c_smbus_read_byte(struct i2c_client *client)
|
s32 i2c_smbus_read_byte(struct i2c_client *client)
|
||||||
|
@ -996,11 +996,11 @@ s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
|
||||||
I2C_SMBUS_I2C_BLOCK_DATA, &data);
|
I2C_SMBUS_I2C_BLOCK_DATA, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simulate a SMBus command using the i2c protocol
|
/* Simulate a SMBus command using the i2c protocol
|
||||||
No checking of parameters is done! */
|
No checking of parameters is done! */
|
||||||
static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
||||||
unsigned short flags,
|
unsigned short flags,
|
||||||
char read_write, u8 command, int size,
|
char read_write, u8 command, int size,
|
||||||
union i2c_smbus_data * data)
|
union i2c_smbus_data * data)
|
||||||
{
|
{
|
||||||
/* So we need to generate a series of msgs. In the case of writing, we
|
/* So we need to generate a series of msgs. In the case of writing, we
|
||||||
|
@ -1010,7 +1010,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
||||||
unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
|
unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
|
||||||
unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
|
unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
|
||||||
int num = read_write == I2C_SMBUS_READ?2:1;
|
int num = read_write == I2C_SMBUS_READ?2:1;
|
||||||
struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
|
struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
|
||||||
{ addr, flags | I2C_M_RD, 0, msgbuf1 }
|
{ addr, flags | I2C_M_RD, 0, msgbuf1 }
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
@ -1103,14 +1103,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
||||||
if (i) {
|
if (i) {
|
||||||
/* Compute PEC if first message is a write */
|
/* Compute PEC if first message is a write */
|
||||||
if (!(msg[0].flags & I2C_M_RD)) {
|
if (!(msg[0].flags & I2C_M_RD)) {
|
||||||
if (num == 1) /* Write only */
|
if (num == 1) /* Write only */
|
||||||
i2c_smbus_add_pec(&msg[0]);
|
i2c_smbus_add_pec(&msg[0]);
|
||||||
else /* Write followed by read */
|
else /* Write followed by read */
|
||||||
partial_pec = i2c_smbus_msg_pec(0, &msg[0]);
|
partial_pec = i2c_smbus_msg_pec(0, &msg[0]);
|
||||||
}
|
}
|
||||||
/* Ask for PEC if last message is a read */
|
/* Ask for PEC if last message is a read */
|
||||||
if (msg[num-1].flags & I2C_M_RD)
|
if (msg[num-1].flags & I2C_M_RD)
|
||||||
msg[num-1].len++;
|
msg[num-1].len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i2c_transfer(adapter, msg, num) < 0)
|
if (i2c_transfer(adapter, msg, num) < 0)
|
||||||
|
@ -1130,7 +1130,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
||||||
case I2C_SMBUS_BYTE_DATA:
|
case I2C_SMBUS_BYTE_DATA:
|
||||||
data->byte = msgbuf1[0];
|
data->byte = msgbuf1[0];
|
||||||
break;
|
break;
|
||||||
case I2C_SMBUS_WORD_DATA:
|
case I2C_SMBUS_WORD_DATA:
|
||||||
case I2C_SMBUS_PROC_CALL:
|
case I2C_SMBUS_PROC_CALL:
|
||||||
data->word = msgbuf1[0] | (msgbuf1[1] << 8);
|
data->word = msgbuf1[0] | (msgbuf1[1] << 8);
|
||||||
break;
|
break;
|
||||||
|
@ -1146,7 +1146,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
|
||||||
|
|
||||||
|
|
||||||
s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
|
s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
|
||||||
char read_write, u8 command, int size,
|
char read_write, u8 command, int size,
|
||||||
union i2c_smbus_data * data)
|
union i2c_smbus_data * data)
|
||||||
{
|
{
|
||||||
s32 res;
|
s32 res;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
i2c-dev.c - i2c-bus driver, char device interface
|
i2c-dev.c - i2c-bus driver, char device interface
|
||||||
|
|
||||||
Copyright (C) 1995-97 Simon G. Vogl
|
Copyright (C) 1995-97 Simon G. Vogl
|
||||||
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
||||||
|
@ -172,7 +172,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
switch ( cmd ) {
|
switch ( cmd ) {
|
||||||
case I2C_SLAVE:
|
case I2C_SLAVE:
|
||||||
case I2C_SLAVE_FORCE:
|
case I2C_SLAVE_FORCE:
|
||||||
if ((arg > 0x3ff) ||
|
if ((arg > 0x3ff) ||
|
||||||
(((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))
|
(((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg))
|
if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg))
|
||||||
|
@ -196,8 +196,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
return put_user(funcs, (unsigned long __user *)arg);
|
return put_user(funcs, (unsigned long __user *)arg);
|
||||||
|
|
||||||
case I2C_RDWR:
|
case I2C_RDWR:
|
||||||
if (copy_from_user(&rdwr_arg,
|
if (copy_from_user(&rdwr_arg,
|
||||||
(struct i2c_rdwr_ioctl_data __user *)arg,
|
(struct i2c_rdwr_ioctl_data __user *)arg,
|
||||||
sizeof(rdwr_arg)))
|
sizeof(rdwr_arg)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
@ -205,9 +205,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
* be sent at once */
|
* be sent at once */
|
||||||
if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
|
if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
rdwr_pa = (struct i2c_msg *)
|
rdwr_pa = (struct i2c_msg *)
|
||||||
kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
|
kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
|
||||||
if (rdwr_pa == NULL) return -ENOMEM;
|
if (rdwr_pa == NULL) return -ENOMEM;
|
||||||
|
@ -277,9 +277,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
(struct i2c_smbus_ioctl_data __user *) arg,
|
(struct i2c_smbus_ioctl_data __user *) arg,
|
||||||
sizeof(struct i2c_smbus_ioctl_data)))
|
sizeof(struct i2c_smbus_ioctl_data)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if ((data_arg.size != I2C_SMBUS_BYTE) &&
|
if ((data_arg.size != I2C_SMBUS_BYTE) &&
|
||||||
(data_arg.size != I2C_SMBUS_QUICK) &&
|
(data_arg.size != I2C_SMBUS_QUICK) &&
|
||||||
(data_arg.size != I2C_SMBUS_BYTE_DATA) &&
|
(data_arg.size != I2C_SMBUS_BYTE_DATA) &&
|
||||||
(data_arg.size != I2C_SMBUS_WORD_DATA) &&
|
(data_arg.size != I2C_SMBUS_WORD_DATA) &&
|
||||||
(data_arg.size != I2C_SMBUS_PROC_CALL) &&
|
(data_arg.size != I2C_SMBUS_PROC_CALL) &&
|
||||||
(data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
|
(data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
|
||||||
|
@ -290,11 +290,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
data_arg.size);
|
data_arg.size);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
|
/* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
|
||||||
so the check is valid if size==I2C_SMBUS_QUICK too. */
|
so the check is valid if size==I2C_SMBUS_QUICK too. */
|
||||||
if ((data_arg.read_write != I2C_SMBUS_READ) &&
|
if ((data_arg.read_write != I2C_SMBUS_READ) &&
|
||||||
(data_arg.read_write != I2C_SMBUS_WRITE)) {
|
(data_arg.read_write != I2C_SMBUS_WRITE)) {
|
||||||
dev_dbg(&client->adapter->dev,
|
dev_dbg(&client->adapter->dev,
|
||||||
"read_write out of range (%x) in ioctl I2C_SMBUS.\n",
|
"read_write out of range (%x) in ioctl I2C_SMBUS.\n",
|
||||||
data_arg.read_write);
|
data_arg.read_write);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -303,7 +303,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
/* Note that command values are always valid! */
|
/* Note that command values are always valid! */
|
||||||
|
|
||||||
if ((data_arg.size == I2C_SMBUS_QUICK) ||
|
if ((data_arg.size == I2C_SMBUS_QUICK) ||
|
||||||
((data_arg.size == I2C_SMBUS_BYTE) &&
|
((data_arg.size == I2C_SMBUS_BYTE) &&
|
||||||
(data_arg.read_write == I2C_SMBUS_WRITE)))
|
(data_arg.read_write == I2C_SMBUS_WRITE)))
|
||||||
/* These are special: we do not use data */
|
/* These are special: we do not use data */
|
||||||
return i2c_smbus_xfer(client->adapter, client->addr,
|
return i2c_smbus_xfer(client->adapter, client->addr,
|
||||||
|
@ -321,14 +321,14 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
if ((data_arg.size == I2C_SMBUS_BYTE_DATA) ||
|
if ((data_arg.size == I2C_SMBUS_BYTE_DATA) ||
|
||||||
(data_arg.size == I2C_SMBUS_BYTE))
|
(data_arg.size == I2C_SMBUS_BYTE))
|
||||||
datasize = sizeof(data_arg.data->byte);
|
datasize = sizeof(data_arg.data->byte);
|
||||||
else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
|
else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
|
||||||
(data_arg.size == I2C_SMBUS_PROC_CALL))
|
(data_arg.size == I2C_SMBUS_PROC_CALL))
|
||||||
datasize = sizeof(data_arg.data->word);
|
datasize = sizeof(data_arg.data->word);
|
||||||
else /* size == smbus block, i2c block, or block proc. call */
|
else /* size == smbus block, i2c block, or block proc. call */
|
||||||
datasize = sizeof(data_arg.data->block);
|
datasize = sizeof(data_arg.data->block);
|
||||||
|
|
||||||
if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
|
if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
|
||||||
(data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
|
(data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
|
||||||
(data_arg.read_write == I2C_SMBUS_WRITE)) {
|
(data_arg.read_write == I2C_SMBUS_WRITE)) {
|
||||||
if (copy_from_user(&temp, data_arg.data, datasize))
|
if (copy_from_user(&temp, data_arg.data, datasize))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -336,8 +336,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
|
||||||
res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
|
res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
|
||||||
data_arg.read_write,
|
data_arg.read_write,
|
||||||
data_arg.command,data_arg.size,&temp);
|
data_arg.command,data_arg.size,&temp);
|
||||||
if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
|
if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
|
||||||
(data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
|
(data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) ||
|
||||||
(data_arg.read_write == I2C_SMBUS_READ))) {
|
(data_arg.read_write == I2C_SMBUS_READ))) {
|
||||||
if (copy_to_user(data_arg.data, &temp, datasize))
|
if (copy_to_user(data_arg.data, &temp, datasize))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
/* --- Defines for bit-adapters --------------------------------------- */
|
/* --- Defines for bit-adapters --------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* This struct contains the hw-dependent functions of bit-style adapters to
|
* This struct contains the hw-dependent functions of bit-style adapters to
|
||||||
* manipulate the line states, and to init any hw-specific features. This is
|
* manipulate the line states, and to init any hw-specific features. This is
|
||||||
* only used if you have more than one hw-type of adapter running.
|
* only used if you have more than one hw-type of adapter running.
|
||||||
*/
|
*/
|
||||||
struct i2c_algo_bit_data {
|
struct i2c_algo_bit_data {
|
||||||
void *data; /* private data for lowlevel routines */
|
void *data; /* private data for lowlevel routines */
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct i2c_algo_pcf_data {
|
||||||
int (*getpcf) (void *data, int ctl);
|
int (*getpcf) (void *data, int ctl);
|
||||||
int (*getown) (void *data);
|
int (*getown) (void *data);
|
||||||
int (*getclock) (void *data);
|
int (*getclock) (void *data);
|
||||||
void (*waitforpin) (void);
|
void (*waitforpin) (void);
|
||||||
|
|
||||||
/* local settings */
|
/* local settings */
|
||||||
int udelay;
|
int udelay;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* */
|
/* */
|
||||||
/* i2c-id.h - identifier values for i2c drivers and adapters */
|
/* i2c-id.h - identifier values for i2c drivers and adapters */
|
||||||
/* */
|
/* */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* Copyright (C) 1995-1999 Simon G. Vogl
|
/* Copyright (C) 1995-1999 Simon G. Vogl
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@
|
||||||
#define I2C_DRIVERID_SAA7120 11 /* video encoder */
|
#define I2C_DRIVERID_SAA7120 11 /* video encoder */
|
||||||
#define I2C_DRIVERID_SAA7121 12 /* video encoder */
|
#define I2C_DRIVERID_SAA7121 12 /* video encoder */
|
||||||
#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
|
#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
|
||||||
#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */
|
#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */
|
||||||
#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */
|
#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */
|
||||||
#define I2C_DRIVERID_PCF8582C 16 /* eeprom */
|
#define I2C_DRIVERID_PCF8582C 16 /* eeprom */
|
||||||
#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */
|
#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */
|
||||||
#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
|
#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
|
||||||
#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */
|
#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */
|
||||||
#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
|
#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
* ---- Adapter types ----------------------------------------------------
|
* ---- Adapter types ----------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* --- Bit algorithm adapters */
|
/* --- Bit algorithm adapters */
|
||||||
#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
|
#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
|
||||||
#define I2C_HW_B_SER 0x010002 /* Serial line interface */
|
#define I2C_HW_B_SER 0x010002 /* Serial line interface */
|
||||||
#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
|
#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* */
|
/* */
|
||||||
/* i2c.h - definitions for the i2c-bus interface */
|
/* i2c.h - definitions for the i2c-bus interface */
|
||||||
/* */
|
/* */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* Copyright (C) 1995-2000 Simon G. Vogl
|
/* Copyright (C) 1995-2000 Simon G. Vogl
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#define _LINUX_I2C_H
|
#define _LINUX_I2C_H
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/i2c-id.h>
|
#include <linux/i2c-id.h>
|
||||||
#include <linux/mod_devicetable.h>
|
#include <linux/mod_devicetable.h>
|
||||||
|
@ -53,8 +53,8 @@ union i2c_smbus_data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The master routines are the ones normally used to transmit data to devices
|
* The master routines are the ones normally used to transmit data to devices
|
||||||
* on a bus (or read from them). Apart from two basic transfer functions to
|
* on a bus (or read from them). Apart from two basic transfer functions to
|
||||||
* transmit one message at a time, a more complex version can be used to
|
* transmit one message at a time, a more complex version can be used to
|
||||||
* transmit an arbitrary number of messages without interruption.
|
* transmit an arbitrary number of messages without interruption.
|
||||||
*/
|
*/
|
||||||
extern int i2c_master_send(struct i2c_client *,const char* ,int);
|
extern int i2c_master_send(struct i2c_client *,const char* ,int);
|
||||||
|
@ -67,10 +67,10 @@ extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
|
||||||
|
|
||||||
/* This is the very generalized SMBus access routine. You probably do not
|
/* This is the very generalized SMBus access routine. You probably do not
|
||||||
want to use this, though; one of the functions below may be much easier,
|
want to use this, though; one of the functions below may be much easier,
|
||||||
and probably just as fast.
|
and probably just as fast.
|
||||||
Note that we use i2c_adapter here, because you do not need a specific
|
Note that we use i2c_adapter here, because you do not need a specific
|
||||||
smbus adapter to call this function. */
|
smbus adapter to call this function. */
|
||||||
extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
|
extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
|
||||||
unsigned short flags,
|
unsigned short flags,
|
||||||
char read_write, u8 command, int size,
|
char read_write, u8 command, int size,
|
||||||
union i2c_smbus_data * data);
|
union i2c_smbus_data * data);
|
||||||
|
@ -112,14 +112,14 @@ struct i2c_driver {
|
||||||
|
|
||||||
/* Notifies the driver that a new bus has appeared. This routine
|
/* Notifies the driver that a new bus has appeared. This routine
|
||||||
* can be used by the driver to test if the bus meets its conditions
|
* can be used by the driver to test if the bus meets its conditions
|
||||||
* & seek for the presence of the chip(s) it supports. If found, it
|
* & seek for the presence of the chip(s) it supports. If found, it
|
||||||
* registers the client(s) that are on the bus to the i2c admin. via
|
* registers the client(s) that are on the bus to the i2c admin. via
|
||||||
* i2c_attach_client.
|
* i2c_attach_client.
|
||||||
*/
|
*/
|
||||||
int (*attach_adapter)(struct i2c_adapter *);
|
int (*attach_adapter)(struct i2c_adapter *);
|
||||||
int (*detach_adapter)(struct i2c_adapter *);
|
int (*detach_adapter)(struct i2c_adapter *);
|
||||||
|
|
||||||
/* tells the driver that a client is about to be deleted & gives it
|
/* tells the driver that a client is about to be deleted & gives it
|
||||||
* the chance to remove its private data. Also, if the client struct
|
* the chance to remove its private data. Also, if the client struct
|
||||||
* has been dynamically allocated by the driver in the function above,
|
* has been dynamically allocated by the driver in the function above,
|
||||||
* it must be freed here.
|
* it must be freed here.
|
||||||
|
@ -139,13 +139,13 @@ struct i2c_driver {
|
||||||
#define I2C_NAME_SIZE 50
|
#define I2C_NAME_SIZE 50
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* i2c_client identifies a single device (i.e. chip) that is connected to an
|
* i2c_client identifies a single device (i.e. chip) that is connected to an
|
||||||
* i2c bus. The behaviour is defined by the routines of the driver. This
|
* i2c bus. The behaviour is defined by the routines of the driver. This
|
||||||
* function is mainly used for lookup & other admin. functions.
|
* function is mainly used for lookup & other admin. functions.
|
||||||
*/
|
*/
|
||||||
struct i2c_client {
|
struct i2c_client {
|
||||||
unsigned int flags; /* div., see below */
|
unsigned int flags; /* div., see below */
|
||||||
unsigned short addr; /* chip address - NOTE: 7bit */
|
unsigned short addr; /* chip address - NOTE: 7bit */
|
||||||
/* addresses are stored in the */
|
/* addresses are stored in the */
|
||||||
/* _LOWER_ 7 bits */
|
/* _LOWER_ 7 bits */
|
||||||
struct i2c_adapter *adapter; /* the adapter we sit on */
|
struct i2c_adapter *adapter; /* the adapter we sit on */
|
||||||
|
@ -182,14 +182,14 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
|
||||||
*/
|
*/
|
||||||
struct i2c_algorithm {
|
struct i2c_algorithm {
|
||||||
/* If an adapter algorithm can't do I2C-level access, set master_xfer
|
/* If an adapter algorithm can't do I2C-level access, set master_xfer
|
||||||
to NULL. If an adapter algorithm can do SMBus access, set
|
to NULL. If an adapter algorithm can do SMBus access, set
|
||||||
smbus_xfer. If set to NULL, the SMBus protocol is simulated
|
smbus_xfer. If set to NULL, the SMBus protocol is simulated
|
||||||
using common I2C messages */
|
using common I2C messages */
|
||||||
/* master_xfer should return the number of messages successfully
|
/* master_xfer should return the number of messages successfully
|
||||||
processed, or a negative value on error */
|
processed, or a negative value on error */
|
||||||
int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
|
int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
|
||||||
int num);
|
int num);
|
||||||
int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
|
int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
|
||||||
unsigned short flags, char read_write,
|
unsigned short flags, char read_write,
|
||||||
u8 command, int size, union i2c_smbus_data * data);
|
u8 command, int size, union i2c_smbus_data * data);
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
|
||||||
* It will only call found_proc if some client is connected at the
|
* It will only call found_proc if some client is connected at the
|
||||||
* specific address (unless a 'force' matched);
|
* specific address (unless a 'force' matched);
|
||||||
*/
|
*/
|
||||||
extern int i2c_probe(struct i2c_adapter *adapter,
|
extern int i2c_probe(struct i2c_adapter *adapter,
|
||||||
struct i2c_client_address_data *address_data,
|
struct i2c_client_address_data *address_data,
|
||||||
int (*found_proc) (struct i2c_adapter *, int, int));
|
int (*found_proc) (struct i2c_adapter *, int, int));
|
||||||
|
|
||||||
|
@ -353,15 +353,15 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
|
||||||
*/
|
*/
|
||||||
struct i2c_msg {
|
struct i2c_msg {
|
||||||
__u16 addr; /* slave address */
|
__u16 addr; /* slave address */
|
||||||
__u16 flags;
|
__u16 flags;
|
||||||
#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
|
#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
|
||||||
#define I2C_M_RD 0x01
|
#define I2C_M_RD 0x01
|
||||||
#define I2C_M_NOSTART 0x4000
|
#define I2C_M_NOSTART 0x4000
|
||||||
#define I2C_M_REV_DIR_ADDR 0x2000
|
#define I2C_M_REV_DIR_ADDR 0x2000
|
||||||
#define I2C_M_IGNORE_NAK 0x1000
|
#define I2C_M_IGNORE_NAK 0x1000
|
||||||
#define I2C_M_NO_RD_ACK 0x0800
|
#define I2C_M_NO_RD_ACK 0x0800
|
||||||
__u16 len; /* msg length */
|
__u16 len; /* msg length */
|
||||||
__u8 *buf; /* pointer to msg data */
|
__u8 *buf; /* pointer to msg data */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* To determine what functionality is present */
|
/* To determine what functionality is present */
|
||||||
|
@ -371,16 +371,16 @@ struct i2c_msg {
|
||||||
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
||||||
#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
|
#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
|
||||||
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
||||||
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||||
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||||
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
||||||
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
||||||
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
||||||
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
||||||
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
||||||
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
||||||
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
||||||
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
||||||
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
|
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
|
||||||
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
||||||
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
|
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
|
||||||
|
@ -407,10 +407,10 @@ struct i2c_msg {
|
||||||
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
|
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
|
||||||
I2C_FUNC_SMBUS_I2C_BLOCK)
|
I2C_FUNC_SMBUS_I2C_BLOCK)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data for SMBus Messages
|
* Data for SMBus Messages
|
||||||
*/
|
*/
|
||||||
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
|
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
|
||||||
union i2c_smbus_data {
|
union i2c_smbus_data {
|
||||||
__u8 byte;
|
__u8 byte;
|
||||||
__u16 word;
|
__u16 word;
|
||||||
|
@ -422,11 +422,11 @@ union i2c_smbus_data {
|
||||||
#define I2C_SMBUS_READ 1
|
#define I2C_SMBUS_READ 1
|
||||||
#define I2C_SMBUS_WRITE 0
|
#define I2C_SMBUS_WRITE 0
|
||||||
|
|
||||||
/* SMBus transaction types (size parameter in the above functions)
|
/* SMBus transaction types (size parameter in the above functions)
|
||||||
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
|
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
|
||||||
#define I2C_SMBUS_QUICK 0
|
#define I2C_SMBUS_QUICK 0
|
||||||
#define I2C_SMBUS_BYTE 1
|
#define I2C_SMBUS_BYTE 1
|
||||||
#define I2C_SMBUS_BYTE_DATA 2
|
#define I2C_SMBUS_BYTE_DATA 2
|
||||||
#define I2C_SMBUS_WORD_DATA 3
|
#define I2C_SMBUS_WORD_DATA 3
|
||||||
#define I2C_SMBUS_PROC_CALL 4
|
#define I2C_SMBUS_PROC_CALL 4
|
||||||
#define I2C_SMBUS_BLOCK_DATA 5
|
#define I2C_SMBUS_BLOCK_DATA 5
|
||||||
|
@ -435,15 +435,15 @@ union i2c_smbus_data {
|
||||||
|
|
||||||
|
|
||||||
/* ----- commands for the ioctl like i2c_command call:
|
/* ----- commands for the ioctl like i2c_command call:
|
||||||
* note that additional calls are defined in the algorithm and hw
|
* note that additional calls are defined in the algorithm and hw
|
||||||
* dependent layers - these can be listed here, or see the
|
* dependent layers - these can be listed here, or see the
|
||||||
* corresponding header files.
|
* corresponding header files.
|
||||||
*/
|
*/
|
||||||
/* -> bit-adapter specific ioctls */
|
/* -> bit-adapter specific ioctls */
|
||||||
#define I2C_RETRIES 0x0701 /* number of times a device address */
|
#define I2C_RETRIES 0x0701 /* number of times a device address */
|
||||||
/* should be polled when not */
|
/* should be polled when not */
|
||||||
/* acknowledging */
|
/* acknowledging */
|
||||||
#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
|
#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
|
||||||
|
|
||||||
|
|
||||||
/* this is for i2c-dev.c */
|
/* this is for i2c-dev.c */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue