Skip to content

Commit 58dd8f2

Browse files
author
Thomas Gleixner
committed
[MTD] NAND consolidate data types
The NAND driver used a mix of unsigned char, u_char amd uint8_t data types. Consolidate to uint8_t usage Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 2c0a2be commit 58dd8f2

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

drivers/mtd/nand/nand_base.c

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static struct nand_oobinfo nand_oob_64 = {
118118
};
119119

120120
/* This is used for padding purposes in nand_write_oob */
121-
static u_char ffchars[] = {
121+
static uint8_t ffchars[] = {
122122
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
123123
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
124124
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -132,39 +132,39 @@ static u_char ffchars[] = {
132132
/*
133133
* NAND low-level MTD interface functions
134134
*/
135-
static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
136-
static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len);
137-
static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len);
135+
static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
136+
static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len);
137+
static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len);
138138

139139
static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
140-
size_t *retlen, u_char *buf);
140+
size_t *retlen, uint8_t *buf);
141141
static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
142-
size_t *retlen, u_char *buf, u_char *eccbuf,
142+
size_t *retlen, uint8_t *buf, uint8_t *eccbuf,
143143
struct nand_oobinfo *oobsel);
144144
static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
145-
size_t *retlen, u_char *buf);
145+
size_t *retlen, uint8_t *buf);
146146
static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
147-
size_t *retlen, const u_char *buf);
147+
size_t *retlen, const uint8_t *buf);
148148
static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
149-
size_t *retlen, const u_char *buf, u_char *eccbuf,
149+
size_t *retlen, const uint8_t *buf, uint8_t *eccbuf,
150150
struct nand_oobinfo *oobsel);
151151
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
152-
size_t *retlen, const u_char *buf);
152+
size_t *retlen, const uint8_t *buf);
153153
static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs,
154154
unsigned long count, loff_t to, size_t *retlen);
155155
static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
156156
unsigned long count, loff_t to, size_t *retlen,
157-
u_char *eccbuf, struct nand_oobinfo *oobsel);
157+
uint8_t *eccbuf, struct nand_oobinfo *oobsel);
158158
static int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
159159
static void nand_sync(struct mtd_info *mtd);
160160

