Commit 9095b23f authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Mauro Carvalho Chehab

media: pci: cx23885: Replace mdelay() with msleep() and usleep_range() in cx23885_gpio_setup()

cx23885_gpio_setup() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep() and usleep_range().

This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent ccb2ca78
...@@ -1497,20 +1497,20 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1497,20 +1497,20 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the demod into reset and protect the eeprom */ /* Put the demod into reset and protect the eeprom */
mc417_gpio_clear(dev, GPIO_15 | GPIO_14); mc417_gpio_clear(dev, GPIO_15 | GPIO_14);
mdelay(100); msleep(100);
/* Bring the demod and blaster out of reset */ /* Bring the demod and blaster out of reset */
mc417_gpio_set(dev, GPIO_15 | GPIO_14); mc417_gpio_set(dev, GPIO_15 | GPIO_14);
mdelay(100); msleep(100);
/* Force the TDA8295A into reset and back */ /* Force the TDA8295A into reset and back */
cx23885_gpio_enable(dev, GPIO_2, 1); cx23885_gpio_enable(dev, GPIO_2, 1);
cx23885_gpio_set(dev, GPIO_2); cx23885_gpio_set(dev, GPIO_2);
mdelay(20); msleep(20);
cx23885_gpio_clear(dev, GPIO_2); cx23885_gpio_clear(dev, GPIO_2);
mdelay(20); msleep(20);
cx23885_gpio_set(dev, GPIO_2); cx23885_gpio_set(dev, GPIO_2);
mdelay(20); msleep(20);
break; break;
case CX23885_BOARD_HAUPPAUGE_HVR1200: case CX23885_BOARD_HAUPPAUGE_HVR1200:
/* GPIO-0 tda10048 demodulator reset */ /* GPIO-0 tda10048 demodulator reset */
...@@ -1518,9 +1518,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1518,9 +1518,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x00050000); cx_set(GP0_IO, 0x00050000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x00000005); cx_clear(GP0_IO, 0x00000005);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x00050005); cx_set(GP0_IO, 0x00050005);
break; break;
case CX23885_BOARD_HAUPPAUGE_HVR1700: case CX23885_BOARD_HAUPPAUGE_HVR1700:
...@@ -1539,9 +1539,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1539,9 +1539,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x00050000); cx_set(GP0_IO, 0x00050000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x00000005); cx_clear(GP0_IO, 0x00000005);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x00050005); cx_set(GP0_IO, 0x00050005);
break; break;
case CX23885_BOARD_HAUPPAUGE_HVR1400: case CX23885_BOARD_HAUPPAUGE_HVR1400:
...@@ -1551,9 +1551,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1551,9 +1551,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x00050000); cx_set(GP0_IO, 0x00050000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x00000005); cx_clear(GP0_IO, 0x00000005);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x00050005); cx_set(GP0_IO, 0x00050005);
break; break;
case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
...@@ -1564,9 +1564,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1564,9 +1564,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x000f0000); cx_set(GP0_IO, 0x000f0000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x0000000f); cx_clear(GP0_IO, 0x0000000f);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x000f000f); cx_set(GP0_IO, 0x000f000f);
break; break;
case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
...@@ -1578,9 +1578,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1578,9 +1578,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x000f0000); cx_set(GP0_IO, 0x000f0000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x0000000f); cx_clear(GP0_IO, 0x0000000f);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x000f000f); cx_set(GP0_IO, 0x000f000f);
break; break;
case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
...@@ -1596,9 +1596,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1596,9 +1596,9 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the parts into reset and back */ /* Put the parts into reset and back */
cx_set(GP0_IO, 0x00040000); cx_set(GP0_IO, 0x00040000);
mdelay(20); msleep(20);
cx_clear(GP0_IO, 0x00000004); cx_clear(GP0_IO, 0x00000004);
mdelay(20); msleep(20);
cx_set(GP0_IO, 0x00040004); cx_set(GP0_IO, 0x00040004);
break; break;
case CX23885_BOARD_TBS_6920: case CX23885_BOARD_TBS_6920:
...@@ -1608,11 +1608,11 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1608,11 +1608,11 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_write(MC417_CTL, 0x00000036); cx_write(MC417_CTL, 0x00000036);
cx_write(MC417_OEN, 0x00001000); cx_write(MC417_OEN, 0x00001000);
cx_set(MC417_RWD, 0x00000002); cx_set(MC417_RWD, 0x00000002);
mdelay(200); msleep(200);
cx_clear(MC417_RWD, 0x00000800); cx_clear(MC417_RWD, 0x00000800);
mdelay(200); msleep(200);
cx_set(MC417_RWD, 0x00000800); cx_set(MC417_RWD, 0x00000800);
mdelay(200); msleep(200);
break; break;
case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
/* GPIO-0 INTA from CiMax1 /* GPIO-0 INTA from CiMax1
...@@ -1630,7 +1630,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1630,7 +1630,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x00040000); /* GPIO as out */ cx_set(GP0_IO, 0x00040000); /* GPIO as out */
/* GPIO1 and GPIO2 as INTA and INTB from CiMaxes, reset low */ /* GPIO1 and GPIO2 as INTA and INTB from CiMaxes, reset low */
cx_clear(GP0_IO, 0x00030004); cx_clear(GP0_IO, 0x00030004);
mdelay(100);/* reset delay */ msleep(100);/* reset delay */
cx_set(GP0_IO, 0x00040004); /* GPIO as out, reset high */ cx_set(GP0_IO, 0x00040004); /* GPIO as out, reset high */
cx_write(MC417_CTL, 0x00000037);/* enable GPIO3-18 pins */ cx_write(MC417_CTL, 0x00000037);/* enable GPIO3-18 pins */
/* GPIO-15 IN as ~ACK, rest as OUT */ /* GPIO-15 IN as ~ACK, rest as OUT */
...@@ -1653,7 +1653,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1653,7 +1653,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx23885_gpio_enable(dev, GPIO_9 | GPIO_6 | GPIO_5, 1); cx23885_gpio_enable(dev, GPIO_9 | GPIO_6 | GPIO_5, 1);
cx23885_gpio_set(dev, GPIO_9 | GPIO_6 | GPIO_5); cx23885_gpio_set(dev, GPIO_9 | GPIO_6 | GPIO_5);
cx23885_gpio_clear(dev, GPIO_9); cx23885_gpio_clear(dev, GPIO_9);
mdelay(20); msleep(20);
cx23885_gpio_set(dev, GPIO_9); cx23885_gpio_set(dev, GPIO_9);
break; break;
case CX23885_BOARD_MYGICA_X8506: case CX23885_BOARD_MYGICA_X8506:
...@@ -1664,18 +1664,18 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1664,18 +1664,18 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* GPIO-2 demod reset */ /* GPIO-2 demod reset */
cx23885_gpio_enable(dev, GPIO_0 | GPIO_1 | GPIO_2, 1); cx23885_gpio_enable(dev, GPIO_0 | GPIO_1 | GPIO_2, 1);
cx23885_gpio_clear(dev, GPIO_1 | GPIO_2); cx23885_gpio_clear(dev, GPIO_1 | GPIO_2);
mdelay(100); msleep(100);
cx23885_gpio_set(dev, GPIO_0 | GPIO_1 | GPIO_2); cx23885_gpio_set(dev, GPIO_0 | GPIO_1 | GPIO_2);
mdelay(100); msleep(100);
break; break;
case CX23885_BOARD_MYGICA_X8558PRO: case CX23885_BOARD_MYGICA_X8558PRO:
/* GPIO-0 reset first ATBM8830 */ /* GPIO-0 reset first ATBM8830 */
/* GPIO-1 reset second ATBM8830 */ /* GPIO-1 reset second ATBM8830 */
cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1); cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
cx23885_gpio_clear(dev, GPIO_0 | GPIO_1); cx23885_gpio_clear(dev, GPIO_0 | GPIO_1);
mdelay(100); msleep(100);
cx23885_gpio_set(dev, GPIO_0 | GPIO_1); cx23885_gpio_set(dev, GPIO_0 | GPIO_1);
mdelay(100); msleep(100);
break; break;
case CX23885_BOARD_HAUPPAUGE_HVR1850: case CX23885_BOARD_HAUPPAUGE_HVR1850:
case CX23885_BOARD_HAUPPAUGE_HVR1290: case CX23885_BOARD_HAUPPAUGE_HVR1290:
...@@ -1699,11 +1699,11 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1699,11 +1699,11 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* Put the demod into reset and protect the eeprom */ /* Put the demod into reset and protect the eeprom */
mc417_gpio_clear(dev, GPIO_14 | GPIO_13); mc417_gpio_clear(dev, GPIO_14 | GPIO_13);
mdelay(100); msleep(100);
/* Bring the demod out of reset */ /* Bring the demod out of reset */
mc417_gpio_set(dev, GPIO_14); mc417_gpio_set(dev, GPIO_14);
mdelay(100); msleep(100);
/* CX24228 GPIO */ /* CX24228 GPIO */
/* Connected to IF / Mux */ /* Connected to IF / Mux */
...@@ -1728,7 +1728,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1728,7 +1728,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x00060000); /* GPIO-1,2 as out */ cx_set(GP0_IO, 0x00060000); /* GPIO-1,2 as out */
/* GPIO-0 as INT, reset & TMS low */ /* GPIO-0 as INT, reset & TMS low */
cx_clear(GP0_IO, 0x00010006); cx_clear(GP0_IO, 0x00010006);
mdelay(100);/* reset delay */ msleep(100);/* reset delay */
cx_set(GP0_IO, 0x00000004); /* reset high */ cx_set(GP0_IO, 0x00000004); /* reset high */
cx_write(MC417_CTL, 0x00000037);/* enable GPIO-3..18 pins */ cx_write(MC417_CTL, 0x00000037);/* enable GPIO-3..18 pins */
/* GPIO-17 is TDO in, GPIO-15 is ~RDY in, rest is out */ /* GPIO-17 is TDO in, GPIO-15 is ~RDY in, rest is out */
...@@ -1747,36 +1747,36 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1747,36 +1747,36 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1); cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
cx23885_gpio_clear(dev, GPIO_8 | GPIO_9); cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
mdelay(100); msleep(100);
cx23885_gpio_set(dev, GPIO_8 | GPIO_9); cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
mdelay(100); msleep(100);
break; break;
case CX23885_BOARD_AVERMEDIA_HC81R: case CX23885_BOARD_AVERMEDIA_HC81R:
cx_clear(MC417_CTL, 1); cx_clear(MC417_CTL, 1);
/* GPIO-0,1,2 setup direction as output */ /* GPIO-0,1,2 setup direction as output */
cx_set(GP0_IO, 0x00070000); cx_set(GP0_IO, 0x00070000);
mdelay(10); usleep_range(10000, 11000);
/* AF9013 demod reset */ /* AF9013 demod reset */
cx_set(GP0_IO, 0x00010001); cx_set(GP0_IO, 0x00010001);
mdelay(10); usleep_range(10000, 11000);
cx_clear(GP0_IO, 0x00010001); cx_clear(GP0_IO, 0x00010001);
mdelay(10); usleep_range(10000, 11000);
cx_set(GP0_IO, 0x00010001); cx_set(GP0_IO, 0x00010001);
mdelay(10); usleep_range(10000, 11000);
/* demod tune? */ /* demod tune? */
cx_clear(GP0_IO, 0x00030003); cx_clear(GP0_IO, 0x00030003);
mdelay(10); usleep_range(10000, 11000);
cx_set(GP0_IO, 0x00020002); cx_set(GP0_IO, 0x00020002);
mdelay(10); usleep_range(10000, 11000);
cx_set(GP0_IO, 0x00010001); cx_set(GP0_IO, 0x00010001);
mdelay(10); usleep_range(10000, 11000);
cx_clear(GP0_IO, 0x00020002); cx_clear(GP0_IO, 0x00020002);
/* XC3028L tuner reset */ /* XC3028L tuner reset */
cx_set(GP0_IO, 0x00040004); cx_set(GP0_IO, 0x00040004);
cx_clear(GP0_IO, 0x00040004); cx_clear(GP0_IO, 0x00040004);
cx_set(GP0_IO, 0x00040004); cx_set(GP0_IO, 0x00040004);
mdelay(60); msleep(60);
break; break;
case CX23885_BOARD_DVBSKY_T9580: case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_S952: case CX23885_BOARD_DVBSKY_S952:
...@@ -1785,7 +1785,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1785,7 +1785,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_write(MC417_CTL, 0x00000037); cx_write(MC417_CTL, 0x00000037);
cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1); cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
cx23885_gpio_clear(dev, GPIO_2 | GPIO_11); cx23885_gpio_clear(dev, GPIO_2 | GPIO_11);
mdelay(100); msleep(100);
cx23885_gpio_set(dev, GPIO_2 | GPIO_11); cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
break; break;
case CX23885_BOARD_DVBSKY_T980C: case CX23885_BOARD_DVBSKY_T980C:
...@@ -1807,7 +1807,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) ...@@ -1807,7 +1807,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */ cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */
cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */ cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */
mdelay(100); /* reset delay */ msleep(100); /* reset delay */
cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */ cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */
cx_clear(GP0_IO, 0x00010002); cx_clear(GP0_IO, 0x00010002);
cx_write(MC417_CTL, 0x00000037); /* enable GPIO3-18 pins */ cx_write(MC417_CTL, 0x00000037); /* enable GPIO3-18 pins */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment