49 if ((file->
flags & O_ACCMODE) == O_WRONLY)
55 msg.addr = (uintptr_t)file->
priv;
58 msg.buf = (uint8_t*)buf;
77 if ((file->
flags & O_ACCMODE) == O_RDONLY)
83 msg.addr = (uintptr_t)file->
priv;
86 msg.buf = (uint8_t*)buf;
110 file->
priv = (
void*)data;
114 struct i2c_rdwr_ioctl_data *rdwr_data = (
struct i2c_rdwr_ioctl_data*)data;
118 return smbus(file, data);
136 for (
int i = 0; i < num; ++i)
138 count += msgs[i].len;
139 result =
transfer(msgs + i, (num == (i + 1)));
158 struct i2c_smbus_ioctl_data *sm_data = (
struct i2c_smbus_ioctl_data *)data;
161 if ((sm_data->size != I2C_SMBUS_QUICK) &&
162 (sm_data->size != I2C_SMBUS_BYTE) &&
163 (sm_data->size != I2C_SMBUS_BYTE_DATA) &&
164 (sm_data->size != I2C_SMBUS_WORD_DATA) &&
165 (sm_data->size != I2C_SMBUS_PROC_CALL) &&
166 (sm_data->size != I2C_SMBUS_BLOCK_DATA) &&
167 (sm_data->size != I2C_SMBUS_I2C_BLOCK_BROKEN) &&
168 (sm_data->size != I2C_SMBUS_BLOCK_PROC_CALL) &&
169 (sm_data->size != I2C_SMBUS_I2C_BLOCK_DATA))
175 if ((sm_data->read_write != I2C_SMBUS_READ) &&
176 (sm_data->read_write != I2C_SMBUS_WRITE))
ssize_t write(File *file, const void *buf, size_t count) OVERRIDE
Write to a file or device.
int smbus(File *file, unsigned long data)
Request an smbus (ioctl) transaction.
ssize_t read(File *file, void *buf, size_t count) OVERRIDE
Read from a file or device.
int ioctl(File *file, unsigned long int key, unsigned long data) OVERRIDE
Request an ioctl transaction.
virtual int transfer(struct i2c_msg *msg, bool stop)=0
Method to transmit/receive the data.
int transfer_messages(struct i2c_msg *msgs, int num)
Conduct multiple message transfers with one stop at the end.
OSMutex lock_
protects internal structures.
void unlock()
Unlock a mutex.
#define IOC_TYPE(_num)
Decode ioctl type.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
void * priv
file reference specific data "pointer"