pinmux: Convert return codes to errno.h

Before moving pinmux related code to 'drivers/pinmux' fix their return
codes to be consistent with the rest of the API.

Change-Id: Ie84f64e93745d44bef8b9d2119f6a05cdc8cb8c4
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
Vinicius Costa Gomes 2016-03-18 11:58:02 -03:00 committed by Gerrit Code Review
commit facfc59464
6 changed files with 56 additions and 56 deletions

View file

@ -56,7 +56,7 @@
* *
* @param dev The UART device struct * @param dev The UART device struct
* *
* @return DEV_OK if successful, otherwise failed. * @return 0 if successful, otherwise failed.
*/ */
static int uart_k20_console_init(struct device *dev) static int uart_k20_console_init(struct device *dev)
{ {
@ -80,7 +80,7 @@ static int uart_k20_console_init(struct device *dev)
port_pcr_p->port[port].pcr[rxPin] = pcr; port_pcr_p->port[port].pcr[rxPin] = pcr;
port_pcr_p->port[port].pcr[txPin] = pcr; port_pcr_p->port[port].pcr[txPin] = pcr;
return DEV_OK; return 0;
} }
SYS_INIT(uart_k20_console_init, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); SYS_INIT(uart_k20_console_init, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
@ -124,7 +124,7 @@ static int uart_k20_init(struct device *dev)
sim->scgc1.field.uart4_clk_en = 1; sim->scgc1.field.uart4_clk_en = 1;
#endif #endif
return DEV_OK; return 0;
} }
DEVICE_INIT(_uart_k20_init, "", uart_k20_init, DEVICE_INIT(_uart_k20_init, "", uart_k20_init,
@ -204,7 +204,7 @@ int fsl_frdm_k64f_pin_init(struct device *arg)
pmux = device_get_binding(PINMUX_NAME); pmux = device_get_binding(PINMUX_NAME);
if (!pmux) { if (!pmux) {
return DEV_INVALID_CONF; return -EINVAL;
} }
/* configure the pins from the default mapping above */ /* configure the pins from the default mapping above */
@ -213,7 +213,7 @@ int fsl_frdm_k64f_pin_init(struct device *arg)
pinmux_pin_set(pmux, mux_config[i].pin_num, mux_config[i].mode); pinmux_pin_set(pmux, mux_config[i].pin_num, mux_config[i].mode);
} }
return DEV_OK; return 0;
} }
DEVICE_INIT(frdm_k64f_pmux, "", fsl_frdm_k64f_pin_init, NULL, NULL, DEVICE_INIT(frdm_k64f_pmux, "", fsl_frdm_k64f_pin_init, NULL, NULL,

View file

@ -218,7 +218,7 @@ static int _quark_se_set_mux(uint32_t base, uint32_t pin, uint8_t func)
(*(mux_register)) = ((*(mux_register)) & ~(0x1 << pin_offset)) | (*(mux_register)) = ((*(mux_register)) & ~(0x1 << pin_offset)) |
((func & 0x01) << pin_offset); ((func & 0x01) << pin_offset);
return DEV_OK; return 0;
} }
static inline void _pinmux_pullups(uint32_t base_address) static inline void _pinmux_pullups(uint32_t base_address)
@ -259,7 +259,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
uint32_t mode_mask = func << (pin_no << 1); uint32_t mode_mask = func << (pin_no << 1);
(*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask; (*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask;
return DEV_OK; return 0;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -294,7 +294,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
*func = mode; *func = mode;
return DEV_OK; return 0;
} }
#else #else
static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func) static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
@ -305,7 +305,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -316,7 +316,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
#endif /* CONFIG_PINMUX_DEV */ #endif /* CONFIG_PINMUX_DEV */
@ -328,7 +328,7 @@ static int pinmux_dev_pullup(struct device *dev,
_quark_se_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET, pin, func); _quark_se_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET, pin, func);
return DEV_OK; return 0;
} }
static int pinmux_dev_input(struct device *dev, uint32_t pin, uint8_t func) static int pinmux_dev_input(struct device *dev, uint32_t pin, uint8_t func)
{ {
@ -336,7 +336,7 @@ static int pinmux_dev_input(struct device *dev, uint32_t pin, uint8_t func)
_quark_se_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin, func); _quark_se_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin, func);
return DEV_OK; return 0;
} }
static struct pinmux_driver_api api_funcs = { static struct pinmux_driver_api api_funcs = {
@ -355,7 +355,7 @@ int pinmux_initialize(struct device *port)
_pinmux_defaults(pmux->base_address); _pinmux_defaults(pmux->base_address);
_pinmux_pullups(pmux->base_address); _pinmux_pullups(pmux->base_address);
return DEV_OK; return 0;
} }
struct pinmux_config board_pmux = { struct pinmux_config board_pmux = {

View file

@ -161,7 +161,7 @@ static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func)
ARG_UNUSED(dev); ARG_UNUSED(dev);
if (!port) { if (!port) {
return DEV_INVALID_CONF; return -EINVAL;
} }
tmp = port->absr; tmp = port->absr;
@ -172,7 +172,7 @@ static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func)
} }
port->absr = tmp; port->absr = tmp;
return DEV_OK; return 0;
} }
static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -182,12 +182,12 @@ static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func)
ARG_UNUSED(dev); ARG_UNUSED(dev);
if (!port) { if (!port) {
return DEV_INVALID_CONF; return -EINVAL;
} }
*func = (port->absr & (1 << (pin % 32))) ? 1 : 0; *func = (port->absr & (1 << (pin % 32))) ? 1 : 0;
return DEV_OK; return 0;
} }
#else #else
static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func) static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func)
@ -198,7 +198,7 @@ static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -209,7 +209,7 @@ static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
#endif /* CONFIG_PINMUX_DEV */ #endif /* CONFIG_PINMUX_DEV */
@ -220,7 +220,7 @@ static int pinmux_pullup(struct device *dev, uint32_t pin, uint8_t func)
ARG_UNUSED(dev); ARG_UNUSED(dev);
if (!port) { if (!port) {
return DEV_INVALID_CONF; return -EINVAL;
} }
if (func) { if (func) {
@ -229,7 +229,7 @@ static int pinmux_pullup(struct device *dev, uint32_t pin, uint8_t func)
port->pudr = (1 << (pin % 32)); port->pudr = (1 << (pin % 32));
} }
return DEV_OK; return 0;
} }
static int pinmux_input(struct device *dev, uint32_t pin, uint8_t func) static int pinmux_input(struct device *dev, uint32_t pin, uint8_t func)
{ {
@ -238,7 +238,7 @@ static int pinmux_input(struct device *dev, uint32_t pin, uint8_t func)
ARG_UNUSED(dev); ARG_UNUSED(dev);
if (!port) { if (!port) {
return DEV_INVALID_CONF; return -EINVAL;
} }
if (func) { if (func) {
@ -247,7 +247,7 @@ static int pinmux_input(struct device *dev, uint32_t pin, uint8_t func)
port->oer = (1 << (pin % 32)); port->oer = (1 << (pin % 32));
} }
return DEV_OK; return 0;
} }
@ -431,7 +431,7 @@ int pinmux_init(struct device *port)
__pinmux_defaults(); __pinmux_defaults();
return DEV_OK; return 0;
} }
DEVICE_INIT(pmux, PINMUX_NAME, &pinmux_init, NULL, NULL, DEVICE_INIT(pmux, PINMUX_NAME, &pinmux_init, NULL, NULL,

View file

@ -547,7 +547,7 @@ int _galileo_set_pin(struct device *port, uint8_t pin, uint8_t func)
struct mux_path *enable = NULL; struct mux_path *enable = NULL;
if (pin > CONFIG_PINMUX_NUM_PINS) { if (pin > CONFIG_PINMUX_NUM_PINS) {
return DEV_INVALID_OP; return -ENOTSUP;
} }
/* NUM_PIN_FUNCS being the number of alt functions */ /* NUM_PIN_FUNCS being the number of alt functions */
@ -624,7 +624,7 @@ int _galileo_set_pin(struct device *port, uint8_t pin, uint8_t func)
} }
} }
return DEV_OK; return 0;
} }
#ifdef CONFIG_PINMUX_DEV #ifdef CONFIG_PINMUX_DEV
@ -633,7 +633,7 @@ static int galileo_dev_set(struct device *dev,
uint32_t func) uint32_t func)
{ {
if (pin > CONFIG_PINMUX_NUM_PINS) { if (pin > CONFIG_PINMUX_NUM_PINS) {
return DEV_INVALID_CONF; return -EINVAL;
} }
mux_config[pin].mode = func; mux_config[pin].mode = func;
@ -646,12 +646,12 @@ static int galileo_dev_get(struct device *dev,
uint32_t *func) uint32_t *func)
{ {
if (pin > CONFIG_PINMUX_NUM_PINS) { if (pin > CONFIG_PINMUX_NUM_PINS) {
return DEV_INVALID_CONF; return -EINVAL;
} }
*func = mux_config[pin].mode; *func = mux_config[pin].mode;
return DEV_OK; return 0;
} }
#else #else
static int galileo_dev_set(struct device *dev, static int galileo_dev_set(struct device *dev,
@ -662,7 +662,7 @@ static int galileo_dev_set(struct device *dev,
ARG_UNUSED(pin); ARG_UNUSED(pin);
ARG_UNUSED(func); ARG_UNUSED(func);
return DEV_INVALID_OP; return -ENOTSUP;
} }
static int galileo_dev_get(struct device *dev, static int galileo_dev_get(struct device *dev,
@ -673,7 +673,7 @@ static int galileo_dev_get(struct device *dev,
ARG_UNUSED(pin); ARG_UNUSED(pin);
ARG_UNUSED(func); ARG_UNUSED(func);
return DEV_INVALID_OP; return -ENOTSUP;
} }
#endif #endif
@ -686,7 +686,7 @@ static int galileo_dev_pullup(struct device *dev,
* On Galileo the pullup operation is handled through the selection * On Galileo the pullup operation is handled through the selection
* of an actual pin * of an actual pin
*/ */
return DEV_OK; return 0;
} }
static int galileo_dev_input_enable(struct device *dev, static int galileo_dev_input_enable(struct device *dev,
@ -698,7 +698,7 @@ static int galileo_dev_input_enable(struct device *dev,
* On Galileo select a pin for input enabling is handled through the * On Galileo select a pin for input enabling is handled through the
* selection of an actual pin user configuration. * selection of an actual pin user configuration.
*/ */
return DEV_OK; return 0;
} }
static struct pinmux_driver_api api_funcs = { static struct pinmux_driver_api api_funcs = {
@ -718,33 +718,33 @@ int pinmux_galileo_initialize(struct device *port)
/* Grab the EXP0, EXP1, EXP2, and PWM0 now by name */ /* Grab the EXP0, EXP1, EXP2, and PWM0 now by name */
dev->exp0 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP0_NAME); dev->exp0 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP0_NAME);
if (!dev->exp0) { if (!dev->exp0) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->exp1 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP1_NAME); dev->exp1 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP1_NAME);
if (!dev->exp1) { if (!dev->exp1) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->exp2 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP2_NAME); dev->exp2 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP2_NAME);
if (!dev->exp2) { if (!dev->exp2) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->pwm0 = device_get_binding(CONFIG_PINMUX_GALILEO_PWM0_NAME); dev->pwm0 = device_get_binding(CONFIG_PINMUX_GALILEO_PWM0_NAME);
if (!dev->pwm0) { if (!dev->pwm0) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->gpio_dw = device_get_binding(CONFIG_PINMUX_GALILEO_GPIO_DW_NAME); dev->gpio_dw = device_get_binding(CONFIG_PINMUX_GALILEO_GPIO_DW_NAME);
if (!dev->gpio_dw) { if (!dev->gpio_dw) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->gpio_core = device_get_binding( dev->gpio_core = device_get_binding(
CONFIG_PINMUX_GALILEO_GPIO_INTEL_CW_NAME); CONFIG_PINMUX_GALILEO_GPIO_INTEL_CW_NAME);
if (!dev->gpio_core) { if (!dev->gpio_core) {
return DEV_INVALID_CONF; return -EINVAL;
} }
dev->gpio_resume = device_get_binding( dev->gpio_resume = device_get_binding(
CONFIG_PINMUX_GALILEO_GPIO_INTEL_RW_NAME); CONFIG_PINMUX_GALILEO_GPIO_INTEL_RW_NAME);
if (!dev->gpio_resume) { if (!dev->gpio_resume) {
return DEV_INVALID_CONF; return -EINVAL;
} }
/* /*
@ -757,7 +757,7 @@ int pinmux_galileo_initialize(struct device *port)
mux_config[i].mode); mux_config[i].mode);
} }
return DEV_OK; return 0;
} }

View file

@ -181,7 +181,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
(*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask; (*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask;
return DEV_OK; return 0;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -215,7 +215,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
*func = mode; *func = mode;
return DEV_OK; return 0;
} }
#else #else
static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func) static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
@ -226,7 +226,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -237,7 +237,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
#endif /* CONFIG_PINMUX_DEV */ #endif /* CONFIG_PINMUX_DEV */
@ -249,7 +249,7 @@ static int pinmux_pullup_set(struct device *dev, uint32_t pin,
_quark_d2000_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET, pin, _quark_d2000_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET, pin,
func); func);
return DEV_OK; return 0;
} }
static int pinmux_input_enable(struct device *dev, uint32_t pin, static int pinmux_input_enable(struct device *dev, uint32_t pin,
@ -260,7 +260,7 @@ static int pinmux_input_enable(struct device *dev, uint32_t pin,
_quark_d2000_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin, _quark_d2000_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin,
func); func);
return DEV_OK; return 0;
} }
static struct pinmux_driver_api api_funcs = { static struct pinmux_driver_api api_funcs = {
@ -281,7 +281,7 @@ int pinmux_initialize(struct device *port)
/* Enable the UART RX pin to receive input */ /* Enable the UART RX pin to receive input */
_quark_d2000_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, 5, 0x1); _quark_d2000_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, 5, 0x1);
return DEV_OK; return 0;
} }
struct pinmux_config board_pmux = { struct pinmux_config board_pmux = {

View file

@ -210,7 +210,7 @@ static int _quark_se_set_mux(uint32_t base, uint32_t pin, uint8_t func)
(*(mux_register)) = ((*(mux_register)) & ~(0x1 << pin_offset)) | (*(mux_register)) = ((*(mux_register)) & ~(0x1 << pin_offset)) |
(func << pin_offset); (func << pin_offset);
return DEV_OK; return 0;
} }
#ifdef CONFIG_PINMUX_DEV #ifdef CONFIG_PINMUX_DEV
@ -245,7 +245,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
uint32_t mode_mask = func << (pin_no << 1); uint32_t mode_mask = func << (pin_no << 1);
(*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask; (*(mux_register)) = ((*(mux_register)) & ~pin_mask) | mode_mask;
return DEV_OK; return 0;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -281,7 +281,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
*func = mode; *func = mode;
return DEV_OK; return 0;
} }
#else #else
static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func) static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
@ -292,7 +292,7 @@ static int pinmux_dev_set(struct device *dev, uint32_t pin, uint32_t func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func) static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
@ -303,7 +303,7 @@ static int pinmux_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
PRINT("ERROR: %s is not enabled", __func__); PRINT("ERROR: %s is not enabled", __func__);
return DEV_NOT_CONFIG; return -EPERM;
} }
#endif /* CONFIG_PINMUX_DEV */ #endif /* CONFIG_PINMUX_DEV */
@ -316,7 +316,7 @@ static int pinmux_dev_pullup(struct device *dev,
_quark_se_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET, _quark_se_set_mux(pmux->base_address + PINMUX_PULLUP_OFFSET,
pin, func); pin, func);
return DEV_OK; return 0;
} }
static int pinmux_dev_input(struct device *dev, static int pinmux_dev_input(struct device *dev,
uint32_t pin, uint8_t func) uint32_t pin, uint8_t func)
@ -325,7 +325,7 @@ static int pinmux_dev_input(struct device *dev,
_quark_se_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin, func); _quark_se_set_mux(pmux->base_address + PINMUX_INPUT_OFFSET, pin, func);
return DEV_OK; return 0;
} }
static struct pinmux_driver_api api_funcs = { static struct pinmux_driver_api api_funcs = {
@ -344,7 +344,7 @@ int pinmux_initialize(struct device *port)
_pinmux_defaults(pmux->base_address); _pinmux_defaults(pmux->base_address);
_pinmux_pullups(pmux->base_address); _pinmux_pullups(pmux->base_address);
return DEV_OK; return 0;
} }
struct pinmux_config board_pmux = { struct pinmux_config board_pmux = {