lkml.org 
[lkml]   [2007]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 1/3] Blackfin ethernet driver: on chip ethernet MAC controller driver
    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.
    -mike
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-07-14 22:41    [W:0.040 / U:29.732 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site