10 Jan, 2012

40 commits

  • Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • This patch is part of a patch-set which changes the MTD interface
    from 'mtd->func()' form to 'mtd_func()' form. We need this because
    we want to add common code to to all drivers in the mtd core level,
    which is impossible with the current interface when MTD clients
    call driver functions like 'read()' or 'write()' directly.

    At this point we just introduce a new inline wrapper function, but
    later some of them are expected to gain more code. E.g., the input
    parameters check should be moved to the wrappers rather than be
    duplicated at many drivers.

    This particular patch introduced the 'mtd_erase()' interface. The
    following patches add all the other interfaces one by one.

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • We are going to re-work the MTD interface and change 'mtd->write()' to
    'mtd_write()', 'mtd->read()' to 'mtd_read()' and so forth for all functions
    in the 'struct mtd_info' structure.

    However, mtdchar.c has its own 'mtd_read()', 'mtd_write()', etc functions
    which collide with our changes. This patch renames these functions
    to 'mtdchar_read()', 'mtdchar_write()', etc.

    Additionally, to make the 'mtdchar.c' file look consistent, rename
    similarly all the other functions starting with 'mtd_'.

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • We are going to re-work the MTD interface and change 'mtd->write()' to
    'mtd_write()', 'mtd->read()' to 'mtd_read()' and so forth for all functions
    in the 'struct mtd_info' structure.

    However, logfs has its own 'mtd_read()', 'mtd_write()', etc functions
    which collide with our changes. This patch renames these logfs functions
    to 'logfs_mtd_read()', 'logfs_mtd_write()', etc.

    Additionally, to make the 'fs/logfs/dev_mtd.c' file look consistent, rename
    similarly all the other functions starting with 'mtd_'.

    Cc: Jörn Engel
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • We allocate the "mtd" structure using kzalloc which means we do not have
    to initialize unused MTD function pointers to NULL, since it is safe to
    assume in Linux that NULL contains all zeroes.

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • This patch fixes the following build failure:
    In file included from include/linux/mtd/qinfo.h:4:0,
    from include/linux/mtd/pfow.h:7,
    from drivers/mtd/lpddr/lpddr_cmds.c:27:
    include/linux/mtd/map.h: In function 'inline_map_read':
    include/linux/mtd/map.h:409:3: error: implicit declaration of function 'BUILD_BUG_ON' [-Werror=implicit-function-declaration]

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • Reimplement a call to devm_request_mem_region followed by a call to ioremap
    or ioremap_nocache by a call to devm_request_and_ioremap.

    The semantic patch that makes this transformation is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @nm@
    expression myname;
    identifier i;
    @@

    struct platform_driver i = { .driver = { .name = myname } };

    @@
    expression dev,res,size;
    expression nm.myname;
    @@

    -if (!devm_request_mem_region(dev, res->start, size,
    - \(res->name\|dev_name(dev)\|myname\))) {
    - ...
    - return ...;
    -}
    ... when != res->start
    (
    -devm_ioremap(dev,res->start,size)
    +devm_request_and_ioremap(dev,res)
    |
    -devm_ioremap_nocache(dev,res->start,size)
    +devm_request_and_ioremap(dev,res)
    )
    ... when any
    when != res->start
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Julia Lawall
     
  • Data allocated with devm_ioremap or devm_ioremap_nocache should not be
    freed using iounmap, because doing so causes a dangling pointer, and a
    subsequent double free.

    The semantic match that finds this problem is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @r@
    expression x;
    @@
    (
    x = devm_ioremap(...)
    |
    x = devm_ioremap_nocache(...)
    )

    @@
    expression r.x;
    @@
    * iounmap(x)
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Julia Lawall
     
  • Add device tree bindings so that the gpio-nand driver may be
    instantiated from the device tree. This also allows the partitions
    to be specified in the device tree.

    v7: - restore runtime device tree/non device tree detection
    v6: - convert to mtd_device_parse_register()
    v5: - fold dt config helpers into a single gpio_nand_of_get_config()
    v4: - get io sync address from gpio-control-nand,io-sync-reg
    property rather than a resource
    - clarified a few details in the binding
    v3: - remove redundant cast and a couple of whitespace/naming
    changes
    v2: - add CONFIG_OF guards for non-dt platforms
    - compatible becomes gpio-control-nand
    - clarify some binding details

    Signed-off-by: Jamie Iles
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jamie Iles
     
  • Only use the values from the image tag if it is valid. Always create
    the CFE, NVRAM and linux partitions, to allow flashing a new image even
    if the old is invalid without overwriting CFE or NVRAM.

    Signed-off-by: Jonas Gorski
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • All CRC32 fields are 32 bit integers, so define them as such to prevent
    unnecessary casts if we want to use them.

    Signed-off-by: Jonas Gorski
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Instead of referencing the sizes of fixed partitions, use the
    precomputed CFE/NVRAM lengths.

    Signed-off-by: Jonas Gorski
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • The CFE boot loader on BCM63XX platforms assumes itself and the NVRAM
    partition to be 64 KiB (or erase block sized, if larger).
    Ensure this assumption is also met when creating the partitions to
    prevent accidential erasure of CFE or NVRAM.

    Signed-off-by: Jonas Gorski
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Recent CFEs do not contain the CFE1CFE1 magic anymore, so check for the
    "cfe-v" version marker string instead. As very old CFEs do not have
    this string, leave the CFE1CFE1 magic as a fallback for detection.

    Signed-off-by: Jonas Gorski
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • You didn't mean this to be a bool.

    Signed-off-by: Rusty Russell
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Rusty Russell
     
  • As the MTD api has no use for the number of erase cycles
    each block has endured, remove the function which calculated
    that value.

    If one day MTD api finds it usefull for wear levelling
    algorithms to have this information, the function should be
    put back in place.

    Signed-off-by: Robert Jarzmik
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Robert Jarzmik
     
  • - fix NAND_CMD_READID command for ONFI detect.
    - add NAND_CMD_PARAM command to read the ONFI parameter page.

    Signed-off-by: Shengzhou Liu
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Shengzhou Liu
     
  • There was a bug for fmr initialization, which lead to fmr was always 0x100
    in fsl_elbc_chip_init() and caused FCM command timeout before calling
    fsl_elbc_chip_init_tail(), now we initialize CWTO to maximum timeout value
    and not relying on the setting of bootloader.

    Signed-off-by: Shengzhou Liu
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Shengzhou Liu
     
  • Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Artem Bityutskiy
     
  • If we use the Nand flash chip whose number of pages in a block is greater
    than 64(for large page), we must treat the low bit of FBAR as being the
    high bit of the page address due to the limitation of FCM, it simply uses
    the low 6-bits (for large page) of the combined block/page address as the
    FPAR component, rather than considering the actual block size.

    Signed-off-by: Liu Shuo
    Signed-off-by: Jerry Huang
    Signed-off-by: Tang Yuantian
    Signed-off-by: Li Yang
    Acked-by: Scott Wood
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Liu Shuo
     
  • The array of unsigned long pointed by oops_page_used is allocated
    by vmalloc which requires the size to be in bytes.

    BITS_PER_LONG is equal to 32.
    If we want to allocate memory for 32 pages with one bit per page then
    32 / BITS_PER_LONG is equal to 1 byte that is 8 bits.
    To fix it we need to multiply the result by sizeof(unsigned long) equal to 4.

    Cc: stable@kernel.org
    Signed-off-by: Roman Tereshonkov
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Roman Tereshonkov
     
  • after 250df6ed274d767da844a5d9f05720b804240197
    (fs: protect inode->i_state with inode->i_lock), insert_inode_locked()
    no longer returns the inode with I_NEW set on failure. However,
    the error handler still calls unlock_new_inode() on failure,
    which does a WARN_ON if I_NEW is not set, so any failure spews
    a lot of warnings.

    We can just drop the unlock_new_inode() if insert_inode_locked()
    fails here.

    Signed-off-by: Eric Sandeen
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Eric Sandeen
     
  • bcm963xx-flash does nothing meaningful anymore.

    Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Arch setup code might want to use their own partition parsers, but still
    use the generic physmap flash driver.

    Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Recent BCM63XX devices support a variety of flash types (parallel, SPI,
    NAND) and share the partition layout. To prevent code duplication make
    the CFE partition parsing code a stand alone mtd parser to allow SPI or
    NAND flash drivers to use it.

    Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Replace raw printk's with their pr_XXX equivalent and unify broken up
    strings so they become grepable.

    Also replace the PFX definition with a pr_fmt().

    Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Signed-off-by: Jonas Gorski
    Acked-by: Florian Fainelli
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Jonas Gorski
     
  • Signed-off-by: Heiko Schocher
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Heiko Schocher
     
  • When we do a non-full-page write, the length be set to FBCR should
    not be 'elbc_fcm_ctrl->index', it should be 'elbc_fcm_ctrl->index -
    elbc_fcm_ctrl->column'.

    Signed-off-by: Liu Shuo
    Signed-off-by: Li Yang
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Liu Shuo
     
  • On both of large-page chip and small-page chip, we always should use
    'elbc_fcm_ctrl->oob' to set the FPAR_LP_MS/FPAR_SP_MS bit of FPAR, don't
    use a overflowed 'column' to set it.

    Signed-off-by: Liu Shuo
    Signed-off-by: Li Yang
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Liu Shuo
     
  • This patch takes into account checkpatch, sparse and ECC
    comments.

    Signed-off-by: Robert Jarzmik
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Robert Jarzmik
     
  • Use block_isbad to check and skip the bad blocks reading.
    This will allow to get rid of the read errors if bad blocks
    are present initially.

    Cc: stable@kernel.org
    Signed-off-by: Roman Tereshonkov
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Roman Tereshonkov
     
  • stresstest needs at least two eraseblocks. Bail out gracefully if that
    condition is not met. Fixes the following 'division by zero' OOPS:

    [ 619.100000] mtd_stresstest: MTD device size 131072, eraseblock size 131072, page size 2048, count of eraseblocks 1, pages per eraseblock 64, OOB size 64
    [ 619.120000] mtd_stresstest: scanning for bad eraseblocks
    [ 619.120000] mtd_stresstest: scanned 1 eraseblocks, 0 are bad
    [ 619.130000] mtd_stresstest: doing operations
    [ 619.130000] mtd_stresstest: 0 operations done
    [ 619.140000] Division by zero in kernel.
    ...

    caused by

    /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */
    eb %= (ebcnt - 1);

    Cc: stable@kernel.org
    Signed-off-by: Wolfram Sang
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Wolfram Sang
     
  • This patch converts the drivers in drivers/mtd/* to use the
    module_platform_driver() macro which makes the code smaller and a bit
    simpler.

    Signed-off-by: Axel Lin
    Acked by: Haojian Zhuang
    Signed-off-by: Artem Bityutskiy

    Signed-off-by: David Woodhouse

    Axel Lin
     
  • Add documentation for MSystems disk-on-chip docg3 chips
    sysfs entries, which enable and disable protection areas,
    giving or disabling access to the chip's memory.

    Signed-off-by: Robert Jarzmik
    Signed-off-by: David Woodhouse

    Robert Jarzmik
     
  • If doc_probe_device() returned an ERR_PTR, then we accidentally saved
    that to docg3_floors[floor] = mtd; which gets derefenced in the error
    handling when we call doc_release_device().

    I've reworked the error handling to take care of that and hopefully
    make it a little simpler.

    Signed-off-by: Dan Carpenter
    Acked-by: Robert Jarzmik
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: David Woodhouse

    Dan Carpenter