[U-Boot] [PATCH v3 2/7] dfu:usb: DFU USB function (f_dfu) support for g_dnl composite gadget

Mike Frysinger
2012-08-01T22:45:34Z

On Tuesday 31 July 2012 02:36:58 Lukasz Majewski wrote:
> --- /dev/null
> +++ b/drivers/usb/gadget/f_dfu.c
>
> +static struct usb_interface_descriptor dfu_intf_runtime = {

can this be made const ?

> +static struct usb_descriptor_header *dfu_runtime_descs[] = {
> + (struct usb_descriptor_header *) &dfu_intf_runtime,

can you change the descs array to be const ?
static const struct usb_descriptor_header * const dfu_runtime_descs[] = {

then i think you can drop the cast there ...

> +static struct usb_qualifier_descriptor dev_qualifier = {
> +static struct usb_gadget_strings stringtab_dfu_generic = {
> +static struct usb_gadget_strings *dfu_generic_strings[] = {
> +static struct usb_gadget_strings stringtab_dfu = {
> +static struct usb_gadget_strings *dfu_strings[] = {

can these be made const ?

> +static void handle_getstate(struct usb_request *req)
> +{
> + struct f_dfu *f_dfu = req->context;
> +
> + ((u8 *)req->buf)[0] = f_dfu->dfu_state & 0xff;

pretty sure you don't need that "& 0xff"

> +static int state_app_idle(struct f_dfu *f_dfu,
> + const struct usb_ctrlrequest *ctrl,
> + struct usb_gadget *gadget,
> + struct usb_request *req)
> +{
> + int value = 0;

might be good to push this down into the 1 case statement
(USB_REQ_DFU_GETSTATE) that uses it rather than init it up top

same goes for all the other funcs below that follow this style
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120801/72139cae/attachment.pgp>