[PATCH] transform udelay to mdelay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
following the conversation on the v4l-dvb-maitainer ML:
http://www.linuxtv.org/pipermail/v4l-dvb-maintainer/2008-August/007753.html
Contents:
Thierry Merle a écrit :
> Hi Martin
>
> Martin Michlmayr a écrit :
>   
>> budget.ko fails to build on ARM with:
>>
>> ERROR: "__bad_udelay" [drivers/media/dvb/ttpci/budget.ko] undefined!
>> make[1]: *** [__modpost] Error 1
>>
>> __bad_udelay is specifically designed on ARM to fail when udelay is
>> called in a bad way.  arch/arm/include/asm/delay.h has this to say
>> about __bad_udelay:
>>
>> /*
>>  * This function intentionally does not exist; if you see references to
>>  * it, it means that you're calling udelay() with an out of range value.
>>  *
>>  * With currently imposed limits, this means that we support a max delay
>>  * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
>>  */
>> extern void __bad_udelay(void);
>>
>> Can you check why your driver is calling udelay() with a value > 2000?
>>
>>   
>>     
> Right, I experienced the same problem with the em28xx (from mcentral.de)
> driver compilation on my NSLU2 target.
> I guess you are doing the same thing for this driver.
> The solution was to use mdelay when possible.
> It solves the compilation on these low-power-consuming-but-high-capacities targets.
> Here are all the udelay with value greater than 2000 in v4l-dvb/:
> linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c:                       
> udelay(12500);
> linux/drivers/media/dvb/bt8xx/dst.c:            udelay(3000);
> linux/drivers/media/dvb/bt8xx/dst.c:            udelay(3000);
> linux/drivers/media/dvb/ttpci/budget-patch.c:                  
> udelay(12500);
> linux/drivers/media/dvb/ttpci/budget.c:                 udelay(12500);
> linux/drivers/media/video/bt8xx/bttv-cards.c:   udelay(2500);
> I attached a patch that replaces all these calls to mdelay, and additional udelay if
> necessary.
> I cannot test it since I do not own any of these devices so this is just a proposal.
> Cheers,
> Thierry
>   
Here is the patch I proposed, this should be harmless but I have no
device to test them.

Cheers,
Thierry

Signed-off-by: Thierry Merle <thierry.merle@xxxxxxx>

diff -r a4843e1304e6 linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
--- a/linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c	Sun Aug 24 12:28:11 2008 -0300
+++ b/linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c	Tue Aug 26 14:15:36 2008 +0200
@@ -137,7 +137,8 @@ static int flexcop_send_diseqc_msg(struc
 			flexcop_diseqc_send_byte(fe, 0xff);
 		else {
 			flexcop_set_tone(fe, SEC_TONE_ON);
-			udelay(12500);
+			mdelay(12);
+			udelay(500);
 			flexcop_set_tone(fe, SEC_TONE_OFF);
 		}
 		msleep(20);
diff -r a4843e1304e6 linux/drivers/media/dvb/bt8xx/dst.c
--- a/linux/drivers/media/dvb/bt8xx/dst.c	Sun Aug 24 12:28:11 2008 -0300
+++ b/linux/drivers/media/dvb/bt8xx/dst.c	Tue Aug 26 14:16:16 2008 +0200
@@ -1244,7 +1244,7 @@ static int dst_command(struct dst_state 
 		goto error;
 	}
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
-		udelay(3000);
+		mdelay(3);
 	if (read_dst(state, &reply, GET_ACK)) {
 		dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
 		if ((dst_error_recovery(state)) < 0) {
@@ -1260,7 +1260,7 @@ static int dst_command(struct dst_state 
 	if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
 		goto error;
 	if (state->type_flags & DST_TYPE_HAS_FW_1)
-		udelay(3000);
+		mdelay(3);
 	else
 		udelay(2000);
 	if (!dst_wait_dst_ready(state, NO_DELAY))
diff -r a4843e1304e6 linux/drivers/media/dvb/ttpci/budget-patch.c
--- a/linux/drivers/media/dvb/ttpci/budget-patch.c	Sun Aug 24 12:28:11 2008 -0300
+++ b/linux/drivers/media/dvb/ttpci/budget-patch.c	Tue Aug 26 14:16:54 2008 +0200
@@ -116,7 +116,8 @@ static int SendDiSEqCMsg (struct budget 
 			DiseqcSendByte(budget, 0xff);
 		else {
 			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
-			udelay(12500);
+			mdelay(12);
+			udelay(500);
 			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
 		}
 		msleep(20);
diff -r a4843e1304e6 linux/drivers/media/dvb/ttpci/budget.c
--- a/linux/drivers/media/dvb/ttpci/budget.c	Sun Aug 24 12:28:11 2008 -0300
+++ b/linux/drivers/media/dvb/ttpci/budget.c	Tue Aug 26 14:18:56 2008 +0200
@@ -108,7 +108,8 @@ static int SendDiSEqCMsg (struct budget 
 			DiseqcSendByte(budget, 0xff);
 		else {
 			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
-			udelay(12500);
+			mdelay(12);
+			udelay(500);
 			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
 		}
 		msleep(20);
diff -r a4843e1304e6 linux/drivers/media/video/bt8xx/bttv-cards.c
--- a/linux/drivers/media/video/bt8xx/bttv-cards.c	Sun Aug 24 12:28:11 2008 -0300
+++ b/linux/drivers/media/video/bt8xx/bttv-cards.c	Tue Aug 26 14:17:45 2008 +0200
@@ -4103,7 +4103,8 @@ static void __devinit boot_msp34xx(struc
 
 	gpio_inout(mask,mask);
 	gpio_bits(mask,0);
-	udelay(2500);
+	mdelay(2);
+	udelay(500);
 	gpio_bits(mask,mask);
 
 	if (bttv_gpio)
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux