void show_gadget(struct gadget *g)
{
fprintf(stdout, "ID %04x:%04x '%s'\n",
- g->vendor, g->product, g->name);
+ g->attrs.vendor, g->attrs.product, g->name);
fprintf(stdout, " UDC\t\t\t%s\n", g->udc);
- fprintf(stdout, " bDeviceClass\t\t0x%02x\n", g->dclass);
- fprintf(stdout, " bDeviceSubClass\t0x%02x\n", g->dsubclass);
- fprintf(stdout, " bDeviceProtocol\t0x%02x\n", g->dproto);
- fprintf(stdout, " bMaxPacketSize0\t0x%02x\n", g->maxpacket);
- fprintf(stdout, " bcdDevice\t\t0x%04x\n", g->bcddevice);
- fprintf(stdout, " bcdUSB\t\t0x%04x\n", g->bcdusb);
- fprintf(stdout, " idVendor\t\t0x%04x\n", g->vendor);
- fprintf(stdout, " idProduct\t\t0x%04x\n", g->product);
+ fprintf(stdout, " bDeviceClass\t\t0x%02x\n", g->attrs.dclass);
+ fprintf(stdout, " bDeviceSubClass\t0x%02x\n", g->attrs.dsubclass);
+ fprintf(stdout, " bDeviceProtocol\t0x%02x\n", g->attrs.dproto);
+ fprintf(stdout, " bMaxPacketSize0\t0x%02x\n", g->attrs.maxpacket);
+ fprintf(stdout, " bcdDevice\t\t0x%04x\n", g->attrs.bcddevice);
+ fprintf(stdout, " bcdUSB\t\t0x%04x\n", g->attrs.bcdusb);
+ fprintf(stdout, " idVendor\t\t0x%04x\n", g->attrs.vendor);
+ fprintf(stdout, " idProduct\t\t0x%04x\n", g->attrs.product);
fprintf(stdout, " Serial Number\t\t%s\n", g->str_ser);
fprintf(stdout, " Manufacturer\t\t%s\n", g->str_mnf);
fprintf(stdout, " Product\t\t%s\n", g->str_prd);
return 0;
}
-static void usbg_parse_attrs(char *path, struct gadget *g)
+static void usbg_parse_gadget_attrs(char *path, char *name,
+ struct gadget_attrs *g_attrs)
{
/* Actual attributes */
- g->dclass = usbg_read_hex(path, g->name, "bDeviceClass");
- g->dsubclass = usbg_read_hex(path, g->name, "bDeviceSubClass");
- g->dproto = usbg_read_hex(path, g->name, "bDeviceProtocol");
- g->maxpacket = usbg_read_hex(path, g->name, "bMaxPacketSize0");
- g->bcddevice = usbg_read_hex(path, g->name, "bcdDevice");
- g->bcdusb = usbg_read_hex(path, g->name, "bcdUSB");
- g->vendor = usbg_read_hex(path, g->name, "idVendor");
- g->product = usbg_read_hex(path, g->name, "idProduct");
+ g_attrs->dclass = usbg_read_hex(path, name, "bDeviceClass");
+ g_attrs->dsubclass = usbg_read_hex(path, name, "bDeviceSubClass");
+ g_attrs->dproto = usbg_read_hex(path, name, "bDeviceProtocol");
+ g_attrs->maxpacket = usbg_read_hex(path, name, "bMaxPacketSize0");
+ g_attrs->bcddevice = usbg_read_hex(path, name, "bcdDevice");
+ g_attrs->bcdusb = usbg_read_hex(path, name, "bcdUSB");
+ g_attrs->vendor = usbg_read_hex(path, name, "idVendor");
+ g_attrs->product = usbg_read_hex(path, name, "idProduct");
}
static void usbg_parse_strings(char *path, struct gadget *g)
g->parent = s;
/* UDC bound to, if any */
usbg_read_string(path, g->name, "UDC", g->udc);
- usbg_parse_attrs(path, g);
+ usbg_parse_gadget_attrs(path, g->name, &g->attrs);
usbg_parse_strings(path, g);
usbg_parse_functions(path, g);
usbg_parse_configs(path, g);
usbg_write_hex16(s->path, name, "idVendor", vendor);
usbg_write_hex16(s->path, name, "idProduct", product);
- usbg_parse_attrs(s->path, g);
+ usbg_parse_gadget_attrs(s->path, name, &g->attrs);
usbg_parse_strings(s->path, g);
/* Insert in string order */
void usbg_set_gadget_device_class(struct gadget *g, int dclass)
{
- g->dclass = dclass;
+ g->attrs.dclass = dclass;
usbg_write_hex8(g->path, "", "bDeviceClass", dclass);
}
void usbg_set_gadget_device_protocol(struct gadget *g, int dproto)
{
- g->dproto = dproto;
+ g->attrs.dproto = dproto;
usbg_write_hex8(g->path, "", "bDeviceProtocol", dproto);
}
void usbg_set_gadget_device_subclass(struct gadget *g, int dsubclass)
{
- g->dsubclass = dsubclass;
+ g->attrs.dsubclass = dsubclass;
usbg_write_hex8(g->path, "", "bDeviceSubClass", dsubclass);
}
void usbg_set_gadget_device_max_packet(struct gadget *g, int maxpacket)
{
- g->maxpacket = maxpacket;
+ g->attrs.maxpacket = maxpacket;
usbg_write_hex8(g->path, "", "bMaxPacketSize0", maxpacket);
}
void usbg_set_gadget_device_bcd_device(struct gadget *g, int bcddevice)
{
- g->bcddevice = bcddevice;
+ g->attrs.bcddevice = bcddevice;
usbg_write_hex16(g->path, "", "bcdDevice", bcddevice);
}
void usbg_set_gadget_device_bcd_usb(struct gadget *g, int bcdusb)
{
- g->bcdusb = bcdusb;
+ g->attrs.bcdusb = bcdusb;
usbg_write_hex16(g->path, "", "bcdUSB", bcdusb);
}