History log of /linux-master/drivers/staging/greybus/uart.c
Revision Date Author Comments
# 95713967 10-Aug-2023 Jiri Slaby (SUSE) <jirislaby@kernel.org>

tty: make tty_operations::write()'s count size_t

Unify with the rest of the code. Use size_t for counts and ssize_t for
retval.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230810091510.13006-30-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 69851e4a 10-Aug-2023 Jiri Slaby (SUSE) <jirislaby@kernel.org>

tty: propagate u8 data to tty_operations::write()

Data are now typed as u8. Propagate this change to
tty_operations::write().

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20230810091510.13006-28-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5701cb8b 17-Jan-2023 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

tty: Call ->dtr_rts() parameter active consistently

Convert various parameter names for ->dtr_rts() and related functions
from onoff, on, and raise to active.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230117090358.4796-12-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5d420399 17-Jan-2023 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

tty: Convert ->dtr_rts() to take bool argument

Convert the raise/on parameter in ->dtr_rts() to bool through the
callchain. The parameter is used like bool. In USB serial, there
remains a few implicit bool -> larger type conversions because some
devices use u8 in their control messages.

In moxa_tiocmget(), dtr variable was reused for line status which
requires int so use a separate variable for status.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230117090358.4796-8-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a8c11c15 16-Aug-2022 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

tty: Make ->set_termios() old ktermios const

There should be no reason to adjust old ktermios which is going to get
discarded anyway.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220816115739.10928-9-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 92dc0b1f 06-Sep-2021 Johan Hovold <johan@kernel.org>

staging: greybus: uart: fix tty use after free

User space can hold a tty open indefinitely and tty drivers must not
release the underlying structures until the last user is gone.

Switch to using the tty-port reference counter to manage the life time
of the greybus tty state to avoid use after free after a disconnect.

Fixes: a18e15175708 ("greybus: more uart work")
Cc: stable@vger.kernel.org # 4.9
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210906124538.22358-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f90a4dd 23-Jul-2021 Jiri Slaby <jirislaby@kernel.org>

tty: drop put_tty_driver

put_tty_driver() is an alias for tty_driver_kref_put(). There is no need
for two exported identical functions, therefore switch all users of
old put_tty_driver() to new tty_driver_kref_put() and remove the former
for good.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: David Sterba <dsterba@suse.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Acked-by: Alex Elder <elder@linaro.org>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: David Sterba <dsterba@suse.com>
Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210723074317.32690-8-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3ec2ff37 10-Jun-2021 Jiri Slaby <jirislaby@kernel.org>

tty: make use of tty_get_{char,frame}_size

In the previous patch, we introduced tty_get_char_size() and
tty_get_frame_size() for computing character and frame sizes,
respectively. Here, we make use of them in various tty drivers where
applicable.

The stats look nice: 12 insertions, 169 deletions.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Oliver Neukum <oneukum@suse.com>
Acked-by: Alex Elder <elder@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210610090247.2593-4-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fff4ef17 05-May-2021 Jiri Slaby <jirislaby@kernel.org>

tty: make tty_operations::chars_in_buffer return uint

tty_operations::chars_in_buffer is another hook which is expected to
return values >= 0. So make it explicit by the return type too -- use
unsigned int.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: David Sterba <dsterba@suse.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20210505091928.22010-27-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 03b3b1a2 05-May-2021 Jiri Slaby <jirislaby@kernel.org>

tty: make tty_operations::write_room return uint

Line disciplines expect a positive value or zero returned from
tty->ops->write_room (invoked by tty_write_room). So make this
assumption explicit by using unsigned int as a return value. Both of
tty->ops->write_room and tty_write_room.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Acked-by: Alex Elder <elder@linaro.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com> # xtensa
Acked-by: David Sterba <dsterba@suse.com>
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Chris Zankel <chris@zankel.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Cc: Jens Taprogge <jens.taprogge@taprogge.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Link: https://lore.kernel.org/r/20210505091928.22010-23-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d38be702 06-Apr-2021 Johan Hovold <johan@kernel.org>

staging: greybus: uart: clean up TIOCGSERIAL

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The xmit_fifo_size parameter could be used to set the hardware transmit
fifo size of a legacy UART when it could not be detected, but the
interface is limited to eight bits and should be left unset when not
used.

Similarly, baud_base could be used to set the UART base clock when it
could not be detected but might as well be left unset when it is not
known.

The type parameter could be used to set the UART type, but is
better left unspecified (type unknown) when it isn't used.

Note that some applications have historically expected TIOCGSERIAL to be
implemented, but judging from the Debian sources, the port type not
being PORT_UNKNOWN is only used to check for the existence of legacy
serial ports (ttySn). Notably USB serial drivers like ftdi_sio have been
using PORT_UNKNOWN for twenty years without any problems.

Drop the bogus values provided by the greybus implementation.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407102334.32361-8-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 60c6b305 06-Apr-2021 Johan Hovold <johan@kernel.org>

staging: greybus: uart: fix unprivileged TIOCCSERIAL

TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

A non-privileged user has only ever been able to set the since long
deprecated ASYNC_SPD flags and trying to change any other *supported*
feature should result in -EPERM being returned. Setting the current
values for any supported features should return success.

Fix the greybus implementation which instead indicated that the
TIOCSSERIAL ioctl was not even implemented when a non-privileged user
set the current values.

Fixes: e68453ed28c5 ("greybus: uart-gb: now builds, more framework added")
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407102334.32361-7-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b71e571a 06-Apr-2021 Johan Hovold <johan@kernel.org>

staging: greybus: uart: fix TIOCSSERIAL jiffies conversions

The port close_delay and closing_wait parameters set by TIOCSSERIAL are
specified in jiffies and not milliseconds.

Add the missing conversions so that TIOCSSERIAL works as expected also
when HZ is not 1000.

Fixes: e68453ed28c5 ("greybus: uart-gb: now builds, more framework added")
Cc: stable@vger.kernel.org # 4.9
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407102334.32361-6-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6064aeef 14-May-2020 Johan Hovold <johan@kernel.org>

staging: greybus: uart: replace driver line-coding struct

Drop the driver version of the line-coding request and use the protocol
definition directly as was originally intended instead.

This specifically avoids having the two versions of what is supposed to
be the same struct ever getting out of sync.

Note that this has in fact already happened once when the protocol
definition had its implicit padding removed while the driver struct
wasn't updated. The fact that we used the size of the then larger driver
struct when memcpying its content to the stack didn't exactly make
things better. A later addition of a flow-control field incidentally
made the structures match again.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20200514070548.4423-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 34625c19 09-May-2020 Oscar Carter <oscar.carter@gmx.com>

staging: greybus: Fix uninitialized scalar variable

In the "gb_tty_set_termios" function the "newline" variable is declared
but not initialized. So the "flow_control" member is not initialized and
the OR / AND operations with itself results in an undefined value in
this member.

The purpose of the code is to set the flow control type, so remove the
OR / AND self operator and set the value directly.

Addresses-Coverity-ID: 1374016 ("Uninitialized scalar variable")
Fixes: e55c25206d5c9 ("greybus: uart: Handle CRTSCTS flag in termios")
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200510101426.23631-1-oscar.carter@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ec0ad868 24-Aug-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: move core include files to include/linux/greybus/

With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 327f2769 09-Nov-2018 Ioannis Valasakis <code@wizofe.uk>

staging: greybus: remove space before tab

Remove extra space before a tab character.
Reported by checkpatch.

Signed-off-by: Ioannis Valasakis <code@wizofe.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0aad5ad5 11-Sep-2018 Al Viro <viro@zeniv.linux.org.uk>

greybus/uart: switch to ->[sg]et_serial()

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 863dbc52 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: Remove redundant license text

Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner. So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text. And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb50fd3a 07-Nov-2017 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

staging: greybus: add SPDX identifiers to all greybus driver files

It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself. The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4330887f 12-Apr-2017 Darryl T. Agostinelli <dagostinelli@gmail.com>

staging: greybus: uart.c: Remove include linux/serial.h

$ make includecheck | grep staging
./drivers/staging/greybus/uart.c: linux/serial.h is included more than once.

Signed-off-by: Darryl T. Agostinelli <dagostinelli@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4452b090 04-Mar-2017 simran singhal <singhalsimran0@gmail.com>

staging: greybus: Replace "is is" with "is"

This patch replace "is is " with "is". The replacement couldn't be
automated because sometimes the first "is" was meant to be another
word.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 174cd4b1 02-Feb-2017 Ingo Molnar <mingo@kernel.org>

sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>

Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 461ab807 09-Feb-2017 Gioh Kim <gi-oh.kim@profitbricks.com>

staging: greybus: fix "line over 80 characters" coding style issues

