From patchwork Thu Aug 22 03:39:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Liu X-Patchwork-Id: 13772613 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13B85C3DA4A for ; Thu, 22 Aug 2024 03:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gCneuIT6Rq2rxHSyitUkMuaEIU4QSMLzF/kfR0v556c=; b=DKkwcZQ2szAvGApFKORD87s2Zd xd1Hi1Cdal3QZjdRnGch+U9Mi5Q+/Ywq/ETvo6RfxZXoL5vLsU1Y34ya0aLcwdldqTfo5/FLNAxNP ePrq++qXxlP5JxxrYYqNvxZbTUUYaziuRWF2lh26wHvuGEmjEbYlsUdhwxF1gboQLuBX3U1j+oBEa LoES2gbMOHFIOQlacy4i2EXwTb38QChFDSWnhCsMKQOor5Cbs7grSN4cJN11oHWYbkexV0pClmmuV 7JM/xVVzISiWg3qJNfc6BNdbA7MJi/7KPd/V8wxAX0EjyZHdSpgJQwfxYcshCDJspIQiLZ5KtAnv1 Yyu7d98A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgykt-0000000BGCi-0ruT; Thu, 22 Aug 2024 03:44:59 +0000 Received: from mail-eastasiaazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c400::] helo=HK2PR02CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgyi0-0000000BFRl-2di2; Thu, 22 Aug 2024 03:42:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r9mWNQkmUI0LVbteOZ9plxey1ngUcmWyDa6Sj+jWPYUNncK6I4K772S0P9Hh6qwR0fTbkyBAJzJtbMa/RPAfIiR3Vr953f9me3tZQ3X1BO0zDDSqdy0atzt5HQMco8cds95gnENCoyRHni+Jm9kCa2bTyj/xYI7Sq8gFXzN77ikWWVzYWIaGJonCzALzaQeJyKsT8c4YfimdXfwD6+tlouDVD2Z2I6kFcpsfP3+K7ik0WoRVX4kTBcZQnO0JljUzLJ1Abl/tlHxUKIyFlyeCLrrbN2mxzD2I9K7emn7c9XAAkDLi84PzxlIGNUp2JeB4nmj0Bhrz88R3ricsF6c02Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gCneuIT6Rq2rxHSyitUkMuaEIU4QSMLzF/kfR0v556c=; b=j6L6OOslpsMYq6SDyqdag2JD21tyjF8VhaophQzTbNa4dLh3rwZyKI0vIQqZ78eNy9hYoZYxGaRbZqn170XtYMtbk1zE0wc7JHQTlNSvVE7hUJnmaI6s1n6ifgmmeviyJD6TA0erPigNGxWN1SxWM8yrUvZ2GH0fTTVSM2rpdUPKl5VJ7cgOn/N+Q+XoocmDG8BjgupJwjTZmsY/7WhgW0kvO5XryHEA4fQ90zl8wfZyZ4p/zdUVGF2RgHzQ7Uuyd+YgV9ipXeX+Zn3e0qhfxDK5FEhM3zE8jVDBn2b2Ef9zvJwZH+IShEBZmcSrcxFFzfN26avXDxOnNocwgBSAOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gCneuIT6Rq2rxHSyitUkMuaEIU4QSMLzF/kfR0v556c=; b=cLHV8t2EcDVR0YedssRXWAe7FaRtm/q+IlywdojjJtgdPxRhuTpSymmJeJCd6ivIczubYBG7W5+/fI+QmZM4q03JC3k+WeQbQh6a/qtQiWvpYnSb7U+pspMgld3ZS9dWDfLcILVZs7jk/0AZneHC6H3z3hSQQl+av9oOx+9twxiVF10lw6UFypah/77YBIKOyGQMs3tvg1rFRxGYWvpbBpvkFRngC8EnwN22g8Oh4uxcfnezax9oPnPMXHcGgUPzWQ48paxwqWkqJit3lRlH5qoF/nO635MunI4sylqwFPlb9loNXk7mPHe1Wa8mI2HeEhlCPJZZ9UIqbk11jdeLaA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PUZPR06MB5620.apcprd06.prod.outlook.com (2603:1096:301:ee::9) by SEYPR06MB5892.apcprd06.prod.outlook.com (2603:1096:101:d5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Thu, 22 Aug 2024 03:41:57 +0000 Received: from PUZPR06MB5620.apcprd06.prod.outlook.com ([fe80::b771:8e9f:2fb:ee83]) by PUZPR06MB5620.apcprd06.prod.outlook.com ([fe80::b771:8e9f:2fb:ee83%7]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 03:41:57 +0000 From: Lei Liu To: Paul Cercueil , Greg Kroah-Hartman , Jiri Slaby , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam , Patrice Chotard , Maxime Coquelin , Alexandre Torgue , Lei Liu , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Andi Shyti , Geert Uytterhoeven , Andy Shevchenko , Thomas Gleixner , John Ogness , Jeff Johnson , Sebastian Andrzej Siewior , Valentin Caron , Lino Sanfilippo , Amelie Delaunay , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Cc: opensource.kernel@vivo.com Subject: [PATCH 8/8] tty: stm32-usart: Use devm_clk_get_enabled() helpers Date: Thu, 22 Aug 2024 11:39:12 +0800 Message-Id: <20240822033924.32397-9-liulei.rjpt@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822033924.32397-1-liulei.rjpt@vivo.com> References: <20240822033924.32397-1-liulei.rjpt@vivo.com> X-ClientProxiedBy: TYAPR01CA0108.jpnprd01.prod.outlook.com (2603:1096:404:2a::24) To PUZPR06MB5620.apcprd06.prod.outlook.com (2603:1096:301:ee::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR06MB5620:EE_|SEYPR06MB5892:EE_ X-MS-Office365-Filtering-Correlation-Id: 700f359a-aafb-4e5f-3b73-08dcc25c5f50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: rzUc3M9XlvkWLMPt27YHNaosZznXUxIf4mfY9w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uC1O4/i8aIzILlOUxI3HDf7Q4EFs+o8gPi3T5p6nW30y1aafgWk+f3lbi+0hju2EbLaSkmUVZjlgClg8dypPebHTCXgI8NUV8GeZWc8lIRJwcCZuFA4NDwZqjsNtheNDeMvmSy3l+zE8le4rR8NEvyGZ6jq5XT4yI7mtdWbYv3qA8Ad5m4V4wFzlT87udDR4csqgQThg+xdeM1Tm9Xyk4G7TWxgNTPlI0D+LKXS8/s+fFjMprlQB4wCuHfXsxZEtONIB2RW+twVsVPBc+OAJBEhR9CAo8rcEc5biFkGXK/P9bderKanwkK+ToVePslyhECKced3ZY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5620.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yE+y/D5FQBq31sbVrqbrxZlDIWE9mOgmH8X683ABTMRrcvMAcecqW7LQDHGR8nzoIu5puPB9BQP8XAPLqlTSqbu4Od7IsmBUTIGef6+kMGsNzTTcNkmkjJ4xGqWlIk8HAtnA6npRlmn2mpxLgDAFf8RJKKowy4om+F0FEE5JSDnupBvNNoJiv/N1XrsuYUKZkDgWBhtqF9hL9xXhsvMTiqpGrIWBm1P8HQBno9fpHBm2vxUGG3C8IjZw/cq9dG5SfwSFYV4gB4xgb7OStanUGDu2cgc1fJrc6+L8R6KTXpGn1VfT01ksUm88RL2fhwiEoE25wjBAbgwuYXNuybOEqCRvRMSI7dXwNzp9ctDdrZaxAx/u/561UDQGI02zfrXD4x+OGHl5UVjV2MTuz/lFG18MjQw6CApiEztQF3H1m1x9CCWfmqujjzRV1ctj5z0jutnZtLd0VaId8NzAd7s3W3TXVPKeOImwCip6BDkYXvsbgZ+xuugE2LB4m3isFkaLUi6cEsS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-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 700f359a-aafb-4e5f-3b73-08dcc25c5f50 X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5620.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 03:41:57.3446 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ruINW/oRR7brO+2/d3lL4uKUES2hNu1ENIn8SyXLK7rmqqY3Pd3KlnyN98vJsE4Jql33OreXv/bYREIYEzbRQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5892 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_204201_137759_7BB342C2 X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids calls to clk_disable_unprepare(). Signed-off-by: Lei Liu --- drivers/tty/serial/stm32-usart.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index e1e7bc04c579..9bce3159165a 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -1550,11 +1550,6 @@ static int stm32_usart_get_ftcfg(struct platform_device *pdev, struct stm32_port return fifo_size; } -static void stm32_usart_deinit_port(struct stm32_port *stm32port) -{ - clk_disable_unprepare(stm32port->clk); -} - static const struct serial_rs485 stm32_rs485_supported = { .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | SER_RS485_RX_DURING_TX, @@ -1599,15 +1594,10 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, spin_lock_init(&port->lock); - stm32port->clk = devm_clk_get(&pdev->dev, NULL); + stm32port->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(stm32port->clk)) return PTR_ERR(stm32port->clk); - /* Ensure that clk rate is correct by enabling the clk */ - ret = clk_prepare_enable(stm32port->clk); - if (ret) - return ret; - stm32port->port.uartclk = clk_get_rate(stm32port->clk); if (!stm32port->port.uartclk) { ret = -EINVAL; @@ -1645,7 +1635,6 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, return ret; err_clk: - clk_disable_unprepare(stm32port->clk); return ret; } @@ -1853,8 +1842,6 @@ static int stm32_usart_serial_probe(struct platform_device *pdev) if (stm32port->wakeup_src) device_set_wakeup_capable(&pdev->dev, false); - stm32_usart_deinit_port(stm32port); - err_dma_tx: if (stm32port->tx_ch) dma_release_channel(stm32port->tx_ch); @@ -1904,7 +1891,6 @@ static void stm32_usart_serial_remove(struct platform_device *pdev) device_init_wakeup(&pdev->dev, false); } - stm32_usart_deinit_port(stm32_port); } static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch)