static int __devinit of_platform_serial_probe(struct platform_device *ofdev) { const struct of_device_id *match; struct of_serial_info *info; struct uart_port port; int port_type; int ret; match = of_match_device(of_platform_serial_table, &ofdev->dev); if (!match) return -EINVAL; if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) return -EBUSY; info = kmalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; port_type = (unsigned long)match->data; ret = of_platform_serial_setup(ofdev, port_type, &port); if (ret) goto out; switch (port_type) { #ifdef CONFIG_SERIAL_8250 case PORT_8250 ... PORT_MAX_8250: ret = serial8250_register_port(&port); break; #endif #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL case PORT_NWPSERIAL: ret = nwpserial_register_port(&port); break; #endif default: /* need to add code for these */ case PORT_UNKNOWN: dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); ret = -ENODEV; break; } if (ret < 0) goto out; info->type = port_type; info->line = ret; dev_set_drvdata(&ofdev->dev, info); return 0; out: kfree(info); irq_dispose_mapping(port.irq); return ret; }
static int of_platform_serial_probe(struct platform_device *ofdev) { const struct of_device_id *match; struct of_serial_info *info; struct uart_8250_port port8250; u32 tx_threshold; int port_type; int ret; match = of_match_device(of_platform_serial_table, &ofdev->dev); if (!match) return -EINVAL; if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) return -EBUSY; info = kzalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; port_type = (unsigned long)match->data; memset(&port8250, 0, sizeof(port8250)); ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info); if (ret) goto out; if (port8250.port.fifosize) port8250.capabilities = UART_CAP_FIFO; /* Check for TX FIFO threshold & set tx_loadsz */ if ((of_property_read_u32(ofdev->dev.of_node, "tx-threshold", &tx_threshold) == 0) && (tx_threshold < port8250.port.fifosize)) port8250.tx_loadsz = port8250.port.fifosize - tx_threshold; if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control")) port8250.capabilities |= UART_CAP_AFE; ret = serial8250_register_8250_port(&port8250); if (ret < 0) goto out; info->type = port_type; info->line = ret; platform_set_drvdata(ofdev, info); return 0; out: kfree(info); irq_dispose_mapping(port8250.port.irq); return ret; }
/* * Try to register a serial port */ static int __devinit of_platform_serial_probe(struct of_device *ofdev, const struct of_device_id *id) { struct of_serial_info *info; struct uart_port port; int port_type; int ret; if (of_find_property(ofdev->node, "used-by-rtas", NULL)) return -EBUSY; info = kmalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; port_type = (unsigned long)id->data; ret = of_platform_serial_setup(ofdev, port_type, &port); if (ret) goto out; switch (port_type) { case PORT_8250 ... PORT_MAX_8250: ret = serial8250_register_port(&port); break; default: /* need to add code for these */ case PORT_UNKNOWN: dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); ret = -ENODEV; break; } if (ret < 0) goto out; info->type = port_type; info->line = ret; ofdev->dev.driver_data = info; return 0; out: kfree(info); irq_dispose_mapping(port.irq); return ret; }
static int of_platform_serial_probe(struct platform_device *ofdev) { const struct of_device_id *match; struct of_serial_info *info; struct uart_port port; int port_type; int ret; int ids; match = of_match_device(of_platform_serial_table, &ofdev->dev); if (!match) return -EINVAL; if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) return -EBUSY; info = kzalloc(sizeof(*info), GFP_KERNEL); if (info == NULL) return -ENOMEM; port_type = (unsigned long)match->data; ret = of_platform_serial_setup(ofdev, port_type, &port, info); if (ret) goto out; ids = of_alias_get_id(ofdev->dev.of_node, "serial"); if (ids < 0) { dev_warn(&ofdev->dev, "FAILED to find out alias id\n"); } else { if (ids < CONFIG_SERIAL_8250_RUNTIME_UARTS) port.line = ids; else { dev_warn(&ofdev->dev, "FAILED to register serial driver with id %d\n", ids); goto out; } } switch (port_type) { #ifdef CONFIG_SERIAL_8250 case PORT_8250 ... PORT_MAX_8250: { struct uart_8250_port port8250; memset(&port8250, 0, sizeof(port8250)); port.type = port_type; port8250.port = port; if (port.fifosize) port8250.capabilities = UART_CAP_FIFO; if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control")) port8250.capabilities |= UART_CAP_AFE; ret = serial8250_register_8250_port(&port8250); break; } #endif #ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL case PORT_NWPSERIAL: ret = nwpserial_register_port(&port); break; #endif default: /* need to add code for these */ case PORT_UNKNOWN: dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); ret = -ENODEV; break; } if (ret < 0) goto out; info->type = port_type; info->line = ret; platform_set_drvdata(ofdev, info); return 0; out: kfree(info); irq_dispose_mapping(port.irq); return ret; }