summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2016-04-12 13:53:42 +0200
committerDaniel Hellstrom <daniel@gaisler.com>2016-04-12 13:55:33 +0200
commitc7d624eedc3995f4554505e565013a5103d37c48 (patch)
tree325d5053407ab7cfa8575612dcb5011abe95f3cc
parent7bae805b8b0d1e0afb8de896bb66591e76c00c22 (diff)
leon, grspw_pkt: Added checks for special list casesrcc-v1.2.19
- Fixed grspw_dma_tx_send() so that it does not fail when an empty user packet is provided. - Added empty checks on some of the list handling inline functions for GRSPW_PKT. Their use by the driver may be correct already, but the user might not have been aware of the assumptions that certain lists had to be non-empty.
-rw-r--r--c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h9
-rw-r--r--c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c4
2 files changed, 11 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h b/c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h
index ec0fe06d04..8277b87ae4 100644
--- a/c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h
+++ b/c/src/lib/libbsp/sparc/shared/include/grspw_pkt.h
@@ -646,6 +646,9 @@ grspw_list_prepend(struct grspw_list *list, struct grspw_pkt *pkt)
static inline void
grspw_list_append_list(struct grspw_list *list, struct grspw_list *alist)
{
+ if (grspw_list_is_empty(alist)) {
+ return;
+ }
alist->tail->next = NULL;
if ( list->tail == NULL ) {
list->head = alist->head;
@@ -658,6 +661,9 @@ grspw_list_append_list(struct grspw_list *list, struct grspw_list *alist)
static inline void
grspw_list_prepend_list(struct grspw_list *list, struct grspw_list *alist)
{
+ if (grspw_list_is_empty(alist)) {
+ return;
+ }
if ( list->head == NULL ) {
list->tail = alist->tail;
alist->tail->next = NULL;
@@ -671,6 +677,9 @@ grspw_list_prepend_list(struct grspw_list *list, struct grspw_list *alist)
static inline void
grspw_list_remove_head_list(struct grspw_list *list, struct grspw_list *dlist)
{
+ if (grspw_list_is_empty(dlist)) {
+ return;
+ }
list->head = dlist->tail->next;
if ( list->head == NULL ) {
list->tail = NULL;
diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c
index bb402d20dc..da0362b141 100644
--- a/c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c
+++ b/c/src/lib/libbsp/sparc/shared/spw/grspw_pkt.c
@@ -1841,7 +1841,7 @@ int grspw_dma_tx_send(void *c, int opts, struct grspw_list *pkts, int count)
grspw_tx_process_scheduled(dma);
/* 2. Add the requested packets to the SEND List (USER->SEND) */
- if (pkts) {
+ if (pkts && (count > 0)) {
grspw_list_append_list(&dma->send, pkts);
dma->send_cnt += count;
if (dma->stats.send_cnt_max < dma->send_cnt)
@@ -3104,7 +3104,7 @@ static int grspw_common_init(void)
if (rtems_task_start(grspw_work_task, grspw_work_func, 0) !=
RTEMS_SUCCESSFUL)
return -1;
- }
+}
grspw_initialized = 1;
return 0;