2005-01-13 23:38:17

by Dave

[permalink] [raw]
Subject: [PATCH 2/5] Convert resource to u64 from unsigned long

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

Signed-off-by: Dave Jiang ([email protected])


--
-= 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.).


Attachments:
(No filename) (432.00 B)
patch-driver_u64fix (5.34 kB)
Download all attachments

2005-01-14 05:48:25

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH 2/5] Convert resource to u64 from unsigned long

On Jan 13, 2005 16:28 -0700, Dave wrote:
> Fixed some of the drivers as example just to get working on i386.
> + /*
> + * FIXME: apparently ia32 does not have u64 divide implementation
> + * we cast the pci_resource_len to u32 for the time being
> + * 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/


Attachments:
(No filename) (1.27 kB)
(No filename) (189.00 B)
Download all attachments