Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1312492 > unrolled thread
| Started by | "Matwey V. Kornilov" <matwey@sai.msu.ru> |
|---|---|
| First post | 2016-01-19 21:40 +0100 |
| Last post | 2016-01-23 21:40 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control "Matwey V. Kornilov" <matwey@sai.msu.ru> - 2016-01-19 21:40 +0100
Re: [PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-01-23 16:30 +0100
Re: [PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control "Matwey V. Kornilov" <matwey@sai.msu.ru> - 2016-01-23 21:40 +0100
| From | "Matwey V. Kornilov" <matwey@sai.msu.ru> |
|---|---|
| Date | 2016-01-19 21:40 +0100 |
| Subject | [PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control |
| Message-ID | <qSLei-4ue-15@gated-at.bofh.it> |
Use software emulated RS485 direction control to provide RS485 API existed in
omap_serial driver. Note that 8250_omap issues interrupt on shift register
empty which is single prerequesite for using software emulated RS485.
Signed-off-by: Matwey V. Kornilov <matwey@sai.msu.ru>
---
drivers/tty/serial/8250/8250_omap.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index a2c0734..31f7905 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -697,6 +697,30 @@ static void omap_8250_throttle(struct uart_port *port)
pm_runtime_put_autosuspend(port->dev);
}
+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_* functions 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;
+ } else
+ serial8250_em485_destroy(up);
+
+ return 0;
+}
+
static void omap_8250_unthrottle(struct uart_port *port)
{
unsigned long flags;
@@ -1146,6 +1170,7 @@ static int omap8250_probe(struct platform_device *pdev)
up.port.shutdown = omap_8250_shutdown;
up.port.throttle = omap_8250_throttle;
up.port.unthrottle = omap_8250_unthrottle;
+ up.port.rs485_config = omap_8250_rs485_config;
if (pdev->dev.of_node) {
const struct of_device_id *id;
--
2.7.0
[toc] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2016-01-23 16:30 +0100 |
| Subject | Re: [PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control |
| Message-ID | <qU8it-4Dc-1@gated-at.bofh.it> |
| In reply to | #1312492 |
On Tue, Jan 19, 2016 at 10:33 PM, Matwey V. Kornilov <matwey@sai.msu.ru> wrote:
> Use software emulated RS485 direction control to provide RS485 API existed in
> omap_serial driver. Note that 8250_omap issues interrupt on shift register
> empty which is single prerequesite for using software emulated RS485.
> +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] */
It's not exactly clamping but rather cutting extra as I can see below.
> + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
> + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
> + /* Both serial8250_em485_* functions are idempotent */
Better to decode what functions do you mean here.
> + 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;
> + } else
You have to do } else { in multi-line branches, but luckily there is
redundant else keyword.
And checkpatch.pl doesn't tell you anything?
> + serial8250_em485_destroy(up);
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | "Matwey V. Kornilov" <matwey@sai.msu.ru> |
|---|---|
| Date | 2016-01-23 21:40 +0100 |
| Subject | Re: [PATCH v7 3/3] tty: 8250_omap: Use software emulated RS485 direction control |
| Message-ID | <qUd8u-8iW-11@gated-at.bofh.it> |
| In reply to | #1315662 |
2016-01-23 18:20 GMT+03:00 Andy Shevchenko <andy.shevchenko@gmail.com>:
> On Tue, Jan 19, 2016 at 10:33 PM, Matwey V. Kornilov <matwey@sai.msu.ru> wrote:
>> Use software emulated RS485 direction control to provide RS485 API existed in
>> omap_serial driver. Note that 8250_omap issues interrupt on shift register
>> empty which is single prerequesite for using software emulated RS485.
>
>
>> +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] */
>
> It's not exactly clamping but rather cutting extra as I can see below.
>
I took this code and the comment from
http://marc.info/?l=linux-serial&m=145264055108439&w=2
>> + rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
>> + rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
>
>> + /* Both serial8250_em485_* functions are idempotent */
>
> Better to decode what functions do you mean here.
>
>> + 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;
>> + } else
>
> You have to do } else { in multi-line branches, but luckily there is
> redundant else keyword.
>
> And checkpatch.pl doesn't tell you anything?
>
>> + serial8250_em485_destroy(up);
>> +
>> + return 0;
>> +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
--
With best regards,
Matwey V. Kornilov.
Sternberg Astronomical Institute, Lomonosov Moscow State University, Russia
119991, Moscow, Universitetsky pr-k 13, +7 (495) 9392382
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web