#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>
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;
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;
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;
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;