netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Mike Frysinger <vapier.adi@gmail.com>
Cc: Michael Buesch <mb@bu3sch.de>,
	bryan.wu@analog.com, Jeff Garzik <jeff@garzik.org>,
	LKML <linux-kernel@vger.kernel.org>,
	netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/3] Blackfin ethernet driver: on chip ethernet MAC controller driver
Date: Sun, 15 Jul 2007 09:04:21 -0400	[thread overview]
Message-ID: <1184504661.5871.25.camel@localhost.localdomain> (raw)
In-Reply-To: <8bd0f97a0707141338q996f246p6abdc2f65efa5e7@mail.gmail.com>

On Sat, 2007-07-14 at 16:38 -0400, Mike Frysinger wrote:
> On 7/14/07, Michael Buesch <mb@bu3sch.de> wrote:
> > On Saturday 14 July 2007 21:49:21 Mike Frysinger wrote:
> > > On 7/14/07, Michael Buesch <mb@bu3sch.de> wrote:
> > > > On Saturday 14 July 2007 20:49:53 Bryan Wu wrote:
> > > > > +static int __init bf537mac_probe(struct net_device *dev)
> > > > > +{
> > > > > +     struct bf537mac_local *lp = netdev_priv(dev);
> > > > > +     int retval;
> > > > > +
> > > > > +     /* Grab the MAC address in the MAC */
> > > > > +     *(u32 *) (&(dev->dev_addr[0])) = bfin_read_EMAC_ADDRLO();
> > > > > +     *(u16 *) (&(dev->dev_addr[4])) = (u16) bfin_read_EMAC_ADDRHI();
> > > >
> > > > Endianess broken.
> > > >
> > > > > +struct dma_config_reg {
> > > > > +     unsigned short b_DMA_EN:1;  /* Bit 0 : DMA Enable */
> > > > > +     unsigned short b_WNR:1;     /* Bit 1 : DMA Direction */
> > > > > +     unsigned short b_WDSIZE:2;  /* Bit 2 & 3 : DMA Tranfer Word size */
> > > > > +     unsigned short b_DMA2D:1;   /* Bit 4 : DMA Mode 2D or 1D */
> > > > > +     unsigned short b_RESTART:1; /* Bit 5 : Retain the FIFO */
> > > > > +     unsigned short b_DI_SEL:1;  /* Bit 6 : Data Interrupt Timing Select */
> > > > > +     unsigned short b_DI_EN:1;   /* Bit 7 : Data Interrupt Enable */
> > > > > +     unsigned short b_NDSIZE:4;  /* Bit 8 to 11 : Flex descriptor Size */
> > > > > +     unsigned short b_FLOW:3;    /* Bit 12 to 14 : FLOW */
> > > > > +};
> > > >
> > > > This is most likely not endianess safe.
> > >
> > > do we really need to care about this ?  this is a driver for a MAC
> > > which can only be found on Blackfin processors and Blackfin itself is
> > > only little endian.
> >
> > Well, this bitfield _might_ be OK (although I don't like bitfields
> > at all), but the above pointer casting stuff should really use
> > leXX_to_cpu. It's so easy to use and it is easier to read and
> > maintain the code afterwards.
> 
> i think that's arguable ... i dont see how:
> a = foo(b);
> is easier to read than:
> a = b;
> but it is easy to use ... i guess my point was more along the lines of
> wasting further time auditing a driver for endianness issues that will
> never actually be an issue.

Sometimes by doing this you catch bugs you didn't see before.  It's a
good thing to do generally.  Does sparse with endianness check show
errors?  You may want to fix those.

Dan

> -mike
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2007-07-15 13:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-14 18:49 [PATCH 1/3] Blackfin ethernet driver: on chip ethernet MAC controller driver Bryan Wu
2007-07-14 19:38 ` Michael Buesch
2007-07-14 19:49   ` Mike Frysinger
2007-07-14 20:17     ` Michael Buesch
2007-07-14 20:33       ` Jeff Garzik
2007-07-14 20:38       ` Mike Frysinger
2007-07-15 13:04         ` Dan Williams [this message]
2007-07-15 13:55           ` Bryan Wu
2007-07-15  9:16   ` Bryan Wu
2007-07-15  9:36     ` Michael Buesch
2007-07-15  9:52       ` Bryan Wu
2007-07-15 13:12 ` Dan Williams
2007-07-15 15:09   ` Bryan Wu

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=1184504661.5871.25.camel@localhost.localdomain \
    --to=dcbw@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bryan.wu@analog.com \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=netdev@vger.kernel.org \
    --cc=vapier.adi@gmail.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;
as well as URLs for NNTP newsgroup(s).