[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJs94EZNi=g5D08c9-m0aGQFTDUSksaJNsrcT6RYsyd_az75Qg@mail.gmail.com>
Date: Thu, 11 Feb 2016 22:08:11 +0300
From: "Matwey V. Kornilov" <matwey@....msu.ru>
To: Ильяс Гасанов
<torso.nafi@...il.com>
Cc: Greg KH <gregkh@...uxfoundation.org>, Jiri Slaby <jslaby@...e.com>,
Peter Hurley <peter@...leysoftware.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-serial@...r.kernel.org
Subject: Re: [PATCH v8 3/3] tty: 8250_omap: Use software emulated RS485
direction control
2016-02-11 19:40 GMT+03:00 Ильяс Гасанов <torso.nafi@...il.com>:
> Hello,
>
> 2016-02-01 21:09 GMT+03:00 "Matwey V. Kornilov" <matwey@....msu.ru>:
>> +static int omap_8250_rs485_config(struct uart_port *port,
>> + struct serial_rs485 *rs485)
>> +{
>> + struct uart_8250_port *up = up_to_u8250p(port);
>> +
>> + /* Clamp the delays to [0, 100ms] */
>> + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
>> + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
>> +
>> + port->rs485 = *rs485;
>> +
>> + /*
>> + * Both serial8250_em485_init and serial8250_em485_destroy
>> + * are idempotent
>> + */
>> + if (rs485->flags & SER_RS485_ENABLED) {
>> + int ret = serial8250_em485_init(up);
>> +
>> + if (ret) {
>> + rs485->flags &= ~SER_RS485_ENABLED;
>> + port->rs485.flags &= ~SER_RS485_ENABLED;
>> + }
>> + return ret;
>> + }
>> +
>> + serial8250_em485_destroy(up);
>> +
>> + return 0;
>> +}
>
> I think that an invocation of serial8250_em485_destroy() should be
> performed inside omap8250_remove() as well. However there is a catch -
> serial8250_get_port() is only reserved for suspend-resume power
> management operations, and I am aware of no other means how to supply
> an uart_8250_port to serial8250_em485_destroy() at that point.
Thanks for pointing out. serial8250_unregister_port should set
serial8250_ports[line].em485 to NULL in order to prevent unneeded
activation when this struct is reused.
>
> Similarly, I got no idea on how to implement handling
> "linux,rs485-enabled-at-boot-time" property without using
> serial8250_get_port() directly (well, honestly I could try invoking
> the corresponding ioctl somehow, but that's gonna be plain ugly at
> least).
You would be able to use serial8250_em485_register in omap8250_probe
on &up before serial8250_register_8250_port(&up) if
serial8250_register_8250_port could replicate em485 member state.
But there are alternatives in implementation.
serial8250_register_8250_port may either copy pointer up->em485 to
uart->em485 or perform deep copy.
>
> Regards,
> Ilyas G.
>
--
With best regards,
Matwey V. Kornilov.
Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia
119991, Moscow, Universitetsky pr-k 13, +7 (495) 9392382
Powered by blists - more mailing lists