From 452d208fe752a055c2475926c1f137a6d9a83ef3 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Wed, 12 Feb 2014 11:45:03 +0100 Subject: [PATCH] libusbgx: Add missing set vendor/product functions. Setting idVendor and idProduct was allowed only when creating new gadget. Add usbg_set_gadget_vendor_id() and usbg_set_gadget_product_id() to allow set those values on existing gadget. Signed-off-by: Krzysztof Opasiak [Port from libusbg and update description] Signed-off-by: Krzysztof Opasiak --- include/usbg/usbg.h | 14 ++++++++++++++ src/usbg.c | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 08d5d8d..740754b 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -273,6 +273,20 @@ extern struct gadget *usbg_create_gadget(struct state *s, char *name, uint16_t idVendor, uint16_t idProduct); /** + * @brief Set the USB gadget vendor id + * @param g Pointer to gadget + * @param idVendor USB device vendor id + */ +extern void usbg_set_gadget_vendor_id(struct gadget *g, uint16_t idVendor); + +/** + * @brief Set the USB gadget product id + * @param g Pointer to gadget + * @param idProduct USB device product id + */ +extern void usbg_set_gadget_product_id(struct gadget *g, uint16_t idProduct); + +/** * @brief Set the USB gadget device class code * @param g Pointer to gadget * @param bDeviceClass USB device class code diff --git a/src/usbg.c b/src/usbg.c index 974077f..cc06182 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -573,6 +573,18 @@ struct gadget *usbg_create_gadget(struct state *s, char *name, return g; } +void usbg_set_gadget_vendor_id(struct gadget *g, uint16_t idVendor) +{ + g->attrs.idVendor = idVendor; + usbg_write_hex16(g->path, "", "idVendor", idVendor); +} + +void usbg_set_gadget_product_id(struct gadget *g, uint16_t idProduct) +{ + g->attrs.idProduct = idProduct; + usbg_write_hex16(g->path, "", "idProduct", idProduct); +} + void usbg_set_gadget_device_class(struct gadget *g, uint8_t bDeviceClass) { g->attrs.bDeviceClass = bDeviceClass; -- 2.7.4