All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: Semen Protsenko <semen.protsenko@globallogic.com>,
	Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ARM: OMAP2+: gpmc: Fix writing in gpmc_cs_set_memconf
Date: Mon, 26 Jan 2015 11:34:50 +0200	[thread overview]
Message-ID: <54C60A3A.1090008@ti.com> (raw)
In-Reply-To: <1422131320-1018-1-git-send-email-semen.protsenko@globallogic.com>

On 24/01/15 22:28, Semen Protsenko wrote:
> Some GPMC_CONFIG7 register bits marked as "RESERVED", means they
> shouldn't be overwritten. A typical approach to handle such bits called
> "Read-Modify-Write". Writing procedure used in gpmc_cs_set_memconf()
> utilizes RMW technique, but implemented incorrectly. Due to obvious typo
> in code read register value is being rewritten by another value, which
> leads to loss of read RESERVED bits. This patch fixes this.
> 
> While at it, replace magic numbers with named constants to improve code
> readability.
> 
> Signed-off-by: Semen Protsenko <semen.protsenko@globallogic.com>

This is much nicer.

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>  drivers/memory/omap-gpmc.c |   20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 24696f5..10eb4ac 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -153,6 +153,15 @@
>  #define GPMC_CONFIG1_FCLK_DIV4          (GPMC_CONFIG1_FCLK_DIV(3))
>  #define GPMC_CONFIG7_CSVALID		(1 << 6)
>  
> +#define GPMC_CONFIG7_BASEADDRESS_MASK	0x3f
> +#define GPMC_CONFIG7_CSVALID_MASK	BIT(6)
> +#define GPMC_CONFIG7_MASKADDRESS_OFFSET	8
> +#define GPMC_CONFIG7_MASKADDRESS_MASK	(0xf << GPMC_CONFIG7_MASKADDRESS_OFFSET)
> +/* All CONFIG7 bits except reserved bits */
> +#define GPMC_CONFIG7_MASK		(GPMC_CONFIG7_BASEADDRESS_MASK | \
> +					 GPMC_CONFIG7_CSVALID_MASK |     \
> +					 GPMC_CONFIG7_MASKADDRESS_MASK)
> +
>  #define GPMC_DEVICETYPE_NOR		0
>  #define GPMC_DEVICETYPE_NAND		2
>  #define GPMC_CONFIG_WRITEPROTECT	0x00000010
> @@ -586,12 +595,15 @@ static int gpmc_cs_set_memconf(int cs, u32 base, u32 size)
>  	if (base & (size - 1))
>  		return -EINVAL;
>  
> +	base >>= GPMC_CHUNK_SHIFT;
>  	mask = (1 << GPMC_SECTION_SHIFT) - size;
> +	mask >>= GPMC_CHUNK_SHIFT;
> +	mask <<= GPMC_CONFIG7_MASKADDRESS_OFFSET;
> +
>  	l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
> -	l &= ~0x3f;
> -	l = (base >> GPMC_CHUNK_SHIFT) & 0x3f;
> -	l &= ~(0x0f << 8);
> -	l |= ((mask >> GPMC_CHUNK_SHIFT) & 0x0f) << 8;
> +	l &= ~GPMC_CONFIG7_MASK;
> +	l |= base & GPMC_CONFIG7_BASEADDRESS_MASK;
> +	l |= mask & GPMC_CONFIG7_MASKADDRESS_MASK;
>  	l |= GPMC_CONFIG7_CSVALID;
>  	gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
>  
> 

WARNING: multiple messages have this Message-ID (diff)
From: Roger Quadros <rogerq@ti.com>
To: Semen Protsenko <semen.protsenko@globallogic.com>,
	Tony Lindgren <tony@atomide.com>
Cc: <linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] ARM: OMAP2+: gpmc: Fix writing in gpmc_cs_set_memconf
Date: Mon, 26 Jan 2015 11:34:50 +0200	[thread overview]
Message-ID: <54C60A3A.1090008@ti.com> (raw)
In-Reply-To: <1422131320-1018-1-git-send-email-semen.protsenko@globallogic.com>

