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:51 UTC
[1/2] incubator-mynewt-core git commit: os; add error code OS_EBUSY
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/sterly_refactor 401e4636d -> c8a47199f
os; add error code OS_EBUSY
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/6407f494
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6407f494
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6407f494
Branch: refs/heads/sterly_refactor
Commit: 6407f494b9ca6412c9e253c2aa386808fa3947be
Parents: 401e463
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Aug 25 14:57:03 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Aug 25 14:57:03 2016 -0700
----------------------------------------------------------------------
libs/os/include/os/os.h | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6407f494/libs/os/include/os/os.h
----------------------------------------------------------------------
diff --git a/libs/os/include/os/os.h b/libs/os/include/os/os.h
index e36bb20..a8dbd5c 100644
--- a/libs/os/include/os/os.h
+++ b/libs/os/include/os/os.h
@@ -18,7 +18,7 @@
*/
#ifndef _OS_H
-#define _OS_H
+#define _OS_H
#include <stdlib.h>
//#include <stdint.h>
@@ -40,16 +40,16 @@
)
-/**
- * Whether or not the operating system has been started. Set to
+/**
+ * Whether or not the operating system has been started. Set to
* 1 right before first task is run.
*/
-extern int g_os_started;
+extern int g_os_started;
int os_info_init(void);
/**
- * Returns 1 if the OS has been started, 0 if it has not yet been
+ * Returns 1 if the OS has been started, 0 if it has not yet been
* been started.
*/
int os_started(void);
@@ -67,9 +67,10 @@ enum os_error {
OS_ERR_PRIV = 8, /* Privileged access error */
OS_NOT_STARTED = 9, /* Operating must be started to call this function, but isn't */
OS_ENOENT = 10, /* No such thing */
+ OS_EBUSY = 11, /* Resource busy */
};
-#define OS_WAIT_FOREVER (-1)
+#define OS_WAIT_FOREVER (-1)
typedef enum os_error os_error_t;
@@ -89,7 +90,7 @@ void os_init_idle_task(void);
#include "os/os_task.h"
#include "os/os_sched.h"
#include "os/os_eventq.h"
-#include "os/os_callout.h"
+#include "os/os_callout.h"
#include "os/os_heap.h"
#include "os/os_mutex.h"
#include "os/os_sem.h"
[2/2] incubator-mynewt-core git commit: uart drivers;
use os error codes as return values.
Posted by ma...@apache.org.
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;
}