Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3340875yba; Sun, 28 Apr 2019 23:59:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMtAfXuqhqu3sQL7epgV7bGB2CzGjOeuGgTxxZfrJ2pfvtkvHaWDDSwJd2drNFln8KrJ1B X-Received: by 2002:a63:5149:: with SMTP id r9mr41806518pgl.177.1556521150870; Sun, 28 Apr 2019 23:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556521150; cv=none; d=google.com; s=arc-20160816; b=x4poJ6T2GDG1HdSn4yq6R1HUFr6tk8yAWnK5voQszf3OtSQ0fUioP9PegLzc0dOsxd Viw3tJdxbiL5x13/szfT85mVQga6uNfLbTNkqkUEehB6Qs0a7deC41fKgztST3BLaGmk ADDQ7GOUZ7KIQL0/6BuXjNczlSE0ER8bV1JKaF3Tv9J2VnQValCatBkaaZ5e5xvsdXnw v/yZY8MzfFkNykcHVN3QbkykNQNQ+ak3kBUlaedRrqtVofIe7drPGcCs3cbFwd6a1mcx wSN1JJhjIHoyUnIsublhSWJsGRXiZAmd5/6M/eaNeLj4BfZl9qmYn/WY33w2zk/YyJRb xhTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=6XgGXBZd9XuP2oE4RYwYzog341NRJDxtjWMZBSjiAvQ=; b=VNK97FnhHB5pmHdY11vKkgr7/PbDbko1q+GOgfM8NUtW+cJOlyb09NMB6sRqayVwfT qe4rjedkbB5+UewNIeWiek77NJ/wJ5Ei2ivkcNsutv36vzKRNtdTghHtnyTQJvi6Ol1a 1pUXTzW2Z4N/5zG9EeErRhZCnSJZsWCqeGLFdPr/1m+GweRu9BTrsNo/2plXQ9Nmc8vR uyanidvjH9RacvaAgsXnPqXLeu1cpG5THmCjLKCN16GnW+eBgMfEqDtKWEQEyvqDhmP2 A1YPsOOchkex+/NJ1XslTEPlRaUWK2Ny2wtnpBUJC3x9dkwb62dx3M06rCzeikvbORtV qAQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@haabendal.dk header.s=20140924 header.b=lBNJsg0T; 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 cp9si20381plb.67.2019.04.28.23.58.55; Sun, 28 Apr 2019 23:59:10 -0700 (PDT) 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=@haabendal.dk header.s=20140924 header.b=lBNJsg0T; 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 S1727366AbfD2G5s (ORCPT + 99 others); Mon, 29 Apr 2019 02:57:48 -0400 Received: from mailrelay4-1.pub.mailoutpod1-cph3.one.com ([46.30.210.185]:24048 "EHLO mailrelay4-1.pub.mailoutpod1-cph3.one.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbfD2G5s (ORCPT ); Mon, 29 Apr 2019 02:57:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=haabendal.dk; s=20140924; h=content-type:mime-version:message-id:in-reply-to:date:references:subject:cc: to:from:from; bh=6XgGXBZd9XuP2oE4RYwYzog341NRJDxtjWMZBSjiAvQ=; b=lBNJsg0TqOZCs9zsmi7OlOlz1wKeTb8FI0J/+yKQeypPoT337WSvpPYP2/pyW3ht3JjaSTybk0hbz c0LpDVQOhmRpZB7EFxCcruxLFgSmAMtfq2RxssZSD9SC3JZbOA2dkqsbdOav7qrmogx3ryl8zofC4J 4WA76c54x5vGgSFE= X-HalOne-Cookie: ee6e547916cc579600553f0a2d7cd6ab5b054162 X-HalOne-ID: 164fce27-6a4c-11e9-a5a1-d0431ea8bb10 Received: from localhost (unknown [193.163.1.7]) by mailrelay4.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id 164fce27-6a4c-11e9-a5a1-d0431ea8bb10; Mon, 29 Apr 2019 06:57:43 +0000 (UTC) From: Esben Haabendal To: "Enrico Weigelt\, metux IT consult" Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, andrew@aj.id.au, andriy.shevchenko@linux.intel.com, macro@linux-mips.org, vz@mleia.com, slemieux.tyco@gmail.com, khilman@baylibre.com, liviu.dudau@arm.com, sudeep.holla@arm.com, lorenzo.pieralisi@arm.com, davem@davemloft.net, jacmet@sunsite.dk, linux@prisktech.co.nz, matthias.bgg@gmail.com, linux-mips@vger.kernel.org, linux-serial@vger.kernel.org, linux-ia64@vger.kernel.org, linux-amlogic@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org Subject: Re: [PATCH 40/41] drivers: tty: serial: helper for setting mmio range References: <1556369542-13247-1-git-send-email-info@metux.net> <1556369542-13247-41-git-send-email-info@metux.net> Date: Mon, 29 Apr 2019 08:57:43 +0200 In-Reply-To: <1556369542-13247-41-git-send-email-info@metux.net> (Enrico Weigelt's message of "Sat, 27 Apr 2019 14:52:21 +0200") Message-ID: <87muk9z4bc.fsf@haabendal.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Enrico Weigelt, metux IT consult" writes: > @@ -131,7 +133,8 @@ int __init hp300_setup_serial_console(void) > pr_info("Serial console is HP DCA at select code %d\n", scode); > > port.uartclk = HPDCA_BAUD_BASE * 16; > - port.mapbase = (pa + UART_OFFSET); > + > + uart_memres_set_start_len(&port, (pa + UART_OFFSET)); Missing length argument here. > port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE); > port.regshift = 1; > port.irq = DIO_IPL(pa + DIO_VIRADDRBASE); > diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c > index cf8ca66..895c90c 100644 > --- a/drivers/tty/serial/xilinx_uartps.c > +++ b/drivers/tty/serial/xilinx_uartps.c > @@ -1626,8 +1626,7 @@ static int cdns_uart_probe(struct platform_device *pdev) > * This function also registers this device with the tty layer > * and triggers invocation of the config_port() entry point. > */ > - port->mapbase = res->start; > - port->mapsize = CDNS_UART_REGISTER_SPACE; > + uart_memres_set_start_len(res->start, CDNS_UART_REGISTER_SPACE); Missing 1st (port) argument here. > port->irq = irq; > port->dev = &pdev->dev; > port->uartclk = clk_get_rate(cdns_uart_data->uartclk); > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h > index 5fe2b03..d891c8d 100644 > --- a/include/linux/serial_core.h > +++ b/include/linux/serial_core.h > @@ -427,6 +427,46 @@ void uart_console_write(struct uart_port *port, const char *s, > int uart_match_port(struct uart_port *port1, struct uart_port *port2); > > /* > + * set physical io range from struct resource > + * if resource is NULL, clear the fields > + * also set the iotype to UPIO_MEM > + */ > +static inline void uart_memres_set_res(struct uart_port *port, > + struct resource *res) > +{ > + if (!res) { > + port->mapsize = 0; > + port->mapbase = 0; > + port->iobase = 0; > + return; > + } > + > + if (resource_type(res) == IORESOURCE_IO) { > + port->iotype = UPIO_PORT; > + port->iobase = resource->start; > + return; > + } > + > + uart->mapbase = res->start; > + uart->mapsize = resource_size(res); > + uart->iotype = UPIO_MEM; Hardcoding UPIO_MEM like does not work for drivers using other kind of memory access, like UPIO_MEM16, UPIO_MEM32 and UPIO_MEM32BE. Why not leave the control of iotype to drivers as before this patch? > +} > + > +/* > + * set physical io range by start address and length > + * if resource is NULL, clear the fields > + * also set the iotype to UPIO_MEM > + */ > +static inline void uart_memres_set_start_len(struct uart_driver *uart, > + resource_size_t start, > + resource_size_t len) > +{ > + uart->mapbase = start; > + uart->mapsize = len; > + uart->iotype = UPIO_MEM; Same here, other iotype values must be possible. > +} > + > +/* > * Power Management > */ > int uart_suspend_port(struct uart_driver *reg, struct uart_port *port); /Esben