From patchwork Tue May 3 06:31:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 569256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 225D3C433FE for ; Tue, 3 May 2022 06:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiECGfE (ORCPT ); Tue, 3 May 2022 02:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiECGe7 (ORCPT ); Tue, 3 May 2022 02:34:59 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57159381AF; Mon, 2 May 2022 23:31:28 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id EFB92210EE; Tue, 3 May 2022 06:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651559486; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ytM5kTlhfOQM6IG3OcCbjJmaCYay4pn3Lo26jfdHWE=; b=nRidPY8mC0MDHLS4HCFIYDsJYXv8fCSaTj0BWC5AVOU43vPcu6L2R1xy1aOuyPfKaVT/fA rXZcS4v0pm4pM5VADGVQmPigdpdvVQHqHpbcMKPxmN7SJGAQmVyGpjl5xVZacJQOEWR+ZM olCykiczgjscDYXB4AgaYxwRIS2r7gM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651559486; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ytM5kTlhfOQM6IG3OcCbjJmaCYay4pn3Lo26jfdHWE=; b=3cA9kMxo9F4eQVSxgHQm3qqmzr5En3M/kY/cxRfcDNfBJQgsT68W879fHDDtYUrSvFFrK3 c68PZlbS/JS+ynCw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C56172C143; Tue, 3 May 2022 06:31:26 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 03/11] serial: pic32: remove constants from struct pic32_sport Date: Tue, 3 May 2022 08:31:14 +0200 Message-Id: <20220503063122.20957-4-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503063122.20957-1-jslaby@suse.cz> References: <20220503063122.20957-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org All the irqflags_* in struct pic32_sport are set to IRQF_NO_THREAD and never updated. So remove pic32_sport::irqflags_* and use the flag directly. Signed-off-by: Jiri Slaby --- drivers/tty/serial/pic32_uart.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index a1b8c05f3d46..1e8ff6004e8e 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -45,13 +45,10 @@ * @port: uart port descriptor * @idx: port index * @irq_fault: virtual fault interrupt number - * @irqflags_fault: flags related to fault irq * @irq_fault_name: irq fault name * @irq_rx: virtual rx interrupt number - * @irqflags_rx: flags related to rx irq * @irq_rx_name: irq rx name * @irq_tx: virtual tx interrupt number - * @irqflags_tx: : flags related to tx irq * @irq_tx_name: irq tx name * @cts_gpio: clear to send gpio * @dev: device descriptor @@ -61,13 +58,10 @@ struct pic32_sport { int idx; int irq_fault; - int irqflags_fault; const char *irq_fault_name; int irq_rx; - int irqflags_rx; const char *irq_rx_name; int irq_tx; - int irqflags_tx; const char *irq_tx_name; u8 enable_tx_irq; @@ -533,7 +527,7 @@ static int pic32_uart_startup(struct uart_port *port) } irq_set_status_flags(sport->irq_fault, IRQ_NOAUTOEN); ret = request_irq(sport->irq_fault, pic32_uart_fault_interrupt, - sport->irqflags_fault, sport->irq_fault_name, port); + IRQF_NO_THREAD, sport->irq_fault_name, port); if (ret) { dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", __func__, sport->irq_fault, ret, @@ -551,7 +545,7 @@ static int pic32_uart_startup(struct uart_port *port) } irq_set_status_flags(sport->irq_rx, IRQ_NOAUTOEN); ret = request_irq(sport->irq_rx, pic32_uart_rx_interrupt, - sport->irqflags_rx, sport->irq_rx_name, port); + IRQF_NO_THREAD, sport->irq_rx_name, port); if (ret) { dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", __func__, sport->irq_rx, ret, @@ -569,7 +563,7 @@ static int pic32_uart_startup(struct uart_port *port) } irq_set_status_flags(sport->irq_tx, IRQ_NOAUTOEN); ret = request_irq(sport->irq_tx, pic32_uart_tx_interrupt, - sport->irqflags_tx, sport->irq_tx_name, port); + IRQF_NO_THREAD, sport->irq_tx_name, port); if (ret) { dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", __func__, sport->irq_tx, ret, @@ -918,11 +912,8 @@ static int pic32_uart_probe(struct platform_device *pdev) sport->idx = uart_idx; sport->irq_fault = irq_of_parse_and_map(np, 0); - sport->irqflags_fault = IRQF_NO_THREAD; sport->irq_rx = irq_of_parse_and_map(np, 1); - sport->irqflags_rx = IRQF_NO_THREAD; sport->irq_tx = irq_of_parse_and_map(np, 2); - sport->irqflags_tx = IRQF_NO_THREAD; sport->clk = devm_clk_get(&pdev->dev, NULL); sport->cts_gpio = -EINVAL; sport->dev = &pdev->dev; From patchwork Tue May 3 06:31:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 569255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7932CC43217 for ; Tue, 3 May 2022 06:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbiECGfG (ORCPT ); Tue, 3 May 2022 02:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbiECGfA (ORCPT ); Tue, 3 May 2022 02:35:00 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 960AF381B1; Mon, 2 May 2022 23:31:28 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3B8CB1F74A; Tue, 3 May 2022 06:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651559487; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mDGq2MehCOuWbouH8qY7t2f0w7/Wwz3YBeWZPEhcmus=; b=FKJ8qSQJInvQR3s5rJMHC9K+NJk9VbJ7/e4VvVXMP3P28/siEuTnY4Fy45CwsFsELW8RVJ wr1w5R7pF6/NLCYrtyRrdn7X5pW3I1iD1EYqMSun1NlWlVrgXW4g5P1KueJ0SyXCSrRPeI o7MctBUPzKFET8c1l/429EAQ+1XLyPY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651559487; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mDGq2MehCOuWbouH8qY7t2f0w7/Wwz3YBeWZPEhcmus=; b=KDD3IkJ2LZ6OIyANkpCZUBsxLCPHiMTRkCgmpmhMnZP85FChGfQ/cBqTttbyvr6V2jaFPB d7Yl1bkS+hiOyUAg== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0DD9A2C141; Tue, 3 May 2022 06:31:27 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 04/11] serial: pic32: simplify clk handling Date: Tue, 3 May 2022 08:31:15 +0200 Message-Id: <20220503063122.20957-5-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503063122.20957-1-jslaby@suse.cz> References: <20220503063122.20957-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org struct pic32_sport::ref_clk is only set, but not read. That means we can remove it. And when we do so, pic32_enable_clock() and pic32_disable_clock() are simple wrappers around clk_prepare_enable() and clk_disable_unprepare() respectively. So we can remove the former two from the code and replace it by the latter two. Signed-off-by: Jiri Slaby --- drivers/tty/serial/pic32_uart.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index 1e8ff6004e8e..42269e96b3f8 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -68,7 +68,6 @@ struct pic32_sport { bool hw_flow_ctrl; int cts_gpio; - int ref_clk; struct clk *clk; struct device *dev; @@ -138,23 +137,6 @@ static inline void pic32_wait_deplete_txbuf(struct pic32_sport *sport) udelay(1); } -static inline int pic32_enable_clock(struct pic32_sport *sport) -{ - int ret = clk_prepare_enable(sport->clk); - - if (ret) - return ret; - - sport->ref_clk++; - return 0; -} - -static inline void pic32_disable_clock(struct pic32_sport *sport) -{ - sport->ref_clk--; - clk_disable_unprepare(sport->clk); -} - /* serial core request to check if uart tx buffer is empty */ static unsigned int pic32_uart_tx_empty(struct uart_port *port) { @@ -491,7 +473,7 @@ static int pic32_uart_startup(struct uart_port *port) local_irq_save(flags); - ret = pic32_enable_clock(sport); + ret = clk_prepare_enable(sport->clk); if (ret) { local_irq_restore(flags); goto out_done; @@ -611,7 +593,7 @@ static void pic32_uart_shutdown(struct uart_port *port) spin_lock_irqsave(&port->lock, flags); pic32_uart_dsbl_and_mask(port); spin_unlock_irqrestore(&port->lock, flags); - pic32_disable_clock(sport); + clk_disable_unprepare(sport->clk); /* free all 3 interrupts for this UART */ free_irq(sport->irq_fault, port); @@ -835,7 +817,7 @@ static int pic32_console_setup(struct console *co, char *options) return -ENODEV; port = pic32_get_port(sport); - ret = pic32_enable_clock(sport); + ret = clk_prepare_enable(sport->clk); if (ret) return ret; @@ -965,7 +947,7 @@ static int pic32_uart_probe(struct platform_device *pdev) /* The peripheral clock has been enabled by console_setup, * so disable it till the port is used. */ - pic32_disable_clock(sport); + clk_disable_unprepare(sport->clk); } #endif @@ -986,7 +968,7 @@ static int pic32_uart_remove(struct platform_device *pdev) struct pic32_sport *sport = to_pic32_sport(port); uart_remove_one_port(&pic32_uart_driver, port); - pic32_disable_clock(sport); + clk_disable_unprepare(sport->clk); platform_set_drvdata(pdev, NULL); pic32_sports[sport->idx] = NULL; From patchwork Tue May 3 06:31:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 569253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8138C4332F for ; Tue, 3 May 2022 06:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbiECGfJ (ORCPT ); Tue, 3 May 2022 02:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbiECGfC (ORCPT ); Tue, 3 May 2022 02:35:02 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B83F381B2; Mon, 2 May 2022 23:31:29 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 562DB1F74C; Tue, 3 May 2022 06:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tSVRncgXdxhSPnVu1HuIPNNJumIspe/QnB20qz/St8A=; b=livOX+eqi0gqvVmRuIoSMusLlBiZsQJe79CErg/SCugI6OfWuMX39YzG98FzqW0zWQldFk MRrH57oXVUw7ZHCQHnL6nIAeOjHep/yuG65lsZvREaP5FGZnKzcirGpOXUV0kN0deqCewU xQC+oDAk211IIhDrB0RXRBxBxaHKwu0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tSVRncgXdxhSPnVu1HuIPNNJumIspe/QnB20qz/St8A=; b=iy/H9Iu8/5AC8ky2uJdj5hCRPtHFsk/ianeeCPqclSW6ijOcXHI/oERBEz2bRJzcfCWieY kunN/D42qT4fJaDw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 216502C141; Tue, 3 May 2022 06:31:28 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 08/11] serial: pic32: don't assign pic32_sport::cts_gpio twice Date: Tue, 3 May 2022 08:31:19 +0200 Message-Id: <20220503063122.20957-9-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503063122.20957-1-jslaby@suse.cz> References: <20220503063122.20957-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org sport->cts_gpio is first assigned -EINVAL and few lines below using of_get_named_gpio(). Remove the first (useless) assignment. Signed-off-by: Jiri Slaby --- drivers/tty/serial/pic32_uart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index c3b4fd0b5b76..08e79d7f34f7 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -892,7 +892,6 @@ static int pic32_uart_probe(struct platform_device *pdev) sport->irq_rx = irq_of_parse_and_map(np, 1); sport->irq_tx = irq_of_parse_and_map(np, 2); sport->clk = devm_clk_get(&pdev->dev, NULL); - sport->cts_gpio = -EINVAL; sport->dev = &pdev->dev; /* Hardware flow control: gpios From patchwork Tue May 3 06:31:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 569254 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BC40C43219 for ; Tue, 3 May 2022 06:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiECGfH (ORCPT ); Tue, 3 May 2022 02:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiECGfC (ORCPT ); Tue, 3 May 2022 02:35:02 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E005A381B7; Mon, 2 May 2022 23:31:29 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9C70A21872; Tue, 3 May 2022 06:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UG/G8r1uCWHszZ/IvDqONfY3WDPVaGaRQxk6wngLySk=; b=OSPynr1u15u5yOyv1jfUUPpuj0OZuawxO0leMQdaIRmlY/140fy4+R6Xe1V9PbyXJK0r7m 5vU9Hsa05zdPpYtErr3MmI/zMrtHJNfxnfJyjbdD4Z8RQZ8nzBPwW8f4aaCzp7f5PZ76wV 5q62Q9adDVRi0pzMW2Tul96GgFLmF/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UG/G8r1uCWHszZ/IvDqONfY3WDPVaGaRQxk6wngLySk=; b=cHvR6udnaIXGXx0SVJ+SW9CRnDo9NA9KZU+WrszBIc0AR0X34kKQ31PmgO/QZexRWzkyPB 1N+iuFZzVq30CNCA== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6829C2C143; Tue, 3 May 2022 06:31:28 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 09/11] serial: pic32: don't zero members of kzalloc-ated structure Date: Tue, 3 May 2022 08:31:20 +0200 Message-Id: <20220503063122.20957-10-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503063122.20957-1-jslaby@suse.cz> References: <20220503063122.20957-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org struct pic32_sport (sport) has just been kzallocated. So there is no need to zero its member (sport->port) now. Signed-off-by: Jiri Slaby --- drivers/tty/serial/pic32_uart.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index 08e79d7f34f7..990603fe8a8d 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -919,7 +919,6 @@ static int pic32_uart_probe(struct platform_device *pdev) pic32_sports[uart_idx] = sport; port = &sport->port; - memset(port, 0, sizeof(*port)); port->iotype = UPIO_MEM; port->mapbase = res_mem->start; port->ops = &pic32_uart_ops; From patchwork Tue May 3 06:31:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 569252 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAAB4C433F5 for ; Tue, 3 May 2022 06:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbiECGfK (ORCPT ); Tue, 3 May 2022 02:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbiECGfC (ORCPT ); Tue, 3 May 2022 02:35:02 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7F2381B9; Mon, 2 May 2022 23:31:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DCB041F747; Tue, 3 May 2022 06:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kglfxKG8tOeOX0Y7XjujhzV++vy+pMPUwg+1PazJyZA=; b=fu+k0L0lbktlDQMhsGobm0GybDiRtyawngc3BfVZGH+Pay8xZK9HFACmzMTR4IH/dQS+Q8 lLldzCGZZzpWkDxYHMf42yxtTtIZPe6cEvkGgrCqbVSSbcnVz7KZbdV4ys3I/ttbV0bDJb c5SVBIa5ULbc/85AFKDe71CVzM9t5FE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651559488; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kglfxKG8tOeOX0Y7XjujhzV++vy+pMPUwg+1PazJyZA=; b=MUHdNmBrGDdkFUrm72yoGJX8ErNImRxRpNdiwPihjoTRAnyX20PPcp53moOpxH501//RV1 +HVrWVp104M9NuDA== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B37FB2C141; Tue, 3 May 2022 06:31:28 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 10/11] serial: pic32: free up irq names correctly Date: Tue, 3 May 2022 08:31:21 +0200 Message-Id: <20220503063122.20957-11-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503063122.20957-1-jslaby@suse.cz> References: <20220503063122.20957-1-jslaby@suse.cz> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org struct pic32_sport contains built-up names for irqs. These are freed only in error path of pic32_uart_startup(). And even there, the freeing happens before free_irq(). So fix this by: * moving frees after free_irq(), and * add frees to pic32_uart_shutdown() -- the opposite of pic32_uart_startup(). Signed-off-by: Jiri Slaby --- drivers/tty/serial/pic32_uart.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c index 990603fe8a8d..c5584628f8c4 100644 --- a/drivers/tty/serial/pic32_uart.c +++ b/drivers/tty/serial/pic32_uart.c @@ -569,14 +569,14 @@ static int pic32_uart_startup(struct uart_port *port) return 0; out_t: - kfree(sport->irq_tx_name); free_irq(sport->irq_tx, port); + kfree(sport->irq_tx_name); out_r: - kfree(sport->irq_rx_name); free_irq(sport->irq_rx, port); + kfree(sport->irq_rx_name); out_f: - kfree(sport->irq_fault_name); free_irq(sport->irq_fault, port); + kfree(sport->irq_fault_name); out_done: return ret; } @@ -595,8 +595,11 @@ static void pic32_uart_shutdown(struct uart_port *port) /* free all 3 interrupts for this UART */ free_irq(sport->irq_fault, port); + kfree(sport->irq_fault_name); free_irq(sport->irq_tx, port); + kfree(sport->irq_tx_name); free_irq(sport->irq_rx, port); + kfree(sport->irq_rx_name); } /* serial core request to change current uart setting */