1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #include "hdf_driver_installer.h" 10 #include "devhost_service.h" 11 #include "hdf_base.h" 12 #include "hdf_log.h" 13 #include "hdf_object_manager.h" 14 15 #define HDF_LOG_TAG driver_installer 16 DriverInstallerStartDeviceHost(uint32_t devHostId,const char * devHostName)17static int DriverInstallerStartDeviceHost(uint32_t devHostId, const char *devHostName) 18 { 19 struct IDevHostService *hostServiceIf = DevHostServiceNewInstance(devHostId, devHostName); 20 if ((hostServiceIf == NULL) || (hostServiceIf->StartService == NULL)) { 21 HDF_LOGE("hostServiceIf or hostServiceIf->StartService is null"); 22 return HDF_FAILURE; 23 } 24 int ret = hostServiceIf->StartService(hostServiceIf); 25 if (ret != HDF_SUCCESS) { 26 HDF_LOGE("failed to start host service, ret: %d", ret); 27 DevHostServiceFreeInstance(hostServiceIf); 28 } 29 return ret; 30 } 31 DriverInstallerConstruct(struct DriverInstaller * inst)32static void DriverInstallerConstruct(struct DriverInstaller *inst) 33 { 34 struct IDriverInstaller *driverInstallIf = (struct IDriverInstaller *)inst; 35 driverInstallIf->StartDeviceHost = DriverInstallerStartDeviceHost; 36 } 37 DriverInstallerCreate(void)38struct HdfObject *DriverInstallerCreate(void) 39 { 40 static bool isDriverInstInit = false; 41 static struct DriverInstaller driverInstaller; 42 if (!isDriverInstInit) { 43 DriverInstallerConstruct(&driverInstaller); 44 isDriverInstInit = true; 45 } 46 return (struct HdfObject *)&driverInstaller; 47 } 48 DriverInstallerGetInstance()49struct IDriverInstaller *DriverInstallerGetInstance() 50 { 51 static struct IDriverInstaller *installer = NULL; 52 if (installer == NULL) { 53 installer = (struct IDriverInstaller *)HdfObjectManagerGetObject(HDF_OBJECT_ID_DRIVER_INSTALLER); 54 } 55 return installer; 56 } 57 58