[media] radio-tea5777.c: Get rid of do_div usage
authorHans de Goede <hdegoede@redhat.com>
Fri, 10 Aug 2012 10:47:25 +0000 (07:47 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 13 Sep 2012 20:42:09 +0000 (17:42 -0300)
freq fits easily into 32 bits until it gets shifted, so make it 32 bits,
and cast it to 64 bits before shifting.

[mchehab@redhat.com: also remove asm/div64.h header, as this is not
 needed anymore]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/radio/radio-tea5777.c

index 5bc9fa62720b6e23355a2ae54447a95de04d9222..8cfa364b8190c156f935ec714b35cfdaf66a81a5 100644 (file)
@@ -33,7 +33,6 @@
 #include <media/v4l2-fh.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-event.h>
-#include <asm/div64.h>
 #include "radio-tea5777.h"
 
 MODULE_AUTHOR("Hans de Goede <perex@perex.cz>");
@@ -155,18 +154,17 @@ static u32 tea5777_freq_to_v4l2_freq(struct radio_tea5777 *tea, u32 freq)
 
 static int radio_tea5777_set_freq(struct radio_tea5777 *tea)
 {
-       u64 freq;
+       u32 freq;
        int res;
 
        freq = clamp_t(u32, tea->freq,
-                      TEA5777_FM_RANGELOW, TEA5777_FM_RANGEHIGH) + 8;
-       do_div(freq, 16); /* to kHz */
+                      TEA5777_FM_RANGELOW, TEA5777_FM_RANGEHIGH);
+       freq = (freq + 8) / 16; /* to kHz */
 
-       freq -= TEA5777_FM_IF;
-       do_div(freq, TEA5777_FM_FREQ_STEP);
+       freq = (freq - TEA5777_FM_IF) / TEA5777_FM_FREQ_STEP;
 
        tea->write_reg &= ~(TEA5777_W_FM_PLL_MASK | TEA5777_W_FM_FREF_MASK);
-       tea->write_reg |= freq << TEA5777_W_FM_PLL_SHIFT;
+       tea->write_reg |= (u64)freq << TEA5777_W_FM_PLL_SHIFT;
        tea->write_reg |= TEA5777_W_FM_FREF_VALUE << TEA5777_W_FM_FREF_SHIFT;
 
        res = tea->ops->write_reg(tea, tea->write_reg);