All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <anup@brainfault.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v10 2/4] net: macb: Fix check for little-endian system in gmac_configure_dma()
Date: Tue, 23 Jul 2019 09:37:31 +0530	[thread overview]
Message-ID: <CAAhSdy2RXyOKA1NuPCstG7rdwg0oZ5e=r=WcYGbjfS-0x9R3xg@mail.gmail.com> (raw)
In-Reply-To: <CANr=Z=ZMSwiJZfma2z6Ncr=mYPJztzr4+tUieda59v7rgOhJRA@mail.gmail.com>

On Tue, Jul 23, 2019 at 8:55 AM Joe Hershberger <joe.hershberger@ni.com> wrote:
>
> On Mon, Jul 22, 2019 at 2:54 AM Anup Patel <Anup.Patel@wdc.com> wrote:
> >
> > Instead of depending on CONFIG_SYS_LITTLE_ENDIAN, we check at runtime
> > whether underlying system is little-endian or big-endian. This way
> > we are not dependent on any U-Boot specific OR compiler specific macro
> > to check system endianness.
> >
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> > Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> > Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
> > ---
> >  drivers/net/macb.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> > index 3db5597373..27a6c6db2b 100644
> > --- a/drivers/net/macb.c
> > +++ b/drivers/net/macb.c
> > @@ -84,6 +84,8 @@ struct macb_dma_desc {
> >  struct macb_device {
> >         void                    *regs;
> >
> > +       bool                    is_big_endian;
> > +
> >         const struct macb_config *config;
> >
> >         unsigned int            rx_tail;
> > @@ -743,11 +745,10 @@ static void gmac_configure_dma(struct macb_device *macb)
> >         dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
> >         dmacfg &= ~GEM_BIT(ENDIA_PKT);
> >
> > -#ifdef CONFIG_SYS_LITTLE_ENDIAN
> > -               dmacfg &= ~GEM_BIT(ENDIA_DESC);
> > -#else
> > +       if (macb->is_big_endian)
> >                 dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */
> > -#endif
> > +       else
> > +               dmacfg &= ~GEM_BIT(ENDIA_DESC);
> >
> >         dmacfg &= ~GEM_BIT(ADDR64);
> >         gem_writel(macb, DMACFG, dmacfg);
> > @@ -1221,6 +1222,9 @@ static int macb_eth_probe(struct udevice *dev)
> >
> >         macb->regs = (void *)pdata->iobase;
> >
> > +       macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678) ?
> > +                               true : false;
>
> You don't need the "? true : false". That's a no-op. Just assign the
> result of the comparison.

Sure, I will update.

>
> > +
> >         macb->config = (struct macb_config *)dev_get_driver_data(dev);
> >         if (!macb->config)
> >                 macb->config = &default_gem_config;
> > --
> > 2.17.1
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Thanks,
Anup

  reply	other threads:[~2019-07-23  4:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22  7:37 [U-Boot] [PATCH v10 0/4] Update SiFive Unleashed Drivers Anup Patel
2019-07-22  7:38 ` [U-Boot] [PATCH v10 1/4] net: macb: Extend MACB driver for SiFive Unleashed board Anup Patel
2019-07-23  3:20   ` Joe Hershberger
2019-07-23  4:07     ` Anup Patel
2019-07-22  7:38 ` [U-Boot] [PATCH v10 2/4] net: macb: Fix check for little-endian system in gmac_configure_dma() Anup Patel
2019-07-23  3:21   ` Joe Hershberger
2019-07-23  4:07     ` Anup Patel [this message]
2019-07-22  7:38 ` [U-Boot] [PATCH v10 3/4] riscv: sifive: fu540: Sync-up config header with RISC-V QEMU support Anup Patel
2019-07-22 15:00   ` Bin Meng
2019-07-23  3:09   ` Joe Hershberger
2019-07-23 17:14   ` David Abdurachmanov
2019-07-22  7:38 ` [U-Boot] [PATCH v10 4/4] doc: sifive-fu540: Update README to explicitly load DTB for Linux Anup Patel
2019-07-22 15:00   ` Bin Meng
2019-07-23  3:15   ` Joe Hershberger
2019-07-25 18:57   ` Joe Hershberger
2019-07-26  2:35     ` Anup Patel

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='CAAhSdy2RXyOKA1NuPCstG7rdwg0oZ5e=r=WcYGbjfS-0x9R3xg@mail.gmail.com' \
    --to=anup@brainfault.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.