This patch fixes only obvious lines.
There are still more issues.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 414850d9 25-Jan-2017 Johan Hovold <johan@kernel.org>

staging: greybus: uart: fix TIOCGSERIAL flags

This driver does not have a low-latency mode and should not report
anything else.

Also drop the skip-test flag which isn't used either.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 424a4b59 08-Nov-2016 Johan Hovold <johan@kernel.org>

staging: greybus: use get_icount tty operation

Use the tty get_icount operation instead of implementing TIOCGICOUNT
directly.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4dfc109c 08-Nov-2016 Johan Hovold <johan@kernel.org>

staging: greybus: uart: fix invalid user-pointer check

Drop invalid user-pointer check from TIOCGSERIAL handler.

A NULL-pointer can be valid in user space and copy_to_user() takes care
of sanity checking.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4d79f431 14-Oct-2016 Bhumika Goyal <bhumirks@gmail.com>

Staging: greybus: uart: constify tty_port_operations structure

Declare tty_port_operations structure as const as it is only stored in
the ops field of a tty_port structure which is a field of a gb_tty
structure. The ops field is of type const struct tty_port_operations *,
so tty_port_operations structures having this property can be
declared as const.
Done using Coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct tty_port_operations i@p = {...};

@ok1@
identifier r1.i;
position p;
struct gb_tty q;
@@
q.port.ops=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct tty_port_operations i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct tty_port_operations i;

File size before:
text data bss dec hex filename
7646 512 56 8214 2016 drivers/staging/greybus/uart.o

File size after:
text data bss dec hex filename
7710 448 56 8214 2016 drivers/staging/greybus/uart.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: David Lin <dtwlin@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4fa58912 11-Oct-2016 Viresh Kumar <viresh.kumar@linaro.org>

Staging: greybus: uart: Use gbphy_dev->dev instead of bundle->dev

Some of the print messages are using the incorrect device pointer, fix
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 319b78c3 21-Sep-2016 Chaehyun Lim <chaehyun.lim@gmail.com>

staging: greybus: uart.c: fix alignment to match open parenthesis

Fixes checkpatch.pl warning:
CHECK: Alignment should match open parenthesis

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 26746a36 21-Sep-2016 Chaehyun Lim <chaehyun.lim@gmail.com>

staging: greybus: uart.c: change 'unsigned' to 'unsigned int'

Fixes checkpatch.pl warning:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 22b87087 14-Jul-2016 Axel Haslam <haslam_axel@projectara.com>

greybus: uart: Add runtime pm support

This adds runtime pm support for the uart driver.

Testing Done: Using the test daughter board, let
the gpb bridge enter standby and do a uart transfer
operation.

Signed-off-by: Axel Haslam <haslam_axel@projectara.com>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>


# 2aae92bd 27-Jun-2016 Johan Hovold <johan@kernel.org>

greybus: Revert "greybus: uart: don't use spin_lock_irq()"

This reverts commit bd3c4aa99dc23449699432e0744bcb5af7afa98c.

Someone decided that all use of spin_lock_irq was to be considered a bug
and went on a search-and-replace type "bug-fixing" spree last week.

This is however just plain wrong. Using spin_lock_irq is perfectly fine
in paths were interrupts have not been disabled, and this is in fact
even preferred over the lazy approach of always using spin_lock_irqsave
instead of understanding the code that is being written or modified.

All current uses of spin_lock_irq have already been vetted in this
respect. Also note that it is only used in functions that may sleep,
that is, in functions that must not be called with interrupts disabled
in the first place.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# e9f80f33 23-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: don't use spin_lock_irq()

spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.

The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.

This may not work well, if some other code was relying on interrupts
being disabled.

Use spin_lock_irqsave() and spin_unlock_restore() instead.

This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.

Tested on EVT 2.0 with lots of debug patches to kernel and greybus.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 19cdabcf 23-Jun-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: Revert "greybus: don't use spin_lock_irq()"

This reverts commit 469fbe5da0229edcb42aa08bef8e10feaa37e6d7.

It isn't correct in places.

Reported-by: Gjorgji Rosikopulos <rosikopulos_gjorgji@projectara.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 5e2b6391 23-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: don't use spin_lock_irq()

spin_[un]lock_irq() routines should be used carefully as they things can
go wrong, if they are mixed with spin_lock_irqsave() or other variants.

The main problem is that spin_[un]lock_irq() routines doesn't check if
the IRQs are already disabled/enabled on the local CPU and so
spin_unlock_irq() will forcefully enable interrupts for example.

This may not work well, if some other code was relying on interrupts
being disabled.

Use spin_lock_irqsave() and spin_unlock_restore() instead.

This patch doesn't claim that it fixes the JIRA completely, but
the issue was harder to reproduce for some iterations after this, which
was quite easy to reproduce earlier on.

Tested on EVT 2.0 with lots of debug patches to kernel and greybus.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 60fb3405 10-Jun-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Remove extra blank lines

This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.

Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6db9cc68 10-Jun-2016 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Fix minor number leak

On the gb_uart_remove() path we are forgetting to do a release_minor()
leading to a minor number leak. This is a simple one-line fix.

Tested on EVT 2.0

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 64060fe9 30-May-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: gbphy: Remove protocol specific version handling

We should be using the generic version handling at bundle level, instead
of at protocol level for bridged PHY devices as well.

The bundle version handling is already in place, though it is *not* used
today as we haven't bumped the version of control protocol yet.

Remove protocol specific handling for bridged PHY devices.

Tested on EVT 1.5 with gpbridge-test module. No nuttx changes are
required with this.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 5dad5c31 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: wait for credits on shutdown

We should try to wait until all credits are accounted
for before returning from shutdown.

For this purpose add a helper function that will
wait on completion, and call it form the shutdown.
This helper will also be useful when "wait until sent" is
implemented.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 2b3b87f0 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Implement flush_buffer

Data may be held pening in the hardware because of flow
control mechanisms. When the port is closed, we need to flush
all data that was not sent.

For this, use the greybus message GB_UART_TYPE_FLUSH_FIFOS
which will flush all data queued on the module but not
yet sent on the data line.

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# a8bc00fb 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Add credits based tracking for transmit path

To avoid polling the firmware for space, a credit based system
is implemented.

The host will keep track of how many credits (bytes) it has
sent to the firmware, and stop sending data when the quota
is filled.

The host will be informed that the firmware has more
room for data when it handles the receive_credits request
message from the firmware, and will continue to write data
as credits become available.

The firmware and the host may implement an algorithm to aggregate
credits, and avoid extra greybus traffic.

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 8d6fbe9b 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Use a fifo to send data to the modules

The firmware now buffers data instead of blocking while the transfer
is sent, and the write operation cannot sleep.

Instead of using gb_transfer_sync (which sleeps) in the write callback,
buffer data in a fifo and send it from from a work queue.

The write_room callback will will report 1 byte less that what is really
available in the fifo, to leave space for extra characters that may
be added by the tty layer.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 219ffcf3 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Implement dtr_rts callback.

Dtr_dts allows the tty layer to set the flow control lines
to the correct state during open and close.

Note that locking for newctrl is missing throughout the
driver and will be addressed on a separate patch.

Suggested-and-reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# e55c2520 31-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Handle CRTSCTS flag in termios

Handle the CRTSCTS flag in set_termios, so that auto
flow control can be turned off. For this, add a new flag
in the line coding request specifically for this purpose.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# e54b106d 19-May-2016 Sandeep Patil <patil_sandeep@projectara.com>

greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhere

The 'gpbridge' name didn't relaly reflect what the bus is; which
is a bus for bridged-phy devices. So, rename all instances
of 'gpbridge' to more appropriate 'gbphy'

Testing Done:
Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices
until I change the library to reflect this change.

Signed-off-by: Sandeep Patil <patil_sandeep@projectara.com>
Suggested-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 9bc63b7f 16-May-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart fix missing negation on DTR setting

The unset the DTR flag is missing "~"

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 66b9e09e 09-May-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: Create separate module

Create separate module for uart gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 73d292d8 05-May-2016 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: Kill reference_count hack

This was done long back and was probably the best bet then, but it looks
really bad to have it this way now.

Kill the hack and implement proper driver init()/exit() routines to do
the same thing.

Tested using gbsim by hotplugging uart manifest and removing it later.
Also tried removing the gb-phy module to test the exit path properly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 7dbe1f49 05-May-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: UART: convert to a gpbridge driver

This converts the UART driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# b4b1b7ed 20-Apr-2016 Axel Haslam <ahaslam@baylibre.com>

greybus: uart: Update line coding settings only when needed

The check for line coding changed should use memcmp and not memcpy.

Testing done: trivial

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 0ec30632 22-Mar-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: convert drivers to use connection->private set/get

