media: pvrusb2: Use wait_event_freezable() for freezable kthread
authorKevin Hao <haokexin@gmail.com>
Thu, 21 Dec 2023 02:22:28 +0000 (10:22 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 16 Feb 2024 10:46:31 +0000 (11:46 +0100)
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 for the following snippet of code in a kernel thread loop:
  try_to_freeze();
  wait_event_interruptible();

We can change it to a simple wait_event_freezable() and then eliminate
a function call.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/usb/pvrusb2/pvrusb2-dvb.c

index 26811efe0fb58b32dbfe05c63cb1380e3704aa5c..6dd6c5a18251bdd322a2e07b1f594ac728ef3aff 100644 (file)
@@ -33,9 +33,6 @@ static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap)
        for (;;) {
                if (kthread_should_stop()) break;
 
-               /* Not sure about this... */
-               try_to_freeze();
-
                bp = pvr2_stream_get_ready_buffer(stream);
                if (bp != NULL) {
                        count = pvr2_buffer_get_count(bp);
@@ -62,8 +59,7 @@ static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap)
 
                /* Wait until more buffers become available or we're
                   told not to wait any longer. */
-               ret = wait_event_interruptible(
-                   adap->buffer_wait_data,
+               ret = wait_event_freezable(adap->buffer_wait_data,
                    (pvr2_stream_get_ready_count(stream) > 0) ||
                    kthread_should_stop());
                if (ret < 0) break;