From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] serial_ns16550: move switch from ns16550_{read, write}() to ns16550_probe()
Date: Thu, 4 Aug 2011 09:51:24 +0200 [thread overview]
Message-ID: <20110804075124.GX31404@pengutronix.de> (raw)
In-Reply-To: <CAA4bVAE2z76oS5TcU+eUozouKCqR1kAAeQgQw0ZLZVLseJVo2g@mail.gmail.com>
On Thu, Aug 04, 2011 at 11:38:53AM +0400, Antony Pavlov wrote:
> On 4 August 2011 11:19, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> >>
> >> +#define NS16550_READ_WRITE_UART_FUNC(pfx, cmdr, cmdw, mask) \
> >> +static unsigned int ns16550_generic_##pfx##_read(unsigned long base, \
> >> + unsigned char reg_idx) \
> >> +{ \
> >> + return cmdr((char *)base + reg_idx); \
> >> +} \
> >> + \
> >> +static void ns16550_generic_##pfx##_write(unsigned int val, unsigned long base, \
> >> + unsigned char reg_idx) \
> >> +{ \
> >> + cmdw((mask val), (char *)base + reg_idx); \
> >> +}
> >> +
> >> +NS16550_READ_WRITE_UART_FUNC(8bit, readb, writeb, 0xff &)
> >> +NS16550_READ_WRITE_UART_FUNC(16bit, readw, writew, 0xffff &)
> >> +NS16550_READ_WRITE_UART_FUNC(32bit, readl, writel, )
> >
> > Please don't do such preprocessor tricks if not necessary. we can afford
> > the 8 additional lines for making this readable.
>
> approx. > 16 additional lines
Whatever.
>
> >> + if (plat->reg_read == NULL) {
> >> + int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> >> +
> >> + switch (width) {
> ...
> >> + }
> >> +
> >> + if (plat->reg_write == NULL) {
> >> + int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> >> +
> >> + switch (width) {
> ...
> >> + }
> >> + }
> >
> > Passing one of the register access function without the other shouldn't
> > be a valid usecase. Jean is right, there should be only one if().
>
> Agree.
>
> > Generally platform_data shouldn't be used after device probe and for
> > sure it shouldn't be modified. This may be the point where this driver
> > needs a private data struct.
>
> I like this point of view.
> We must add private data struct and copy plat->width, plat->reg_read etc there.
You won't need plat->width, only the correct the register accessors
depending on plat->width.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2011-08-04 7:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 18:37 Antony Pavlov
2011-08-03 18:37 ` [PATCH 2/2] serial_ns16550: use 'struct device_d *' instead of 'struct console_device *' Antony Pavlov
2011-08-04 0:37 ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-04 4:54 ` Antony Pavlov
2011-08-04 0:42 ` [PATCH 1/2] serial_ns16550: move switch from ns16550_{read, write}() to ns16550_probe() Jean-Christophe PLAGNIOL-VILLARD
2011-08-04 7:30 ` Antony Pavlov
2011-08-04 7:19 ` Sascha Hauer
2011-08-04 7:38 ` Antony Pavlov
2011-08-04 7:51 ` Sascha Hauer [this message]
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=20110804075124.GX31404@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
/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