Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4918617pxb; Wed, 19 Jan 2022 07:31:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTo8Ys/GXFuo6JMNnamuKgHMsVtYbimHYDGh6W3EJFNayAkAAL08DV1IjRvqdcRCA1t1yr X-Received: by 2002:a63:8f18:: with SMTP id n24mr27409529pgd.132.1642606310490; Wed, 19 Jan 2022 07:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642606310; cv=none; d=google.com; s=arc-20160816; b=LnPN3gGHDwUHQeHROWGE3bysvI0+2HooYMoNUgbClmVkrnIh8tTcOlD3GzPmbGLavw LkMideXVSykmrVGLh8iBIRE6XX0R3lGaNoItefPv2qCQ2JcLZa/EiRbDk+S86JUllSYo XB4SYQUz/5PGCESDxqOfcO60irQSEfnoXRdiGW+ka+w+DXd8yCPdGrpl0T1iHMvLLuP2 YOW5b7JexJV7X5po6RLEIRgj+sx5tsLYRPFrN+iYaDle+JZOyK20nt+jVDSIOnsuToIs Bg0rDefzoSMuOiXHvSCJGml1oUSpikCCHiQgrVXbsIsDSzbb3LBsPU3MwEQ1jDgFhyCj YuIw== 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; bh=B2zRbBNj508s+laMlo0uICkEn4ONDhAhi8cUi0r/t68=; b=ey4ciODxStb9INa7bpwFtAJDT4jyiMEGIs8NXq2+h8EAgi/6RIsFoLTzMknnz07gjV hFlyHChhegIZHMx66EKHyfWIDcCwdk1jF5ilBoniA7jc0Dkues+7hw3Yfi9Ca+NIEF81 aN4qq8dnc6MLrZAedDWpxURw5hTOjBtZBsAr0qyXbLy8DB0z55myfJ3OW3CUCJmTodo0 pDkMLD4G3dLlUhHLa5011LDQl2sfoN+J9sbPXMx3slOZB82yAGTD70gpYSTJ7YI+s8yR excx2NEEJkDwb3NFsZ9m0tWju84OEtNj7NhQNQO06DjO71GqVgwVY7/xcqwefwxULBqR fgOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c38si131573pgc.746.2022.01.19.07.31.38; Wed, 19 Jan 2022 07:31:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350463AbiARD0N (ORCPT + 99 others); Mon, 17 Jan 2022 22:26:13 -0500 Received: from mail-sh.amlogic.com ([58.32.228.43]:17120 "EHLO mail-sh.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354895AbiARDKb (ORCPT ); Mon, 17 Jan 2022 22:10:31 -0500 Received: from droid06.amlogic.com (10.18.11.248) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server id 15.1.2176.14; Tue, 18 Jan 2022 11:09:54 +0800 From: Yu Tu To: , , , CC: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Yu Tu Subject: [PATCH V6 1/5] tty: serial: meson: Move request the register region to probe Date: Tue, 18 Jan 2022 11:09:07 +0800 Message-ID: <20220118030911.12815-2-yu.tu@amlogic.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220118030911.12815-1-yu.tu@amlogic.com> References: <20220118030911.12815-1-yu.tu@amlogic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.18.11.248] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This simplifies resetting the UART controller during probe and will make it easier to integrate the common clock code which will require the registers at probe time as well. Signed-off-by: Yu Tu --- drivers/tty/serial/meson_uart.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 45e00d928253..6b80e41b4cc1 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -395,24 +395,11 @@ static int meson_uart_verify_port(struct uart_port *port, static void meson_uart_release_port(struct uart_port *port) { - devm_iounmap(port->dev, port->membase); - port->membase = NULL; - devm_release_mem_region(port->dev, port->mapbase, port->mapsize); + /* nothing to do */ } static int meson_uart_request_port(struct uart_port *port) { - if (!devm_request_mem_region(port->dev, port->mapbase, port->mapsize, - dev_name(port->dev))) { - dev_err(port->dev, "Memory region busy\n"); - return -EBUSY; - } - - port->membase = devm_ioremap(port->dev, port->mapbase, - port->mapsize); - if (!port->membase) - return -ENOMEM; - return 0; } @@ -733,6 +720,18 @@ static int meson_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + if (!devm_request_mem_region(&pdev->dev, res_mem->start, + resource_size(res_mem), + dev_name(&pdev->dev))) { + dev_err(&pdev->dev, "Memory region busy\n"); + return -EBUSY; + } + + port->membase = devm_ioremap(&pdev->dev, res_mem->start, + resource_size(res_mem)); + if (IS_ERR(port->membase)) + return PTR_ERR(port->membase); + ret = meson_uart_probe_clocks(pdev, port); if (ret) return ret; @@ -754,10 +753,7 @@ static int meson_uart_probe(struct platform_device *pdev) platform_set_drvdata(pdev, port); /* reset port before registering (and possibly registering console) */ - if (meson_uart_request_port(port) >= 0) { - meson_uart_reset(port); - meson_uart_release_port(port); - } + meson_uart_reset(port); ret = uart_add_one_port(&meson_uart_driver, port); if (ret) -- 2.33.1