All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Wan ZongShun <mcuos.com@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: nuc900_nand: read correct SMISR register
Date: Wed, 13 Jan 2016 13:50:13 -0800	[thread overview]
Message-ID: <20160113215013.GS109450@google.com> (raw)
In-Reply-To: <9019174.GYajdpGP8V@wuerfel>

On Wed, Jan 13, 2016 at 10:38:08PM +0100, Arnd Bergmann wrote:
> The nuc900_nand driver has always passed an incorrect register
> address in its nuc900_check_rb() function, which cannot possibly
> work, and in some configurations gives us a build warning:
> 
> drivers/mtd/nand/nuc900_nand.c: In function 'nuc900_check_rb':
> drivers/mtd/nand/nuc900_nand.c:27:23: warning: passing argument 1 of '__raw_readl' makes pointer from integer without a cast [-Wint-conversion]
>  #define REG_SMISR     0xac
> drivers/mtd/nand/nuc900_nand.c:118:20: note: in expansion of macro 'REG_SMISR'
>   val = __raw_readl(REG_SMISR);
> 
> This makes sure we actually read from the register rather than
> from (void *)0x000000ac in user space.
> 
> I suspect nobody noticed this before because the nuc900_nand_devready()
> function never gets called, or nobody uses this driver on an upstream
> kernel. Possibly even both.

Almost definitely not the first. That's an absolutely essential
function for this driver (it doesn't have ->waitfunc(), so we use
->dev_ready() all the time). Quite likely the latter.

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c
> index 220ddfcf29f5..dbc5b571c2bb 100644
> --- a/drivers/mtd/nand/nuc900_nand.c
> +++ b/drivers/mtd/nand/nuc900_nand.c
> @@ -113,7 +113,7 @@ static int nuc900_check_rb(struct nuc900_nand *nand)
>  {
>  	unsigned int val;
>  	spin_lock(&nand->lock);
> -	val = __raw_readl(REG_SMISR);
> +	val = __raw_readl(nand->reg + REG_SMISR);
>  	val &= READYBUSY;
>  	spin_unlock(&nand->lock);
>  

Looks OK to me, though I kinda hate dragging on support for
obviously-unused drivers...

Brian

WARNING: multiple messages have this Message-ID (diff)
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mtd: nuc900_nand: read correct SMISR register
Date: Wed, 13 Jan 2016 13:50:13 -0800	[thread overview]
Message-ID: <20160113215013.GS109450@google.com> (raw)
In-Reply-To: <9019174.GYajdpGP8V@wuerfel>

On Wed, Jan 13, 2016 at 10:38:08PM +0100, Arnd Bergmann wrote:
> The nuc900_nand driver has always passed an incorrect register
> address in its nuc900_check_rb() function, which cannot possibly
> work, and in some configurations gives us a build warning:
> 
> drivers/mtd/nand/nuc900_nand.c: In function 'nuc900_check_rb':
> drivers/mtd/nand/nuc900_nand.c:27:23: warning: passing argument 1 of '__raw_readl' makes pointer from integer without a cast [-Wint-conversion]
>  #define REG_SMISR     0xac
> drivers/mtd/nand/nuc900_nand.c:118:20: note: in expansion of macro 'REG_SMISR'
>   val = __raw_readl(REG_SMISR);
> 
> This makes sure we actually read from the register rather than
> from (void *)0x000000ac in user space.
> 
> I suspect nobody noticed this before because the nuc900_nand_devready()
> function never gets called, or nobody uses this driver on an upstream
> kernel. Possibly even both.

Almost definitely not the first. That's an absolutely essential
function for this driver (it doesn't have ->waitfunc(), so we use
->dev_ready() all the time). Quite likely the latter.

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c
> index 220ddfcf29f5..dbc5b571c2bb 100644
> --- a/drivers/mtd/nand/nuc900_nand.c
> +++ b/drivers/mtd/nand/nuc900_nand.c
> @@ -113,7 +113,7 @@ static int nuc900_check_rb(struct nuc900_nand *nand)
>  {
>  	unsigned int val;
>  	spin_lock(&nand->lock);
> -	val = __raw_readl(REG_SMISR);
> +	val = __raw_readl(nand->reg + REG_SMISR);
>  	val &= READYBUSY;
>  	spin_unlock(&nand->lock);
>  

Looks OK to me, though I kinda hate dragging on support for
obviously-unused drivers...

Brian

  reply	other threads:[~2016-01-13 21:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13 21:38 [PATCH] mtd: nuc900_nand: read correct SMISR register Arnd Bergmann
2016-01-13 21:38 ` Arnd Bergmann
2016-01-13 21:50 ` Brian Norris [this message]
2016-01-13 21:50   ` Brian Norris
2016-01-13 22:02   ` Arnd Bergmann
2016-01-13 22:02     ` Arnd Bergmann
2016-01-14  0:29     ` Brian Norris
2016-01-14  0:29       ` Brian Norris
2016-01-14  9:34       ` Wan Zongshun
2016-01-14  9:34         ` Wan Zongshun
2016-01-14 12:08         ` Arnd Bergmann
2016-01-14 12:08           ` Arnd Bergmann
2016-01-15  7:53           ` Wan Zongshun
2016-01-15  7:53             ` Wan Zongshun
2016-01-15 11:03             ` Arnd Bergmann
2016-01-15 11:03               ` Arnd Bergmann
2016-01-15 15:01               ` Wan Zongshun
2016-01-15 15:01                 ` Wan Zongshun
2016-01-15 18:03 ` Brian Norris
2016-01-15 18:03   ` Brian Norris

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=20160113215013.GS109450@google.com \
    --to=computersforpeace@gmail.com \
    --cc=arnd@arndb.de \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mcuos.com@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.