9
0
Fork 0
Commit Graph

393 Commits

Author SHA1 Message Date
Zahari Doychev 433135c85c drivers/mtd: fix NULL pointer dereference in partition lock/unlock
Some mtd device does not support lock and unlock functions. Adding this check
avoids crashing when mtd_part_lock/unlock are called for such devices.

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-07-09 07:31:01 +02:00
Renaud Barbier c8890e057a mtd: delete partition erase size initialisation
Delete the partition erase size initialisation to let the code
that follows determine the biggest partition erase size.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-07-03 09:00:06 +02:00
Herve Codina 3ee907d89e mtd: use long long dev param for size
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-13 06:27:34 +02:00
Antony Pavlov 8e89bc594a treewide: remove address of the Free Software Foundation
The FSF address has changed; The FSF site says that
address is

  Free Software Foundation
  51 Franklin Street, Fifth Floor
  Boston, MA 02110-1301
  USA

(see http://www.fsf.org/about/contact/)

Instead of updating it each time the address changes,
just drop it completely treewide.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-11 08:35:25 +02:00
Sascha Hauer 70579ca94f mtd: partition: implement lock/unlock
CFI Nor flashes need lock/unlock which is not implemented for partitions.
Fix this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-10 13:55:23 +02:00
Sascha Hauer 02fed023e1 mtd: partition: Fix multi eraseregion chips
The current code counts the eraseregions a new partition spans and
sets the partitions number of eraseregions accordingly, but the code
forgets to allocate and fill in the eraseregions for the partition
mtd device. This makes the erase operation crash with a NULL pointer
exception.
This patch fixes this with the same approach the kernel uses: Set
the number of eraseregions to 1 unconditionally and the eraseregion
size to the maximum of the eraseregions found in the partition.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-10 13:52:03 +02:00
Herve Codina d2d058365c mtd: fix mtd erasesize
Set mtd erasize using max erasesize from erase regions

Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-10 08:38:39 +02:00
Herve Codina 4d032fd6fa mtd: Fix writesize parameter value
Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-06-10 08:38:21 +02:00
Sascha Hauer 6331e58a2c Merge branch 'for-next/misc'
Conflicts:
	commands/devinfo.c
2014-06-04 21:03:36 +02:00
Sascha Hauer 2d13b034a2 Merge branch 'for-next/doc' 2014-06-04 21:01:16 +02:00
Sascha Hauer 50147cd34d mtd: nand: mxs: Fix 2k nand with oob size of 224 bytes
The mxs nand driver has a calculation for the ecc strength.
This calculation was not used for some common nands and it
was assumed that 2k page nands always have a ecc strength
of 8. This is not true since there are devices with 224 bytes
of oob instread of 64 bytes. These allow for a greater ecc
strength. Since the kernel relies on the calculation and
we have to be consistent with the kernel use the calculcation
in barebox aswell and just remove our assumptions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-20 07:36:03 +02:00
Sascha Hauer 49432aecf1 mtd: m25p80: update Micron IDs
Update Micron IDs from Linux-3.15-rc5. Skip n25q512a for now
since it needs flag status polling.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 14:14:13 +02:00
Sascha Hauer dc611863be mtd: partitions: only add write functions when mtd write support is enabled
Makes the binary a few bytes smaller.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-15 13:59:49 +02:00
Holger Schurig f1f532084a commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:

* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
  options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
  is listed by character in this (short) option string (the long
  description is in the long help text, as before)
* help texts have been reworked, to make them
  - sometimes smaller
  - sometimes describe the options better
  - more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
  macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
  all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
  is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
  errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
  compiled long help texts
* 'help -v' gives a list of commands with their short description, this
  is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-14 10:03:43 +02:00
Holger Schurig ab23d0bb3f commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.

The old output format (plus grouping) is now available with 'help -v'.

Example:

   Information commands:
     ?, devinfo, help, iomem, meminfo, version
   Boot commands:
     boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
   ...

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-14 07:59:55 +02:00
Sascha Hauer 9f8aab600d drop CONFIG_PARTITION_NEED_MTD
With CONFIG_PARTITION_NEED_MTD enabled we use mtd rather than devfs
directly to create partitions on mtd devices. Since:

| commit b32cd8df87
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date:   Wed Apr 9 15:49:32 2014 +0200
|
|     mtd: nand: bb: use mtd api directly
|
|     The devfs layer just adds an addition indirection between mtd
|     and the bb devices with no purpose. Drop it.
|
|     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

The bad block aware device creation doesn't work if this option
is disabled. With this we remove CONFIG_PARTITION_NEED_MTD and always
use mtd partitions on mtd devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 09:19:46 +02:00
Sascha Hauer bf1d71d5e1 Merge branch 'for-next/misc' 2014-05-05 13:32:37 +02:00
Sascha Hauer 2274c6ea77 Merge branch 'for-next/env' 2014-05-05 11:05:50 +02:00
Sascha Hauer eecac38c2c mtd: nand-mxs: Return bitflips
The read_page hook shall return the number of bitflips. Implement
that.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-29 16:12:33 +02:00
Sascha Hauer 3fafc8e5c7 mtd: nand-bb: use list_for_each_entry_safe
We need list_for_each_entry_safe in dev_remove_bb_dev since the
list entries are removed during iteration over the list.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Alexander Aring <alex.aring@gmail.com>
2014-04-29 08:05:17 +02:00
Sascha Hauer 1a8800458b mtd: nand: create bb devices automatically
When a mtd device can have bad blocks we want to create a
bb device, so do this automatically. This allows us to
drop bb device creation from the environment.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-28 11:45:09 +02:00
Sascha Hauer 33d4f7cb3d mtd: refactor bb device creation
This refactors the code so that we get a mtd_add_bb which can
be used to create a bb dev on a mtd_info.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-28 11:43:09 +02:00
Sascha Hauer b32cd8df87 mtd: nand: bb: use mtd api directly
The devfs layer just adds an addition indirection between mtd
and the bb devices with no purpose. Drop it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-28 11:41:15 +02:00
Alexander Shiyan 54a8d12cd2 mtd: nand: bbt: Remove unused variable
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-23 14:01:45 +02:00
Alexander Shiyan 40bfcc42c0 mtd: partition: Remove unused variable
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-23 14:01:45 +02:00
Sascha Hauer 149e9d8121 Merge branch 'for-next/mtd' 2014-04-04 10:06:22 +02:00
Sascha Hauer 245bc10ca5 Merge branch 'for-next/misc' 2014-04-04 10:06:22 +02:00
Sascha Hauer 5dcb117e82 mtd: omap gpmc: Turn debug message into dev_dbg
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-04-04 08:40:00 +02:00
Philipp Zabel 4449fac898 mtd: ubi: avoid NULL pointer dereference in ubi_get_device
If the ubidetach command is given a number that passes the range check
in ubi_detach_mtd_dev, but at which index the ubi_devices array contains
a NULL pointer, ubi_get_device tries to dereference this NULL pointer
to increment the ubi device reference count.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-03-23 09:46:47 +01:00
Dmitry Lavnikevich 3676454f5c nand: mxs: Fix for calculating ecc strength on some types of NAND flash
Was tested on NAND with {writesize=4096, oobsize=224} and
{writesize=2048, oobsize=64}.

This patch will not break any NAND that was working
before. Implemented calculation way may be used for other NAND chips
with writesize == 2048 but oobsize != 64.

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>
2014-03-12 21:26:37 +01:00
Dmitry Lavnikevich c15680099e nand: mxs: Check for up to 4 NAND chips
Since i.MX6 has only one R/B actual pin, if there are several R/B
signals (from different NAND chips) they must be connected to this
pin.

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>
2014-03-12 21:26:37 +01:00
Dmitry Lavnikevich 95147b1d95 ubi: Fix for creating ubi volumes with 64bit size
Since MTD is already supports >= 4GB device sizes it is better to
allow ubi valumes also be created of larger sizes.

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>
2014-03-12 21:26:37 +01:00
Dmitry Lavnikevich 76a88c0227 mtd: Support for 4GB partitions
This patch implements correct way of creating partitions on mtd
devices with size >= 4GB.

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>
2014-03-12 21:26:37 +01:00
Dmitry Lavnikevich 1ee640765a mtd: Update internal API to support 64-bit device size
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>
2014-03-12 21:26:37 +01:00
Sascha Hauer cf1b29a850 Merge branch 'for-next/ubi'
Conflicts:
	drivers/mtd/ubi/cdev.c
2014-03-07 09:26:35 +01:00
Sascha Hauer 74213ed9a7 Merge branch 'for-next/partitionhelper'
Conflicts:
	fs/devfs-core.c
2014-03-07 09:25:53 +01:00
Sascha Hauer e358922a74 Merge branch 'for-next/mtd'
Conflicts:
	drivers/mtd/core.c
	net/eth.c
2014-03-07 09:25:18 +01:00
Sascha Hauer 98615784a6 Merge branch 'for-next/modalias' 2014-03-07 09:25:12 +01:00
Sascha Hauer a8a08f88cc Merge branch 'for-next/misc'
Conflicts:
	common/environment.c
2014-03-07 09:25:09 +01:00
Herve Codina ad22ad38ea mtd: nand: atmel pmecc: disable subpage writes
I am using an sam5d35 and its pmecc nand ecc controller.

In barebox, using similar atmel_nand.c the system crashes.

The problem was a call to chip->ecc.hwctl from nand_write_subpage_hwecc
(nand_base.c) when we write a sub page.

chip->ecc.hwctl function is not set when we are using PMECC controller.

As a workaround, i set NAND_NO_SUBPAGE_WRITE for PMECC controller in
order to disable sub page access in nand_write_page.

I think we can have the same problem in Linux. I do not performed
subpage nand writes from Linux but i made the following patch according
to my Barebox defect.

Signed-off-by: Herve Codina <Herve.CODINA@celad.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-03-03 08:56:28 +01:00
Sascha Hauer f957d0a09c mtd: ubi: rework logging
By default UBI is very verbose. Decrease the verbosity, turn
printf messages into ubi_ messages and add device parameters
for the values which are not printed anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-28 11:23:56 +01:00
Philippe Rétornaz fb7836ebf6 cfi_flash: fix NULL pointer dereference
We need to setup the info->dev pointer before flash_get_size() since it
might use it for dev_dbg().
This fix a crash on boot when debug output is enabled.

Signed-off-by: Philippe Rétornaz <philippe.retornaz@epfl.ch>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-28 09:03:04 +01:00
Uwe Kleine-König 14d0355d7c mtd/nand: constify filename parameter
The string pointed to isn't modified, so declare it as const.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-28 08:20:26 +01:00
Sascha Hauer d5e38fc913 mtd: mtdoob: Do not create for partitions
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:19 +01:00
Sascha Hauer 05e4864f6b mtd: mtdraw: Do not create for partitions and devices without oob
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00
Sascha Hauer 9c66af7b0e ubi: register ubi devices and volumes as devices
struct ubi_device and struct ubi_volume have devices attached
to them. Register them to make them part of the barebox device
hierarchy.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00
Sascha Hauer 0c76b7e377 mtd: register mtd partitions as real mtd devices
So far mtd partitions were mtd devices, but these were not registered.
This patch changes this. mtd partitions are now registered like real
mtd devices. This makes them part of the device hierarchy.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00
Sascha Hauer 08f007c897 mtd: partition: make the mtd device the parent of the partition
Parent of a partition should be the parent mtd device, not its
parent.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00
Sascha Hauer e25cabf6a3 mtd: partition: only copy selected fields to partition
struct mtd_info contains members which should not be copied
to the new partition, like for example the class_dev, so
only copy selected members of struct mtd_info to the partition.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00
Sascha Hauer 6f0a7d82a1 mtd: Only call of_parse_partitions when the mtd has a parent
mtd->parent is optional so we can't derefence mtd->parent->device_node
without checking mtd->parent.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-02-26 08:33:18 +01:00