Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp390320iob; Mon, 2 May 2022 23:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh58bERNfGMqsFfCkWU12+Ma6GCOACkDVmamnps/S3GDXKKmodyj1CAFBYVFko7UoTs7UE X-Received: by 2002:a2e:a447:0:b0:249:5d85:aa54 with SMTP id v7-20020a2ea447000000b002495d85aa54mr9188545ljn.528.1651560841702; Mon, 02 May 2022 23:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651560841; cv=none; d=google.com; s=arc-20160816; b=UtARUrbyyif/EOJpVRXz7fUKcfwq5psBdszo7pSiuCMdMuV8ZyoNIoteo5jfGTLlKa ZIbSbpuY1+qE57SJDMSt8ImypZQR5Ion6llFG1e2leJ6brgkC+/I+q0Ld97XKL/hYixG BxNdoW2/HRkO0x1NqL4JMsZXVhZX2KrH5QJrQIf8+w5uGhPDFmOQuJkyBDsqfzlntj2Q jqoY58GB+IRN+6assYwPHXe2zV3S6ctEssYAHre+hyUqvzkV2pVF10/6kS3v985lC1oj o0isz3b7X8swHWYs2oif+9yNhpBo4TxMsNVqIg6l9GzNoHGetFSpPOIFGgFpNESvGbJT hbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=mDGq2MehCOuWbouH8qY7t2f0w7/Wwz3YBeWZPEhcmus=; b=LjuC1sOYzMFLDSID45JrxNoCIGvXZBfpkWDY596kwBQhAHHnui1CoLqu9PUuLs6jmh PCi1ZTNZKtnEIPHPMVvWQuSnFNRQmFT8NCXuayTZXsV155b+XuskbSMLuaR8KxI7nN4g uSYiPqXLan2Dejx7OGk0WKge2nHXXsU8S4jV+bFT1SP7ChtD5DAwg6KAB0rLjaSHXBVe uGIONS3zRh3QvNIt4lqWvgyLrwDKfnU8eafFs+h8xp/a1d36rdrpy2JLNcE6Z+evABOI +OUqhRa39OdKVnvHh6ODANiSmre14rDMp6BDuadUQ1oUK/IPpNzJLutWAl4NnKZjbEZy j2Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=FKJ8qSQJ; dkim=neutral (no key) header.i=@suse.cz header.b=KDD3IkJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a2ea901000000b0024f0dd8f214si14690859ljq.62.2022.05.02.23.53.34; Mon, 02 May 2022 23:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=FKJ8qSQJ; dkim=neutral (no key) header.i=@suse.cz header.b=KDD3IkJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230073AbiECGfY (ORCPT + 99 others); Tue, 3 May 2022 02:35:24 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.36.0