Skip to contentSkip to conversation

Convert resource to u64 from unsigned long

PATCH In review Dave 2 participants 2 messages Jan 13, 2005 – Jan 14, 2005

lore
Share & tools
lore

Dave

author
#0 lore raw

PATCH 2/5 Convert resource to u64 from unsigned long

Fixed some of the drivers as example just to get working on i386.

Signature · 11 lines
-= Dave =-

Software Engineer - Advanced Development Engineering Team 
Storage Component Division - Intel Corp. 
mailto://dave.jiang @ intel
http://sourceforge.net/projects/xscaleiop/
----
The views expressed in this email are
mine alone and do not necessarily 
reflect the views of my employer
(Intel Corp.).
#1 lore raw
Quoted 4 lines · Dave

Fixed some of the drivers as example just to get working on i386.

(quoted diff) +3 -0
+     /*
+      * FIXME: apparently ia32 does not have u64 divide implementation
+      * we cast the pci_resource_len to u32 for the time being

Review

Quoted 10 lines
(quoted diff) +8 -0
+      * this probably should be fixed to support u64 for ia32
+      * and other archs that do not have u64 divide
+      */
+#if BIS_PER_LONG == 64
      maxnr = (pci_resource_len(dev, bar) - board->first_offset) /
              (8 << board->reg_shift);
+#else
+     maxnr = ((u32)pci_resource_len(dev, bar) - board->first_offset) /
+             (8 << board->reg_shift);
+#endif

One of the reasons that ia32 doesn't support 64-bit divide directly is because it is a big red flag that you are probably doing something wrong. This is a prime example - why do a divide when you could do a shift:

        maxnr = (pci_resource_len(dev, bar) - board->first_offset) >>
                (board->reg_shift + 3);

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/