summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-01-28 22:55:33 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-01-29 09:27:03 +0100
commit6f37d9efd9183ff06e65438e349ac2341d459290 (patch)
tree90ae6874b7a4b11c4665432b2efc1016464c600f
parent184d75a9dee979bf044649bff2854bc66172c9ff (diff)
downloadbarebox-6f37d9efd9183ff06e65438e349ac2341d459290.tar.gz
commands: Move /dev/mem driver to drivers/misc
With all other code gone from commands/mem.c, move it into driver/misc, where it fits better. While at it, expose it directly via a Kconfig options instead of relying on CONFIG_COMPILE_MEMORY Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--commands/Kconfig17
-rw-r--r--commands/Makefile1
-rw-r--r--commands/mem.c77
-rw-r--r--drivers/misc/Kconfig3
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/mem.c44
6 files changed, 54 insertions, 89 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 1de4b9d..c14332c 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -14,11 +14,6 @@ config COMPILE_HASH
help
Turns on compilation of digest.c
-config COMPILE_MEMORY
- bool
- help
- Turns on compilation of mem.c
-
menu "Commands"
@@ -1493,7 +1488,7 @@ config CMD_CRC_CMP
config CMD_MD
tristate
default y
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "md"
help
Memory display
@@ -1517,7 +1512,7 @@ config CMD_MD
config CMD_MEMCMP
tristate
default y
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "memcmp"
help
Memory compare
@@ -1539,7 +1534,7 @@ config CMD_MEMCMP
config CMD_MEMCPY
tristate
default y
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "memcpy"
help
Memory copy
@@ -1558,7 +1553,7 @@ config CMD_MEMCPY
config CMD_MEMSET
tristate
default y
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "memset"
help
Memory fill
@@ -1591,7 +1586,7 @@ config CMD_MEMTEST
config CMD_MM
tristate
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "memory modify (mm)"
help
Memory modify with mask
@@ -1609,7 +1604,7 @@ config CMD_MM
config CMD_MW
tristate
default y
- select COMPILE_MEMORY
+ select DEV_MEM
prompt "mw"
help
Memory write
diff --git a/commands/Makefile b/commands/Makefile
index eb47963..358671b 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -1,7 +1,6 @@
obj-$(CONFIG_STDDEV) += stddev.o
obj-$(CONFIG_CMD_DIGEST) += digest.o
obj-$(CONFIG_COMPILE_HASH) += hashsum.o
-obj-$(CONFIG_COMPILE_MEMORY) += mem.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_UIMAGE) += uimage.o
obj-$(CONFIG_CMD_LINUX16) += linux16.o
diff --git a/commands/mem.c b/commands/mem.c
deleted file mode 100644
index 8a47e1f..0000000
--- a/commands/mem.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-/*
- * Memory Functions
- *
- * Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
- */
-
-#include <common.h>
-#include <command.h>
-#include <init.h>
-#include <driver.h>
-#include <malloc.h>
-#include <errno.h>
-#include <fs.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <linux/stat.h>
-#include <xfuncs.h>
-
-#ifdef CMD_MEM_DEBUG
-#define PRINTF(fmt,args...) printf (fmt ,##args)
-#else
-#define PRINTF(fmt,args...)
-#endif
-
-static struct cdev_operations memops = {
- .read = mem_read,
- .write = mem_write,
- .memmap = generic_memmap_rw,
- .lseek = dev_lseek_default,
-};
-
-static int mem_probe(struct device_d *dev)
-{
- struct cdev *cdev;
-
- cdev = xzalloc(sizeof (*cdev));
- dev->priv = cdev;
-
- cdev->name = (char*)dev->resource[0].name;
- cdev->size = min_t(unsigned long long, resource_size(&dev->resource[0]),
- S64_MAX);
- cdev->ops = &memops;
- cdev->dev = dev;
-
- devfs_create(cdev);
-
- return 0;
-}
-
-static struct driver_d mem_drv = {
- .name = "mem",
- .probe = mem_probe,
-};
-
-static int mem_init(void)
-{
- add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE);
- return platform_driver_register(&mem_drv);
-}
-device_initcall(mem_init);
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 6640a70..4c8a769 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -20,4 +20,7 @@ config STATE_DRV
depends on OFDEVICE
depends on STATE
+config DEV_MEM
+ bool "Generic memory I/O device (/dev/mem)"
+
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 487e4b8..d4e616d 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,3 +5,4 @@
obj-$(CONFIG_JTAG) += jtag.o
obj-$(CONFIG_SRAM) += sram.o
obj-$(CONFIG_STATE_DRV) += state.o
+obj-$(CONFIG_DEV_MEM) += mem.o
diff --git a/drivers/misc/mem.c b/drivers/misc/mem.c
new file mode 100644
index 0000000..60981a3
--- /dev/null
+++ b/drivers/misc/mem.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2011 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <init.h>
+
+static struct cdev_operations memops = {
+ .read = mem_read,
+ .write = mem_write,
+ .memmap = generic_memmap_rw,
+};
+
+static int mem_probe(struct device_d *dev)
+{
+ struct cdev *cdev;
+
+ cdev = xzalloc(sizeof (*cdev));
+ dev->priv = cdev;
+
+ cdev->name = (char*)dev->resource[0].name;
+ cdev->size = min_t(unsigned long long, resource_size(&dev->resource[0]),
+ S64_MAX);
+ cdev->ops = &memops;
+ cdev->dev = dev;
+
+ devfs_create(cdev);
+
+ return 0;
+}
+
+static struct driver_d mem_drv = {
+ .name = "mem",
+ .probe = mem_probe,
+};
+
+static int mem_init(void)
+{
+ add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE);
+ return platform_driver_register(&mem_drv);
+}
+device_initcall(mem_init);