Thread (25 messages) read the whole thread 25 messages, 4 authors, 2022-07-05

Re: [PATCH v2 1/9] serial: core: only get RS485 termination GPIO if supported

From: Andy Shevchenko <hidden>
Date: 2022-07-03 18:28:22
Also in: linux-devicetree, linux-serial, lkml

On Sun, Jul 3, 2022 at 7:02 PM Lino Sanfilippo [off-list ref] wrote:
From: Lino Sanfilippo <redacted>

In uart_get_rs485_mode() only try to get a termination GPIO if RS485 bus
termination is supported by the driver. This prevents from allocating
and holding a GPIO descriptor for the drivers lifetimg that will never be
lifetiming
used.
...
        port->rs485_term_gpio = devm_gpiod_get_optional(dev, "rs485-term",
                                                        GPIOD_OUT_LOW);
+
+       if (port->rs485_term_gpio &&
This check is incorrect. Either you need to move that after error
checking (that's what I personally prefer), or use !IS_ERR_OR_NULL().
+           !(port->rs485_supported->flags & SER_RS485_TERMINATE_BUS)) {
+               dev_warn(port->dev,
+                       "%s (%d): RS485 termination gpio not supported by driver\n",
+                       port->name, port->line);
+               devm_gpiod_put(dev, port->rs485_term_gpio);
+               port->rs485_term_gpio = NULL;
+       }
+
        if (IS_ERR(port->rs485_term_gpio)) {
                ret = PTR_ERR(port->rs485_term_gpio);
                port->rs485_term_gpio = NULL;

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help