All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: "G, Manjunath Kondaiah" <manjugk@ti.com>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Tony Lindgren <tony@atomide.com>, Nishanth Menon <nm@ti.com>
Subject: Re: [PATCH v2 01/10] OMAP: mach-omap2: Fix incorrect assignment warnings
Date: Fri, 08 Oct 2010 13:12:58 -0700	[thread overview]
Message-ID: <878w28v3xx.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1285063280-4057-2-git-send-email-manjugk@ti.com> (Manjunath Kondaiah G.'s message of "Tue, 21 Sep 2010 15:31:11 +0530")

"G, Manjunath Kondaiah" <manjugk@ti.com> writes:

> This patch fixes below sparse warnings for incorrect assignments.

As pointed out by Jean, this patch fixed some sparse warnings, but also
broke some things, specifically off mode.

In the future, *please* be sure to test the code paths that are being
changed.  This patch changed some code that is only exercised during
off-mode, but was clearly not tested with off mode enabled.

As background for why this broke functionality, keep this in mind:

 	void *a = NULL;
	u32 *b = NULL;

a + 1 = 1
b + 1 = 4

IOW, you cannot simply replace a 'u32 *' by a 'void *' without checking
and fixing any pointer arithmetic.

[...]

> diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
> index a8d20ee..7405936 100644
> --- a/arch/arm/mach-omap2/control.c
> +++ b/arch/arm/mach-omap2/control.c
> @@ -190,7 +190,7 @@ void omap_ctrl_writel(u32 val, u16 offset)
>  void omap3_clear_scratchpad_contents(void)
>  {
>  	u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET;
> -	u32 *v_addr;
> +	void __iomem *v_addr;
>  	u32 offset = 0;
>  	v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM);
>  	if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) &

Interestingly, this one not only fixed the sparse warning but also fixed
a bug. :) Before this change, only every 4th entry of the scratchpad was
zeroed.

