1 /* 2 * Copyright (c) 2020-2023 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_log.h" 10 #include "mtd_core.h" 11 MtdBlockOsInit(struct MtdDevice * mtdDevice)12__attribute__((weak)) int32_t MtdBlockOsInit(struct MtdDevice *mtdDevice) 13 { 14 (void)mtdDevice; 15 return HDF_SUCCESS; 16 } 17 MtdBlockOsUninit(struct MtdDevice * mtdDevice)18__attribute__ ((weak)) void MtdBlockOsUninit(struct MtdDevice *mtdDevice) 19 { 20 (void)mtdDevice; 21 } 22 MtdBlockInit(struct MtdDevice * mtdDevice)23int32_t MtdBlockInit(struct MtdDevice *mtdDevice) 24 { 25 int32_t ret; 26 27 if (mtdDevice == NULL) { 28 HDF_LOGE("MtdBlockInit: mtdDevice is null!"); 29 return HDF_ERR_INVALID_OBJECT; 30 } 31 32 if (MtdDeviceGet(mtdDevice) == NULL) { 33 HDF_LOGE("MtdBlockInit: get mtd device fail!"); 34 return HDF_PLT_ERR_DEV_GET; 35 } 36 37 ret = MtdBlockOsInit(mtdDevice); 38 if (ret != HDF_SUCCESS) { 39 HDF_LOGE("MtdBlockInit: os init fail, ret = %d!", ret); 40 MtdDevicePut(mtdDevice); 41 return ret; 42 } 43 44 return HDF_SUCCESS; 45 } 46 MtdBlockUninit(struct MtdDevice * mtdDevice)47void MtdBlockUninit(struct MtdDevice *mtdDevice) 48 { 49 if (mtdDevice != NULL) { 50 MtdBlockOsUninit(mtdDevice); 51 MtdDevicePut(mtdDevice); 52 } 53 } 54