From 6ff6a27ed4e41ef1f258cc2c2f632fa378b19de2 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 9 Apr 2018 15:57:15 +0900 Subject: [PATCH] usb: gadget: slp: fix to use serial-number if arm64 has no dmi serial 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 --- drivers/usb/gadget/legacy/slp.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/legacy/slp.c b/drivers/usb/gadget/legacy/slp.c index 1eeca11..19a639b 100644 --- a/drivers/usb/gadget/legacy/slp.c +++ b/drivers/usb/gadget/legacy/slp.c @@ -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) -- 2.7.4