summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdraw.c
Commit message (Collapse)AuthorAgeFilesLines
* devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-1/+0
| | | | | | | | | | | | | | | | | | | | | 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 <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: fix wrong alignment checkSascha Hauer2018-09-251-1/+1
| | | | | | | The write offset must be raw page size aligned on entry, not page size aligned. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: replace "block" with "page"Sascha Hauer2018-09-251-19/+19
| | | | | | | When the code says "block" it actually means "page" as this is what the code handles. Rename the functions and variable names accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: fail when writing failsSascha Hauer2018-09-241-10/+7
| | | | | | | | | When writing a block fails then fail the whole write process. There's no point in returning the written bytes so far as this would only indicate the caller to write the remaining bytes again which would then fail. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: add raw page size to private dataSascha Hauer2018-09-241-20/+20
| | | | | | | The raw page size is used many times in the driver, so add a variable to the private data instead of calculating it each time again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: pass mtdraw aroundSascha Hauer2018-09-211-17/+17
| | | | | | | Pass mtdraw around internally instead of mtd. mtd can be accessed easily from mtdraw, so we can also drop to_mtd(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: do not write empty buffersSascha Hauer2018-09-211-0/+3
| | | | | | | When a page is completely 0xff then do not write it since users expect pages to be writable when they are empty. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: use dev_* for printingSascha Hauer2018-09-211-2/+4
| | | | | | | We have a struct device_d *, so use dev_* for printing instead of printf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: Simplify error pathSascha Hauer2018-09-211-9/+7
| | | | | | | We do not need a printf when writing fails, it's the callers job to report this. Remove printf and simplify the error path a bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-2/+2
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: only build mtdraw_raw_to_mtd_offset when write support is enabledLucas Stach2017-05-171-5/+5
| | | | | | | | | mtdraw_raw_to_mtd_offset() is only used from mtdraw_erase(), so will only be referenced when MTD write support is enabled. This fixes a harmless warning. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: fix mtdraw_erase stub signatureLucas Stach2016-06-241-1/+1
| | | | | | | | | Commit 81737c1d436a (mtd: Fix erasing of devices >4GiB) changed the prototype of the erase function, but fogot to fix up the stub function used when no MTD write support is built in. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-1/+1
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-091-1/+1
| | | | | | | | | When a device >4GiB is erased, not only the offset can be bigger than 4GiB, but also the size. This happens with the simplest command to erase a device: erase /dev/nand0. Make the size argument a 64bit type to make this work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Fix mtdraw for Nand > 4GiBSascha Hauer2016-02-091-20/+33
| | | | | | | | The mtdraw code has some casts to avoid 64bit divisions. For Chips >4GiB using 64bit types become necessary, so use them and to the necessary 64bit math. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Make devname argument to add_mtd_device constSascha Hauer2015-06-291-1/+1
| | | | | | | add_mtd_device duplicates the string where necessary, so make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Update internal API to support 64-bit device sizeDmitry Lavnikevich2014-03-121-1/+1
| | | | | | | | | | | | | | | | | | | MTD internal API presently uses 32-bit values to represent device size. This patch updates them to 64-bits but leaves the external API unchanged. In general, changing from 32-bit to 64-bit values cause little or no changes to the majority of the code with the following exceptions: - printk message formats; - division and modulus of 64-bit values (mtd_div_by_wb, mtd_div_by_eb may be used in some of such cases). Was tested on phyFLEX i.MX6. Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com> Signed-off-by: Grigory Milev <g.milev@sam-solutions.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: Do not create for partitions and devices without oobSascha Hauer2014-02-261-0/+6
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: mtdraw: drop ioctl callback for mtdraw deviceSascha Hauer2013-12-021-1/+0
| | | | | | | | | Do not call mtd_ioctl for mtdraw devices. mtd_ioctl will derefence the priv pointer to a struct mtd_info whereas with mtdraw devices it will be a struct mtdraw pointer. We do not need ioctls for mtdraw devices, so drop it instead of fixing it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: raw: rename raw deviceSascha Hauer2013-10-291-1/+1
| | | | | | | The name of the raw device is mtdraw<num> which is inconsistent to other mtd devices which are named mtd<num>.<partname>. Rename it to mtd<num>.raw. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: introduce mtd_read_oob and mtd_write_oobSascha Hauer2013-07-221-3/+3
| | | | | | Directly copied from the Kernel as of 3.11-rc1 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: rename MTD_OOB_* to MTD_OPS_*Sascha Hauer2013-07-221-2/+2
| | | | | | To sync with the Linux kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtdraw: fix oob read and writeEric Bénard2013-04-121-0/+2
| | | | | | | | | | | | actually ops.ooboffs is not defaulted so when its value gets added to chip->oob_poi in nand_fill_oob or nand_transfer_oob the respective memcpy is using a wrong address. With this patch, both md -s /dev/nandraw0 and cp xyz /dev/nandraw0.sb are working fine on an i.MX28 target (instead of crashing the board). Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Add parameter to allow erasing bad blocksSascha Hauer2013-03-041-1/+5
| | | | | | | | | | | | While erasing bad blocks is a potentially dangerous operation it is sometimes needed during development or when some foreign code has touched the flash. This patch adds a device parameter 'erasebad' to allow erasing bad blocks. Since this is not wanted during production this is behind a Kconfig option. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Use mtd_* functions where appropriateSascha Hauer2013-02-141-1/+1
| | | | | | | | Instead of dereferencing struct mtd_info members directly use the wrapper functions which have an additional check if the callback exists if it is optional, like mark_bad or is_bad. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2012-11-161-1/+1
|\ | | | | | | | | Conflicts: arch/arm/configs/at91sam9x5ek_defconfig
| * mtd: introduce mtd_block_isbadJean-Christophe PLAGNIOL-VILLARD2012-11-031-1/+1
| | | | | | | | | | | | | | | | this allow to do not provide block_isbad at mtd driver level as example spi flash Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: fix mtdraw_write/mtdraw_erase argumentsSascha Hauer2012-10-261-2/+2
|/ | | | | | | For the !CONFIG_MTD_WRITE case they still have ulong as offset argument. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd mtdraw: fix fixing partial page readSascha Hauer2012-09-201-1/+1
| | | | | | | | | | | | | | | toread is unitialized. We have to use count instead. | commit 992c291e9561381cf86d4a7fc9271c2b60fea0c1 | Author: Sascha Hauer <s.hauer@pengutronix.de> | Date: Sat Sep 15 16:54:47 2012 +0200 | | mtd mtdraw: Fix partial page read | | When reading parts of a page we have to limit the maximum bytes copied | to the remaining bytes of a page. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd mtdraw: Fix partial page readSascha Hauer2012-09-161-1/+2
| | | | | | | | When reading parts of a page we have to limit the maximum bytes copied to the remaining bytes of a page. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
* mtd/mtdraw: fix format specifier for ssize_tJan Luebbe2012-09-071-1/+1
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: add private data to mtddev-hookAlexander Aring2012-09-031-1/+14
| | | | | | | | | The mtdoob and mtdraw device don't clean up correctly. Added a private data element to hold allocated memory. Fix remove of mtdoob and mtdraw device. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: fix compiler warningsAlexander Aring2012-09-031-2/+2
| | | | | | | Fix some compiler warnings. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* use loff_t for file offsetsSascha Hauer2012-06-301-3/+6
| | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/mtd: fix mtdraw write supportRobert Jarzmik2012-01-271-2/+4
| | | | | | | | | | | When unaligned writes are used, typically doing a cp file /dev/mtdraw0.foo, the alignement correction code was incorrectly handling such cases, and didn't return the expected number of written bytes. This was tested on a 528 block size. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/mtd: add the mtdraw device (data+oob)Robert Jarzmik2011-12-221-0/+303
Add a device to read and write to MTD data and oob (/dev/mtdraw<N>). The device is constrained in a separate source file, so that further improvement of commands (such as nandwrite) could make it useless, and easy to remove. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>