* [PATCH 0/6] mtd: small cleanups
@ 2014-05-21 6:16 Brian Norris
2014-05-21 6:16 ` [PATCH 1/6] mtd: pfow: remove unused variable Brian Norris
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:16 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
This series consists of miscellaneous fixes and cleanups, mostly caught through
some sort of static analysis (gcc warnings, sparse, Coverity, etc.).
Brian Norris (6):
mtd: pfow: remove unused variable
mtd: slram: fix unused variable warning
mtd: maps: sc520cdp: fix warnings
mtd: nand_bbt: remove unused variable
mtd: nand_bbt: handle error case for nand_create_badblock_pattern()
mtd: nand: r852: correct write_buf loop bounds
drivers/mtd/devices/slram.c | 4 +---
drivers/mtd/maps/sc520cdp.c | 6 +++---
drivers/mtd/nand/nand_bbt.c | 13 +++++++------
drivers/mtd/nand/r852.c | 6 ++++--
include/linux/mtd/pfow.h | 3 ---
5 files changed, 15 insertions(+), 17 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] mtd: pfow: remove unused variable
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
@ 2014-05-21 6:16 ` Brian Norris
2014-05-21 6:16 ` [PATCH 2/6] mtd: slram: fix unused variable warning Brian Norris
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:16 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
Fixes warning:
In file included from drivers/mtd/lpddr/qinfo_probe.c:31:0:
include/linux/mtd/pfow.h: In function ‘send_pfow_command’:
include/linux/mtd/pfow.h:104:6: warning: variable ‘chipnum’ set but not used [-Wunused-but-set-variable]
int chipnum;
^
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
include/linux/mtd/pfow.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/include/linux/mtd/pfow.h b/include/linux/mtd/pfow.h
index b730d4f84655..42ff7ff09bf5 100644
--- a/include/linux/mtd/pfow.h
+++ b/include/linux/mtd/pfow.h
@@ -101,9 +101,6 @@ static inline void send_pfow_command(struct map_info *map,
unsigned long len, map_word *datum)
{
int bits_per_chip = map_bankwidth(map) * 8;
- int chipnum;
- struct lpddr_private *lpddr = map->fldrv_priv;
- chipnum = adr >> lpddr->chipshift;
map_write(map, CMD(cmd_code), map->pfow_base + PFOW_COMMAND_CODE);
map_write(map, CMD(adr & ((1<<bits_per_chip) - 1)),
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] mtd: slram: fix unused variable warning
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
2014-05-21 6:16 ` [PATCH 1/6] mtd: pfow: remove unused variable Brian Norris
@ 2014-05-21 6:16 ` Brian Norris
2014-05-21 6:17 ` [PATCH 3/6] mtd: maps: sc520cdp: fix warnings Brian Norris
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:16 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
drivers/mtd/devices/slram.c: In function 'init_slram':
drivers/mtd/devices/slram.c:283:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/devices/slram.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 5a5cd2ace4a6..2fc4957cbe7f 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -280,14 +280,11 @@ __setup("slram=", mtd_slram_setup);
static int __init init_slram(void)
{
char *devname;
- int i;
#ifndef MODULE
char *devstart;
char *devlength;
- i = 0;
-
if (!map) {
E("slram: not enough parameters.\n");
return(-EINVAL);
@@ -314,6 +311,7 @@ static int __init init_slram(void)
}
#else
int count;
+ int i;
for (count = 0; count < SLRAM_MAX_DEVICES_PARAMS && map[count];
count++) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] mtd: maps: sc520cdp: fix warnings
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
2014-05-21 6:16 ` [PATCH 1/6] mtd: pfow: remove unused variable Brian Norris
2014-05-21 6:16 ` [PATCH 2/6] mtd: slram: fix unused variable warning Brian Norris
@ 2014-05-21 6:17 ` Brian Norris
2014-05-21 6:17 ` [PATCH 4/6] mtd: nand_bbt: remove unused variable Brian Norris
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:17 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
On m86k, and maybe a few other architectures, we get this kind of
warning, due to misuse of volatile:
drivers/mtd/maps/sc520cdp.c: In function 'sc520cdp_setup_par':
>> drivers/mtd/maps/sc520cdp.c:223:2: warning: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [enabled by default]
arch/m68k/include/asm/raw_io.h:22:13: note: expected 'void *' but argument is of type 'volatile long unsigned int *'
Rather than annotating the variable declaration, let's just use the
proper accessors, which add the 'volatile' qualifier to the operation.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/maps/sc520cdp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index 8fead8e46bce..093edd51bdc7 100644
--- a/drivers/mtd/maps/sc520cdp.c
+++ b/drivers/mtd/maps/sc520cdp.c
@@ -183,7 +183,7 @@ static const struct sc520_par_table par_table[NUM_FLASH_BANKS] =
static void sc520cdp_setup_par(void)
{
- volatile unsigned long __iomem *mmcr;
+ unsigned long __iomem *mmcr;
unsigned long mmcr_val;
int i, j;
@@ -203,11 +203,11 @@ static void sc520cdp_setup_par(void)
*/
for(i = 0; i < NUM_FLASH_BANKS; i++) { /* for each par_table entry */
for(j = 0; j < NUM_SC520_PAR; j++) { /* for each PAR register */
- mmcr_val = mmcr[SC520_PAR(j)];
+ mmcr_val = readl(&mmcr[SC520_PAR(j)]);
/* if target device field matches, reprogram the PAR */
if((mmcr_val & SC520_PAR_TRGDEV) == par_table[i].trgdev)
{
- mmcr[SC520_PAR(j)] = par_table[i].new_par;
+ writel(par_table[i].new_par, &mmcr[SC520_PAR(j)]);
break;
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] mtd: nand_bbt: remove unused variable
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
` (2 preceding siblings ...)
2014-05-21 6:17 ` [PATCH 3/6] mtd: maps: sc520cdp: fix warnings Brian Norris
@ 2014-05-21 6:17 ` Brian Norris
2014-05-21 6:17 ` [PATCH 5/6] mtd: nand_bbt: handle error case for nand_create_badblock_pattern() Brian Norris
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:17 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
Set, but unused, variable.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/nand_bbt.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index c0615d1526f9..6cbf8768a0a4 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -528,7 +528,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
{
struct nand_chip *this = mtd->priv;
int i, chips;
- int bits, startblock, block, dir;
+ int startblock, block, dir;
int scanlen = mtd->writesize + mtd->oobsize;
int bbtblocks;
int blocktopage = this->bbt_erase_shift - this->page_shift;
@@ -552,9 +552,6 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
bbtblocks = mtd->size >> this->bbt_erase_shift;
}
- /* Number of bits for each erase block in the bbt */
- bits = td->options & NAND_BBT_NRBITS_MSK;
-
for (i = 0; i < chips; i++) {
/* Reset version information */
td->version[i] = 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] mtd: nand_bbt: handle error case for nand_create_badblock_pattern()
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
` (3 preceding siblings ...)
2014-05-21 6:17 ` [PATCH 4/6] mtd: nand_bbt: remove unused variable Brian Norris
@ 2014-05-21 6:17 ` Brian Norris
2014-05-21 6:17 ` [PATCH 6/6] mtd: nand: r852: correct write_buf loop bounds Brian Norris
2014-05-28 7:07 ` [PATCH 0/6] mtd: small cleanups Brian Norris
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:17 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/nand_bbt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 6cbf8768a0a4..7f0c3b4c2a4f 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1282,6 +1282,7 @@ static int nand_create_badblock_pattern(struct nand_chip *this)
int nand_default_bbt(struct mtd_info *mtd)
{
struct nand_chip *this = mtd->priv;
+ int ret;
/* Is a flash based bad block table requested? */
if (this->bbt_options & NAND_BBT_USE_FLASH) {
@@ -1300,8 +1301,11 @@ int nand_default_bbt(struct mtd_info *mtd)
this->bbt_md = NULL;
}
- if (!this->badblock_pattern)
- nand_create_badblock_pattern(this);
+ if (!this->badblock_pattern) {
+ ret = nand_create_badblock_pattern(this);
+ if (ret)
+ return ret;
+ }
return nand_scan_bbt(mtd, this->badblock_pattern);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] mtd: nand: r852: correct write_buf loop bounds
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
` (4 preceding siblings ...)
2014-05-21 6:17 ` [PATCH 5/6] mtd: nand_bbt: handle error case for nand_create_badblock_pattern() Brian Norris
@ 2014-05-21 6:17 ` Brian Norris
2014-05-28 7:07 ` [PATCH 0/6] mtd: small cleanups Brian Norris
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-21 6:17 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris, Maxim Levitsky
The two loops in r852_write_buf() are designed to handle 4-byte-aligned
and then 1-byte-aligned portions, respectively. However, there are two
issues:
(1) The first loop will only terminate if 'len' is a multiple of 4
(2) The second loop will never terminate if it runs at least once
Rewrite these loops as they were probably intended. Compile tested only.
Issues pointed out by Coverity Scan.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
---
drivers/mtd/nand/r852.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index 325930db3f04..baea83f4dea8 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -245,7 +245,7 @@ static void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
}
/* write DWORD chinks - faster */
- while (len) {
+ while (len >= 4) {
reg = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24;
r852_write_reg_dword(dev, R852_DATALINE, reg);
buf += 4;
@@ -254,8 +254,10 @@ static void r852_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
}
/* write rest */
- while (len)
+ while (len > 0) {
r852_write_reg(dev, R852_DATALINE, *buf++);
+ len--;
+ }
}
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] mtd: small cleanups
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
` (5 preceding siblings ...)
2014-05-21 6:17 ` [PATCH 6/6] mtd: nand: r852: correct write_buf loop bounds Brian Norris
@ 2014-05-28 7:07 ` Brian Norris
6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2014-05-28 7:07 UTC (permalink / raw)
To: linux-mtd
On Tue, May 20, 2014 at 11:16:57PM -0700, Brian Norris wrote:
> This series consists of miscellaneous fixes and cleanups, mostly caught through
> some sort of static analysis (gcc warnings, sparse, Coverity, etc.).
>
> Brian Norris (6):
> mtd: pfow: remove unused variable
> mtd: slram: fix unused variable warning
> mtd: maps: sc520cdp: fix warnings
> mtd: nand_bbt: remove unused variable
> mtd: nand_bbt: handle error case for nand_create_badblock_pattern()
> mtd: nand: r852: correct write_buf loop bounds
Pushed all 6 to l2-mtd.git.
Brian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-05-28 7:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 6:16 [PATCH 0/6] mtd: small cleanups Brian Norris
2014-05-21 6:16 ` [PATCH 1/6] mtd: pfow: remove unused variable Brian Norris
2014-05-21 6:16 ` [PATCH 2/6] mtd: slram: fix unused variable warning Brian Norris
2014-05-21 6:17 ` [PATCH 3/6] mtd: maps: sc520cdp: fix warnings Brian Norris
2014-05-21 6:17 ` [PATCH 4/6] mtd: nand_bbt: remove unused variable Brian Norris
2014-05-21 6:17 ` [PATCH 5/6] mtd: nand_bbt: handle error case for nand_create_badblock_pattern() Brian Norris
2014-05-21 6:17 ` [PATCH 6/6] mtd: nand: r852: correct write_buf loop bounds Brian Norris
2014-05-28 7:07 ` [PATCH 0/6] mtd: small cleanups Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).