9
0
Fork 0
Commit Graph

34 Commits

Author SHA1 Message Date
Sascha Hauer 7c6c61fe8e treewide: Use dev_add_param_int_ro where possible
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-04-11 11:48:35 +02:00
Sascha Hauer c26ef8231f mtd: Add parameter to allow erasing bad blocks
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>
2013-03-04 11:00:33 +01:00
Sascha Hauer 62ee96bd3b Merge branch 'for-next/mtd'
Conflicts:
	arch/arm/configs/eukrea_cpuimx27_defconfig
	drivers/mtd/core.c
2013-03-04 09:21:49 +01:00
Sascha Hauer 22d747e264 mtd: nand: do not write empty pages
Do not write pages which only contain 0xff. UBI expects pages which
seem empty to be writable. This got lost with:

| commit 3139c3e9a6
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date:   Thu Nov 29 11:16:40 2012 +0100
|
|    mtd core: call driver write function with complete buffer
|
|    mtd->write is supposed to loop around pages internally, no need
|    to do this in mtd_write. This fixes a huge write performance drop
|    with the m25p80 driver when it was converted to a mtd driver recently.
|    Since mtd->writesize is 1 for this driver mtd_write ended up doing
|    single byte writes on the flash.

Introduce mtd_all_ff as a global function since UBI currently has its own
implementation.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-21 08:58:45 +01:00
Sascha Hauer 1bd90ff5a1 mtd: implement mtd_lock and mtd_unlock
Needed for NOR flashes.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-14 10:44:41 +01:00
Sascha Hauer bdd58b17eb mtd: Use mtd_* functions where appropriate
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>
2013-02-14 10:38:23 +01:00
Sascha Hauer 7b7cf936cb mtd: Add mtd_* functions
The Kernel has mtd_read, mtd_write, mtd_erase and mtd_block_markbad.
Add these functions to barebox aswell to make future mtd synchronizations
with the kernel easier.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-14 10:31:39 +01:00
Sascha Hauer b600cb936e mtd: rename mtd file operations callback functions
These are currently named mtd_read/write/erase. Functions with
the same name exist as global functions in the kernel. Rename
them to mtd_op_* to avoid name clashes with future mtd updates.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-02-14 10:22:17 +01:00
Alexander Aring 65fd4afcf2 mtd-core: fix compiler warning
Got this compile warning if MTD_WRITE support isn't set.

drivers/mtd/core.c: In function 'mtd_ioctl':
drivers/mtd/core.c:117:26: warning: unused variable 'ei' [-Wunused-variable]

Add a #ifdef to declaration of variable 'ei' to solve it.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2013-01-17 08:13:44 +01:00
Wolfram Sang 8c98a5dfb7 devfs & mtd: add MEMERASE ioctl support
To make that, we need to shift mtd_erase before mtd_ioctl.
ubi-utils need that, especially ubiformat.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-12-19 10:31:23 +01:00
Sascha Hauer 1a9e93cc81 drivers/base: fix corrupt device tree
dev_add_child is a very unsafe function. If called multiple times
it allows setting the same device to different parents thus corrupting
the siblings list. This happens regularly since:

| commit c2e568d19c
| Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
| Date:   Sat Nov 3 16:11:05 2012 +0100
|
|    bus: add bus device
|
|    automatically add it as parent of any bus device if none already specified
|
|    we have now a nice output per bus

If for example a FATfs is mounted this nice output per bus often ends with:

>     `---- fat0
>     `---- 0
>          `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL>
>          `---- sram00
>               `---- 0x00000000-0xffffffffffffffff: /dev/<NULL>
>               `---- 0x00000000-0xffffffffffffffff: /dev/<NULL>
>               unable to handle NULL pointer dereference at address 0x0000000c
> pc : [<87f08a20>]    lr : [<87f08a04>]
> sp : 86eff8c0  ip : 87f3fbde  fp : ffffffff
> r10: ffffffff  r9 : 00000000  r8 : 00000003
> r7 : 86f075b8  r6 : 00000002  r5 : ffffffec  r4 : 86f07544
> r3 : 00000000  r2 : 43f900b4  r1 : 00000020  r0 : 00000005
> Flags: Nzcv  IRQs off  FIQs off  Mode SVC_32
> [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130)
>
> [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c)
> [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14)
> [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38)
> [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60)

