drivers: Replace DEV_INVALID_CONF by -EINVAL

This patch replaces all occurences of the macro DEV_INVALID_CONF by
-EINVAL at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: Idae0d5af8dd780416977c9261a5fb6188c3aab64
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
This commit is contained in:
Andre Guedes 2016-03-09 15:22:04 -03:00 committed by Anas Nashif
commit b3cb3a1f68
27 changed files with 83 additions and 70 deletions

View file

@ -139,7 +139,7 @@ static int adc_qmsi_read(struct device *dev, struct adc_seq_table *seq_tbl)
adc_lock(info);
if (qm_adc_set_config(QM_ADC_0, &cfg) != QM_RC_OK) {
ret = DEV_INVALID_CONF;
ret = -EINVAL;
adc_unlock(info);
break;
}
@ -188,7 +188,7 @@ static int adc_qmsi_read(struct device *dev, struct adc_seq_table *seq_tbl)
adc_lock(info);
if (qm_adc_set_config(QM_ADC_0, &cfg) != QM_RC_OK) {
ret = DEV_INVALID_CONF;
ret = -EINVAL;
adc_unlock(info);
break;
}

View file

@ -184,7 +184,7 @@ static int ti_adc108s102_read(struct device *dev,
memset(adc->chans, 0, ADC108S102_CHANNELS_SIZE);
if (_verify_entries(seq_table) == 0) {
return DEV_INVALID_CONF;
return -EINVAL;
}
adc->seq_table = seq_table;

View file

@ -14,6 +14,7 @@
* limitations under the License.
*/
#include <errno.h>
#include <stdio.h>
#include <nanokernel.h>
@ -35,7 +36,7 @@ static int dw_aio_cmp_disable(struct device *dev, uint8_t index)
(struct dw_aio_cmp_t *)config->base_address;
if (index >= AIO_DW_CMP_COUNT) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Disable interrupt to host */
@ -64,16 +65,16 @@ static int dw_aio_cmp_configure(struct device *dev, uint8_t index,
/* index out of range */
if (index >= AIO_DW_CMP_COUNT) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* make sure reference makes sense */
if ((refsel != AIO_CMP_REF_A) && (refsel != AIO_CMP_REF_B))
return DEV_INVALID_CONF;
return -EINVAL;
/* make sure polarity makes sense */
if ((polarity != AIO_CMP_POL_RISE) && (polarity != AIO_CMP_POL_FALL))
return DEV_INVALID_CONF;
return -EINVAL;
dev_data->cb[index].cb = cb;
dev_data->cb[index].param = param;
@ -162,7 +163,7 @@ int dw_aio_cmp_init(struct device *dev)
int i;
if ((config->base_address == 0) || (config->interrupt_num == 0))
return DEV_INVALID_CONF;
return -EINVAL;
if (config->config_func) {
i = config->config_func(dev);

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <stdio.h>
#include <nanokernel.h>
#include <board.h>
@ -45,11 +47,11 @@ static int aio_qmsi_cmp_disable(struct device *dev, uint8_t index)
qm_ac_config_t config;
if (qm_ac_get_config(&config) != QM_RC_OK) {
return DEV_INVALID_CONF;
return -EINVAL;
}
if (index >= AIO_QMSI_CMP_COUNT) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Disable interrupt to host */
@ -60,7 +62,7 @@ static int aio_qmsi_cmp_disable(struct device *dev, uint8_t index)
config.power &= ~(1 << index);
if (qm_ac_set_config(&config) != QM_RC_OK) {
return DEV_INVALID_CONF;
return -EINVAL;
}
return 0;
@ -77,11 +79,11 @@ static int aio_qmsi_cmp_configure(struct device *dev, uint8_t index,
qm_ac_config_t config;
if (qm_ac_get_config(&config) != QM_RC_OK) {
return DEV_INVALID_CONF;
return -EINVAL;
}
if (index >= AIO_QMSI_CMP_COUNT) {
return DEV_INVALID_CONF;
return -EINVAL;
}
aio_qmsi_cmp_disable(dev, index);
@ -107,7 +109,7 @@ static int aio_qmsi_cmp_configure(struct device *dev, uint8_t index,
config.power |= (1 << index);
if (qm_ac_set_config(&config) != QM_RC_OK) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Enable Interrupts to host for an specific comparator */

View file

@ -249,7 +249,7 @@ static int _bt_uart_init(struct device *unused)
h4_dev = device_get_binding(CONFIG_BLUETOOTH_UART_ON_DEV_NAME);
if (!h4_dev) {
return DEV_INVALID_CONF;
return -EINVAL;
}
bt_driver_register(&drv);

View file

@ -776,7 +776,7 @@ static int _bt_uart_init(struct device *unused)
h5_dev = device_get_binding(CONFIG_BLUETOOTH_UART_ON_DEV_NAME);
if (h5_dev == NULL) {
return DEV_INVALID_CONF;
return -EINVAL;
}
bt_driver_register(&drv);

View file

@ -16,6 +16,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <nanokernel.h>
#include <misc/ring_buffer.h>
#include <misc/printk.h>
@ -102,13 +104,13 @@ int ipm_console_receiver_init(struct device *d)
if (!ipm) {
printk("unable to bind IPM console receiver to '%s'\n",
__func__, config_info->bind_to);
return DEV_INVALID_CONF;
return -EINVAL;
}
if (ipm_max_id_val_get(ipm) < 0xFF) {
printk("IPM driver %s doesn't support 8-bit id values",
config_info->bind_to);
return DEV_INVALID_CONF;
return -EINVAL;
}
nano_sem_init(&driver_data->sem);

View file

@ -16,6 +16,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <nanokernel.h>
#include <misc/printk.h>
#include <ipm.h>
@ -51,7 +53,7 @@ int ipm_console_sender_init(struct device *d)
if (!ipm_console_device) {
printk("unable to bind IPM console sender to '%s'\n",
config_info->bind_to);
return DEV_INVALID_CONF;
return -EINVAL;
}
if (config_info->flags & IPM_CONSOLE_STDOUT) {

View file

@ -112,7 +112,7 @@ static int gpio_mmio_config(struct device *dev, int access_op,
/* Setup direction register */
if (!cfg->reg.dir) {
return DEV_INVALID_CONF;
return -EINVAL;
}
if (cfg->cfg_flags & GPIO_MMIO_CFG_DIR_MASK) {
@ -197,7 +197,7 @@ static int gpio_mmio_write(struct device *dev, int access_op,
dev->config->config_info;
if (!cfg->reg.output) {
return DEV_INVALID_CONF;
return -EINVAL;
}
switch (access_op) {
@ -231,7 +231,7 @@ static int gpio_mmio_read(struct device *dev, int access_op,
dev->config->config_info;
if (!cfg->reg.input) {
return DEV_INVALID_CONF;
return -EINVAL;
}
switch (access_op) {

View file

@ -385,7 +385,7 @@ static int gpio_pcal9535a_config(struct device *dev, int access_op,
#endif
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
ret = _setup_pin_dir(dev, access_op, pin, flags);
@ -434,7 +434,7 @@ static int gpio_pcal9535a_write(struct device *dev, int access_op,
int ret;
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Invert input value for pins configurated as active low. */
@ -490,7 +490,7 @@ static int gpio_pcal9535a_read(struct device *dev, int access_op,
int ret;
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
ret = _read_port_regs(dev, REG_INPUT_PORT0, &buf);
@ -546,7 +546,7 @@ static int gpio_pcal9535a_disable_callback(struct device *dev,
static int gpio_pcal9535a_suspend_port(struct device *dev)
{
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
return -ENOTSUP;
@ -555,7 +555,7 @@ static int gpio_pcal9535a_suspend_port(struct device *dev)
static int gpio_pcal9535a_resume_port(struct device *dev)
{
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
return -ENOTSUP;
@ -591,7 +591,7 @@ int gpio_pcal9535a_init(struct device *dev)
/* Find out the device struct of the I2C master */
i2c_master = device_get_binding((char *)config->i2c_master_dev_name);
if (!i2c_master) {
return DEV_INVALID_CONF;
return -EINVAL;
}
drv_data->i2c_master = i2c_master;

View file

@ -183,7 +183,7 @@ static inline int gpio_qmsi_config(struct device *port, int access_op,
{
if (((flags & GPIO_INT) && (flags & GPIO_DIR_OUT)) ||
((flags & GPIO_DIR_IN) && (flags & GPIO_DIR_OUT))) {
return DEV_INVALID_CONF;
return -EINVAL;
}
if (access_op == GPIO_ACCESS_BY_PIN) {

View file

@ -143,7 +143,7 @@ static int gpio_sch_config(struct device *dev,
if (access_op == GPIO_ACCESS_BY_PIN) {
if (pin >= info->bits) {
return DEV_INVALID_CONF;
return -EINVAL;
}
_gpio_pin_config(dev, pin, flags);

View file

@ -216,13 +216,13 @@ static int i2c_sam3_runtime_configure(struct device *dev, uint32_t config)
/* Currently support master mode only */
if (dev_data->dev_config.bits.is_slave_read) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Calculate clock dividers */
clk = clk_div_calc(dev);
if (!clk) {
return DEV_INVALID_CONF;
return -EINVAL;
}
/* Disable controller first before changing anything */
@ -628,7 +628,7 @@ static int i2c_sam3_init(struct device *dev)
!= 0) {
DBG("I2C: Cannot set default configuration 0x%x\n",
dev_data->dev_config.raw);
return DEV_INVALID_CONF;
return -EINVAL;
}
return 0;

View file

@ -375,7 +375,7 @@ static int _i2c_dw_setup(struct device *dev, uint16_t slave_address)
break;
case I2C_SPEED_HIGH:
if (!dw->support_hs_mode) {
return DEV_INVALID_CONF;
return -EINVAL;
}
DBG("I2C: speed set to HIGH\n");
@ -386,7 +386,7 @@ static int _i2c_dw_setup(struct device *dev, uint16_t slave_address)
break;
default:
DBG("I2C: invalid speed requested\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
DBG("I2C: lcnt = %d\n", dw->lcnt);
@ -605,12 +605,12 @@ static int i2c_dw_runtime_configure(struct device *dev, uint32_t config)
dw->hcnt = value;
} else {
rc = DEV_INVALID_CONF;
rc = -EINVAL;
}
break;
default:
/* TODO change */
rc = DEV_INVALID_CONF;
rc = -EINVAL;
}
/*

View file

@ -76,7 +76,7 @@ static int i2c_qmsi_configure(struct device *dev, uint32_t config)
/* This driver only supports master mode. */
if (!cfg.bits.is_master_device)
return DEV_INVALID_CONF;
return -EINVAL;
qm_cfg.mode = QM_I2C_MASTER;
qm_cfg.address_mode = (cfg.bits.use_10_bit_addr) ? QM_I2C_10_BIT :
@ -93,7 +93,7 @@ static int i2c_qmsi_configure(struct device *dev, uint32_t config)
qm_cfg.speed = QM_I2C_SPEED_FAST_PLUS;
break;
default:
return DEV_INVALID_CONF;
return -EINVAL;
}
if (qm_i2c_set_config(instance, &qm_cfg) != QM_RC_OK)

View file

@ -392,7 +392,7 @@ static int _i2c_qse_ss_setup(struct device *dev, uint16_t addr)
default:
DBG("I2C: invalid speed requested\n");
/* TODO change */
rc = DEV_INVALID_CONF;
rc = -EINVAL;
goto done;
}
@ -584,7 +584,7 @@ static int i2c_qse_ss_runtime_configure(struct device *dev, uint32_t config)
break;
default:
/* TODO change */
rc = DEV_INVALID_CONF;
rc = -EINVAL;
}
/*

View file

@ -16,6 +16,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <nanokernel.h>
#include <sections.h>
@ -226,7 +228,7 @@ static int _bt_nble_init(struct device *unused)
nble_dev = device_get_binding(CONFIG_NBLE_UART_ON_DEV_NAME);
if (!nble_dev) {
return DEV_INVALID_CONF;
return -EINVAL;
}
net_buf_pool_init(rx_pool);

View file

@ -310,35 +310,35 @@ int pinmux_fsl_k64_initialize(struct device *port)
#ifdef CONFIG_GPIO_K64_A
data->gpio_a = device_get_binding(CONFIG_PINMUX_K64_GPIO_A_NAME);
if (!data->gpio_a) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif
#ifdef CONFIG_GPIO_K64_B
data->gpio_b = device_get_binding(CONFIG_PINMUX_K64_GPIO_B_NAME);
if (!data->gpio_b) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif
#ifdef CONFIG_GPIO_K64_C
data->gpio_c = device_get_binding(CONFIG_PINMUX_K64_GPIO_C_NAME);
if (!data->gpio_c) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif
#ifdef CONFIG_GPIO_K64_D
data->gpio_d = device_get_binding(CONFIG_PINMUX_K64_GPIO_D_NAME);
if (!data->gpio_d) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif
#ifdef CONFIG_GPIO_K64_E
data->gpio_e = device_get_binding(CONFIG_PINMUX_K64_GPIO_E_NAME);
if (!data->gpio_e) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif

View file

@ -94,7 +94,7 @@ static int pwm_ftm_clk_enable(uint8_t ftm_num)
if (ftm_num > 3) {
DBG("ERROR: Illegal FTM number (%d).\n"
" Cannot enable PWM clock\n", ftm_num);
return DEV_INVALID_CONF;
return -EINVAL;
}
/* enabling the FTM by setting one of the bits SIM_SCGC6[26:24] */
@ -339,7 +339,7 @@ static int pwm_ftm_set_values(struct device *dev, int access_op,
/* If phase != 0 enable combine mode */
if (channel % 2 != 0) {
DBG("If Phase is non-zero pwm must be 0, 2, 4, 6.\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
DBG("Note: Enabling phase on pwm%d therefore "
@ -352,14 +352,14 @@ static int pwm_ftm_set_values(struct device *dev, int access_op,
case 0:
if (!config->phase_enable0) {
DBG("Error: Phase capability must be enabled on FTM0\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
break;
case 1:
if (!config->phase_enable2) {
DBG("Error: Phase capability must be enabled on FTM2\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
drv_data->phase[1] = on;
break;
@ -367,19 +367,19 @@ static int pwm_ftm_set_values(struct device *dev, int access_op,
case 2:
if (!config->phase_enable4) {
DBG("Error: Phase capability must be enabled on FTM4\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
break;
case 3:
if (!config->phase_enable6) {
DBG("Error: Phase capability must be enabled on FTM0\n");
return DEV_INVALID_CONF;
return -EINVAL;
}
break;
default:
return DEV_INVALID_CONF;
return -EINVAL;
}
drv_data->phase[pwm_pair] = on;
@ -406,7 +406,7 @@ static int pwm_ftm_set_values(struct device *dev, int access_op,
sys_write32(off, PWM_K64_FTM_CNV(config->reg_base, channel+1));
#else /*COMBINE_MODE_SUPPORT*/
DBG("Error: \"on\" value must be zero. Phase is not supported\n");
return DEV_INVALID_CONF;
return -EINVAL;
#endif /*COMBINE_MODE_SUPPORT*/
} else {

View file

@ -88,13 +88,13 @@ static int pwm_pca9685_set_values(struct device *dev, int access_op,
uint8_t buf[] = { 0, 0, 0, 0, 0};
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
switch (access_op) {
case PWM_ACCESS_BY_PIN:
if (pwm > MAX_PWM_OUT) {
return DEV_INVALID_CONF;
return -EINVAL;
}
buf[0] = REG_LED_ON_L(pwm);
break;
@ -159,7 +159,7 @@ static int pwm_pca9685_set_duty_cycle(struct device *dev, int access_op,
static int pwm_pca9685_suspend(struct device *dev)
{
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
return -ENOTSUP;
@ -168,7 +168,7 @@ static int pwm_pca9685_suspend(struct device *dev)
static int pwm_pca9685_resume(struct device *dev)
{
if (!_has_i2c_master(dev)) {
return DEV_INVALID_CONF;
return -EINVAL;
}
return -ENOTSUP;
@ -203,7 +203,7 @@ int pwm_pca9685_init(struct device *dev)
/* Find out the device struct of the I2C master */
i2c_master = device_get_binding((char *)config->i2c_master_dev_name);
if (!i2c_master) {
return DEV_INVALID_CONF;
return -EINVAL;
}
drv_data->i2c_master = i2c_master;

View file

@ -102,7 +102,7 @@ int mcp9808_init(struct device *dev)
if (!data->i2c_master) {
DBG("mcp9808: i2c master not found: %s\n",
CONFIG_MCP9808_I2C_DEV_NAME);
return DEV_INVALID_CONF;
return -EINVAL;
}
data->i2c_slave_addr = CONFIG_MCP9808_I2C_ADDR;

View file

@ -16,6 +16,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <nanokernel.h>
#include <i2c.h>
#include <gpio.h>
@ -76,7 +78,7 @@ int mcp9808_attr_set(struct device *dev, enum sensor_channel chan,
#ifdef CONFIG_SENSOR_DEBUG
if (chan != SENSOR_CHAN_TEMP) {
return DEV_INVALID_CONF;
return -EINVAL;
}
#endif
@ -92,7 +94,7 @@ int mcp9808_attr_set(struct device *dev, enum sensor_channel chan,
reg_val |= val->val1 << 4;
break;
default:
return DEV_INVALID_CONF;
return -EINVAL;
}
switch (attr) {
@ -103,7 +105,7 @@ int mcp9808_attr_set(struct device *dev, enum sensor_channel chan,
reg_addr = MCP9808_REG_UPPER_LIMIT;
break;
default:
return DEV_INVALID_CONF;
return -EINVAL;
}
return mcp9808_reg_write(data, reg_addr, reg_val);

View file

@ -170,7 +170,7 @@ int sx9500_init(struct device *dev)
if (!data->i2c_master) {
DBG("sx9500: i2c master not found: %s\n",
CONFIG_SX9500_I2C_DEV_NAME);
return DEV_INVALID_CONF;
return -EINVAL;
}
data->i2c_slave_addr = CONFIG_SX9500_I2C_ADDR;

View file

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <errno.h>
#include <nanokernel.h>
#include <i2c.h>
#include <sensor.h>
@ -56,7 +58,7 @@ int sx9500_trigger_set(struct device *dev,
break;
default:
return DEV_INVALID_CONF;
return -EINVAL;
}
return 0;
@ -145,7 +147,7 @@ int sx9500_setup_interrupt(struct device *dev)
if (!gpio) {
DBG("sx9500: gpio controller %s not found\n",
CONFIG_SX9500_GPIO_CONTROLLER);
return DEV_INVALID_CONF;
return -EINVAL;
}
gpio_pin_configure(gpio, CONFIG_SX9500_GPIO_PIN,

View file

@ -258,7 +258,7 @@ static inline int ns16550_pci_uart_scan(struct device *dev)
struct uart_device_config * const dev_cfg = DEV_CFG(dev);
if (dev_cfg->pci_dev.vendor_id == 0x0000) {
return DEV_INVALID_CONF;
return -EINVAL;
}
pci_bus_scan_init();

View file

@ -250,7 +250,7 @@ static int spi_dw_slave_select(struct device *dev, uint32_t slave)
DBG("%s: %p %d\n", __func__, dev, slave);
if (slave == 0 || slave > 4) {
return DEV_INVALID_CONF;
return -EINVAL;
}
spi->slave = 1 << (slave - 1);

View file

@ -200,7 +200,7 @@ static int spi_qmsi_transceive(struct device *dev,
rc = qm_spi_set_config(spi, cfg);
if (rc != QM_RC_OK)
return DEV_INVALID_CONF;
return -EINVAL;
spi_control_cs(dev, true);