161161
/* Some internal functions */
162162
static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this,
163-
int page, u_char * oob_buf,
163+
int page, uint8_t * oob_buf,
164164
struct nand_oobinfo *oobsel, int mode);
165165
#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
166166
static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this,
167-
int page, int numpages, u_char *oob_buf,
167+
int page, int numpages, uint8_t *oob_buf,
168168
struct nand_oobinfo *oobsel, int chipnr,
169169
int oobmode);
170170
#else
@@ -201,7 +201,7 @@ static void nand_release_device(struct mtd_info *mtd)
201201
*
202202
* Default read function for 8bit buswith
203203
*/
204-
static u_char nand_read_byte(struct mtd_info *mtd)
204+
static uint8_t nand_read_byte(struct mtd_info *mtd)
205205
{
206206
struct nand_chip *this = mtd->priv;
207207
return readb(this->IO_ADDR_R);
@@ -214,7 +214,7 @@ static u_char nand_read_byte(struct mtd_info *mtd)
214214
*
215215
* Default write function for 8it buswith
216216
*/
217-
static void nand_write_byte(struct mtd_info *mtd, u_char byte)
217+
static void nand_write_byte(struct mtd_info *mtd, uint8_t byte)
218218
{
219219
struct nand_chip *this = mtd->priv;
220220
writeb(byte, this->IO_ADDR_W);
@@ -227,10 +227,10 @@ static void nand_write_byte(struct mtd_info *mtd, u_char byte)
227227
* Default read function for 16bit buswith with
228228
* endianess conversion
229229
*/
230-
static u_char nand_read_byte16(struct mtd_info *mtd)
230+
static uint8_t nand_read_byte16(struct mtd_info *mtd)
231231
{
232232
struct nand_chip *this = mtd->priv;
233-
return (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
233+
return (uint8_t) cpu_to_le16(readw(this->IO_ADDR_R));
234234
}
235235

236236
/**
@@ -241,7 +241,7 @@ static u_char nand_read_byte16(struct mtd_info *mtd)
241241
* Default write function for 16bit buswith with
242242
* endianess conversion
243243
*/
244-
static void nand_write_byte16(struct mtd_info *mtd, u_char byte)
244+
static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte)
245245
{
246246
struct nand_chip *this = mtd->priv;
247247
writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);
@@ -305,7 +305,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chip)
305305
*
306306
* Default write function for 8bit buswith
307307
*/
308-
static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
308+
static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
309309
{
310310
int i;
311311
struct nand_chip *this = mtd->priv;
@@ -322,7 +322,7 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
322322
*
323323
* Default read function for 8bit buswith
324324
*/
325-
static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
325+
static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
326326
{
327327
int i;
328328
struct nand_chip *this = mtd->priv;
@@ -339,7 +339,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
339339
*
340340
* Default verify function for 8bit buswith
341341
*/
342-
static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
342+
static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
343343
{
344344
int i;
345345
struct nand_chip *this = mtd->priv;
@@ -359,7 +359,7 @@ static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
359359
*
360360
* Default write function for 16bit buswith
361361
*/
362-
static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
362+
static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
363363
{
364364
int i;
365365
struct nand_chip *this = mtd->priv;
@@ -379,7 +379,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
379379
*
380380
* Default read function for 16bit buswith
381381
*/
382-
static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
382+
static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
383383
{
384384
int i;
385385
struct nand_chip *this = mtd->priv;
@@ -398,7 +398,7 @@ static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
398398
*
399399
* Default verify function for 16bit buswith
400400
*/
401-
static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len)
401+
static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
402402
{
403403
int i;
404404
struct nand_chip *this = mtd->priv;
@@ -472,7 +472,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
472472
static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
473473
{
474474
struct nand_chip *this = mtd->priv;
475-
u_char buf[2] = { 0, 0 };
475+
uint8_t buf[2] = { 0, 0 };
476476
size_t retlen;
477477
int block;
478478

@@ -600,11 +600,11 @@ static void nand_command(struct mtd_info *mtd, unsigned command, int column,
600600
this->write_byte(mtd, column);
601601
}
602602
if (page_addr != -1) {
603-
this->write_byte(mtd, (unsigned char)(page_addr & 0xff));
604-
this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff));
603+
this->write_byte(mtd, (uint8_t)(page_addr & 0xff));
604+
this->write_byte(mtd, (uint8_t)((page_addr >> 8) & 0xff));
605605
/* One more address cycle for devices > 32MiB */
606606
if (this->chipsize > (32 << 20))
607-
this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0x0f));
607+
this->write_byte(mtd, (uint8_t)((page_addr >> 16) & 0x0f));
608608
}
609609
/* Latch in address */
610610
this->hwcontrol(mtd, NAND_CTL_CLRALE);
@@ -692,11 +692,11 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
692692
this->write_byte(mtd, column >> 8);
693693
}
694694
if (page_addr != -1) {
695-
this->write_byte(mtd, (unsigned char)(page_addr & 0xff));
696-
this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff));
695+
this->write_byte(mtd, (uint8_t)(page_addr & 0xff));
696+
this->write_byte(mtd, (uint8_t)((page_addr >> 8) & 0xff));
697697
/* One more address cycle for devices > 128MiB */
698698
if (this->chipsize > (128 << 20))
699-
this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0xff));
699+
this->write_byte(mtd, (uint8_t)((page_addr >> 16) & 0xff));
700700
}
701701
/* Latch in address */
702702
this->hwcontrol(mtd, NAND_CTL_CLRALE);
@@ -874,10 +874,10 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
874874
* Cached programming is not supported yet.
875875
*/
876876
static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page,
877-
u_char *oob_buf, struct nand_oobinfo *oobsel, int cached)
877+
uint8_t *oob_buf, struct nand_oobinfo *oobsel, int cached)
878878
{
879879
int i, status;
880-
u_char ecc_code[32];
880+
uint8_t ecc_code[32];
881881
int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
882882
int *oob_config = oobsel->eccpos;
883883
int datidx = 0, eccidx = 0, eccsteps = this->eccsteps;
@@ -978,12 +978,12 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
978978
* it early in the page write stage. Better to write no data than invalid data.
979979
*/
980980
static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages,
981-
u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode)
981+
uint8_t *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode)
982982
{
983983
int i, j, datidx = 0, oobofs = 0, res = -EIO;
984984
int eccsteps = this->eccsteps;
985985
int hweccbytes;
986-
u_char oobdata[64];
986+
uint8_t oobdata[64];
987987

988988
hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0;
989989

@@ -1078,7 +1078,7 @@ static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int p
10781078
* This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL
10791079
* and flags = 0xff
10801080
*/
1081-
static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
1081+
static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, uint8_t *buf)
10821082
{
10831083
return nand_do_read_ecc(mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff);
10841084
}
@@ -1096,7 +1096,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retl
10961096
* This function simply calls nand_do_read_ecc with flags = 0xff
10971097
*/
10981098
static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1099-
size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel)
1099+
size_t *retlen, uint8_t *buf, uint8_t *oob_buf, struct nand_oobinfo *oobsel)
11001100
{
11011101
/* use userspace supplied oobinfo, if zero */
11021102
if (oobsel == NULL)
@@ -1121,15 +1121,15 @@ static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
11211121
* NAND read with ECC
11221122
*/
11231123
int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
1124-
size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel, int flags)
1124+
size_t *retlen, uint8_t *buf, uint8_t *oob_buf, struct nand_oobinfo *oobsel, int flags)
11251125
{
11261126

11271127
int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1;
11281128
int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0;
11291129
struct nand_chip *this = mtd->priv;
1130-
u_char *data_poi, *oob_data = oob_buf;
1131-
u_char ecc_calc[32];
1132-
u_char ecc_code[32];
1130+
uint8_t *data_poi, *oob_data = oob_buf;
1131+
uint8_t ecc_calc[32];
1132+
uint8_t ecc_code[32];
11331133
int eccmode, eccsteps;
11341134
int *oob_config, datidx;
11351135
int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1;
@@ -1383,7 +1383,7 @@ int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
13831383
*
13841384
* NAND read out-of-band data from the spare area
13851385
*/
1386-
static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
1386+
static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, uint8_t *buf)
13871387
{
13881388
int i, col, page, chipnr;
13891389
struct nand_chip *this = mtd->priv;
@@ -1550,7 +1550,7 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s
15501550
* forces the 0xff fill before using the buffer again.
15511551
*
15521552
*/
1553-
static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel,
1553+
static uint8_t *nand_prepare_oobbuf(struct mtd_info *mtd, uint8_t *fsbuf, struct nand_oobinfo *oobsel,
15541554
int autoplace, int numpages)
15551555
{
15561556
struct nand_chip *this = mtd->priv;
@@ -1599,7 +1599,7 @@ static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct n
15991599
* This function simply calls nand_write_ecc with oob buffer and oobsel = NULL
16001600
*
16011601
*/
1602-
static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
1602+
static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf)
16031603
{
16041604
return (nand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL));
16051605
}
@@ -1617,13 +1617,13 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retle
16171617
* NAND write with ECC
16181618
*/
16191619
static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
1620-
size_t *retlen, const u_char *buf, u_char *eccbuf,
1620+
size_t *retlen, const uint8_t *buf, uint8_t *eccbuf,
16211621
struct nand_oobinfo *oobsel)
16221622
{
16231623
int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr;
16241624
int autoplace = 0, numpages, totalpages;
16251625
struct nand_chip *this = mtd->priv;
1626-
u_char *oobbuf, *bufstart;
1626+
uint8_t *oobbuf, *bufstart;
16271627
int ppblock = (1 << (this->phys_erase_shift - this->page_shift));
16281628

16291629
DEBUG(MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len);
@@ -1680,12 +1680,12 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
16801680
/* Calc number of pages we can write in one go */
16811681
numpages = min(ppblock - (startpage & (ppblock - 1)), totalpages);
16821682
oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages);
1683-
bufstart = (u_char *) buf;
1683+
bufstart = (uint8_t *) buf;
16841684

