3

I need to do an integer division in a kernel module and I am using do_div() for that. It seems to work on my machine (I have an i686 processor), however I am not sure that it works everywhere. Could anyone confirm whether do_div() should function correctly in 32 bit and 64 bit architectures, or whether there are any know limitations ?

I use Ubuntu 10.04 with kernel 2.6.38, so I am interested in support for kernels >= 2.6.38.

I would also be interested if anyone knows a better way to do an integer division in the kernel than do_div().

Best Regards

Daniel

osgx
  • 90,338
  • 53
  • 357
  • 513
Dani Camps
  • 195
  • 2
  • 5

1 Answers1

0

do_div() does work on 64bit arch, but unless you really need the remainder and is fully aware of the effects of using do_div(), you should probably be doing bit shifts instead.

Ronny Vindenes
  • 2,361
  • 1
  • 18
  • 15
  • 1
    Hi, thanks for the comment. Then I understand that do_div() should always work regardless of the architecture, correct ? Regarding doing bit shifts, that would only be possible if I wanted to divide by a power of 2, right? This is not my case since I need to divide by any integer. – Dani Camps Sep 08 '11 at 12:27