Commit b84e7731 authored by Grant Likely's avatar Grant Likely

tty/serial: change of_serial to use new of_property_read_u32() api

Simplifies the code a bit and drops a few lines.
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
parent f09bc831
...@@ -32,17 +32,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, ...@@ -32,17 +32,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
{ {
struct resource resource; struct resource resource;
struct device_node *np = ofdev->dev.of_node; struct device_node *np = ofdev->dev.of_node;
const __be32 *clk, *spd; u32 clk, spd, prop;
const __be32 *prop; int ret;
int ret, prop_size;
memset(port, 0, sizeof *port); memset(port, 0, sizeof *port);
spd = of_get_property(np, "current-speed", NULL); if (of_property_read_u32(np, "clock-frequency", &clk)) {
clk = of_get_property(np, "clock-frequency", NULL);
if (!clk) {
dev_warn(&ofdev->dev, "no clock-frequency property set\n"); dev_warn(&ofdev->dev, "no clock-frequency property set\n");
return -ENODEV; return -ENODEV;
} }
/* If current-speed was set, then try not to change it. */
if (of_property_read_u32(np, "current-speed", &spd) == 0)
port->custom_divisor = clk / (16 * spd);
ret = of_address_to_resource(np, 0, &resource); ret = of_address_to_resource(np, 0, &resource);
if (ret) { if (ret) {
...@@ -54,20 +54,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, ...@@ -54,20 +54,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
port->mapbase = resource.start; port->mapbase = resource.start;
/* Check for shifted address mapping */ /* Check for shifted address mapping */
prop = of_get_property(np, "reg-offset", &prop_size); if (of_property_read_u32(np, "reg-offset", &prop) == 0)
if (prop && (prop_size == sizeof(u32))) port->mapbase += prop;
port->mapbase += be32_to_cpup(prop);
/* Check for registers offset within the devices address range */ /* Check for registers offset within the devices address range */
prop = of_get_property(np, "reg-shift", &prop_size); if (of_property_read_u32(np, "reg-shift", &prop) == 0)
if (prop && (prop_size == sizeof(u32))) port->regshift = prop;
port->regshift = be32_to_cpup(prop);
port->irq = irq_of_parse_and_map(np, 0); port->irq = irq_of_parse_and_map(np, 0);
port->iotype = UPIO_MEM; port->iotype = UPIO_MEM;
prop = of_get_property(np, "reg-io-width", &prop_size); if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
if (prop && (prop_size == sizeof(u32))) { switch (prop) {
switch (be32_to_cpup(prop)) {
case 1: case 1:
port->iotype = UPIO_MEM; port->iotype = UPIO_MEM;
break; break;
...@@ -75,21 +72,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, ...@@ -75,21 +72,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
port->iotype = UPIO_MEM32; port->iotype = UPIO_MEM32;
break; break;
default: default:
dev_warn(&ofdev->dev, dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
"unsupported io width (%d bytes)\n", prop);
be32_to_cpup(prop));
return -EINVAL; return -EINVAL;
} }
} }
port->type = type; port->type = type;
port->uartclk = be32_to_cpup(clk); port->uartclk = clk;
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
| UPF_FIXED_PORT | UPF_FIXED_TYPE; | UPF_FIXED_PORT | UPF_FIXED_TYPE;
port->dev = &ofdev->dev; port->dev = &ofdev->dev;
/* If current-speed was set, then try not to change it. */
if (spd)
port->custom_divisor = be32_to_cpup(clk) / (16 * (be32_to_cpup(spd)));
return 0; return 0;
} }
......
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