jlaitine commented on code in PR #17010:
URL: https://github.com/apache/nuttx/pull/17010#discussion_r2409399216
##########
boards/boardctl.c:
##########
@@ -133,16 +133,14 @@ static inline int
case BOARDIOC_USBDEV_CONNECT: /* Connect the CDC/ACM device */
#ifndef CONFIG_CDCACM_COMPOSITE
{
- DEBUGASSERT(ctrl->handle != NULL);
ret = cdcacm_initialize(ctrl->instance, ctrl->handle);
}
#endif
break;
case BOARDIOC_USBDEV_DISCONNECT: /* Disconnect the CDC/ACM device
*/
{
- DEBUGASSERT(ctrl->handle != NULL && *ctrl->handle != NULL);
- cdcacm_uninitialize(*ctrl->handle);
+ ret = cdcacm_uninitialize_instance(ctrl->instance, NULL);
Review Comment:
For the memory protected builds, the client can't always store the handle.
The point here is that the caller doesn't need to store the handle, since it is
already stored by the kernel in the driver inode. If the client passes NULL
handle here, it means that the kernel looks up the handle from the filesystem
(see "cdcacm_uninitialize_instance" below). This PR essentially adds support
for unregistering the CDCACM by just knowing the instance number.
In the previous block the DEBUGASSERT has always been redundant, NULL
pointer was a valid argument for "cdcacm_initialize" aready before this PR. If
/ when the client doesn't need the handle, it can just pass in NULL pointer,
this is not an error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]