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.opas...@samsung.com>
---
 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 5b2213d..2d832ba 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 2264e7c..15bcd8d 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;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to