Set limit and count to integers to not overflow during failed hotplug attempts and then not trying again.
Disable USB stats which were not meant to be enabled by default and add extra memory for a memory error when stats are enabled.
There is no need to limit usb write transfers to maxpacketsize and it's harmful for large transfers on slow devices such as wrt routers.
The json_val in api.c is a borrowed reference, not a new one so don't decref it.
Simplify the end of message detection in _usb_read and allow it to return without doing another read if the message is already in the buffer.
Only check strlen on end if end exists.
Don't lose data beyond the end of message in a usb read.
Change the processed value not the bufsiz in response to an end of message marker.
Zero the read buffer in _usb_read to avoid stale data and only use stack memory instead of using the bulkbuf since it is only used in _usb_read.