linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: wangzhou1@hisilicon.com (Zhou Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 1/2] mtd: hisilicon: add a new NAND controller driver for hisilicon hip04 Soc
Date: Wed, 14 Jan 2015 20:45:05 +0800	[thread overview]
Message-ID: <54B664D1.6060508@hisilicon.com> (raw)
In-Reply-To: <20150113040254.GK9759@ld-irv-0074>

On 2015/1/13 12:02, Brian Norris wrote:
> One more thing:
> 
> On Mon, Jan 12, 2015 at 03:28:53PM +0800, Zhou Wang wrote:
>> diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c
>> new file mode 100644
>> index 0000000..2000f21
>> --- /dev/null
>> +++ b/drivers/mtd/nand/hisi504_nand.c
> ...
>> +static int hisi_nand_read_page_hwecc(struct mtd_info *mtd,
>> +	struct nand_chip *chip, uint8_t *buf, int oob_required, int page)
>> +{
>> +	struct hinfc_host *host = chip->priv;
>> +	int max_bitflips = 0, stat = 0, stat_max, status_ecc;
> 
>     drivers/mtd/nand/hisi504_nand.c:547:34: warning: ?stat_max? may be used uninitialized in this function [-Wmaybe-uninitialized]
>       int max_bitflips = 0, stat = 0, stat_max, status_ecc;

In fact, there is no chance to run "default case" there as hisi_nfc_ecc_probe
will check this and print error.
I will initialize stat_max with 0 to eliminate this warning.

>                                       ^
> 
>> +	int stat_1, stat_2;
>> +
>> +	chip->read_buf(mtd, buf, mtd->writesize);
>> +	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
>> +
>> +	/* errors which can not be corrected by ECC */
>> +	if (host->irq_status & HINFC504_INTS_UE) {
>> +		mtd->ecc_stats.failed++;
>> +	} else if (host->irq_status & HINFC504_INTS_CE) {
>> +		/* TODO: need add other ECC modes! */
> 
> You may want a 'default' case that sets stat_max to zero, then.
> 
>> +		switch (chip->ecc.strength) {
>> +		case 1:
>> +			stat = hweight8(hinfc_read(host, HINFC504_ECC_STATUS)>>
>> +						HINFC504_ECC_1_BIT_SHIFT);
>> +			stat_max = 1;
>> +			break;
>> +		case 16:
>> +			status_ecc = hinfc_read(host, HINFC504_ECC_STATUS) >>
>> +					HINFC504_ECC_16_BIT_SHIFT & 0x0fff;
>> +			stat_2 = status_ecc & 0x3f;
>> +			stat_1 = status_ecc >> 6 & 0x3f;
>> +			stat = stat_1 + stat_2;
>> +			stat_max = max_t(int, stat_1, stat_2);
>> +		}
>> +		mtd->ecc_stats.corrected += stat;
>> +		max_bitflips = max_t(int, max_bitflips, stat_max);
>> +	}
>> +	host->irq_status = 0;
>> +
>> +	return max_bitflips;
>> +}
> 
> Brian

Thanks for your comment!
Zhou Wang
> 
> .
> 

  reply	other threads:[~2015-01-14 12:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  7:28 [PATCH v6 0/2] mtd: hisilicon: add a new driver for NAND controller of hisilicon hip04 Soc Zhou Wang
2015-01-12  7:28 ` [PATCH v6 1/2] mtd: hisilicon: add a new NAND controller driver for " Zhou Wang
2015-01-12  8:21   ` Arnd Bergmann
2015-01-12  9:18     ` Zhou Wang
2015-01-13  3:58   ` Brian Norris
2015-01-14 12:34     ` Zhou Wang
2015-01-14 19:25       ` Brian Norris
2015-01-15  1:27         ` Zhou Wang
2015-01-13  4:02   ` Brian Norris
2015-01-14 12:45     ` Zhou Wang [this message]
2015-01-12  7:28 ` [PATCH v6 2/2] mtd: hisilicon: add device tree binding documentation Zhou Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B664D1.6060508@hisilicon.com \
    --to=wangzhou1@hisilicon.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).