diff options
author | Antti Palosaari <crope@iki.fi> | 2014-08-30 23:29:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-09-21 17:29:34 -0400 |
commit | 5190ff3e3e6ec55ecda805e68c4746aec8c1203c (patch) | |
tree | e834617831227e28aa356e757b4b68ddce44b88c | |
parent | 17027b9620e6a2ea1d7f3cd0761803c44c65e2ed (diff) |
[media] it913x: replace udelay polling with jiffies
udelay based I/O polling loop is a bad idea, especially system
performance point of view. Kernel jiffies are preferred solution
for such situations. Use it instead.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/tuners/it913x.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c index 098e9d542708..a076c87eda7a 100644 --- a/drivers/media/tuners/it913x.c +++ b/drivers/media/tuners/it913x.c | |||
@@ -39,10 +39,11 @@ struct it913x_dev { | |||
39 | static int it913x_init(struct dvb_frontend *fe) | 39 | static int it913x_init(struct dvb_frontend *fe) |
40 | { | 40 | { |
41 | struct it913x_dev *dev = fe->tuner_priv; | 41 | struct it913x_dev *dev = fe->tuner_priv; |
42 | int ret, i; | 42 | int ret; |
43 | unsigned int utmp; | 43 | unsigned int utmp; |
44 | u8 iqik_m_cal, nv_val, buf[2]; | 44 | u8 iqik_m_cal, nv_val, buf[2]; |
45 | static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2}; | 45 | static const u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2}; |
46 | unsigned long timeout; | ||
46 | 47 | ||
47 | dev_dbg(&dev->client->dev, "role %u\n", dev->role); | 48 | dev_dbg(&dev->client->dev, "role %u\n", dev->role); |
48 | 49 | ||
@@ -85,7 +86,9 @@ static int it913x_init(struct dvb_frontend *fe) | |||
85 | else | 86 | else |
86 | nv_val = 2; | 87 | nv_val = 2; |
87 | 88 | ||
88 | for (i = 0; i < 50; i++) { | 89 | #define TIMEOUT 50 |
90 | timeout = jiffies + msecs_to_jiffies(TIMEOUT); | ||
91 | while (!time_after(jiffies, timeout)) { | ||
89 | ret = regmap_bulk_read(dev->regmap, 0x80ed23, buf, 2); | 92 | ret = regmap_bulk_read(dev->regmap, 0x80ed23, buf, 2); |
90 | if (ret) | 93 | if (ret) |
91 | goto err; | 94 | goto err; |
@@ -93,30 +96,38 @@ static int it913x_init(struct dvb_frontend *fe) | |||
93 | utmp = (buf[1] << 8) | (buf[0] << 0); | 96 | utmp = (buf[1] << 8) | (buf[0] << 0); |
94 | if (utmp) | 97 | if (utmp) |
95 | break; | 98 | break; |
96 | |||
97 | udelay(2000); | ||
98 | } | 99 | } |
99 | 100 | ||
100 | dev_dbg(&dev->client->dev, "loop count %d, utmp %d\n", i, utmp); | 101 | dev_dbg(&dev->client->dev, "r_fbc_m_bdry took %u ms, val %u\n", |
102 | jiffies_to_msecs(jiffies) - | ||
103 | (jiffies_to_msecs(timeout) - TIMEOUT), utmp); | ||
101 | 104 | ||
102 | dev->fn_min = dev->xtal * utmp; | 105 | dev->fn_min = dev->xtal * utmp; |
103 | dev->fn_min /= (dev->fdiv * nv_val); | 106 | dev->fn_min /= (dev->fdiv * nv_val); |
104 | dev->fn_min *= 1000; | 107 | dev->fn_min *= 1000; |
105 | dev_dbg(&dev->client->dev, "fn_min %u\n", dev->fn_min); | 108 | dev_dbg(&dev->client->dev, "fn_min %u\n", dev->fn_min); |
106 | 109 | ||
110 | /* | ||
111 | * Chip version BX never sets that flag so we just wait 50ms in that | ||
112 | * case. It is possible poll BX similarly than AX and then timeout in | ||
113 | * order to get 50ms delay, but that causes about 120 extra I2C | ||
114 | * messages. As for now, we just wait and reduce IO. | ||
115 | */ | ||
107 | if (dev->chip_ver == 1) { | 116 | if (dev->chip_ver == 1) { |
108 | for (i = 0; i < 50; i++) { | 117 | #define TIMEOUT 50 |
118 | timeout = jiffies + msecs_to_jiffies(TIMEOUT); | ||
119 | while (!time_after(jiffies, timeout)) { | ||
109 | ret = regmap_read(dev->regmap, 0x80ec82, &utmp); | 120 | ret = regmap_read(dev->regmap, 0x80ec82, &utmp); |
110 | if (ret) | 121 | if (ret) |
111 | goto err; | 122 | goto err; |
112 | 123 | ||
113 | if (utmp) | 124 | if (utmp) |
114 | break; | 125 | break; |
115 | |||
116 | udelay(2000); | ||
117 | } | 126 | } |
118 | 127 | ||
119 | dev_dbg(&dev->client->dev, "loop count %d\n", i); | 128 | dev_dbg(&dev->client->dev, "p_tsm_init_mode took %u ms, val %u\n", |
129 | jiffies_to_msecs(jiffies) - | ||
130 | (jiffies_to_msecs(timeout) - TIMEOUT), utmp); | ||
120 | } else { | 131 | } else { |
121 | msleep(50); | 132 | msleep(50); |
122 | } | 133 | } |