Commit 97894cda authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Thomas Gleixner

[MTD] core: Clean up trailing white spaces

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent b95f9609
# $Id: Kconfig,v 1.10 2005/07/11 10:39:27 gleixner Exp $ # $Id: Kconfig,v 1.11 2005/11/07 11:14:19 gleixner Exp $
menu "Memory Technology Devices (MTD)" menu "Memory Technology Devices (MTD)"
...@@ -10,7 +10,7 @@ config MTD ...@@ -10,7 +10,7 @@ config MTD
will provide the generic support for MTD drivers to register will provide the generic support for MTD drivers to register
themselves with the kernel and for potential users of MTD devices themselves with the kernel and for potential users of MTD devices
to enumerate the devices which are present and obtain a handle on to enumerate the devices which are present and obtain a handle on
them. It will also allow you to select individual drivers for them. It will also allow you to select individual drivers for
particular hardware and users of MTD devices. If unsure, say N. particular hardware and users of MTD devices. If unsure, say N.
config MTD_DEBUG config MTD_DEBUG
...@@ -61,11 +61,11 @@ config MTD_REDBOOT_PARTS ...@@ -61,11 +61,11 @@ config MTD_REDBOOT_PARTS
If you need code which can detect and parse this table, and register If you need code which can detect and parse this table, and register
MTD 'partitions' corresponding to each image in the table, enable MTD 'partitions' corresponding to each image in the table, enable
this option. this option.
You will still need the parsing functions to be called by the driver You will still need the parsing functions to be called by the driver
for your particular device. It won't happen automatically. The for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example. example.
config MTD_REDBOOT_DIRECTORY_BLOCK config MTD_REDBOOT_DIRECTORY_BLOCK
...@@ -81,10 +81,10 @@ config MTD_REDBOOT_DIRECTORY_BLOCK ...@@ -81,10 +81,10 @@ config MTD_REDBOOT_DIRECTORY_BLOCK
partition table. A zero or positive value gives an absolete partition table. A zero or positive value gives an absolete
erase block number. A negative value specifies a number of erase block number. A negative value specifies a number of
sectors before the end of the device. sectors before the end of the device.
For example "2" means block number 2, "-1" means the last For example "2" means block number 2, "-1" means the last
block and "-2" means the penultimate block. block and "-2" means the penultimate block.
config MTD_REDBOOT_PARTS_UNALLOCATED config MTD_REDBOOT_PARTS_UNALLOCATED
bool " Include unallocated flash regions" bool " Include unallocated flash regions"
depends on MTD_REDBOOT_PARTS depends on MTD_REDBOOT_PARTS
...@@ -105,11 +105,11 @@ config MTD_CMDLINE_PARTS ...@@ -105,11 +105,11 @@ config MTD_CMDLINE_PARTS
---help--- ---help---
Allow generic configuration of the MTD paritition tables via the kernel Allow generic configuration of the MTD paritition tables via the kernel
command line. Multiple flash resources are supported for hardware where command line. Multiple flash resources are supported for hardware where
different kinds of flash memory are available. different kinds of flash memory are available.
You will still need the parsing functions to be called by the driver You will still need the parsing functions to be called by the driver
for your particular device. It won't happen automatically. The for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example. example.
The format for the command line is as follows: The format for the command line is as follows:
...@@ -118,12 +118,12 @@ config MTD_CMDLINE_PARTS ...@@ -118,12 +118,12 @@ config MTD_CMDLINE_PARTS
<mtddef> := <mtd-id>:<partdef>[,<partdef>] <mtddef> := <mtd-id>:<partdef>[,<partdef>]
<partdef> := <size>[@offset][<name>][ro] <partdef> := <size>[@offset][<name>][ro]
<mtd-id> := unique id used in mapping driver/device <mtd-id> := unique id used in mapping driver/device
<size> := standard linux memsize OR "-" to denote all <size> := standard linux memsize OR "-" to denote all
remaining space remaining space
<name> := (NAME) <name> := (NAME)
Due to the way Linux handles the command line, no spaces are Due to the way Linux handles the command line, no spaces are
allowed in the partition definition, including mtd id's and partition allowed in the partition definition, including mtd id's and partition
names. names.
Examples: Examples:
...@@ -240,7 +240,7 @@ config INFTL ...@@ -240,7 +240,7 @@ config INFTL
tristate "INFTL (Inverse NAND Flash Translation Layer) support" tristate "INFTL (Inverse NAND Flash Translation Layer) support"
depends on MTD depends on MTD
---help--- ---help---
This provides support for the Inverse NAND Flash Translation This provides support for the Inverse NAND Flash Translation
Layer which is used on M-Systems' newer DiskOnChip devices. It Layer which is used on M-Systems' newer DiskOnChip devices. It
uses a kind of pseudo-file system on a flash device to emulate uses a kind of pseudo-file system on a flash device to emulate
a block device with 512-byte sectors, on top of which you put a block device with 512-byte sectors, on top of which you put
...@@ -257,8 +257,8 @@ config RFD_FTL ...@@ -257,8 +257,8 @@ config RFD_FTL
tristate "Resident Flash Disk (Flash Translation Layer) support" tristate "Resident Flash Disk (Flash Translation Layer) support"
depends on MTD depends on MTD
---help--- ---help---
This provides support for the flash translation layer known This provides support for the flash translation layer known
as the Resident Flash Disk (RFD), as used by the Embedded BIOS as the Resident Flash Disk (RFD), as used by the Embedded BIOS
of General Software. There is a blurb at: of General Software. There is a blurb at:
http://www.gensw.com/pages/prod/bios/rfd.htm http://www.gensw.com/pages/prod/bios/rfd.htm
......
/*====================================================================== /*======================================================================
drivers/mtd/afs.c: ARM Flash Layout/Partitioning drivers/mtd/afs.c: ARM Flash Layout/Partitioning
Copyright (C) 2000 ARM Limited Copyright (C) 2000 ARM Limited
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
This is access code for flashes using ARM's flash partitioning This is access code for flashes using ARM's flash partitioning
standards. standards.
$Id: afs.c,v 1.13 2004/02/27 22:09:59 rmk Exp $ $Id: afs.c,v 1.15 2005/11/07 11:14:19 gleixner Exp $
======================================================================*/ ======================================================================*/
...@@ -163,7 +163,7 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr) ...@@ -163,7 +163,7 @@ afs_read_iis(struct mtd_info *mtd, struct image_info_struct *iis, u_int ptr)
return ret; return ret;
} }
static int parse_afs_partitions(struct mtd_info *mtd, static int parse_afs_partitions(struct mtd_info *mtd,
struct mtd_partition **pparts, struct mtd_partition **pparts,
unsigned long origin) unsigned long origin)
{ {
......
/* /*
* $Id: cmdlinepart.c,v 1.18 2005/06/07 15:04:26 joern Exp $ * $Id: cmdlinepart.c,v 1.19 2005/11/07 11:14:19 gleixner Exp $
* *
* Read flash partition table from command line * Read flash partition table from command line
* *
* Copyright 2002 SYSGO Real-Time Solutions GmbH * Copyright 2002 SYSGO Real-Time Solutions GmbH
* *
* The format for the command line is as follows: * The format for the command line is as follows:
* *
* mtdparts=<mtddef>[;<mtddef] * mtdparts=<mtddef>[;<mtddef]
* <mtddef> := <mtd-id>:<partdef>[,<partdef>] * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
* <partdef> := <size>[@offset][<name>][ro] * <partdef> := <size>[@offset][<name>][ro]
* <mtd-id> := unique name used in mapping driver/device (mtd->name) * <mtd-id> := unique name used in mapping driver/device (mtd->name)
* <size> := standard linux memsize OR "-" to denote all remaining space * <size> := standard linux memsize OR "-" to denote all remaining space
* <name> := '(' NAME ')' * <name> := '(' NAME ')'
* *
* Examples: * Examples:
* *
* 1 NOR Flash, with 1 single writable partition: * 1 NOR Flash, with 1 single writable partition:
* edb7312-nor:- * edb7312-nor:-
* *
* 1 NOR Flash with 2 partitions, 1 NAND with one * 1 NOR Flash with 2 partitions, 1 NAND with one
* edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home) * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
*/ */
...@@ -60,17 +60,17 @@ static int cmdline_parsed = 0; ...@@ -60,17 +60,17 @@ static int cmdline_parsed = 0;
/* /*
* Parse one partition definition for an MTD. Since there can be many * Parse one partition definition for an MTD. Since there can be many
* comma separated partition definitions, this function calls itself * comma separated partition definitions, this function calls itself
* recursively until no more partition definitions are found. Nice side * recursively until no more partition definitions are found. Nice side
* effect: the memory to keep the mtd_partition structs and the names * effect: the memory to keep the mtd_partition structs and the names
* is allocated upon the last definition being found. At that point the * is allocated upon the last definition being found. At that point the
* syntax has been verified ok. * syntax has been verified ok.
*/ */
static struct mtd_partition * newpart(char *s, static struct mtd_partition * newpart(char *s,
char **retptr, char **retptr,
int *num_parts, int *num_parts,
int this_part, int this_part,
unsigned char **extra_mem_ptr, unsigned char **extra_mem_ptr,
int extra_mem_size) int extra_mem_size)
{ {
struct mtd_partition *parts; struct mtd_partition *parts;
...@@ -102,7 +102,7 @@ static struct mtd_partition * newpart(char *s, ...@@ -102,7 +102,7 @@ static struct mtd_partition * newpart(char *s,
mask_flags = 0; /* this is going to be a regular partition */ mask_flags = 0; /* this is going to be a regular partition */
delim = 0; delim = 0;
/* check for offset */ /* check for offset */
if (*s == '@') if (*s == '@')
{ {
s++; s++;
offset = memparse(s, &s); offset = memparse(s, &s);
...@@ -112,7 +112,7 @@ static struct mtd_partition * newpart(char *s, ...@@ -112,7 +112,7 @@ static struct mtd_partition * newpart(char *s,
{ {
delim = ')'; delim = ')';
} }
if (delim) if (delim)
{ {
char *p; char *p;
...@@ -131,12 +131,12 @@ static struct mtd_partition * newpart(char *s, ...@@ -131,12 +131,12 @@ static struct mtd_partition * newpart(char *s,
name = NULL; name = NULL;
name_len = 13; /* Partition_000 */ name_len = 13; /* Partition_000 */
} }
/* record name length for memory allocation later */ /* record name length for memory allocation later */
extra_mem_size += name_len + 1; extra_mem_size += name_len + 1;
/* test for options */ /* test for options */
if (strncmp(s, "ro", 2) == 0) if (strncmp(s, "ro", 2) == 0)
{ {
mask_flags |= MTD_WRITEABLE; mask_flags |= MTD_WRITEABLE;
s += 2; s += 2;
...@@ -151,7 +151,7 @@ static struct mtd_partition * newpart(char *s, ...@@ -151,7 +151,7 @@ static struct mtd_partition * newpart(char *s,
return NULL; return NULL;
} }
/* more partitions follow, parse them */ /* more partitions follow, parse them */
if ((parts = newpart(s + 1, &s, num_parts, if ((parts = newpart(s + 1, &s, num_parts,
this_part + 1, &extra_mem, extra_mem_size)) == 0) this_part + 1, &extra_mem, extra_mem_size)) == 0)
return NULL; return NULL;
} }
...@@ -187,7 +187,7 @@ static struct mtd_partition * newpart(char *s, ...@@ -187,7 +187,7 @@ static struct mtd_partition * newpart(char *s,
extra_mem += name_len + 1; extra_mem += name_len + 1;
dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n", dbg(("partition %d: name <%s>, offset %x, size %x, mask flags %x\n",
this_part, this_part,
parts[this_part].name, parts[this_part].name,
parts[this_part].offset, parts[this_part].offset,
parts[this_part].size, parts[this_part].size,
...@@ -204,8 +204,8 @@ static struct mtd_partition * newpart(char *s, ...@@ -204,8 +204,8 @@ static struct mtd_partition * newpart(char *s,
return parts; return parts;
} }
/* /*
* Parse the command line. * Parse the command line.
*/ */
static int mtdpart_setup_real(char *s) static int mtdpart_setup_real(char *s)
{ {
...@@ -230,7 +230,7 @@ static int mtdpart_setup_real(char *s) ...@@ -230,7 +230,7 @@ static int mtdpart_setup_real(char *s)
dbg(("parsing <%s>\n", p+1)); dbg(("parsing <%s>\n", p+1));
/* /*
* parse one mtd. have it reserve memory for the * parse one mtd. have it reserve memory for the
* struct cmdline_mtd_partition and the mtd-id string. * struct cmdline_mtd_partition and the mtd-id string.
*/ */
...@@ -239,7 +239,7 @@ static int mtdpart_setup_real(char *s) ...@@ -239,7 +239,7 @@ static int mtdpart_setup_real(char *s)
&num_parts, /* out: number of parts */ &num_parts, /* out: number of parts */
0, /* first partition */ 0, /* first partition */
(unsigned char**)&this_mtd, /* out: extra mem */ (unsigned char**)&this_mtd, /* out: extra mem */
mtd_id_len + 1 + sizeof(*this_mtd) + mtd_id_len + 1 + sizeof(*this_mtd) +
sizeof(void*)-1 /*alignment*/); sizeof(void*)-1 /*alignment*/);
if(!parts) if(!parts)
{ {
...@@ -254,21 +254,21 @@ static int mtdpart_setup_real(char *s) ...@@ -254,21 +254,21 @@ static int mtdpart_setup_real(char *s)
} }
/* align this_mtd */ /* align this_mtd */
this_mtd = (struct cmdline_mtd_partition *) this_mtd = (struct cmdline_mtd_partition *)
ALIGN((unsigned long)this_mtd, sizeof(void*)); ALIGN((unsigned long)this_mtd, sizeof(void*));
/* enter results */ /* enter results */
this_mtd->parts = parts; this_mtd->parts = parts;
this_mtd->num_parts = num_parts; this_mtd->num_parts = num_parts;
this_mtd->mtd_id = (char*)(this_mtd + 1); this_mtd->mtd_id = (char*)(this_mtd + 1);
strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1);
/* link into chain */ /* link into chain */
this_mtd->next = partitions; this_mtd->next = partitions;
partitions = this_mtd; partitions = this_mtd;
dbg(("mtdid=<%s> num_parts=<%d>\n", dbg(("mtdid=<%s> num_parts=<%d>\n",
this_mtd->mtd_id, this_mtd->num_parts)); this_mtd->mtd_id, this_mtd->num_parts));
/* EOS - we're done */ /* EOS - we're done */
if (*s == 0) if (*s == 0)
...@@ -292,7 +292,7 @@ static int mtdpart_setup_real(char *s) ...@@ -292,7 +292,7 @@ static int mtdpart_setup_real(char *s)
* information. It returns partitions for the requested mtd device, or * information. It returns partitions for the requested mtd device, or
* the first one in the chain if a NULL mtd_id is passed in. * the first one in the chain if a NULL mtd_id is passed in.
*/ */
static int parse_cmdline_partitions(struct mtd_info *master, static int parse_cmdline_partitions(struct mtd_info *master,
struct mtd_partition **pparts, struct mtd_partition **pparts,
unsigned long origin) unsigned long origin)
{ {
...@@ -322,7 +322,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, ...@@ -322,7 +322,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
part->parts[i].size = master->size - offset; part->parts[i].size = master->size - offset;
if (offset + part->parts[i].size > master->size) if (offset + part->parts[i].size > master->size)
{ {
printk(KERN_WARNING ERRP printk(KERN_WARNING ERRP
"%s: partitioning exceeds flash size, truncating\n", "%s: partitioning exceeds flash size, truncating\n",
part->mtd_id); part->mtd_id);
part->parts[i].size = master->size - offset; part->parts[i].size = master->size - offset;
...@@ -338,8 +338,8 @@ static int parse_cmdline_partitions(struct mtd_info *master, ...@@ -338,8 +338,8 @@ static int parse_cmdline_partitions(struct mtd_info *master,
} }
/* /*
* This is the handler for our kernel parameter, called from * This is the handler for our kernel parameter, called from
* main.c::checksetup(). Note that we can not yet kmalloc() anything, * main.c::checksetup(). Note that we can not yet kmalloc() anything,
* so we only save the commandline for later processing. * so we only save the commandline for later processing.
* *
......
This diff is collapsed.
/* /*
* inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL) * inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL)
* *
* (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* (c) 1999 Machine Vision Holdings, Inc. * (c) 1999 Machine Vision Holdings, Inc.
* Author: David Woodhouse <dwmw2@infradead.org> * Author: David Woodhouse <dwmw2@infradead.org>
* *
* $Id: inftlcore.c,v 1.18 2004/11/16 18:28:59 dwmw2 Exp $ * $Id: inftlcore.c,v 1.19 2005/11/07 11:14:20 gleixner Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -113,14 +113,14 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) ...@@ -113,14 +113,14 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) { if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) {
/* /*
Oh no we don't have Oh no we don't have
mbd.size == heads * cylinders * sectors mbd.size == heads * cylinders * sectors
*/ */
printk(KERN_WARNING "INFTL: cannot calculate a geometry to " printk(KERN_WARNING "INFTL: cannot calculate a geometry to "
"match size of 0x%lx.\n", inftl->mbd.size); "match size of 0x%lx.\n", inftl->mbd.size);
printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d " printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d "
"(== 0x%lx sects)\n", "(== 0x%lx sects)\n",
inftl->cylinders, inftl->heads , inftl->sectors, inftl->cylinders, inftl->heads , inftl->sectors,
(long)inftl->cylinders * (long)inftl->heads * (long)inftl->cylinders * (long)inftl->heads *
(long)inftl->sectors ); (long)inftl->sectors );
} }
...@@ -223,7 +223,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned ...@@ -223,7 +223,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
"Virtual Unit Chain %d!\n", thisVUC); "Virtual Unit Chain %d!\n", thisVUC);
return BLOCK_NIL; return BLOCK_NIL;
} }
/* /*
* Scan to find the Erase Unit which holds the actual data for each * Scan to find the Erase Unit which holds the actual data for each
* 512-byte block within the Chain. * 512-byte block within the Chain.
...@@ -264,7 +264,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned ...@@ -264,7 +264,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
"Unit Chain 0x%x\n", thisVUC); "Unit Chain 0x%x\n", thisVUC);
return BLOCK_NIL; return BLOCK_NIL;
} }
thisEUN = inftl->PUtable[thisEUN]; thisEUN = inftl->PUtable[thisEUN];
} }
...@@ -295,15 +295,15 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned ...@@ -295,15 +295,15 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
*/ */
if (BlockMap[block] == BLOCK_NIL) if (BlockMap[block] == BLOCK_NIL)
continue; continue;
ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE,
&retlen, movebuf); &retlen, movebuf);
if (ret < 0) { if (ret < 0) {
ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
BlockMap[block]) + (block * SECTORSIZE), BlockMap[block]) + (block * SECTORSIZE),
SECTORSIZE, &retlen, movebuf); SECTORSIZE, &retlen, movebuf);
if (ret != -EIO) if (ret != -EIO)
DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
"away on retry?\n"); "away on retry?\n");
} }
...@@ -355,7 +355,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned ...@@ -355,7 +355,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock) static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
{ {
/* /*
* This is the part that needs some cleverness applied. * This is the part that needs some cleverness applied.
* For now, I'm doing the minimum applicable to actually * For now, I'm doing the minimum applicable to actually
* get the thing to work. * get the thing to work.
* Wear-levelling and other clever stuff needs to be implemented * Wear-levelling and other clever stuff needs to be implemented
...@@ -414,7 +414,7 @@ static int nrbits(unsigned int val, int bitcount) ...@@ -414,7 +414,7 @@ static int nrbits(unsigned int val, int bitcount)
} }
/* /*
* INFTL_findwriteunit: Return the unit number into which we can write * INFTL_findwriteunit: Return the unit number into which we can write
* for this block. Make it available if it isn't already. * for this block. Make it available if it isn't already.
*/ */
static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
...@@ -463,10 +463,10 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -463,10 +463,10 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
* Invalid block. Don't use it any more. * Invalid block. Don't use it any more.
* Must implement. * Must implement.
*/ */
break; break;
} }
if (!silly--) { if (!silly--) {
printk(KERN_WARNING "INFTL: infinite loop in " printk(KERN_WARNING "INFTL: infinite loop in "
"Virtual Unit Chain 0x%x\n", thisVUC); "Virtual Unit Chain 0x%x\n", thisVUC);
return 0xffff; return 0xffff;
...@@ -482,7 +482,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -482,7 +482,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
/* /*
* OK. We didn't find one in the existing chain, or there * OK. We didn't find one in the existing chain, or there
* is no existing chain. Allocate a new one. * is no existing chain. Allocate a new one.
*/ */
writeEUN = INFTL_findfreeblock(inftl, 0); writeEUN = INFTL_findfreeblock(inftl, 0);
...@@ -506,8 +506,8 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -506,8 +506,8 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
if (writeEUN == BLOCK_NIL) { if (writeEUN == BLOCK_NIL) {
/* /*
* Ouch. This should never happen - we should * Ouch. This should never happen - we should
* always be able to make some room somehow. * always be able to make some room somehow.
* If we get here, we've allocated more storage * If we get here, we've allocated more storage
* space than actual media, or our makefreeblock * space than actual media, or our makefreeblock
* routine is missing something. * routine is missing something.
*/ */
...@@ -518,7 +518,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -518,7 +518,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
INFTL_dumpVUchains(inftl); INFTL_dumpVUchains(inftl);
#endif #endif
return BLOCK_NIL; return BLOCK_NIL;
} }
} }
/* /*
...@@ -543,7 +543,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -543,7 +543,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0; parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0;
parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0; parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0;
parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0; parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0;
oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC); oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC);
oob.u.a.prevUnitNo = cpu_to_le16(prev_block); oob.u.a.prevUnitNo = cpu_to_le16(prev_block);
oob.u.a.ANAC = anac; oob.u.a.ANAC = anac;
...@@ -562,7 +562,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) ...@@ -562,7 +562,7 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
oob.u.b.parityPerField = parity; oob.u.b.parityPerField = parity;
oob.u.b.discarded = 0xaa; oob.u.b.discarded = 0xaa;
MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize +
SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u); SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);
inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC]; inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
...@@ -602,7 +602,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC) ...@@ -602,7 +602,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
"Virtual Unit Chain %d!\n", thisVUC); "Virtual Unit Chain %d!\n", thisVUC);
return; return;
} }
/* /*
* Scan through the Erase Units to determine whether any data is in * Scan through the Erase Units to determine whether any data is in
* each of the 512-byte blocks within the Chain. * each of the 512-byte blocks within the Chain.
...@@ -642,7 +642,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC) ...@@ -642,7 +642,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
"Unit Chain 0x%x\n", thisVUC); "Unit Chain 0x%x\n", thisVUC);
return; return;
} }
thisEUN = inftl->PUtable[thisEUN]; thisEUN = inftl->PUtable[thisEUN];
} }
...@@ -758,7 +758,7 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block) ...@@ -758,7 +758,7 @@ static int INFTL_deleteblock(struct INFTLrecord *inftl, unsigned block)
return 0; return 0;
} }
static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,
char *buffer) char *buffer)
{ {
struct INFTLrecord *inftl = (void *)mbd; struct INFTLrecord *inftl = (void *)mbd;
...@@ -893,7 +893,7 @@ extern char inftlmountrev[]; ...@@ -893,7 +893,7 @@ extern char inftlmountrev[];
static int __init init_inftl(void) static int __init init_inftl(void)
{ {
printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.18 $, " printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, "
"inftlmount.c %s\n", inftlmountrev); "inftlmount.c %s\n", inftlmountrev);
return register_mtd_blktrans(&inftl_tr); return register_mtd_blktrans(&inftl_tr);
......
/* /*
* inftlmount.c -- INFTL mount code with extensive checks. * inftlmount.c -- INFTL mount code with extensive checks.
* *
* Author: Greg Ungerer (gerg@snapgear.com) * Author: Greg Ungerer (gerg@snapgear.com)
* (C) Copyright 2002-2003, Greg Ungerer (gerg@snapgear.com) * (C) Copyright 2002-2003, Greg Ungerer (gerg@snapgear.com)
* *
* Based heavily on the nftlmount.c code which is: * Based heavily on the nftlmount.c code which is:
* Author: Fabrice Bellard (fabrice.bellard@netgem.com) * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
* Copyright (C) 2000 Netgem S.A. * Copyright (C) 2000 Netgem S.A.
* *
* $Id: inftlmount.c,v 1.17 2005/08/08 08:56:19 dwmw2 Exp $ * $Id: inftlmount.c,v 1.18 2005/11/07 11:14:20 gleixner Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <linux/mtd/inftl.h> #include <linux/mtd/inftl.h>
#include <linux/mtd/compatmac.h> #include <linux/mtd/compatmac.h>
char inftlmountrev[]="$Revision: 1.17 $"; char inftlmountrev[]="$Revision: 1.18 $";
/* /*
* find_boot_record: Find the INFTL Media Header and its Spare copy which * find_boot_record: Find the INFTL Media Header and its Spare copy which
...@@ -273,7 +273,7 @@ static int find_boot_record(struct INFTLrecord *inftl) ...@@ -273,7 +273,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
inftl->nb_boot_blocks); inftl->nb_boot_blocks);
return -1; return -1;
} }
inftl->mbd.size = inftl->numvunits * inftl->mbd.size = inftl->numvunits *
(inftl->EraseSize / SECTORSIZE); (inftl->EraseSize / SECTORSIZE);
...@@ -302,7 +302,7 @@ static int find_boot_record(struct INFTLrecord *inftl) ...@@ -302,7 +302,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
inftl->nb_blocks * sizeof(u16)); inftl->nb_blocks * sizeof(u16));
return -ENOMEM; return -ENOMEM;
} }
/* Mark the blocks before INFTL MediaHeader as reserved */ /* Mark the blocks before INFTL MediaHeader as reserved */
for (i = 0; i < inftl->nb_boot_blocks; i++) for (i = 0; i < inftl->nb_boot_blocks; i++)
inftl->PUtable[i] = BLOCK_RESERVED; inftl->PUtable[i] = BLOCK_RESERVED;
...@@ -380,7 +380,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address, ...@@ -380,7 +380,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
* *
* Return: 0 when succeed, -1 on error. * Return: 0 when succeed, -1 on error.
* *
* ToDo: 1. Is it neceressary to check_free_sector after erasing ?? * ToDo: 1. Is it neceressary to check_free_sector after erasing ??
*/ */
int INFTL_formatblock(struct INFTLrecord *inftl, int block) int INFTL_formatblock(struct INFTLrecord *inftl, int block)
{ {
...@@ -578,7 +578,7 @@ int INFTL_mount(struct INFTLrecord *s) ...@@ -578,7 +578,7 @@ int INFTL_mount(struct INFTLrecord *s)
printk(KERN_ERR "INFTL: Out of memory.\n"); printk(KERN_ERR "INFTL: Out of memory.\n");
return -ENOMEM; return -ENOMEM;
} }
memset(ANACtable, 0, s->nb_blocks); memset(ANACtable, 0, s->nb_blocks);
/* /*
...@@ -600,7 +600,7 @@ int INFTL_mount(struct INFTLrecord *s) ...@@ -600,7 +600,7 @@ int INFTL_mount(struct INFTLrecord *s)
for (chain_length = 0; ; chain_length++) { for (chain_length = 0; ; chain_length++) {
if ((chain_length == 0) && if ((chain_length == 0) &&
(s->PUtable[block] != BLOCK_NOTEXPLORED)) { (s->PUtable[block] != BLOCK_NOTEXPLORED)) {
/* Nothing to do here, onto next block */ /* Nothing to do here, onto next block */
break; break;
...@@ -747,7 +747,7 @@ int INFTL_mount(struct INFTLrecord *s) ...@@ -747,7 +747,7 @@ int INFTL_mount(struct INFTLrecord *s)
"in virtual chain %d\n", "in virtual chain %d\n",
s->PUtable[block], logical_block); s->PUtable[block], logical_block);
s->PUtable[block] = BLOCK_NIL; s->PUtable[block] = BLOCK_NIL;
} }
if (ANACtable[block] != ANAC) { if (ANACtable[block] != ANAC) {
/* /*
......
/* /*
* $Id: mtd_blkdevs.c,v 1.26 2005/07/29 19:42:04 tpoynor Exp $ * $Id: mtd_blkdevs.c,v 1.27 2005/11/07 11:14:20 gleixner Exp $
* *
* (C) 2003 David Woodhouse <dwmw2@infradead.org> * (C) 2003 David Woodhouse <dwmw2@infradead.org>
* *
...@@ -85,7 +85,7 @@ static int mtd_blktrans_thread(void *arg) ...@@ -85,7 +85,7 @@ static int mtd_blktrans_thread(void *arg)
daemonize("%sd", tr->name); daemonize("%sd", tr->name);
/* daemonize() doesn't do this for us since some kernel threads /* daemonize() doesn't do this for us since some kernel threads
actually want to deal with signals. We can't just call actually want to deal with signals. We can't just call
exit_sighand() since that'll cause an oops when we finally exit_sighand() since that'll cause an oops when we finally
do exit. */ do exit. */
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
...@@ -94,7 +94,7 @@ static int mtd_blktrans_thread(void *arg) ...@@ -94,7 +94,7 @@ static int mtd_blktrans_thread(void *arg)
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
spin_lock_irq(rq->queue_lock); spin_lock_irq(rq->queue_lock);
while (!tr->blkcore_priv->exiting) { while (!tr->blkcore_priv->exiting) {
struct request *req; struct request *req;
struct mtd_blktrans_dev *dev; struct mtd_blktrans_dev *dev;
...@@ -157,7 +157,7 @@ static int blktrans_open(struct inode *i, struct file *f) ...@@ -157,7 +157,7 @@ static int blktrans_open(struct inode *i, struct file *f)
if (!try_module_get(tr->owner)) if (!try_module_get(tr->owner))
goto out_tr; goto out_tr;
/* FIXME: Locking. A hot pluggable device can go away /* FIXME: Locking. A hot pluggable device can go away
(del_mtd_device can be called for it) without its module (del_mtd_device can be called for it) without its module
being unloaded. */ being unloaded. */
dev->mtd->usecount++; dev->mtd->usecount++;
...@@ -195,7 +195,7 @@ static int blktrans_release(struct inode *i, struct file *f) ...@@ -195,7 +195,7 @@ static int blktrans_release(struct inode *i, struct file *f)
} }
static int blktrans_ioctl(struct inode *inode, struct file *file, static int blktrans_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data; struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data;
...@@ -264,7 +264,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -264,7 +264,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
/* Required number was free */ /* Required number was free */
list_add_tail(&new->list, &d->list); list_add_tail(&new->list, &d->list);
goto added; goto added;
} }
last_devnum = d->devnum; last_devnum = d->devnum;
} }
if (new->devnum == -1) if (new->devnum == -1)
...@@ -288,7 +288,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -288,7 +288,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
gd->major = tr->major; gd->major = tr->major;
gd->first_minor = (new->devnum) << tr->part_bits; gd->first_minor = (new->devnum) << tr->part_bits;
gd->fops = &mtd_blktrans_ops; gd->fops = &mtd_blktrans_ops;
if (tr->part_bits) if (tr->part_bits)
if (new->devnum < 26) if (new->devnum < 26)
snprintf(gd->disk_name, sizeof(gd->disk_name), snprintf(gd->disk_name, sizeof(gd->disk_name),
...@@ -314,7 +314,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) ...@@ -314,7 +314,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
set_disk_ro(gd, 1); set_disk_ro(gd, 1);
add_disk(gd); add_disk(gd);
return 0; return 0;
} }
...@@ -329,7 +329,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) ...@@ -329,7 +329,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
del_gendisk(old->blkcore_priv); del_gendisk(old->blkcore_priv);
put_disk(old->blkcore_priv); put_disk(old->blkcore_priv);
return 0; return 0;
} }
...@@ -368,12 +368,12 @@ static struct mtd_notifier blktrans_notifier = { ...@@ -368,12 +368,12 @@ static struct mtd_notifier blktrans_notifier = {
.add = blktrans_notify_add, .add = blktrans_notify_add,
.remove = blktrans_notify_remove, .remove = blktrans_notify_remove,
}; };
int register_mtd_blktrans(struct mtd_blktrans_ops *tr) int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
{ {
int ret, i; int ret, i;
/* Register the notifier if/when the first device type is /* Register the notifier if/when the first device type is
registered, to prevent the link/init ordering from fucking registered, to prevent the link/init ordering from fucking
us over. */ us over. */
if (!blktrans_notifier.list.next) if (!blktrans_notifier.list.next)
...@@ -416,7 +416,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) ...@@ -416,7 +416,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
kfree(tr->blkcore_priv); kfree(tr->blkcore_priv);
up(&mtd_table_mutex); up(&mtd_table_mutex);
return ret; return ret;
} }
INIT_LIST_HEAD(&tr->devs); INIT_LIST_HEAD(&tr->devs);
list_add(&tr->list, &blktrans_majors); list_add(&tr->list, &blktrans_majors);
......
/* /*
* Direct MTD block device access * Direct MTD block device access
* *
* $Id: mtdblock.c,v 1.67 2005/11/06 10:04:37 gleixner Exp $ * $Id: mtdblock.c,v 1.68 2005/11/07 11:14:20 gleixner Exp $
* *
* (C) 2000-2003 Nicolas Pitre <nico@cam.org> * (C) 2000-2003 Nicolas Pitre <nico@cam.org>
* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
...@@ -32,7 +32,7 @@ static struct mtdblk_dev { ...@@ -32,7 +32,7 @@ static struct mtdblk_dev {
/* /*
* Cache stuff... * Cache stuff...
* *
* Since typical flash erasable sectors are much larger than what Linux's * Since typical flash erasable sectors are much larger than what Linux's
* buffer cache can handle, we must implement read-modify-write on flash * buffer cache can handle, we must implement read-modify-write on flash
* sectors for each block write requests. To avoid over-erasing flash sectors * sectors for each block write requests. To avoid over-erasing flash sectors
...@@ -46,7 +46,7 @@ static void erase_callback(struct erase_info *done) ...@@ -46,7 +46,7 @@ static void erase_callback(struct erase_info *done)
wake_up(wait_q); wake_up(wait_q);
} }
static int erase_write (struct mtd_info *mtd, unsigned long pos, static int erase_write (struct mtd_info *mtd, unsigned long pos,
int len, const char *buf) int len, const char *buf)
{ {
struct erase_info erase; struct erase_info erase;
...@@ -104,18 +104,18 @@ static int write_cached_data (struct mtdblk_dev *mtdblk) ...@@ -104,18 +104,18 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
return 0; return 0;
DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: writing cached data for \"%s\" " DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: writing cached data for \"%s\" "
"at 0x%lx, size 0x%x\n", mtd->name, "at 0x%lx, size 0x%x\n", mtd->name,
mtdblk->cache_offset, mtdblk->cache_size); mtdblk->cache_offset, mtdblk->cache_size);
ret = erase_write (mtd, mtdblk->cache_offset, ret = erase_write (mtd, mtdblk->cache_offset,
mtdblk->cache_size, mtdblk->cache_data); mtdblk->cache_size, mtdblk->cache_data);
if (ret) if (ret)
return ret; return ret;
/* /*
* Here we could argubly set the cache state to STATE_CLEAN. * Here we could argubly set the cache state to STATE_CLEAN.
* However this could lead to inconsistency since we will not * However this could lead to inconsistency since we will not
* be notified if this content is altered on the flash by other * be notified if this content is altered on the flash by other
* means. Let's declare it empty and leave buffering tasks to * means. Let's declare it empty and leave buffering tasks to
* the buffer cache instead. * the buffer cache instead.
*/ */
...@@ -124,7 +124,7 @@ static int write_cached_data (struct mtdblk_dev *mtdblk) ...@@ -124,7 +124,7 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
} }
static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
int len, const char *buf) int len, const char *buf)
{ {
struct mtd_info *mtd = mtdblk->mtd; struct mtd_info *mtd = mtdblk->mtd;
...@@ -134,7 +134,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -134,7 +134,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n", DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: write on \"%s\" at 0x%lx, size 0x%x\n",
mtd->name, pos, len); mtd->name, pos, len);
if (!sect_size) if (!sect_size)
return MTD_WRITE (mtd, pos, len, &retlen, buf); return MTD_WRITE (mtd, pos, len, &retlen, buf);
...@@ -142,11 +142,11 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -142,11 +142,11 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
unsigned long sect_start = (pos/sect_size)*sect_size; unsigned long sect_start = (pos/sect_size)*sect_size;
unsigned int offset = pos - sect_start; unsigned int offset = pos - sect_start;
unsigned int size = sect_size - offset; unsigned int size = sect_size - offset;
if( size > len ) if( size > len )
size = len; size = len;
if (size == sect_size) { if (size == sect_size) {
/* /*
* We are covering a whole sector. Thus there is no * We are covering a whole sector. Thus there is no
* need to bother with the cache while it may still be * need to bother with the cache while it may still be
* useful for other partial writes. * useful for other partial writes.
...@@ -160,7 +160,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -160,7 +160,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
if (mtdblk->cache_state == STATE_DIRTY && if (mtdblk->cache_state == STATE_DIRTY &&
mtdblk->cache_offset != sect_start) { mtdblk->cache_offset != sect_start) {
ret = write_cached_data(mtdblk); ret = write_cached_data(mtdblk);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -193,7 +193,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -193,7 +193,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
} }
static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
int len, char *buf) int len, char *buf)
{ {
struct mtd_info *mtd = mtdblk->mtd; struct mtd_info *mtd = mtdblk->mtd;
...@@ -201,9 +201,9 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -201,9 +201,9 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
size_t retlen; size_t retlen;
int ret; int ret;
DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n", DEBUG(MTD_DEBUG_LEVEL2, "mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
mtd->name, pos, len); mtd->name, pos, len);
if (!sect_size) if (!sect_size)
return MTD_READ (mtd, pos, len, &retlen, buf); return MTD_READ (mtd, pos, len, &retlen, buf);
...@@ -211,7 +211,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -211,7 +211,7 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
unsigned long sect_start = (pos/sect_size)*sect_size; unsigned long sect_start = (pos/sect_size)*sect_size;
unsigned int offset = pos - sect_start; unsigned int offset = pos - sect_start;
unsigned int size = sect_size - offset; unsigned int size = sect_size - offset;
if (size > len) if (size > len)
size = len; size = len;
/* /*
...@@ -269,12 +269,12 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) ...@@ -269,12 +269,12 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
int dev = mbd->devnum; int dev = mbd->devnum;
DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n"); DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n");
if (mtdblks[dev]) { if (mtdblks[dev]) {
mtdblks[dev]->count++; mtdblks[dev]->count++;
return 0; return 0;
} }
/* OK, it's not open. Create cache info for it */ /* OK, it's not open. Create cache info for it */
mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
if (!mtdblk) if (!mtdblk)
...@@ -293,7 +293,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) ...@@ -293,7 +293,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
} }
mtdblks[dev] = mtdblk; mtdblks[dev] = mtdblk;
DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
return 0; return 0;
...@@ -321,7 +321,7 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd) ...@@ -321,7 +321,7 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
return 0; return 0;
} }
static int mtdblock_flush(struct mtd_blktrans_dev *dev) static int mtdblock_flush(struct mtd_blktrans_dev *dev)
{ {
......
/* /*
* $Id: mtdchar.c,v 1.75 2005/11/06 10:04:37 gleixner Exp $ * $Id: mtdchar.c,v 1.76 2005/11/07 11:14:20 gleixner Exp $
* *
* Character-device access to raw MTD devices. * Character-device access to raw MTD devices.
* *
...@@ -28,7 +28,7 @@ static void mtd_notify_add(struct mtd_info* mtd) ...@@ -28,7 +28,7 @@ static void mtd_notify_add(struct mtd_info* mtd)
class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
NULL, "mtd%d", mtd->index); NULL, "mtd%d", mtd->index);
class_device_create(mtd_class, NULL, class_device_create(mtd_class, NULL,
MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
NULL, "mtd%dro", mtd->index); NULL, "mtd%dro", mtd->index);
...@@ -108,23 +108,23 @@ static int mtd_open(struct inode *inode, struct file *file) ...@@ -108,23 +108,23 @@ static int mtd_open(struct inode *inode, struct file *file)
return -EACCES; return -EACCES;
mtd = get_mtd_device(NULL, devnum); mtd = get_mtd_device(NULL, devnum);
if (!mtd) if (!mtd)
return -ENODEV; return -ENODEV;
if (MTD_ABSENT == mtd->type) { if (MTD_ABSENT == mtd->type) {
put_mtd_device(mtd); put_mtd_device(mtd);
return -ENODEV; return -ENODEV;
} }
file->private_data = mtd; file->private_data = mtd;
/* You can't open it RW if it's not a writeable device */ /* You can't open it RW if it's not a writeable device */
if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
put_mtd_device(mtd); put_mtd_device(mtd);
return -EACCES; return -EACCES;
} }
return 0; return 0;
} /* mtd_open */ } /* mtd_open */
...@@ -137,10 +137,10 @@ static int mtd_close(struct inode *inode, struct file *file) ...@@ -137,10 +137,10 @@ static int mtd_close(struct inode *inode, struct file *file)
DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n"); DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
mtd = TO_MTD(file); mtd = TO_MTD(file);
if (mtd->sync) if (mtd->sync)
mtd->sync(mtd); mtd->sync(mtd);
put_mtd_device(mtd); put_mtd_device(mtd);
return 0; return 0;
...@@ -159,7 +159,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -159,7 +159,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
int ret=0; int ret=0;
int len; int len;
char *kbuf; char *kbuf;
DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n"); DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n");
if (*ppos + count > mtd->size) if (*ppos + count > mtd->size)
...@@ -167,11 +167,11 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -167,11 +167,11 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
if (!count) if (!count)
return 0; return 0;
/* FIXME: Use kiovec in 2.5 to lock down the user's buffers /* FIXME: Use kiovec in 2.5 to lock down the user's buffers
and pass them directly to the MTD functions */ and pass them directly to the MTD functions */
while (count) { while (count) {
if (count > MAX_KMALLOC_SIZE) if (count > MAX_KMALLOC_SIZE)
len = MAX_KMALLOC_SIZE; len = MAX_KMALLOC_SIZE;
else else
len = count; len = count;
...@@ -179,7 +179,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -179,7 +179,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
kbuf=kmalloc(len,GFP_KERNEL); kbuf=kmalloc(len,GFP_KERNEL);
if (!kbuf) if (!kbuf)
return -ENOMEM; return -ENOMEM;
switch (MTD_MODE(file)) { switch (MTD_MODE(file)) {
case MTD_MODE_OTP_FACT: case MTD_MODE_OTP_FACT:
ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf); ret = mtd->read_fact_prot_reg(mtd, *ppos, len, &retlen, kbuf);
...@@ -192,7 +192,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -192,7 +192,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
} }
/* Nand returns -EBADMSG on ecc errors, but it returns /* Nand returns -EBADMSG on ecc errors, but it returns
* the data. For our userspace tools it is important * the data. For our userspace tools it is important
* to dump areas with ecc errors ! * to dump areas with ecc errors !
* Userspace software which accesses NAND this way * Userspace software which accesses NAND this way
* must be aware of the fact that it deals with NAND * must be aware of the fact that it deals with NAND
*/ */
...@@ -214,7 +214,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t ...@@ -214,7 +214,7 @@ static ssize_t mtd_read(struct file *file, char __user *buf, size_t count,loff_t
kfree(kbuf); kfree(kbuf);
return ret; return ret;
} }
kfree(kbuf); kfree(kbuf);
} }
...@@ -231,10 +231,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -231,10 +231,10 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
int len; int len;
DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n"); DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n");
if (*ppos == mtd->size) if (*ppos == mtd->size)
return -ENOSPC; return -ENOSPC;
if (*ppos + count > mtd->size) if (*ppos + count > mtd->size)
count = mtd->size - *ppos; count = mtd->size - *ppos;
...@@ -242,7 +242,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -242,7 +242,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
return 0; return 0;
while (count) { while (count) {
if (count > MAX_KMALLOC_SIZE) if (count > MAX_KMALLOC_SIZE)
len = MAX_KMALLOC_SIZE; len = MAX_KMALLOC_SIZE;
else else
len = count; len = count;
...@@ -257,7 +257,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -257,7 +257,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
kfree(kbuf); kfree(kbuf);
return -EFAULT; return -EFAULT;
} }
switch (MTD_MODE(file)) { switch (MTD_MODE(file)) {
case MTD_MODE_OTP_FACT: case MTD_MODE_OTP_FACT:
ret = -EROFS; ret = -EROFS;
...@@ -282,7 +282,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count ...@@ -282,7 +282,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
kfree(kbuf); kfree(kbuf);
return ret; return ret;
} }
kfree(kbuf); kfree(kbuf);
} }
...@@ -306,7 +306,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -306,7 +306,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int ret = 0; int ret = 0;
u_long size; u_long size;
DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n"); DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n");
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
...@@ -318,7 +318,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -318,7 +318,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
if (!access_ok(VERIFY_WRITE, argp, size)) if (!access_ok(VERIFY_WRITE, argp, size))
return -EFAULT; return -EFAULT;
} }
switch (cmd) { switch (cmd) {
case MEMGETREGIONCOUNT: case MEMGETREGIONCOUNT:
if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int))) if (copy_to_user(argp, &(mtd->numeraseregions), sizeof(int)))
...@@ -370,11 +370,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -370,11 +370,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
erase->mtd = mtd; erase->mtd = mtd;
erase->callback = mtdchar_erase_callback; erase->callback = mtdchar_erase_callback;
erase->priv = (unsigned long)&waitq; erase->priv = (unsigned long)&waitq;
/* /*
FIXME: Allow INTERRUPTIBLE. Which means FIXME: Allow INTERRUPTIBLE. Which means
not having the wait_queue head on the stack. not having the wait_queue head on the stack.
If the wq_head is on the stack, and we If the wq_head is on the stack, and we
leave because we got interrupted, then the leave because we got interrupted, then the
wq_head is no longer there when the wq_head is no longer there when the
...@@ -402,13 +402,13 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -402,13 +402,13 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
struct mtd_oob_buf buf; struct mtd_oob_buf buf;
void *databuf; void *databuf;
ssize_t retlen; ssize_t retlen;
if(!(file->f_mode & 2)) if(!(file->f_mode & 2))
return -EPERM; return -EPERM;
if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT; return -EFAULT;
if (buf.length > 0x4096) if (buf.length > 0x4096)
return -EINVAL; return -EINVAL;
...@@ -424,7 +424,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -424,7 +424,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
databuf = kmalloc(buf.length, GFP_KERNEL); databuf = kmalloc(buf.length, GFP_KERNEL);
if (!databuf) if (!databuf)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(databuf, buf.ptr, buf.length)) { if (copy_from_user(databuf, buf.ptr, buf.length)) {
kfree(databuf); kfree(databuf);
return -EFAULT; return -EFAULT;
...@@ -448,7 +448,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -448,7 +448,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf))) if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
return -EFAULT; return -EFAULT;
if (buf.length > 0x4096) if (buf.length > 0x4096)
return -EINVAL; return -EINVAL;
...@@ -464,14 +464,14 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -464,14 +464,14 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
databuf = kmalloc(buf.length, GFP_KERNEL); databuf = kmalloc(buf.length, GFP_KERNEL);
if (!databuf) if (!databuf)
return -ENOMEM; return -ENOMEM;
ret = (mtd->read_oob)(mtd, buf.start, buf.length, &retlen, databuf); ret = (mtd->read_oob)(mtd, buf.start, buf.length, &retlen, databuf);
if (put_user(retlen, (uint32_t __user *)argp)) if (put_user(retlen, (uint32_t __user *)argp))
ret = -EFAULT; ret = -EFAULT;
else if (retlen && copy_to_user(buf.ptr, databuf, retlen)) else if (retlen && copy_to_user(buf.ptr, databuf, retlen))
ret = -EFAULT; ret = -EFAULT;
kfree(databuf); kfree(databuf);
break; break;
} }
...@@ -521,7 +521,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, ...@@ -521,7 +521,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
case MEMGETBADBLOCK: case MEMGETBADBLOCK:
{ {
loff_t offs; loff_t offs;
if (copy_from_user(&offs, argp, sizeof(loff_t))) if (copy_from_user(&offs, argp, sizeof(loff_t)))
return -EFAULT; return -EFAULT;
if (!mtd->block_isbad) if (!mtd->block_isbad)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* This code is GPL * This code is GPL
* *
* $Id: mtdconcat.c,v 1.10 2005/11/06 10:04:37 gleixner Exp $ * $Id: mtdconcat.c,v 1.11 2005/11/07 11:14:20 gleixner Exp $
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -44,7 +44,7 @@ struct mtd_concat { ...@@ -44,7 +44,7 @@ struct mtd_concat {
*/ */
#define CONCAT(x) ((struct mtd_concat *)(x)) #define CONCAT(x) ((struct mtd_concat *)(x))
/* /*
* MTD methods which look up the relevant subdevice, translate the * MTD methods which look up the relevant subdevice, translate the
* effective address and pass through to the subdevice. * effective address and pass through to the subdevice.
*/ */
...@@ -878,7 +878,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c ...@@ -878,7 +878,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
return &concat->mtd; return &concat->mtd;
} }
/* /*
* This function destroys an MTD object obtained from concat_mtd_devs() * This function destroys an MTD object obtained from concat_mtd_devs()
*/ */
......
/* /*
* $Id: mtdcore.c,v 1.46 2005/08/11 17:13:43 gleixner Exp $ * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $
* *
* Core registration and callback routines for MTD * Core registration and callback routines for MTD
* drivers and users. * drivers and users.
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
/* These are exported solely for the purpose of mtd_blkdevs.c. You /* These are exported solely for the purpose of mtd_blkdevs.c. You
should not use them for _anything_ else */ should not use them for _anything_ else */
DECLARE_MUTEX(mtd_table_mutex); DECLARE_MUTEX(mtd_table_mutex);
struct mtd_info *mtd_table[MAX_MTD_DEVICES]; struct mtd_info *mtd_table[MAX_MTD_DEVICES];
...@@ -66,7 +66,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -66,7 +66,7 @@ int add_mtd_device(struct mtd_info *mtd)
struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list); struct mtd_notifier *not = list_entry(this, struct mtd_notifier, list);
not->add(mtd); not->add(mtd);
} }
up(&mtd_table_mutex); up(&mtd_table_mutex);
/* We _know_ we aren't being removed, because /* We _know_ we aren't being removed, because
our caller is still holding us here. So none our caller is still holding us here. So none
...@@ -75,7 +75,7 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -75,7 +75,7 @@ int add_mtd_device(struct mtd_info *mtd)
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
return 0; return 0;
} }
up(&mtd_table_mutex); up(&mtd_table_mutex);
return 1; return 1;
} }
...@@ -93,13 +93,13 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -93,13 +93,13 @@ int add_mtd_device(struct mtd_info *mtd)
int del_mtd_device (struct mtd_info *mtd) int del_mtd_device (struct mtd_info *mtd)
{ {
int ret; int ret;
down(&mtd_table_mutex); down(&mtd_table_mutex);
if (mtd_table[mtd->index] != mtd) { if (mtd_table[mtd->index] != mtd) {
ret = -ENODEV; ret = -ENODEV;
} else if (mtd->usecount) { } else if (mtd->usecount) {
printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
mtd->index, mtd->name, mtd->usecount); mtd->index, mtd->name, mtd->usecount);
ret = -EBUSY; ret = -EBUSY;
} else { } else {
...@@ -140,7 +140,7 @@ void register_mtd_user (struct mtd_notifier *new) ...@@ -140,7 +140,7 @@ void register_mtd_user (struct mtd_notifier *new)
list_add(&new->list, &mtd_notifiers); list_add(&new->list, &mtd_notifiers);
__module_get(THIS_MODULE); __module_get(THIS_MODULE);
for (i=0; i< MAX_MTD_DEVICES; i++) for (i=0; i< MAX_MTD_DEVICES; i++)
if (mtd_table[i]) if (mtd_table[i])
new->add(mtd_table[i]); new->add(mtd_table[i]);
...@@ -169,7 +169,7 @@ int unregister_mtd_user (struct mtd_notifier *old) ...@@ -169,7 +169,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
for (i=0; i< MAX_MTD_DEVICES; i++) for (i=0; i< MAX_MTD_DEVICES; i++)
if (mtd_table[i]) if (mtd_table[i])
old->remove(mtd_table[i]); old->remove(mtd_table[i]);
list_del(&old->list); list_del(&old->list);
up(&mtd_table_mutex); up(&mtd_table_mutex);
return 0; return 0;
...@@ -187,7 +187,7 @@ int unregister_mtd_user (struct mtd_notifier *old) ...@@ -187,7 +187,7 @@ int unregister_mtd_user (struct mtd_notifier *old)
* both, return the num'th driver only if its address matches. Return NULL * both, return the num'th driver only if its address matches. Return NULL
* if not. * if not.
*/ */
struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
{ {
struct mtd_info *ret = NULL; struct mtd_info *ret = NULL;
......
This diff is collapsed.
This diff is collapsed.
/* /*
* NFTL mount code with extensive checks * NFTL mount code with extensive checks
* *
* Author: Fabrice Bellard (fabrice.bellard@netgem.com) * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
* Copyright (C) 2000 Netgem S.A. * Copyright (C) 2000 Netgem S.A.
* *
* $Id: nftlmount.c,v 1.40 2004/11/22 14:38:29 kalev Exp $ * $Id: nftlmount.c,v 1.41 2005/11/07 11:14:21 gleixner Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define SECTORSIZE 512 #define SECTORSIZE 512
char nftlmountrev[]="$Revision: 1.40 $"; char nftlmountrev[]="$Revision: 1.41 $";
/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the /* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
* various device information of the NFTL partition and Bad Unit Table. Update * various device information of the NFTL partition and Bad Unit Table. Update
...@@ -47,7 +47,7 @@ static int find_boot_record(struct NFTLrecord *nftl) ...@@ -47,7 +47,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
struct NFTLMediaHeader *mh = &nftl->MediaHdr; struct NFTLMediaHeader *mh = &nftl->MediaHdr;
unsigned int i; unsigned int i;
/* Assume logical EraseSize == physical erasesize for starting the scan. /* Assume logical EraseSize == physical erasesize for starting the scan.
We'll sort it out later if we find a MediaHeader which says otherwise */ We'll sort it out later if we find a MediaHeader which says otherwise */
/* Actually, we won't. The new DiskOnChip driver has already scanned /* Actually, we won't. The new DiskOnChip driver has already scanned
the MediaHeader and adjusted the virtual erasesize it presents in the MediaHeader and adjusted the virtual erasesize it presents in
...@@ -83,9 +83,9 @@ static int find_boot_record(struct NFTLrecord *nftl) ...@@ -83,9 +83,9 @@ static int find_boot_record(struct NFTLrecord *nftl)
if (retlen < 6 || memcmp(buf, "ANAND", 6)) { if (retlen < 6 || memcmp(buf, "ANAND", 6)) {
/* ANAND\0 not found. Continue */ /* ANAND\0 not found. Continue */
#if 0 #if 0
printk(KERN_DEBUG "ANAND header not found at 0x%x in mtd%d\n", printk(KERN_DEBUG "ANAND header not found at 0x%x in mtd%d\n",
block * nftl->EraseSize, nftl->mbd.mtd->index); block * nftl->EraseSize, nftl->mbd.mtd->index);
#endif #endif
continue; continue;
} }
...@@ -103,7 +103,7 @@ static int find_boot_record(struct NFTLrecord *nftl) ...@@ -103,7 +103,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
*/ */
if (le16_to_cpu(h1.EraseMark | h1.EraseMark1) != ERASE_MARK) { if (le16_to_cpu(h1.EraseMark | h1.EraseMark1) != ERASE_MARK) {
printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n", printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but erase mark not present (0x%04x,0x%04x instead)\n",
block * nftl->EraseSize, nftl->mbd.mtd->index, block * nftl->EraseSize, nftl->mbd.mtd->index,
le16_to_cpu(h1.EraseMark), le16_to_cpu(h1.EraseMark1)); le16_to_cpu(h1.EraseMark), le16_to_cpu(h1.EraseMark1));
continue; continue;
} }
...@@ -175,7 +175,7 @@ device is already correct. ...@@ -175,7 +175,7 @@ device is already correct.
nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) { if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) {
printk(KERN_NOTICE "NFTL Media Header sanity check failed:\n"); printk(KERN_NOTICE "NFTL Media Header sanity check failed:\n");
printk(KERN_NOTICE "nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n", printk(KERN_NOTICE "nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n",
nftl->nb_boot_blocks, nftl->nb_blocks); nftl->nb_boot_blocks, nftl->nb_blocks);
return -1; return -1;
} }
...@@ -187,7 +187,7 @@ device is already correct. ...@@ -187,7 +187,7 @@ device is already correct.
nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks); nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks);
return -1; return -1;
} }
nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE); nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE);
/* If we're not using the last sectors in the device for some reason, /* If we're not using the last sectors in the device for some reason,
...@@ -210,12 +210,12 @@ device is already correct. ...@@ -210,12 +210,12 @@ device is already correct.
printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n"); printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n");
return -ENOMEM; return -ENOMEM;
} }
/* mark the bios blocks (blocks before NFTL MediaHeader) as reserved */ /* mark the bios blocks (blocks before NFTL MediaHeader) as reserved */
for (i = 0; i < nftl->nb_boot_blocks; i++) for (i = 0; i < nftl->nb_boot_blocks; i++)
nftl->ReplUnitTable[i] = BLOCK_RESERVED; nftl->ReplUnitTable[i] = BLOCK_RESERVED;
/* mark all remaining blocks as potentially containing data */ /* mark all remaining blocks as potentially containing data */
for (; i < nftl->nb_blocks; i++) { for (; i < nftl->nb_blocks; i++) {
nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED; nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED;
} }
...@@ -245,12 +245,12 @@ The new DiskOnChip driver already scanned the bad block table. Just query it. ...@@ -245,12 +245,12 @@ The new DiskOnChip driver already scanned the bad block table. Just query it.
if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize)) if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize))
nftl->ReplUnitTable[i] = BLOCK_RESERVED; nftl->ReplUnitTable[i] = BLOCK_RESERVED;
} }
nftl->MediaUnit = block; nftl->MediaUnit = block;
boot_record_count++; boot_record_count++;
} /* foreach (block) */ } /* foreach (block) */
return boot_record_count?0:-1; return boot_record_count?0:-1;
} }
...@@ -265,7 +265,7 @@ static int memcmpb(void *a, int c, int n) ...@@ -265,7 +265,7 @@ static int memcmpb(void *a, int c, int n)
} }
/* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area */ /* check_free_sector: check if a free sector is actually FREE, i.e. All 0xff in data and oob area */
static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len, static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len,
int check_oob) int check_oob)
{ {
int i; int i;
...@@ -293,7 +293,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int ...@@ -293,7 +293,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int
* *
* Return: 0 when succeed, -1 on error. * Return: 0 when succeed, -1 on error.
* *
* ToDo: 1. Is it neceressary to check_free_sector after erasing ?? * ToDo: 1. Is it neceressary to check_free_sector after erasing ??
*/ */
int NFTL_formatblock(struct NFTLrecord *nftl, int block) int NFTL_formatblock(struct NFTLrecord *nftl, int block)
{ {
...@@ -385,7 +385,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b ...@@ -385,7 +385,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_b
/* verify that the sector is really free. If not, mark /* verify that the sector is really free. If not, mark
as ignore */ as ignore */
if (memcmpb(&bci, 0xff, 8) != 0 || if (memcmpb(&bci, 0xff, 8) != 0 ||
check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE, check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE,
SECTORSIZE, 0) != 0) { SECTORSIZE, 0) != 0) {
printk("Incorrect free sector %d in block %d: " printk("Incorrect free sector %d in block %d: "
"marking it as ignored\n", "marking it as ignored\n",
...@@ -486,7 +486,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) ...@@ -486,7 +486,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
size_t retlen; size_t retlen;
/* check erase mark. */ /* check erase mark. */
if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, if (MTD_READOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
&retlen, (char *)&h1) < 0) &retlen, (char *)&h1) < 0)
return -1; return -1;
...@@ -501,7 +501,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) ...@@ -501,7 +501,7 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
h1.EraseMark = cpu_to_le16(ERASE_MARK); h1.EraseMark = cpu_to_le16(ERASE_MARK);
h1.EraseMark1 = cpu_to_le16(ERASE_MARK); h1.EraseMark1 = cpu_to_le16(ERASE_MARK);
h1.WearInfo = cpu_to_le32(0); h1.WearInfo = cpu_to_le32(0);
if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, if (MTD_WRITEOOB(nftl->mbd.mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
&retlen, (char *)&h1) < 0) &retlen, (char *)&h1) < 0)
return -1; return -1;
} else { } else {
...@@ -582,9 +582,9 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -582,9 +582,9 @@ int NFTL_mount(struct NFTLrecord *s)
for (;;) { for (;;) {
/* read the block header. If error, we format the chain */ /* read the block header. If error, we format the chain */
if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8, 8, if (MTD_READOOB(s->mbd.mtd, block * s->EraseSize + 8, 8,
&retlen, (char *)&h0) < 0 || &retlen, (char *)&h0) < 0 ||
MTD_READOOB(s->mbd.mtd, block * s->EraseSize + SECTORSIZE + 8, 8, MTD_READOOB(s->mbd.mtd, block * s->EraseSize + SECTORSIZE + 8, 8,
&retlen, (char *)&h1) < 0) { &retlen, (char *)&h1) < 0) {
s->ReplUnitTable[block] = BLOCK_NIL; s->ReplUnitTable[block] = BLOCK_NIL;
do_format_chain = 1; do_format_chain = 1;
...@@ -639,7 +639,7 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -639,7 +639,7 @@ int NFTL_mount(struct NFTLrecord *s)
first_logical_block = logical_block; first_logical_block = logical_block;
} else { } else {
if (logical_block != first_logical_block) { if (logical_block != first_logical_block) {
printk("Block %d: incorrect logical block: %d expected: %d\n", printk("Block %d: incorrect logical block: %d expected: %d\n",
block, logical_block, first_logical_block); block, logical_block, first_logical_block);
/* the chain is incorrect : we must format it, /* the chain is incorrect : we must format it,
but we need to read it completly */ but we need to read it completly */
...@@ -668,7 +668,7 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -668,7 +668,7 @@ int NFTL_mount(struct NFTLrecord *s)
s->ReplUnitTable[block] = BLOCK_NIL; s->ReplUnitTable[block] = BLOCK_NIL;
break; break;
} else if (rep_block >= s->nb_blocks) { } else if (rep_block >= s->nb_blocks) {
printk("Block %d: referencing invalid block %d\n", printk("Block %d: referencing invalid block %d\n",
block, rep_block); block, rep_block);
do_format_chain = 1; do_format_chain = 1;
s->ReplUnitTable[block] = BLOCK_NIL; s->ReplUnitTable[block] = BLOCK_NIL;
...@@ -688,7 +688,7 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -688,7 +688,7 @@ int NFTL_mount(struct NFTLrecord *s)
s->ReplUnitTable[block] = rep_block; s->ReplUnitTable[block] = rep_block;
s->EUNtable[first_logical_block] = BLOCK_NIL; s->EUNtable[first_logical_block] = BLOCK_NIL;
} else { } else {
printk("Block %d: referencing block %d already in another chain\n", printk("Block %d: referencing block %d already in another chain\n",
block, rep_block); block, rep_block);
/* XXX: should handle correctly fold in progress chains */ /* XXX: should handle correctly fold in progress chains */
do_format_chain = 1; do_format_chain = 1;
...@@ -710,7 +710,7 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -710,7 +710,7 @@ int NFTL_mount(struct NFTLrecord *s)
} else { } else {
unsigned int first_block1, chain_to_format, chain_length1; unsigned int first_block1, chain_to_format, chain_length1;
int fold_mark; int fold_mark;
/* valid chain : get foldmark */ /* valid chain : get foldmark */
fold_mark = get_fold_mark(s, first_block); fold_mark = get_fold_mark(s, first_block);
if (fold_mark == 0) { if (fold_mark == 0) {
...@@ -729,9 +729,9 @@ int NFTL_mount(struct NFTLrecord *s) ...@@ -729,9 +729,9 @@ int NFTL_mount(struct NFTLrecord *s)
if (first_block1 != BLOCK_NIL) { if (first_block1 != BLOCK_NIL) {
/* XXX: what to do if same length ? */ /* XXX: what to do if same length ? */
chain_length1 = calc_chain_length(s, first_block1); chain_length1 = calc_chain_length(s, first_block1);
printk("Two chains at blocks %d (len=%d) and %d (len=%d)\n", printk("Two chains at blocks %d (len=%d) and %d (len=%d)\n",
first_block1, chain_length1, first_block, chain_length); first_block1, chain_length1, first_block, chain_length);
if (chain_length >= chain_length1) { if (chain_length >= chain_length1) {
chain_to_format = first_block1; chain_to_format = first_block1;
s->EUNtable[first_logical_block] = first_block; s->EUNtable[first_logical_block] = first_block;
......
/* /*
* $Id: redboot.c,v 1.17 2004/11/22 11:33:56 ijc Exp $ * $Id: redboot.c,v 1.18 2005/11/07 11:14:21 gleixner Exp $
* *
* Parse RedBoot-style Flash Image System (FIS) tables and * Parse RedBoot-style Flash Image System (FIS) tables and
* produce a Linux partition array to match. * produce a Linux partition array to match.
...@@ -39,7 +39,7 @@ static inline int redboot_checksum(struct fis_image_desc *img) ...@@ -39,7 +39,7 @@ static inline int redboot_checksum(struct fis_image_desc *img)
return 1; return 1;
} }
static int parse_redboot_partitions(struct mtd_info *master, static int parse_redboot_partitions(struct mtd_info *master,
struct mtd_partition **pparts, struct mtd_partition **pparts,
unsigned long fis_origin) unsigned long fis_origin)
{ {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment