1.优化错误码,默认为负。
This commit is contained in:
12
device/adc.c
12
device/adc.c
@@ -14,12 +14,12 @@
|
||||
|
||||
static mr_err_t err_io_adc_configure(mr_adc_t adc, mr_state_t state)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static mr_err_t err_io_adc_channel_configure(mr_adc_t adc, mr_adc_config_t config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static mr_uint32_t err_io_adc_read(mr_adc_t adc, mr_off_t channel)
|
||||
@@ -63,7 +63,7 @@ static mr_err_t mr_adc_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -74,11 +74,11 @@ static mr_err_t mr_adc_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = adc->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ static mr_ssize_t mr_adc_read(mr_device_t device, mr_off_t pos, void *buffer, mr
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((read_size += sizeof(*read_buffer)) <= size)
|
||||
|
||||
12
device/dac.c
12
device/dac.c
@@ -14,12 +14,12 @@
|
||||
|
||||
static mr_err_t err_io_dac_configure(mr_dac_t dac, mr_state_t state)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static mr_err_t err_io_dac_channel_configure(mr_dac_t dac, struct mr_dac_config *config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_dac_write(mr_dac_t dac, mr_off_t channel, mr_uint32_t value)
|
||||
@@ -63,7 +63,7 @@ static mr_err_t mr_dac_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -74,11 +74,11 @@ static mr_err_t mr_dac_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = dac->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ static mr_ssize_t mr_dac_write(mr_device_t device, mr_off_t pos, const void *buf
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((write_size += sizeof(*write_buffer)) <= size)
|
||||
|
||||
14
device/i2c.c
14
device/i2c.c
@@ -17,7 +17,7 @@
|
||||
|
||||
static mr_err_t err_io_i2c_configure(mr_i2c_bus_t i2c_bus, mr_i2c_config_t config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_i2c_start(mr_i2c_bus_t i2c_bus)
|
||||
@@ -48,7 +48,7 @@ static mr_err_t mr_i2c_device_take_bus(mr_i2c_device_t i2c_device)
|
||||
/* Check if the i2c-bus is valid */
|
||||
if (i2c_bus == MR_NULL)
|
||||
{
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* Take the mutex lock of the i2c-bus */
|
||||
@@ -102,7 +102,7 @@ static mr_err_t mr_i2c_device_connect_bus(mr_i2c_device_t i2c_device, const char
|
||||
i2c_bus = mr_device_find(name);
|
||||
if (i2c_bus == MR_NULL || i2c_bus->type != Mr_Device_Type_I2CBUS)
|
||||
{
|
||||
return -MR_ERR_NOT_FOUND;
|
||||
return MR_ERR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
i2c_device->config = *config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -220,7 +220,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = i2c_device->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_CONNECT:
|
||||
@@ -229,7 +229,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ mr_err_t mr_i2c_bus_add(mr_i2c_bus_t i2c_bus, const char *name, struct mr_i2c_bu
|
||||
|
||||
static mr_err_t err_io_soft_i2c_bus_configure(mr_soft_i2c_bus_t i2c_bus, mr_state_t state)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_soft_i2c_scl_write(mr_soft_i2c_bus_t i2c_bus, mr_level_t level)
|
||||
|
||||
10
device/pin.c
10
device/pin.c
@@ -14,7 +14,7 @@
|
||||
|
||||
static mr_err_t err_io_pin_configure(mr_pin_t pin, struct mr_pin_config *config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static mr_level_t err_io_pin_read(mr_pin_t pin, mr_off_t number)
|
||||
@@ -40,7 +40,7 @@ static mr_err_t mr_pin_ioctl(mr_device_t device, int cmd, void *args)
|
||||
mr_pin_config_t config = (mr_pin_config_t)args;
|
||||
return pin->ops->configure(pin, config);
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_SET_RX_CB:
|
||||
@@ -50,7 +50,7 @@ static mr_err_t mr_pin_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ static mr_ssize_t mr_pin_read(mr_device_t device, mr_off_t pos, void *buffer, mr
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((read_size += sizeof(*read_buffer)) <= size)
|
||||
@@ -82,7 +82,7 @@ static mr_ssize_t mr_pin_write(mr_device_t device, mr_off_t pos, const void *buf
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((write_size += sizeof(*write_buffer)) <= size)
|
||||
|
||||
12
device/pwm.c
12
device/pwm.c
@@ -14,7 +14,7 @@
|
||||
|
||||
static mr_err_t err_io_pwm_configure(mr_pwm_t pwm, mr_pwm_config_t config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_pwm_write(mr_pwm_t pwm, mr_off_t channel, mr_uint32_t duty)
|
||||
@@ -61,7 +61,7 @@ static mr_err_t mr_pwm_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -72,11 +72,11 @@ static mr_err_t mr_pwm_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = pwm->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static mr_err_t mr_pwm_read(mr_device_t device, mr_off_t pos, void *buffer, mr_s
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((read_size += sizeof(*read_buffer)) <= size)
|
||||
@@ -108,7 +108,7 @@ static mr_err_t mr_pwm_write(mr_device_t device, mr_off_t pos, const void *buffe
|
||||
|
||||
if (pos < 0)
|
||||
{
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
while ((write_size += sizeof(*write_buffer)) <= size)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
static mr_err_t err_io_serial_configure(mr_serial_t serial, struct mr_serial_config *config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_serial_write(mr_serial_t serial, mr_uint8_t data)
|
||||
@@ -75,7 +75,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -86,7 +86,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = serial->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_SET_RX_CB:
|
||||
@@ -108,7 +108,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
|
||||
mr_size_t bufsz = *((mr_size_t *)args);
|
||||
return mr_rb_allocate_buffer(&serial->rx_fifo, bufsz);
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_SET_TX_BUFSZ:
|
||||
@@ -118,11 +118,11 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
|
||||
mr_size_t bufsz = *((mr_size_t *)args);
|
||||
return mr_rb_allocate_buffer(&serial->tx_fifo, bufsz);
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
device/spi.c
20
device/spi.c
@@ -22,7 +22,7 @@
|
||||
|
||||
static mr_err_t err_io_spi_configure(mr_spi_bus_t spi_bus, struct mr_spi_config *config)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_spi_write(mr_spi_bus_t spi_bus, mr_uint32_t data)
|
||||
@@ -53,7 +53,7 @@ mr_err_t mr_spi_device_take_bus(mr_spi_device_t spi_device)
|
||||
/* Check if the spi-bus is valid */
|
||||
if (spi_bus == MR_NULL)
|
||||
{
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* Take the mutex lock of the spi-bus */
|
||||
@@ -109,7 +109,7 @@ static mr_err_t mr_spi_device_connect_bus(mr_spi_device_t spi_device, const char
|
||||
spi_bus = mr_device_find(name);
|
||||
if (spi_bus == MR_NULL || spi_bus->type != Mr_Device_Type_SPIBUS)
|
||||
{
|
||||
return -MR_ERR_NOT_FOUND;
|
||||
return MR_ERR_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
} else if (rw == MR_SPI_RD)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -318,7 +318,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
spi_device->config = *config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -412,7 +412,7 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = spi_device->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_SET_RX_CB:
|
||||
@@ -462,11 +462,11 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
|
||||
return (mr_err_t)tf_size;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
static mr_err_t err_io_timer_configure(mr_timer_t timer, mr_state_t state)
|
||||
{
|
||||
return -MR_ERR_IO;
|
||||
return MR_ERR_IO;
|
||||
}
|
||||
|
||||
static void err_io_timer_start(mr_timer_t timer, mr_uint32_t prescaler, mr_uint32_t period)
|
||||
@@ -41,7 +41,7 @@ static mr_err_t mr_timer_calculate(mr_timer_t timer, mr_uint32_t timeout, mr_uin
|
||||
clk_mhz = timer->data->clk / 1000000u;
|
||||
if (clk_mhz == 0)
|
||||
{
|
||||
return -MR_ERR_GENERIC;
|
||||
return MR_ERR_GENERIC;
|
||||
}
|
||||
|
||||
/* Calculate the prescaler */
|
||||
@@ -141,7 +141,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
|
||||
timer->config = *config;
|
||||
return ret;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_GET_CONFIG:
|
||||
@@ -152,7 +152,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
|
||||
*config = timer->config;
|
||||
return MR_ERR_OK;
|
||||
}
|
||||
return -MR_ERR_INVALID;
|
||||
return MR_ERR_INVALID;
|
||||
}
|
||||
|
||||
case MR_DEVICE_CTRL_SET_RX_CB:
|
||||
@@ -162,7 +162,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
|
||||
}
|
||||
|
||||
default:
|
||||
return -MR_ERR_UNSUPPORTED;
|
||||
return MR_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user