usb: gadget: slp: fix to use serial number of dmi
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 19 Apr 2017 01:00:36 +0000 (10:00 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Jan 2019 02:25:36 +0000 (11:25 +0900)
For identical serial string of slp gadget, this patch fixes to use
product serial of dmi if the dmi value is set.

Change-Id: Ic75f6c7730cba5860afdf3bd60babc754b3ecd67
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/usb/gadget/legacy/slp.c

index 06736800ca1cfbc7dc1c6422021ab2c7681da833..cc76ceec0f9762d516f6b97bc3bd2e373e0718f9 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/kernel.h>
 #include <linux/utsname.h>
 #include <linux/platform_device.h>
@@ -1163,6 +1164,7 @@ static int slp_multi_bind(struct usb_composite_dev *cdev)
 {
        struct slp_multi_dev *dev = _slp_multi_dev;
        struct usb_gadget       *gadget = cdev->gadget;
+       const char              *serial;
        int                     id, ret;
 
        /*
@@ -1193,7 +1195,12 @@ static int slp_multi_bind(struct usb_composite_dev *cdev)
        /* Default strings - should be updated by userspace */
        strncpy(manufacturer_string, "Samsung", sizeof(manufacturer_string)-1);
        strncpy(product_string, "TIZEN", sizeof(product_string) - 1);
-       snprintf(serial_string, 18, "%s", "01234TEST");
+
+       serial = dmi_get_system_info(DMI_PRODUCT_SERIAL);
+       if (serial)
+               snprintf(serial_string, 18, "%s", serial);
+       else
+               snprintf(serial_string, 18, "%s", "01234TEST");
 
        id = usb_string_id(cdev);
        if (id < 0)