Commit 31c095b0 authored by Jean-Baptiste Maneyrol's avatar Jean-Baptiste Maneyrol Committed by Jean Delvare

i2c: Add request/release_mem_region to i2c-ibm_iic bus driver

Reserving I/O memory for a driver with request_mem_region is necessary to
avoid memory access conflicts. Even if it's never going to happen, it is
cleaner and it allows to monitor I/O memory used in /proc/iomem.
Signed-off-by: default avatarJean-Baptiste Maneyrol <jean-baptiste.maneyrol@teamlog.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 41561f28
...@@ -680,6 +680,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -680,6 +680,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){
dev->idx = ocp->def->index; dev->idx = ocp->def->index;
ocp_set_drvdata(ocp, dev); ocp_set_drvdata(ocp, dev);
if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs),
"ibm_iic")) {
ret = -EBUSY;
goto fail1;
}
if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){ if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){
printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n", printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
dev->idx); dev->idx);
...@@ -750,6 +756,8 @@ static int __devinit iic_probe(struct ocp_device *ocp){ ...@@ -750,6 +756,8 @@ static int __devinit iic_probe(struct ocp_device *ocp){
iounmap(dev->vaddr); iounmap(dev->vaddr);
fail2: fail2:
release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
fail1:
ocp_set_drvdata(ocp, NULL); ocp_set_drvdata(ocp, NULL);
kfree(dev); kfree(dev);
return ret; return ret;
...@@ -777,6 +785,7 @@ static void __devexit iic_remove(struct ocp_device *ocp) ...@@ -777,6 +785,7 @@ static void __devexit iic_remove(struct ocp_device *ocp)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
} }
iounmap(dev->vaddr); iounmap(dev->vaddr);
release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
kfree(dev); kfree(dev);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment