Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6984052imu; Wed, 14 Nov 2018 09:50:38 -0800 (PST) X-Google-Smtp-Source: AJdET5dhY9j8sDJk2gCFl3MwwaTQOdEDlXt1oOJkJMkJCLv2RDREZCTJQfhtxZJIY7Ze41WaNNqQ X-Received: by 2002:a17:902:e10f:: with SMTP id cc15-v6mr2930653plb.309.1542217838667; Wed, 14 Nov 2018 09:50:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542217838; cv=none; d=google.com; s=arc-20160816; b=LhXFhxaRXXZnHhBBpObh2iR/iQu4E58WqFUhoTYXsLHs01Fk1+nMTm8Wjl21xMROUq JxKvpuvIqih4o4UZGPhQw3ad0bfBmv2oVHFvVmrSQGRgaGP2y3+Cx35EcGR+I7SH/cJ9 o6hlveUHPw8dFzjd2nnUPgjnkkWEiqu0JyTwmrkFIKhDe4P+ZtVhkSIaQPlRG0/glGft GbqrVZuOW9wT4k9amFEJ2HHZQGtGCgOuJiTFh5Jf2Mn8FBP/qy/CnSLWdsrkvd1yiKj5 tuPGCRgcJVsVUSXs8vrxQwAy0eqbbub5UPlmVvlOWgJYd8bS7TNAi+4hGpxuTMEybKM6 b35A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WLKkszEWOPlBFuW2wcbYnhdMhnLa9QG3D33fjz0lQpw=; b=URJvgXBu3XHajf51TeysENFPeJVtgS7jhqnL66DDz0+XFxU75LVpnND02Ko6QZ/a3b 7pnoIb+9wHdWwWIzH37zXYbS2fv3q6VehljHbKt7AxHaiddUD5NwH5ea0/MNAkYdkjQH w17C0yqiw+D26zkuru5F/AdiEvh5knM6/4XjR8pgQWEXIrdzyzE3OmFcEngADrLvEdAz ZfDC6JvfbWBxfKGxVxe/U4jq89hhyIjLB0zK29tYdhUbSMkrmTHLaueMJ+lJAwQS/lxq htwFoxRrTH95tkULq8Fw7558Sgnp2VtuelHDc9ulG5K16ee4TERrnjFMU2+IQ5YVVma8 CIHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=t9W1z9Ex; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f2-v6si26342021pfb.246.2018.11.14.09.50.22; Wed, 14 Nov 2018 09:50:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=t9W1z9Ex; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732965AbeKODx6 (ORCPT + 99 others); Wed, 14 Nov 2018 22:53:58 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:50452 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbeKODx5 (ORCPT ); Wed, 14 Nov 2018 22:53:57 -0500 Received: from trochilidae.toradex.int (unknown [46.140.72.82]) by mail.kmu-office.ch (Postfix) with ESMTPSA id B3CB95C1776; Wed, 14 Nov 2018 18:49:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1542217785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WLKkszEWOPlBFuW2wcbYnhdMhnLa9QG3D33fjz0lQpw=; b=t9W1z9ExdUtXJDW+Vbuqb0sh4I7pt349j5coJFsS554VrAMeGjsSDUcwZfLik4ZTb+kHG1 58TFaCePKL/rxz5PKweGtjS0Q+jREUFwiNz0i2p6+GQ6nTNl8+gwnebXnTeYojv5hIgfrP piB4Y5rlQEgTSDNrHfTlaojPrLVNUk0= From: Stefan Agner To: gregkh@linuxfoundation.org, jslaby@suse.com Cc: fabio.estevam@nxp.com, u.kleine-koenig@pengutronix.de, s.hauer@pengutronix.de, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [PATCH 2/3] serial: imx: unprepare console clocks on remove Date: Wed, 14 Nov 2018 18:49:39 +0100 Message-Id: <20181114174940.7865-2-stefan@agner.ch> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181114174940.7865-1-stefan@agner.ch> References: <20181114174940.7865-1-stefan@agner.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently imx_uart_console_setup() prepares clocks which do not get unprepared anywhere. Check whether the console has been used by testing if index is set and unprepare clocks in this case. This makes sure that clocks are properly unprepared after the console device has been unbound. Signed-off-by: Stefan Agner --- drivers/tty/serial/imx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 313c3b1900a8..757c91e5105a 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2085,7 +2085,7 @@ static struct console imx_uart_console = { .data = &imx_uart_uart_driver, }; -#define IMX_CONSOLE &imx_uart_console +#define IMX_CONSOLE (&imx_uart_console) #ifdef CONFIG_OF static void imx_uart_console_early_putchar(struct uart_port *port, int ch) @@ -2378,8 +2378,17 @@ static int imx_uart_probe(struct platform_device *pdev) static int imx_uart_remove(struct platform_device *pdev) { struct imx_port *sport = platform_get_drvdata(pdev); + int ret; + + ret = uart_remove_one_port(&imx_uart_uart_driver, &sport->port); + + if (IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE) && IMX_CONSOLE->index >= 0) { + clk_unprepare(sport->clk_ipg); + clk_unprepare(sport->clk_per); + IMX_CONSOLE->index = -1; + } - return uart_remove_one_port(&imx_uart_uart_driver, &sport->port); + return ret; } static void imx_uart_restore_context(struct imx_port *sport) -- 2.19.1