From cea3147c69b1054b991e5324b529beec21307b7c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 11 Jan 2015 08:05:09 -0600 Subject: USB host drivers: Change all parmeters named class to usbclass to avoid C++ conflicts --- nuttx/arch/arm/src/tiva/tiva_timer.h | 4 ++ nuttx/drivers/usbhost/usbhost_devaddr.c | 2 +- nuttx/drivers/usbhost/usbhost_enumerate.c | 14 ++-- nuttx/drivers/usbhost/usbhost_findclass.c | 12 ++-- nuttx/drivers/usbhost/usbhost_hidkbd.c | 42 ++++++------ nuttx/drivers/usbhost/usbhost_hidmouse.c | 41 ++++++------ nuttx/drivers/usbhost/usbhost_registerclass.c | 12 ++-- nuttx/drivers/usbhost/usbhost_registry.c | 2 +- nuttx/drivers/usbhost/usbhost_registry.h | 2 +- nuttx/drivers/usbhost/usbhost_skeleton.c | 69 ++++++++++--------- nuttx/drivers/usbhost/usbhost_storage.c | 95 ++++++++++++++------------- nuttx/include/nuttx/usb/usbhost.h | 27 ++++---- 12 files changed, 169 insertions(+), 153 deletions(-) diff --git a/nuttx/arch/arm/src/tiva/tiva_timer.h b/nuttx/arch/arm/src/tiva/tiva_timer.h index 1a33ad6d5..dc9e4b71d 100644 --- a/nuttx/arch/arm/src/tiva/tiva_timer.h +++ b/nuttx/arch/arm/src/tiva/tiva_timer.h @@ -199,6 +199,7 @@ struct tiva_timer32config_s struct { + /* No special configuration settings */ } rtc; } u; }; @@ -244,18 +245,21 @@ struct tiva_timer16config_s struct { + /* TODO: To be provided */ } count; /* 16-bit input time capture mode w/8-bit prescaler */ struct { + /* TODO: To be provided */ } time; /* 16-bit PWM output mode w/8-bit prescaler */ struct { + /* TODO: To be provided */ } pwm; } u; }; diff --git a/nuttx/drivers/usbhost/usbhost_devaddr.c b/nuttx/drivers/usbhost/usbhost_devaddr.c index 24eb63556..eb121c2ee 100755 --- a/nuttx/drivers/usbhost/usbhost_devaddr.c +++ b/nuttx/drivers/usbhost/usbhost_devaddr.c @@ -70,7 +70,7 @@ static void usbhost_takesem(FAR struct usbhost_devaddr_s *hcd) while (sem_wait(&hcd->exclsem) != 0) { - /* The only case that an error should occr here is if the wait was + /* The only case that an error should occur here is if the wait was * awakened by a signal. */ diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c index 97f9ac9ef..989f6923a 100644 --- a/nuttx/drivers/usbhost/usbhost_enumerate.c +++ b/nuttx/drivers/usbhost/usbhost_enumerate.c @@ -73,7 +73,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen, static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, const uint8_t *configdesc, int desclen, struct usbhost_id_s *id, uint8_t funcaddr, - FAR struct usbhost_class_s **class); + FAR struct usbhost_class_s **usbclass); /******************************************************************************* * Private Data @@ -224,7 +224,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen, static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, const uint8_t *configdesc, int desclen, struct usbhost_id_s *id, uint8_t funcaddr, - FAR struct usbhost_class_s **class) + FAR struct usbhost_class_s **usbclass) { FAR struct usbhost_class_s *devclass; const struct usbhost_registry_s *reg; @@ -259,7 +259,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, } else { - *class = devclass; + *usbclass = devclass; } } } @@ -290,7 +290,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, * the class create() method. * funcaddr - The USB address of the function containing the endpoint that EP0 * controls - * class - If the class driver for the device is successful located + * usbclass - If the class driver for the device is successful located * and bound to the driver, the allocated class instance is returned into * this caller-provided memory location. * @@ -306,7 +306,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, *******************************************************************************/ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, - FAR struct usbhost_class_s **class) + FAR struct usbhost_class_s **usbclass) { struct usb_ctrlreq_s *ctrlreq; struct usbhost_devinfo_s devinfo; @@ -318,7 +318,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, uint8_t *buffer; int ret; - DEBUGASSERT(drvr && class); + DEBUGASSERT(drvr && usbclass); /* Allocate descriptor buffers for use in this function. We will need two: * One for the request and one for the data buffer. @@ -542,7 +542,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, * will begin configuring the device. */ - ret = usbhost_classbind(drvr, buffer, cfglen, &id, funcaddr, class); + ret = usbhost_classbind(drvr, buffer, cfglen, &id, funcaddr, usbclass); if (ret != OK) { udbg("ERROR: usbhost_classbind returned %d\n", ret); diff --git a/nuttx/drivers/usbhost/usbhost_findclass.c b/nuttx/drivers/usbhost/usbhost_findclass.c index 8172db434..46fbfc76f 100644 --- a/nuttx/drivers/usbhost/usbhost_findclass.c +++ b/nuttx/drivers/usbhost/usbhost_findclass.c @@ -152,7 +152,7 @@ static bool usbhost_idmatch(const struct usbhost_id_s *classid, const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id) { - struct usbhost_registry_s *class; + struct usbhost_registry_s *usbclass; irqstate_t flags; int ndx; @@ -170,23 +170,23 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id /* Examine each register class in the linked list */ - for (class = g_classregistry; class; class = class->flink) + for (usbclass = g_classregistry; usbclass; usbclass = usbclass->flink) { /* If the registered class supports more than one ID, subclass, or * protocol, then try each. */ - uvdbg("Checking class:%p nids:%d\n", class, class->nids); - for (ndx = 0; ndx < class->nids; ndx++) + uvdbg("Checking class:%p nids:%d\n", usbclass, usbclass->nids); + for (ndx = 0; ndx < usbclass->nids; ndx++) { /* Did we find a matching ID? */ - if (usbhost_idmatch(&class->id[ndx], id)) + if (usbhost_idmatch(&usbclass->id[ndx], id)) { /* Yes.. restore interrupts and return the class info */ irqrestore(flags); - return class; + return usbclass; } } } diff --git a/nuttx/drivers/usbhost/usbhost_hidkbd.c b/nuttx/drivers/usbhost/usbhost_hidkbd.c index 53cd15561..9b07ad3e6 100644 --- a/nuttx/drivers/usbhost/usbhost_hidkbd.c +++ b/nuttx/drivers/usbhost/usbhost_hidkbd.c @@ -194,7 +194,7 @@ struct usbhost_state_s { /* This is the externally visible portion of the state */ - struct usbhost_class_s class; + struct usbhost_class_s usbclass; /* This is an instance of the USB host driver bound to this class instance */ @@ -223,7 +223,7 @@ struct usbhost_state_s * - OUT data from the host. * EP Interrupt IN: * - Receiving asynchronous (unrequested) IN data from the device. - * EP Interrrupt OUT (optional): + * EP Interrupt OUT (optional): * - Transmitting low latency OUT data to the device. * - If not present, EP0 used. */ @@ -277,7 +277,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *dev); /* Memory allocation services */ static inline FAR struct usbhost_state_s *usbhost_allocclass(void); -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class); +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass); /* Device name management */ @@ -327,10 +327,10 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr, /* struct usbhost_class_s methods */ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr); -static int usbhost_disconnected(FAR struct usbhost_class_s *class); +static int usbhost_disconnected(FAR struct usbhost_class_s *usbclass); /* Driver methods. We export the keyboard as a standard character driver */ @@ -676,21 +676,21 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Free a class instance previously allocated by usbhost_allocclass(). * * Input Parameters: - * class - A reference to the class instance to be freed. + * usbclass - A reference to the class instance to be freed. * * Returned Values: * None * ****************************************************************************/ -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass) { - DEBUGASSERT(class != NULL); + DEBUGASSERT(usbclass != NULL); /* Free the class instance. */ - uvdbg("Freeing: %p\n", class);; - kmm_free(class); + uvdbg("Freeing: %p\n", usbclass);; + kmm_free(usbclass); } /**************************************************************************** @@ -1801,14 +1801,14 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d { /* Initialize class method function pointers */ - priv->class.connect = usbhost_connect; - priv->class.disconnected = usbhost_disconnected; + priv->usbclass.connect = usbhost_connect; + priv->usbclass.disconnected = usbhost_disconnected; /* The initial reference count is 1... One reference is held by * the driver. */ - priv->crefs = 1; + priv->crefs = 1; /* Initialize semaphores */ @@ -1817,11 +1817,11 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d /* Bind the driver to the storage class instance */ - priv->drvr = drvr; + priv->drvr = drvr; /* Return the instance of the USB keyboard class driver */ - return &priv->class; + return &priv->usbclass; } } @@ -1848,7 +1848,7 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * descriptor to the class so that the class may initialize properly * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). + * usbclass - The USB host class entry previously obtained from a call to create(). * configdesc - A pointer to a uint8_t buffer container the configuration * descriptor. * desclen - The length in bytes of the configuration descriptor. @@ -1870,11 +1870,11 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * ****************************************************************************/ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; int ret; DEBUGASSERT(priv != NULL && @@ -1922,7 +1922,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * been disconnected. * * Input Parameters: - * class - The USB host class entry previously obtained from a call to + * usbclass - The USB host class entry previously obtained from a call to * create(). * * Returned Values: @@ -1934,9 +1934,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * ****************************************************************************/ -static int usbhost_disconnected(struct usbhost_class_s *class) +static int usbhost_disconnected(struct usbhost_class_s *usbclass) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; DEBUGASSERT(priv != NULL); diff --git a/nuttx/drivers/usbhost/usbhost_hidmouse.c b/nuttx/drivers/usbhost/usbhost_hidmouse.c index d79d94fd0..8e648bf16 100644 --- a/nuttx/drivers/usbhost/usbhost_hidmouse.c +++ b/nuttx/drivers/usbhost/usbhost_hidmouse.c @@ -253,7 +253,7 @@ struct usbhost_state_s { /* This is the externally visible portion of the state */ - struct usbhost_class_s class; + struct usbhost_class_s usbclass; /* This is an instance of the USB host driver bound to this class instance */ @@ -320,7 +320,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *dev); /* Memory allocation services */ static inline FAR struct usbhost_state_s *usbhost_allocclass(void); -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class); +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass); /* Device name management */ @@ -374,10 +374,10 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr, /* struct usbhost_class_s methods */ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr); -static int usbhost_disconnected(FAR struct usbhost_class_s *class); +static int usbhost_disconnected(FAR struct usbhost_class_s *usbclass); /* Driver methods. We export the mouse as a standard character driver */ @@ -531,21 +531,21 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Free a class instance previously allocated by usbhost_allocclass(). * * Input Parameters: - * class - A reference to the class instance to be freed. + * usbclass - A reference to the class instance to be freed. * * Returned Values: * None * ****************************************************************************/ -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass) { - DEBUGASSERT(class != NULL); + DEBUGASSERT(usbclass != NULL); /* Free the class instance. */ - uvdbg("Freeing: %p\n", class);; - kmm_free(class); + uvdbg("Freeing: %p\n", usbclass);; + kmm_free(usbclass); } /**************************************************************************** @@ -1874,14 +1874,14 @@ static FAR struct usbhost_class_s * { /* Initialize class method function pointers */ - priv->class.connect = usbhost_connect; - priv->class.disconnected = usbhost_disconnected; + priv->usbclass.connect = usbhost_connect; + priv->usbclass.disconnected = usbhost_disconnected; /* The initial reference count is 1... One reference is held by * the driver. */ - priv->crefs = 1; + priv->crefs = 1; /* Initialize semaphores */ @@ -1890,11 +1890,11 @@ static FAR struct usbhost_class_s * /* Bind the driver to the storage class instance */ - priv->drvr = drvr; + priv->drvr = drvr; /* Return the instance of the USB mouse class driver */ - return &priv->class; + return &priv->usbclass; } } @@ -1921,7 +1921,8 @@ static FAR struct usbhost_class_s * * descriptor to the class so that the class may initialize properly * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). + * usbclass - The USB host class entry previously obtained from a call to + * create(). * configdesc - A pointer to a uint8_t buffer container the configuration * descriptor. * desclen - The length in bytes of the configuration descriptor. @@ -1943,11 +1944,11 @@ static FAR struct usbhost_class_s * * ****************************************************************************/ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; int ret; DEBUGASSERT(priv != NULL && @@ -1995,7 +1996,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * been disconnected. * * Input Parameters: - * class - The USB host class entry previously obtained from a call to + * usbclass - The USB host class entry previously obtained from a call to * create(). * * Returned Values: @@ -2007,9 +2008,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * ****************************************************************************/ -static int usbhost_disconnected(struct usbhost_class_s *class) +static int usbhost_disconnected(struct usbhost_class_s *usbclass) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; int i; DEBUGASSERT(priv != NULL); diff --git a/nuttx/drivers/usbhost/usbhost_registerclass.c b/nuttx/drivers/usbhost/usbhost_registerclass.c index f4d1b64af..09d7c7c10 100644 --- a/nuttx/drivers/usbhost/usbhost_registerclass.c +++ b/nuttx/drivers/usbhost/usbhost_registerclass.c @@ -83,8 +83,8 @@ * bind a struct usbhost_class_s instance for the device. * * Input Parameters: - * class - An write-able instance of struct usbhost_registry_s that will be - * maintained in a registry. + * usbclass - An write-able instance of struct usbhost_registry_s that + * will be maintained in a registry. * * Returned Values: * On success, this function will return zero (OK). Otherwise, a negated @@ -92,11 +92,11 @@ * ****************************************************************************/ -int usbhost_registerclass(struct usbhost_registry_s *class) +int usbhost_registerclass(struct usbhost_registry_s *usbclass) { irqstate_t flags; - uvdbg("Registering class:%p nids:%d\n", class, class->nids); + uvdbg("Registering class:%p nids:%d\n", usbclass, usbclass->nids); /* g_classregistry is a singly-linkedlist of class ID information added by * calls to usbhost_registerclass(). Since this list is accessed from USB @@ -108,8 +108,8 @@ int usbhost_registerclass(struct usbhost_registry_s *class) /* Add the new class ID info to the head of the list */ - class->flink = g_classregistry; - g_classregistry = class; + usbclass->flink = g_classregistry; + g_classregistry = usbclass; irqrestore(flags); return OK; diff --git a/nuttx/drivers/usbhost/usbhost_registry.c b/nuttx/drivers/usbhost/usbhost_registry.c index fb2e900e2..db4c435e2 100644 --- a/nuttx/drivers/usbhost/usbhost_registry.c +++ b/nuttx/drivers/usbhost/usbhost_registry.c @@ -63,7 +63,7 @@ * Public Data ****************************************************************************/ -/* g_classregistry is a singly-linkedlist of class ID information added by +/* g_classregistry is a singly-linked list of class ID information added by * calls to usbhost_registerclass(). Since this list is accessed from USB * host controller interrupt handling logic, accesses to this list must be * protected by disabling interrupts. diff --git a/nuttx/drivers/usbhost/usbhost_registry.h b/nuttx/drivers/usbhost/usbhost_registry.h index 759a1c66e..27874429e 100644 --- a/nuttx/drivers/usbhost/usbhost_registry.h +++ b/nuttx/drivers/usbhost/usbhost_registry.h @@ -67,7 +67,7 @@ extern "C" # define EXTERN extern #endif -/* g_classregistry is a singly-linkedlist of class ID information added by +/* g_classregistry is a singly-linked list of class ID information added by * calls to usbhost_registerclass(). Since this list is accessed from USB * host controller interrupt handling logic, accesses to this list must be * protected by disabling interrupts. diff --git a/nuttx/drivers/usbhost/usbhost_skeleton.c b/nuttx/drivers/usbhost/usbhost_skeleton.c index b1af20f11..8a0ee452a 100644 --- a/nuttx/drivers/usbhost/usbhost_skeleton.c +++ b/nuttx/drivers/usbhost/usbhost_skeleton.c @@ -94,7 +94,7 @@ struct usbhost_state_s { /* This is the externally visible portion of the state */ - struct usbhost_class_s class; + struct usbhost_class_s usbclass; /* This is an instance of the USB host driver bound to this class instance */ @@ -126,13 +126,14 @@ static void usbhost_takesem(sem_t *sem); /* Memory allocation services */ static inline FAR struct usbhost_state_s *usbhost_allocclass(void); -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class); +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass); /* Device name management */ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv); static void usbhost_freedevno(FAR struct usbhost_state_s *priv); -static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *devname); +static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, + FAR char *devname); /* Worker thread actions */ @@ -141,8 +142,8 @@ static void usbhost_destroy(FAR void *arg); /* Helpers for usbhost_connect() */ static inline int usbhost_cfgdesc(FAR struct usbhost_state_s *priv, - FAR const uint8_t *configdesc, int desclen, - uint8_t funcaddr); + FAR const uint8_t *configdesc, + int desclen, uint8_t funcaddr); static inline int usbhost_devinit(FAR struct usbhost_state_s *priv); /* (Little Endian) Data helpers */ @@ -164,10 +165,10 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr, /* struct usbhost_class_s methods */ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr); -static int usbhost_disconnected(FAR struct usbhost_class_s *class); +static int usbhost_disconnected(FAR struct usbhost_class_s *usbclass); /* Driver methods -- depend upon the type of NuttX driver interface exported */ @@ -221,7 +222,7 @@ static void usbhost_takesem(sem_t *sem) while (sem_wait(sem) != 0) { - /* The only case that an error should occr here is if the wait was + /* The only case that an error should occur here is if the wait was * awakened by a signal. */ @@ -265,23 +266,23 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Free a class instance previously allocated by usbhost_allocclass(). * * Input Parameters: - * class - A reference to the class instance to be freed. + * usbclass - A reference to the class instance to be freed. * * Returned Values: * None * ****************************************************************************/ -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass) { - DEBUGASSERT(class != NULL); + DEBUGASSERT(usbclass != NULL); /* Free the class instance (perhaps calling sched_kmm_free() in case we are * executing from an interrupt handler. */ - uvdbg("Freeing: %p\n", class);; - kmm_free(class); + uvdbg("Freeing: %p\n", usbclass);; + kmm_free(usbclass); } /**************************************************************************** @@ -326,7 +327,8 @@ static void usbhost_freedevno(FAR struct usbhost_state_s *priv) } } -static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *devname) +static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, + FAR char *devname) { (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->devchar); } @@ -335,7 +337,7 @@ static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *dev * Name: usbhost_destroy * * Description: - * The USB device has been disconnected and the refernce count on the USB + * The USB device has been disconnected and the reference count on the USB * host class instance has gone to 1.. Time to destroy the USB host class * instance. * @@ -390,10 +392,11 @@ static void usbhost_destroy(FAR void *arg) * * Input Parameters: * priv - The USB host class instance. - * configdesc - A pointer to a uint8_t buffer container the configuration descripor. + * configdesc - A pointer to a uint8_t buffer container the configuration + * descriptor. * desclen - The length in bytes of the configuration descriptor. - * funcaddr - The USB address of the function containing the endpoint that EP0 - * controls + * funcaddr - The USB address of the function containing the endpoint that + * EP0 controls * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -863,12 +866,12 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d { /* Initialize class method function pointers */ - priv->class.connect = usbhost_connect; - priv->class.disconnected = usbhost_disconnected; + priv->usbclass.connect = usbhost_connect; + priv->usbclass.disconnected = usbhost_disconnected; /* The initial reference count is 1... One reference is held by the driver */ - priv->crefs = 1; + priv->crefs = 1; /* Initialize semphores (this works okay in the interrupt context) */ @@ -876,11 +879,11 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d /* Bind the driver to the storage class instance */ - priv->drvr = drvr; + priv->drvr = drvr; /* Return the instance of the USB class driver */ - return &priv->class; + return &priv->usbclass; } } @@ -906,11 +909,13 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * descriptor to the class so that the class may initialize properly * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). - * configdesc - A pointer to a uint8_t buffer container the configuration descripor. + * usbclass - The USB host class entry previously obtained from a call to + * create(). + * configdesc - A pointer to a uint8_t buffer container the configuration + * descriptor. * desclen - The length in bytes of the configuration descriptor. - * funcaddr - The USB address of the function containing the endpoint that EP0 - * controls + * funcaddr - The USB address of the function containing the endpoint + * that EP0 controls * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -927,11 +932,11 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * ****************************************************************************/ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; int ret; DEBUGASSERT(priv != NULL && @@ -969,7 +974,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * been disconnected. * * Input Parameters: - * class - The USB host class entry previously obtained from a call to + * usbclass - The USB host class entry previously obtained from a call to * create(). * * Returned Values: @@ -981,9 +986,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * ****************************************************************************/ -static int usbhost_disconnected(struct usbhost_class_s *class) +static int usbhost_disconnected(struct usbhost_class_s *usbclass) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; irqstate_t flags; DEBUGASSERT(priv != NULL); diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c index 0b8072467..04ee1baaf 100644 --- a/nuttx/drivers/usbhost/usbhost_storage.c +++ b/nuttx/drivers/usbhost/usbhost_storage.c @@ -118,7 +118,7 @@ struct usbhost_state_s { /* This is the externally visible portion of the state */ - struct usbhost_class_s class; + struct usbhost_class_s usbclass; /* This is an instance of the USB host driver bound to this class instance */ @@ -159,13 +159,14 @@ static void usbhost_takesem(sem_t *sem); /* Memory allocation services */ static inline FAR struct usbhost_state_s *usbhost_allocclass(void); -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class); +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass); /* Device name management */ static int usbhost_allocdevno(FAR struct usbhost_state_s *priv); static void usbhost_freedevno(FAR struct usbhost_state_s *priv); -static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, char *devname); +static inline void usbhost_mkdevname(FAR struct usbhost_state_s *priv, + FAR char *devname); /* CBW/CSW debug helpers */ @@ -232,10 +233,10 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr, /* struct usbhost_class_s methods */ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr); -static int usbhost_disconnected(FAR struct usbhost_class_s *class); +static int usbhost_disconnected(FAR struct usbhost_class_s *usbclass); /* struct block_operations methods */ @@ -334,7 +335,7 @@ static void usbhost_takesem(sem_t *sem) while (sem_wait(sem) != 0) { - /* The only case that an error should occr here is if the wait was + /* The only case that an error should occur here is if the wait was * awakened by a signal. */ @@ -405,7 +406,7 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) * Free a class instance previously allocated by usbhost_allocclass(). * * Input Parameters: - * class - A reference to the class instance to be freed. + * usbclass - A reference to the class instance to be freed. * * Returned Values: * None @@ -413,9 +414,9 @@ static inline FAR struct usbhost_state_s *usbhost_allocclass(void) ****************************************************************************/ #if CONFIG_USBHOST_NPREALLOC > 0 -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass) { - FAR struct usbhost_freestate_s *entry = (FAR struct usbhost_freestate_s *)class; + FAR struct usbhost_freestate_s *entry = (FAR struct usbhost_freestate_s *)usbclass; irqstate_t flags; DEBUGASSERT(entry != NULL); @@ -429,16 +430,16 @@ static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) irqrestore(flags); } #else -static inline void usbhost_freeclass(FAR struct usbhost_state_s *class) +static inline void usbhost_freeclass(FAR struct usbhost_state_s *usbclass) { - DEBUGASSERT(class != NULL); + DEBUGASSERT(usbclass != NULL); /* Free the class instance (calling sched_kmm_free() in case we are executing * from an interrupt handler. */ - uvdbg("Freeing: %p\n", class);; - kmm_free(class); + uvdbg("Freeing: %p\n", usbclass);; + kmm_free(usbclass); } #endif @@ -880,7 +881,7 @@ static inline int usbhost_inquiry(FAR struct usbhost_state_s *priv) * Name: usbhost_destroy * * Description: - * The USB mass storage device has been disconnected and the refernce count + * The USB mass storage device has been disconnected and the reference count * on the USB host class instance has gone to 1.. Time to destroy the USB * host class instance. * @@ -953,10 +954,11 @@ static void usbhost_destroy(FAR void *arg) * * Input Parameters: * priv - The USB host class instance. - * configdesc - A pointer to a uint8_t buffer container the configuration descripor. + * configdesc - A pointer to a uint8_t buffer container the configuration + * descriptor. * desclen - The length in bytes of the configuration descriptor. - * funcaddr - The USB address of the function containing the endpoint that EP0 - * controls + * funcaddr - The USB address of the function containing the endpoint that + * EP0 controls * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -1644,8 +1646,9 @@ static FAR struct usbmsc_cbw_s *usbhost_cbwalloc(FAR struct usbhost_state_s *pri * ****************************************************************************/ -static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr, - FAR const struct usbhost_id_s *id) +static FAR struct usbhost_class_s * +usbhost_create(FAR struct usbhost_driver_s *drvr, + FAR const struct usbhost_id_s *id) { FAR struct usbhost_state_s *priv; @@ -1664,12 +1667,12 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d { /* Initialize class method function pointers */ - priv->class.connect = usbhost_connect; - priv->class.disconnected = usbhost_disconnected; + priv->usbclass.connect = usbhost_connect; + priv->usbclass.disconnected = usbhost_disconnected; /* The initial reference count is 1... One reference is held by the driver */ - priv->crefs = 1; + priv->crefs = 1; /* Initialize semphores (this works okay in the interrupt context) */ @@ -1677,13 +1680,13 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d /* Bind the driver to the storage class instance */ - priv->drvr = drvr; + priv->drvr = drvr; /* NOTE: We do not yet know the geometry of the USB mass storage device */ /* Return the instance of the USB mass storage class */ - return &priv->class; + return &priv->usbclass; } } @@ -1709,11 +1712,13 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * descriptor to the class so that the class may initialize properly * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). - * configdesc - A pointer to a uint8_t buffer container the configuration descripor. + * usbclass - The USB host class entry previously obtained from a call to + * create(). + * configdesc - A pointer to a uint8_t buffer container the configuration + * descriptor. * desclen - The length in bytes of the configuration descriptor. - * funcaddr - The USB address of the function containing the endpoint that EP0 - * controls + * funcaddr - The USB address of the function containing the endpoint that + * EP0 controls * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -1730,11 +1735,11 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d * ****************************************************************************/ -static int usbhost_connect(FAR struct usbhost_class_s *class, +static int usbhost_connect(FAR struct usbhost_class_s *usbclass, FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; int ret; DEBUGASSERT(priv != NULL && @@ -1772,7 +1777,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * been disconnected. * * Input Parameters: - * class - The USB host class entry previously obtained from a call to + * usbclass - The USB host class entry previously obtained from a call to * create(). * * Returned Values: @@ -1784,9 +1789,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *class, * ****************************************************************************/ -static int usbhost_disconnected(struct usbhost_class_s *class) +static int usbhost_disconnected(struct usbhost_class_s *usbclass) { - FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class; + FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass; irqstate_t flags; DEBUGASSERT(priv != NULL); @@ -1963,9 +1968,9 @@ static ssize_t usbhost_read(FAR struct inode *inode, unsigned char *buffer, if (priv->disconnected) { - /* No... the block driver is no longer bound to the class. That means that - * the USB storage device is no longer connected. Refuse any attempt to read - * from the device. + /* No... the block driver is no longer bound to the class. That means + * that the USB storage device is no longer connected. Refuse any + * attempt to read from the device. */ ret = -ENODEV; @@ -2062,9 +2067,9 @@ static ssize_t usbhost_write(FAR struct inode *inode, const unsigned char *buffe if (priv->disconnected) { - /* No... the block driver is no longer bound to the class. That means that - * the USB storage device is no longer connected. Refuse any attempt to - * write to the device. + /* No... the block driver is no longer bound to the class. That means + * that the USB storage device is no longer connected. Refuse any + * attempt to write to the device. */ ret = -ENODEV; @@ -2150,9 +2155,9 @@ static int usbhost_geometry(FAR struct inode *inode, struct geometry *geometry) priv = (FAR struct usbhost_state_s *)inode->i_private; if (priv->disconnected) { - /* No... the block driver is no longer bound to the class. That means that - * the USB storage device is no longer connected. Refuse to return any - * geometry info. + /* No... the block driver is no longer bound to the class. That means + * that the USB storage device is no longer connected. Refuse to + * return any geometry info. */ ret = -ENODEV; @@ -2203,9 +2208,9 @@ static int usbhost_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) if (priv->disconnected) { - /* No... the block driver is no longer bound to the class. That means that - * the USB storage device is no longer connected. Refuse to process any - * ioctl commands. + /* No... the block driver is no longer bound to the class. That means + * that the USB storage device is no longer connected. Refuse to + * process any ioctl commands. */ ret = -ENODEV; diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h index e6deed85f..642cdf376 100644 --- a/nuttx/include/nuttx/usb/usbhost.h +++ b/nuttx/include/nuttx/usb/usbhost.h @@ -98,12 +98,12 @@ * * Description: * This macro will call the connect() method of struct usbhost_class_s. This - * method is a callback into the class implementation. It is used to provide the - * device's configuration descriptor to the class so that the class may initialize + * method is a callback into the usbclass implementation. It is used to provide the + * device's configuration descriptor to the usbclass so that the usbclass may initialize * properly * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). + * usbclass - The USB host class entry previously obtained from a call to create(). * configdesc - A pointer to a uint8_t buffer container the configuration descripor. * desclen - The length in bytes of the configuration descriptor. * funcaddr - The USB address of the function containing the endpoint that EP0 @@ -126,8 +126,8 @@ * ************************************************************************************/ -#define CLASS_CONNECT(class,configdesc,desclen,funcaddr) \ - ((class)->connect(class,configdesc,desclen, funcaddr)) +#define CLASS_CONNECT(usbclass,configdesc,desclen,funcaddr) \ + ((usbclass)->connect(usbclass,configdesc,desclen, funcaddr)) /************************************************************************************ * Name: CLASS_DISCONNECTED @@ -138,7 +138,7 @@ * class that the USB device has been disconnected. * * Input Parameters: - * class - The USB host class entry previously obtained from a call to create(). + * usbclass - The USB host class entry previously obtained from a call to create(). * * Returned Values: * On success, zero (OK) is returned. On a failure, a negated errno value is @@ -149,7 +149,7 @@ * ************************************************************************************/ -#define CLASS_DISCONNECTED(class) ((class)->disconnected(class)) +#define CLASS_DISCONNECTED(usbclass) ((usbclass)->disconnected(usbclass)) /******************************************************************************* * Name: CONN_WAIT @@ -584,12 +584,13 @@ struct usbhost_class_s * initialize properly (such as endpoint selections). */ - int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc, + int (*connect)(FAR struct usbhost_class_s *usbclass, + FAR const uint8_t *configdesc, int desclen, uint8_t funcaddr); /* This method informs the class that the USB device has been disconnected. */ - int (*disconnected)(FAR struct usbhost_class_s *class); + int (*disconnected)(FAR struct usbhost_class_s *usbclass); }; /* This structure describes one endpoint. It is used as an input to the @@ -765,7 +766,7 @@ extern "C" * the device. * * Input Parameters: - * class - An write-able instance of struct usbhost_registry_s that will be + * usbclass - An write-able instance of struct usbhost_registry_s that will be * maintained in a registry. * * Returned Values: @@ -774,7 +775,7 @@ extern "C" * ************************************************************************************/ -int usbhost_registerclass(struct usbhost_registry_s *class); +int usbhost_registerclass(struct usbhost_registry_s *usbclass); /************************************************************************************ * Name: usbhost_findclass @@ -902,7 +903,7 @@ int usbhost_wlaninit(void); * the class create() method. * funcaddr - The USB address of the function containing the endpoint that EP0 * controls - * class - If the class driver for the device is successful located + * usbclass - If the class driver for the device is successful located * and bound to the driver, the allocated class instance is returned into * this caller-provided memory location. * @@ -918,7 +919,7 @@ int usbhost_wlaninit(void); *******************************************************************************/ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, - FAR struct usbhost_class_s **class); + FAR struct usbhost_class_s **usbclass); #undef EXTERN #if defined(__cplusplus) -- cgit v1.2.3