Seems like we've (tried) to fix this in the past, although it crept in
again. Just use a compiler directive and drop the error prone individual
includes.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
These allow descriptors with common fields at the start, one of
which common fields specifies a field whos value determines which
of a set of descriptor extensions should be used to render the
remainder of the descriptor.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Splits out the rendering of fields from desc_dump() since it
is a single unit of functionality and the desc_dump() function
had grown quite complex.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
This removes the "boiler-plate" license texts in the individual files to
use SPDX identifiers instead. Cleans up the text a lot.
All copyright notices were left intact, as this does not change
anything.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This fixes a divide by zero which happened when an array,
without an explicit entry count (ultimately calculated from
the value in the descriptor data's bLength field) was used
on field with a variable size.
The solultion is to use the get_entry_size() function on
the array entry, which can get the entry size from a
referenced field.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This squashes "warning: comparison between pointer and zero character"
This was an empty string check that was checking the pointer rather
than the first character. The check was done correctly before the
string was used, so here we yank the correct check up, to the upper
level, replacing the ineffectual/broken one.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
These descriptor definitions descibe how raw descriptor data
should be interpreted.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This adds a new way of dumping descriptors. It takes the descriptor
data to be dumped, and a descriptor definition as input.
The descriptor definition takes the form of a NULL terminated array
of descriptor field definitions.
These definitions describe how the raw descriptor data buffer should
be interpreted.
Thus the knowledge of how to interpret a descriptor buffer is separate
from the shared code that renders the descriptor dump. This has two
advantages:
1. The code for dumping descriptors is common, so the output is easy
to keep consistent. It is also consistent and thorough in its
handling of insufficient descriptor data buffer, and junk data
at the end of a descriptor.
2. It is easy to add support for new descriptors, since they are now
simple definitions that resemble the tables in the USB specifications.
Signed-off-by: Michael Drake <michael.drake@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>