mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.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 11:30:21 +0400	[thread overview]
Message-ID: <CAA4bVAH6aq64kakhj6m1d=r_dzwp51u0-QWKjJ6Ect0XAa3c5w@mail.gmail.com> (raw)
In-Reply-To: <20110804004250.GH24730@game.jcrosoft.org>

On 4 August 2011 04:42, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 22:37 Wed 03 Aug     , Antony Pavlov wrote:
>> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
>> ---
>>  drivers/serial/serial_ns16550.c |   87 ++++++++++++++++++++++++---------------
>>  1 files changed, 54 insertions(+), 33 deletions(-)
>>

>> +     plat->reg_write(val, (unsigned long)dev->priv, off);
> no it must stay void __iomem*

plat->reg_write() get the second argument 'unsigned long base'.

Moreover, using 'void *' in arithmetic is a poor practice.

Fortunally for us, in GCC incrementing a void pointer adds one to the
value (sizeof(void) == 1).

Add '-pedantic' flag to gcc and compile current 'next' barebox.

You will see something like this:
In function ‘ns16550_read’:
drivers/serial/serial_ns16550.c:72: warning: pointer of type ‘void *’
used in arithmetic

>> +     if (plat->reg_read == NULL) {
>> +             int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
>> +
>> +             switch (width) {
>> +             default:
...
>> +             }
>> +     }
>> +
>> +     if (plat->reg_write == NULL) {
>> +             int width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> why do it twice?

You are right.
width calculation or even separate reg_write & reg_read handling  can
be combined.

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-08-04  7:30 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 [this message]
2011-08-04  7:19 ` Sascha Hauer
2011-08-04  7:38   ` Antony Pavlov
2011-08-04  7:51     ` Sascha Hauer

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='CAA4bVAH6aq64kakhj6m1d=r_dzwp51u0-QWKjJ6Ect0XAa3c5w@mail.gmail.com' \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.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