diff options
Diffstat (limited to 'drivers/media/radio/si470x/radio-si470x-common.c')
-rw-r--r-- | drivers/media/radio/si470x/radio-si470x-common.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c index 38ae6cd65790..0e740c98786c 100644 --- a/drivers/media/radio/si470x/radio-si470x-common.c +++ b/drivers/media/radio/si470x/radio-si470x-common.c | |||
@@ -174,15 +174,27 @@ static int si470x_set_chan(struct si470x_device *radio, unsigned short chan) | |||
174 | if (retval < 0) | 174 | if (retval < 0) |
175 | goto done; | 175 | goto done; |
176 | 176 | ||
177 | /* wait till tune operation has completed */ | 177 | /* currently I2C driver only uses interrupt way to tune */ |
178 | timeout = jiffies + msecs_to_jiffies(tune_timeout); | 178 | if (radio->stci_enabled) { |
179 | do { | 179 | INIT_COMPLETION(radio->completion); |
180 | retval = si470x_get_register(radio, STATUSRSSI); | 180 | |
181 | if (retval < 0) | 181 | /* wait till tune operation has completed */ |
182 | goto stop; | 182 | retval = wait_for_completion_timeout(&radio->completion, |
183 | timed_out = time_after(jiffies, timeout); | 183 | msecs_to_jiffies(tune_timeout)); |
184 | } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) && | 184 | if (!retval) |
185 | (!timed_out)); | 185 | timed_out = true; |
186 | } else { | ||
187 | /* wait till tune operation has completed */ | ||
188 | timeout = jiffies + msecs_to_jiffies(tune_timeout); | ||
189 | do { | ||
190 | retval = si470x_get_register(radio, STATUSRSSI); | ||
191 | if (retval < 0) | ||
192 | goto stop; | ||
193 | timed_out = time_after(jiffies, timeout); | ||
194 | } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) | ||
195 | && (!timed_out)); | ||
196 | } | ||
197 | |||
186 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) | 198 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) |
187 | dev_warn(&radio->videodev->dev, "tune does not complete\n"); | 199 | dev_warn(&radio->videodev->dev, "tune does not complete\n"); |
188 | if (timed_out) | 200 | if (timed_out) |
@@ -310,15 +322,27 @@ static int si470x_set_seek(struct si470x_device *radio, | |||
310 | if (retval < 0) | 322 | if (retval < 0) |
311 | goto done; | 323 | goto done; |
312 | 324 | ||
313 | /* wait till seek operation has completed */ | 325 | /* currently I2C driver only uses interrupt way to seek */ |
314 | timeout = jiffies + msecs_to_jiffies(seek_timeout); | 326 | if (radio->stci_enabled) { |
315 | do { | 327 | INIT_COMPLETION(radio->completion); |
316 | retval = si470x_get_register(radio, STATUSRSSI); | 328 | |
317 | if (retval < 0) | 329 | /* wait till seek operation has completed */ |
318 | goto stop; | 330 | retval = wait_for_completion_timeout(&radio->completion, |
319 | timed_out = time_after(jiffies, timeout); | 331 | msecs_to_jiffies(seek_timeout)); |
320 | } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) && | 332 | if (!retval) |
321 | (!timed_out)); | 333 | timed_out = true; |
334 | } else { | ||
335 | /* wait till seek operation has completed */ | ||
336 | timeout = jiffies + msecs_to_jiffies(seek_timeout); | ||
337 | do { | ||
338 | retval = si470x_get_register(radio, STATUSRSSI); | ||
339 | if (retval < 0) | ||
340 | goto stop; | ||
341 | timed_out = time_after(jiffies, timeout); | ||
342 | } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) | ||
343 | && (!timed_out)); | ||
344 | } | ||
345 | |||
322 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) | 346 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) |
323 | dev_warn(&radio->videodev->dev, "seek does not complete\n"); | 347 | dev_warn(&radio->videodev->dev, "seek does not complete\n"); |
324 | if (radio->registers[STATUSRSSI] & STATUSRSSI_SF) | 348 | if (radio->registers[STATUSRSSI] & STATUSRSSI_SF) |