libusbgx: Add missing set vendor/product functions.
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 12 Feb 2014 10:45:03 +0000 (11:45 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 22 Dec 2015 19:34:56 +0000 (20:34 +0100)
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 <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
include/usbg/usbg.h
src/usbg.c

index 08d5d8d..740754b 100644 (file)
@@ -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
index 974077f..cc06182 100644 (file)
@@ -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;