linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Enrico Weigelt, metux IT consult" <lkml@metux.net>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"Enrico Weigelt, metux IT consult" <info@metux.net>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	andrew@aj.id.au, 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
Date: Mon, 29 Apr 2019 12:12:35 +0200	[thread overview]
Message-ID: <c75f4ca9-367c-25d5-2597-75f2dccf6e1c@metux.net> (raw)
In-Reply-To: <20190428153905.GR9224@smile.fi.intel.com>

On 28.04.19 17:39, Andy Shevchenko wrote:

Hi,

seems I've forgot to add "RFC:" in the subject - I'm not entirely happy
w/ that patch myself, just want to hear your oppinions.

>> -	port->port.iotype = UPIO_MEM;>> -	port->port.mapbase = pci_resource_start(pcidev, bar) + offset;>> +
uart_memres_set_start_len(&port->port,>> +				
pci_resource_start(pcidev, bar) + offset,>> +				
pci_resource_len(pcidev, bar));>> +> > I don't see how it's better.>
Moreover, the size argument seems wrong here.
hmm, I'm actually not sure yet, what the correct size really would be,
where the value actually comes from. Just assumed that it would be the
whole area that the BAR tells. But now I recognized that I'd need to
substract 'offset' here.

Rethinking it further, we'd probably could deduce the UPIO_* from the
struct resource, too.

>> +		uart_memres_set_start_len(>> +			&port,>> +			FRODO_BASE + FRODO_APCI_OFFSET(1), 0);> > Please,
avoid such splitting, first parameter is quite fit above line.

Ok. My intention was having both parameters starting at the same line,
but then the second line would get too long again. > ...and here, and
maybe in other places you split the assignments to the members> in two
part. Better to call your function before or after these blocks of>
assignments.
the reason what I've just replaced the exactly the assignments, trying
not to touch too much ;-)
I'll have a closer look on what can be moved w/o side effects.

>> -			uport->mapsize	= ZS_CHAN_IO_SIZE;
>> -			uport->mapbase	= dec_kn_slot_base +
>> -					  zs_parms.scc[chip] +
>> -					  (side ^ ZS_CHAN_B) * ZS_CHAN_IO_SIZE;
>> +
>> +			uart_memres_set_start_len(dec_kn_slot_base +
>> +						    zs_parms.scc[chip] +
>> +						    (side ^ ZS_CHAN_B) *
>> +							ZS_CHAN_IO_SIZE,
>> +						  ZS_CHAN_IO_SIZE);
> 
> This looks hard to read. Think of temporary variables and better formatting
> style.

Ok.

> 
>>  /*
>> + * set physical io range from struct resource
>> + * if resource is NULL, clear the fields
>> + * also set the iotype to UPIO_MEM
> 
> Something wrong with punctuation and style. Please, use proper casing and
> sentences split.

Ok. fixed it.


>> +static inline void uart_memres_set_res(struct uart_port *port,
> 
> Perhaps better name can be found.
> Especially taking into account that it handles IO / MMIO here.

hmm, lacking creativity here ;-)
any suggestions ?

> 
>> +				       struct resource *res)
>> +{
>> +	if (!res) {
> 
> It should return an error in such case.

It's not an error, but desired behaviour: NULL resource
clears the value.

>> +		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;
> 
> Only one type? Why type is even set here?

It's the default case. The special cases (eg. UPIO_MEM32) need to be
set explicitly, after that call.

Not really nice, but haven't found a better solution yet. I don't like
the idea of passing an UPIO_* parameter to the function, most callers
should not care, if they don't really need to.


>> + */
> 
>> +static inline void uart_memres_set_start_len(struct uart_driver *uart,
>> +					     resource_size_t start,
>> +					     resource_size_t len)
> 
> The comment doesn't tell why this is needed when we have one for struct
> resource.

Renamed it to uart_memres_set_mmio_range().