This patch fixes this by adding a device to its parents children list in
register_device so that dev_add_child is no longer needed. This function
is removed from the tree. Now callers of register_device have to clearly
set the parent *before* registering a device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Jan Lübbe <jlu@pengutronix.de>
2012-12-12 15:04:27 +01:00
Sascha Hauer 3139c3e9a6 mtd core: call driver write function with complete buffer
mtd->write is supposed to loop around pages internally, no need
to do this in mtd_write. This fixes a huge write performance drop
with the m25p80 driver when it was converted to a mtd driver recently.
Since mtd->writesize is 1 for this driver mtd_write ended up doing
single byte writes on the flash.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-12-07 09:22:15 +01:00
Jean-Christophe PLAGNIOL-VILLARD 4104dd9173 mtd: introduce mtd_block_isbad
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>
2012-11-03 23:20:59 +01:00
Jean-Christophe PLAGNIOL-VILLARD 006538e7c2 mtd: add parent support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-17 20:16:58 +02:00
Jean-Christophe PLAGNIOL-VILLARD 28d294de70 mtd: register device a pure device
as we do not need to probe them and they have no driver or bus attached

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-16 22:46:56 +02:00
Alexander Aring 461e7d7aef mtd-core: add writesize in MEMGETINFO ioctl
Add writesize in MEMGETINFO ioctl.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-10-13 14:30:50 +02:00
Jean-Christophe PLAGNIOL-VILLARD 3c5327e660 switch all platform_bus device/driver registering to platform_driver/device_register
now register_driver and register_device are for bus only usage.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-10-04 15:19:12 +02:00
Jan Luebbe d17aed1a07 mtd: use correct format specifier
For the size_t type the format specifier %zu or %zx must be used.
See Documentation/printk-formats.txt in the kernel for details.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-07 12:23:26 +02:00
Alexander Aring 83f311a9bb mtd: add private data to mtddev-hook
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>
2012-09-03 11:06:01 +02:00
Alexander Aring 06e5a6a5ca mtd: fix compiler warnings
Fix some compiler warnings.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-09-03 11:06:01 +02:00
Sascha Hauer 3e503822c7 use loff_t for file offsets
This is a first step for 64bit file support: Make the file sizes/offsets
64bit.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:24 +02:00
Sascha Hauer e71c343668 mtd: fix arguments to bad block ioctls
In the Kernel the mtd ioctls expect a pointer to the offset, whereas
barebox interprets the pointer itself as an offset. Since we want
to add 64bit support for file sizes a pointer may not be sufficient,
so align with the kernel and convert it to a pointer to the offset.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:16 +02:00
Sascha Hauer abe4560c8a Use DEVICE_ID_DYNAMIC where applicable
We now have DEVICE_ID_DYNAMIC for dynamic allocation of device ids,
Use it where applicable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-16 09:43:02 +02:00
Sascha Hauer 6838fedc76 mtd: fix compiler warning
Fixes:

drivers/mtd/core.c: In function 'mtd_ioctl':
drivers/mtd/core.c:122:24: warning: unused variable 'ecc' [-Wunused-variable]

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-05 08:48:13 +02:00
Sascha Hauer 8742816771 Merge branch 'pu/jean-codesize' into next 2012-01-13 09:33:36 +01:00
Jean-Christophe PLAGNIOL-VILLARD 971d164f62 param: add config to disable it
this will allow to save 992 Bytes for TI xlaoder or AT91 bootstrap

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-01-11 21:22:34 +08:00
Alexander Aring 364c3aadfd ioctl: add support for ECCGETSTATS and MEMGETREGIONINFO
Support added for ioctl of ECCGETSTATS and MEMGETREGIONINFO.

Fix default handling in core.c to return -EINVAL, if request
was unknown.

Signed-off-by: Alexander Aring <a.aring@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-01-06 09:49:37 +01:00
Jean-Christophe PLAGNIOL-VILLARD 7caf8009cc mtd/core.c: fix MTDPGALG
introduced in commit f76ad819e4
drivers/mtd: cosmetic changes

it's supposed to the invert of the writesize - 1

Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-01-02 11:47:49 +01:00
Robert Jarzmik 6473b28065 drivers/mtd: split mtd mtdoob devices
Split /dev/mtd and /dev/mtdoob devices.
Remove from mtd structure the mtdoob character device.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00
Robert Jarzmik c6c880ecdb drivers/mtd: add mtd core hooks
Add hooks for spinoff MTD drivers (mtdoob, mtdraw, ...).

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00
Robert Jarzmik d29b112f68 drivers/mtd: fix core multiple MTD registrations
If multiple MTD devices were registered, an exception
occured, as they all wanted id 0. Let the driver code choose
the device number dynamically.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00
Robert Jarzmik 88ce7ef769 drivers/mtd: transfer NAND notions to MTD core
Change NAND_WRITE into MTD_WRITE.
Change "page_shift" references in the core, which are purely
NAND, into mtd->writesize which is MTD generic.
Rename all "info" (struct mtd_info) into "mtd".

Also provide a parameter to add_mtd_device() so that legacy
nand devices still appear as nand<N>.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00
Robert Jarzmik f76ad819e4 drivers/mtd: cosmetic changes
Fix whitespace, replace all debug() by dev_dbg(), and fix
line length to 80 characters.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00
Robert Jarzmik 8ccde79470 drivers/mtd: move nand.c into core.c
Move nand core into the global MTD core.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-22 10:11:11 +01:00