palm_bk3710 buildfix
PATCH 1/1 palm_bk3710 buildfix
From: David Brownell <[email protected]>
Subject: drivers/ide/palm_bk3710.c buildfix
CC drivers/ide/palm_bk3710.odrivers/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 *".
--- drivers/ide/palm_bk3710.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/ide/palm_bk3710.c +7 -4
@@ -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 ); hw.irq = irq->start; hw.dev = &pdev->dev; hw.chipset = ide_palm3710;
Hello.
Quoted 6 lines · David Brownell
CC
drivers/ide/palm_bk3710.odrivers/ide/palm_bk3710.c: In function 'palm_bk3710_probe':drivers/ide/palm_bk3710.c:382: warning: assignment makes integer from pointer without a castSomeone should fix
hw_regs_tto 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.
Quoted 18 lines
Signed-off-by David Brownell <[email protected]>drivers/ide/palm_bk3710.c +2
-1@@ -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 */
drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru · line 392
Quoted 10 lines
drivers/ide/palm_bk3710.c +5
-3-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...
drivers/ide/palm_bk3710.c +4 -2
@@ -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(strureturn -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;
MBR, Sergei
Quoted 4 lines · Sergei Shtylyov
Quoted 2 lines
Someone should fix
hw_regs_tto 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.
It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
- Dave
Hello.
Quoted 11 lines · David Brownell
Quoted 5 lines · Sergei Shtylyov
Quoted 3 lines
Someone should fix
hw_regs_tto 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.
It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
Probably they can... though using those would only slow down register
access on x86.
Quoted 1 line
- Dave
WBR, Sergei
Quoted 7 lines · Hello, I wrote:
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Someone should fix
hw_regs_tto 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.
Quoted 6 lines
Quoted 3 lines
It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
Probably they can... though using those would only slow down
register access on x86.
... and cause code bloat due to switching to real function calls from
inlines which now should render into in/out isns.
Quoted 1 line
- Dave
WBR, Sergei
Quoted 13 lines · Sergei Shtylyov
Quoted 11 lines · Hello, I wrote:
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Someone should fix
hw_regs_tto 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.It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
Quoted 5 lines
Quoted 2 lines
Probably they can... though using those would only slow down
register access on x86.... and cause code bloat due to switching to real function calls from
inlines which now should render into in/out isns.
OTOH it would allow to unify a lot of 'if (hwif->host_flags & IDE_HFLAG_MMIO)' cases so the code may even shrink. I also suspect that register access slow down is most likely negligable (we can always measure and check it).
The real reason for not using ioread*() and co. is that not all archs support them (though I checked some time ago, maybe they do now?) and we don't want to break IDE support for them.
Thanks,
Bart
Quoted 9 lines · Bartlomiej Zolnierkiewicz
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Someone should fix
hw_regs_tto 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.It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Probably they can... though using those would only slow down
register access on x86.... and cause code bloat due to switching to real function calls from
inlines which now should render into in/out isns.OTOH it would allow to unify a lot of 'if (
hwif->host_flags&IDE_HFLAG_MMIO)' cases so the code may even shrink.
It won't shrink as much as it will grow.
Quoted 2 lines
I also suspect that register access slow
down is most likely negligable (we can always measure and check it).
I'd agree here but code bloat won't be as negligible considering the IDE
code's predominant use of I/O ports on x86.
Quoted 3 lines
The real reason for not using ioread*() and co. is that not all archs support them (though I checked some time ago, maybe they do now?) and we don't want to break IDE support for them.
Sure. :-)
Quoted 2 lines
Thanks,
Bart
MBR, Sergei
Quoted 18 lines · Hello, I wrote:
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Someone should fix
hw_regs_tto 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.It could use the ioread*() calls, which take pointers and handle both types of I/O in a type-safe manner.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Probably they can... though using those would only slow down
register access on x86.... and cause code bloat due to switching to real function calls
from inlines which now should render into in/out isns.OTOH it would allow to unify a lot of 'if (
hwif->host_flags&IDE_HFLAG_MMIO)' cases so the code may even shrink.
Quoted 7 lines
It won't shrink as much as it will grow.
Quoted 2 lines
I also suspect that register access slow
down is most likely negligable (we can always measure and check it).I'd agree here but code bloat won't be as negligible considering the
IDE code's predominant use of I/O ports on x86.
After looking at the current code, the generic IDE code would actually
benefit from such change, while the most of the controller drivers will only be subject to the code bloat.
MBR, Sergei
Quoted 60 lines · Sergei Shtylyov
Hello.
Quoted 6 lines · David Brownell
CC
drivers/ide/palm_bk3710.odrivers/ide/palm_bk3710.c: In function 'palm_bk3710_probe':drivers/ide/palm_bk3710.c:382: warning: assignment makes integer from pointer without a castSomeone should fix
hw_regs_tto 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.
Quoted 18 lines
Signed-off-by David Brownell <[email protected]>drivers/ide/palm_bk3710.c +2
-1@@ -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 */ drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru · line 392
Quoted 10 lines
drivers/ide/palm_bk3710.c +5
-3-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...
drivers/ide/palm_bk3710.c +1
-1@@ -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(strureturn -EBUSY ; } - base =IO_ADDRESS (mem->start);
drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru
Quoted 10 lines
drivers/ide/palm_bk3710.c +3
-1+ 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...
Hello.
Quoted 62 lines · Bartlomiej Zolnierkiewicz
Quoted 62 lines
Quoted 6 lines
CC
drivers/ide/palm_bk3710.odrivers/ide/palm_bk3710.c: In function 'palm_bk3710_probe':drivers/ide/palm_bk3710.c:382: warning: assignment makes integer from pointer without a castSomeone should fix
hw_regs_tto 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.
Quoted 18 lines
Signed-off-by David Brownell <[email protected]>drivers/ide/palm_bk3710.c +2
-1@@ -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 */ drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru · line 392
Quoted 10 lines
drivers/ide/palm_bk3710.c +5
-3-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...
drivers/ide/palm_bk3710.c +3
-2@@ -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(strureturn -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);
Quoted 7 lines
drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru
Quoted 4 lines
drivers/ide/palm_bk3710.c +1
-0+ 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.
MBR, Sergei
Quoted 74 lines · Sergei Shtylyov
Hello.
Quoted 62 lines · Bartlomiej Zolnierkiewicz
Quoted 62 lines
Quoted 6 lines
CC
drivers/ide/palm_bk3710.odrivers/ide/palm_bk3710.c: In function 'palm_bk3710_probe':drivers/ide/palm_bk3710.c:382: warning: assignment makes integer from pointer without a castSomeone should fix
hw_regs_tto 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.
Quoted 18 lines
Signed-off-by David Brownell <[email protected]>drivers/ide/palm_bk3710.c +2
-1@@ -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 */ drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru · line 392
Quoted 10 lines
drivers/ide/palm_bk3710.c +5
-3-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...
drivers/ide/palm_bk3710.c +3
-2@@ -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(strureturn -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);Quoted 7 lines
drivers/ide/palm_bk3710.c static int __init palm_bk3710_probe(stru
Quoted 4 lines
drivers/ide/palm_bk3710.c +1
-0+ 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...
Quoted 2 lines
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