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: [RFC] ns16550: support for UART with broken FIFO
Date: Tue, 17 Jan 2012 23:40:43 +0400	[thread overview]
Message-ID: <CAA4bVAFLHb6idJ6yUa5ZNDYdBTKroAE4g2_u=YAZ7XB2MCLGrw@mail.gmail.com> (raw)
In-Reply-To: <20120117145302.GB25622@game.jcrosoft.org>

On 17 January 2012 18:53, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 17:27 Tue 17 Jan     , Antony Pavlov wrote:
>> On 17 January 2012 17:09, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> > On Tue, Jan 17, 2012 at 02:39:06PM +0400, Antony Pavlov wrote:
>> >> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
>> >> ---
>> >>  drivers/serial/serial_ns16550.c |   19 +++++++++++++++++--
>> >>  include/ns16550.h               |    2 ++
>> >>  2 files changed, 19 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
>> >> index 1217a5f..01de964 100644
>> >> --- a/drivers/serial/serial_ns16550.c
>> >> +++ b/drivers/serial/serial_ns16550.c
>> >> @@ -139,6 +139,8 @@ static unsigned int ns16550_calc_divisor(struct console_device *cdev,
>> >>  static void ns16550_serial_init_port(struct console_device *cdev)
>> >>  {
>> >>       unsigned int baud_divisor;
>> >> +     struct NS16550_plat *plat = (struct NS16550_plat *)
>> >> +         cdev->dev->platform_data;
>> >>
>> >>       /* Setup the serial port with the defaults first */
>> >>       baud_divisor = ns16550_calc_divisor(cdev, CONFIG_BAUDRATE);
>> >> @@ -153,7 +155,13 @@ static void ns16550_serial_init_port(struct console_device *cdev)
>> >>       ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
>> >>       ns16550_write(cdev, LCRVAL, lcr);
>> >>       ns16550_write(cdev, MCRVAL, mcr);
>> >> -     ns16550_write(cdev, FCRVAL, fcr);
>> >> +
>> >> +     if (plat->flags & NS16650_FLAG_DISABLE_FIFO) {
>> >> +             ns16550_write(cdev, FCRVAL & ~FCR_FIFO_EN, fcr);
>> >> +     } else {
>> >> +             ns16550_write(cdev, FCRVAL, fcr);
>> >> +     }
>> >
>> > unnecessary braces here..
>> >
>> >> +
>> >>  #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
>> >>       ns16550_write(cdev, 0x00,  mdr1);
>> >>  #endif
>> >> @@ -211,6 +219,8 @@ static int ns16550_tstc(struct console_device *cdev)
>> >>  static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
>> >>  {
>> >>       unsigned int baud_divisor = ns16550_calc_divisor(cdev, baud_rate);
>> >> +     struct NS16550_plat *plat = (struct NS16550_plat *)
>> >> +         cdev->dev->platform_data;
>> >>
>> >>       ns16550_write(cdev, 0x00, ier);
>> >>       ns16550_write(cdev, LCR_BKSE, lcr);
>> >> @@ -218,7 +228,12 @@ static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
>> >>       ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
>> >>       ns16550_write(cdev, LCRVAL, lcr);
>> >>       ns16550_write(cdev, MCRVAL, mcr);
>> >> -     ns16550_write(cdev, FCRVAL, fcr);
>> >> +     if (plat->flags & NS16650_FLAG_DISABLE_FIFO) {
>> >> +             ns16550_write(cdev, FCRVAL & ~FCR_FIFO_EN, fcr);
>> >> +     } else {
>> >> +             ns16550_write(cdev, FCRVAL, fcr);
>> >> +     }
>> >
>> > and here. Otherwise this looks ok.
>>
>> Ok, I shall remove the braces.
>>
>> Sascha!
>>
>> We have special OMAP code, e.g.:
>>
>> #ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
>>         ns16550_write(cdev, 0x07, mdr1);        /* Disable */
>> #endif
>>
>> I think, that we can change it to something like this:
>>
>>     if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
>>         ns16550_write(cdev, 0x07, mdr1);        /* Disable */
> I don't like to add dead code in the binary
> just use
>        if (IS_ENABLED(CONFIG_...)

You is right, but there is another point of view.

If you have defined CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
macro, then you will use OMAP extensions for __ALL__ ports, not only
for OMAP internal port. May be OMAP have no other ports, only internal
ports with extensions. But in any case it is bad design example: we
have very special code (OMAP EXTENSIONS) in universal driver
(ns16550), and this special code works without checking presents of
the extensions.

I don't like dead code too. So there are another solutions:

#ifdef CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS
        if (plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
            ns16550_write(cdev, 0x07, mdr1);        /* Disable */
#endif

or even
        if (IS_ENABLED(CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS) &&
         plat->flags & NS16650_FLAG_OMAP_EXTENSIONS)
            ns16550_write(cdev, 0x07, mdr1);        /* Disable */
-- 
Best regards,
  Antony Pavlov

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

  reply	other threads:[~2012-01-17 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-17 10:39 Antony Pavlov
2012-01-17 13:09 ` Sascha Hauer
2012-01-17 13:27   ` Antony Pavlov
2012-01-17 14:53     ` Jean-Christophe PLAGNIOL-VILLARD
2012-01-17 19:40       ` Antony Pavlov [this message]
2012-01-17 23:58         ` Jean-Christophe PLAGNIOL-VILLARD

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='CAA4bVAFLHb6idJ6yUa5ZNDYdBTKroAE4g2_u=YAZ7XB2MCLGrw@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