mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
i2c: refactor i2c_master_{send_recv}
Those two functions are very similar, the only differences are that one needs the I2C_M_RD flag for its message while the other one needs the buffer casted to drop the const. Introduce a generic helper which allows to specify the flags (also needed later for DMA safe variants of these calls) and let the casting be done in the inlining functions which are now calling the new helper function. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
978336d48d
commit
8a91732b3b
2 changed files with 48 additions and 50 deletions
|
@ -63,10 +63,36 @@ struct property_entry;
|
|||
* transmit an arbitrary number of messages without interruption.
|
||||
* @count must be be less than 64k since msg.len is u16.
|
||||
*/
|
||||
extern int i2c_master_send(const struct i2c_client *client, const char *buf,
|
||||
int count);
|
||||
extern int i2c_master_recv(const struct i2c_client *client, char *buf,
|
||||
int count);
|
||||
extern int i2c_transfer_buffer_flags(const struct i2c_client *client,
|
||||
char *buf, int count, u16 flags);
|
||||
|
||||
/**
|
||||
* i2c_master_recv - issue a single I2C message in master receive mode
|
||||
* @client: Handle to slave device
|
||||
* @buf: Where to store data read from slave
|
||||
* @count: How many bytes to read, must be less than 64k since msg.len is u16
|
||||
*
|
||||
* Returns negative errno, or else the number of bytes read.
|
||||
*/
|
||||
static inline int i2c_master_recv(const struct i2c_client *client,
|
||||
char *buf, int count)
|
||||
{
|
||||
return i2c_transfer_buffer_flags(client, buf, count, I2C_M_RD);
|
||||
};
|
||||
|
||||
/**
|
||||
* i2c_master_send - issue a single I2C message in master transmit mode
|
||||
* @client: Handle to slave device
|
||||
* @buf: Data that will be written to the slave
|
||||
* @count: How many bytes to write, must be less than 64k since msg.len is u16
|
||||
*
|
||||
* Returns negative errno, or else the number of bytes written.
|
||||
*/
|
||||
static inline int i2c_master_send(const struct i2c_client *client,
|
||||
const char *buf, int count)
|
||||
{
|
||||
return i2c_transfer_buffer_flags(client, (char *)buf, count, 0);
|
||||
};
|
||||
|
||||
/* Transfer num messages.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue