drm/poll-helper: merge drm_kms_helper_poll_disable() and _fini()
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Wed, 2 Nov 2022 18:06:59 +0000 (21:06 +0300)
committerNeil Armstrong <neil.armstrong@linaro.org>
Thu, 5 Jan 2023 13:59:43 +0000 (14:59 +0100)
Merge drm_kms_helper_poll_disable() and drm_kms_helper_poll_fini() code
into a common helper function.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20221102180705.459294-2-dmitry.baryshkov@linaro.org
drivers/gpu/drm/drm_probe_helper.c

index 1ea053cef557ea052f4d0a9a4e5028fcc411008c..d07ad4c5696b87af7455ba3d2828a5b0c355f4d0 100644 (file)
@@ -802,6 +802,17 @@ bool drm_kms_helper_is_poll_worker(void)
 }
 EXPORT_SYMBOL(drm_kms_helper_is_poll_worker);
 
+static void drm_kms_helper_poll_disable_fini(struct drm_device *dev, bool fini)
+{
+       if (!dev->mode_config.poll_enabled)
+               return;
+
+       if (fini)
+               dev->mode_config.poll_enabled = false;
+
+       cancel_delayed_work_sync(&dev->mode_config.output_poll_work);
+}
+
 /**
  * drm_kms_helper_poll_disable - disable output polling
  * @dev: drm_device
@@ -818,9 +829,7 @@ EXPORT_SYMBOL(drm_kms_helper_is_poll_worker);
  */
 void drm_kms_helper_poll_disable(struct drm_device *dev)
 {
-       if (!dev->mode_config.poll_enabled)
-               return;
-       cancel_delayed_work_sync(&dev->mode_config.output_poll_work);
+       drm_kms_helper_poll_disable_fini(dev, false);
 }
 EXPORT_SYMBOL(drm_kms_helper_poll_disable);
 
@@ -858,11 +867,7 @@ EXPORT_SYMBOL(drm_kms_helper_poll_init);
  */
 void drm_kms_helper_poll_fini(struct drm_device *dev)
 {
-       if (!dev->mode_config.poll_enabled)
-               return;
-
-       dev->mode_config.poll_enabled = false;
-       cancel_delayed_work_sync(&dev->mode_config.output_poll_work);
+       drm_kms_helper_poll_disable_fini(dev, true);
 }
 EXPORT_SYMBOL(drm_kms_helper_poll_fini);