Xiaofei Tan
fab491030c
tty: tty_io: Remove return in void function
...
Remove return in void function, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-15-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
27eab12932
tty: tty_io: Delete a blank line before EXPORT_SYMBOL(foo)
...
Delete a blank line before EXPORT_SYMBOL(foo) so that EXPORT_SYMBOL(foo)
immediately follow its function/variable, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-14-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
5e4d5ac32b
tty: tty_io: Fix an issue of code indent for conditional statements
...
Fix an issue of code indent for conditional statements,reported by
checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-13-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
44969f8540
tty: tty_io: Remove the repeated word 'can'
...
Remove the repeated word 'can' following advice of checkpatch.pl
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-12-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
b426a5b815
tty: tty_io: Fix coding style issues of block comments
...
Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, add a period at the end of the sentenses.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-11-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
d91c1a3eed
tty: tty_io: Fix trailing whitespace issues
...
Fix trailing whitespace issues, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-10-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
94bc2eb5fb
tty: tty_io: Fix spaces required around that ':'
...
Fix spaces required around that ':', reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-9-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
e73b240785
tty: tty_io: Add a blank line after declarations
...
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-8-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:13 +02:00
Xiaofei Tan
395e783371
tty: tty_io: Remove spaces before tabs
...
Remove spaces before tabs following the advice of checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-7-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Xiaofei Tan
80e3fce103
tty: tty_buffer: Fix coding style issues of block comments
...
Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, add a period at the end of the sentenses.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-6-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Xiaofei Tan
dadc104948
tty: tty_buffer: Remove the repeated word 'the'
...
Remove the repeated word 'the' following advice of checkpatch.pl
Besides, add a period at the end of comment sentence.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-5-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Xiaofei Tan
993c67b1fe
tty: tty_buffer: Add a blank line after declarations
...
Add a blank line after declarations, reported by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-4-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Xiaofei Tan
ad48749b98
tty: tty_baudrate: Fix coding style issues of block comments
...
Fix coding style issues of block comments, reported by checkpatch.pl.
Besides, add a period at the end of comment sentenses.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-3-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Xiaofei Tan
eb460edb5f
tty: tty_baudrate: Remove unnecessary tab and spaces in comment sentence
...
Remove unnecessary tab and spaces in comment sentence, reported
by checkpatch.pl.
Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com >
Link: https://lore.kernel.org/r/1620811585-18582-2-git-send-email-tanxiaofei@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Christophe JAILLET
31a9a31825
tty: nozomi: Fix a resource leak in an error handling function
...
A 'request_irq()' call is not balanced by a corresponding 'free_irq()' in
the error handling path, as already done in the remove function.
Add it.
Fixes: 9842c38e91 ("kfifo: fix warn_unused_result")
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Link: https://lore.kernel.org/r/4f0d2b3038e82f081d370ccb0cade3ad88463fe7.1620580838.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
27dede097d
tty: serial: sb1250-duart: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-13-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
7d5a3ec537
tty: serial: vr41xx_siu: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-12-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
933100787d
tty: serial: sunzilog: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-11-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
4f1c658130
tty: serial: sunsu: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-10-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
d890c50876
tty: serial: sunsab: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-9-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
10dab44f78
tty: serial: txx9: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-8-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
ce6ff28069
tty: serial: pmac_zilog: include <linux/io.h> insteiad of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-7-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
b1c92c121b
tty: serial: mux: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-6-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
3dccc357b7
tty: serial: ip22zilog: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-5-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:12 +02:00
Zihao Tang
0ebee1ebbc
tty: serial: icom: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-4-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Zihao Tang
27bcf79b8a
tty: serial: dz: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-3-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Zihao Tang
635b258962
tty: serial: atmel: include <linux/io.h> instead of <asm/io.h>
...
Include the more general linux/io.h instead of asm/io.h
as checkpatch suggests.
Signed-off-by: Zihao Tang <tangzihao1@hisilicon.com >
Signed-off-by: Jay Fang <f.fangjian@huawei.com >
Link: https://lore.kernel.org/r/1620874904-39285-2-git-send-email-f.fangjian@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Jiri Slaby
76af233d9b
tty: remove unused tty_throttle
...
The last user was removed in commit e91e52e428 (n_tty: Fix stuck
throttled driver) in 2013. So remove exported tty_throttle completely.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210510065923.5112-1-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Jiri Slaby
3d18354248
nozomi: simplify ntty_chars_in_buffer
...
ntty_chars_in_buffer is overly complicated. Simplify it by inverting the
condition.
Side FIXME: how can dc or port be NULL here?
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210505091928.22010-29-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Jiri Slaby
fff4ef17a9
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 >
2021-05-13 18:29:11 +02:00
Jiri Slaby
fa7501e57e
tty: remove tty_operations::chars_in_buffer for non-buffering
...
The only user of tty_ops::chars_in_buffer is tty_chars_in_buffer. And it
considers tty_ops::chars_in_buffer optional. In case it's NULL, zero is
returned. So remove all those chars_in_buffer from tty_ops which return
zero. (Zero means such driver doesn't buffer.)
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: Richard Henderson <rth@twiddle.net >
Acked-by: Max Filippov <jcmvbkbc@gmail.com > # xtensa
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: Chris Zankel <chris@zankel.net >
Cc: Heiko Carstens <hca@linux.ibm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Christian Borntraeger <borntraeger@de.ibm.com >
Link: https://lore.kernel.org/r/20210505091928.22010-26-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Jiri Slaby
9a33fbf9d2
tty: make tty_buffer_space_avail return uint
...
tty_buffer_space_avail returns values >= 0, so make it clear by the
return type.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: Joel Stanley <joel@jms.id.au >
Link: https://lore.kernel.org/r/20210505091928.22010-25-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 18:29:11 +02:00
Atul Gopinathan
3890e3dea3
serial: max310x: unregister uart driver in case of failure and abort
...
The macro "spi_register_driver" invokes the function
"__spi_register_driver()" which has a return type of int and can fail,
returning a negative value in such a case. This is currently ignored and
the init() function yields success even if the spi driver failed to
register.
Fix this by collecting the return value of "__spi_register_driver()" and
also unregister the uart driver in case of failure.
Cc: Jiri Slaby <jirislaby@kernel.org >
Signed-off-by: Atul Gopinathan <atulgopinathan@gmail.com >
Link: https://lore.kernel.org/r/20210503115736.2104747-12-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:30:21 +02:00
Greg Kroah-Hartman
b0a85abbe9
Revert "serial: max310x: pass return value of spi_register_driver"
...
This reverts commit 51f689cc11 .
Because of recent interactions with developers from @umn.edu, all
commits from them have been recently re-reviewed to ensure if they were
correct or not.
Upon review, this commit was found to be incorrect for the reasons
below, so it must be reverted. It will be fixed up "correctly" in a
later kernel change.
This change did not properly unwind from the error condition, so it was
not correct.
Cc: Kangjie Lu <kjlu@umn.edu >
Acked-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20210503115736.2104747-11-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:30:18 +02:00
Greg Kroah-Hartman
754f391584
Revert "serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference"
...
This reverts commit 32f4717983 .
Because of recent interactions with developers from @umn.edu, all
commits from them have been recently re-reviewed to ensure if they were
correct or not.
Upon review, this commit was found to be not be needed at all as the
change was useless because this function can only be called when
of_match_device matched on something. So it should be reverted.
Cc: Aditya Pakki <pakki001@umn.edu >
Cc: stable <stable@vger.kernel.org >
Fixes: 32f4717983 ("serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference")
Acked-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20210503115736.2104747-6-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:30:04 +02:00
Maximilian Luz
3c35d2a960
serial: 8250_dw: Add device HID for new AMD UART controller
...
Add device HID AMDI0022 to the AMD UART controller driver match table
and create a platform device for it. This controller can be found on
Microsoft Surface Laptop 4 devices and seems similar enough that we can
just copy the existing AMDI0020 entries.
Cc: <stable@vger.kernel.org > # 5.10+
Tested-by: Sachi King <nakato@nakato.io >
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com > # for 8250_dw part
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com >
Link: https://lore.kernel.org/r/20210512210413.1982933-1-luzmaximilian@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:08:42 +02:00
Geert Uytterhoeven
2ea2e019c1
serial: sh-sci: Fix off-by-one error in FIFO threshold register setting
...
The Receive FIFO Data Count Trigger field (RTRG[6:0]) in the Receive
FIFO Data Count Trigger Register (HSRTRGR) of HSCIF can only hold values
ranging from 0-127. As the FIFO size is equal to 128 on HSCIF, the user
can write an out-of-range value, touching reserved bits.
Fix this by limiting the trigger value to the FIFO size minus one.
Reverse the order of the checks, to avoid rx_trig becoming zero if the
FIFO size is one.
Note that this change has no impact on other SCIF variants, as their
maximum supported trigger value is lower than the FIFO size anyway, and
the code below takes care of enforcing these limits.
Fixes: a380ed461f ("serial: sh-sci: implement FIFO threshold register setting")
Reported-by: Linh Phung <linh.phung.jy@renesas.com >
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com >
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu >
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Cc: stable <stable@vger.kernel.org >
Link: https://lore.kernel.org/r/5eff320aef92ffb33d00e57979fd3603bbb4a70f.1620648218.git.geert+renesas@glider.be
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:08:29 +02:00
Ondrej Mosnacek
5e722b217a
serial: core: fix suspicious security_locked_down() call
...
The commit that added this check did so in a very strange way - first
security_locked_down() is called, its value stored into retval, and if
it's nonzero, then an additional check is made for (change_irq ||
change_port), and if this is true, the function returns. However, if
the goto exit branch is not taken, the code keeps the retval value and
continues executing the function. Then, depending on whether
uport->ops->verify_port is set, the retval value may or may not be reset
to zero and eventually the error value from security_locked_down() may
abort the function a few lines below.
I will go out on a limb and assume that this isn't the intended behavior
and that an error value from security_locked_down() was supposed to
abort the function only in case (change_irq || change_port) is true.
Note that security_locked_down() should be called last in any series of
checks, since the SELinux implementation of this hook will do a check
against the policy and generate an audit record in case of denial. If
the operation was to carry on after calling security_locked_down(), then
the SELinux denial record would be bogus.
See commit 59438b4647 ("security,lockdown,selinux: implement SELinux
lockdown") for how SELinux implements this hook.
Fixes: 794edf30ee ("lockdown: Lock down TIOCSSERIAL")
Acked-by: Kees Cook <keescook@chromium.org >
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com >
Cc: stable <stable@vger.kernel.org >
Link: https://lore.kernel.org/r/20210507115719.140799-1-omosnace@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:08:04 +02:00
Colin Ian King
3ddb4ce1e6
serial: tegra: Fix a mask operation that is always true
...
Currently the expression lsr | UART_LSR_TEMT is always true and
this seems suspect. I believe the intent was to mask lsr with UART_LSR_TEMT
to check that bit, so the expression should be using the & operator
instead. Fix this.
Fixes: b9c2470fb1 ("serial: tegra: flush the RX fifo on frame error")
Signed-off-by: Colin Ian King <colin.king@canonical.com >
Cc: stable <stable@vger.kernel.org >
Link: https://lore.kernel.org/r/20210426105514.23268-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 17:07:43 +02:00
Jiri Slaby
03b3b1a240
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 >
2021-05-13 17:03:20 +02:00
Jiri Slaby
f6f19595a7
tty: return void from tty_unregister_ldisc
...
Now that noone checks the return value of tty_unregister_ldisc, make the
function return 'void'.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210505091928.22010-20-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:17 +02:00
Jiri Slaby
357a6a875f
tty: no checking of tty_unregister_ldisc
...
tty_unregister_ldisc now returns 0 = success. No need to check the
return value. In fact, the users only warned if an error occured and
didn't do anything useful anyway -- the ldisc module was unloaded in any
case.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: William Hubbs <w.d.hubbs@gmail.com >
Cc: Chris Brannon <chris@the-brannons.com >
Cc: Kirk Reiser <kirk@reisers.ca >
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org >
Cc: Marcel Holtmann <marcel@holtmann.org >
Cc: Johan Hedberg <johan.hedberg@gmail.com >
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Wolfgang Grandegger <wg@grandegger.com >
Cc: Marc Kleine-Budde <mkl@pengutronix.de >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Rodolfo Giometti <giometti@enneenne.com >
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com >
Cc: Liam Girdwood <lgirdwood@gmail.com >
Cc: Mark Brown <broonie@kernel.org >
Cc: Jaroslav Kysela <perex@perex.cz >
Cc: Takashi Iwai <tiwai@suse.com >
Link: https://lore.kernel.org/r/20210505091928.22010-19-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:17 +02:00
Jiri Slaby
1947520933
tty: drop tty_ldisc_ops::refcount
...
The refcount is checked only in tty_unregister_ldisc and EBUSY returned
if it is nonzero. But none of the tty_unregister_ldisc callers act
anyhow if this (or any other) error is returned. So remove
tty_ldisc_ops::refcount completely and make tty_unregister_ldisc return
'void' in the next patches. That means we assume tty_unregister_ldisc is
not called while the ldisc might be in use. That relies on
try_module_get in get_ldops and module_put in put_ldops.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210505091928.22010-18-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:17 +02:00
Jiri Slaby
f81ee8b8b8
tty: make tty_ldisc_ops a param in tty_unregister_ldisc
...
Make tty_unregister_ldisc symmetric to tty_register_ldisc by accepting
struct tty_ldisc_ops as a parameter instead of ldisc number. This avoids
checking of the ldisc number bounds in tty_unregister_ldisc.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: William Hubbs <w.d.hubbs@gmail.com >
Cc: Chris Brannon <chris@the-brannons.com >
Cc: Kirk Reiser <kirk@reisers.ca >
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org >
Cc: Marcel Holtmann <marcel@holtmann.org >
Cc: Johan Hedberg <johan.hedberg@gmail.com >
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com >
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Wolfgang Grandegger <wg@grandegger.com >
Cc: Marc Kleine-Budde <mkl@pengutronix.de >
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Rodolfo Giometti <giometti@enneenne.com >
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com >
Cc: Liam Girdwood <lgirdwood@gmail.com >
Cc: Mark Brown <broonie@kernel.org >
Cc: Jaroslav Kysela <perex@perex.cz >
Cc: Takashi Iwai <tiwai@suse.com >
Link: https://lore.kernel.org/r/20210505091928.22010-17-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
839e0f226d
n_gsm: use goto-failpaths in gsm_init
...
Use the classic failpath handling using gotos in gsm_init. That way,
tty_unregister_ldisc needs not be repeated on two places.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210505091928.22010-16-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
fbadf70a80
tty: set tty_ldisc_ops::num statically
...
There is no reason to pass the ldisc number to tty_register_ldisc
separately. Just set it in the already defined tty_ldisc_ops in all the
ldiscs.
This simplifies tty_register_ldisc a bit too (no need to set the num
member there).
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: William Hubbs <w.d.hubbs@gmail.com >
Cc: Chris Brannon <chris@the-brannons.com >
Cc: Kirk Reiser <kirk@reisers.ca >
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org >
Cc: Marcel Holtmann <marcel@holtmann.org >
Cc: Johan Hedberg <johan.hedberg@gmail.com >
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com >
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Wolfgang Grandegger <wg@grandegger.com >
Cc: Marc Kleine-Budde <mkl@pengutronix.de >
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Rodolfo Giometti <giometti@enneenne.com >
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com >
Cc: Liam Girdwood <lgirdwood@gmail.com >
Cc: Mark Brown <broonie@kernel.org >
Cc: Jaroslav Kysela <perex@perex.cz >
Cc: Takashi Iwai <tiwai@suse.com >
Link: https://lore.kernel.org/r/20210505091928.22010-15-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
64d608db38
tty: cumulate and document tty_struct::ctrl* members
...
Group the ctrl members under a single struct called ctrl. The new struct
contains 'pgrp', 'session', 'pktstatus', and 'packet'. 'pktstatus' and
'packet' used to be bits in a bitfield. The struct also contains the
lock protecting them to share the same cache line.
Note that commit c545b66c69 (tty: Serialize tcflow() with other tty
flow control changes) added a padding to the original bitfield. It was
for the bitfield to occupy a whole 64b word to avoid interferring stores
on Alpha (cannot we evaporate this arch with weird implications to C
code yet?). But it doesn't work as expected as the padding
(tty_struct::ctrl_unused) is aligned to a 8B boundary too and occupies
some bytes from the next word.
So make it reliable by:
1) setting __aligned of the struct -- that aligns the start, and
2) making 'unsigned long unused[0]' as the last member of the struct --
pads the end.
Add a kerneldoc comment for this grouped members.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: netdev@vger.kernel.org
Link: https://lore.kernel.org/r/20210505091928.22010-14-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
6e94dbc7a4
tty: cumulate and document tty_struct::flow* members
...
Group the flow flags under a single struct called flow. The new struct
contains 'stopped' and 'tco_stopped' bools which used to be bits in a
bitfield. The struct also contains the lock protecting them to
potentially share the same cache line.
Note that commit c545b66c69 (tty: Serialize tcflow() with other tty
flow control changes) added a padding to the original bitfield. It was
for the bitfield to occupy a whole 64b word to avoid interferring stores
on Alpha (cannot we evaporate this arch with weird implications to C
code yet?). But it doesn't work as expected as the padding
(tty_struct::unused) is aligned to a 8B boundary too and occupies some
bytes from the next word.
So make it reliable by:
1) setting __aligned of the struct -- that aligns the start, and
2) making 'unsigned long unused[0]' as the last member of the struct --
pads the end.
This is also the perfect time to start the documentation of tty_struct
where all this lives. So we start by documenting what these bools
actually serve for. And why we do all the alignment dances. Only the few
up-to-date information from the Theodore's comment made it into this new
Kerneldoc comment.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Ulf Hansson <ulf.hansson@linaro.org >
Cc: Heiko Carstens <hca@linux.ibm.com >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Christian Borntraeger <borntraeger@de.ibm.com >
Cc: Shawn Guo <shawnguo@kernel.org >
Cc: Sascha Hauer <s.hauer@pengutronix.de >
Cc: Vineet Gupta <vgupta@synopsys.com >
Cc: "Maciej W. Rozycki" <macro@orcam.me.uk >
Link: https://lore.kernel.org/r/20210505091928.22010-13-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
0f3dcf3b5d
tty: make fp of tty_ldisc_ops::receive_buf{,2} const
...
Char pointer (cp) passed to tty_ldisc_ops::receive_buf{,2} is const.
There is no reason for flag pointer (fp) not to be too. So switch it in
the definition and all uses.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Cc: William Hubbs <w.d.hubbs@gmail.com >
Cc: Chris Brannon <chris@the-brannons.com >
Cc: Kirk Reiser <kirk@reisers.ca >
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org >
Cc: Marcel Holtmann <marcel@holtmann.org >
Cc: Johan Hedberg <johan.hedberg@gmail.com >
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com >
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: "David S. Miller" <davem@davemloft.net >
Cc: Jakub Kicinski <kuba@kernel.org >
Cc: Wolfgang Grandegger <wg@grandegger.com >
Cc: Marc Kleine-Budde <mkl@pengutronix.de >
Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de >
Cc: Paul Mackerras <paulus@samba.org >
Cc: Liam Girdwood <lgirdwood@gmail.com >
Cc: Mark Brown <broonie@kernel.org >
Cc: Jaroslav Kysela <perex@perex.cz >
Cc: Takashi Iwai <tiwai@suse.com >
Cc: Peter Ujfalusi <peter.ujfalusi@gmail.com >
Link: https://lore.kernel.org/r/20210505091928.22010-12-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00
Jiri Slaby
fc0df90b78
n_tty: remove superfluous return from n_tty_receive_signal_char
...
A return at the end of a void-returning function is superfluous. Get rid
of it.
Signed-off-by: Jiri Slaby <jslaby@suse.cz >
Link: https://lore.kernel.org/r/20210505091928.22010-11-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-05-13 16:57:16 +02:00