On 24/01/15 22:28, Semen Protsenko wrote:
> Some GPMC_CONFIG7 register bits marked as "RESERVED", means they
> shouldn't be overwritten. A typical approach to handle such bits called
> "Read-Modify-Write". Writing procedure used in gpmc_cs_set_memconf()
> utilizes RMW technique, but implemented incorrectly. Due to obvious typo
> in code read register value is being rewritten by another value, which
> leads to loss of read RESERVED bits. This patch fixes this.
> 
> While at it, replace magic numbers with named constants to improve code
> readability.
> 
> Signed-off-by: Semen Protsenko <semen.protsenko@globallogic.com>

This is much nicer.

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> ---
>  drivers/memory/omap-gpmc.c |   20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index 24696f5..10eb4ac 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -153,6 +153,15 @@
>  #define GPMC_CONFIG1_FCLK_DIV4          (GPMC_CONFIG1_FCLK_DIV(3))
>  #define GPMC_CONFIG7_CSVALID		(1 << 6)
>  
> +#define GPMC_CONFIG7_BASEADDRESS_MASK	0x3f
> +#define GPMC_CONFIG7_CSVALID_MASK	BIT(6)
> +#define GPMC_CONFIG7_MASKADDRESS_OFFSET	8
> +#define GPMC_CONFIG7_MASKADDRESS_MASK	(0xf << GPMC_CONFIG7_MASKADDRESS_OFFSET)
> +/* All CONFIG7 bits except reserved bits */
> +#define GPMC_CONFIG7_MASK		(GPMC_CONFIG7_BASEADDRESS_MASK | \
> +					 GPMC_CONFIG7_CSVALID_MASK |     \
> +					 GPMC_CONFIG7_MASKADDRESS_MASK)
> +
>  #define GPMC_DEVICETYPE_NOR		0
>  #define GPMC_DEVICETYPE_NAND		2
>  #define GPMC_CONFIG_WRITEPROTECT	0x00000010
> @@ -586,12 +595,15 @@ static int gpmc_cs_set_memconf(int cs, u32 base, u32 size)
>  	if (base & (size - 1))
>  		return -EINVAL;
>  
> +	base >>= GPMC_CHUNK_SHIFT;
>  	mask = (1 << GPMC_SECTION_SHIFT) - size;
> +	mask >>= GPMC_CHUNK_SHIFT;
> +	mask <<= GPMC_CONFIG7_MASKADDRESS_OFFSET;
> +
>  	l = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
> -	l &= ~0x3f;
> -	l = (base >> GPMC_CHUNK_SHIFT) & 0x3f;
> -	l &= ~(0x0f << 8);
> -	l |= ((mask >> GPMC_CHUNK_SHIFT) & 0x0f) << 8;
> +	l &= ~GPMC_CONFIG7_MASK;
> +	l |= base & GPMC_CONFIG7_BASEADDRESS_MASK;
> +	l |= mask & GPMC_CONFIG7_MASKADDRESS_MASK;
>  	l |= GPMC_CONFIG7_CSVALID;
>  	gpmc_cs_write_reg(cs, GPMC_CS_CONFIG7, l);
>  
> 


  parent reply	other threads:[~2015-01-26  9:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-24 20:28 [PATCH 1/3] ARM: OMAP2+: gpmc: Fix writing in gpmc_cs_set_memconf Semen Protsenko
2015-01-24 20:28 ` [PATCH 2/3] ARM: OMAP2+: gpmc: make gpmc_cs_get_name() static Semen Protsenko
2015-01-26  9:20   ` Roger Quadros
2015-01-26  9:20     ` Roger Quadros
2015-02-02 17:07     ` Tony Lindgren
2015-01-24 20:28 ` [PATCH 3/3] ARM: OMAP2+: gpmc: Do not modify LIMITEDADDRESS on new architectures Semen Protsenko
2015-01-26  9:50   ` Roger Quadros
2015-01-26  9:50     ` Roger Quadros
2015-01-26 13:07     ` Sam Protsenko
2015-01-26 15:46       ` Roger Quadros
2015-01-26 15:46         ` Roger Quadros
2015-01-26  9:34 ` Roger Quadros [this message]
2015-01-26  9:34   ` [PATCH 1/3] ARM: OMAP2+: gpmc: Fix writing in gpmc_cs_set_memconf Roger Quadros
2015-02-02 17:08   ` Tony Lindgren
2015-02-03  9:30     ` Roger Quadros
2015-02-03  9:30       ` Roger Quadros

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=54C60A3A.1090008@ti.com \
    --to=rogerq@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=semen.protsenko@globallogic.com \
    --cc=tony@atomide.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.