linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: David Brownell <david-b@pacbell.net>,
	linux-ide@vger.kernel.org,
	Kevin Hilman <khilman@deeprootsystems.com>
Subject: Re: [patch 2.6.29-rc2] palm_bk3710 buildfix
Date: Mon, 19 Jan 2009 14:21:10 +0100	[thread overview]
Message-ID: <200901191421.10717.bzolnier@gmail.com> (raw)
In-Reply-To: <49747A0A.2000305@ru.mvista.com>

On Monday 19 January 2009, Sergei Shtylyov wrote:
> Hello.
> 
> Bartlomiej Zolnierkiewicz wrote:
> 
> >>>  CC      drivers/ide/palm_bk3710.o
> >>>drivers/ide/palm_bk3710.c: In function 'palm_bk3710_probe':
> >>>drivers/ide/palm_bk3710.c:382: warning: assignment makes integer from pointer without a cast
> 
> >>>Someone should fix hw_regs_t to neither be a typedef, nor
> >>>use "unsigned long" where it should use "void __iomem *".
> 
> >>    It cannot use pointers of course -- as the addresses can be I/O ports.
> 
> >>>Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> 
> >>>--- a/drivers/ide/palm_bk3710.c
> >>>+++ b/drivers/ide/palm_bk3710.c
> >>>@@ -346,7 +346,8 @@ static int __init palm_bk3710_probe(stru
> >>> {
> >>> 	struct clk *clk;
> >>> 	struct resource *mem, *irq;
> >>>-	unsigned long base, rate;
> >>>+	void __iomem *base;
> >>>+	unsigned long rate;
> >>> 	int i, rc;
> >>> 	hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
> >>> 
> >>>@@ -382,11 +383,13 @@ static int __init palm_bk3710_probe(stru
> >>> 	base = IO_ADDRESS(mem->start);
> >>> 
> >>> 	/* Configure the Palm Chip controller */
> >>>-	palm_bk3710_chipinit((void __iomem *)base);
> >>>+	palm_bk3710_chipinit(base);
> >>> 
> >>> 	for (i = 0; i < IDE_NR_PORTS - 2; i++)
> >>>-		hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i;
> >>>-	hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET;
> >>>+		hw.io_ports_array[i] = (unsigned long)
> >>>+				(base + IDE_PALM_ATA_PRI_REG_OFFSET + i);
> >>>+	hw.io_ports.ctl_addr = (unsigned long)
> >>>+			(base + IDE_PALM_ATA_PRI_CTL_OFFSET);
> 
> >>    Ugh. I suggest adding another variable...
> 
> >>--- a/drivers/ide/palm_bk3710.c
> >>+++ b/drivers/ide/palm_bk3710.c
> >>@@ -346,7 +346,8 @@ static int __init palm_bk3710_probe(stru
> >>  {
> >>  	struct clk *clk;
> >>  	struct resource *mem, *irq;
> >>  	unsigned long base, rate;
> >>+	void __iomem *regs;
> >>  	int i, rc;
> >>  	hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
> >>
> >>@@ -379,11 +380,11 @@ static int __init palm_bk3710_probe(stru
> >>  		return -EBUSY;
> >>  	}
> >>
> >>- 	base = IO_ADDRESS(mem->start);
> >>+ 	regs = IO_ADDRESS(mem->start);
> >>
> >>  	/* Configure the Palm Chip controller */
> >>-	palm_bk3710_chipinit((void __iomem *)base);
> >>+	palm_bk3710_chipinit(regs);
> >>
> >>+	base = (unsigned long)regs;
> >>  	for (i = 0; i < IDE_NR_PORTS - 2; i++)
> >>  		hw.io_ports_array[i] = base + IDE_PALM_ATA_PRI_REG_OFFSET + i;
> >>  	hw.io_ports.ctl_addr = base + IDE_PALM_ATA_PRI_CTL_OFFSET;
> 
> > I applied original patch since having one additional cast has overally lower
> > complexity than having an additional variable...
> 
>     Grr... as if the stack use aren't optimized by gcc based on the variable 
> lifetimes. I can recast the patch myself BTW.

I meant code complexity in the maintainance / readability context here.

You know what this variable is for (at least now but a year from now it may
result in a brief WTF moment when looking at base/regs) and that it is short
lived but some random person who will need to update this driver won't...

Thanks,
Bart

      reply	other threads:[~2009-01-19 13:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 16:33 [patch 2.6.29-rc2] palm_bk3710 buildfix David Brownell
2009-01-18 17:14 ` Sergei Shtylyov
2009-01-19  0:29   ` David Brownell
2009-01-19  8:35     ` Sergei Shtylyov
2009-01-19  8:57       ` Sergei Shtylyov
2009-01-19 12:07         ` Bartlomiej Zolnierkiewicz
2009-01-19 13:06           ` Sergei Shtylyov
2009-01-19 14:14             ` Sergei Shtylyov
2009-01-19 12:00   ` Bartlomiej Zolnierkiewicz
2009-01-19 13:03     ` Sergei Shtylyov
2009-01-19 13:21       ` Bartlomiej Zolnierkiewicz [this message]

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=200901191421.10717.bzolnier@gmail.com \
    --to=bzolnier@gmail.com \
    --cc=david-b@pacbell.net \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=sshtylyov@ru.mvista.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 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).