aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
Commit message (Collapse)AuthorAgeFilesLines
* [MTD] [NAND] remove len/ooblen confusion.Vitaly Wool2006-11-281-16/+35
| | | | | | | | | | | | | | | | | | | | As was discussed between Ricard Wanderlöf, David Woodhouse, Artem Bityutskiy and me, the current API for reading/writing OOB is confusing. The thing that introduces confusion is the need to specify ops.len together with ops.ooblen for reads/writes that concern only OOB not data area. So, ops.len is overloaded: when ops.datbuf != NULL it serves to specify the length of the data read, and when ops.datbuf == NULL, it serves to specify the full OOB read length. The patch inlined below is the slightly updated version of the previous patch serving the same purpose, but with the new Artem's comments taken into account. Artem, BTW, thanks a lot for your valuable input! Signed-off-by: Vitaly Wool <vwool@ru.mvista.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND: Fix nand_default_mark_blockbad() when flash-based BBT disabledRicard Wanderlöf2006-10-261-1/+1
| | | | | | | | | | | | | | | | | When a flash-based BBT is not used, nand_default_mark_blockbad() is supposed to mark the block bad in the oob. However, it sets the wrong length variable so that no bad block marker is in fact written. This patch attempts to rectify that. (As note, it seems to be that logically, it shouldn't be necessary to set both length variables, as one appears to be for the main buffer, and one for the oob buffer, but this is how it is done in several places, including the code for the mtd character device MEMWRITEOOB and MEMREADOOB ioctls. I'm not sure if this is a temporary solution during some rework of the mtd infrastructure, or whether there is a deeper thought here.) Signed-off-by: Ricard Wanderlöf <ricardw@axis.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND: Correct setting of chip->oob_poi OOB bufferDavid Woodhouse2006-10-221-1/+1
| | | | Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND: Combined oob buffer so it's contiguous with dataDavid Woodhouse2006-10-211-10/+5
| | | | | | | | | | Ditch the separate oobrbuf and oobwbuf fields from the chip buffers, and use only a single buffer immediately after the data. This accommodates NAND controllers such as the OLPC CAFÉ chip, which can't do scatter/gather DMA so needs the OOB buffer to be contiguous with the data, for both read and write. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] core: trivial comments fixArtem Bityutskiy2006-10-211-6/+6
| | | | | Signed-off-by: Artem Bityutskiy <dedekind@infradead.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD NAND] Allow override of page read and write functions.David Woodhouse2006-09-251-23/+21
| | | | | | | | - allow high-level nand_write_page() function to be overridden - likewise low-level write_page_raw() and read_page_raw() functions - Clean up the abuse of chip->ecc.{write,read}_page() with MTD_OOB_RAW Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD NAND] Allocate chip->buffers separately to allow it to be overriddenDavid Woodhouse2006-09-251-14/+21
| | | | | | In particular, the board driver might need it to be DMAable. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD NAND] Split nand_scan() into two parts; allow board driver to interveneDavid Woodhouse2006-09-251-25/+65
| | | | Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD NAND] Export nand_wait_ready() for use by board driversDavid Woodhouse2006-09-251-1/+2
| | | | Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* Merge branch 'master' of ↵David Woodhouse2006-08-301-2/+4
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
| * [PATCH] mtd corruption fixRichard Purdie2006-08-271-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Read the return value before we release the nand device otherwise the value can become corrupted by another user of chip->ops, ultimately resulting in filesystem corruption. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Cc: David Woodhouse <dwmw2@infradead.org> Acked-by: Josh Boyer <jwboyer@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* | [MTD NAND] Fix lookup error in nand_get_flash_type()David Woodhouse2006-07-151-1/+1
| | | | | | | | | | Spotted by liyu <liyu@ccoss.com.cn> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* | [MTD] NAND: OOB buffer offset fixupsVitaly Wool2006-07-111-2/+2
|/ | | | | | | | | | | In the case of data-pad-ecc-pad-data... layout the oob start position has to be sizeof(data) in nand_write_oob_syndrom(). In nand_fill_oob() we need to copy to buf + buffer offset instead of buf + write offset. From: Vitaly Wool <vwool@ru.mvista.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* MTD: fix all kernel-doc warningsRandy Dunlap2006-06-291-8/+8
| | | | | | | | | | | Fix all kernel-doc warnings in MTD headers and source files: - add some missing struct fields; - correct some function parameter names; - use kernel-doc format for function doc. headers; - nand_ecc.c contains only exported interfaces, no internal ones; Signed-off-by: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND: Select chip before checking write protect statusThomas Gleixner2006-06-271-3/+3
| | | | | | | | The other way round works not really well with boards which have a static NAND chipselect. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND: Missing fixupsSavin Zlobec2006-06-211-5/+5
| | | | | | | | The oob fixups broke a return value and missed one patch from the Mailing List. Signed-off-by: Savin Zlobec <savin@epico.si> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND: Fix breakage all over the placeThomas Gleixner2006-06-201-82/+215
| | | | | | | | | | | | | | | | | | Following problems are addressed: - wrong status caused early break out of nand_wait() - removed the bogus status check in nand_wait() which is a relict of the abandoned support for interrupted erase. - status check moved to the correct place in read_oob - oob support for syndrom based ecc with strange layouts - use given offset in the AUTOOOB based oob operations Partially based on a patch from Vitaly Vool <vwool@ru.mvista.com> Thanks to Savin Zlobec <savin@epico.si> for tracking down the status problem. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [PATCH] NAND: fix remaining OOB length calculationVitaly Wool2006-06-201-2/+2
| | | | | | | | | In nand_read_page_syndrome/nand_write_page_syndrome the calculation of the remaining oob length which is not used by the prepad/ecc/postpad areas is wrong. Signed-off-by: Vitaly Wool <vwool@ru.mvista.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Fix build warnings (and debug build error) in nand_base.cAndrew Morton2006-05-301-4/+4
| | | | | | | | | | | | | | | drivers/mtd/nand/nand_base.c: In function 'nand_transfer_oob': drivers/mtd/nand/nand_base.c:909: warning: comparison of distinct pointer types lacks a cast drivers/mtd/nand/nand_base.c: In function 'nand_do_read_oob': drivers/mtd/nand/nand_base.c:1097: error: 'len' undeclared (first use in this function) drivers/mtd/nand/nand_base.c:1097: error: (Each undeclared identifier is reported only once drivers/mtd/nand/nand_base.c:1097: error: for each function it appears in.) drivers/mtd/nand/nand_base.c: In function 'nand_fill_oob': drivers/mtd/nand/nand_base.c:1411: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND Expose the new raw mode function and status info to userspaceThomas Gleixner2006-05-301-10/+16
| | | | | | | | | | | The raw read/write access to NAND (without ECC) has been changed in the NAND rework. Expose the new way - setting the file mode via ioctl - to userspace. Also allow to read out the ecc statistics information so userspace tools can see that bitflips happened and whether errors where correctable or not. Also expose the number of bad blocks for the partition, so nandwrite can check if the data fits into the parition before writing to it. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Signal that a bitflip was corrected by ECCThomas Gleixner2006-05-291-1/+4
| | | | | | | | Return -EUCLEAN on read when a bitflip was detected and corrected, so the clients can react and eventually copy the affected block to a spare one. Make all in kernel users aware of the change. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Rework the out of band handling completelyThomas Gleixner2006-05-291-222/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hopefully the last iteration on this! The handling of out of band data on NAND was accompanied by tons of fruitless discussions and halfarsed patches to make it work for a particular problem. Sufficiently annoyed by I all those "I know it better" mails and the resonable amount of discarded "it solves my problem" patches, I finally decided to go for the big rework. After removing the _ecc variants of mtd read/write functions the solution to satisfy the various requirements was to refactor the read/write _oob functions in mtd. The major change is that read/write_oob now takes a pointer to an operation descriptor structure "struct mtd_oob_ops".instead of having a function with at least seven arguments. read/write_oob which should probably renamed to a more descriptive name, can do the following tasks: - read/write out of band data - read/write data content and out of band data - read/write raw data content and out of band data (ecc disabled) struct mtd_oob_ops has a mode field, which determines the oob handling mode. Aside of the MTD_OOB_RAW mode, which is intended to be especially for diagnostic purposes and some internal functions e.g. bad block table creation, the other two modes are for mtd clients: MTD_OOB_PLACE puts/gets the given oob data exactly to/from the place which is described by the ooboffs and ooblen fields of the mtd_oob_ops strcuture. It's up to the caller to make sure that the byte positions are not used by the ECC placement algorithms. MTD_OOB_AUTO puts/gets the given oob data automaticaly to/from the places in the out of band area which are described by the oobfree tuples in the ecclayout data structre which is associated to the devicee. The decision whether data plus oob or oob only handling is done depends on the setting of the datbuf member of the data structure. When datbuf == NULL then the internal read/write_oob functions are selected, otherwise the read/write data routines are invoked. Tested on a few platforms with all variants. Please be aware of possible regressions for your particular device / application scenario Disclaimer: Any whining will be ignored from those who just contributed "hot air blurb" and never sat down to tackle the underlying problem of the mess in the NAND driver grown over time and the big chunk of work to fix up the existing users. The problem was not the holiness of the existing MTD interfaces. The problems was the lack of time to go for the big overhaul. It's easy to add more mess to the existing one, but it takes alot of effort to go for a real solution. Improvements and bugfixes are welcome! Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Replace oobinfo by ecclayoutThomas Gleixner2006-05-291-19/+33
| | | | | | | | | The nand_oobinfo structure is not fitting the newer error correction demands anymore. Replace it by struct nand_ecclayout and fixup the users all over the place. Keep the nand_oobinfo based ioctl for user space compability reasons. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Consolidate oobinfo handlingThomas Gleixner2006-05-291-9/+1
| | | | | | | | | The info structure for out of band data was copied into the mtd structure. Make it a pointer and remove the ability to set it from userspace. The position of ecc bytes is defined by the hardware and should not be changed by software. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Consolidate references and add back default name settingThomas Gleixner2006-05-271-7/+10
| | | | | | | | | | We have a type pointer. Make use of it instead of the error prone nand_ids[i] reference. The NAND driver used to set default name settings from the chip ID string for the device. The feature got lost during the rework. Add it back. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND simplify nand_chip_selectThomas Gleixner2006-05-271-2/+0
| | | | | | | | nCE setting can be done when the first command is issued to the device. We keep the deselect functionality as it makes sense to deassert nCE when the device becomes idle. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Fix thinko in nand_write_page_hwecc()David Woodhouse2006-05-261-1/+1
| | | | | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND modularize write functionThomas Gleixner2006-05-261-514/+261
| | | | | | | | Modularize the write function and reorganaize the internal buffer management. Remove obsolete chip options and fixup all affected users. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Fix NAND_VERIFY_WRITE case to build with tglx's recent changesDavid Woodhouse2006-05-251-4/+4
| | | | | | Bad tglx. No biscuit. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* [MTD] NAND Modularize read functionThomas Gleixner2006-05-251-221/+227
| | | | | | | | Split the core of the read function out and implement seperate handling functions for software and hardware ECC. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Cleanup oob functionsThomas Gleixner2006-05-251-75/+81
| | | | | | | Cleanup the code in the oob related functions and make use of the new NO_READRDY flag. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND Initialize controller lock and wq only onceThomas Gleixner2006-05-251-3/+4
| | | | | | | | | The lock simplifying patch did not move the lock and waitqueue initialization into the controller allocation patch. This reinitializes waitqueue and spinlocks also for driver supplied controller stuctures. Move it into the allocation path. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND fix cmd_ctrl breakageThomas Gleixner2006-05-241-5/+10
| | | | | | The cmd_ctrl rework lacks some state transition flags. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND coding style and namespace cleanupThomas Gleixner2006-05-241-534/+520
| | | | | | | Cleanup the functions which are not going to change in the next steps. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND LED support cleanupThomas Gleixner2006-05-231-2/+6
| | | | | | | Move the define out of the middle of the code and add an appropriate comment. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] NAND remove write_byte/word function from nand_chipThomas Gleixner2006-05-231-45/+0
| | | | | | | | The previous change of the command / hardware control allows to remove the write_byte/word functions completely, as their only user were nand_command and nand_command_lp. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Refactor NAND hwcontrol to cmd_ctrlThomas Gleixner2006-05-231-61/+54
| | | | | | | | | | | | The hwcontrol function enforced a step by step state machine for any kind of hardware chip access. Let the hardware driver know which control bits are set and inform it about a change of the control lines. Let the hardware driver write out the command and address bytes directly. This gives a peformance advantage for address bus controlled chips and simplifies the quirks in the hardware drivers. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Export nand_write_rawThomas Gleixner2006-05-231-0/+1
| | | | | | | The previous _ecc removal / cleanup broke (i)nftl module usage. Export the missing symbol. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Remove read/write _ecc variantsThomas Gleixner2006-05-231-62/+60
| | | | | | | MTD clients are agnostic of FLASH which needs ECC suppport. Remove the functions and fixup the callers. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Remove readv/readv_eccThomas Gleixner2006-05-231-1/+0
| | | | | | | These functions were never implemented and added only bloat to partition and concat code. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD] Remove nand writev supportThomas Gleixner2006-05-231-188/+0
| | | | | | NAND writev(_ecc) support is not longer necessary. Remove it. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* Merge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/Thomas Gleixner2006-05-231-32/+32
|\ | | | | | | Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
| * [MTD] Introduce MTD_BIT_WRITEABLEJoern Engel2006-05-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | o Add a flag MTD_BIT_WRITEABLE for devices that allow single bits to be cleared. o Replace MTD_PROGRAM_REGIONS with a cleared MTD_BIT_WRITEABLE flag for STMicro and Intel Sibley flashes with internal ECC. Those flashes disallow clearing of single bits, unlike regular NOR flashes, so the new flag models their behaviour better. o Remove MTD_ECC. After the STMicro/Sibley merge, this flag is only set and never checked. Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
| * [MTD] Introduce writesizeJoern Engel2006-05-221-32/+32
| | | | | | | | | | | | | | | | At least two flashes exists that have the concept of a minimum write unit, similar to NAND pages, but no other NAND characteristics. Therefore, rename the minimum write unit to "writesize" for all flashes, including NAND. Signed-off-by: Joern Engel <joern@wh.fh-wedel.de>
* | [MTD] NAND modularize ECCThomas Gleixner2006-05-231-98/+48
| | | | | | | | | | | | | | | | First step of modularizing ECC support. - Move ECC related functionality into a seperate embedded data structure - Get rid of the hardware dependend constants to simplify new ECC models Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* | [MTD] NAND cleanup nand_scanThomas Gleixner2006-05-231-174/+233
| | | | | | | | | | | | | | | | Seperate functionality out of nand_scan so the code is more readable. No functional change. First step of simplifying the nand driver. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* | [MTD] NAND consolidate data typesThomas Gleixner2006-05-231-53/+53
| | | | | | | | | | | | | | The NAND driver used a mix of unsigned char, u_char amd uint8_t data types. Consolidate to uint8_t usage Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* | [MTD] NAND whitespace and formatting cleanupThomas Gleixner2006-05-231-42/+62
| | | | | | | | Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* | [MTD] Simplify NAND lockingThomas Gleixner2006-05-231-38/+43
|/ | | | | | | | Replace the chip lock by a the controller lock. For simple drivers a dummy controller structure is created by the scan code. This simplifies the locking algorithm in nand_get/release_chip(). Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* [MTD NAND] Modify check for modules registering NAND devices without ->ownerDavid Woodhouse2006-05-141-6/+11
| | | | | | | | Make it work even with compilers which lack the wit to notice that THIS_MODULE is always non-NULL. Use #ifdef MODULE instead. It's only a temporary debugging check anyway. Signed-off-by: David Woodhouse <dwmw2@infradead.org>