This helper is meant for drivers that don't work w/ struct resource,
or explicitly set their own len.



Thanks for your review.

--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

  reply	other threads:[~2019-04-29 10:13 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27 12:51 serial drivers polishing Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 01/41] drivers: tty: serial: dz: use dev_err() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 13:29   ` Greg KH
2019-04-29 14:11     ` Enrico Weigelt, metux IT consult
2019-04-29 14:23       ` Greg KH
2019-04-27 13:31   ` Greg KH
2019-04-29  7:23     ` Enrico Weigelt, metux IT consult
2019-04-29 12:37     ` Enrico Weigelt, metux IT consult
2019-04-29 13:12       ` Greg KH
2019-05-01  2:20         ` Maciej W. Rozycki
2019-04-27 12:51 ` [PATCH 02/41] drivers: tty: serial: dz: include <linux/io.h> instead of <asm/io.h> Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 03/41] drivers: tty: serial: dz: fix missing parentheses Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 04/41] drivers: tty: serial: dz: fix use fix bare 'unsigned' Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 05/41] drivers: tty: serial: dz: use pr_info() instead of incomplete printk() Enrico Weigelt, metux IT consult
2019-04-27 13:30   ` Greg KH
2019-04-27 12:51 ` [PATCH 06/41] drivers: tty: serial: sb1250-duart: use dev_err() instead of printk() Enrico Weigelt, metux IT consult
2019-05-01  2:29   ` Maciej W. Rozycki
2019-04-27 12:51 ` [PATCH 07/41] drivers: tty: serial: sb1250-duart: include <linux/io.h> instead of <asm/io.h> Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 08/41] drivers: tty: serial: sb1250-duart: fix checkpatch warning on printk() Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 09/41] drivers: tty: serial: sb1250-duart: fill mapsize and use it Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 10/41] drivers: tty: serial: sb1250-duart: fix missing parentheses Enrico Weigelt, metux IT consult
2019-04-27 13:32   ` Greg KH
2019-04-27 12:51 ` [PATCH 11/41] drivers: tty: serial: sb1250-duart: fix formatting error Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 12/41] drivers: tty: serial: uartlite: use dev_dbg() instead of pr_debug() Enrico Weigelt, metux IT consult
2019-04-29 15:26   ` Peter Korsgaard
2019-04-27 12:51 ` [PATCH 13/41] drivers: tty: serial: uartlite: fill mapsize and use it Enrico Weigelt, metux IT consult
2019-04-29 15:19   ` Peter Korsgaard
2019-04-29 18:26     ` Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 14/41] drivers: tty: serial: uartlite: remove unnecessary braces Enrico Weigelt, metux IT consult
2019-04-29 15:20   ` Peter Korsgaard
2019-04-27 12:51 ` [PATCH 15/41] drivers: tty: serial: uartlite: fix use fix bare 'unsigned' Enrico Weigelt, metux IT consult
2019-04-29 15:21   ` Peter Korsgaard
2019-04-27 12:51 ` [PATCH 16/41] drivers: tty: serial: uartlite: fix overlong lines Enrico Weigelt, metux IT consult
2019-04-29 15:24   ` Peter Korsgaard
2019-04-27 12:51 ` [PATCH 17/41] drivers: tty: serial: apbuart: fix logging calls Enrico Weigelt, metux IT consult
2019-04-27 12:51 ` [PATCH 18/41] drivers: tty: serial: apbuart: use dev_info() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 19/41] drivers: tty: serial: apbuart: fix code formatting Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 20/41] drivers: tty: serial: cpm_uart: use dev_err()/dev_warn() instead of printk() Enrico Weigelt, metux IT consult
2019-04-29 16:02   ` Christophe Leroy
2019-04-27 12:52 ` [PATCH 21/41] drivers: tty: serial: cpm_uart: fix includes Enrico Weigelt, metux IT consult
2019-04-29 16:02   ` Christophe Leroy
2019-04-27 12:52 ` [PATCH 22/41] drivers: tty: serial: cpm_uart: fix logging calls Enrico Weigelt, metux IT consult
2019-04-29 15:59   ` Christophe Leroy
2019-04-29 16:20     ` Enrico Weigelt, metux IT consult
2019-04-30 14:10     ` Andy Shevchenko
2019-04-27 12:52 ` [PATCH 23/41] drivers: tty: serial: cpm_uart: fix styling issues Enrico Weigelt, metux IT consult
2019-04-29 15:56   ` Christophe Leroy
2019-04-27 12:52 ` [PATCH 24/41] drivers: tty: serial: timbuart: use dev_err() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 25/41] drivers: tty: serial: timbuart: fix formatting issues Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 26/41] drivers: tty: serial: sunzilog: use dev_info() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 27/41] drivers: tty: serial: sunzilog: fix formatting issues Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 28/41] drivers: tty: serial: sunzilog: fix includes Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 29/41] drivers: tty: serial: sunzilog: cleanup logging Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 30/41] drivers: tty: serial: ioc4_serial: use dev_warn() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 31/41] drivers: tty: serial: ioc4_serial: use pr_*() " Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 32/41] drivers: tty: serial: 21285: define's for address/size, use mapsize field Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 33/41] drivers: tty: serial: zs: use dev_err() instead of printk() Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 34/41] drivers: tty: serial: zs: fill mapsize and use it Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 35/41] drivers: tty: serial: 8250: add mapsize to platform data Enrico Weigelt, metux IT consult
2019-04-29  7:06   ` Esben Haabendal
2019-04-27 12:52 ` [PATCH 36/41] drivers: tty: serial: 8250: store mmio resource size in port struct Enrico Weigelt, metux IT consult
2019-04-28 15:18   ` Andy Shevchenko
2019-04-29 14:55     ` Enrico Weigelt, metux IT consult
2019-04-29 15:39       ` Andy Shevchenko
2019-04-27 12:52 ` [PATCH 37/41] drivers: tty: serial: 8250: simplify io resource size computation Enrico Weigelt, metux IT consult
2019-04-27 13:03   ` John Paul Adrian Glaubitz
2019-04-29 15:58     ` Enrico Weigelt, metux IT consult
2019-04-28 15:21   ` Andy Shevchenko
2019-04-29  6:48     ` Enrico Weigelt, metux IT consult
2019-04-29 13:19       ` Andy Shevchenko
2019-04-27 12:52 ` [PATCH 38/41] drivers: tty: serial: xilinx_uartps: fill mapsize and use it Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 39/41] drivers: tty: serial: pmac_zilog: " Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 40/41] drivers: tty: serial: helper for setting mmio range Enrico Weigelt, metux IT consult
2019-04-28 15:39   ` Andy Shevchenko
2019-04-29 10:12     ` Enrico Weigelt, metux IT consult [this message]
2019-04-29 13:28       ` Andy Shevchenko
2019-04-29  6:57   ` Esben Haabendal
2019-04-29  7:03   ` Esben Haabendal
2019-04-29  9:43     ` Enrico Weigelt, metux IT consult
2019-04-27 12:52 ` [PATCH 41/41] drivers: tty: serial: lpc32xx_hs: fill mapsize and use it Enrico Weigelt, metux IT consult
2019-04-30 20:52   ` Vladimir Zapolskiy
2019-04-29 16:16 ` serial drivers polishing Christophe Leroy
2019-04-29 16:50   ` Enrico Weigelt, metux IT consult

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c75f4ca9-367c-25d5-2597-75f2dccf6e1c@metux.net \
    --to=lkml@metux.net \
    --cc=andrew@aj.id.au \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@metux.net \
    --cc=jacmet@sunsite.dk \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@prisktech.co.nz \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=macro@linux-mips.org \
    --cc=matthias.bgg@gmail.com \
    --cc=slemieux.tyco@gmail.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=vz@mleia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).