linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/17] mtd: get rid of direct mtd->func use
@ 2012-01-02 12:20 Artem Bityutskiy
  2012-01-02 12:20 ` [PATCH 04/17] romfs: do not use mtd->get_unmapped_area directly Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Bityutskiy @ 2012-01-02 12:20 UTC (permalink / raw)
  To: linux-mtd; +Cc: Jörn Engel, linux-fsdevel

Hi,

this patch-set goes on top of the "MTD API rework" patches which I sent
recently:

http://lists.infradead.org/pipermail/linux-mtd/2011-December/039031.html

This patch-set further removes direct mtd function pointers accesses like:

if (mtd->block_isbad)
	blah

This is a part of the big MTD API re-work we have started. The next steps will
be:

1. Rename all the function pointers to make sure we catch all direct uses:
   (s/mtd->func/mtd->_func/g)
2. Move common input parameters check from implementations to the wrapper
   function to get rid of duplication.

Artem.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 04/17] romfs: do not use mtd->get_unmapped_area directly
  2012-01-02 12:20 [PATCH 00/17] mtd: get rid of direct mtd->func use Artem Bityutskiy
@ 2012-01-02 12:20 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2012-01-02 12:20 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-fsdevel

From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Remove direct usage of mtd->get_unmapped_area. Instead, just call
'mtd_get_unmapped_area()' which will return -EOPNOTSUPP if the function
is not implemented, and then test for this code.

We also translate -EOPNOTSUPP to -ENOSYS because this return code is
probably part of the kernel ABI which we do not want to break.

Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 fs/romfs/mmap-nommu.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index d5168e8..e1a7779 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -28,9 +28,10 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
 	struct inode *inode = file->f_mapping->host;
 	struct mtd_info *mtd = inode->i_sb->s_mtd;
 	unsigned long isize, offset, maxpages, lpages;
+	int ret;
 
 	if (!mtd)
-		goto cant_map_directly;
+		return (unsigned long) -ENOSYS;
 
 	/* the mapping mustn't extend beyond the EOF */
 	lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -41,23 +42,20 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
 	if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
 		return (unsigned long) -EINVAL;
 
-	/* we need to call down to the MTD layer to do the actual mapping */
-	if (mtd->get_unmapped_area) {
-		if (addr != 0)
-			return (unsigned long) -EINVAL;
-
-		if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT))
-			return (unsigned long) -EINVAL;
+	if (addr != 0)
+		return (unsigned long) -EINVAL;
 
-		offset += ROMFS_I(inode)->i_dataoffset;
-		if (offset > mtd->size - len)
-			return (unsigned long) -EINVAL;
+	if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT))
+		return (unsigned long) -EINVAL;
 
-		return mtd_get_unmapped_area(mtd, len, offset, flags);
-	}
+	offset += ROMFS_I(inode)->i_dataoffset;
+	if (offset > mtd->size - len)
+		return (unsigned long) -EINVAL;
 
-cant_map_directly:
-	return (unsigned long) -ENOSYS;
+	ret = mtd_get_unmapped_area(mtd, len, offset, flags);
+	if (ret == -EOPNOTSUPP)
+		ret = -ENOSYS;
+	return (unsigned long) ret;
 }
 
 /*
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-02 12:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-02 12:20 [PATCH 00/17] mtd: get rid of direct mtd->func use Artem Bityutskiy
2012-01-02 12:20 ` [PATCH 04/17] romfs: do not use mtd->get_unmapped_area directly Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).