The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Andrew Morton <akpm@osdl.org>
Cc: anemo@mba.ocn.ne.jp, linux-kernel@vger.kernel.org, ralf@linux-mips.org
Subject: Re: [PATCH] serial: serial_txx9 driver update
Date: Sun, 22 Jan 2006 23:02:09 +0000	[thread overview]
Message-ID: <20060122230209.GB5511@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20060122003307.738931b7.akpm@osdl.org>

On Sun, Jan 22, 2006 at 12:33:07AM -0800, Andrew Morton wrote:
> Russell King <rmk+lkml@arm.linux.org.uk> wrote:
> >
> > On Sat, Jan 21, 2006 at 11:36:49PM -0800, Andrew Morton wrote:
> > > Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > > >
> > > >  serial_txx9_verify_port(struct uart_port *port, struct serial_struct *ser)
> > > >   {
> > > >  -	if (ser->irq < 0 ||
> > > >  -	    ser->baud_base < 9600 || ser->type != PORT_TXX9)
> > > >  +	unsigned long new_port = (unsigned long)ser->port +
> > > >  +		((unsigned long)ser->port_high << ((sizeof(long) - sizeof(int)) * 8));
> > > 
> > > Are you sure about this part?  Shifting something left by sizeof(something)
> > > seems very strange.  It'll give different results on 64-bit machines for
> > > the same hardware.  Are you sure it wasn't supposed to be an addition?
> > 
> > There is a definition for that constant - it's called HIGH_BITS_OFFSET.
> 
> There are two definitions, actually.  drivers/serial/serial_core.c and
> drivers/serial/8250.h.
> 
> > No need to try to buggily recreate it.
> 
> Where's the bug in the proposed code?

There isn't, but because it's wider than 80 columns, it got mis-read.
As demonstrated, the 80 column rule _still_ matters for readability.

> Can you tell us what HIGH_BITS_OFFSET actually does?  Stuffing the port
> address into the upper 32-bits of a ulong on 64-bit machines.  Am consumed
> by curiosity.

It's history.  port in serial_struct has been declared as:

        unsigned int    port;

since the year dot, and has been exposed to userland since it's
inception. I guess that 64-bit machines came along, and this was
found to be inadequate.  Rather than deprecate the current interface
and provide a sane API, whoever did this came up with this yucky
solution where

        unsigned int    port_high;

contains the address bits outside the range of "port".  Presumably
they assumed that sizeof(unsigned long) == 2 * sizeof(unsigned int)
here. If not, this silly interface again breaks on us.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

  reply	other threads:[~2006-01-22 23:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-17 17:19 [PATCH] serial: serial_txx9 driver update Atsushi Nemoto
2006-01-22  7:36 ` Andrew Morton
2006-01-22  8:00   ` Russell King
2006-01-22  8:33     ` Andrew Morton
2006-01-22 23:02       ` Russell King [this message]
2006-01-23  6:05         ` Atsushi Nemoto
2006-01-23  9:57           ` Russell King
2006-01-23 13:39             ` Atsushi Nemoto
2006-01-23 13:42               ` Atsushi Nemoto
2006-01-23 19:49               ` Russell King
2006-01-24  2:24                 ` Atsushi Nemoto
  -- strict thread matches above, loose matches on Subject: below --
2006-12-21 17:01 Atsushi Nemoto

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=20060122230209.GB5511@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=akpm@osdl.org \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ralf@linux-mips.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