[device]修改i2c读写函数返回类型为rt_ssize_t (#7029)

This commit is contained in:
Zxy 2023-03-10 12:42:58 +08:00 committed by GitHub
parent f6847af0cd
commit c8b30bf31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 20 deletions

View File

@ -35,7 +35,7 @@ static uint32_t get_i2c_freq(I2C_Type *base)
static rt_ssize_t master_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
{
rt_size_t ret = (0);
rt_ssize_t ret = (0);
rt_uint32_t index = 0;
struct lpc_i2c *lpc_i2c = RT_NULL;

View File

@ -51,11 +51,11 @@ struct rt_i2c_bus_device *rt_i2c_bus_device_find(const char *bus_name)
return bus;
}
rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
{
rt_size_t ret;
rt_ssize_t ret;
if (bus->ops->master_xfer)
{
@ -78,7 +78,7 @@ rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
{
LOG_E("I2C bus operation not supported");
return 0;
return -RT_ERROR;
}
}
@ -98,17 +98,17 @@ rt_err_t rt_i2c_control(struct rt_i2c_bus_device *bus,
{
LOG_E("I2C bus operation not supported");
return 0;
return -RT_ERROR;
}
}
rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
rt_uint16_t addr,
rt_uint16_t flags,
const rt_uint8_t *buf,
rt_uint32_t count)
{
rt_size_t ret;
rt_ssize_t ret;
struct rt_i2c_msg msg;
msg.addr = addr;
@ -118,16 +118,16 @@ rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
ret = rt_i2c_transfer(bus, &msg, 1);
return (ret > 0) ? count : ret;
return ret;
}
rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_uint16_t addr,
rt_uint16_t flags,
rt_uint8_t *buf,
rt_uint32_t count)
{
rt_size_t ret;
rt_ssize_t ret;
struct rt_i2c_msg msg;
RT_ASSERT(bus != RT_NULL);
@ -138,11 +138,5 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
ret = rt_i2c_transfer(bus, &msg, 1);
return (ret > 0) ? count : ret;
return ret;
}
int rt_i2c_core_init(void)
{
return 0;
}
INIT_COMPONENT_EXPORT(rt_i2c_core_init);

View File

@ -70,18 +70,18 @@ struct rt_i2c_client
rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
const char *bus_name);
struct rt_i2c_bus_device *rt_i2c_bus_device_find(const char *bus_name);
rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num);
rt_err_t rt_i2c_control(struct rt_i2c_bus_device *bus,
rt_uint32_t cmd,
rt_uint32_t arg);
rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
rt_uint16_t addr,
rt_uint16_t flags,
const rt_uint8_t *buf,
rt_uint32_t count);
rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_ssize_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
rt_uint16_t addr,
rt_uint16_t flags,
rt_uint8_t *buf,