diff options
-rw-r--r-- | drivers/i2c/i2c-core.c | 54 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 34 | ||||
-rw-r--r-- | include/linux/i2c-algo-bit.h | 4 | ||||
-rw-r--r-- | include/linux/i2c-algo-pcf.h | 2 | ||||
-rw-r--r-- | include/linux/i2c-id.h | 10 | ||||
-rw-r--r-- | include/linux/i2c.h | 74 |
6 files changed, 89 insertions, 89 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 79eaa12474dd..64f11e00651c 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -127,7 +127,7 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att | |||
127 | return sprintf(buf, "%s\n", client->name); | 127 | return sprintf(buf, "%s\n", client->name); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* | 130 | /* |
131 | * We can't use the DEVICE_ATTR() macro here as we want the same filename for a | 131 | * We can't use the DEVICE_ATTR() macro here as we want the same filename for a |
132 | * different type of a device. So beware if the DEVICE_ATTR() macro ever | 132 | * different type of a device. So beware if the DEVICE_ATTR() macro ever |
133 | * changes, this definition will also have to change. | 133 | * changes, this definition will also have to change. |
@@ -139,8 +139,8 @@ static struct device_attribute dev_attr_client_name = { | |||
139 | 139 | ||
140 | 140 | ||
141 | /* --------------------------------------------------- | 141 | /* --------------------------------------------------- |
142 | * registering functions | 142 | * registering functions |
143 | * --------------------------------------------------- | 143 | * --------------------------------------------------- |
144 | */ | 144 | */ |
145 | 145 | ||
146 | /* ----- | 146 | /* ----- |
@@ -314,7 +314,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver) | |||
314 | res = driver_register(&driver->driver); | 314 | res = driver_register(&driver->driver); |
315 | if (res) | 315 | if (res) |
316 | return res; | 316 | return res; |
317 | 317 | ||
318 | mutex_lock(&core_lists); | 318 | mutex_lock(&core_lists); |
319 | 319 | ||
320 | list_add_tail(&driver->list,&drivers); | 320 | list_add_tail(&driver->list,&drivers); |
@@ -338,13 +338,13 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
338 | struct list_head *item1, *item2, *_n; | 338 | struct list_head *item1, *item2, *_n; |
339 | struct i2c_client *client; | 339 | struct i2c_client *client; |
340 | struct i2c_adapter *adap; | 340 | struct i2c_adapter *adap; |
341 | 341 | ||
342 | int res = 0; | 342 | int res = 0; |
343 | 343 | ||
344 | mutex_lock(&core_lists); | 344 | mutex_lock(&core_lists); |
345 | 345 | ||
346 | /* Have a look at each adapter, if clients of this driver are still | 346 | /* Have a look at each adapter, if clients of this driver are still |
347 | * attached. If so, detach them to be able to kill the driver | 347 | * attached. If so, detach them to be able to kill the driver |
348 | * afterwards. | 348 | * afterwards. |
349 | */ | 349 | */ |
350 | list_for_each(item1,&adapters) { | 350 | list_for_each(item1,&adapters) { |
@@ -419,14 +419,14 @@ int i2c_attach_client(struct i2c_client *client) | |||
419 | goto out_unlock; | 419 | goto out_unlock; |
420 | } | 420 | } |
421 | list_add_tail(&client->list,&adapter->clients); | 421 | list_add_tail(&client->list,&adapter->clients); |
422 | 422 | ||
423 | client->usage_count = 0; | 423 | client->usage_count = 0; |
424 | 424 | ||
425 | client->dev.parent = &client->adapter->dev; | 425 | client->dev.parent = &client->adapter->dev; |
426 | client->dev.driver = &client->driver->driver; | 426 | client->dev.driver = &client->driver->driver; |
427 | client->dev.bus = &i2c_bus_type; | 427 | client->dev.bus = &i2c_bus_type; |
428 | client->dev.release = &i2c_client_release; | 428 | client->dev.release = &i2c_client_release; |
429 | 429 | ||
430 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), | 430 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), |
431 | "%d-%04x", i2c_adapter_id(adapter), client->addr); | 431 | "%d-%04x", i2c_adapter_id(adapter), client->addr); |
432 | dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", | 432 | dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", |
@@ -467,7 +467,7 @@ int i2c_detach_client(struct i2c_client *client) | |||
467 | { | 467 | { |
468 | struct i2c_adapter *adapter = client->adapter; | 468 | struct i2c_adapter *adapter = client->adapter; |
469 | int res = 0; | 469 | int res = 0; |
470 | 470 | ||
471 | if (client->usage_count > 0) { | 471 | if (client->usage_count > 0) { |
472 | dev_warn(&client->dev, "Client [%s] still busy, " | 472 | dev_warn(&client->dev, "Client [%s] still busy, " |
473 | "can't detach\n", client->name); | 473 | "can't detach\n", client->name); |
@@ -535,10 +535,10 @@ int i2c_release_client(struct i2c_client *client) | |||
535 | __FUNCTION__); | 535 | __FUNCTION__); |
536 | return -EPERM; | 536 | return -EPERM; |
537 | } | 537 | } |
538 | 538 | ||
539 | client->usage_count--; | 539 | client->usage_count--; |
540 | i2c_dec_use_client(client); | 540 | i2c_dec_use_client(client); |
541 | 541 | ||
542 | return 0; | 542 | return 0; |
543 | } | 543 | } |
544 | 544 | ||
@@ -624,7 +624,7 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count) | |||
624 | msg.flags = client->flags & I2C_M_TEN; | 624 | msg.flags = client->flags & I2C_M_TEN; |
625 | msg.len = count; | 625 | msg.len = count; |
626 | msg.buf = (char *)buf; | 626 | msg.buf = (char *)buf; |
627 | 627 | ||
628 | ret = i2c_transfer(adap, &msg, 1); | 628 | ret = i2c_transfer(adap, &msg, 1); |
629 | 629 | ||
630 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes | 630 | /* If everything went ok (i.e. 1 msg transmitted), return #bytes |
@@ -757,7 +757,7 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
757 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { | 757 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) { |
758 | if (address_data->probe[0] == I2C_CLIENT_END | 758 | if (address_data->probe[0] == I2C_CLIENT_END |
759 | && address_data->normal_i2c[0] == I2C_CLIENT_END) | 759 | && address_data->normal_i2c[0] == I2C_CLIENT_END) |
760 | return 0; | 760 | return 0; |
761 | 761 | ||
762 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " | 762 | dev_warn(&adapter->dev, "SMBus Quick command not supported, " |
763 | "can't probe for chips\n"); | 763 | "can't probe for chips\n"); |
@@ -817,7 +817,7 @@ int i2c_probe(struct i2c_adapter *adapter, | |||
817 | struct i2c_adapter* i2c_get_adapter(int id) | 817 | struct i2c_adapter* i2c_get_adapter(int id) |
818 | { | 818 | { |
819 | struct i2c_adapter *adapter; | 819 | struct i2c_adapter *adapter; |
820 | 820 | ||
821 | mutex_lock(&core_lists); | 821 | mutex_lock(&core_lists); |
822 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); | 822 | adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); |
823 | if (adapter && !try_module_get(adapter->owner)) | 823 | if (adapter && !try_module_get(adapter->owner)) |
@@ -834,14 +834,14 @@ void i2c_put_adapter(struct i2c_adapter *adap) | |||
834 | 834 | ||
835 | /* The SMBus parts */ | 835 | /* The SMBus parts */ |
836 | 836 | ||
837 | #define POLY (0x1070U << 3) | 837 | #define POLY (0x1070U << 3) |
838 | static u8 | 838 | static u8 |
839 | crc8(u16 data) | 839 | crc8(u16 data) |
840 | { | 840 | { |
841 | int i; | 841 | int i; |
842 | 842 | ||
843 | for(i = 0; i < 8; i++) { | 843 | for(i = 0; i < 8; i++) { |
844 | if (data & 0x8000) | 844 | if (data & 0x8000) |
845 | data = data ^ POLY; | 845 | data = data ^ POLY; |
846 | data = data << 1; | 846 | data = data << 1; |
847 | } | 847 | } |
@@ -891,13 +891,13 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg) | |||
891 | rpec, cpec); | 891 | rpec, cpec); |
892 | return -1; | 892 | return -1; |
893 | } | 893 | } |
894 | return 0; | 894 | return 0; |
895 | } | 895 | } |
896 | 896 | ||
897 | s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) | 897 | s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) |
898 | { | 898 | { |
899 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 899 | return i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
900 | value,0,I2C_SMBUS_QUICK,NULL); | 900 | value,0,I2C_SMBUS_QUICK,NULL); |
901 | } | 901 | } |
902 | 902 | ||
903 | s32 i2c_smbus_read_byte(struct i2c_client *client) | 903 | 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, | |||
996 | I2C_SMBUS_I2C_BLOCK_DATA, &data); | 996 | I2C_SMBUS_I2C_BLOCK_DATA, &data); |
997 | } | 997 | } |
998 | 998 | ||
999 | /* Simulate a SMBus command using the i2c protocol | 999 | /* Simulate a SMBus command using the i2c protocol |
1000 | No checking of parameters is done! */ | 1000 | No checking of parameters is done! */ |
1001 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | 1001 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, |
1002 | unsigned short flags, | 1002 | unsigned short flags, |
1003 | char read_write, u8 command, int size, | 1003 | char read_write, u8 command, int size, |
1004 | union i2c_smbus_data * data) | 1004 | union i2c_smbus_data * data) |
1005 | { | 1005 | { |
1006 | /* So we need to generate a series of msgs. In the case of writing, we | 1006 | /* 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, | |||
1010 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; | 1010 | unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; |
1011 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; | 1011 | unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; |
1012 | int num = read_write == I2C_SMBUS_READ?2:1; | 1012 | int num = read_write == I2C_SMBUS_READ?2:1; |
1013 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, | 1013 | struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, |
1014 | { addr, flags | I2C_M_RD, 0, msgbuf1 } | 1014 | { addr, flags | I2C_M_RD, 0, msgbuf1 } |
1015 | }; | 1015 | }; |
1016 | int i; | 1016 | int i; |
@@ -1103,14 +1103,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1103 | if (i) { | 1103 | if (i) { |
1104 | /* Compute PEC if first message is a write */ | 1104 | /* Compute PEC if first message is a write */ |
1105 | if (!(msg[0].flags & I2C_M_RD)) { | 1105 | if (!(msg[0].flags & I2C_M_RD)) { |
1106 | if (num == 1) /* Write only */ | 1106 | if (num == 1) /* Write only */ |
1107 | i2c_smbus_add_pec(&msg[0]); | 1107 | i2c_smbus_add_pec(&msg[0]); |
1108 | else /* Write followed by read */ | 1108 | else /* Write followed by read */ |
1109 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); | 1109 | partial_pec = i2c_smbus_msg_pec(0, &msg[0]); |
1110 | } | 1110 | } |
1111 | /* Ask for PEC if last message is a read */ | 1111 | /* Ask for PEC if last message is a read */ |
1112 | if (msg[num-1].flags & I2C_M_RD) | 1112 | if (msg[num-1].flags & I2C_M_RD) |
1113 | msg[num-1].len++; | 1113 | msg[num-1].len++; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | if (i2c_transfer(adapter, msg, num) < 0) | 1116 | if (i2c_transfer(adapter, msg, num) < 0) |
@@ -1130,7 +1130,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1130 | case I2C_SMBUS_BYTE_DATA: | 1130 | case I2C_SMBUS_BYTE_DATA: |
1131 | data->byte = msgbuf1[0]; | 1131 | data->byte = msgbuf1[0]; |
1132 | break; | 1132 | break; |
1133 | case I2C_SMBUS_WORD_DATA: | 1133 | case I2C_SMBUS_WORD_DATA: |
1134 | case I2C_SMBUS_PROC_CALL: | 1134 | case I2C_SMBUS_PROC_CALL: |
1135 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); | 1135 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); |
1136 | break; | 1136 | break; |
@@ -1146,7 +1146,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1146 | 1146 | ||
1147 | 1147 | ||
1148 | s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, | 1148 | s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, |
1149 | char read_write, u8 command, int size, | 1149 | char read_write, u8 command, int size, |
1150 | union i2c_smbus_data * data) | 1150 | union i2c_smbus_data * data) |
1151 | { | 1151 | { |
1152 | s32 res; | 1152 | s32 res; |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index d66cefc63df7..cf9381eae8da 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | i2c-dev.c - i2c-bus driver, char device interface | 2 | i2c-dev.c - i2c-bus driver, char device interface |
3 | 3 | ||
4 | Copyright (C) 1995-97 Simon G. Vogl | 4 | Copyright (C) 1995-97 Simon G. Vogl |
5 | Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> | 5 | Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl> |
@@ -172,7 +172,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
172 | switch ( cmd ) { | 172 | switch ( cmd ) { |
173 | case I2C_SLAVE: | 173 | case I2C_SLAVE: |
174 | case I2C_SLAVE_FORCE: | 174 | case I2C_SLAVE_FORCE: |
175 | if ((arg > 0x3ff) || | 175 | if ((arg > 0x3ff) || |
176 | (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) | 176 | (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) |
177 | return -EINVAL; | 177 | return -EINVAL; |
178 | if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) | 178 | if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) |
@@ -196,8 +196,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
196 | return put_user(funcs, (unsigned long __user *)arg); | 196 | return put_user(funcs, (unsigned long __user *)arg); |
197 | 197 | ||
198 | case I2C_RDWR: | 198 | case I2C_RDWR: |
199 | if (copy_from_user(&rdwr_arg, | 199 | if (copy_from_user(&rdwr_arg, |
200 | (struct i2c_rdwr_ioctl_data __user *)arg, | 200 | (struct i2c_rdwr_ioctl_data __user *)arg, |
201 | sizeof(rdwr_arg))) | 201 | sizeof(rdwr_arg))) |
202 | return -EFAULT; | 202 | return -EFAULT; |
203 | 203 | ||
@@ -205,9 +205,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
205 | * be sent at once */ | 205 | * be sent at once */ |
206 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) | 206 | if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) |
207 | return -EINVAL; | 207 | return -EINVAL; |
208 | 208 | ||
209 | rdwr_pa = (struct i2c_msg *) | 209 | rdwr_pa = (struct i2c_msg *) |
210 | kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), | 210 | kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg), |
211 | GFP_KERNEL); | 211 | GFP_KERNEL); |
212 | 212 | ||
213 | if (rdwr_pa == NULL) return -ENOMEM; | 213 | if (rdwr_pa == NULL) return -ENOMEM; |
@@ -277,9 +277,9 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
277 | (struct i2c_smbus_ioctl_data __user *) arg, | 277 | (struct i2c_smbus_ioctl_data __user *) arg, |
278 | sizeof(struct i2c_smbus_ioctl_data))) | 278 | sizeof(struct i2c_smbus_ioctl_data))) |
279 | return -EFAULT; | 279 | return -EFAULT; |
280 | if ((data_arg.size != I2C_SMBUS_BYTE) && | 280 | if ((data_arg.size != I2C_SMBUS_BYTE) && |
281 | (data_arg.size != I2C_SMBUS_QUICK) && | 281 | (data_arg.size != I2C_SMBUS_QUICK) && |
282 | (data_arg.size != I2C_SMBUS_BYTE_DATA) && | 282 | (data_arg.size != I2C_SMBUS_BYTE_DATA) && |
283 | (data_arg.size != I2C_SMBUS_WORD_DATA) && | 283 | (data_arg.size != I2C_SMBUS_WORD_DATA) && |
284 | (data_arg.size != I2C_SMBUS_PROC_CALL) && | 284 | (data_arg.size != I2C_SMBUS_PROC_CALL) && |
285 | (data_arg.size != I2C_SMBUS_BLOCK_DATA) && | 285 | (data_arg.size != I2C_SMBUS_BLOCK_DATA) && |
@@ -290,11 +290,11 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
290 | data_arg.size); | 290 | data_arg.size); |
291 | return -EINVAL; | 291 | return -EINVAL; |
292 | } | 292 | } |
293 | /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1, | 293 | /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1, |
294 | so the check is valid if size==I2C_SMBUS_QUICK too. */ | 294 | so the check is valid if size==I2C_SMBUS_QUICK too. */ |
295 | if ((data_arg.read_write != I2C_SMBUS_READ) && | 295 | if ((data_arg.read_write != I2C_SMBUS_READ) && |
296 | (data_arg.read_write != I2C_SMBUS_WRITE)) { | 296 | (data_arg.read_write != I2C_SMBUS_WRITE)) { |
297 | dev_dbg(&client->adapter->dev, | 297 | dev_dbg(&client->adapter->dev, |
298 | "read_write out of range (%x) in ioctl I2C_SMBUS.\n", | 298 | "read_write out of range (%x) in ioctl I2C_SMBUS.\n", |
299 | data_arg.read_write); | 299 | data_arg.read_write); |
300 | return -EINVAL; | 300 | return -EINVAL; |
@@ -303,7 +303,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
303 | /* Note that command values are always valid! */ | 303 | /* Note that command values are always valid! */ |
304 | 304 | ||
305 | if ((data_arg.size == I2C_SMBUS_QUICK) || | 305 | if ((data_arg.size == I2C_SMBUS_QUICK) || |
306 | ((data_arg.size == I2C_SMBUS_BYTE) && | 306 | ((data_arg.size == I2C_SMBUS_BYTE) && |
307 | (data_arg.read_write == I2C_SMBUS_WRITE))) | 307 | (data_arg.read_write == I2C_SMBUS_WRITE))) |
308 | /* These are special: we do not use data */ | 308 | /* These are special: we do not use data */ |
309 | return i2c_smbus_xfer(client->adapter, client->addr, | 309 | return i2c_smbus_xfer(client->adapter, client->addr, |
@@ -321,14 +321,14 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
321 | if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || | 321 | if ((data_arg.size == I2C_SMBUS_BYTE_DATA) || |
322 | (data_arg.size == I2C_SMBUS_BYTE)) | 322 | (data_arg.size == I2C_SMBUS_BYTE)) |
323 | datasize = sizeof(data_arg.data->byte); | 323 | datasize = sizeof(data_arg.data->byte); |
324 | else if ((data_arg.size == I2C_SMBUS_WORD_DATA) || | 324 | else if ((data_arg.size == I2C_SMBUS_WORD_DATA) || |
325 | (data_arg.size == I2C_SMBUS_PROC_CALL)) | 325 | (data_arg.size == I2C_SMBUS_PROC_CALL)) |
326 | datasize = sizeof(data_arg.data->word); | 326 | datasize = sizeof(data_arg.data->word); |
327 | else /* size == smbus block, i2c block, or block proc. call */ | 327 | else /* size == smbus block, i2c block, or block proc. call */ |
328 | datasize = sizeof(data_arg.data->block); | 328 | datasize = sizeof(data_arg.data->block); |
329 | 329 | ||
330 | if ((data_arg.size == I2C_SMBUS_PROC_CALL) || | 330 | if ((data_arg.size == I2C_SMBUS_PROC_CALL) || |
331 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || | 331 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || |
332 | (data_arg.read_write == I2C_SMBUS_WRITE)) { | 332 | (data_arg.read_write == I2C_SMBUS_WRITE)) { |
333 | if (copy_from_user(&temp, data_arg.data, datasize)) | 333 | if (copy_from_user(&temp, data_arg.data, datasize)) |
334 | return -EFAULT; | 334 | return -EFAULT; |
@@ -336,8 +336,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file, | |||
336 | res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 336 | res = i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
337 | data_arg.read_write, | 337 | data_arg.read_write, |
338 | data_arg.command,data_arg.size,&temp); | 338 | data_arg.command,data_arg.size,&temp); |
339 | if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || | 339 | if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) || |
340 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || | 340 | (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL) || |
341 | (data_arg.read_write == I2C_SMBUS_READ))) { | 341 | (data_arg.read_write == I2C_SMBUS_READ))) { |
342 | if (copy_to_user(data_arg.data, &temp, datasize)) | 342 | if (copy_to_user(data_arg.data, &temp, datasize)) |
343 | return -EFAULT; | 343 | return -EFAULT; |
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h index c8f8df25c7e0..a99e28a86c3b 100644 --- a/include/linux/i2c-algo-bit.h +++ b/include/linux/i2c-algo-bit.h | |||
@@ -26,9 +26,9 @@ | |||
26 | 26 | ||
27 | /* --- Defines for bit-adapters --------------------------------------- */ | 27 | /* --- Defines for bit-adapters --------------------------------------- */ |
28 | /* | 28 | /* |
29 | * This struct contains the hw-dependent functions of bit-style adapters to | 29 | * This struct contains the hw-dependent functions of bit-style adapters to |
30 | * manipulate the line states, and to init any hw-specific features. This is | 30 | * manipulate the line states, and to init any hw-specific features. This is |
31 | * only used if you have more than one hw-type of adapter running. | 31 | * only used if you have more than one hw-type of adapter running. |
32 | */ | 32 | */ |
33 | struct i2c_algo_bit_data { | 33 | struct i2c_algo_bit_data { |
34 | void *data; /* private data for lowlevel routines */ | 34 | void *data; /* private data for lowlevel routines */ |
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h index 9908f3fc4839..7d7045cbb344 100644 --- a/include/linux/i2c-algo-pcf.h +++ b/include/linux/i2c-algo-pcf.h | |||
@@ -31,7 +31,7 @@ struct i2c_algo_pcf_data { | |||
31 | int (*getpcf) (void *data, int ctl); | 31 | int (*getpcf) (void *data, int ctl); |
32 | int (*getown) (void *data); | 32 | int (*getown) (void *data); |
33 | int (*getclock) (void *data); | 33 | int (*getclock) (void *data); |
34 | void (*waitforpin) (void); | 34 | void (*waitforpin) (void); |
35 | 35 | ||
36 | /* local settings */ | 36 | /* local settings */ |
37 | int udelay; | 37 | int udelay; |
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 00da370bbcd6..5b97f1cce7a5 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* i2c-id.h - identifier values for i2c drivers and adapters */ | 3 | /* i2c-id.h - identifier values for i2c drivers and adapters */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* Copyright (C) 1995-1999 Simon G. Vogl | 6 | /* Copyright (C) 1995-1999 Simon G. Vogl |
7 | 7 | ||
@@ -40,10 +40,10 @@ | |||
40 | #define I2C_DRIVERID_SAA7120 11 /* video encoder */ | 40 | #define I2C_DRIVERID_SAA7120 11 /* video encoder */ |
41 | #define I2C_DRIVERID_SAA7121 12 /* video encoder */ | 41 | #define I2C_DRIVERID_SAA7121 12 /* video encoder */ |
42 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ | 42 | #define I2C_DRIVERID_SAA7185B 13 /* video encoder */ |
43 | #define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ | 43 | #define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */ |
44 | #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ | 44 | #define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */ |
45 | #define I2C_DRIVERID_PCF8582C 16 /* eeprom */ | 45 | #define I2C_DRIVERID_PCF8582C 16 /* eeprom */ |
46 | #define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ | 46 | #define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */ |
47 | #define I2C_DRIVERID_TEA6300 18 /* audio mixer */ | 47 | #define I2C_DRIVERID_TEA6300 18 /* audio mixer */ |
48 | #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ | 48 | #define I2C_DRIVERID_BT829 19 /* pc to tv encoder */ |
49 | #define I2C_DRIVERID_TDA9850 20 /* audio mixer */ | 49 | #define I2C_DRIVERID_TDA9850 20 /* audio mixer */ |
@@ -162,7 +162,7 @@ | |||
162 | * ---- Adapter types ---------------------------------------------------- | 162 | * ---- Adapter types ---------------------------------------------------- |
163 | */ | 163 | */ |
164 | 164 | ||
165 | /* --- Bit algorithm adapters */ | 165 | /* --- Bit algorithm adapters */ |
166 | #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ | 166 | #define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ |
167 | #define I2C_HW_B_SER 0x010002 /* Serial line interface */ | 167 | #define I2C_HW_B_SER 0x010002 /* Serial line interface */ |
168 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ | 168 | #define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 08df4169b411..71e50d3e492f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* i2c.h - definitions for the i2c-bus interface */ | 3 | /* i2c.h - definitions for the i2c-bus interface */ |
4 | /* */ | 4 | /* */ |
5 | /* ------------------------------------------------------------------------- */ | 5 | /* ------------------------------------------------------------------------- */ |
6 | /* Copyright (C) 1995-2000 Simon G. Vogl | 6 | /* Copyright (C) 1995-2000 Simon G. Vogl |
7 | 7 | ||
@@ -27,7 +27,7 @@ | |||
27 | #define _LINUX_I2C_H | 27 | #define _LINUX_I2C_H |
28 | 28 | ||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/i2c-id.h> | 32 | #include <linux/i2c-id.h> |
33 | #include <linux/mod_devicetable.h> | 33 | #include <linux/mod_devicetable.h> |
@@ -53,8 +53,8 @@ union i2c_smbus_data; | |||
53 | 53 | ||
54 | /* | 54 | /* |
55 | * The master routines are the ones normally used to transmit data to devices | 55 | * The master routines are the ones normally used to transmit data to devices |
56 | * on a bus (or read from them). Apart from two basic transfer functions to | 56 | * on a bus (or read from them). Apart from two basic transfer functions to |
57 | * transmit one message at a time, a more complex version can be used to | 57 | * transmit one message at a time, a more complex version can be used to |
58 | * transmit an arbitrary number of messages without interruption. | 58 | * transmit an arbitrary number of messages without interruption. |
59 | */ | 59 | */ |
60 | extern int i2c_master_send(struct i2c_client *,const char* ,int); | 60 | 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) | |||
67 | 67 | ||
68 | /* This is the very generalized SMBus access routine. You probably do not | 68 | /* This is the very generalized SMBus access routine. You probably do not |
69 | want to use this, though; one of the functions below may be much easier, | 69 | want to use this, though; one of the functions below may be much easier, |
70 | and probably just as fast. | 70 | and probably just as fast. |
71 | Note that we use i2c_adapter here, because you do not need a specific | 71 | Note that we use i2c_adapter here, because you do not need a specific |
72 | smbus adapter to call this function. */ | 72 | smbus adapter to call this function. */ |
73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, | 73 | extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, |
74 | unsigned short flags, | 74 | unsigned short flags, |
75 | char read_write, u8 command, int size, | 75 | char read_write, u8 command, int size, |
76 | union i2c_smbus_data * data); | 76 | union i2c_smbus_data * data); |
@@ -112,14 +112,14 @@ struct i2c_driver { | |||
112 | 112 | ||
113 | /* Notifies the driver that a new bus has appeared. This routine | 113 | /* Notifies the driver that a new bus has appeared. This routine |
114 | * can be used by the driver to test if the bus meets its conditions | 114 | * can be used by the driver to test if the bus meets its conditions |
115 | * & seek for the presence of the chip(s) it supports. If found, it | 115 | * & seek for the presence of the chip(s) it supports. If found, it |
116 | * registers the client(s) that are on the bus to the i2c admin. via | 116 | * registers the client(s) that are on the bus to the i2c admin. via |
117 | * i2c_attach_client. | 117 | * i2c_attach_client. |
118 | */ | 118 | */ |
119 | int (*attach_adapter)(struct i2c_adapter *); | 119 | int (*attach_adapter)(struct i2c_adapter *); |
120 | int (*detach_adapter)(struct i2c_adapter *); | 120 | int (*detach_adapter)(struct i2c_adapter *); |
121 | 121 | ||
122 | /* tells the driver that a client is about to be deleted & gives it | 122 | /* tells the driver that a client is about to be deleted & gives it |
123 | * the chance to remove its private data. Also, if the client struct | 123 | * the chance to remove its private data. Also, if the client struct |
124 | * has been dynamically allocated by the driver in the function above, | 124 | * has been dynamically allocated by the driver in the function above, |
125 | * it must be freed here. | 125 | * it must be freed here. |
@@ -139,13 +139,13 @@ struct i2c_driver { | |||
139 | #define I2C_NAME_SIZE 50 | 139 | #define I2C_NAME_SIZE 50 |
140 | 140 | ||
141 | /* | 141 | /* |
142 | * i2c_client identifies a single device (i.e. chip) that is connected to an | 142 | * i2c_client identifies a single device (i.e. chip) that is connected to an |
143 | * i2c bus. The behaviour is defined by the routines of the driver. This | 143 | * i2c bus. The behaviour is defined by the routines of the driver. This |
144 | * function is mainly used for lookup & other admin. functions. | 144 | * function is mainly used for lookup & other admin. functions. |
145 | */ | 145 | */ |
146 | struct i2c_client { | 146 | struct i2c_client { |
147 | unsigned int flags; /* div., see below */ | 147 | unsigned int flags; /* div., see below */ |
148 | unsigned short addr; /* chip address - NOTE: 7bit */ | 148 | unsigned short addr; /* chip address - NOTE: 7bit */ |
149 | /* addresses are stored in the */ | 149 | /* addresses are stored in the */ |
150 | /* _LOWER_ 7 bits */ | 150 | /* _LOWER_ 7 bits */ |
151 | struct i2c_adapter *adapter; /* the adapter we sit on */ | 151 | 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) | |||
182 | */ | 182 | */ |
183 | struct i2c_algorithm { | 183 | struct i2c_algorithm { |
184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer | 184 | /* If an adapter algorithm can't do I2C-level access, set master_xfer |
185 | to NULL. If an adapter algorithm can do SMBus access, set | 185 | to NULL. If an adapter algorithm can do SMBus access, set |
186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated | 186 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
187 | using common I2C messages */ | 187 | using common I2C messages */ |
188 | /* master_xfer should return the number of messages successfully | 188 | /* master_xfer should return the number of messages successfully |
189 | processed, or a negative value on error */ | 189 | processed, or a negative value on error */ |
190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, | 190 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, |
191 | int num); | 191 | int num); |
192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, | 192 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, |
193 | unsigned short flags, char read_write, | 193 | unsigned short flags, char read_write, |
194 | u8 command, int size, union i2c_smbus_data * data); | 194 | u8 command, int size, union i2c_smbus_data * data); |
195 | 195 | ||
@@ -317,7 +317,7 @@ extern int i2c_check_addr (struct i2c_adapter *adapter, int addr); | |||
317 | * It will only call found_proc if some client is connected at the | 317 | * It will only call found_proc if some client is connected at the |
318 | * specific address (unless a 'force' matched); | 318 | * specific address (unless a 'force' matched); |
319 | */ | 319 | */ |
320 | extern int i2c_probe(struct i2c_adapter *adapter, | 320 | extern int i2c_probe(struct i2c_adapter *adapter, |
321 | struct i2c_client_address_data *address_data, | 321 | struct i2c_client_address_data *address_data, |
322 | int (*found_proc) (struct i2c_adapter *, int, int)); | 322 | int (*found_proc) (struct i2c_adapter *, int, int)); |
323 | 323 | ||
@@ -353,15 +353,15 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) | |||
353 | */ | 353 | */ |
354 | struct i2c_msg { | 354 | struct i2c_msg { |
355 | __u16 addr; /* slave address */ | 355 | __u16 addr; /* slave address */ |
356 | __u16 flags; | 356 | __u16 flags; |
357 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ | 357 | #define I2C_M_TEN 0x10 /* we have a ten bit chip address */ |
358 | #define I2C_M_RD 0x01 | 358 | #define I2C_M_RD 0x01 |
359 | #define I2C_M_NOSTART 0x4000 | 359 | #define I2C_M_NOSTART 0x4000 |
360 | #define I2C_M_REV_DIR_ADDR 0x2000 | 360 | #define I2C_M_REV_DIR_ADDR 0x2000 |
361 | #define I2C_M_IGNORE_NAK 0x1000 | 361 | #define I2C_M_IGNORE_NAK 0x1000 |
362 | #define I2C_M_NO_RD_ACK 0x0800 | 362 | #define I2C_M_NO_RD_ACK 0x0800 |
363 | __u16 len; /* msg length */ | 363 | __u16 len; /* msg length */ |
364 | __u8 *buf; /* pointer to msg data */ | 364 | __u8 *buf; /* pointer to msg data */ |
365 | }; | 365 | }; |
366 | 366 | ||
367 | /* To determine what functionality is present */ | 367 | /* To determine what functionality is present */ |
@@ -371,16 +371,16 @@ struct i2c_msg { | |||
371 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ | 371 | #define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ |
372 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ | 372 | #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ |
373 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ | 373 | #define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ |
374 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 | 374 | #define I2C_FUNC_SMBUS_QUICK 0x00010000 |
375 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 | 375 | #define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 |
376 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 | 376 | #define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 |
377 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 | 377 | #define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 |
378 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 | 378 | #define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 |
379 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 | 379 | #define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 |
380 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 | 380 | #define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 |
381 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 | 381 | #define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 |
382 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 | 382 | #define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 |
383 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 | 383 | #define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 |
384 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ | 384 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ |
385 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ | 385 | #define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ |
386 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ | 386 | #define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ |
@@ -407,10 +407,10 @@ struct i2c_msg { | |||
407 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ | 407 | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ |
408 | I2C_FUNC_SMBUS_I2C_BLOCK) | 408 | I2C_FUNC_SMBUS_I2C_BLOCK) |
409 | 409 | ||
410 | /* | 410 | /* |
411 | * Data for SMBus Messages | 411 | * Data for SMBus Messages |
412 | */ | 412 | */ |
413 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ | 413 | #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ |
414 | union i2c_smbus_data { | 414 | union i2c_smbus_data { |
415 | __u8 byte; | 415 | __u8 byte; |
416 | __u16 word; | 416 | __u16 word; |
@@ -422,11 +422,11 @@ union i2c_smbus_data { | |||
422 | #define I2C_SMBUS_READ 1 | 422 | #define I2C_SMBUS_READ 1 |
423 | #define I2C_SMBUS_WRITE 0 | 423 | #define I2C_SMBUS_WRITE 0 |
424 | 424 | ||
425 | /* SMBus transaction types (size parameter in the above functions) | 425 | /* SMBus transaction types (size parameter in the above functions) |
426 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ | 426 | Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ |
427 | #define I2C_SMBUS_QUICK 0 | 427 | #define I2C_SMBUS_QUICK 0 |
428 | #define I2C_SMBUS_BYTE 1 | 428 | #define I2C_SMBUS_BYTE 1 |
429 | #define I2C_SMBUS_BYTE_DATA 2 | 429 | #define I2C_SMBUS_BYTE_DATA 2 |
430 | #define I2C_SMBUS_WORD_DATA 3 | 430 | #define I2C_SMBUS_WORD_DATA 3 |
431 | #define I2C_SMBUS_PROC_CALL 4 | 431 | #define I2C_SMBUS_PROC_CALL 4 |
432 | #define I2C_SMBUS_BLOCK_DATA 5 | 432 | #define I2C_SMBUS_BLOCK_DATA 5 |
@@ -435,15 +435,15 @@ union i2c_smbus_data { | |||
435 | 435 | ||
436 | 436 | ||
437 | /* ----- commands for the ioctl like i2c_command call: | 437 | /* ----- commands for the ioctl like i2c_command call: |
438 | * note that additional calls are defined in the algorithm and hw | 438 | * note that additional calls are defined in the algorithm and hw |
439 | * dependent layers - these can be listed here, or see the | 439 | * dependent layers - these can be listed here, or see the |
440 | * corresponding header files. | 440 | * corresponding header files. |
441 | */ | 441 | */ |
442 | /* -> bit-adapter specific ioctls */ | 442 | /* -> bit-adapter specific ioctls */ |
443 | #define I2C_RETRIES 0x0701 /* number of times a device address */ | 443 | #define I2C_RETRIES 0x0701 /* number of times a device address */ |
444 | /* should be polled when not */ | 444 | /* should be polled when not */ |
445 | /* acknowledging */ | 445 | /* acknowledging */ |
446 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ | 446 | #define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ |
447 | 447 | ||
448 | 448 | ||
449 | /* this is for i2c-dev.c */ | 449 | /* this is for i2c-dev.c */ |