Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
xcap
xcap-capability-linux
Commits
97894cda
Commit
97894cda
authored
Nov 07, 2005
by
Thomas Gleixner
Committed by
Thomas Gleixner
Nov 07, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MTD] core: Clean up trailing white spaces
Signed-off-by:
Thomas Gleixner
<
tglx@linutronix.de
>
parent
b95f9609
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
399 additions
and
399 deletions
+399
-399
drivers/mtd/Kconfig
drivers/mtd/Kconfig
+16
-16
drivers/mtd/afs.c
drivers/mtd/afs.c
+8
-8
drivers/mtd/cmdlinepart.c
drivers/mtd/cmdlinepart.c
+28
-28
drivers/mtd/ftl.c
drivers/mtd/ftl.c
+64
-64
drivers/mtd/inftlcore.c
drivers/mtd/inftlcore.c
+24
-24
drivers/mtd/inftlmount.c
drivers/mtd/inftlmount.c
+10
-10
drivers/mtd/mtd_blkdevs.c
drivers/mtd/mtd_blkdevs.c
+12
-12
drivers/mtd/mtdblock.c
drivers/mtd/mtdblock.c
+22
-22
drivers/mtd/mtdchar.c
drivers/mtd/mtdchar.c
+30
-30
drivers/mtd/mtdconcat.c
drivers/mtd/mtdconcat.c
+3
-3
drivers/mtd/mtdcore.c
drivers/mtd/mtdcore.c
+9
-9
drivers/mtd/mtdpart.c
drivers/mtd/mtdpart.c
+46
-46
drivers/mtd/nftlcore.c
drivers/mtd/nftlcore.c
+40
-40
drivers/mtd/nftlmount.c
drivers/mtd/nftlmount.c
+28
-28
drivers/mtd/redboot.c
drivers/mtd/redboot.c
+2
-2
drivers/mtd/rfd_ftl.c
drivers/mtd/rfd_ftl.c
+57
-57
No files found.
drivers/mtd/Kconfig
View file @
97894cda
# $Id: Kconfig,v 1.1
0
2005/07
/
11
10:39:27
gleixner Exp $
# $Id: Kconfig,v 1.1
1
2005/
11/
07
11
:14:19
gleixner Exp $
menu "Memory Technology Devices (MTD)"
...
...
@@ -10,7 +10,7 @@ config MTD
will provide the generic support for MTD drivers to register
themselves with the kernel and for potential users of MTD devices
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.
config MTD_DEBUG
...
...
@@ -61,11 +61,11 @@ config MTD_REDBOOT_PARTS
If you need code which can detect and parse this table, and register
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
for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example.
config MTD_REDBOOT_DIRECTORY_BLOCK
...
...
@@ -81,10 +81,10 @@ config MTD_REDBOOT_DIRECTORY_BLOCK
partition table. A zero or positive value gives an absolete
erase block number. A negative value specifies a number of
sectors before the end of the device.
For example "2" means block number 2, "-1" means the last
block and "-2" means the penultimate block.
config MTD_REDBOOT_PARTS_UNALLOCATED
bool " Include unallocated flash regions"
depends on MTD_REDBOOT_PARTS
...
...
@@ -105,11 +105,11 @@ config MTD_CMDLINE_PARTS
---help---
Allow generic configuration of the MTD paritition tables via the kernel
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
for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
for your particular device. It won't happen automatically. The
SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for
example.
The format for the command line is as follows:
...
...
@@ -118,12 +118,12 @@ config MTD_CMDLINE_PARTS
<mtddef> := <mtd-id>:<partdef>[,<partdef>]
<partdef> := <size>[@offset][<name>][ro]
<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
<name> := (NAME)
Due to the way Linux handles the command line, no spaces are
allowed in the partition definition, including mtd id's and partition
Due to the way Linux handles the command line, no spaces are
allowed in the partition definition, including mtd id's and partition
names.
Examples:
...
...
@@ -240,7 +240,7 @@ config INFTL
tristate "INFTL (Inverse NAND Flash Translation Layer) support"
depends on MTD
---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
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
...
...
@@ -257,8 +257,8 @@ config RFD_FTL
tristate "Resident Flash Disk (Flash Translation Layer) support"
depends on MTD
---help---
This provides support for the flash translation layer known
as the Resident Flash Disk (RFD), as used by the Embedded BIOS
This provides support for the flash translation layer known
as the Resident Flash Disk (RFD), as used by the Embedded BIOS
of General Software. There is a blurb at:
http://www.gensw.com/pages/prod/bios/rfd.htm
...
...
drivers/mtd/afs.c
View file @
97894cda
/*======================================================================
drivers/mtd/afs.c: ARM Flash Layout/Partitioning
Copyright (C) 2000 ARM Limited
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
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.
$Id: afs.c,v 1.1
3
200
4/02/27 22:09:59 rmk
Exp $
$Id: afs.c,v 1.1
5
200
5/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)
return
ret
;
}
static
int
parse_afs_partitions
(
struct
mtd_info
*
mtd
,
static
int
parse_afs_partitions
(
struct
mtd_info
*
mtd
,
struct
mtd_partition
**
pparts
,
unsigned
long
origin
)
{
...
...
drivers/mtd/cmdlinepart.c
View file @
97894cda
/*
* $Id: cmdlinepart.c,v 1.1
8
2005/
06
/07 1
5:04:26 jo
er
n
Exp $
* $Id: cmdlinepart.c,v 1.1
9
2005/
11
/07 1
1:14:19 gleixn
er Exp $
*
* Read flash partition table from command line
*
* Copyright 2002 SYSGO Real-Time Solutions GmbH
*
* The format for the command line is as follows:
*
*
* mtdparts=<mtddef>[;<mtddef]
* <mtddef> := <mtd-id>:<partdef>[,<partdef>]
* <partdef> := <size>[@offset][<name>][ro]
* <mtd-id> := unique name used in mapping driver/device (mtd->name)
* <size> := standard linux memsize OR "-" to denote all remaining space
* <name> := '(' NAME ')'
*
*
* Examples:
*
*
* 1 NOR Flash, with 1 single writable partition:
* edb7312-nor:-
*
*
* 1 NOR Flash with 2 partitions, 1 NAND with one
* edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
*/
...
...
@@ -60,17 +60,17 @@ static int cmdline_parsed = 0;
/*
* 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
* effect: the memory to keep the mtd_partition structs and the names
* is allocated upon the last definition being found. At that point the
* syntax has been verified ok.
*/
static
struct
mtd_partition
*
newpart
(
char
*
s
,
static
struct
mtd_partition
*
newpart
(
char
*
s
,
char
**
retptr
,
int
*
num_parts
,
int
this_part
,
unsigned
char
**
extra_mem_ptr
,
int
this_part
,
unsigned
char
**
extra_mem_ptr
,
int
extra_mem_size
)
{
struct
mtd_partition
*
parts
;
...
...
@@ -102,7 +102,7 @@ static struct mtd_partition * newpart(char *s,
mask_flags
=
0
;
/* this is going to be a regular partition */
delim
=
0
;
/* check for offset */
if
(
*
s
==
'@'
)
if
(
*
s
==
'@'
)
{
s
++
;
offset
=
memparse
(
s
,
&
s
);
...
...
@@ -112,7 +112,7 @@ static struct mtd_partition * newpart(char *s,
{
delim
=
')'
;
}
if
(
delim
)
{
char
*
p
;
...
...
@@ -131,12 +131,12 @@ static struct mtd_partition * newpart(char *s,
name
=
NULL
;
name_len
=
13
;
/* Partition_000 */
}
/* record name length for memory allocation later */
extra_mem_size
+=
name_len
+
1
;
/* test for options */
if
(
strncmp
(
s
,
"ro"
,
2
)
==
0
)
if
(
strncmp
(
s
,
"ro"
,
2
)
==
0
)
{
mask_flags
|=
MTD_WRITEABLE
;
s
+=
2
;
...
...
@@ -151,7 +151,7 @@ static struct mtd_partition * newpart(char *s,
return
NULL
;
}
/* 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
)
return
NULL
;
}
...
...
@@ -187,7 +187,7 @@ static struct mtd_partition * newpart(char *s,
extra_mem
+=
name_len
+
1
;
dbg
((
"partition %d: name <%s>, offset %x, size %x, mask flags %x
\n
"
,
this_part
,
this_part
,
parts
[
this_part
].
name
,
parts
[
this_part
].
offset
,
parts
[
this_part
].
size
,
...
...
@@ -204,8 +204,8 @@ static struct mtd_partition * newpart(char *s,
return
parts
;
}
/*
* Parse the command line.
/*
* Parse the command line.
*/
static
int
mtdpart_setup_real
(
char
*
s
)
{
...
...
@@ -230,7 +230,7 @@ static int mtdpart_setup_real(char *s)
dbg
((
"parsing <%s>
\n
"
,
p
+
1
));
/*
/*
* parse one mtd. have it reserve memory for the
* struct cmdline_mtd_partition and the mtd-id string.
*/
...
...
@@ -239,7 +239,7 @@ static int mtdpart_setup_real(char *s)
&
num_parts
,
/* out: number of parts */
0
,
/* first partition */
(
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*/
);
if
(
!
parts
)
{
...
...
@@ -254,21 +254,21 @@ static int mtdpart_setup_real(char *s)
}
/* align this_mtd */
this_mtd
=
(
struct
cmdline_mtd_partition
*
)
this_mtd
=
(
struct
cmdline_mtd_partition
*
)
ALIGN
((
unsigned
long
)
this_mtd
,
sizeof
(
void
*
));
/* enter results */
/* enter results */
this_mtd
->
parts
=
parts
;
this_mtd
->
num_parts
=
num_parts
;
this_mtd
->
mtd_id
=
(
char
*
)(
this_mtd
+
1
);
strlcpy
(
this_mtd
->
mtd_id
,
mtd_id
,
mtd_id_len
+
1
);
/* link into chain */
this_mtd
->
next
=
partitions
;
this_mtd
->
next
=
partitions
;
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
));
/* EOS - we're done */
if
(
*
s
==
0
)
...
...
@@ -292,7 +292,7 @@ static int mtdpart_setup_real(char *s)
* information. It returns partitions for the requested mtd device, or
* 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
,
unsigned
long
origin
)
{
...
...
@@ -322,7 +322,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
part
->
parts
[
i
].
size
=
master
->
size
-
offset
;
if
(
offset
+
part
->
parts
[
i
].
size
>
master
->
size
)
{
printk
(
KERN_WARNING
ERRP
printk
(
KERN_WARNING
ERRP
"%s: partitioning exceeds flash size, truncating
\n
"
,
part
->
mtd_id
);
part
->
parts
[
i
].
size
=
master
->
size
-
offset
;
...
...
@@ -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,
* so we only save the commandline for later processing.
*
...
...
drivers/mtd/ftl.c
View file @
97894cda
/* This version ported to the Linux-MTD system by dwmw2@infradead.org
* $Id: ftl.c,v 1.5
5
2005/
0
1/
1
7 1
3:47:21 hv
r Exp $
* $Id: ftl.c,v 1.5
8
2005/
1
1/
0
7 1
1:14:19 gleixne
r Exp $
*
* Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
...
...
@@ -53,7 +53,7 @@
Use of the FTL format for non-PCMCIA applications may be an
infringement of these patents. For additional information,
contact M-Systems (http://www.m-sys.com) directly.
======================================================================*/
#include <linux/mtd/blktrans.h>
#include <linux/module.h>
...
...
@@ -160,7 +160,7 @@ static void ftl_erase_callback(struct erase_info *done);
Scan_header() checks to see if a memory region contains an FTL
partition. build_maps() reads all the erase unit headers, builds
the erase unit map, and then builds the virtual page map.
======================================================================*/
static
int
scan_header
(
partition_t
*
part
)
...
...
@@ -176,10 +176,10 @@ static int scan_header(partition_t *part)
(
offset
+
sizeof
(
header
))
<
max_offset
;
offset
+=
part
->
mbd
.
mtd
->
erasesize
?
:
0x2000
)
{
err
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
header
),
&
ret
,
err
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
header
),
&
ret
,
(
unsigned
char
*
)
&
header
);
if
(
err
)
if
(
err
)
return
err
;
if
(
strcmp
(
header
.
DataOrgTuple
+
3
,
"FTL100"
)
==
0
)
break
;
...
...
@@ -232,10 +232,10 @@ static int build_maps(partition_t *part)
for
(
i
=
0
;
i
<
le16_to_cpu
(
part
->
header
.
NumEraseUnits
);
i
++
)
{
offset
=
((
i
+
le16_to_cpu
(
part
->
header
.
FirstPhysicalEUN
))
<<
part
->
header
.
EraseUnitSize
);
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
header
),
&
retval
,
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
header
),
&
retval
,
(
unsigned
char
*
)
&
header
);
if
(
ret
)
if
(
ret
)
goto
out_XferInfo
;
ret
=
-
1
;
...
...
@@ -274,7 +274,7 @@ static int build_maps(partition_t *part)
"don't add up!
\n
"
);
goto
out_XferInfo
;
}
/* Set up virtual page map */
blocks
=
le32_to_cpu
(
header
.
FormattedSize
)
>>
header
.
BlockSize
;
part
->
VirtualBlockMap
=
vmalloc
(
blocks
*
sizeof
(
u_int32_t
));
...
...
@@ -296,12 +296,12 @@ static int build_maps(partition_t *part)
part
->
EUNInfo
[
i
].
Free
=
0
;
part
->
EUNInfo
[
i
].
Deleted
=
0
;
offset
=
part
->
EUNInfo
[
i
].
Offset
+
le32_to_cpu
(
header
.
BAMOffset
);
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
part
->
BlocksPerUnit
*
sizeof
(
u_int32_t
),
&
retval
,
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
part
->
BlocksPerUnit
*
sizeof
(
u_int32_t
),
&
retval
,
(
unsigned
char
*
)
part
->
bam_cache
);
if
(
ret
)
if
(
ret
)
goto
out_bam_cache
;
for
(
j
=
0
;
j
<
part
->
BlocksPerUnit
;
j
++
)
{
...
...
@@ -316,7 +316,7 @@ static int build_maps(partition_t *part)
part
->
EUNInfo
[
i
].
Deleted
++
;
}
}
ret
=
0
;
goto
out
;
...
...
@@ -336,7 +336,7 @@ out:
Erase_xfer() schedules an asynchronous erase operation for a
transfer unit.
======================================================================*/
static
int
erase_xfer
(
partition_t
*
part
,
...
...
@@ -351,10 +351,10 @@ static int erase_xfer(partition_t *part,
xfer
->
state
=
XFER_ERASING
;
/* Is there a free erase slot? Always in MTD. */
erase
=
kmalloc
(
sizeof
(
struct
erase_info
),
GFP_KERNEL
);
if
(
!
erase
)
if
(
!
erase
)
return
-
ENOMEM
;
erase
->
mtd
=
part
->
mbd
.
mtd
;
...
...
@@ -362,7 +362,7 @@ static int erase_xfer(partition_t *part,
erase
->
addr
=
xfer
->
Offset
;
erase
->
len
=
1
<<
part
->
header
.
EraseUnitSize
;
erase
->
priv
=
(
u_long
)
part
;
ret
=
part
->
mbd
.
mtd
->
erase
(
part
->
mbd
.
mtd
,
erase
);
if
(
!
ret
)
...
...
@@ -377,7 +377,7 @@ static int erase_xfer(partition_t *part,
Prepare_xfer() takes a freshly erased transfer unit and gives
it an appropriate header.
======================================================================*/
static
void
ftl_erase_callback
(
struct
erase_info
*
erase
)
...
...
@@ -385,7 +385,7 @@ static void ftl_erase_callback(struct erase_info *erase)
partition_t
*
part
;
struct
xfer_info_t
*
xfer
;
int
i
;
/* Look up the transfer unit */
part
=
(
partition_t
*
)(
erase
->
priv
);
...
...
@@ -422,7 +422,7 @@ static int prepare_xfer(partition_t *part, int i)
xfer
=
&
part
->
XferInfo
[
i
];
xfer
->
state
=
XFER_FAILED
;
DEBUG
(
1
,
"ftl_cs: preparing xfer unit at 0x%x
\n
"
,
xfer
->
Offset
);
/* Write the transfer unit header */
...
...
@@ -446,7 +446,7 @@ static int prepare_xfer(partition_t *part, int i)
for
(
i
=
0
;
i
<
nbam
;
i
++
,
offset
+=
sizeof
(
u_int32_t
))
{
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
u_int32_t
),
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
u_int32_t
),
&
retlen
,
(
u_char
*
)
&
ctl
);
if
(
ret
)
...
...
@@ -454,7 +454,7 @@ static int prepare_xfer(partition_t *part, int i)
}
xfer
->
state
=
XFER_PREPARED
;
return
0
;
}
/* prepare_xfer */
/*======================================================================
...
...
@@ -466,7 +466,7 @@ static int prepare_xfer(partition_t *part, int i)
All data blocks are copied to the corresponding blocks in the
target unit, so the virtual block map does not need to be
updated.
======================================================================*/
static
int
copy_erase_unit
(
partition_t
*
part
,
u_int16_t
srcunit
,
...
...
@@ -486,14 +486,14 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
xfer
=
&
part
->
XferInfo
[
xferunit
];
DEBUG
(
2
,
"ftl_cs: copying block 0x%x to 0x%x
\n
"
,
eun
->
Offset
,
xfer
->
Offset
);
/* Read current BAM */
if
(
part
->
bam_index
!=
srcunit
)
{
offset
=
eun
->
Offset
+
le32_to_cpu
(
part
->
header
.
BAMOffset
);
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
offset
,
part
->
BlocksPerUnit
*
sizeof
(
u_int32_t
),
&
retlen
,
(
u_char
*
)
(
part
->
bam_cache
));
...
...
@@ -501,11 +501,11 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
part
->
bam_index
=
0xffff
;
if
(
ret
)
{
printk
(
KERN_WARNING
"ftl: Failed to read BAM cache in copy_erase_unit()!
\n
"
);
printk
(
KERN_WARNING
"ftl: Failed to read BAM cache in copy_erase_unit()!
\n
"
);
return
ret
;
}
}
/* Write the LogicalEUN for the transfer unit */
xfer
->
state
=
XFER_UNKNOWN
;
offset
=
xfer
->
Offset
+
20
;
/* Bad! */
...
...
@@ -513,12 +513,12 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
offset
,
sizeof
(
u_int16_t
),
&
retlen
,
(
u_char
*
)
&
unit
);
if
(
ret
)
{
printk
(
KERN_WARNING
"ftl: Failed to write back to BAM cache in copy_erase_unit()!
\n
"
);
return
ret
;
}
/* Copy all data blocks from source unit to transfer unit */
src
=
eun
->
Offset
;
dest
=
xfer
->
Offset
;
...
...
@@ -558,15 +558,15 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
}
/* Write the BAM to the transfer unit */
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
xfer
->
Offset
+
le32_to_cpu
(
part
->
header
.
BAMOffset
),
part
->
BlocksPerUnit
*
sizeof
(
int32_t
),
&
retlen
,
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
xfer
->
Offset
+
le32_to_cpu
(
part
->
header
.
BAMOffset
),
part
->
BlocksPerUnit
*
sizeof
(
int32_t
),
&
retlen
,
(
u_char
*
)
part
->
bam_cache
);
if
(
ret
)
{
printk
(
KERN_WARNING
"ftl: Error writing BAM in copy_erase_unit
\n
"
);
return
ret
;
}
/* All clear? Then update the LogicalEUN again */
ret
=
part
->
mbd
.
mtd
->
write
(
part
->
mbd
.
mtd
,
xfer
->
Offset
+
20
,
sizeof
(
u_int16_t
),
&
retlen
,
(
u_char
*
)
&
srcunitswap
);
...
...
@@ -574,9 +574,9 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
if
(
ret
)
{
printk
(
KERN_WARNING
"ftl: Error writing new LogicalEUN in copy_erase_unit
\n
"
);
return
ret
;
}
}
/* Update the maps and usage stats*/
i
=
xfer
->
EraseCount
;
xfer
->
EraseCount
=
eun
->
EraseCount
;
...
...
@@ -588,10 +588,10 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
part
->
FreeTotal
+=
free
;
eun
->
Free
=
free
;
eun
->
Deleted
=
0
;
/* Now, the cache should be valid for the new block */
part
->
bam_index
=
srcunit
;
return
0
;
}
/* copy_erase_unit */
...
...
@@ -608,7 +608,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
oldest data unit instead. This means that we generally postpone
the next reclaimation as long as possible, but shuffle static
stuff around a bit for wear leveling.
======================================================================*/
static
int
reclaim_block
(
partition_t
*
part
)
...
...
@@ -666,7 +666,7 @@ static int reclaim_block(partition_t *part)
else
DEBUG
(
1
,
"ftl_cs: reclaim failed: no "
"suitable transfer units!
\n
"
);
return
-
EIO
;
}
}
...
...
@@ -715,7 +715,7 @@ static int reclaim_block(partition_t *part)
returns the block index -- the erase unit is just the currently
cached unit. If there are no free blocks, it returns 0 -- this
is never a valid data block because it contains the header.
======================================================================*/
#ifdef PSYCHO_DEBUG
...
...
@@ -737,7 +737,7 @@ static u_int32_t find_free(partition_t *part)
u_int32_t
blk
;
size_t
retlen
;
int
ret
;
/* Find an erase unit with some free space */
stop
=
(
part
->
bam_index
==
0xffff
)
?
0
:
part
->
bam_index
;
eun
=
stop
;
...
...
@@ -749,17 +749,17 @@ static u_int32_t find_free(partition_t *part)
if
(
part
->
EUNInfo
[
eun
].
Free
==
0
)
return
0
;
/* Is this unit's BAM cached? */
if
(
eun
!=
part
->
bam_index
)
{
/* Invalidate cache */
part
->
bam_index
=
0xffff
;
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
ret
=
part
->
mbd
.
mtd
->
read
(
part
->
mbd
.
mtd
,
part
->
EUNInfo
[
eun
].
Offset
+
le32_to_cpu
(
part
->
header
.
BAMOffset
),
part
->
BlocksPerUnit
*
sizeof
(
u_int32_t
),
&
retlen
,
(
u_char
*
)
(
part
->
bam_cache
));
if
(
ret
)
{
printk
(
KERN_WARNING
"ftl: Error reading BAM in find_free
\n
"
);
return
0
;
...
...
@@ -781,14 +781,14 @@ static u_int32_t find_free(partition_t *part)
}
DEBUG
(
2
,
"ftl_cs: found free block at %d in %d
\n
"
,
blk
,
eun
);
return
blk
;
}
/* find_free */
/*======================================================================
Read a series of sectors from an FTL partition.
======================================================================*/
static
int
ftl_read
(
partition_t
*
part
,
caddr_t
buffer
,
...
...
@@ -798,7 +798,7 @@ static int ftl_read(partition_t *part, caddr_t buffer,
u_long
i
;
int
ret
;
size_t
offset
,
retlen
;