MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / disk_remove_blk_dev

Function disk_remove_blk_dev

components/drivers/block/blk_dev.c:240–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240rt_err_t disk_remove_blk_dev(struct rt_blk_device *blk, rt_bool_t lockless)
241{
242 struct rt_blk_disk *disk;
243
244 if (!blk)
245 {
246 return -RT_EINVAL;
247 }
248
249 disk = blk->disk;
250
251 if (!disk)
252 {
253 return -RT_EINVAL;
254 }
255 else
256 {
257 #ifdef RT_USING_DFS
258 const char *mountpath;
259
260 if ((mountpath = dfs_filesystem_get_mounted_path(&blk->parent)))
261 {
262 dfs_unmount(mountpath);
263 LOG_D("%s: Unmount file system on %s",
264 to_blk_name(blk), mountpath);
265 }
266 #endif
267 }
268
269#ifdef RT_USING_DM
270 rt_dm_ida_free(disk->ida, blk->parent.device_id);
271#endif
272
273 rt_device_unregister(&blk->parent);
274
275 if (!lockless)
276 {
277 spin_lock(&disk->lock);
278 }
279
280 rt_list_remove(&blk->list);
281
282 if (!lockless)
283 {
284 spin_unlock(&disk->lock);
285 }
286
287 --disk->partitions;
288
289 return RT_EOK;
290}
291
292rt_uint32_t blk_request_ioprio(void)
293{

Callers 1

blk_remove_allFunction · 0.85

Calls 7

rt_dm_ida_freeFunction · 0.85
rt_device_unregisterFunction · 0.85
rt_list_removeFunction · 0.85
spin_lockFunction · 0.70
spin_unlockFunction · 0.70
dfs_unmountFunction · 0.50

Tested by

no test coverage detected