• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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)23 int32_t MtdBlockInit(struct MtdDevice *mtdDevice)
24 {
25     int32_t ret;
26 
27     if (mtdDevice == NULL) {
28         return HDF_ERR_INVALID_OBJECT;
29     }
30 
31     if (MtdDeviceGet(mtdDevice) == NULL) {
32         HDF_LOGE("%s: get mtd device failed", __func__);
33         return HDF_PLT_ERR_DEV_GET;
34     }
35 
36     ret = MtdBlockOsInit(mtdDevice);
37     if (ret != HDF_SUCCESS) {
38         HDF_LOGE("%s: os init failed, ret = %d", __func__, ret);
39         MtdDevicePut(mtdDevice);
40         return ret;
41     }
42 
43     return HDF_SUCCESS;
44 }
45 
MtdBlockUninit(struct MtdDevice * mtdDevice)46 void MtdBlockUninit(struct MtdDevice *mtdDevice)
47 {
48     if (mtdDevice != NULL) {
49         MtdBlockOsUninit(mtdDevice);
50         MtdDevicePut(mtdDevice);
51     }
52 }
53