From patchwork Wed Jun 6 12:41:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10450203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C007360467 for ; Wed, 6 Jun 2018 12:58:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA8CE1FEB1 for ; Wed, 6 Jun 2018 12:58:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C5421FF40; Wed, 6 Jun 2018 12:58:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2204F1FEB1 for ; Wed, 6 Jun 2018 12:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NT9rOxcX0OJ6lOkXrJCMdB9ctqwW6qCCLrDw+tlLhr4=; b=o67GB98vyLw2q3X/jNw+obw5J2 LNSuDvTkShV5OVydf77/5V3DnSThRfXpe3lvtKGntyQ34t6cfQF7ezjEXF8IcIqr2sd1oL7yA7W1C CyhQ2ff3S3097/xlc8GdaG5bt6DA8d4VZ5P9yZ+6zdj8h0b+MGZwtTaITtFwh1NiO9vykPWGkrBWm MvFIUdpGiDLOxv4ODnyNwNUmzXGhWhkWsxSAxHsuXbGATqgKvTrs3nDRL7qAGigrijQ4ibxBs9X0j GHH1kxbEJqeCsVDcrKiUVeWeRzzp+erQgleSz/TObtz0HrCGfyhIbUQO2kHrOYhX8ZmOlqtxgqtic /8TGXAyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQY0j-0001R3-PH; Wed, 06 Jun 2018 12:57:57 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQXlH-0000it-Ch for linux-arm-kernel@lists.infradead.org; Wed, 06 Jun 2018 12:42:03 +0000 Received: by mail-wr0-x244.google.com with SMTP id 94-v6so6134536wrf.5 for ; Wed, 06 Jun 2018 05:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+zJMkuOVXqIevxfZO5CxmDMg7jswzGR2ZGdy+QkYBmQ=; b=mhxOyC8zFXvGEgBoHMAIi419N88r1gfF8DuS6FPMW/Ij5hC/Uon0de2bqNuUE1pAHg MqM4+jA2X6dA9sGjOhtt+DRjThWIr3x7RrJ0QWWpy0I4oBR6ksZZYZS3nFtvyTK7SjXI 14lTrZmzKHbYEBsia2h/w1kZN2OmxfIsqdh2gNRX481sQKOKQ0hthQIXF2W5Nlz3tEIq 2bH6JkWOZiTOkmhvq/yYtkfQhzYJYLf6BUtUqlg9pPIGMlvzKrTXUIx6Z9emacGhmREO 3aIpiQHN3OuPzbXqOhWxSahKXkXgnO1oYTbyddmS4CPKQe6Av6xfSRzFFTRAzI9y2pRn /kdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=+zJMkuOVXqIevxfZO5CxmDMg7jswzGR2ZGdy+QkYBmQ=; b=jFnvClpgfAmlOJVEBs4kLlc02Dthcn6P9sn4p1P6uTrr62UXckE6Poioxq0XMLMZYE +1tC6SeL3mV4AY02jWi076PeqtG62ebxwPq2RZ4Kgai8PycuLIRMuv97e511ExbK9UqL NVCb0X6WWmTshNaoBS8O6l3Tx5kox3QDlTrRcYma+tPELp3mE19EeQHOPzyHOjUotZJj ZT0wctZWwkqEx8Z134LDQ9jddPzGqM22xRRplhIKVJLTOB/x2pKZJLXZfv7ufOvREtk2 bM5Kcdn8QqLO/ffRa0d3i2bRH2vAxB/A7lMGAlroIxfe+u6+N1zNwOjeqdERGaYDDBz0 0bSA== X-Gm-Message-State: APt69E2r7ILyGrKXQgD/fyuF7iWyQDeBrhlxjek1OjH3C8WVZjWDEGQq tTg4GkefgzHpX+lOiXMbu1bXcQ== X-Google-Smtp-Source: ADUXVKJc/g6K/xgcCKjkfZNZeo4Wzs7AZ6Y1VpEzGzOYGcBfgij3SqDXvki9vA875+sxDnYdeKKIPQ== X-Received: by 2002:adf:dfc2:: with SMTP id q2-v6mr2204673wrn.113.1528288907850; Wed, 06 Jun 2018 05:41:47 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id f81-v6sm5144241wmh.32.2018.06.06.05.41.47 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 06 Jun 2018 05:41:47 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [RFC PATCH v2 3/6] serial: uartps: Do not use static struct uart_driver out of probe() Date: Wed, 6 Jun 2018 14:41:36 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180606_054159_447273_4C68F7E0 X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, Jiri Slaby MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP cdns_uart_suspend()/resume() and remove() are using static reference to struct uart_driver. Assign this referece to private data structure as preparation step for dynamic struct uart_driver allocation. Signed-off-by: Michal Simek --- Changes in v2: - new patch - it can be sent separately too drivers/tty/serial/xilinx_uartps.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e24382f58dea..fe96fd950d3a 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -179,6 +179,7 @@ * @port: Pointer to the UART port * @uartclk: Reference clock * @pclk: APB clock + * @cdns_uart_driver: Pointer to UART driver * @baud: Current baud rate * @clk_rate_change_nb: Notifier block for clock changes * @quirks: Flags for RXBS support. @@ -187,6 +188,7 @@ struct cdns_uart { struct uart_port *port; struct clk *uartclk; struct clk *pclk; + struct uart_driver *cdns_uart_driver; unsigned int baud; struct notifier_block clk_rate_change_nb; u32 quirks; @@ -1280,6 +1282,7 @@ static int __init cdns_uart_console_setup(struct console *co, char *options) static int cdns_uart_suspend(struct device *device) { struct uart_port *port = dev_get_drvdata(device); + struct cdns_uart *cdns_uart = port->private_data; struct tty_struct *tty; struct device *tty_dev; int may_wake = 0; @@ -1296,7 +1299,7 @@ static int cdns_uart_suspend(struct device *device) * Call the API provided in serial_core.c file which handles * the suspend. */ - uart_suspend_port(&cdns_uart_uart_driver, port); + uart_suspend_port(cdns_uart->cdns_uart_driver, port); if (!(console_suspend_enabled && !may_wake)) { unsigned long flags = 0; @@ -1324,6 +1327,7 @@ static int cdns_uart_suspend(struct device *device) static int cdns_uart_resume(struct device *device) { struct uart_port *port = dev_get_drvdata(device); + struct cdns_uart *cdns_uart = port->private_data; unsigned long flags = 0; u32 ctrl_reg; struct tty_struct *tty; @@ -1339,8 +1343,6 @@ static int cdns_uart_resume(struct device *device) } if (console_suspend_enabled && !may_wake) { - struct cdns_uart *cdns_uart = port->private_data; - clk_enable(cdns_uart->pclk); clk_enable(cdns_uart->uartclk); @@ -1374,7 +1376,7 @@ static int cdns_uart_resume(struct device *device) spin_unlock_irqrestore(&port->lock, flags); } - return uart_resume_port(&cdns_uart_uart_driver, port); + return uart_resume_port(cdns_uart->cdns_uart_driver, port); } #endif /* ! CONFIG_PM_SLEEP */ static int __maybe_unused cdns_runtime_suspend(struct device *dev) @@ -1446,6 +1448,8 @@ static int cdns_uart_probe(struct platform_device *pdev) } } + cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver; + match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); if (match && match->data) { const struct cdns_platform_data *data = match->data; @@ -1603,7 +1607,7 @@ static int cdns_uart_remove(struct platform_device *pdev) clk_notifier_unregister(cdns_uart_data->uartclk, &cdns_uart_data->clk_rate_change_nb); #endif - rc = uart_remove_one_port(&cdns_uart_uart_driver, port); + rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port); port->mapbase = 0; clk_disable_unprepare(cdns_uart_data->uartclk); clk_disable_unprepare(cdns_uart_data->pclk);