From: "Jan Beulich" Subject: Re: [PATCH RFC 3/8] ns16550: make usable on ARM Date: Tue, 10 Sep 2013 16:00:50 +0100 Message-ID: <522F504202000078000F2061@nat28.tlf.novell.com> References: <1378822681.10928.8.camel@kazak.uk.xensource.com> <1378822705-19310-3-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VJPR1-0001F5-DB for xen-devel@lists.xenproject.org; Tue, 10 Sep 2013 15:00:55 +0000 In-Reply-To: <1378822705-19310-3-git-send-email-ian.campbell@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: keir@xen.org, stefano.stabellini@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, Josh Zhao , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 10.09.13 at 16:18, Ian Campbell wrote: > @@ -40,15 +45,22 @@ string_param("com2", opt_com2); > > static struct ns16550 { > int baud, clock_hz, data_bits, parity, stop_bits, fifo_size, irq; > - unsigned long io_base; /* I/O port or memory-mapped I/O address. */ > + u64 io_base; /* I/O port or memory-mapped I/O address. */ > + u64 io_size; Does the size really need to be 64 bits? > static char ns_read_reg(struct ns16550 *uart, int reg) > { > + void __iomem *addr = uart->remapped_io_base + (reg<reg_shift); Blanks around <<. > +#ifdef HAS_IOPORTS > if ( uart->remapped_io_base == NULL ) > return inb(uart->io_base + reg); > - return readb(uart->remapped_io_base + reg); > +#endif > + switch (uart->reg_width) { Coding style. > + default: /* assume single byte */ Is that really a good idea? I'd recommend returning all 1s here, and dropping writes below. > + case 1: > + return readb(addr); > + case 4: > + return readl(addr); This won't work without changing the return type of the function. Or is this just mandating the access width, without the upper 24 bits carrying meaningful data? > + } > static void ns_write_reg(struct ns16550 *uart, int reg, char c) Same/similar comments go for this function. > +#ifdef HAS_PCI > static void pci_serial_early_init(struct ns16550 *uart) > { > if ( !uart->ps_bdf_enable || uart->io_base >= 0x10000 ) > @@ -178,6 +215,9 @@ static void pci_serial_early_init(struct ns16550 *uart) > pci_conf_write16(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2], > PCI_COMMAND, PCI_COMMAND_IO); > } > +#else > +static void pci_serial_early_init(struct ns16550 *uart) {} > +#endif I'd prefer if #ifdef-s of this kind went inside the function body, thus avoiding the duplication of the function "header". This particularly reduces the churn on eventual future changes to the function type (in particular people not building all architectures not noticing the need to change more than one place). > @@ -278,21 +320,27 @@ static void __init ns16550_init_postirq(struct serial_port *port) > bits = uart->data_bits + uart->stop_bits + !!uart->parity; > uart->timeout_ms = max_t( > unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud); > - > if ( uart->irq > 0 ) Anything wrong with the blank line above? > +static const char const *ns16550_dt_compat[] __initdata = That ought to be __initconst now that committed that patch. Jan