Lines Matching +full:disk +full:- +full:name

5  * SPDX-License-Identifier: Apache-2.0
19 LOG_MODULE_REGISTER(disk);
27 struct disk_info *disk_access_get_di(const char *name) in disk_access_get_di() argument
29 struct disk_info *disk = NULL, *itr; in disk_access_get_di() local
30 size_t name_len = strlen(name); in disk_access_get_di()
40 * name is shorter than the mount point name. in disk_access_get_di()
42 if (strlen(itr->name) != name_len) { in disk_access_get_di()
46 /* Check for disk name match */ in disk_access_get_di()
47 if (strncmp(name, itr->name, name_len) == 0) { in disk_access_get_di()
48 disk = itr; in disk_access_get_di()
54 return disk; in disk_access_get_di()
59 struct disk_info *disk = disk_access_get_di(pdrv); in disk_access_init() local
60 int rc = -EINVAL; in disk_access_init()
62 if ((disk != NULL) && (disk->refcnt == 0U)) { in disk_access_init()
63 /* Disk has not been initialized, start it */ in disk_access_init()
64 if ((disk->ops != NULL) && (disk->ops->init != NULL)) { in disk_access_init()
65 rc = disk->ops->init(disk); in disk_access_init()
68 disk->refcnt++; in disk_access_init()
71 } else if ((disk != NULL) && (disk->refcnt < UINT16_MAX)) { in disk_access_init()
72 /* Disk reference count is nonzero, simply increment it */ in disk_access_init()
73 disk->refcnt++; in disk_access_init()
82 struct disk_info *disk = disk_access_get_di(pdrv); in disk_access_status() local
83 int rc = -EINVAL; in disk_access_status()
85 if ((disk != NULL) && (disk->ops != NULL) && in disk_access_status()
86 (disk->ops->status != NULL)) { in disk_access_status()
87 rc = disk->ops->status(disk); in disk_access_status()
96 struct disk_info *disk = disk_access_get_di(pdrv); in disk_access_read() local
97 int rc = -EINVAL; in disk_access_read()
99 if ((disk != NULL) && (disk->ops != NULL) && in disk_access_read()
100 (disk->ops->read != NULL)) { in disk_access_read()
101 rc = disk->ops->read(disk, data_buf, start_sector, num_sector); in disk_access_read()
110 struct disk_info *disk = disk_access_get_di(pdrv); in disk_access_write() local
111 int rc = -EINVAL; in disk_access_write()
113 if ((disk != NULL) && (disk->ops != NULL) && in disk_access_write()
114 (disk->ops->write != NULL)) { in disk_access_write()
115 rc = disk->ops->write(disk, data_buf, start_sector, num_sector); in disk_access_write()
123 struct disk_info *disk = disk_access_get_di(pdrv); in disk_access_ioctl() local
124 int rc = -EINVAL; in disk_access_ioctl()
126 if ((disk != NULL) && (disk->ops != NULL) && in disk_access_ioctl()
127 (disk->ops->ioctl != NULL)) { in disk_access_ioctl()
130 if (disk->refcnt == 0U) { in disk_access_ioctl()
131 rc = disk->ops->ioctl(disk, cmd, buf); in disk_access_ioctl()
133 disk->refcnt++; in disk_access_ioctl()
135 } else if (disk->refcnt < UINT16_MAX) { in disk_access_ioctl()
136 disk->refcnt++; in disk_access_ioctl()
139 LOG_ERR("Disk reference count at max value"); in disk_access_ioctl()
144 /* Force deinit disk */ in disk_access_ioctl()
145 disk->refcnt = 0U; in disk_access_ioctl()
146 disk->ops->ioctl(disk, cmd, buf); in disk_access_ioctl()
148 } else if (disk->refcnt == 1U) { in disk_access_ioctl()
149 rc = disk->ops->ioctl(disk, cmd, buf); in disk_access_ioctl()
151 disk->refcnt--; in disk_access_ioctl()
153 } else if (disk->refcnt > 0) { in disk_access_ioctl()
154 disk->refcnt--; in disk_access_ioctl()
157 LOG_WRN("Disk is already deinitialized"); in disk_access_ioctl()
161 rc = disk->ops->ioctl(disk, cmd, buf); in disk_access_ioctl()
168 int disk_access_register(struct disk_info *disk) in disk_access_register() argument
172 if ((disk == NULL) || (disk->name == NULL)) { in disk_access_register()
173 LOG_ERR("invalid disk interface!!"); in disk_access_register()
174 return -EINVAL; in disk_access_register()
177 if (disk_access_get_di(disk->name) != NULL) { in disk_access_register()
178 LOG_ERR("disk interface already registered!!"); in disk_access_register()
179 return -EINVAL; in disk_access_register()
183 disk->refcnt = 0U; in disk_access_register()
186 /* append to the disk list */ in disk_access_register()
187 sys_dlist_append(&disk_access_list, &disk->node); in disk_access_register()
188 LOG_DBG("disk interface(%s) registered", disk->name); in disk_access_register()
193 int disk_access_unregister(struct disk_info *disk) in disk_access_unregister() argument
197 if ((disk == NULL) || (disk->name == NULL)) { in disk_access_unregister()
198 LOG_ERR("invalid disk interface!!"); in disk_access_unregister()
199 return -EINVAL; in disk_access_unregister()
202 if (disk_access_get_di(disk->name) == NULL) { in disk_access_unregister()
203 LOG_ERR("disk interface not registered!!"); in disk_access_unregister()
204 return -EINVAL; in disk_access_unregister()
208 /* remove disk node from the list */ in disk_access_unregister()
209 sys_dlist_remove(&disk->node); in disk_access_unregister()
211 LOG_DBG("disk interface(%s) unregistered", disk->name); in disk_access_unregister()