Re: [PATCH DON'T APPLY v2 3/7] serial: 8250: Support rs485 bus termination GPIO

From: Andy Shevchenko
Date: Mon Mar 30 2020 - 10:51:05 EST


On Thu, Mar 26, 2020 at 12:14:18AM +0100, Heiko Stuebner wrote:
> From: Lukas Wunner <lukas@xxxxxxxxx>
>
> Amend the serial core to retrieve the rs485 bus termination GPIO from
> the device tree (or ACPI table) and amend the default ->rs485_config()
> callback for 8250 drivers to change the GPIO on request from user space.

> + port->rs485_term_gpio = devm_gpiod_get(dev, "rs485-term",
> + GPIOD_FLAGS_BIT_DIR_OUT);
> + if (IS_ERR(port->rs485_term_gpio)) {
> + ret = PTR_ERR(port->rs485_term_gpio);
> + port->rs485_term_gpio = NULL;
> + if (ret != -ENOENT) {
> + if (ret != -EPROBE_DEFER)
> + dev_err(dev, "Cannot get rs485-term-gpios\n");
> + return ret;
> + }

NIH of gpiod_get_optional().

> + } else {
> + ret = gpiod_get_value(port->rs485_term_gpio);
> + if (ret < 0) {
> + dev_err(dev, "Cannot get rs485-term-gpios value\n");
> + return ret;
> + }
> + if (ret)
> + rs485conf->flags |= SER_RS485_TERMINATE_BUS;
> + }

--
With Best Regards,
Andy Shevchenko