> @@ -206,7 +206,7 @@ void omap3_clear_scratchpad_contents(void)
>  /* Populate the scratchpad structure with restore structure */
>  void omap3_save_scratchpad_contents(void)
>  {
> -	void * __iomem scratchpad_address;
> +	void  __iomem *scratchpad_address;
>  	u32 arm_context_addr;
>  	struct omap3_scratchpad scratchpad_contents;
>  	struct omap3_scratchpad_prcm_block prcm_block_contents;

This one is fine.

> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 7b03426..4af19a6 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
> @@ -316,7 +316,7 @@ static void restore_control_register(u32 val)
>  /* Function to restore the table entry that was modified for enabling MMU */
>  static void restore_table_entry(void)
>  {
> -	u32 *scratchpad_address;
> +	void __iomem *scratchpad_address;
>  	u32 previous_value, control_reg_value;
>  	u32 *address;

This one changes the result of any 'scratchpad_address + foo'.  

So, if this is changed from u32 to void, all the offsets used when
adding to the base need to be changed as well.

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: khilman@deeprootsystems.com (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 01/10] OMAP: mach-omap2: Fix incorrect assignment warnings
Date: Fri, 08 Oct 2010 13:12:58 -0700	[thread overview]
Message-ID: <878w28v3xx.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1285063280-4057-2-git-send-email-manjugk@ti.com> (Manjunath Kondaiah G.'s message of "Tue, 21 Sep 2010 15:31:11 +0530")

"G, Manjunath Kondaiah" <manjugk@ti.com> writes:

> This patch fixes below sparse warnings for incorrect assignments.

As pointed out by Jean, this patch fixed some sparse warnings, but also
broke some things, specifically off mode.

In the future, *please* be sure to test the code paths that are being
changed.  This patch changed some code that is only exercised during
off-mode, but was clearly not tested with off mode enabled.

As background for why this broke functionality, keep this in mind:

 	void *a = NULL;
	u32 *b = NULL;

a + 1 = 1
b + 1 = 4

IOW, you cannot simply replace a 'u32 *' by a 'void *' without checking
and fixing any pointer arithmetic.

[...]

> diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
> index a8d20ee..7405936 100644
> --- a/arch/arm/mach-omap2/control.c
> +++ b/arch/arm/mach-omap2/control.c
> @@ -190,7 +190,7 @@ void omap_ctrl_writel(u32 val, u16 offset)
>  void omap3_clear_scratchpad_contents(void)
>  {
>  	u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET;
> -	u32 *v_addr;
> +	void __iomem *v_addr;
>  	u32 offset = 0;
>  	v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM);
>  	if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) &

Interestingly, this one not only fixed the sparse warning but also fixed
a bug. :) Before this change, only every 4th entry of the scratchpad was
zeroed.

> @@ -206,7 +206,7 @@ void omap3_clear_scratchpad_contents(void)
>  /* Populate the scratchpad structure with restore structure */
>  void omap3_save_scratchpad_contents(void)
>  {
> -	void * __iomem scratchpad_address;
> +	void  __iomem *scratchpad_address;
>  	u32 arm_context_addr;
>  	struct omap3_scratchpad scratchpad_contents;
>  	struct omap3_scratchpad_prcm_block prcm_block_contents;

This one is fine.

> diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
> index 7b03426..4af19a6 100644
> --- a/arch/arm/mach-omap2/pm34xx.c
> +++ b/arch/arm/mach-omap2/pm34xx.c
> @@ -316,7 +316,7 @@ static void restore_control_register(u32 val)
>  /* Function to restore the table entry that was modified for enabling MMU */
>  static void restore_table_entry(void)
>  {
> -	u32 *scratchpad_address;
> +	void __iomem *scratchpad_address;
>  	u32 previous_value, control_reg_value;
>  	u32 *address;

This one changes the result of any 'scratchpad_address + foo'.  

So, if this is changed from u32 to void, all the offsets used when
adding to the base need to be changed as well.

Kevin

  reply	other threads:[~2010-10-08 20:13 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-21 10:01 [PATCH v2 00/10] OMAP2/TWL: Fix Sparse warnings G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 01/10] OMAP: mach-omap2: Fix incorrect assignment warnings G, Manjunath Kondaiah
2010-10-08 20:12   ` Kevin Hilman [this message]
2010-10-08 20:12     ` Kevin Hilman
2010-10-11  3:51     ` G, Manjunath Kondaiah
2010-10-11  3:51       ` G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 02/10] OMAP: mach-omap2: Fix static declaration warnings G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 03/10] OMAP: mach-omap2: Fix static function warnings G, Manjunath Kondaiah
2010-09-29 21:35   ` Paul Walmsley
2010-09-29 21:35     ` Paul Walmsley
2010-09-29 23:49     ` G, Manjunath Kondaiah
2010-09-29 23:49       ` G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 04/10] OMAP: mach-omap2: Fix miscellaneous sparse warnings G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 05/10] OMAP: plat-omap: Fix static function warnings G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 06/10] OMAP: NAND: Fix static declaration warning G, Manjunath Kondaiah
2010-09-21 10:01 ` [PATCH v2 07/10] TWL CORE: Fix sparse warning G, Manjunath Kondaiah
2010-09-27 11:07   ` Samuel Ortiz
2010-09-27 11:07     ` Samuel Ortiz
2010-09-21 10:01 ` [PATCH v2 08/10] TWL IRQ: Fix fucntion declaration warnings G, Manjunath Kondaiah
2010-09-27 11:16   ` Samuel Ortiz
2010-09-27 11:16     ` Samuel Ortiz
2010-09-27 13:10     ` G, Manjunath Kondaiah
2010-09-27 13:10       ` G, Manjunath Kondaiah
2010-09-27 13:49       ` G, Manjunath Kondaiah
2010-09-27 13:49         ` G, Manjunath Kondaiah
2010-09-27 14:46         ` Samuel Ortiz
2010-09-27 14:46           ` Samuel Ortiz
2010-09-21 10:01 ` [PATCH v2 09/10] OMAP2/3: Convert write/read functions to raw read/write G, Manjunath Kondaiah
2010-10-07 12:17   ` Menon, Nishanth
2010-10-07 12:17     ` Menon, Nishanth
2010-10-07 12:17     ` Menon, Nishanth
2010-10-07 18:56     ` Russell King - ARM Linux
2010-10-07 18:56       ` Russell King - ARM Linux
2010-10-07 19:50       ` Nishanth Menon
2010-10-07 19:50         ` Nishanth Menon
2010-10-25  0:01         ` David Woodhouse
2010-10-25  0:01           ` David Woodhouse
2010-10-25  0:01           ` David Woodhouse
2010-10-25  5:34           ` G, Manjunath Kondaiah
2010-10-25  5:34             ` G, Manjunath Kondaiah
2010-10-25  5:34             ` G, Manjunath Kondaiah
2010-10-25 10:11             ` David Woodhouse
2010-10-25 10:11               ` David Woodhouse
2010-10-25 10:11               ` David Woodhouse
2010-10-25  7:54           ` Artem Bityutskiy
2010-10-25  7:54             ` Artem Bityutskiy
2010-10-25  7:54             ` Artem Bityutskiy
2010-10-07 17:39   ` Vimal Singh
2010-10-07 17:39     ` Vimal Singh
2010-09-21 10:01 ` [PATCH v2 10/10] OMAP3: Keypad: Fix incorrect type initializer G, Manjunath Kondaiah

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=878w28v3xx.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=manjugk@ti.com \
    --cc=nm@ti.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.