Skip to contentSkip to conversation

palm_bk3710: fix resource management

PATCH Applied Sergei Shtylyov 2 participants 4 messages Jun 16, 2008 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 palm_bk3710: fix resource management

The driver expected a *virtual* address in the IDE platform device's memory resource and didn't request the memory region for the register block. Fix this taking into account the fact that DaVinci SoC devices are fixed-mapped to the virtual memory early and we can get their virtual addresses using IO_ADDRESS() macro, not having to call ioremap()...

While at it, also do some cosmetic changes...

---
The patch is against the recent Linus' tree.

 drivers/ide/arm/palm_bk3710.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)
drivers/ide/arm/palm_bk3710.c +13 -9
Index: linux-2.6/drivers/ide/arm/palm_bk3710.c
===================================================================
@@ -353,8 +353,8 @@ static int __devinit palm_bk3710_probe(s
 	struct clk *clkp;
 	struct resource *mem, *irq;
 	ide_hwif_t *hwif;
-	void __iomem *base;
-	int pribase, i;
+	unsigned long base;
+	int i;
 	hw_regs_t hw;
 	u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
@@ -374,22 +374,27 @@ static int __devinit palm_bk3710_probe(s
 		printk(KERN_ERR "failed to get memory region resource\n");
 		return -ENODEV;
 	}
+
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (irq == NULL) {
 		printk(KERN_ERR "failed to get IRQ resource\n");
 		return -ENODEV;
 	}
 
-	base = (void *)mem->start;
+	if (request_mem_region(mem->start, mem->end - mem->start + 1,
+			       "palm_bk3710") == NULL) {
+		printk(KERN_ERR "failed to request memory region\n");
+		return -EBUSY;
+	}
+
+	base = IO_ADDRESS(mem->start);
 
 	/* Configure the Palm Chip controller */
-	palm_bk3710_chipinit(base);
+	palm_bk3710_chipinit((void __iomem *)base);
 
-	pribase = mem->start + IDE_PALM_ATA_PRI_REG_OFFSET;
 	for (i = 0; i < IDE_NR_PORTS - 2; i++)
-		hw.io_ports_array[i] = pribase + i;
-	hw.io_ports.ctl_addr = mem->start +
-			IDE_PALM_ATA_PRI_CTL_OFFSET;
+ 		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.irq = irq->start;
 	hw.chipset = ide_palm3710;
 
@@ -434,4 +439,3 @@ static int __init palm_bk3710_init(void)
 
 module_init(palm_bk3710_init);
 MODULE_LICENSE("GPL");
-
#1 lore raw
Quoted 10 lines · Sergei Shtylyov

The driver expected a *virtual* address in the IDE platform device's memory resource and didn't request the memory region for the register block. Fix this taking into account the fact that DaVinci SoC devices are fixed-mapped to the virtual memory early and we can get their virtual addresses using IO_ADDRESS() macro, not having to call ioremap()...

While at it, also do some cosmetic changes...

---
The patch is against the recent Linus' tree.

looks OK but please S-o-b it

#2 lore raw

Hello.

Quoted 6 lines · Bartlomiej Zolnierkiewicz
Quoted 5 lines

The driver expected a *virtual* address in the IDE platform device's memory resource and didn't request the memory region for the register block. Fix this taking into account the fact that DaVinci SoC devices are fixed-mapped to the virtual memory early and we can get their virtual addresses using IO_ADDRESS() macro, not having to call ioremap()...

Quoted 6 lines
Quoted 4 lines

While at it, also do some cosmetic changes...

---
The patch is against the recent Linus' tree.

looks OK but please S-o-b it

Done. I often forget about it, silly SOB. :-)

MBR, Sergei

#3 lore raw
Quoted 10 lines · Sergei Shtylyov

Hello.

Quoted 5 lines · Bartlomiej Zolnierkiewicz
Quoted 5 lines

The driver expected a *virtual* address in the IDE platform device's memory resource and didn't request the memory region for the register block. Fix this taking into account the fact that DaVinci SoC devices are fixed-mapped to the virtual memory early and we can get their virtual addresses using IO_ADDRESS() macro, not having to call ioremap()...

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

While at it, also do some cosmetic changes...

---
The patch is against the recent Linus' tree.

looks OK but please S-o-b it

Done. I often forget about it, silly SOB. :-)

thanks, applied