Hello Alan, Gregory, Thank you for your replies.
Yes. /dev/mtd1 was instantiated via bchdev_register() call. If I use bchdev_unregister,I noticed that the device is removed from the list. Before bchdev_unregister("/dev/mtd1") I call unlink method, but the inode is not removed because it still has one reference. As you mentioned, I have to find and release that reference. In the documentation https://cwiki.apache.org/confluence/display/NUTTX/Using+SmartFS I found "Example SmartFS Device Setup". Is it sufficient to call *unlink("/dev/smart1d")* and *unregister_blockdriver("/dev/smart1d") *to tear down Smart device? Or is there a way to tear down a device that uses SmartFS? Thank you, Cate On Thu, Nov 19, 2020 at 1:04 AM Gregory Nutt <spudan...@gmail.com> wrote: > > > The /dev/mtd1 is, I assume, a character driver that was instantiated > > via bchdev_register(). It should be unlinked first before the block > > driver. The bchdev_unlink() method will teardown the /dev/mtd1 > > instance /*when it can*/. ... > > And it cannot do that until all of the open references to the driver are > closed. > > If you do unlink while there are open references, the name will be > removed from the file namespace, but the underlying driver instance will > persist and will continue to hold resources until the last reference to > the driver is closed. Then that underlying driver instance will be > released. > >