mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 00:20:52 -05:00
media: msp3400: Use wait_event_freezable_timeout() in msp_sleep()
The msp_sleep() is nearly open-coded wait_event_interruptible_timeout(), and a freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. So we can reimplement msp_sleep() to simply invoke a wait_event_freezable_timeout() and then eliminate a call to try_to_freeze(). Signed-off-by: Kevin Hao <haokexin@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
ed917040eb
commit
7c17c55248
2 changed files with 7 additions and 15 deletions
|
@ -309,23 +309,15 @@ static void msp_wake_thread(struct i2c_client *client)
|
||||||
wake_up_interruptible(&state->wq);
|
wake_up_interruptible(&state->wq);
|
||||||
}
|
}
|
||||||
|
|
||||||
int msp_sleep(struct msp_state *state, int timeout)
|
int msp_sleep(struct msp_state *state, int msec)
|
||||||
{
|
{
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
long timeout;
|
||||||
|
|
||||||
add_wait_queue(&state->wq, &wait);
|
timeout = msec < 0 ? MAX_SCHEDULE_TIMEOUT : msecs_to_jiffies(msec);
|
||||||
if (!kthread_should_stop()) {
|
|
||||||
if (timeout < 0) {
|
wait_event_freezable_timeout(state->wq, kthread_should_stop() ||
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
state->restart, timeout);
|
||||||
schedule();
|
|
||||||
} else {
|
|
||||||
schedule_timeout_interruptible
|
|
||||||
(msecs_to_jiffies(timeout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_wait_queue(&state->wq, &wait);
|
|
||||||
try_to_freeze();
|
|
||||||
return state->restart;
|
return state->restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ int msp_read_dsp(struct i2c_client *client, int addr);
|
||||||
int msp_reset(struct i2c_client *client);
|
int msp_reset(struct i2c_client *client);
|
||||||
void msp_set_scart(struct i2c_client *client, int in, int out);
|
void msp_set_scart(struct i2c_client *client, int in, int out);
|
||||||
void msp_update_volume(struct msp_state *state);
|
void msp_update_volume(struct msp_state *state);
|
||||||
int msp_sleep(struct msp_state *state, int timeout);
|
int msp_sleep(struct msp_state *state, int msec);
|
||||||
|
|
||||||
/* msp3400-kthreads.c */
|
/* msp3400-kthreads.c */
|
||||||
const char *msp_standard_std_name(int std);
|
const char *msp_standard_std_name(int std);
|
||||||
|
|
Loading…
Reference in a new issue