drivers/mtd and other MTD drivers: Remove mtd_procfsoperations since we can now get the same information from inode

This commit is contained in:
Xiang Xiao 2018-11-08 09:46:11 -06:00 committed by Gregory Nutt
parent d32d9d4b24
commit 247414c6ad
30 changed files with 33 additions and 648 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -1,407 +0,0 @@
/****************************************************************************
* drivers/mtd/mtd_procfs.c
*
* Copyright (C) 2013 Ken Pettit. All rights reserved.
* Author: Ken Pettit <pettitkd@gmail.com>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/procfs.h>
#include <nuttx/mtd/mtd.h>
#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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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)

View File

@ -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
}