16851685
/* Loop until all data is written */
16861686
while (written < len) {
16871687

1688-
this->data_poi = (u_char *) &buf[written];
1688+
this->data_poi = (uint8_t *) &buf[written];
16891689
/* Write one page. If this is the last page to write
16901690
* or the last page in this block, then use the
16911691
* real pageprogram command, else select cached programming
@@ -1764,7 +1764,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
17641764
*
17651765
* NAND write out-of-band
17661766
*/
1767-
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
1767+
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf)
17681768
{
17691769
int column, page, status, ret = -EIO, chipnr;
17701770
struct nand_chip *this = mtd->priv;
@@ -1884,13 +1884,13 @@ static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned l
18841884
* NAND write with iovec with ecc
18851885
*/
18861886
static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count,
1887-
loff_t to, size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
1887+
loff_t to, size_t *retlen, uint8_t *eccbuf, struct nand_oobinfo *oobsel)
18881888
{
18891889
int i, page, len, total_len, ret = -EIO, written = 0, chipnr;
18901890
int oob, numpages, autoplace = 0, startpage;
18911891
struct nand_chip *this = mtd->priv;
18921892
int ppblock = (1 << (this->phys_erase_shift - this->page_shift));
1893-
u_char *oobbuf, *bufstart;
1893+
uint8_t *oobbuf, *bufstart;
18941894

18951895
/* Preset written len for early exit */
18961896
*retlen = 0;
@@ -1959,7 +1959,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
19591959
/* Do not cross block boundaries */
19601960
numpages = min(ppblock - (startpage & (ppblock - 1)), numpages);
19611961
oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages);
1962-
bufstart = (u_char *) vecs->iov_base;
1962+
bufstart = (uint8_t *) vecs->iov_base;
19631963
bufstart += len;
19641964
this->data_poi = bufstart;
19651965
oob = 0;
@@ -1990,7 +1990,7 @@ static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsign
19901990
int cnt = 0;
19911991
while (cnt < mtd->oobblock) {
19921992
if (vecs->iov_base != NULL && vecs->iov_len)
1993-
this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
1993+
this->data_buf[cnt++] = ((uint8_t *) vecs->iov_base)[len++];
19941994
/* Check, if we have to switch to the next tuple */
19951995
if (len >= (int)vecs->iov_len) {
19961996
vecs++;

0 commit comments

Comments
 (0)