Merge \\\\"init: select usb gadget controller at run time\\\\" am: 916f5e873e am: 91272bd435 am: aff2347646

am: 114a00ea03

Change-Id: I5f0ffb78092d7d3e0425cfce3c4f614b81b0ff5e
This commit is contained in:
Amit Pundir 2016-07-15 23:38:48 +00:00 committed by android-build-merger
commit 707eeb0a23

View file

@ -546,6 +546,22 @@ static void selinux_initialize(bool in_kernel_domain) {
}
}
// Set the UDC controller for the ConfigFS USB Gadgets.
// Read the UDC controller in use from "/sys/class/udc".
// In case of multiple UDC controllers select the first one.
static void set_usb_controller() {
std::unique_ptr<DIR, decltype(&closedir)>dir(opendir("/sys/class/udc"), closedir);
if (!dir) return;
dirent* dp;
while ((dp = readdir(dir.get())) != nullptr) {
if (dp->d_name[0] == '.') continue;
property_set("sys.usb.controller", dp->d_name);
break;
}
}
int main(int argc, char** argv) {
if (!strcmp(basename(argv[0]), "ueventd")) {
return ueventd_main(argc, argv);
@ -638,6 +654,7 @@ int main(int argc, char** argv) {
property_load_boot_defaults();
export_oem_lock_status();
start_property_service();
set_usb_controller();
const BuiltinFunctionMap function_map;
Action::set_function_map(&function_map);