This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# c7b07265 28-Feb-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: gpbridge.h: move protocol init/exit prototypes

Create gpbridge.h for the gpbridge-specific function prototypes, the
rest of the greybus drivers don't care about them.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>


# c5f338c4 24-Feb-2016 Johan Hovold <johan@kernel.org>

greybus: uart: fix incomplete receive-data sanity checks

Fix incomplete receive-data sanity checks.

The payload size was never verified before parsing the uart header and
neither was the uart-header data size verified against the actual
payload size, something which could lead to information leaks when
passing data beyond the payload buffer to the tty layer.

Also remove the incorrect check against the maximum (tx-buffer) payload
size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# cb7f00ba 24-Feb-2016 Johan Hovold <johan@kernel.org>

greybus: uart: add missing serial-state sanity check

Add dedicated serial-state request handler and add the missing sanity
check on the incoming request.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 066f950c 24-Feb-2016 Johan Hovold <johan@kernel.org>

greybus: uart: add max-payload sanity check

Let's be well behaved and add a sanity check on the maximum greybus
payload size to avoid underflow on the calculated buffer size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 7f29aded 22-Feb-2016 Greg Kroah-Hartman <gregkh@google.com>

greybus: uart: properly calculate max buffer size

We forgot to count the size of the uart send data message header when
calculating the maximum size of the buffer that the uart driver could
send in one chunk.

This fixes the math and makes the variable a size_t to match the return
value of the call to gb_operation_get_payload_size_max();

Reported-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 9d4bb6c9 05-Feb-2016 Rui Miguel Silva <rui.silva@linaro.org>

greybus: uart: fix double free of tty port

When inserting and removing a module with a UART protocol defined a
double free of the tty_port would happen and that would generate a lot
of kernel oops in different places related to memory corruption.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# b933fa4a 04-Dec-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Prefix hexadecimal values with 0x while printing them

To clearly specify the base for printed values, prefix hexadecimal
values with 0x.

Suggested-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4f30bf3a 14-Oct-2015 Greg Kroah-Hartman <gregkh@google.com>

greybus: uart: use the bundle struct device instead of the connector

We are removing struct device from the gb_connection structure in the
near future. The gb_bundle structure's struct device should be used as
a replacement.

This patch moves the uart driver to use the bundle pointer instead of
the connection pointer.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>


# a94e1448 10-Aug-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: Drop get_version support

This is done from a common place now, no need to replicate it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 9475fb5c 07-Aug-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: Use (already defined) major/minor macros

We already have macros for these, use them instead of writing fixed
values.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# a5192032 13-Jul-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: fix typo in defintion

Fixing needless redefinition of operation types in gbsim reveals this typo
GB_UART_TYPE_SET_BREAK -> GB_UART_TYPE_SEND_BREAK. This patch should be
applied in lock-step to the patch to gbsim 'gbsim/uart: remove unnecessary
redefinition of operation types' since gbsim does not contain the typo.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 5c1ac694 08-Jul-2015 Greg Kroah-Hartman <gregkh@google.com>

greybus: properly cleanup ida and idr structures when shutting down

idr and ida structures have internal memory allocated that needs to be
freed when modules are removed. So call the proper idr_destroy() or
ida_destroy() functions on the module exit path to free the memory.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>


# e18822e3 30-Jun-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()

This macro is also required by core protocols like control and svc, and
hence the 'gpbridge' name doesn't fit anymore.

Lets call this macro gb_builtin_protocol_driver().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# ba4b099c 29-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Update UART to reflect field size changes

The greybus UART protocol specification was updated to reduce the size of
the control field in serial-state-request and line-state-request. This
patch updates the kernel protocol driver to reflect the specification
changes. Once applied gbsim changes will be also be updated automatically
since gbsim depends on the header being modified directly.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4c025cf4 29-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Add support for UART error signals

After reviewing the UART specification for greybus break, parity, framing
and over-run errors were moved to the receive-data message. This patch
implements that specification change in the UART protocol driver. Matching
code in gbsim has been tested with this change.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 3ee2266c 16-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Latch modem control signals for tciomget

Latch signals coming from UART module for
- GB_UART_CTRL_DCD
- GB_UART_CTRL_DSR
- GB_UART_CTRL_RI

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 55a8e355 10-Jun-2015 Phong Tran <tranmanphong@gmail.com>

greybus: uart: fix the clean up while uart initiates connection unsucessfully

There is lack of unregister and free the tty driver.
This patch fixes it.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 61b65a39 09-Jun-2015 Phong Tran <tranmanphong@gmail.com>

greybus: uart: remove the redundant unregister chrdev

The unregister_chrdev_region() does twice here.
The chrdev region was unregistered
inside tty_unregister_driver().

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 81c3a772 07-Jun-2015 Alex Elder <elder@linaro.org>

greybus: uart: properly interpret receive data size

In gb_uart_request_recv(), the receive data size is in little-endian
format. Do the proper byte swapping of that value before using it.
Found by "make check".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 62229a1b 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Remove magic numbers make struct gb_tty variable names consistent

Use defines for the data format command.
Tidy up naming of gb_tty variables.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 1c087015 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Add gb_uart_request_recv for receiving async UART data

gb_uart_request_recv job in life is to process unsolicited greybus
mesages from the UART.
Hook the incoming UART data and pass to the TTY layer.
Line-state changes still TBD.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# dd1c64ed 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: kmalloc for send_data once only

Make kmalloc for the send buffer a one time alloc based on the MTU for
a given greybus link.

The write_room for an gb_operation_sync then will be the size of the
buffer we use for a single operation.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 563bd79b 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: send_data should return size or error

gb_operation_sync returns 0 on success but the calling function
expects the number of bytes written on success or a negative errno

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# f95ad78c 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Update uart.c to register tty ports

For each new UART connection we need to do a tty_port_init else
we'll crash when trying to access the tty mutex later on.
Base the TTY major/minor numbers on non-zero values.
Supply an empty operations structure for the newly regitered port.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# f5537d46 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Reduce UART count from 255 to 16

Arbitrary number 255 is both not aligned and probably too big.
Move the UART count down to 16 which is still large but, more realistic.
8 may be too few for future testing setups, 16 should accomodate any.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 11fca140 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Tidy naming convention to more closely match spec

Update tabs and naming of structures to match the naming used in the greybus
specification more closely.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 4ef53485 02-Jun-2015 Bryan O'Donoghue <bryan.odonoghue@linaro.org>

greybus: uart: Move UART protocol structs/defines to greybus_protocols.h

gbsim depends on the structures and defines in greybus_protocols.h
generally in order to simulate firmware. Move UART defines into this
header to facilitate.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 55f22911 01-Jun-2015 Phong Tran <tranmanphong@gmail.com>

greybus: uart: Fix the memory leak in connection init

If alloc minor is error, gb_tty should free.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# bdac599c 20-May-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Use gb_gpbridge_protocol_init()

Start using gb_gpbridge_protocol_init() in gpbridge drivers.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# 6d653370 07-May-2015 Alex Elder <elder@linaro.org>

greybus: eliminate extra response flag definitions

All protocols use the same value to distinguish between request and
response message types. This is a requirement.

Use GB_MESSAGE_TYPE_RESPONSE rather than GB_OPERATION_TYPE_RESPONSE
for the name of the flag used to distiguish between request and
response messages.

Get rid of the redundant response flag definitions that are
associated with specific protocols.

Describe the symbolic values as "operation types" rather than
"message types" where they are defined. The message type for a
request is the same as the operation type; the message type for a
response is the operation type OR'd with GB_MESSAGE_TYPE_RESPONSE.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>


# afcf8c71 17-Mar-2015 Johan Hovold <johan@kernel.org>

greybus: uart: remove packed-attribute from line-coding struct

Remove packed-attribute from line-coding struct, whose members are all
naturally aligned.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# 89210f64 21-Jan-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: remove unused version-response structs

These aren't used anymore and so can be removed.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# 36e79dec 21-Jan-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: create get_version() routines with the help of a macro

This gets rid of lots of duplication of code.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# 530430b7 21-Jan-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: uart: s/REQ/TYPE

Request type for all other protocols is defined like: GB_<protocol>_TYPE_<operation>,
but for UART is like: GB_<protocol>_REQ_<operation>.

Replace REQ with TYPE to make it consistent. It will also be useful in a later
patch that creates get_version() routines with the help of a macro.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


# 5357cf32 21-Jan-2015 Viresh Kumar <viresh.kumar@linaro.org>

greybus: Remove "-gb" suffix from .c files

Some files are prefixed with "gb-" and some are suffixed with "-gb". The
rationale behind the first one is that the modules would be named so, i.e.
gb-*.ko. But there is no reason to keep the "-gb" suffix in the second case.

Remove the unnecessary suffix.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>