From 4c402c06810b20040d532efa20d7b3b99671dd14 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 7 Mar 2007 10:07:13 +0000 Subject: [PATCH] Add support for some I2C ioctls. Based on patch from Jean Delvare . Fixes bug #142186. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6631 --- coregrind/m_syswrap/syswrap-generic.c | 20 ++++++++++++++++++++ include/vki/vki-linux.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 3e4df0e9bc..e086ef3898 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4113,6 +4113,16 @@ PRE(sys_ioctl) } break; + /* I2C (/dev/i2c-*) ioctls */ + case VKI_I2C_SLAVE: + case VKI_I2C_SLAVE_FORCE: + case VKI_I2C_TENBIT: + case VKI_I2C_PEC: + break; + case VKI_I2C_FUNCS: + PRE_MEM_WRITE( "ioctl(I2C_FUNCS)", ARG3, sizeof(unsigned long) ); + break; + /* We don't have any specific information on it, so try to do something reasonable based on direction and size bits. The encoding scheme is described in @@ -4821,6 +4831,16 @@ POST(sys_ioctl) } break; + /* I2C (/dev/i2c-*) ioctls */ + case VKI_I2C_SLAVE: + case VKI_I2C_SLAVE_FORCE: + case VKI_I2C_TENBIT: + case VKI_I2C_PEC: + break; + case VKI_I2C_FUNCS: + POST_MEM_WRITE( ARG3, sizeof(unsigned long) ); + break; + /* We don't have any specific information on it, so try to do something reasonable based on direction and size bits. The encoding scheme is described in diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index a2903cdc42..86eea4fea9 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -2314,6 +2314,20 @@ struct vki_usbdevfs_ioctl { #define VKI_USBDEVFS_CONNECTINFO _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo) #define VKI_USBDEVFS_IOCTL _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl) +//---------------------------------------------------------------------- +// From linux-2.6.20.1/include/linux/i2c.h +//---------------------------------------------------------------------- + +#define VKI_I2C_SLAVE 0x0703 /* Change slave address */ + /* Attn.: Slave address is 7 or 10 bits */ +#define VKI_I2C_SLAVE_FORCE 0x0706 /* Change slave address */ + /* Attn.: Slave address is 7 or 10 bits */ + /* This changes the address, even if it */ + /* is already taken! */ +#define VKI_I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ +#define VKI_I2C_FUNCS 0x0705 /* Get the adapter functionality */ +#define VKI_I2C_PEC 0x0708 /* != 0 for SMBus PEC */ + #endif // __VKI_LINUX_H /*--------------------------------------------------------------------*/ -- 2.47.2