summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* tty: make tty_ldisc_ops::*buf*() hooks operate on size_tJiri Slaby (SUSE)2023-08-1119-35/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Count passed to tty_ldisc_ops::receive_buf*(), ::lookahead_buf(), and returned from ::receive_buf2() is expected to be size_t. So set it to size_t to unify with the rest of the code. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> 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: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Dario Binacchi <dario.binacchi@amarulasolutions.com> Cc: Andreas Koensgen <ajk@comnets.uni-bremen.de> Cc: Jeremy Kerr <jk@codeconstruct.com.au> Cc: Matt Johnston <matt@codeconstruct.com.au> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.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> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-16-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: can327, move overflow test inside can327_ldisc_rx()'s loopJiri Slaby (SUSE)2023-08-111-8/+7
| | | | | | | | | | | | | | | | | | | | The 'count' is going to be unsigned and the 'count >= 0' test would be always true then. Move the condition to the loop where this is easier to check. It looks as is easier to follow after all too. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> 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: linux-can@vger.kernel.org Link: https://lore.kernel.org/r/20230810091510.13006-15-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: can327: unify error paths in can327_ldisc_rx()Jiri Slaby (SUSE)2023-08-111-14/+8
| | | | | | | | | | | | | | | | | Create a label with can327_uart_side_failure() and spin unlock. And jump there from all three fail paths. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> 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: linux-can@vger.kernel.org Link: https://lore.kernel.org/r/20230810091510.13006-14-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: switch count in tty_ldisc_receive_buf() to size_tJiri Slaby (SUSE)2023-08-113-6/+6
| | | | | | | | | | | | | | | It comes from both paste_selection() and tty_port_default_receive_buf() as unsigned (int and size_t respectively). Switch to size_t to converge to that eventually. Return the count as size_t too (the two callers above expect that). Switch paste_selection()'s type of 'count' too, so that the returned and passed type match. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-13-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: switch receive_buf() counts to size_tJiri Slaby (SUSE)2023-08-111-4/+4
| | | | | | | | | | | | 'size_t' is what receive_buf() expects and returns while handling count. So switch to 'size_t'. This renders both local 'count' and 'rcvd' in flush_to_ldisc() to be size_t too. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-12-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: make counts in tty_port_client_operations hooks size_tJiri Slaby (SUSE)2023-08-113-11/+10
| | | | | | | | | | | | | | | | | | | | | The counts in tty_port_client_operations hooks' are currently represented by all 'int', 'unsigned int', and 'size_t'. Unify them all to unsigned 'size_t' for clarity. Note that size_t is used already in tty_buffer.c. So, eventually, it is spread for counts everywhere and this is the beginning. So the two changes namely: * ::receive_buf() is called from tty_ldisc_receive_buf(). And that expects values ">= 0" from ::receive_buf(), so switch its rettype to size_t is fine. tty_ldisc_receive_buf() types will be changed separately. * ::lookahead_buf()'s count comes from lookahead_bufs() and is already 'unsigned int'. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-11-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: make tty_port_client_operations operate with u8Jiri Slaby (SUSE)2023-08-114-12/+12
| | | | | | | | | | The parameters are already unsigned chars. So make them explicitly u8s, as the rest is going to be unified to u8 eventually too. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-10-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: make tty_change_softcar() more understandableJiri Slaby (SUSE)2023-08-111-3/+3
| | | | | | | | | * rename 'arg' to 'enable' as that is what it means. * make 'bit' a tcflag_t, not int, as that is what cflags are. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-9-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: drop tty_debug_wait_until_sent()Jiri Slaby (SUSE)2023-08-111-10/+0
| | | | | | | | | | It's a nop for everyone as TTY_DEBUG_WAIT_UNTIL_SENT is never set. Provided, we have better debugging/printout mechanisms nowadays, remove this mechanism. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: tty_port: rename 'disc' to 'ld'Jiri Slaby (SUSE)2023-08-111-11/+11
| | | | | | | | | | Line discipline variables are named 'ld' all over the tty code. Rename these in tty_port, so that it is easier to grep for the code (namely for "ld->ops"). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-7-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: change tty_write_lock()'s ndelay parameter to boolJiri Slaby (SUSE)2023-08-113-5/+5
| | | | | | | | It's a yes-no parameter, so convert it to bool to be obvious. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: n_null: remove optional ldopsJiri Slaby (SUSE)2023-08-111-18/+0
| | | | | | | | | | | Only tty_ldisc_ops::read() and ::write() of n_null behave differently than the default ldops implementations. They return %EOPNOTSUPP instead of %EIO. So keep only those two and remove the rest ldops as they are superfluous. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-5-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: remove dummy tty_ldisc_ops::poll() implementationsJiri Slaby (SUSE)2023-08-114-30/+0
| | | | | | | | | | | | | | | | | tty_ldisc_ops::poll() is optional and needs not be provided. It is equal to returning 0. So remove all those from the code. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com> 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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230810091510.13006-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: ldisc: document that ldops are optionalJiri Slaby (SUSE)2023-08-111-5/+25
| | | | | | | | | | There is no need to provide any hook in struct tty_ldisc_ops. Document that and write down that read/write return EIO in that case. The rest is simply ignored. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230810091510.13006-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: xtensa/iss: drop unneeded tty_operations hooksJiri Slaby (SUSE)2023-08-111-24/+0
| | | | | | | | | | | | | | | | | | All ::flush_chars(), ::hangup(), and ::wait_until_sent() from struct tty_operations are optional. There is no need to provide them with empty bodies. tty_operations::put_char() needs not be provided if it is the same as tty_operations::write(tty, &ch, 1). So drop all of them. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Chris Zankel <chris@zankel.net> Cc: Max Filippov <jcmvbkbc@gmail.com> Acked-by: Max Filippov <jcmvbkbc@gmail.com> Link: https://lore.kernel.org/r/20230810091510.13006-2-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: serial: qcom-geni-serial: Poll primary sequencer irq status after cancel_txVijaya Krishna Nivarthi2023-08-091-5/+2
| | | | | | | | | | | | TX is handled by primary sequencer. After cancelling primary command, poll primary sequencer's irq status instead of that of secondary. While at it, also remove a couple of redundant lines that read from IRQ_EN register and write back same. Fixes: 2aaa43c70778 ("tty: serial: qcom-geni-serial: add support for serial engine DMA") Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com> Link: https://lore.kernel.org/r/1691578393-9891-1-git-send-email-quic_vnivarth@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: sifive: Remove redundant of_match_ptr()Ruan Jinjie2023-08-091-1/+1
| | | | | | | | | The driver depends on CONFIG_OF, it is not necessary to use of_match_ptr() here. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230809085541.2969654-1-ruanjinjie@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* 8250_men_mcb: remove unnecessary cast when reading registerSanjuán García, Jorge2023-08-041-1/+1
| | | | | | | | | | | | | | | | | Fixes following sparse warning: drivers/tty/serial/8250/8250_men_mcb.c:92:21: sparse: cast removes address space '__iomem' of expression drivers/tty/serial/8250/8250_men_mcb.c:92:21: sparse: incorrect type in argument 1 (different address spaces) expected void const volatile [noderef] __iomem *addr got void * Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202307261517.x1O9OAkd-lkp@intel.com/ Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com> Link: https://lore.kernel.org/r/20230803095816.110864-1-jorge.sanjuangarcia@duagon.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Remove linux/fs_uart_pd.hChristophe Leroy2023-08-041-71/+0
| | | | | | | | linux/fs_uart_pd.h is not used anymore. Remove it. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/f2cb444fa2b5776c9c51b5e46ea85edab62d1524.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Don't include fs_uart_pd.h when not neededChristophe Leroy2023-08-043-3/+0
| | | | | | | | | Remove inclusion of fs_uart_pd.h from all files not using anything from that file. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/c7996ef4de56e7ee42a434e37d214cba337a146c.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.cChristophe Leroy2023-08-041-2/+0
| | | | | | | | | | | | | | Commit 0b5cf10691eb ("[POWERPC] 8xx: Convert mpc866ads to the new device binding.") removed last definition of init_smc_ioports(). Remove it. And don't include anymore fs_uart_pd.h which is only included to provide fs_uart_platform_info structure. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/2869659e7faa20b0a506347bc4d1059e22709f19.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Remove cpm_uart/ subdirectoryChristophe Leroy2023-08-044-7/+1
| | | | | | | | | | | cpm_uart/ subdirectory only has cpm_uart_core.c and cpm_uart.h now. Move them up and remove cpm_uart/ directory while renaming cpm_uart_core.c as cpm_uart.c Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/9b8b8f89fc386480030f5339abe307541ae436a6.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Refactor cpm_uart_[un]map_pram()Christophe Leroy2023-08-045-142/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cpm_uart_map_pram() and cpm_uart_unmap_pram() are very similar for CPM1 and CPM2. On CPM1 cpm_uart_map_pram() uses of_iomap() while CPM2 uses of_address_to_resource()/ioremap(). CPM2 version will also work on CPM1. On CPM2 cpm_uart_map_pram() and cpm_uart_unmap_pram() has a special handling for SMC. Just gate it by an IS_ENABLED(CONFIG_CPM2). So move the CPM2 version into cpm_uart_core.c which is the only user of those two fonctions and refactor to also handle CPM1 as mentionned above. PROFF_SMC_SIZE is only defined for SMC2 and used only there. To make it simple, just use the numerical value 64, this is the only place it is used and anyway there's already the same numerical value for the alignment. Use cpm_muram_alloc() instead of cpm_dpalloc() macro. Then cpm_uart_cpm1.c and cpm_uart_cpm2.c are now empty and go away. Replace printk(KERN_WARN by pr_warn( to make checkpatch happier. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/44a266106c421319aa8e700c2db52d5dcd652c0f.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()Christophe Leroy2023-08-044-140/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cpm_uart_freebuf() is identical for CPM1 and CPM2. cpm_uart_allocbuf() only has a small difference between CPM1 and CPM2 as shown below: CPM1: if (is_con) { /* was hostalloc but changed cause it blows away the */ /* large tlb mapping when pinning the kernel area */ mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); dma_addr = (u32)cpm_dpram_phys(mem_addr); } else mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr, GFP_KERNEL); CPM2: if (is_con) { mem_addr = kzalloc(memsz, GFP_NOWAIT); dma_addr = virt_to_bus(mem_addr); } else mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr, GFP_KERNEL); Refactor this by using IS_ENABLED(CONFIG_CPM1) and move both functions in cpm_uart_core.c as they are used only there. While doing this, add the necessary casts to silence sparse for the CPM1 part. This is because a dma alloc is not expected to be an iomem but for CPM1 as we use DPRAM this is seen as iomem. Also replace calls to cpm_dpxxxx() by relevant cpm_muram_xxxx() calls. This is needed at least for cpm_dpram_phys() which is only defined for CPM1. Just do the same for all so that cpm_dpxxxx() macros can get droped in the future. To silence checkpatch, replace printk(KERN_ERR by pr_err( and display function name instead of hard coded filename. Also replace mem_addr == NULL by !mem_addr. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/606dfdd258a4f2f2882e2e189bef37526bb3b499.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Deduplicate cpm_line_cr_cmd()Christophe Leroy2023-08-044-11/+5
| | | | | | | | | cpm_line_cr_cmd() is identical for CPM1 and CPM2 and is used only in cpm_uart_core.c. Move it there. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/6996e6ff93067dcddebf0d0c86487345149e165c.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()Christophe Leroy2023-08-044-71/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | CPMFCR_EB is the same as SMC_EB and is defined for both CPM1 and CPM2. CPMFCR_GBL is defined as 0 for CPM1. Therefore the CPM2 version of cpm_set_scc_fcr() and cpm_set_smc_fcr() can be used on both CPM1 and CPM2. And cpm_set_brg() is already identical and just a wrapper of cpm_setbrg(). In addition those three fonctions are only called once from cpm_uart_core.c, so just replace the calls with the content of the CPM2 versions of them. And DPRAM_BASE is identical so can go in cpm_uart.h. While moving it, use cpm_muram_addr() directly instead of the cpm_dpram_addr() macro and remove __force tag which isn't needed. Then cpm_uart_cpm1.h and cpm_uart_cpm2.h go away. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/6920e61fd362961ae1aeda897c8bfe1efacdc9dc.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()Christophe Leroy2023-08-042-12/+4
| | | | | | | | | | | | | | uart_baudrate() is just a trivial wrapper to get_baudrate(). Use get_baudrate() directly and remove assignment in if condition. And also remove uart_clock() which is not used since commit 0b2a2e5b7747 ("cpm_uart: Remove !CONFIG_PPC_CPM_NEW_BINDING code") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/4d497386f576a3df768e44a04f9bb512e424c311.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Stop using fs_uart_id enumChristophe Leroy2023-08-042-3/+1
| | | | | | | | | Using an enum indirection to define numeric macros is pointless. Directly use the wanted numeric value. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/4772d2a21894db443fe42836421eb22206a334aa.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Remove stale prototypes and table and macrosChristophe Leroy2023-08-042-24/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | cpm_uart_init_portdesc() smc1_lineif() smc2_lineif() scc1_lineif() scc2_lineif() scc3_lineif() scc4_lineif() Those functions were removed by commit 0b2a2e5b7747 ("cpm_uart: Remove !CONFIG_PPC_CPM_NEW_BINDING code"). Remove stale prototypes. UART_SMC{1..2} and UART_SCC{1..4} and SCC_WAIT_CLOSING macros are not used anymore since the above commit. cpm_uart_ports[] isn't used outside cpm_uart_core.c since the same commit, so make it static. cpm_uart_init_smc() and cpm_uart_init_scc() don't need a forward declaration. FLAG_DISCARDING and IS_DISCARDING have never been used since at least 2.6.12 and the start of git repository for kernel. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/96ef20ae1df056d1b7967871ba6e27e5b5aaeea6.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: cpm_uart: Avoid suspicious lockingChristophe Leroy2023-08-041-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CHECK drivers/tty/serial/cpm_uart/cpm_uart_core.c drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock Allthough 'nolock' is not expected to change, sparse find the following form suspicious: if (unlikely(nolock)) { local_irq_save(flags); } else { spin_lock_irqsave(&pinfo->port.lock, flags); } cpm_uart_early_write(pinfo, s, count, true); if (unlikely(nolock)) { local_irq_restore(flags); } else { spin_unlock_irqrestore(&pinfo->port.lock, flags); } Rewrite it a more obvious form: if (unlikely(oops_in_progress)) { local_irq_save(flags); cpm_uart_early_write(pinfo, s, count, true); local_irq_restore(flags); } else { spin_lock_irqsave(&pinfo->port.lock, flags); cpm_uart_early_write(pinfo, s, count, true); spin_unlock_irqrestore(&pinfo->port.lock, flags); } Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* 8250_men_mcb: Remove redundant initialization owner in mcb_driverLi Zetao2023-08-041-1/+0
| | | | | | | | | | The module_mcb_driver() will set "THIS_MODULE" to driver.owner when register a mcb_driver driver, so it is redundant initialization to set driver.owner in mcb_driver statement. Remove it for clean code. Signed-off-by: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230804100843.100348-1-lizetao1@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* 8250_men_mcb: Fix unsigned expression compared with zeroLi Zetao2023-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | There is a warning reported by coccinelle: ./drivers/tty/serial/8250/8250_men_mcb.c:226:6-19: WARNING: Unsigned expression compared with zero: data -> line [ i ] < 0 The array "line" of serial_8250_men_mcb_data is used to record the registered serial port. When register a port failed, it will return an error code, but the type of "line" is "unsigned int", causing the error code to reverse. Modify the type of "data -> line" to solve this problem. Fixes: 2554e6ba28a2 ("8250_men_mcb: Read num ports from register data.") Signed-off-by: Li Zetao <lizetao1@huawei.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230803142053.1308926-1-lizetao1@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: max310x: fix typos in commentsHugo Villeneuve2023-08-041-1/+1
| | | | | | | | cotroller -> controller. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://lore.kernel.org/r/20230803175931.981625-1-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* serial: max310x: add comments for membase address workaroundHugo Villeneuve2023-08-041-0/+5
| | | | | | | | | | | | Add comments about workaround used to configure membase address. This follows suggestions made during review of a sc16is7xx driver patch to add the same workaround. Link: https://lore.kernel.org/lkml/2936e18f-44ea-faed-9fa0-2ddefe7c3194@linux.intel.com Link: https://lore.kernel.org/lkml/20230801131655.80bd8f97f018dda6155d65f6@hugovil.com/ Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://lore.kernel.org/r/20230803140551.970141-1-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: n_gsm: require CAP_NET_ADMIN to attach N_GSM0710 ldiscThadeu Lima de Souza Cascardo2023-08-041-0/+3
| | | | | | | | | | | Any unprivileged user can attach N_GSM0710 ldisc, but it requires CAP_NET_ADMIN to create a GSM network anyway. Require initial namespace CAP_NET_ADMIN to do that. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> Link: https://lore.kernel.org/r/20230731185942.279611-1-cascardo@canonical.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* 8250_men_mcb: Fix unsigned comparison with less than zeroJiapeng Chong2023-08-041-3/+5
| | | | | | | | | | | | | | The data->line[i] is defined as unsigned int type, if(data->line[i] < 0) is invalid, so replace data->line[i] with res. ./drivers/tty/serial/8250/8250_men_mcb.c:223:6-19: WARNING: Unsigned expression compared with zero: data->line[i] < 0. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6088 Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230803084753.51253-1-jiapeng.chong@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: serial: samsung: Set missing PM ops for hibernation supportAnton Eliasson2023-08-041-3/+2
| | | | | | | | | | | | At least freeze, restore and thaw need to be set in order for the driver to support system hibernation. The existing suspend/resume functions can be reused since those functions don't touch the device's power state or wakeup capability. Use the helper macros SET_SYSTEM_SLEEP_PM_OPS and SET_NOIRQ_SYSTEM_SLEEP_PM_OPS for symmetry with similar drivers. Signed-off-by: Anton Eliasson <anton.eliasson@axis.com> Link: https://lore.kernel.org/r/20230803-samsung_tty_pm_ops-v1-1-1ea7be72194d@axis.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: serial: xilinx_uartps: Do not check for 0 return after calling ↵Ruan Jinjie2023-08-041-2/+2
| | | | | | | | | | | | | platform_get_irq() Since commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid"), there is no possible for platform_get_irq() to return 0. Use the return value from platform_get_irq(). Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Link: https://lore.kernel.org/r/20230803091712.596987-1-ruanjinjie@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: Fix potential deadlock on &info->lockChengfeng Ye2023-08-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As &info->lock is acquired by slgt_interrupt() under irq context, other process context code acquiring the lock should disable irq, otherwise deadlock could happen if the irq preempt the execution while the lock is held in process context on the same CPU. Lock acquisition inside set_params32() does not disable irq, and this function is called by slgt_compat_ioctl() from process context. Possible deadlock scenario: slgt_compat_ioctl() -> set_params32() -> spin_lock(&info->lock) <irq> -> slgt_interrupt() -> spin_lock(&info->lock); (deadlock here) This flaw was found by an experimental static analysis tool I am developing for irq-related deadlock. x86_64 allmodconfig using gcc shows no new warning. The patch fixes the potential deadlock by spin_lock_irqsave() like other lock acquisition sites. Signed-off-by: Chengfeng Ye <dg573847474@gmail.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230728123901.64225-1-dg573847474@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: vt: Remove some repetitive initializationoushixiong2023-08-031-12/+4
| | | | | | | | | | | Members vc_col, vc_rows and vc_size_row of the struct vc_data have been initialized in visual_init(), so it is no longer needed to initialize them in vc_init() again. Signed-off-by: oushixiong <oushixiong@kylinos.cn> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230803065409.461031-1-oushixiong@kylinos.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: serial: Remove redundant initialization for ma35d1serial_driverLi Zetao2023-08-031-1/+0
| | | | | | | | | | | | | | | | There is a warning reported by coccinelle: ./drivers/tty/serial/ma35d1_serial.c:791:3-8: No need to set .owner here. The core will do it. The module_platform_driver() will set "THIS_MODULE" to driver.owner when register a driver for platform-level devices, so it is redundant initialization to set driver.owner in ma35d1serial_driver statement. Remove it to silence the warning. Signed-off-by: Li Zetao <lizetao1@huawei.com> Link: https://lore.kernel.org/r/20230803032353.3045221-1-lizetao1@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* net: nfc: remove casts from tty->disc_dataJiri Slaby2023-08-031-4/+4
| | | | | | | | | | | | | | | | | | | | | tty->disc_data is 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> 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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Cc: linux-can@vger.kernel.org Cc: netdev@vger.kernel.org Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Max Staudt <max@enpas.org> Link: https://lore.kernel.org/r/20230801062237.2687-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* can: can327: remove casts from tty->disc_dataJiri Slaby2023-08-031-4/+4
| | | | | | | | | | | | | | | | | | | | | tty->disc_data is 'void *', so there is no need to cast from that. Therefore remove the casts and assign the pointer directly. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> 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: Dario Binacchi <dario.binacchi@amarulasolutions.com> Cc: linux-can@vger.kernel.org Cc: netdev@vger.kernel.org Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Max Staudt <max@enpas.org> Link: https://lore.kernel.org/r/20230801062237.2687-2-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: mark as BROKENJiri Slaby2023-07-311-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | After walking and trying to clean up the worst in the driver, I came across the pci_driver::remove() _empty_ implementation. That would crash the system at least during hot-unplug (or write to remove in sysfs). There are many other problems: * Initialization + deinitialization apparently comes from no-hotplug support age. It needs a rewrite. * Hairy debug macros. Drop them. * Use of self-baked lists. Replace by list. * The order of the functions should be inverted and fwd decls dropped. * Coding style from the stone age. Fix. * I assume there are many bugs, but the code is unreadable at times, so hard to judge. There is one example posted [1]. I was able to find only one user back in 2016. So mark the driver as BROKEN for some time. Either someone will notice and we can bring the driver to this century. Or we will drop it completely if noone cares. [1] https://lore.kernel.org/all/20230728123901.64225-1-dg573847474@gmail.com/ Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Cc: Chengfeng Ye <dg573847474@gmail.com> Link: https://lore.kernel.org/r/20230731090002.15680-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: make default_params constJiri Slaby2023-07-311-1/+1
| | | | | | | | | default_params are only read, so move them from .data to .rodata using 'const'. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-7-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: use PCI_VDEVICEJiri Slaby2023-07-311-5/+5
| | | | | | | | It makes the device entries quite a bit readable. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-6-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: drop info messages from init/exit functionsJiri Slaby2023-07-311-10/+0
| | | | | | | | | It is preferred NOT to print anything from init and exit functions of a module. (If everything goes fine.) Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-5-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: define global strings as const stringsJiri Slaby2023-07-311-2/+2
| | | | | | | | And not non-const pointers to strings. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: drop global slgt_driver_name arrayJiri Slaby2023-07-311-2/+1
| | | | | | | | It's used on one place, so put the containing string there directly. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-3-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* tty: synclink_gt: convert CALC_REGADDR() macro to an inlineJiri Slaby2023-07-311-18/+18
| | | | | | | | | | | | | | | It makes the code more readable and less error-prone as the result is returned and not stored in a variable newly defined inside the macro. Note that cast to 'unsigned long' and back to 'void *' was eliminated as info->reg_addr is 'char *' already (so the addition is per bytes already). This nicely cleans up the callers too. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230731090002.15680-2-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>