public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] e1000: fix PCI memory addressing
Date: Sat, 22 Aug 2009 15:17:18 +0200	[thread overview]
Message-ID: <20090822131718.36823833DBD2@gemini.denx.de> (raw)
In-Reply-To: <4A8FEA69.9080408@freescale.com>

Dear Timur Tabi,

In message <4A8FEA69.9080408@freescale.com> you wrote:
>
> > Configuring for MVBC_P board...
> > e1000.c: In function 'e1000_transmit':
> > e1000.c:5019: warning: passing argument 1 of 'virt_to_phys' discards
> > qualifiers from pointer target type
> 
> I can't reproduce this problem.
...
> $ ${CROSS_COMPILE}gcc --version
> powerpc-linux-gnu-gcc (Sourcery G++ Lite 4.3-74) 4.3.2

I used ELDK 4.2 (gcc-4.2.2).

> If you look at the definition of virt_to_bus, you'll see that I added a 
> pointer cast specifically to address this warning:

Well, are you aware how this simple statement gets expanded by the
preprocessor?

Out of

txp->buffer_addr = cpu_to_le64(virt_to_bus(hw->pdev, packet));

becomes:

txp->buffer_addr = (__builtin_constant_p((__u64)((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) ? ((__u64)( (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00000000000000ffULL) << 56) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x000000000000ff00ULL) << 40) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x0000000000ff0000ULL) << 24) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00000000ff000000ULL) << 8) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 
 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x000000ff00000000ULL) >> 8) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x0000ff0000000000ULL) >> 24) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00ff000000000000ULL) >> 40) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0xff00000000000000ULL) >> 56) )) : __fswab64(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))));

I take my hat off to you if you manage to understand the consequences
and results of all this casting going on here.


> #define virt_to_bus(devno, v)	pci_virt_to_mem(devno, (void *) (v))

Also, I have to admit that I really dislike such casts as they just
suppress compiler warnings which are usually valuable - I'd rather
see you fixing the original problem (i. e. the type
incompatibilities).

> If I remove the (void *) cast, I get this:
> 
> e1000.c: In function 'e1000_transmit':
> e1000.c:5019: warning: passing argument 1 of 'virt_to_phys' discards 
> qualifiers from pointer target type
> 
> So somehow, you're compiler is ignoring the "(void *)".

I would not go so far to say it is ignoring it. Let's say this cast
is insufficient (or simply the wrong approach) to silence the compiler. 

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Maintain an awareness for contribution --  to  your  schedule,  your
project, our company."                         - A Group of Employees

  reply	other threads:[~2009-08-22 13:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-17 20:55 [U-Boot] [PATCH 2/2] e1000: fix PCI memory addressing Timur Tabi
2009-08-17 20:57 ` Timur Tabi
2009-08-17 23:25 ` Kumar Gala
2009-08-21  6:56   ` Kumar Gala
2009-08-21 16:59 ` Ben Warren
2009-08-22  9:12 ` Wolfgang Denk
2009-08-22 11:40   ` Timur Tabi
2009-08-22 11:49     ` Wolfgang Denk
2009-08-22 12:54   ` Timur Tabi
2009-08-22 13:17     ` Wolfgang Denk [this message]
2009-08-24 15:30       ` Timur Tabi

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=20090822131718.36823833DBD2@gemini.denx.de \
    --to=wd@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox