[PATCH v2 2/9] serial: core, 8250: set RS485 termination gpio in serial core

Lino Sanfilippo LinoSanfilippo at gmx.de
Mon Jul 4 02:25:22 PDT 2022



On 03.07.22 20:31, Andy Shevchenko wrote:
> On Sun, Jul 3, 2022 at 7:02 PM Lino Sanfilippo <LinoSanfilippo at gmx.de> wrote:
>>
>> From: Lino Sanfilippo <l.sanfilippo at kunbus.com>
>>
>> In serial8250_em485_config() the termination GPIO is set with the uart_port
>> spinlock held. This is an issue if setting the GPIO line can sleep (e.g.
>> since the concerning GPIO expander is connected via SPI or I2C).
>>
>> Fix this by setting the termination line outside of the uart_port spinlock
>> in the serial core and using gpiod_set_value_cansleep() which instead of
>> gpiod_set_value() allows to sleep.
>
> allows it to
>

Ok.

>> Beside fixing the termination GPIO line setting for the 8250 driver this
>> change also makes setting the termination GPIO generic for all UART
>> drivers.
>
> ...
>
>> +static void uart_set_rs485_termination(struct uart_port *port,
>> +                                      const struct serial_rs485 *rs485)
>> +{
>
>> +       if (!port->rs485_term_gpio
>
> This duplicates the check the GPIO library does. Drop it.
>

Ok.

>> || !(rs485->flags & SER_RS485_ENABLED))
>> +               return;
>> +
>> +       gpiod_set_value_cansleep(port->rs485_term_gpio,
>> +                                !!(rs485->flags & SER_RS485_TERMINATE_BUS));
>> +}
>

Thanks for the review!

Regards,
Lino



More information about the linux-arm-kernel mailing list