From 60aaeb8be019c75d86cd0aa9615d1ef470983418 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 28 Jan 2019 22:55:31 -0800 Subject: commands: Move mem_parse_options() to lib/misc.c As a first step of de-cluttering /dev/mem related code, move mem_parse_options() out of commands/mem.c into lib/misc.c where it seem to fit better. With this change we no longer explicitly turn this code off using CONFIG_COMPILE_MEMORY and instead rely on LTO to get rid of it when it's not being used. While at it, also fix return value by replacing COMMAND_ERROR_USAGE with -EINVAL. All of the callers of mem_parse_options() expect negative error code as a sign of failure and COMMAND_ERROR_USAGE is not negative. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- commands/mem.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'commands') diff --git a/commands/mem.c b/commands/mem.c index a9e12f3e55..62488bf525 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -41,46 +41,6 @@ char *mem_rw_buf; -/* - * Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp' - * commands. - */ -int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, - char **sourcefile, char **destfile, int *swab) -{ - int opt; - - while((opt = getopt(argc, argv, optstr)) > 0) { - switch(opt) { - case 'b': - *mode = O_RWSIZE_1; - break; - case 'w': - *mode = O_RWSIZE_2; - break; - case 'l': - *mode = O_RWSIZE_4; - break; - case 'q': - *mode = O_RWSIZE_8; - break; - case 's': - *sourcefile = optarg; - break; - case 'd': - *destfile = optarg; - break; - case 'x': - *swab = 1; - break; - default: - return COMMAND_ERROR_USAGE; - } - } - - return 0; -} - static struct cdev_operations memops = { .read = mem_read, .write = mem_write, -- cgit v1.2.3 From 184d75a9dee979bf044649bff2854bc66172c9ff Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 28 Jan 2019 22:55:32 -0800 Subject: commands: Get rid of mem_rw_buf There doesn't seem to be any good reason for all of the memory commands (md, mw, etc.) to rely on a shared pre-allocated buffer anymore. So, to simplify things, drop the shared buffer and adjust all of the utilites to allocate needed memory. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- commands/md.c | 12 +++++++----- commands/mem.c | 6 ------ commands/memcmp.c | 16 ++++++++-------- commands/memcpy.c | 10 ++++++---- commands/memset.c | 2 -- common/ratp/md.c | 9 +++++---- 6 files changed, 26 insertions(+), 29 deletions(-) (limited to 'commands') diff --git a/commands/md.c b/commands/md.c index 3e83c723a3..1ca7931ae1 100644 --- a/commands/md.c +++ b/commands/md.c @@ -34,8 +34,6 @@ #include #include -extern char *mem_rw_buf; - static int do_mem_md(int argc, char *argv[]) { loff_t start = 0, size = 0x100; @@ -46,6 +44,7 @@ static int do_mem_md(int argc, char *argv[]) int mode = O_RWSIZE_4; int swab = 0; void *map; + void *buf = NULL; if (argc < 2) return COMMAND_ERROR_USAGE; @@ -74,9 +73,11 @@ static int do_mem_md(int argc, char *argv[]) goto out; } + buf = xmalloc(RW_BUF_SIZE); + do { now = min(size, (loff_t)RW_BUF_SIZE); - r = read(fd, mem_rw_buf, now); + r = read(fd, buf, now); if (r < 0) { perror("read"); goto out; @@ -84,8 +85,8 @@ static int do_mem_md(int argc, char *argv[]) if (!r) goto out; - if ((ret = memory_display(mem_rw_buf, start, r, - mode >> O_RWSIZE_SHIFT, swab))) + if ((ret = memory_display(buf, start, r, + mode >> O_RWSIZE_SHIFT, swab))) goto out; start += r; @@ -93,6 +94,7 @@ static int do_mem_md(int argc, char *argv[]) } while (size); out: + free(buf); close(fd); return ret ? 1 : 0; diff --git a/commands/mem.c b/commands/mem.c index 62488bf525..8a47e1fe1b 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -39,8 +39,6 @@ #define PRINTF(fmt,args...) #endif -char *mem_rw_buf; - static struct cdev_operations memops = { .read = mem_read, .write = mem_write, @@ -73,10 +71,6 @@ static struct driver_d mem_drv = { static int mem_init(void) { - mem_rw_buf = malloc(RW_BUF_SIZE); - if(!mem_rw_buf) - return -ENOMEM; - add_mem_device("mem", 0, ~0, IORESOURCE_MEM_WRITEABLE); return platform_driver_register(&mem_drv); } diff --git a/commands/memcmp.c b/commands/memcmp.c index 981c8cb38d..48957b4500 100644 --- a/commands/memcmp.c +++ b/commands/memcmp.c @@ -34,8 +34,6 @@ #include #include -extern char *mem_rw_buf; - static char *devmem = "/dev/mem"; static int do_memcmp(int argc, char *argv[]) @@ -45,7 +43,7 @@ static int do_memcmp(int argc, char *argv[]) char *sourcefile = devmem; char *destfile = devmem; int sourcefd, destfd; - char *rw_buf1; + char *buf, *source_data, *dest_data; int ret = 1; int offset = 0; struct stat statbuf; @@ -84,20 +82,22 @@ static int do_memcmp(int argc, char *argv[]) return 1; } - rw_buf1 = xmalloc(RW_BUF_SIZE); + buf = xmalloc(RW_BUF_SIZE + RW_BUF_SIZE); + source_data = buf; + dest_data = buf + RW_BUF_SIZE; while (count > 0) { int now, r1, r2, i; now = min((loff_t)RW_BUF_SIZE, count); - r1 = read_full(sourcefd, mem_rw_buf, now); + r1 = read_full(sourcefd, source_data, now); if (r1 < 0) { perror("read"); goto out; } - r2 = read_full(destfd, rw_buf1, now); + r2 = read_full(destfd, dest_data, now); if (r2 < 0) { perror("read"); goto out; @@ -109,7 +109,7 @@ static int do_memcmp(int argc, char *argv[]) } for (i = 0; i < now; i++) { - if (mem_rw_buf[i] != rw_buf1[i]) { + if (source_data[i] != dest_data[i]) { printf("files differ at offset %d\n", offset); goto out; } @@ -124,7 +124,7 @@ static int do_memcmp(int argc, char *argv[]) out: close(sourcefd); close(destfd); - free(rw_buf1); + free(buf); return ret; } diff --git a/commands/memcpy.c b/commands/memcpy.c index 168ef3b4fc..ddaf767eac 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -34,8 +34,6 @@ #include #include -extern char *mem_rw_buf; - static char *devmem = "/dev/mem"; static int do_memcpy(int argc, char *argv[]) @@ -47,6 +45,7 @@ static int do_memcpy(int argc, char *argv[]) int mode = 0; struct stat statbuf; int ret = 0; + char *buf; if (mem_parse_options(argc, argv, "bwlqs:d:", &mode, &sourcefile, &destfile, NULL) < 0) @@ -82,12 +81,14 @@ static int do_memcpy(int argc, char *argv[]) return 1; } + buf = xmalloc(RW_BUF_SIZE); + while (count > 0) { int now, r, w, tmp; now = min((loff_t)RW_BUF_SIZE, count); - r = read(sourcefd, mem_rw_buf, now); + r = read(sourcefd, buf, now); if (r < 0) { perror("read"); goto out; @@ -99,7 +100,7 @@ static int do_memcpy(int argc, char *argv[]) tmp = 0; now = r; while (now) { - w = write(destfd, mem_rw_buf + tmp, now); + w = write(destfd, buf + tmp, now); if (w < 0) { perror("write"); goto out; @@ -123,6 +124,7 @@ static int do_memcpy(int argc, char *argv[]) } out: + free(buf); close(sourcefd); close(destfd); diff --git a/commands/memset.c b/commands/memset.c index f99bf86c04..b0770159f8 100644 --- a/commands/memset.c +++ b/commands/memset.c @@ -34,8 +34,6 @@ #include #include -extern char *mem_rw_buf; - static int do_memset(int argc, char *argv[]) { loff_t s, c, n; diff --git a/common/ratp/md.c b/common/ratp/md.c index 9ce7e99dfd..0235352030 100644 --- a/common/ratp/md.c +++ b/common/ratp/md.c @@ -59,8 +59,6 @@ struct ratp_bb_md_response { uint8_t buffer[]; } __packed; -extern char *mem_rw_buf; - static int do_ratp_mem_md(const char *filename, loff_t start, loff_t size, @@ -70,6 +68,7 @@ static int do_ratp_mem_md(const char *filename, int ret = 0; int fd; void *map; + char *buf = NULL; fd = open_and_lseek(filename, O_RWSIZE_1 | O_RDONLY, start); if (fd < 0) @@ -81,10 +80,11 @@ static int do_ratp_mem_md(const char *filename, goto out; } + buf = xmalloc(RW_BUF_SIZE); t = 0; do { now = min(size, (loff_t)RW_BUF_SIZE); - r = read(fd, mem_rw_buf, now); + r = read(fd, buf, now); if (r < 0) { ret = -errno; perror("read"); @@ -93,13 +93,14 @@ static int do_ratp_mem_md(const char *filename, if (!r) goto out; - memcpy(output + t, (uint8_t *)(mem_rw_buf), r); + memcpy(output + t, buf, r); size -= r; t += r; } while (size); out: + free(buf); close(fd); return ret; -- cgit v1.2.3 From 6f37d9efd9183ff06e65438e349ac2341d459290 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 28 Jan 2019 22:55:33 -0800 Subject: 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 Signed-off-by: Sascha Hauer --- commands/Kconfig | 17 ++++-------- commands/Makefile | 1 - commands/mem.c | 77 --------------------------------------------------- drivers/misc/Kconfig | 3 ++ drivers/misc/Makefile | 1 + drivers/misc/mem.c | 44 +++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 89 deletions(-) delete mode 100644 commands/mem.c create mode 100644 drivers/misc/mem.c (limited to 'commands') diff --git a/commands/Kconfig b/commands/Kconfig index 1de4b9d604..c14332c9d7 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 eb4796389e..358671bb5b 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 8a47e1fe1b..0000000000 --- a/commands/mem.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011 Sascha Hauer , 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 6640a70792..4c8a769c4c 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 487e4b8ba2..d4e616d51a 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 0000000000..60981a3e98 --- /dev/null +++ b/drivers/misc/mem.c @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2011 Sascha Hauer , Pengutronix + */ + +#include +#include +#include + +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); -- cgit v1.2.3 From 5c9408572406c8718a35931ecf74a5cf38632914 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 28 Jan 2019 22:55:39 -0800 Subject: devfs: Drop dev_lseek_default() Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- arch/arm/mach-mxs/ocotp.c | 1 - arch/sandbox/board/hostfile.c | 1 - commands/stddev.c | 4 ---- common/block.c | 1 - drivers/base/regmap/regmap.c | 1 - drivers/eeprom/at24.c | 1 - drivers/eeprom/at25.c | 1 - drivers/hw_random/core.c | 1 - drivers/mfd/act8846.c | 1 - drivers/mfd/lp3972.c | 1 - drivers/mfd/mc34704.c | 1 - drivers/mfd/mc9sdz60.c | 1 - drivers/mfd/stmpe-i2c.c | 1 - drivers/mfd/twl-core.c | 1 - drivers/misc/sram.c | 1 - drivers/mtd/core.c | 1 - drivers/mtd/mtdoob.c | 1 - drivers/mtd/mtdraw.c | 1 - drivers/net/e1000/eeprom.c | 2 -- drivers/net/ksz8864rmn.c | 1 - drivers/net/phy/mdio_bus.c | 1 - drivers/nvmem/core.c | 1 - drivers/video/fb.c | 1 - drivers/w1/slaves/w1_ds2431.c | 1 - drivers/w1/slaves/w1_ds2433.c | 1 - fs/devfs-core.c | 1 - fs/devfs.c | 2 -- include/driver.h | 5 ----- 28 files changed, 37 deletions(-) (limited to 'commands') diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c index 01db731166..f230d9ad89 100644 --- a/arch/arm/mach-mxs/ocotp.c +++ b/arch/arm/mach-mxs/ocotp.c @@ -174,7 +174,6 @@ free_mem: static struct cdev_operations mxs_ocotp_ops = { .read = mxs_ocotp_cdev_read, - .lseek = dev_lseek_default, }; static int mxs_ocotp_probe(struct device_d *dev) diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c index 3fc1503799..745f078d1a 100644 --- a/arch/sandbox/board/hostfile.c +++ b/arch/sandbox/board/hostfile.c @@ -67,7 +67,6 @@ static void hf_info(struct device_d *dev) static struct cdev_operations hf_fops = { .read = hf_read, .write = hf_write, - .lseek = dev_lseek_default, }; static int hf_probe(struct device_d *dev) diff --git a/commands/stddev.c b/commands/stddev.c index 4d1b6f5108..2b3d084c83 100644 --- a/commands/stddev.c +++ b/commands/stddev.c @@ -27,7 +27,6 @@ static ssize_t zero_read(struct cdev *cdev, void *buf, size_t count, loff_t offs static struct cdev_operations zeroops = { .read = zero_read, - .lseek = dev_lseek_default, }; static int zero_init(void) @@ -55,7 +54,6 @@ static ssize_t full_read(struct cdev *cdev, void *buf, size_t count, loff_t offs static struct cdev_operations fullops = { .read = full_read, - .lseek = dev_lseek_default, }; static int full_init(void) @@ -82,7 +80,6 @@ static ssize_t null_write(struct cdev *cdev, const void *buf, size_t count, loff static struct cdev_operations nullops = { .write = null_write, - .lseek = dev_lseek_default, }; static int null_init(void) @@ -110,7 +107,6 @@ static ssize_t prng_read(struct cdev *cdev, void *buf, size_t count, loff_t offs static struct cdev_operations prngops = { .read = prng_read, - .lseek = dev_lseek_default, }; static int prng_init(void) diff --git a/common/block.c b/common/block.c index 8d0de42d90..d90c98948c 100644 --- a/common/block.c +++ b/common/block.c @@ -350,7 +350,6 @@ static struct cdev_operations block_ops = { #endif .close = block_op_close, .flush = block_op_flush, - .lseek = dev_lseek_default, }; int blockdevice_register(struct block_device *blk) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 8bbc2373fc..d2f8ec70e4 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -353,7 +353,6 @@ static ssize_t regmap_cdev_write(struct cdev *cdev, const void *buf, size_t coun } static struct cdev_operations regmap_fops = { - .lseek = dev_lseek_default, .read = regmap_cdev_read, .write = regmap_cdev_write, }; diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index e79031a2d3..1fd4aeaba6 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -447,7 +447,6 @@ static int at24_probe(struct device_d *dev) at24->cdev.priv = at24; at24->cdev.dev = dev; at24->cdev.ops = &at24->fops; - at24->fops.lseek = dev_lseek_default; at24->fops.read = at24_cdev_read, at24->fops.protect = at24_cdev_protect, at24->cdev.size = chip.byte_len; diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c index a9050d6c16..1c9ef12321 100644 --- a/drivers/eeprom/at25.c +++ b/drivers/eeprom/at25.c @@ -235,7 +235,6 @@ static ssize_t at25_ee_write(struct cdev *cdev, static struct cdev_operations at25_fops = { .read = at25_ee_read, .write = at25_ee_write, - .lseek = dev_lseek_default, }; static int at25_np_to_chip(struct device_d *dev, diff --git a/drivers/hw_random/core.c b/drivers/hw_random/core.c index 1c68a379f7..ee3d5a52dd 100644 --- a/drivers/hw_random/core.c +++ b/drivers/hw_random/core.c @@ -63,7 +63,6 @@ static ssize_t rng_dev_read(struct cdev *cdev, void *buf, size_t size, static struct cdev_operations rng_chrdev_ops = { .read = rng_dev_read, - .lseek = dev_lseek_default, }; static int hwrng_register_cdev(struct hwrng *rng) diff --git a/drivers/mfd/act8846.c b/drivers/mfd/act8846.c index 53ab70f5cc..b7a64c739c 100644 --- a/drivers/mfd/act8846.c +++ b/drivers/mfd/act8846.c @@ -117,7 +117,6 @@ static ssize_t act8846_write(struct cdev *cdev, const void *_buf, size_t count, } static struct cdev_operations act8846_fops = { - .lseek = dev_lseek_default, .read = act8846_read, .write = act8846_write, }; diff --git a/drivers/mfd/lp3972.c b/drivers/mfd/lp3972.c index 42b28070ad..3ae9d1ac64 100644 --- a/drivers/mfd/lp3972.c +++ b/drivers/mfd/lp3972.c @@ -70,7 +70,6 @@ static ssize_t lp_read(struct cdev *cdev, void *_buf, size_t count, loff_t offse } static struct cdev_operations lp_fops = { - .lseek = dev_lseek_default, .read = lp_read, }; diff --git a/drivers/mfd/mc34704.c b/drivers/mfd/mc34704.c index f15f37ef6e..4aa02b74ff 100644 --- a/drivers/mfd/mc34704.c +++ b/drivers/mfd/mc34704.c @@ -100,7 +100,6 @@ static ssize_t mc34704_write(struct cdev *cdev, const void *_buf, size_t count, } static struct cdev_operations mc34704_fops = { - .lseek = dev_lseek_default, .read = mc34704_read, .write = mc34704_write, }; diff --git a/drivers/mfd/mc9sdz60.c b/drivers/mfd/mc9sdz60.c index 2cb38d9784..408d746450 100644 --- a/drivers/mfd/mc9sdz60.c +++ b/drivers/mfd/mc9sdz60.c @@ -112,7 +112,6 @@ static ssize_t mc_write(struct cdev *cdev, const void *_buf, size_t count, loff_ } static struct cdev_operations mc_fops = { - .lseek = dev_lseek_default, .read = mc_read, .write = mc_write, }; diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c index 084e4b43bb..f140f1bbc4 100644 --- a/drivers/mfd/stmpe-i2c.c +++ b/drivers/mfd/stmpe-i2c.c @@ -101,7 +101,6 @@ static ssize_t stmpe_write(struct cdev *cdev, const void *_buf, size_t count, lo } static struct cdev_operations stmpe_fops = { - .lseek = dev_lseek_default, .read = stmpe_read, .write = stmpe_write, }; diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index fb435f510f..c3240b8542 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -150,7 +150,6 @@ static ssize_t twl_write(struct cdev *cdev, const void *_buf, size_t count, } struct cdev_operations twl_fops = { - .lseek = dev_lseek_default, .read = twl_read, .write = twl_write, }; diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index 27b4c681fd..053b35150c 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -29,7 +29,6 @@ static struct cdev_operations memops = { .read = mem_read, .write = mem_write, .memmap = generic_memmap_rw, - .lseek = dev_lseek_default, }; static int sram_probe(struct device_d *dev) diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index f44c6cfc69..881b5f4864 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -462,7 +462,6 @@ static struct cdev_operations mtd_ops = { .protect = mtd_op_protect, #endif .ioctl = mtd_ioctl, - .lseek = dev_lseek_default, }; static int mtd_partition_set(struct param_d *p, void *priv) diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c index ffaf9506f3..4aef844485 100644 --- a/drivers/mtd/mtdoob.c +++ b/drivers/mtd/mtdoob.c @@ -66,7 +66,6 @@ static ssize_t mtd_op_read_oob(struct cdev *cdev, void *buf, size_t count, static struct cdev_operations mtd_ops_oob = { .read = mtd_op_read_oob, .ioctl = mtd_ioctl, - .lseek = dev_lseek_default, }; static int add_mtdoob_device(struct mtd_info *mtd, const char *devname, void **priv) diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c index 6e36dc5337..f63da7b3b2 100644 --- a/drivers/mtd/mtdraw.c +++ b/drivers/mtd/mtdraw.c @@ -291,7 +291,6 @@ static const struct cdev_operations mtd_raw_fops = { .read = mtdraw_read, .write = mtdraw_write, .erase = mtdraw_erase, - .lseek = dev_lseek_default, }; static int add_mtdraw_device(struct mtd_info *mtd, const char *devname, void **priv) diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c index c0f2db552a..01f6addbc3 100644 --- a/drivers/net/e1000/eeprom.c +++ b/drivers/net/e1000/eeprom.c @@ -1325,7 +1325,6 @@ exit: static struct cdev_operations e1000_invm_ops = { .read = e1000_invm_cdev_read, .write = e1000_invm_cdev_write, - .lseek = dev_lseek_default, }; static ssize_t e1000_eeprom_cdev_read(struct cdev *cdev, void *buf, @@ -1350,7 +1349,6 @@ static ssize_t e1000_eeprom_cdev_read(struct cdev *cdev, void *buf, static struct cdev_operations e1000_eeprom_ops = { .read = e1000_eeprom_cdev_read, - .lseek = dev_lseek_default, }; static int e1000_mtd_read_or_write(bool read, diff --git a/drivers/net/ksz8864rmn.c b/drivers/net/ksz8864rmn.c index 4a19dd8734..85063ff0d8 100644 --- a/drivers/net/ksz8864rmn.c +++ b/drivers/net/ksz8864rmn.c @@ -113,7 +113,6 @@ static ssize_t micel_switch_write(struct cdev *cdev, const void *_buf, size_t co static struct cdev_operations micrel_switch_ops = { .read = micel_switch_read, .write = micel_switch_write, - .lseek = dev_lseek_default, }; static int micrel_switch_probe(struct device_d *dev) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index e1dd8f0ae3..3480e2ffb4 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -392,7 +392,6 @@ static ssize_t phydev_write(struct cdev *cdev, const void *_buf, size_t count, l static struct cdev_operations phydev_ops = { .read = phydev_read, .write = phydev_write, - .lseek = dev_lseek_default, }; static void of_set_phy_supported(struct phy_device *phydev) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 9fd599095c..6cf98f62af 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -85,7 +85,6 @@ static ssize_t nvmem_cdev_write(struct cdev *cdev, const void *buf, size_t count static struct cdev_operations nvmem_chrdev_ops = { .read = nvmem_cdev_read, .write = nvmem_cdev_write, - .lseek = dev_lseek_default, }; static int nvmem_register_cdev(struct nvmem_device *nvmem, const char *name) diff --git a/drivers/video/fb.c b/drivers/video/fb.c index 72f33a6db6..2d82bc01fa 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -228,7 +228,6 @@ static struct cdev_operations fb_ops = { .read = mem_read, .write = mem_write, .memmap = generic_memmap_rw, - .lseek = dev_lseek_default, .ioctl = fb_ioctl, .close = fb_close, .flush = fb_op_flush, diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c index 13691d7bab..6446f4ba05 100644 --- a/drivers/w1/slaves/w1_ds2431.c +++ b/drivers/w1/slaves/w1_ds2431.c @@ -260,7 +260,6 @@ out_up: static struct cdev_operations ds2431_ops = { .read = ds2431_cdev_read, .write = ds2431_cdev_write, - .lseek = dev_lseek_default, }; static int ds2431_probe(struct w1_device *dev) diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c index f521a46a75..b24fb5b3b5 100644 --- a/drivers/w1/slaves/w1_ds2433.c +++ b/drivers/w1/slaves/w1_ds2433.c @@ -159,7 +159,6 @@ out_up: static struct cdev_operations ds2433_ops = { .read = ds2433_cdev_read, .write = ds2433_cdev_write, - .lseek = dev_lseek_default, }; static int ds2433_cdev_create(struct w1_device *dev, int size, int id) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index f017e1c55d..522ef91752 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -459,7 +459,6 @@ static const struct cdev_operations loop_ops = { .read = loop_read, .write = loop_write, .memmap = generic_memmap_rw, - .lseek = dev_lseek_default, }; struct cdev *cdev_create_loop(const char *path, ulong flags, loff_t offset) diff --git a/fs/devfs.c b/fs/devfs.c index 6acbbd7adb..5599f39e8c 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -66,8 +66,6 @@ static loff_t devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos) ret = cdev->ops->lseek(cdev, pos + cdev->offset); if (ret < 0) return ret; - } else { - return -ENOSYS; } return pos; diff --git a/include/driver.h b/include/driver.h index 7da184d3ab..bcb31afdc2 100644 --- a/include/driver.h +++ b/include/driver.h @@ -360,11 +360,6 @@ int dummy_probe(struct device_d *); int generic_memmap_ro(struct cdev *dev, void **map, int flags); int generic_memmap_rw(struct cdev *dev, void **map, int flags); -static inline loff_t dev_lseek_default(struct cdev *cdev, loff_t ofs) -{ - return ofs; -} - static inline int dev_open_default(struct device_d *dev, struct filep *f) { return 0; -- cgit v1.2.3