mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 06/19] fs: Move mem_write/mem_read to devfs-core
Date: Tue,  3 Apr 2018 09:48:38 +0200	[thread overview]
Message-ID: <20180403074851.5411-7-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180403074851.5411-1-s.hauer@pengutronix.de>

fs.c is already heavily filled with code. Move mem_write/mem_read
to devfs-core where it fits better.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/devfs-core.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/fs.c         | 66 -------------------------------------------------------
 2 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index d06a534b57..6b5e6da6a8 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -513,3 +513,71 @@ void cdev_remove_loop(struct cdev *cdev)
 	free(cdev->name);
 	free(cdev);
 }
+
+static void memcpy_sz(void *dst, const void *src, size_t count, int rwsize)
+{
+	/* no rwsize specification given. Do whatever memcpy likes best */
+	if (!rwsize) {
+		memcpy(dst, src, count);
+		return;
+	}
+
+	rwsize = rwsize >> O_RWSIZE_SHIFT;
+
+	count /= rwsize;
+
+	while (count-- > 0) {
+		switch (rwsize) {
+		case 1:
+			*((u8 *)dst) = *((u8 *)src);
+			break;
+		case 2:
+			*((u16 *)dst) = *((u16 *)src);
+			break;
+		case 4:
+			*((u32  *)dst) = *((u32  *)src);
+			break;
+		case 8:
+			*((u64  *)dst) = *((u64  *)src);
+			break;
+		}
+		dst += rwsize;
+		src += rwsize;
+	}
+}
+
+ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset,
+		 unsigned long flags)
+{
+	unsigned long size;
+	struct device_d *dev;
+
+	if (!cdev->dev || cdev->dev->num_resources < 1)
+		return -1;
+	dev = cdev->dev;
+
+	size = min((resource_size_t)count,
+			resource_size(&dev->resource[0]) -
+			(resource_size_t)offset);
+	memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
+	return size;
+}
+EXPORT_SYMBOL(mem_read);
+
+ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset,
+		  unsigned long flags)
+{
+	unsigned long size;
+	struct device_d *dev;
+
+	if (!cdev->dev || cdev->dev->num_resources < 1)
+		return -1;
+	dev = cdev->dev;
+
+	size = min((resource_size_t)count,
+			resource_size(&dev->resource[0]) -
+			(resource_size_t)offset);
+	memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
+	return size;
+}
+EXPORT_SYMBOL(mem_write);
diff --git a/fs/fs.c b/fs/fs.c
index 5135112c8b..ca4fe70e15 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1739,72 +1739,6 @@ out:
 }
 EXPORT_SYMBOL(rmdir);
 
-static void memcpy_sz(void *dst, const void *src, size_t count, int rwsize)
-{
-	/* no rwsize specification given. Do whatever memcpy likes best */
-	if (!rwsize) {
-		memcpy(dst, src, count);
-		return;
-	}
-
-	rwsize = rwsize >> O_RWSIZE_SHIFT;
-
-	count /= rwsize;
-
-	while (count-- > 0) {
-		switch (rwsize) {
-		case 1:
-			*((u8 *)dst) = *((u8 *)src);
-			break;
-		case 2:
-			*((u16 *)dst) = *((u16 *)src);
-			break;
-		case 4:
-			*((u32  *)dst) = *((u32  *)src);
-			break;
-		case 8:
-			*((u64  *)dst) = *((u64  *)src);
-			break;
-		}
-		dst += rwsize;
-		src += rwsize;
-	}
-}
-
-ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
-{
-	ulong size;
-	struct device_d *dev;
-
-	if (!cdev->dev || cdev->dev->num_resources < 1)
-		return -1;
-	dev = cdev->dev;
-
-	size = min((resource_size_t)count,
-			resource_size(&dev->resource[0]) -
-			(resource_size_t)offset);
-	memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
-	return size;
-}
-EXPORT_SYMBOL(mem_read);
-
-ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
-{
-	ulong size;
-	struct device_d *dev;
-
-	if (!cdev->dev || cdev->dev->num_resources < 1)
-		return -1;
-	dev = cdev->dev;
-
-	size = min((resource_size_t)count,
-			resource_size(&dev->resource[0]) -
-			(resource_size_t)offset);
-	memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
-	return size;
-}
-EXPORT_SYMBOL(mem_write);
-
 /*
  * cdev_get_mount_path - return the path a cdev is mounted on
  *
-- 
2.16.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-04-03  7:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03  7:48 [PATCH 00/19] Add Linux dcache implementation Sascha Hauer
2018-04-03  7:48 ` [PATCH 01/19] rename file_operations -> cdev_operations Sascha Hauer
2018-04-03  7:48 ` [PATCH 02/19] ubifs: remove dead code Sascha Hauer
2018-04-03  7:48 ` [PATCH 03/19] ubifs: Remove Linux struct definitions we already have Sascha Hauer
2018-04-03  7:48 ` [PATCH 04/19] ubifs: remove dead code Sascha Hauer
2018-04-03  7:48 ` [PATCH 05/19] fs: Add super_operations Sascha Hauer
2018-04-03  7:48 ` Sascha Hauer [this message]
2018-04-03  7:48 ` [PATCH 07/19] fs: Cleanup whitespace damage Sascha Hauer
2018-04-03  7:48 ` [PATCH 08/19] fs: Fix finding correct directory for mkdir/rmdir Sascha Hauer
2018-04-03  7:48 ` [PATCH 09/19] glob: do not unnecessarily opendir() a directory Sascha Hauer
2018-04-03  7:48 ` [PATCH 10/19] ls: Do not depend on normalise_path() Sascha Hauer
2018-04-03  7:48 ` [PATCH 11/19] loadenv: " Sascha Hauer
2018-04-03  7:48 ` [PATCH 12/19] fs: dcache implementation Sascha Hauer
2018-04-03  7:48 ` [PATCH 13/19] fs: ramfs: Switch to " Sascha Hauer
2018-04-03  7:48 ` [PATCH 14/19] fs: devfs: " Sascha Hauer
2018-04-03  7:48 ` [PATCH 15/19] fs: ext4: " Sascha Hauer
2018-04-03  7:48 ` [PATCH 16/19] fs: ubifs: " Sascha Hauer
2018-04-03  7:48 ` [PATCH 17/19] fs: nfs: " Sascha Hauer
2018-04-03  7:48 ` [PATCH 18/19] fs: tftp: " Sascha Hauer
2018-05-18 11:54   ` Philipp Zabel
2018-05-22  7:12     ` Sascha Hauer
2018-05-22  8:21       ` Philipp Zabel
2018-04-03  7:48 ` [PATCH 19/19] block: Adjust cache sizes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180403074851.5411-7-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox