usb: gadget: slp: fix to use serial-number if arm64 has no dmi serial
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 9 Apr 2018 06:57:15 +0000 (15:57 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Jan 2019 02:25:36 +0000 (11:25 +0900)
The arm64 artik710 board has no dmi serial. Fix to use serial-number
of devicetree which is attached from artik u-boot.

If there is the devicetree node, it is found from sysfs path,
/sys/firmware/devicetree/base/serial-number.

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

index 1eeca11..19a639b 100644 (file)
@@ -1201,15 +1201,27 @@ static int slp_multi_bind(struct usb_composite_dev *cdev)
        strncpy(product_string, "TIZEN", sizeof(product_string) - 1);
 
        serial = dmi_get_system_info(DMI_PRODUCT_SERIAL);
-       if (serial)
+       if (serial) {
                snprintf(serial_string, 18, "%s", serial);
-       else
+       } else {
 #ifdef CONFIG_ARM
                snprintf(serial_string, 18, "%s",
                         system_serial);
 #else
-               snprintf(serial_string, 18, "%s", "01234TEST");
+               struct device_node *root;
+               const char *serial_number = NULL;
+
+               root = of_find_node_by_path("/");
+               if (root)
+                       of_property_read_string(root, "serial-number",
+                                               &serial_number);
+
+               if (serial_number)
+                       snprintf(serial_string, 18, "%s", serial_number);
+               else
+                       snprintf(serial_string, 18, "%s", "01234TEST");
 #endif
+       }
 
        id = usb_string_id(cdev);
        if (id < 0)