summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINSUN PYO <insun.pyo@samsung.com>2021-01-28 20:08:25 +0900
committerINSUN PYO <insun.pyo@samsung.com>2021-01-28 20:08:52 +0900
commitf56c4c54e3e440b239d31012c9f45b13c4fe4476 (patch)
tree86f456e37e52501b657118a78c0c7df2c34e4260
parent8f2283db9cb47723911065c264b43011f4198c9d (diff)
downloaddevice-common-f56c4c54e3e440b239d31012c9f45b13c4fe4476.tar.gz
device-common-f56c4c54e3e440b239d31012c9f45b13c4fe4476.tar.bz2
device-common-f56c4c54e3e440b239d31012c9f45b13c4fe4476.zip
- support usb serial for sdb devices --------------------------------------------------- $ sdb devices List of devices attached 530MWC2R10400764 device artik --------------------------------------------------- - remove temporary "BuildRequires: pkgconfig(dlog)" dependency Change-Id: Iae4944b6848efda105396d718ad7fb73a994cd4a
-rw-r--r--packaging/hal-backend-device-common.spec4
-rw-r--r--src/usb_gadget/usb_gadget_common.c34
2 files changed, 5 insertions, 33 deletions
diff --git a/packaging/hal-backend-device-common.spec b/packaging/hal-backend-device-common.spec
index 6e38281..17db5ef 100644
--- a/packaging/hal-backend-device-common.spec
+++ b/packaging/hal-backend-device-common.spec
@@ -9,12 +9,8 @@ Source1: %{name}.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(libusbgx)
BuildRequires: pkgconfig(hal-api-device)
-
BuildRequires: pkgconfig(libsyscommon)
-# TODO remove later. It's temporary patch
-BuildRequires: pkgconfig(dlog)
-
%description
Library for HAL backend device modules
diff --git a/src/usb_gadget/usb_gadget_common.c b/src/usb_gadget/usb_gadget_common.c
index 734f933..0628744 100644
--- a/src/usb_gadget/usb_gadget_common.c
+++ b/src/usb_gadget/usb_gadget_common.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include <unistd.h>
-//include <hw/board.h> TODO move to common
#include <libsyscommon/dbus-systemd.h>
#include <hal/device/hal-usb_gadget-interface.h>
@@ -87,29 +86,7 @@ static int alloc_default_config(struct usb_configuration **_config)
return 0;
}
-static int get_device_serial(char **out)
-{
-#if 0 // TODO fix build error
- struct hw_info *info;
- struct hw_common *common;
- struct hw_board *board;
- int ret;
-
- if (hw_get_info(BOARD_HARDWARE_DEVICE_ID, (const struct hw_info **)&info))
- return -ENOENT;
-
- ret = info->open(info, NULL, &common);
- if (ret < 0)
- return ret;
-
- board = container_of(common, struct hw_board, common);
- return board->get_device_serial(out);
-#else
- return -1;
-#endif
-}
-
-static int alloc_default_gadget(struct usb_gadget **_gadget)
+static int alloc_default_gadget(char *serial, struct usb_gadget **_gadget)
{
struct usb_gadget *gadget;
struct usb_configuration **configs;
@@ -125,8 +102,7 @@ static int alloc_default_gadget(struct usb_gadget **_gadget)
gadget->strs.lang_code = DEFAULT_LANG;
gadget->strs.manufacturer = strdup(DEFAULT_MANUFACTURER);
gadget->strs.product = strdup(DEFAULT_PRODUCT);
- if (get_device_serial(&gadget->strs.serial) < 0)
- gadget->strs.serial = strdup(DEFAULT_SERIAL);
+ gadget->strs.serial = strdup(serial);
if (!gadget->strs.manufacturer || !gadget->strs.product || !gadget->strs.serial)
goto free_strs;
@@ -150,7 +126,7 @@ out:
return -ENOMEM;
}
-static int id_to_gadget(struct usb_gadget_id *gadget_id, struct usb_gadget **_gadget)
+static int id_to_gadget(struct usb_gadget_id *gadget_id, char *serial, struct usb_gadget **_gadget)
{
int ret;
int i, j;
@@ -158,10 +134,10 @@ static int id_to_gadget(struct usb_gadget_id *gadget_id, struct usb_gadget **_ga
struct usb_gadget *gadget;
int functions[2][sizeof(gadget_id->function_mask)*8]; /* zero terminates */
- if (!gadget_id || !_gadget)
+ if (!gadget_id || !serial || !_gadget)
return -EINVAL;
- ret = alloc_default_gadget(&gadget);
+ ret = alloc_default_gadget(serial, &gadget);
if (ret)
goto out;