You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/08/25 21:58:52 UTC
[2/2] incubator-mynewt-core git commit: uart drivers;
use os error codes as return values.
uart drivers; use os error codes as return values.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c8a47199
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c8a47199
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c8a47199
Branch: refs/heads/sterly_refactor
Commit: c8a47199f396682e5ac0f02a8057bafb3ede9da4
Parents: 6407f49
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Aug 25 14:57:23 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Aug 25 14:57:23 2016 -0700
----------------------------------------------------------------------
drivers/uart/uart_bitbang/src/uart_bitbang.c | 13 +++++++-----
drivers/uart/uart_hal/src/uart_hal.c | 25 +++++++++++++++++------
2 files changed, 27 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c8a47199/drivers/uart/uart_bitbang/src/uart_bitbang.c
----------------------------------------------------------------------
diff --git a/drivers/uart/uart_bitbang/src/uart_bitbang.c b/drivers/uart/uart_bitbang/src/uart_bitbang.c
index ebabb49..c20682e 100644
--- a/drivers/uart/uart_bitbang/src/uart_bitbang.c
+++ b/drivers/uart/uart_bitbang/src/uart_bitbang.c
@@ -289,8 +289,11 @@ uart_bitbang_open(struct os_dev *odev, uint32_t wait, void *arg)
ub->ub_tx_done = uc->uc_tx_done;
ub->ub_func_arg = uc->uc_cb_arg;
- return uart_bitbang_config(ub, uc->uc_speed, uc->uc_databits,
- uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl);
+ if (uart_bitbang_config(ub, uc->uc_speed, uc->uc_databits,
+ uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl)) {
+ return OS_EINVAL;
+ }
+ return OS_OK;
}
static int
@@ -310,7 +313,7 @@ uart_bitbang_close(struct os_dev *odev)
cputime_timer_stop(&ub->ub_tx.timer);
cputime_timer_stop(&ub->ub_rx.timer);
OS_EXIT_CRITICAL(sr);
- return 0;
+ return OS_OK;
}
int
@@ -322,7 +325,7 @@ uart_bitbang_init(struct os_dev *odev, void *arg)
ub = (struct uart_bitbang *)os_malloc(sizeof(struct uart_bitbang));
if (!ub) {
- return -1;
+ return OS_ENOMEM;
}
memset(ub, 0, sizeof(*ub));
@@ -338,6 +341,6 @@ uart_bitbang_init(struct os_dev *odev, void *arg)
dev->ud_funcs.uf_blocking_tx = uart_bitbang_blocking_tx;
dev->ud_priv = ub;
- return 0;
+ return OS_OK;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c8a47199/drivers/uart/uart_hal/src/uart_hal.c
----------------------------------------------------------------------
diff --git a/drivers/uart/uart_hal/src/uart_hal.c b/drivers/uart/uart_hal/src/uart_hal.c
index 3937ce6..7244240 100644
--- a/drivers/uart/uart_hal/src/uart_hal.c
+++ b/drivers/uart/uart_hal/src/uart_hal.c
@@ -69,28 +69,41 @@ uart_hal_open(struct os_dev *odev, uint32_t wait, void *arg)
{
struct uart_hal_priv *priv;
struct uart_conf *uc;
+ int rc;
priv = ((struct uart_dev *)odev)->ud_priv;
uc = (struct uart_conf *)arg;
if (!uc) {
- return -1;
+ return OS_EINVAL;
+ }
+ if (odev->od_status & OS_DEV_STATUS_OPEN) {
+ return OS_EBUSY;
}
hal_uart_init_cbs(priv->unit, uc->uc_tx_char, uc->uc_tx_done,
uc->uc_rx_char, uc->uc_cb_arg);
- return hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits,
+ rc = hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits,
uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl);
+ if (rc) {
+ return OS_EINVAL;
+ }
+ return OS_OK;
}
static int
uart_hal_close(struct os_dev *odev)
{
struct uart_hal_priv *priv;
+ int rc;
priv = ((struct uart_dev *)odev)->ud_priv;
- return hal_uart_close(priv->unit);
+ rc = hal_uart_close(priv->unit);
+ if (rc) {
+ return OS_EINVAL;
+ }
+ return OS_OK;
}
/*
@@ -105,13 +118,13 @@ uart_hal_init(struct os_dev *odev, void *arg)
priv = os_malloc(sizeof(struct uart_hal_priv));
if (!priv) {
- return -1;
+ return OS_ENOMEM;
}
priv->unit = -1;
ch = odev->od_name[strlen(odev->od_name) - 1];
if (!isdigit(ch)) {
- return -1;
+ return OS_EINVAL;
}
priv->unit = ch - '0';
@@ -126,5 +139,5 @@ uart_hal_init(struct os_dev *odev, void *arg)
hal_uart_init(priv->unit, arg);
- return 0;
+ return OS_OK;
}