mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox <barebox@lists.infradead.org>
Subject: Re: problem in serial_ns16550.c
Date: Wed, 3 Aug 2011 18:35:14 +0200	[thread overview]
Message-ID: <20110803163514.GD24730@game.jcrosoft.org> (raw)
In-Reply-To: <CAA4bVAGcGr9Xv1RTMBbzYDxhcq+xrUeZCCvDJMDZ04cjVsPhZw@mail.gmail.com>

On 19:35 Wed 03 Aug     , Antony Pavlov wrote:
> Hi!
> 
> IMHO there is a problem in ns16550_probe() (see
> drivers/serial/serial_ns16550.c:243).
> 
> There is the construction:
> ------
> if (!(dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK) &&
>             ((plat->reg_read == NULL) || (plat->reg_write == NULL)))
>                 return -EINVAL;
> ------
> 
> Imagine creation of typical serial port:
> ------
> static struct NS16550_plat plat = {
>         .clock = 1843200,
> };
> 
> ...
> 
> add_ns16550_device(-1, UART_ADDR, 8, IORESOURCE_MEM_8BIT, &plat);
> ------
> 
> Here we have plat.reg_read == NULL, plat.reg_write == NULL.
> Usage of add_ns16550_device will make
> dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK == IORESOURCE_MEM_8BIT.
> 
> But take into account this (see include/linux/ioport.h):
> ------
> #define IORESOURCE_MEM_TYPE_MASK        (3<<3)
> #define IORESOURCE_MEM_8BIT             (0<<3)
> ------
> 
> So IORESOURCE_MEM_8BIT == 0 (sic!)
> 
> A son tour, !(dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK) give
> true, if flags select IORESOURCE_MEM_8BIT.
> 
> As a result, if add_ns16550_device() take IORESOURCE_MEM_8BIT, and
> plat->reg_read == NULL, plat->reg_write == NULL then ns16550_probe()
> will return -EINVAL.
yeah we can drop the check simply

Best Regards,
J.

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

      parent reply	other threads:[~2011-08-03 16:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 15:35 Antony Pavlov
2011-08-03 15:52 ` Sascha Hauer
2011-08-03 16:38   ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-03 16:35 ` Jean-Christophe PLAGNIOL-VILLARD [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=20110803163514.GD24730@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --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