Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3a411a3 authored by David S. Miller's avatar David S. Miller
Browse files

[SPARC64]: Fix of_iounmap() region release.



We need to pass in the resource otherwise we cannot
release the region properly.  We must know whether it is
an I/O or MEM resource.

Spotted by Eric Brower.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6fc5bae7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ void __iomem *of_ioremap(struct resource *res, unsigned long offset,
}
EXPORT_SYMBOL(of_ioremap);

void of_iounmap(void __iomem *base, unsigned long size)
void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
{
	iounmap(base);
}
+5 −2
Original line number Diff line number Diff line
@@ -144,8 +144,11 @@ void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned lo
}
EXPORT_SYMBOL(of_ioremap);

void of_iounmap(void __iomem *base, unsigned long size)
void of_iounmap(struct resource *res, void __iomem *base, unsigned long size)
{
	if (res->flags & IORESOURCE_MEM)
		release_mem_region((unsigned long) base, size);
	else
		release_region((unsigned long) base, size);
}
EXPORT_SYMBOL(of_iounmap);
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ static int i8042_aux_irq = -1;
#define I8042_MUX_PHYS_DESC "sparcps2/serio%d"

static void __iomem *kbd_iobase;
static struct resource *kbd_res;

#define I8042_COMMAND_REG	(kbd_iobase + 0x64UL)
#define I8042_DATA_REG		(kbd_iobase + 0x60UL)
@@ -60,6 +61,7 @@ static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_dev
			i8042_kbd_irq = irq;
			kbd_iobase = of_ioremap(&kbd->resource[0],
						0, 8, "kbd");
			kbd_res = &kbd->resource[0];
		} else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
			   !strcmp(dp->name, OBP_PS2MS_NAME2)) {
			struct of_device *ms = of_find_device_by_node(dp);
@@ -77,7 +79,7 @@ static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_dev

static int __devexit sparc_i8042_remove(struct of_device *op)
{
	of_iounmap(kbd_iobase, 8);
	of_iounmap(kbd_res, kbd_iobase, 8);

	return 0;
}
@@ -119,7 +121,7 @@ static int __init i8042_platform_init(void)
		if (i8042_kbd_irq == -1 ||
		    i8042_aux_irq == -1) {
			if (kbd_iobase) {
				of_iounmap(kbd_iobase, 8);
				of_iounmap(kbd_res, kbd_iobase, 8);
				kbd_iobase = (void __iomem *) NULL;
			}
			return -ENODEV;
+8 −3
Original line number Diff line number Diff line
@@ -1037,7 +1037,8 @@ static int __devinit sunsab_init_one(struct uart_sunsab_port *up,
		err = request_irq(up->port.irq, sunsab_interrupt,
				  IRQF_SHARED, "sab", up);
		if (err) {
			of_iounmap(up->port.membase,
			of_iounmap(&op->resource[0],
				   up->port.membase,
				   sizeof(union sab82532_async_regs));
			return err;
		}
@@ -1064,7 +1065,8 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *
			      sizeof(union sab82532_async_regs),
			      (inst * 2) + 1);
	if (err) {
		of_iounmap(up[0].port.membase,
		of_iounmap(&op->resource[0],
			   up[0].port.membase,
			   sizeof(union sab82532_async_regs));
		free_irq(up[0].port.irq, &up[0]);
		return err;
@@ -1082,10 +1084,13 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *

static void __devexit sab_remove_one(struct uart_sunsab_port *up)
{
	struct of_device *op = to_of_device(up->port.dev);

	uart_remove_one_port(&sunsab_reg, &up->port);
	if (!(up->port.line & 1))
		free_irq(up->port.irq, up);
	of_iounmap(up->port.membase,
	of_iounmap(&op->resource[0],
		   up->port.membase,
		   sizeof(union sab82532_async_regs));
}

+5 −5
Original line number Diff line number Diff line
@@ -1480,13 +1480,13 @@ static int __devinit su_probe(struct of_device *op, const struct of_device_id *m
	return 0;

out_unmap:
	of_iounmap(up->port.membase, up->reg_size);
	of_iounmap(&op->resource[0], up->port.membase, up->reg_size);
	return err;
}

static int __devexit su_remove(struct of_device *dev)
static int __devexit su_remove(struct of_device *op)
{
	struct uart_sunsu_port *up = dev_get_drvdata(&dev->dev);;
	struct uart_sunsu_port *up = dev_get_drvdata(&op->dev);

	if (up->su_type == SU_PORT_MS ||
	    up->su_type == SU_PORT_KBD) {
@@ -1499,9 +1499,9 @@ static int __devexit su_remove(struct of_device *dev)
	}

	if (up->port.membase)
		of_iounmap(up->port.membase, up->reg_size);
		of_iounmap(&op->resource[0], up->port.membase, up->reg_size);

	dev_set_drvdata(&dev->dev, NULL);
	dev_set_drvdata(&op->dev, NULL);

	return 0;
}
Loading