aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-06-10 01:26:28 -0400
committerTakashi Iwai <tiwai@suse.de>2009-06-10 01:26:28 -0400
commit19b1a15a3de2b3b6367c968e65bffe9503556ef1 (patch)
treebd87869290924ac3fee2126e5ba3aa668dde5d09 /sound
parente618a5609e504845786c71e2825e10b6a9728185 (diff)
parent3f7440a6b771169e1f11fa582e53a4259b682809 (diff)
Merge branch 'topic/div64-cleanup' into for-linus
* topic/div64-cleanup: ALSA: Clean up 64bit division functions
Diffstat (limited to 'sound')
-rw-r--r--sound/core/oss/pcm_oss.c5
-rw-r--r--sound/core/pcm_lib.c3
-rw-r--r--sound/pci/rme9652/hdsp.c7
-rw-r--r--sound/pci/rme9652/hdspm.c4
4 files changed, 9 insertions, 10 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index dda000b9684c..dbe406b82591 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -31,6 +31,7 @@
31#include <linux/time.h> 31#include <linux/time.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <linux/math64.h>
34#include <linux/string.h> 35#include <linux/string.h>
35#include <sound/core.h> 36#include <sound/core.h>
36#include <sound/minors.h> 37#include <sound/minors.h>
@@ -617,9 +618,7 @@ static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames)
617#else 618#else
618 { 619 {
619 u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes; 620 u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes;
620 u32 rem; 621 return div_u64(bsize, buffer_size);
621 div64_32(&bsize, buffer_size, &rem);
622 return (long)bsize;
623 } 622 }
624#endif 623#endif
625} 624}
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index d659995ac3ac..a7482874c451 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/time.h> 24#include <linux/time.h>
25#include <linux/math64.h>
25#include <sound/core.h> 26#include <sound/core.h>
26#include <sound/control.h> 27#include <sound/control.h>
27#include <sound/info.h> 28#include <sound/info.h>
@@ -452,7 +453,7 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b,
452 *r = 0; 453 *r = 0;
453 return UINT_MAX; 454 return UINT_MAX;
454 } 455 }
455 div64_32(&n, c, r); 456 n = div_u64_rem(n, c, r);
456 if (n >= UINT_MAX) { 457 if (n >= UINT_MAX) {
457 *r = 0; 458 *r = 0;
458 return UINT_MAX; 459 return UINT_MAX;
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 314e73531bd1..bcfdbb5ebc40 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -28,6 +28,7 @@
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/firmware.h> 29#include <linux/firmware.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/math64.h>
31 32
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/control.h> 34#include <sound/control.h>
@@ -1047,7 +1048,6 @@ static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames)
1047static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) 1048static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1048{ 1049{
1049 u64 n; 1050 u64 n;
1050 u32 r;
1051 1051
1052 if (rate >= 112000) 1052 if (rate >= 112000)
1053 rate /= 4; 1053 rate /= 4;
@@ -1055,7 +1055,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1055 rate /= 2; 1055 rate /= 2;
1056 1056
1057 n = DDS_NUMERATOR; 1057 n = DDS_NUMERATOR;
1058 div64_32(&n, rate, &r); 1058 n = div_u64(n, rate);
1059 /* n should be less than 2^32 for being written to FREQ register */ 1059 /* n should be less than 2^32 for being written to FREQ register */
1060 snd_BUG_ON(n >> 32); 1060 snd_BUG_ON(n >> 32);
1061 /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS 1061 /* HDSP_freqReg and HDSP_resetPointer are the same, so keep the DDS
@@ -3097,7 +3097,6 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3097static int hdsp_dds_offset(struct hdsp *hdsp) 3097static int hdsp_dds_offset(struct hdsp *hdsp)
3098{ 3098{
3099 u64 n; 3099 u64 n;
3100 u32 r;
3101 unsigned int dds_value = hdsp->dds_value; 3100 unsigned int dds_value = hdsp->dds_value;
3102 int system_sample_rate = hdsp->system_sample_rate; 3101 int system_sample_rate = hdsp->system_sample_rate;
3103 3102
@@ -3109,7 +3108,7 @@ static int hdsp_dds_offset(struct hdsp *hdsp)
3109 * dds_value = n / rate 3108 * dds_value = n / rate
3110 * rate = n / dds_value 3109 * rate = n / dds_value
3111 */ 3110 */
3112 div64_32(&n, dds_value, &r); 3111 n = div_u64(n, dds_value);
3113 if (system_sample_rate >= 112000) 3112 if (system_sample_rate >= 112000)
3114 n *= 4; 3113 n *= 4;
3115 else if (system_sample_rate >= 56000) 3114 else if (system_sample_rate >= 56000)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index bac2dc0c5d85..0dce331a2a3b 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -29,6 +29,7 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/math64.h>
32#include <asm/io.h> 33#include <asm/io.h>
33 34
34#include <sound/core.h> 35#include <sound/core.h>
@@ -831,7 +832,6 @@ static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames)
831static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) 832static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
832{ 833{
833 u64 n; 834 u64 n;
834 u32 r;
835 835
836 if (rate >= 112000) 836 if (rate >= 112000)
837 rate /= 4; 837 rate /= 4;
@@ -844,7 +844,7 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
844 */ 844 */
845 /* n = 104857600000000ULL; */ /* = 2^20 * 10^8 */ 845 /* n = 104857600000000ULL; */ /* = 2^20 * 10^8 */
846 n = 110100480000000ULL; /* Value checked for AES32 and MADI */ 846 n = 110100480000000ULL; /* Value checked for AES32 and MADI */
847 div64_32(&n, rate, &r); 847 n = div_u64(n, rate);
848 /* n should be less than 2^32 for being written to FREQ register */ 848 /* n should be less than 2^32 for being written to FREQ register */
849 snd_BUG_ON(n >> 32); 849 snd_BUG_ON(n >> 32);
850 hdspm_write(hdspm, HDSPM_freqReg, (u32)n); 850 hdspm_write(hdspm, HDSPM_freqReg, (u32)n);