diff --git a/fs/driver/Make.defs b/fs/driver/Make.defs index e34f4377816..330f559b10a 100644 --- a/fs/driver/Make.defs +++ b/fs/driver/Make.defs @@ -25,7 +25,7 @@ CSRCS += fs_registerdriver.c fs_unregisterdriver.c ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) CSRCS += fs_registerblockdriver.c fs_unregisterblockdriver.c CSRCS += fs_findblockdriver.c fs_openblockdriver.c fs_closeblockdriver.c -CSRCS += fs_blockpartition.c fs_findmtddriver.c +CSRCS += fs_blockpartition.c fs_findmtddriver.c fs_closemtddriver.c ifeq ($(CONFIG_MTD),y) CSRCS += fs_registermtddriver.c fs_unregistermtddriver.c diff --git a/fs/driver/driver.h b/fs/driver/driver.h index a0bfa4cde2a..b8d99598219 100644 --- a/fs/driver/driver.h +++ b/fs/driver/driver.h @@ -124,28 +124,6 @@ int mtd_proxy(FAR const char *mtddev, int mountflags, FAR struct inode **ppinode); #endif -/**************************************************************************** - * Name: find_mtddriver - * - * Description: - * Return the inode of the named MTD driver specified by 'pathname' - * - * Input Parameters: - * pathname - the full path to the named MTD driver to be located - * ppinode - address of the location to return the inode reference - * - * Returned Value: - * Returns zero on success or a negated errno on failure: - * - * ENOENT - No MTD driver of this name is registered - * ENOTBLK - The inode associated with the pathname is not an MTD driver - * - ****************************************************************************/ - -#ifndef CONFIG_DISABLE_MOUNTPOINT -int find_mtddriver(FAR const char *pathname, FAR struct inode **ppinode); -#endif - #undef EXTERN #if defined(__cplusplus) } diff --git a/fs/driver/fs_closemtddriver.c b/fs/driver/fs_closemtddriver.c new file mode 100644 index 00000000000..3d9d6922a73 --- /dev/null +++ b/fs/driver/fs_closemtddriver.c @@ -0,0 +1,71 @@ +/**************************************************************************** + * fs/driver/fs_closemtddriver.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include "inode/inode.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: close_mtddriver + * + * Description: + * Release the inode got by function find_mtddriver() + * + * Input Parameters: + * pinode - pointer to the inode + * + * Returned Value: + * Returns zero on success or a negated errno on failure: + * + * EINVAL - inode is NULL + * + ****************************************************************************/ + +#ifdef CONFIG_MTD +int close_mtddriver(FAR struct inode *pinode) +{ + /* Sanity checks */ + + if (pinode == NULL) + { + return -EINVAL; + } + + inode_release(pinode); + + return OK; +} +#else +int close_mtddriver(FAR struct inode *pinode) +{ + return -ENODEV; +} +#endif /* CONFIG_MTD */ diff --git a/fs/driver/fs_findmtddriver.c b/fs/driver/fs_findmtddriver.c index 7dc4a83fef9..fad08f0900c 100644 --- a/fs/driver/fs_findmtddriver.c +++ b/fs/driver/fs_findmtddriver.c @@ -33,7 +33,6 @@ #include #include "inode/inode.h" -#include "driver/driver.h" #ifdef CONFIG_MTD diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index 0e631ea05c9..92ffdc432ee 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -986,6 +986,44 @@ int open_blockdriver(FAR const char *pathname, int mountflags, int close_blockdriver(FAR struct inode *inode); +/**************************************************************************** + * Name: find_mtddriver + * + * Description: + * Return the inode of the named MTD driver specified by 'pathname' + * + * Input Parameters: + * pathname - the full path to the named MTD driver to be located + * ppinode - address of the location to return the inode reference + * + * Returned Value: + * Returns zero on success or a negated errno on failure: + * + * ENOENT - No MTD driver of this name is registered + * ENOTBLK - The inode associated with the pathname is not an MTD driver + * + ****************************************************************************/ + +int find_mtddriver(FAR const char *pathname, FAR struct inode **ppinode); + +/**************************************************************************** + * Name: close_mtddriver + * + * Description: + * Release the inode got by function find_mtddriver() + * + * Input Parameters: + * pinode - pointer to the inode + * + * Returned Value: + * Returns zero on success or a negated errno on failure: + * + * EINVAL - inode is NULL + * + ****************************************************************************/ + +int close_mtddriver(FAR struct inode *pinode); + /**************************************************************************** * Name: fs_fdopen *