From 247414c6ad9191620aef362c315020a46ec8c5fe Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 8 Nov 2018 09:46:11 -0600 Subject: [PATCH] drivers/mtd and other MTD drivers: Remove mtd_procfsoperations since we can now get the same information from inode --- arch/arm/src/lc823450/lc823450_mtd.c | 10 +- drivers/mtd/Make.defs | 6 - drivers/mtd/at24xx.c | 7 +- drivers/mtd/at25.c | 7 +- drivers/mtd/at45db.c | 7 +- drivers/mtd/filemtd.c | 7 +- drivers/mtd/gd25.c | 7 +- drivers/mtd/is25xp.c | 7 +- drivers/mtd/m25px.c | 7 +- drivers/mtd/mtd_partition.c | 33 +-- drivers/mtd/mtd_procfs.c | 407 --------------------------- drivers/mtd/mtd_progmem.c | 9 +- drivers/mtd/mtd_rwbuffer.c | 7 +- drivers/mtd/mx25lx.c | 7 +- drivers/mtd/mx25rxx.c | 7 +- drivers/mtd/mx35.c | 10 +- drivers/mtd/n25qxxx.c | 7 +- drivers/mtd/rammtd.c | 7 +- drivers/mtd/ramtron.c | 7 +- drivers/mtd/s25fl1.c | 7 +- drivers/mtd/sector512.c | 7 +- drivers/mtd/skeleton.c | 8 - drivers/mtd/sst25.c | 7 +- drivers/mtd/sst25xx.c | 7 +- drivers/mtd/sst26.c | 7 +- drivers/mtd/sst39vf.c | 9 +- drivers/mtd/w25.c | 7 +- fs/procfs/Kconfig | 5 - fs/procfs/fs_procfs.c | 5 - include/nuttx/mtd/mtd.h | 46 --- 30 files changed, 33 insertions(+), 648 deletions(-) delete mode 100644 drivers/mtd/mtd_procfs.c diff --git a/arch/arm/src/lc823450/lc823450_mtd.c b/arch/arm/src/lc823450/lc823450_mtd.c index 5780f5baa3..f53448e8f9 100644 --- a/arch/arm/src/lc823450/lc823450_mtd.c +++ b/arch/arm/src/lc823450/lc823450_mtd.c @@ -110,13 +110,11 @@ static sem_t g_sem = SEM_INITIALIZER(1); static FAR struct mtd_dev_s *g_mtdpart[LC823450_NPARTS]; static FAR struct mtd_dev_s *g_mtdmaster[CONFIG_MTD_DEV_MAX]; /* 0: eMMC, 1: SDC */ -#ifdef CONFIG_MTD_REGISTRATION static const char g_mtdname[2][4] = { "sd", "mmc" }; -#endif static struct lc823450_partinfo_s partinfo[LC823450_NPARTS] = { @@ -515,6 +513,7 @@ exit_with_error: static FAR struct mtd_dev_s *lc823450_mtd_allocdev(uint32_t channel) { int ret; + int mtype = lc823450_sdc_refmediatype(channel); FAR struct lc823450_mtd_dev_s *priv; /* Create an instance of the LC823450 MTD device state structure */ @@ -539,6 +538,7 @@ static FAR struct mtd_dev_s *lc823450_mtd_allocdev(uint32_t channel) priv->mtd.write = NULL; #endif priv->mtd.ioctl = lc823450_ioctl; + priv->mtd.name = g_mtdname[mtype]; priv->channel = channel; @@ -631,12 +631,6 @@ int lc823450_mtd_initialize(uint32_t devno) priv = (FAR struct lc823450_mtd_dev_s *)g_mtdmaster[ch]; -#ifdef CONFIG_MTD_REGISTRATION - int mtype = lc823450_sdc_refmediatype(ch); - mtd_register(g_mtdmaster[ch], g_mtdname[mtype]); - g_mtdmaster[ch]->mtdno = devno; -#endif - /* If SDC, create no child partition */ #if CONFIG_MTD_DEV_MAX > 1 diff --git a/drivers/mtd/Make.defs b/drivers/mtd/Make.defs index fa76c0444e..625385a656 100644 --- a/drivers/mtd/Make.defs +++ b/drivers/mtd/Make.defs @@ -150,12 +150,6 @@ CSRCS += smart.c endif endif -ifeq ($(CONFIG_FS_PROCFS),y) -ifneq ($(CONFIG_FS_PROCFS_EXCLUDE_MTD),y) -CSRCS += mtd_procfs.c -endif -endif - # Include MTD driver support DEPPATH += --dep-path mtd diff --git a/drivers/mtd/at24xx.c b/drivers/mtd/at24xx.c index a09b948db2..ac727db871 100644 --- a/drivers/mtd/at24xx.c +++ b/drivers/mtd/at24xx.c @@ -684,13 +684,8 @@ FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_master_s *dev) priv->mtd.bwrite = at24c_bwrite; priv->mtd.read = at24c_read; priv->mtd.ioctl = at24c_ioctl; + priv->mtd.name = "at24xx"; priv->dev = dev; - - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "at24xx"); -#endif priv->initd = true; } diff --git a/drivers/mtd/at25.c b/drivers/mtd/at25.c index 783f060181..46c100622c 100644 --- a/drivers/mtd/at25.c +++ b/drivers/mtd/at25.c @@ -664,6 +664,7 @@ FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev) priv->mtd.bwrite = at25_bwrite; priv->mtd.read = at25_read; priv->mtd.ioctl = at25_ioctl; + priv->mtd.name = "at25"; priv->dev = dev; /* Deselect the FLASH */ @@ -693,12 +694,6 @@ FAR struct mtd_dev_s *at25_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "at25"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/at45db.c b/drivers/mtd/at45db.c index 7f4a3f8bb9..9ad206c4d9 100644 --- a/drivers/mtd/at45db.c +++ b/drivers/mtd/at45db.c @@ -851,6 +851,7 @@ FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *spi) priv->mtd.bwrite = at45db_bwrite; priv->mtd.read = at45db_read; priv->mtd.ioctl = at45db_ioctl; + priv->mtd.name = "at45db"; priv->spi = spi; /* Deselect the FLASH */ @@ -901,12 +902,6 @@ FAR struct mtd_dev_s *at45db_initialize(FAR struct spi_dev_s *spi) at45db_unlock(priv); } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "at45db"); -#endif - finfo("Return %p\n", priv); return (FAR struct mtd_dev_s *)priv; diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c index 629fd38078..60949f38d2 100644 --- a/drivers/mtd/filemtd.c +++ b/drivers/mtd/filemtd.c @@ -568,15 +568,10 @@ FAR struct mtd_dev_s *blockmtd_initialize(FAR const char *path, size_t offset, priv->mtd.write = file_bytewrite; #endif priv->mtd.ioctl = filemtd_ioctl; + priv->mtd.name = "filemtd"; priv->offset = offset; priv->nblocks = nblocks; -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "filemtd"); -#endif - return &priv->mtd; } diff --git a/drivers/mtd/gd25.c b/drivers/mtd/gd25.c index 97bc8c5c6b..1382b8da3b 100644 --- a/drivers/mtd/gd25.c +++ b/drivers/mtd/gd25.c @@ -893,6 +893,7 @@ FAR struct mtd_dev_s *gd25_initialize(FAR struct spi_dev_s *spi) #ifdef CONFIG_MTD_BYTE_WRITE priv->mtd.write = gd25_write; #endif + priv->mtd.name = "gd25"; priv->spi = spi; /* Deselect the FLASH */ @@ -920,12 +921,6 @@ FAR struct mtd_dev_s *gd25_initialize(FAR struct spi_dev_s *spi) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "gd25"); -#endif - /* Return the implementation-specific state structure as the MTD device */ return (FAR struct mtd_dev_s *)priv; diff --git a/drivers/mtd/is25xp.c b/drivers/mtd/is25xp.c index b7f4df6657..5632ddb495 100644 --- a/drivers/mtd/is25xp.c +++ b/drivers/mtd/is25xp.c @@ -972,6 +972,7 @@ FAR struct mtd_dev_s *is25xp_initialize(FAR struct spi_dev_s *dev) priv->mtd.write = is25xp_write; #endif priv->mtd.ioctl = is25xp_ioctl; + priv->mtd.name = "is25xp"; priv->dev = dev; priv->lastwaswrite = false; @@ -998,12 +999,6 @@ FAR struct mtd_dev_s *is25xp_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "is25xp"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index fab4d19679..8b015930c4 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -1065,6 +1065,7 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev) priv->mtd.write = m25p_write; #endif priv->mtd.ioctl = m25p_ioctl; + priv->mtd.name = "m25px"; priv->dev = dev; /* Deselect the FLASH */ @@ -1084,12 +1085,6 @@ FAR struct mtd_dev_s *m25p_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "m25px"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/mtd_partition.c b/drivers/mtd/mtd_partition.c index dff88a8f11..1526905fb1 100644 --- a/drivers/mtd/mtd_partition.c +++ b/drivers/mtd/mtd_partition.c @@ -569,15 +569,9 @@ static ssize_t part_procfs_read(FAR struct file *filep, FAR char *buffer, if (attr->nextpart == g_pfirstpartition) { #ifdef CONFIG_MTD_PARTITION_NAMES - total = snprintf(buffer, buflen, "Name Start Size"); + total = snprintf(buffer, buflen, "Name Start Size MTD\n"); #else - total = snprintf(buffer, buflen, " Start Size"); -#endif - -#ifndef CONFIG_FS_PROCFS_EXCLUDE_MTD - total += snprintf(&buffer[total], buflen - total, " MTD\n"); -#else - total += snprintf(&buffer[total], buflen - total, "\n"); + total = snprintf(buffer, buflen, " Start Size MTD\n"); #endif } @@ -627,27 +621,13 @@ static ssize_t part_procfs_read(FAR struct file *filep, FAR char *buffer, /* Terminate the partition name and add to output buffer */ - ret = snprintf(&buffer[total], buflen - total, "%s%7d %7d", + ret = snprintf(&buffer[total], buflen - total, "%s%7d %7d %s\n", partname, attr->nextpart->firstblock / blkpererase, - attr->nextpart->neraseblocks); + attr->nextpart->neraseblocks, attr->nextpart->parent->name); #else - ret = snprintf(&buffer[total], buflen - total, "%7d %7d", + ret = snprintf(&buffer[total], buflen - total, "%7d %7d %s\n", attr->nextpart->firstblock / blkpererase, - attr->nextpart->neraseblocks); -#endif - -#ifndef CONFIG_FS_PROCFS_EXCLUDE_MTD - if (ret + total < buflen) - { - ret += snprintf(&buffer[total + ret], buflen - (total + ret), - " %s\n", attr->nextpart->parent->name); - } -#else - if (ret + total < buflen) - { - ret += snprintf(&buffer[total + ret], buflen - (total + ret), - "\n"); - } + attr->nextpart->neraseblocks, attr->nextpart->parent->name); #endif if (ret + total < buflen) @@ -845,6 +825,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd, off_t firstblock, #ifdef CONFIG_MTD_BYTE_WRITE part->child.write = mtd->write ? part_write : NULL; #endif + part->child.name = "part"; part->parent = mtd; part->firstblock = erasestart * blkpererase; diff --git a/drivers/mtd/mtd_procfs.c b/drivers/mtd/mtd_procfs.c deleted file mode 100644 index 4ba355110c..0000000000 --- a/drivers/mtd/mtd_procfs.c +++ /dev/null @@ -1,407 +0,0 @@ -/**************************************************************************** - * drivers/mtd/mtd_procfs.c - * - * Copyright (C) 2013 Ken Pettit. All rights reserved. - * Author: Ken Pettit - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if !defined(CONFIG_FS_PROCFS_EXCLUDE_MTD) && defined(CONFIG_FS_PROCFS) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ -/* This structure describes one open "file" */ - -struct mtd_file_s -{ - struct procfs_file_s base; /* Base open file structure */ - FAR struct mtd_dev_s *pnextmtd; /* Pointer to next registered MTD */ -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ -/* File system methods */ - -static int mtd_open(FAR struct file *filep, FAR const char *relpath, - int oflags, mode_t mode); -static int mtd_close(FAR struct file *filep); -static ssize_t mtd_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); - -static int mtd_dup(FAR const struct file *oldp, - FAR struct file *newp); - -static int mtd_stat(FAR const char *relpath, FAR struct stat *buf); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* See fs_mount.c -- this structure is explicitly externed there. - * We use the old-fashioned kind of initializers so that this will compile - * with any compiler. - */ - -const struct procfs_operations mtd_procfsoperations = -{ - mtd_open, /* open */ - mtd_close, /* close */ - mtd_read, /* read */ - NULL, /* write */ - - mtd_dup, /* dup */ - - NULL, /* opendir */ - NULL, /* closedir */ - NULL, /* readdir */ - NULL, /* rewinddir */ - - mtd_stat /* stat */ -}; - -/* MTD registration variables */ - -static struct mtd_dev_s *g_pfirstmtd = NULL; -static uint8_t g_nextmtdno = 0; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: mtd_open - ****************************************************************************/ - -static int mtd_open(FAR struct file *filep, FAR const char *relpath, - int oflags, mode_t mode) -{ - FAR struct mtd_file_s *attr; - - finfo("Open '%s'\n", relpath); - - /* PROCFS is read-only. Any attempt to open with any kind of write - * access is not permitted. - * - * REVISIT: Write-able proc files could be quite useful. - */ - - if ((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0) - { - ferr("ERROR: Only O_RDONLY supported\n"); - return -EACCES; - } - - /* Allocate a context structure */ - - attr = (FAR struct mtd_file_s *)kmm_zalloc(sizeof(struct mtd_file_s)); - if (!attr) - { - ferr("ERROR: Failed to allocate file attributes\n"); - return -ENOMEM; - } - - attr->pnextmtd = g_pfirstmtd; - - /* Save the context as the open-specific state in filep->f_priv */ - - filep->f_priv = (FAR void *)attr; - return OK; -} - -/**************************************************************************** - * Name: mtd_close - ****************************************************************************/ - -static int mtd_close(FAR struct file *filep) -{ - FAR struct mtd_file_s *attr; - - /* Recover our private data from the struct file instance */ - - attr = (FAR struct mtd_file_s *)filep->f_priv; - DEBUGASSERT(attr); - - /* Release the file attributes structure */ - - kmm_free(attr); - filep->f_priv = NULL; - return OK; -} - -/**************************************************************************** - * Name: mtd_read - ****************************************************************************/ - -static ssize_t mtd_read(FAR struct file *filep, FAR char *buffer, - size_t buflen) -{ - FAR struct mtd_file_s *priv; - ssize_t total = 0; - ssize_t ret; - - finfo("buffer=%p buflen=%d\n", buffer, (int)buflen); - - /* Recover our private data from the struct file instance */ - - priv = (FAR struct mtd_file_s *)filep->f_priv; - DEBUGASSERT(priv); - - /* If we are at the end of the list, then return 0 signifying the - * end-of-file. This also handles the special case when there are - * no registered MTD devices. - */ - - if (priv->pnextmtd) - { - /* Output a header before the first entry */ - - if (priv->pnextmtd == g_pfirstmtd) - { - total = snprintf(buffer, buflen, "Num Device\n"); - } - - /* The provide the requested data */ - - do - { - ret = snprintf(&buffer[total], buflen - total, "%-5d%s\n", - priv->pnextmtd->mtdno, priv->pnextmtd->name); - - if (ret + total < buflen) - { - total += ret; - priv->pnextmtd = priv->pnextmtd->pnext; - } - else - { - buffer[total] = '\0'; - break; - } - } - while (priv->pnextmtd); - } - - /* Update the file offset */ - - if (total > 0) - { - filep->f_pos += total; - } - - return total; -} - -/**************************************************************************** - * Name: mtd_dup - * - * Description: - * Duplicate open file data in the new file structure. - * - ****************************************************************************/ - -static int mtd_dup(FAR const struct file *oldp, FAR struct file *newp) -{ - FAR struct mtd_file_s *oldattr; - FAR struct mtd_file_s *newattr; - - finfo("Dup %p->%p\n", oldp, newp); - - /* Recover our private data from the old struct file instance */ - - oldattr = (FAR struct mtd_file_s *)oldp->f_priv; - DEBUGASSERT(oldattr); - - /* Allocate a new container to hold the task and attribute selection */ - - newattr = (FAR struct mtd_file_s *)kmm_zalloc(sizeof(struct mtd_file_s)); - if (!newattr) - { - ferr("ERROR: Failed to allocate file attributes\n"); - return -ENOMEM; - } - - /* The copy the file attribtes from the old attributes to the new */ - - memcpy(newattr, oldattr, sizeof(struct mtd_file_s)); - - /* Save the new attributes in the new file structure */ - - newp->f_priv = (FAR void *)newattr; - return OK; -} - -/**************************************************************************** - * Name: mtd_stat - * - * Description: Return information about a file or directory - * - ****************************************************************************/ - -static int mtd_stat(const char *relpath, struct stat *buf) -{ - /* File/directory size, access block size */ - - buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR; - buf->st_size = 0; - buf->st_blksize = 0; - buf->st_blocks = 0; - return OK; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: mtd_register - * - * Description: - * Registers MTD device with the procfs file system. This assigns a unique - * MTD number and associates the given device name, then add adds it to - * the list of registered devices. - * - * In an embedded system, this all is really unnecessary, but is provided - * in the procfs system simply for information purposes (if desired). - * - ****************************************************************************/ - -int mtd_register(FAR struct mtd_dev_s *mtd, FAR const char *name) -{ - FAR struct mtd_dev_s *plast; - - /* Assign the MTD number and device name */ - - mtd->mtdno = g_nextmtdno++; - mtd->name = name; - mtd->pnext = NULL; - - /* Add to the list of registered devices */ - - if (g_pfirstmtd == NULL) - { - g_pfirstmtd = mtd; - } - else - { - /* Insert at end of list */ - - plast = g_pfirstmtd; - while (plast->pnext) - { - /* Skip to next entry as long as there is one */ - - plast = plast->pnext; - } - - /* Now insert at this location */ - - plast->pnext = mtd; - } - - return OK; -} - -/**************************************************************************** - * Name: mtd_unregister - * - * Description: - * Un-Registers an MTD device with the procfs file system. - * - * In an embedded system, this all is really unnecessary, but is provided - * in the procfs system simply for information purposes (if desired). - * - ****************************************************************************/ - -int mtd_unregister(FAR struct mtd_dev_s *mtd) -{ - FAR struct mtd_dev_s *plast; - - /* Remove the MTD from the list of registered devices */ - - if (g_pfirstmtd == mtd) - { - g_pfirstmtd = mtd->pnext; - } - else - { - /* Remove from middle of list */ - - plast = g_pfirstmtd; - while (plast->pnext != mtd) - { - /* Skip to next entry as long as there is one */ - - plast = plast->pnext; - } - - /* Now remove at this location */ - - plast->pnext = mtd->pnext; - } - - return OK; -} - -#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS */ diff --git a/drivers/mtd/mtd_progmem.c b/drivers/mtd/mtd_progmem.c index da903e68ca..b0dbfb2a28 100644 --- a/drivers/mtd/mtd_progmem.c +++ b/drivers/mtd/mtd_progmem.c @@ -114,7 +114,8 @@ static struct progmem_dev_s g_progmem = #ifdef CONFIG_MTD_BYTE_WRITE progmem_write, #endif - progmem_ioctl + progmem_ioctl, + "progmem", } }; @@ -412,12 +413,6 @@ FAR struct mtd_dev_s *progmem_initialize(void) g_progmem.blkshift = blkshift; g_progmem.ersshift = ersshift; g_progmem.initialized = true; - -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "progmem"); -#endif } /* Return the implementation-specific state structure as the MTD device */ diff --git a/drivers/mtd/mtd_rwbuffer.c b/drivers/mtd/mtd_rwbuffer.c index 7c76c5b4a5..1497131300 100644 --- a/drivers/mtd/mtd_rwbuffer.c +++ b/drivers/mtd/mtd_rwbuffer.c @@ -372,6 +372,7 @@ FAR struct mtd_dev_s *mtd_rwb_initialize(FAR struct mtd_dev_s *mtd) priv->mtd.bwrite = mtd_bwrite; /* Our MTD bwrite method */ priv->mtd.read = mtd_read; /* Our MTD read method */ priv->mtd.ioctl = mtd_ioctl; /* Our MTD ioctl method */ + priv->mtd.name = "rwbuffer"; priv->dev = mtd; /* The contained MTD instance */ @@ -413,12 +414,6 @@ FAR struct mtd_dev_s *mtd_rwb_initialize(FAR struct mtd_dev_s *mtd) return NULL; } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "rwbuffer"); -#endif - /* Return the implementation-specific state structure as the MTD device */ return &priv->mtd; diff --git a/drivers/mtd/mx25lx.c b/drivers/mtd/mx25lx.c index f8a19de551..12d83034dc 100644 --- a/drivers/mtd/mx25lx.c +++ b/drivers/mtd/mx25lx.c @@ -1021,6 +1021,7 @@ FAR struct mtd_dev_s *mx25l_initialize_spi(FAR struct spi_dev_s *dev) priv->mtd.bwrite = mx25l_bwrite; priv->mtd.read = mx25l_read; priv->mtd.ioctl = mx25l_ioctl; + priv->mtd.name = "mx25l"; priv->dev = dev; /* Deselect the FLASH */ @@ -1053,12 +1054,6 @@ FAR struct mtd_dev_s *mx25l_initialize_spi(FAR struct spi_dev_s *dev) return NULL; } #endif - -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "mx25l"); -#endif } } diff --git a/drivers/mtd/mx25rxx.c b/drivers/mtd/mx25rxx.c index 785999601f..e29359b99e 100644 --- a/drivers/mtd/mx25rxx.c +++ b/drivers/mtd/mx25rxx.c @@ -747,6 +747,7 @@ FAR struct mtd_dev_s *mx25rxx_initialize(FAR struct qspi_dev_s *qspi, bool unpro dev->mtd.bwrite = mx25rxx_bwrite; dev->mtd.read = mx25rxx_read; dev->mtd.ioctl = mx25rxx_ioctl; + dev->mtd.name = "mx25rxx"; dev->qspi = qspi; /* Allocate a 4-byte buffer to support DMA-able command data */ @@ -788,12 +789,6 @@ FAR struct mtd_dev_s *mx25rxx_initialize(FAR struct qspi_dev_s *qspi, bool unpro mx25rxx_unlock(dev->qspi); -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&dev->mtd, "mx25rxx"); -#endif - /* Return the implementation-specific state structure as the MTD device */ return &dev->mtd; diff --git a/drivers/mtd/mx35.c b/drivers/mtd/mx35.c index 862e544106..7275198f0c 100644 --- a/drivers/mtd/mx35.c +++ b/drivers/mtd/mx35.c @@ -910,6 +910,7 @@ FAR struct mtd_dev_s *mx35_initialize(FAR struct spi_dev_s *dev) priv->mtd.read = mx35_read; priv->mtd.write = mx35_write; priv->mtd.ioctl = mx35_ioctl; + priv->mtd.name = "mx35"; priv->dev = dev; /* Deselect the FLASH */ @@ -937,15 +938,6 @@ FAR struct mtd_dev_s *mx35_initialize(FAR struct spi_dev_s *dev) kmm_free(priv); return NULL; } - else - { - -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "mx35"); -#endif - } mx35_enableECC(priv); mx35_unlockblocks(priv); diff --git a/drivers/mtd/n25qxxx.c b/drivers/mtd/n25qxxx.c index cd66ea2763..3ab92626dc 100644 --- a/drivers/mtd/n25qxxx.c +++ b/drivers/mtd/n25qxxx.c @@ -1423,6 +1423,7 @@ FAR struct mtd_dev_s *n25qxxx_initialize(FAR struct qspi_dev_s *qspi, bool unpro priv->mtd.bwrite = n25qxxx_bwrite; priv->mtd.read = n25qxxx_read; priv->mtd.ioctl = n25qxxx_ioctl; + priv->mtd.name = "n25qxxx"; priv->qspi = qspi; /* Allocate a 4-byte buffer to support DMA-able command data */ @@ -1488,12 +1489,6 @@ FAR struct mtd_dev_s *n25qxxx_initialize(FAR struct qspi_dev_s *qspi, bool unpro #endif } -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "n25qxxx"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/rammtd.c b/drivers/mtd/rammtd.c index 66daf1a6ef..0fa2ba7145 100644 --- a/drivers/mtd/rammtd.c +++ b/drivers/mtd/rammtd.c @@ -469,15 +469,10 @@ FAR struct mtd_dev_s *rammtd_initialize(FAR uint8_t *start, size_t size) priv->mtd.write = ram_bytewrite; #endif priv->mtd.ioctl = ram_ioctl; + priv->mtd.name = "rammtd"; priv->start = start; priv->nblocks = nblocks; - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "rammtd"); -#endif - return &priv->mtd; } diff --git a/drivers/mtd/ramtron.c b/drivers/mtd/ramtron.c index e3a5a5adbf..165a1ab083 100644 --- a/drivers/mtd/ramtron.c +++ b/drivers/mtd/ramtron.c @@ -989,6 +989,7 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev) priv->mtd.bwrite = ramtron_bwrite; priv->mtd.read = ramtron_read; priv->mtd.ioctl = ramtron_ioctl; + priv->mtd.name = "ramtron"; priv->dev = dev; /* Deselect the FLASH */ @@ -1006,12 +1007,6 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "ramtron"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/s25fl1.c b/drivers/mtd/s25fl1.c index a372ec03b5..e9aaff4aa1 100644 --- a/drivers/mtd/s25fl1.c +++ b/drivers/mtd/s25fl1.c @@ -1470,6 +1470,7 @@ FAR struct mtd_dev_s *s25fl1_initialize(FAR struct qspi_dev_s *qspi, bool unprot priv->mtd.bwrite = s25fl1_bwrite; priv->mtd.read = s25fl1_read; priv->mtd.ioctl = s25fl1_ioctl; + priv->mtd.name = "s25fl1"; priv->qspi = qspi; /* Allocate a 4-byte buffer to support DMA command data */ @@ -1540,12 +1541,6 @@ FAR struct mtd_dev_s *s25fl1_initialize(FAR struct qspi_dev_s *qspi, bool unprot #endif } -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "s25fl1"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/sector512.c b/drivers/mtd/sector512.c index 5e0100183a..da0995b305 100644 --- a/drivers/mtd/sector512.c +++ b/drivers/mtd/sector512.c @@ -615,6 +615,7 @@ FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd) priv->mtd.bwrite = s512_bwrite; priv->mtd.read = s512_read; priv->mtd.ioctl = s512_ioctl; + priv->mtd.name = "sector512"; priv->dev = mtd; priv->eblocksize = geo.erasesize; @@ -635,12 +636,6 @@ FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "sector512"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/skeleton.c b/drivers/mtd/skeleton.c index 00dc0e5b5b..f888fd135c 100644 --- a/drivers/mtd/skeleton.c +++ b/drivers/mtd/skeleton.c @@ -327,14 +327,6 @@ FAR struct mtd_dev_s *skel_initialize(void) * device structure. */ - /* Perform initialization as necessary */ - -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "skeleton"); -#endif - /* Return the implementation-specific state structure as the MTD device */ return (FAR struct mtd_dev_s *)&g_skeldev; diff --git a/drivers/mtd/sst25.c b/drivers/mtd/sst25.c index 46f8046170..6ca0c36905 100644 --- a/drivers/mtd/sst25.c +++ b/drivers/mtd/sst25.c @@ -1194,6 +1194,7 @@ FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev) priv->mtd.bwrite = sst25_bwrite; priv->mtd.read = sst25_read; priv->mtd.ioctl = sst25_ioctl; + priv->mtd.name = "sst25"; priv->dev = dev; /* Deselect the FLASH */ @@ -1235,12 +1236,6 @@ FAR struct mtd_dev_s *sst25_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "sst25"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/sst25xx.c b/drivers/mtd/sst25xx.c index fc3d0556d3..667d12cad3 100644 --- a/drivers/mtd/sst25xx.c +++ b/drivers/mtd/sst25xx.c @@ -950,6 +950,7 @@ FAR struct mtd_dev_s *sst25xx_initialize(FAR struct spi_dev_s *dev) priv->mtd.write = sst25xx_write; #endif priv->mtd.ioctl = sst25xx_ioctl; + priv->mtd.name = "sst25xx"; priv->dev = dev; priv->lastwaswrite = false; @@ -976,12 +977,6 @@ FAR struct mtd_dev_s *sst25xx_initialize(FAR struct spi_dev_s *dev) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "sst25xx"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/drivers/mtd/sst26.c b/drivers/mtd/sst26.c index d7e642b93d..d8a2efa475 100644 --- a/drivers/mtd/sst26.c +++ b/drivers/mtd/sst26.c @@ -944,6 +944,7 @@ FAR struct mtd_dev_s *sst26_initialize_spi(FAR struct spi_dev_s *dev) priv->mtd.write = sst26_write; #endif priv->mtd.ioctl = sst26_ioctl; + priv->mtd.name = "sst26"; priv->dev = dev; /* Deselect the FLASH */ @@ -967,12 +968,6 @@ FAR struct mtd_dev_s *sst26_initialize_spi(FAR struct spi_dev_s *dev) sst26_writeenable(priv); sst26_globalunlock(priv); sst26_writedisable(priv); - -#ifdef CONFIG_MTD_REGISTRATION - /* Register the MTD with the procfs system if enabled */ - - mtd_register(&priv->mtd, "sst26"); -#endif } } diff --git a/drivers/mtd/sst39vf.c b/drivers/mtd/sst39vf.c index 43debd5aab..cbd4e3400e 100644 --- a/drivers/mtd/sst39vf.c +++ b/drivers/mtd/sst39vf.c @@ -205,7 +205,8 @@ static struct sst39vf_dev_s g_sst39vf = #ifdef CONFIG_MTD_BYTE_WRITE NULL, /* write method */ #endif - sst39vf_ioctl /* ioctl method */ + sst39vf_ioctl, /* ioctl method */ + "sst39vf", }, NULL /* Chip */ }; @@ -845,12 +846,6 @@ FAR struct mtd_dev_s *sst39vf_initialize(void) return NULL; } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "sst39vf"); -#endif - /* Return the state structure as the MTD device */ return (FAR struct mtd_dev_s *)&g_sst39vf; diff --git a/drivers/mtd/w25.c b/drivers/mtd/w25.c index 70f7ff8259..0245ee9e4e 100644 --- a/drivers/mtd/w25.c +++ b/drivers/mtd/w25.c @@ -1330,6 +1330,7 @@ FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *spi) #if defined(CONFIG_MTD_BYTE_WRITE) && !defined(CONFIG_W25_READONLY) priv->mtd.write = w25_write; #endif + priv->mtd.name = "w25"; priv->spi = spi; /* Deselect the FLASH */ @@ -1371,12 +1372,6 @@ FAR struct mtd_dev_s *w25_initialize(FAR struct spi_dev_s *spi) } } - /* Register the MTD with the procfs system if enabled */ - -#ifdef CONFIG_MTD_REGISTRATION - mtd_register(&priv->mtd, "w25"); -#endif - /* Return the implementation-specific state structure as the MTD device */ finfo("Return %p\n", priv); diff --git a/fs/procfs/Kconfig b/fs/procfs/Kconfig index 0e112f512f..f4cc974551 100644 --- a/fs/procfs/Kconfig +++ b/fs/procfs/Kconfig @@ -102,11 +102,6 @@ config FS_PROCFS_EXCLUDE_NET depends on NET default n -config FS_PROCFS_EXCLUDE_MTD - bool "Exclude mtd" - depends on MTD - default n - config FS_PROCFS_EXCLUDE_PARTITIONS bool "Exclude partitions" depends on MTD_PARTITION diff --git a/fs/procfs/fs_procfs.c b/fs/procfs/fs_procfs.c index d0563440be..931684ba50 100644 --- a/fs/procfs/fs_procfs.c +++ b/fs/procfs/fs_procfs.c @@ -91,7 +91,6 @@ extern const struct procfs_operations uptime_operations; extern const struct procfs_operations net_procfsoperations; extern const struct procfs_operations net_procfs_routeoperations; -extern const struct procfs_operations mtd_procfsoperations; extern const struct procfs_operations part_procfsoperations; extern const struct procfs_operations mount_procfsoperations; extern const struct procfs_operations smartfs_procfsoperations; @@ -153,10 +152,6 @@ static const struct procfs_entry_s g_procfs_entries[] = { "fs/smartfs**", &smartfs_procfsoperations, PROCFS_UNKOWN_TYPE }, #endif -#if defined(CONFIG_MTD) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MTD) - { "mtd", &mtd_procfsoperations, PROCFS_FILE_TYPE }, -#endif - #if defined(CONFIG_NET) && !defined(CONFIG_FS_PROCFS_EXCLUDE_NET) { "net", &net_procfsoperations, PROCFS_DIR_TYPE }, #if defined(CONFIG_NET_ROUTE) && !defined(CONFIG_FS_PROCFS_EXCLUDE_ROUTE) diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h index 1cce4cdab6..b2d47e5de3 100644 --- a/include/nuttx/mtd/mtd.h +++ b/include/nuttx/mtd/mtd.h @@ -100,10 +100,6 @@ # define CONFIG_MTD_SUBSECTOR_ERASE 1 #endif -#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MTD) -# define CONFIG_MTD_REGISTRATION 1 -#endif - /**************************************************************************** * Public Types ****************************************************************************/ @@ -192,19 +188,9 @@ struct mtd_dev_s int (*ioctl)(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); -#ifdef CONFIG_MTD_REGISTRATION - /* An assigned MTD number for procfs reporting */ - - uint8_t mtdno; - - /* Pointer to the next registered MTD device */ - - FAR struct mtd_dev_s *pnext; - /* Name of this MTD device */ FAR const char *name; -#endif }; /**************************************************************************** @@ -664,38 +650,6 @@ void filemtd_teardown(FAR struct mtd_dev_s* dev); bool filemtd_isfilemtd(FAR struct mtd_dev_s* mtd); -/**************************************************************************** - * Name: mtd_register - * - * Description: - * Registers MTD device with the procfs file system. This assigns a unique - * MTD number and associates the given device name, then adds it to - * the list of registered devices. - * - * In an embedded system, this all is really unnecessary, but is provided - * in the procfs system simply for information purposes (if desired). - * - ****************************************************************************/ - -#ifdef CONFIG_MTD_REGISTRATION -int mtd_register(FAR struct mtd_dev_s *mtd, FAR const char *name); -#endif - -/**************************************************************************** - * Name: mtd_unregister - * - * Description: - * Un-registers an MTD device with the procfs file system. - * - * In an embedded system, this all is really unnecessary, but is provided - * in the procfs system simply for information purposes (if desired). - * - ****************************************************************************/ - -#ifdef CONFIG_MTD_REGISTRATION -int mtd_unregister(FAR struct mtd_dev_s *mtd); -#endif - #undef EXTERN #ifdef __cplusplus }