public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Jamie Iles <jamie@jamieiles.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] 8250: add a UPIO_DWAPB32 for 32 bit accesses (v2)
Date: Wed, 1 Dec 2010 11:27:28 -0800	[thread overview]
Message-ID: <20101201192728.GB31841@kroah.com> (raw)
In-Reply-To: <20101201171700.GF2898@pulham.picochip.com>

On Wed, Dec 01, 2010 at 05:17:00PM +0000, Jamie Iles wrote:
> On Wed, Dec 01, 2010 at 09:01:25AM -0800, Greg KH wrote:
> > On Wed, Dec 01, 2010 at 08:10:44AM +0000, Jamie Iles wrote:
> > > --- a/drivers/serial/8250.c
> > > +++ b/drivers/serial/8250.c
> > > @@ -454,21 +454,40 @@ static void tsi_serial_out(struct uart_port *p, int offset, int value)
> > >  		writeb(value, p->membase + offset);
> > >  }
> > >  
> > > +/* Save the LCR value so it can be re-written when a Busy Detect IRQ occurs. */
> > > +static inline void dwapb_save_out_value(struct uart_port *p, int offset,
> > > +					int value)
> > > +{
> > > +	struct uart_8250_port *up =
> > > +		container_of(p, struct uart_8250_port, port);
> > 
> > container_of, when the original code did a simple cast:
> > 
> > >  static void dwapb_serial_out(struct uart_port *p, int offset, int value)
> > >  {
> > >  	int save_offset = offset;
> > >  	offset = map_8250_out_reg(p, offset) << p->regshift;
> > > -	/* Save the LCR value so it can be re-written when a
> > > -	 * Busy Detect interrupt occurs. */
> > > -	if (save_offset == UART_LCR) {
> > > -		struct uart_8250_port *up = (struct uart_8250_port *)p;
> > > -		up->lcr = value;
> > > -	}
> > > +	dwapb_save_out_value(p, save_offset, value);
> > 
> > Because of that, are you sure this is correct now?  You might just be
> > getting lucky due to the location of the pointer within the structure,
> > but then the old code was wrong.
> > 
> > Either way, I don't feel comfortable with this, do you?
> struct uart_8250_port is defined in drivers/serial/8250.c as:
> 
> struct uart_8250_port {
>         struct uart_port        port;
>         struct timer_list       timer;          /* "no irq" timer */
> 	...
> };
> 

Ah, yeah, you are right.

> So yes, I'm happy with the change but I could be missing something... I'm also 
> happy to convert it back to a cast but container_of() feels a bit safer.  

I totally agree, it is safer and makes more sense.

> I've just tried the patch below (on top of my previous patch) to convert all 
> of the explicit casts (apart from the timer callbacks that take an unsigned 
> long) to container_of() and that works fine on my board. Is this worth 
> applying or would you rather I just keep the original cast?

Yes, it's worth applying.

So, care to send me 2 patches that I can apply with the proper changelog
comments and signed-off-by: for this?  I don't care which order you do
things in, which ever is easier for you.

thanks,

greg k-h

  reply	other threads:[~2010-12-01 19:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-22 14:26 [PATCH] 8250: add a UPIO_DWAPB32 for 32 bit accesses (v2) Jamie Iles
2010-12-01  1:17 ` Greg KH
2010-12-01  8:10   ` Jamie Iles
2010-12-01 17:01     ` Greg KH
2010-12-01 17:17       ` Jamie Iles
2010-12-01 19:27         ` Greg KH [this message]
2010-12-01 23:39           ` [PATCH 1/2] 8250: use container_of() instead of casting Jamie Iles
2010-12-01 23:39           ` [PATCH 2/2] 8250: add a UPIO_DWAPB32 for 32 bit accesses Jamie Iles
  -- strict thread matches above, loose matches on Subject: below --
2010-01-04 17:11 [PATCH] " Jamie Iles
2010-01-04 17:19 ` Resend of " Jamie Iles
2010-01-04 17:19   ` [PATCH] 8250: add a UPIO_DWAPB32 for 32 bit accesses (v2) Jamie Iles

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=20101201192728.GB31841@kroah.com \
    --to=greg@kroah.com \
    --cc=jamie@jamieiles.com \
    --cc=linux-serial@vger.kernel.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