Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1594381
| From | Rob Herring <robh+dt@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 09/10] serdev: add serdev_device_set_rts |
| Date | 2017-03-07 17:10 +0100 |
| Message-ID | <tipQt-1uF-7@gated-at.bofh.it> (permalink) |
| References | <thgFz-sD-7@gated-at.bofh.it> <thgFz-sD-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sat, Mar 4, 2017 at 5:58 AM, Sebastian Reichel <sre@kernel.org> wrote:
> Add function to enable/disable RTS line.
>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
> +static void ttyport_set_rts(struct serdev_controller *ctrl, bool enable)
> +{
> + struct serport *serport = serdev_controller_get_drvdata(ctrl);
> + struct tty_struct *tty = serport->tty;
> + int status = tty->driver->ops->tiocmget(tty);
> + unsigned int set = 0;
> + unsigned int clear = 0;
> +
> + if (enable) {
> + set |= (TIOCM_OUT2 | TIOCM_RTS);
> + clear = ~set;
> + set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> + TIOCM_OUT2 | TIOCM_LOOP;
> + clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> + TIOCM_OUT2 | TIOCM_LOOP;
> + status = tty->driver->ops->tiocmset(tty, set, clear);
> + } else {
> + set &= ~(TIOCM_OUT2 | TIOCM_RTS);
> + clear = ~set;
> + set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> + TIOCM_OUT2 | TIOCM_LOOP;
> + clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
> + TIOCM_OUT2 | TIOCM_LOOP;
> + status = tty->driver->ops->tiocmset(tty, set, clear);
The logic here can be greatly simplified. Here's a patch to the
original version that I came up with, but haven't tested:
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index de20a438a78a..0e35663c5d04 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -264,8 +264,8 @@ void hci_uart_set_flow_control(struct hci_uart
*hu, bool enable)
struct tty_struct *tty = hu->tty;
struct ktermios ktermios;
int status;
- unsigned int set = 0;
- unsigned int clear = 0;
+ unsigned int set;
+ unsigned int clear = TIOCM_DTR | TIOCM_OUT1 | TIOCM_LOOP;
if (enable) {
/* Disable hardware flow control */
@@ -280,25 +280,15 @@ void hci_uart_set_flow_control(struct hci_uart
*hu, bool enable)
status = tty->driver->ops->tiocmget(tty);
BT_DBG("Current tiocm 0x%x", status);
- set &= ~(TIOCM_OUT2 | TIOCM_RTS);
- clear = ~set;
- set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
- TIOCM_OUT2 | TIOCM_LOOP;
- clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
- TIOCM_OUT2 | TIOCM_LOOP;
- status = tty->driver->ops->tiocmset(tty, set, clear);
+ clear |= TIOCM_RTS | TIOCM_OUT2;
+ status = tty->driver->ops->tiocmset(tty, 0, clear);
BT_DBG("Clearing RTS: %s", status ? "failed" : "success");
} else {
/* Set RTS to allow the device to send again */
status = tty->driver->ops->tiocmget(tty);
BT_DBG("Current tiocm 0x%x", status);
- set |= (TIOCM_OUT2 | TIOCM_RTS);
- clear = ~set;
- set &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
- TIOCM_OUT2 | TIOCM_LOOP;
- clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_OUT1 |
- TIOCM_OUT2 | TIOCM_LOOP;
+ set = TIOCM_OUT2 | TIOCM_RTS;
status = tty->driver->ops->tiocmset(tty, set, clear);
BT_DBG("Setting RTS: %s", status ? "failed" : "success");
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] Nokia H4+ support Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 09/10] serdev: add serdev_device_set_rts Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 09/10] serdev: add serdev_device_set_rts Rob Herring <robh+dt@kernel.org> - 2017-03-07 17:10 +0100
Re: [PATCH 09/10] serdev: add serdev_device_set_rts Sebastian Reichel <sre@kernel.org> - 2017-03-07 22:20 +0100
[PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Rob Herring <robh+dt@kernel.org> - 2017-03-07 17:50 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-07 22:50 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Marcel Holtmann <marcel@holtmann.org> - 2017-03-07 23:00 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-08 00:10 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Rob Herring <robh+dt@kernel.org> - 2017-03-08 15:40 +0100
[PATCH 03/10] Bluetooth: hci_uart: add support for word alignment Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 04/10] Bluetooth: hci_uart: add serdev driver support library Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 05/10] Bluetooth: hci_serdev: do not open device in hci open Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 07/10] serdev: add serdev_device_wait_until_sent Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Rob Herring <robh+dt@kernel.org> - 2017-03-07 16:50 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Rob Herring <robh+dt@kernel.org> - 2017-03-07 18:00 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Sebastian Reichel <sre@kernel.org> - 2017-03-07 18:20 +0100
csiph-web