USB HUB: Update all USB host connection waiter application threads to use the the new connection interface

This commit is contained in:
Gregory Nutt 2015-04-28 12:21:23 -06:00
parent 1441689cc9
commit 7042225a8a
15 changed files with 98 additions and 177 deletions

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/cloudctrl/src/stm32_usb.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Darcy Gong <darcy.gong@gmail.com>
*
@ -45,6 +45,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -100,27 +101,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/mikroe_stm32f4/src/stm32_usb.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -98,28 +99,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
UNUSED(ret);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -44,6 +44,7 @@
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -170,28 +171,23 @@ static FAR struct sdio_dev_s *g_sdiodev;
#ifdef NSH_HAVE_USBHOST
static int nsh_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
syslog(LOG_INFO, "nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
syslog(LOG_INFO, "nsh_waiter: %s\n",
connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -43,6 +43,7 @@
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
@ -173,28 +174,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVEUSBHOST
static int nsh_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
syslog(LOG_INFO, "nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
syslog(LOG_INFO, "nsh_waiter: %s\n",
connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -43,6 +43,7 @@
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
@ -172,28 +173,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVEUSBHOST
static int nsh_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
syslog(LOG_INFO, "nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
syslog(LOG_INFO, "nsh_waiter: %s\n",
connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/sama5d3-xplained/src/sam_usb.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
static int usbhost_waiter(struct usbhost_connection_s *dev)
#endif
{
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
int rhpndx;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("%s Waiter Running\n", hcistr);
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
rhpndx = CONN_WAIT(dev, connected);
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
connected[rhpndx] = !connected[rhpndx];
uvdbg("%s RHport%d %s\n",
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(dev, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected[rhpndx])
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
ret = CONN_ENUMERATE(dev, rhpndx);
if (ret < 0)
{
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
connected[rhpndx] = false;
}
(void)CONN_ENUMERATE(dev, hport);
}
}

View File

@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
static int usbhost_waiter(struct usbhost_connection_s *dev)
#endif
{
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
int rhpndx;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("%s Waiter Running\n", hcistr);
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
rhpndx = CONN_WAIT(dev, connected);
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
connected[rhpndx] = !connected[rhpndx];
uvdbg("%s RHport%d %s\n",
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(dev, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected[rhpndx])
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
ret = CONN_ENUMERATE(dev, rhpndx);
if (ret < 0)
{
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
connected[rhpndx] = false;
}
(void)CONN_ENUMERATE(dev, hport);
}
}

View File

@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
static int usbhost_waiter(struct usbhost_connection_s *dev)
#endif
{
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
int rhpndx;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("%s Waiter Running\n", hcistr);
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
rhpndx = CONN_WAIT(dev, connected);
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
connected[rhpndx] = !connected[rhpndx];
uvdbg("%s RHport%d %s\n",
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(dev, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected[rhpndx])
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
ret = CONN_ENUMERATE(dev, rhpndx);
if (ret < 0)
{
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
connected[rhpndx] = false;
}
(void)CONN_ENUMERATE(dev, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/shenzhou/src/stm32_usb.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/stm3220g-eval/src/stm32_usb.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/stm3240g-eval/src/stm32_usbdev.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,28 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
UNUSED(ret);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* configs/stm32f4discovery/src/stm32_usb.c
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -44,6 +44,7 @@
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@ -99,28 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef CONFIG_USBHOST
static int usbhost_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
uvdbg("Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
UNUSED(ret);
connected = !connected;
uvdbg("%s\n", connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* config/sure-pic32mx/src/pic32mx_nsh.c
*
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -43,6 +43,7 @@
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <assert.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
@ -165,28 +166,23 @@ static struct usbhost_connection_s *g_usbconn;
#ifdef NSH_HAVE_USBHOST
static int nsh_waiter(int argc, char *argv[])
{
bool connected = false;
int ret;
struct usbhost_hubport_s *hport;
syslog(LOG_INFO, "nsh_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
syslog(LOG_INFO, "nsh_waiter: %s\n",
connected ? "connected" : "disconnected");
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (connected)
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, 0);
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}