* [PATCH] cx18: Use do_div for 64-bit division to fix 32-bit kernels
@ 2009-05-29 0:27 David Ward
2009-05-29 11:09 ` Andy Walls
0 siblings, 1 reply; 3+ messages in thread
From: David Ward @ 2009-05-29 0:27 UTC (permalink / raw)
To: Michael Krufky, linux-media
Use the do_div macro for 64-bit division. Otherwise, the module will
reference __udivdi3 under 32-bit kernels, which is not allowed in kernel
space. Follows style used in cx88 module.
Signed-off-by: David Ward <david.ward@gatech.edu>
diff -r 65ec132f20df -r 91b89f13adb7
linux/drivers/media/video/cx18/cx18-av-core.c
--- a/linux/drivers/media/video/cx18/cx18-av-core.c Wed May 27
15:53:00 2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-core.c Thu May 28
19:16:10 2009 -0400
@@ -447,6 +447,7 @@ void cx18_av_std_setup(struct cx18 *cx)
if (pll_post) {
int fsc, pll;
+ u64 tmp64;
pll = (28636360L * ((((u64)pll_int) << 25) + pll_frac)) >> 25;
pll /= pll_post;
@@ -459,7 +460,9 @@ void cx18_av_std_setup(struct cx18 *cx)
"= %d.%03d\n", src_decimation / 256,
((src_decimation % 256) * 1000) / 256);
- fsc = ((((u64)sc) * 28636360)/src_decimation) >> 13L;
+ tmp64 = ((u64)sc) * 28636360;
+ do_div(tmp64, src_decimation);
+ fsc = ((u32)(tmp64 >> 13L));
CX18_DEBUG_INFO_DEV(sd,
"Chroma sub-carrier initial freq = %d.%06d "
"MHz\n", fsc / 1000000, fsc % 1000000);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cx18: Use do_div for 64-bit division to fix 32-bit kernels
2009-05-29 0:27 [PATCH] cx18: Use do_div for 64-bit division to fix 32-bit kernels David Ward
@ 2009-05-29 11:09 ` Andy Walls
2009-05-29 15:49 ` David Ward
0 siblings, 1 reply; 3+ messages in thread
From: Andy Walls @ 2009-05-29 11:09 UTC (permalink / raw)
To: David Ward; +Cc: Michael Krufky, linux-media
On Thu, 2009-05-28 at 20:27 -0400, David Ward wrote:
> Use the do_div macro for 64-bit division. Otherwise, the module will
> reference __udivdi3 under 32-bit kernels, which is not allowed in kernel
> space. Follows style used in cx88 module.
Ooopsie. Thanks for catching this and providing a fix. :)
(FYI, You would have caught my attention earlier if you had put "cx18:"
in the subject line of the initital report.)
I'll test it tonight on my 64 bit machine, commit it, and ask Mauro to
pull it. I assume you've tested it on your 32 bit machine.
Regards,
Andy
> Signed-off-by: David Ward <david.ward@gatech.edu>
>
> diff -r 65ec132f20df -r 91b89f13adb7
> linux/drivers/media/video/cx18/cx18-av-core.c
> --- a/linux/drivers/media/video/cx18/cx18-av-core.c Wed May 27
> 15:53:00 2009 -0300
> +++ b/linux/drivers/media/video/cx18/cx18-av-core.c Thu May 28
> 19:16:10 2009 -0400
> @@ -447,6 +447,7 @@ void cx18_av_std_setup(struct cx18 *cx)
>
> if (pll_post) {
> int fsc, pll;
> + u64 tmp64;
>
> pll = (28636360L * ((((u64)pll_int) << 25) + pll_frac)) >> 25;
> pll /= pll_post;
> @@ -459,7 +460,9 @@ void cx18_av_std_setup(struct cx18 *cx)
> "= %d.%03d\n", src_decimation / 256,
> ((src_decimation % 256) * 1000) / 256);
>
> - fsc = ((((u64)sc) * 28636360)/src_decimation) >> 13L;
> + tmp64 = ((u64)sc) * 28636360;
> + do_div(tmp64, src_decimation);
> + fsc = ((u32)(tmp64 >> 13L));
> CX18_DEBUG_INFO_DEV(sd,
> "Chroma sub-carrier initial freq = %d.%06d "
> "MHz\n", fsc / 1000000, fsc % 1000000);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cx18: Use do_div for 64-bit division to fix 32-bit kernels
2009-05-29 11:09 ` Andy Walls
@ 2009-05-29 15:49 ` David Ward
0 siblings, 0 replies; 3+ messages in thread
From: David Ward @ 2009-05-29 15:49 UTC (permalink / raw)
To: Andy Walls; +Cc: Michael Krufky, linux-media
On 05/29/2009 07:09 AM, Andy Walls wrote:
> On Thu, 2009-05-28 at 20:27 -0400, David Ward wrote:
>
>> Use the do_div macro for 64-bit division. Otherwise, the module will
>> reference __udivdi3 under 32-bit kernels, which is not allowed in kernel
>> space. Follows style used in cx88 module.
>>
> Ooopsie. Thanks for catching this and providing a fix. :)
>
> (FYI, You would have caught my attention earlier if you had put "cx18:"
> in the subject line of the initital report.)
>
> I'll test it tonight on my 64 bit machine, commit it, and ask Mauro to
> pull it. I assume you've tested it on your 32 bit machine.
>
> Regards,
> Andy
>
>
Thanks Andy. Yes it's running on my 32-bit system. Until Michael
pointed out the offending line of code, I didn't realize that the
problem I was seeing was specific to the cx18 module -- I figured that
the problem could just as easily have been in an include somewhere and
affected multiple modules, perhaps only under older kernels -- so that's
why my original subject line was generic. But I'll keep that in mind in
the future.
David
>> Signed-off-by: David Ward<david.ward@gatech.edu>
>>
>> diff -r 65ec132f20df -r 91b89f13adb7
>> linux/drivers/media/video/cx18/cx18-av-core.c
>> --- a/linux/drivers/media/video/cx18/cx18-av-core.c Wed May 27
>> 15:53:00 2009 -0300
>> +++ b/linux/drivers/media/video/cx18/cx18-av-core.c Thu May 28
>> 19:16:10 2009 -0400
>> @@ -447,6 +447,7 @@ void cx18_av_std_setup(struct cx18 *cx)
>>
>> if (pll_post) {
>> int fsc, pll;
>> + u64 tmp64;
>>
>> pll = (28636360L * ((((u64)pll_int)<< 25) + pll_frac))>> 25;
>> pll /= pll_post;
>> @@ -459,7 +460,9 @@ void cx18_av_std_setup(struct cx18 *cx)
>> "= %d.%03d\n", src_decimation / 256,
>> ((src_decimation % 256) * 1000) / 256);
>>
>> - fsc = ((((u64)sc) * 28636360)/src_decimation)>> 13L;
>> + tmp64 = ((u64)sc) * 28636360;
>> + do_div(tmp64, src_decimation);
>> + fsc = ((u32)(tmp64>> 13L));
>> CX18_DEBUG_INFO_DEV(sd,
>> "Chroma sub-carrier initial freq = %d.%06d "
>> "MHz\n", fsc / 1000000, fsc % 1000000)
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-29 15:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-29 0:27 [PATCH] cx18: Use do_div for 64-bit division to fix 32-bit kernels David Ward
2009-05-29 11:09 ` Andy Walls
2009-05-29 15:49 ` David Ward
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox