public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
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

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1285063280-4057-1-git-send-email-manjugk@ti.com>
     [not found] ` <1285063280-4057-8-git-send-email-manjugk@ti.com>
2010-09-27 11:07   ` [PATCH v2 07/10] TWL CORE: Fix sparse warning Samuel Ortiz
     [not found] ` <1285063280-4057-9-git-send-email-manjugk@ti.com>
2010-09-27 11:16   ` [PATCH v2 08/10] TWL IRQ: Fix fucntion declaration warnings Samuel Ortiz
2010-09-27 13:10     ` G, Manjunath Kondaiah
2010-09-27 13:49       ` G, Manjunath Kondaiah
2010-09-27 14:46         ` Samuel Ortiz
     [not found] ` <1285063280-4057-4-git-send-email-manjugk@ti.com>
2010-09-29 21:35   ` [PATCH v2 03/10] OMAP: mach-omap2: Fix static function warnings Paul Walmsley
2010-09-29 23:49     ` G, Manjunath Kondaiah
     [not found] ` <1285063280-4057-10-git-send-email-manjugk@ti.com>
2010-10-07 12:17   ` [PATCH v2 09/10] OMAP2/3: Convert write/read functions to raw read/write Menon, Nishanth
2010-10-07 18:56     ` Russell King - ARM Linux
2010-10-07 19:50       ` Nishanth Menon
2010-10-25  0:01         ` David Woodhouse
2010-10-25  5:34           ` G, Manjunath Kondaiah
2010-10-25 10:11             ` David Woodhouse
2010-10-25  7:54           ` Artem Bityutskiy
2010-10-07 17:39   ` Vimal Singh
     [not found] ` <1285063280-4057-2-git-send-email-manjugk@ti.com>
2010-10-08 20:12   ` Kevin Hilman [this message]
2010-10-11  3:51     ` [PATCH v2 01/10] OMAP: mach-omap2: Fix incorrect assignment warnings 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$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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