transform udelay to mdelay
PATCH 1/1 transform udelay to mdelay
Hello,
following the conversation on the v4l-dvb-maitainer ML:
http://www.linuxtv.org/pipermail/v4l-dvb-maintainer/2008-August/007753.html
Contents:
Quoted 37 lines · Thierry Merle
Hi Martin
Quoted 18 lines · Martin Michlmayr
budget.ko fails to build on ARM with:
ERROR: "
__bad_udelay" [drivers/media/dvb/ttpci/budget.ko] undefined! make[1]: *** [__modpost] Error 1
__bad_udelayis specifically designed on ARM to fail when udelay is called in a bad way.arch/arm/include/asm/delay.hhas this to say about__bad_udelay:/*
* This function intentionally does not exist; if you see references to
* it, it means that you're callingudelay()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);Quoted 4 lines
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:
Quoted 9 lines
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
linux/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +2 -1
@@ -137,7 +137,8 @@ static int flexcop_send_diseqc_msg(strucflexcop_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 );
linux/drivers/media/dvb/bt8xx/dst.c +2 -2
@@ -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_stateif (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 ))
linux/drivers/media/dvb/ttpci/budget-patch.c +2 -1
@@ -116,7 +116,8 @@ static int SendDiSEqCMsg (struct budgetDiseqcSendByte (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 );
linux/drivers/media/dvb/ttpci/budget.c +2 -1
@@ -108,7 +108,8 @@ static int SendDiSEqCMsg (struct budgetDiseqcSendByte (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 );
linux/drivers/media/video/bt8xx/bttv-cards.c +2 -1
@@ -4103,7 +4103,8 @@ static void __devinit boot_msp34xx(strucgpio_inout (mask,mask);gpio_bits (mask,0 ); -udelay (2500 ); +mdelay (2 ); +udelay (500 );gpio_bits (mask,mask);if (bttv_gpio)
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
Quoted 8 lines · Thierry Merle
Quoted 6 lines
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 is the patch I proposed, this should be harmless but I have no device to test them.
I think mdelay and udelay should be safe for this. I know that generally msleep(2) will produce a much shorter sleep than "msleep(1);msleep(1);"
_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb