diff mbox series

ACPI: video: improve PM notifer callback

Message ID 20220519143732.3804174-1-rui.zhang@intel.com
State Accepted
Commit 1934fee67593c561ef883761bf2ddee82f908ed9
Headers show
Series ACPI: video: improve PM notifer callback | expand

Commit Message

Zhang, Rui May 19, 2022, 2:37 p.m. UTC
PM notifier callbacks should check for supported events rather than filter
out the unsupported events. So that it won't break when a new event is
introduced.

No functional change in this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/acpi/acpi_video.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Comments

Rafael J. Wysocki May 19, 2022, 6:08 p.m. UTC | #1
On Thu, May 19, 2022 at 4:37 PM Zhang Rui <rui.zhang@intel.com> wrote:
>
> PM notifier callbacks should check for supported events rather than filter
> out the unsupported events. So that it won't break when a new event is
> introduced.
>
> No functional change in this patch.
>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/acpi/acpi_video.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 990ff5b0aeb8..e07782b1fbb6 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -1707,24 +1707,23 @@ static int acpi_video_resume(struct notifier_block *nb,
>         int i;
>
>         switch (val) {
> -       case PM_HIBERNATION_PREPARE:
> -       case PM_SUSPEND_PREPARE:
> -       case PM_RESTORE_PREPARE:
> -               return NOTIFY_DONE;
> -       }
> -
> -       video = container_of(nb, struct acpi_video_bus, pm_nb);
> -
> -       dev_info(&video->device->dev, "Restoring backlight state\n");
> +       case PM_POST_HIBERNATION:
> +       case PM_POST_SUSPEND:
> +       case PM_POST_RESTORE:
> +               video = container_of(nb, struct acpi_video_bus, pm_nb);
> +
> +               dev_info(&video->device->dev, "Restoring backlight state\n");
> +
> +               for (i = 0; i < video->attached_count; i++) {
> +                       video_device = video->attached_array[i].bind_info;
> +                       if (video_device && video_device->brightness)
> +                               acpi_video_device_lcd_set_level(video_device,
> +                                               video_device->brightness->curr);
> +               }
>
> -       for (i = 0; i < video->attached_count; i++) {
> -               video_device = video->attached_array[i].bind_info;
> -               if (video_device && video_device->brightness)
> -                       acpi_video_device_lcd_set_level(video_device,
> -                                       video_device->brightness->curr);
> +               return NOTIFY_OK;
>         }
> -
> -       return NOTIFY_OK;
> +       return NOTIFY_DONE;
>  }
>
>  static acpi_status
> --

Applied as 5.19 material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 990ff5b0aeb8..e07782b1fbb6 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1707,24 +1707,23 @@  static int acpi_video_resume(struct notifier_block *nb,
 	int i;
 
 	switch (val) {
-	case PM_HIBERNATION_PREPARE:
-	case PM_SUSPEND_PREPARE:
-	case PM_RESTORE_PREPARE:
-		return NOTIFY_DONE;
-	}
-
-	video = container_of(nb, struct acpi_video_bus, pm_nb);
-
-	dev_info(&video->device->dev, "Restoring backlight state\n");
+	case PM_POST_HIBERNATION:
+	case PM_POST_SUSPEND:
+	case PM_POST_RESTORE:
+		video = container_of(nb, struct acpi_video_bus, pm_nb);
+
+		dev_info(&video->device->dev, "Restoring backlight state\n");
+
+		for (i = 0; i < video->attached_count; i++) {
+			video_device = video->attached_array[i].bind_info;
+			if (video_device && video_device->brightness)
+				acpi_video_device_lcd_set_level(video_device,
+						video_device->brightness->curr);
+		}
 
-	for (i = 0; i < video->attached_count; i++) {
-		video_device = video->attached_array[i].bind_info;
-		if (video_device && video_device->brightness)
-			acpi_video_device_lcd_set_level(video_device,
-					video_device->brightness->curr);
+		return NOTIFY_OK;
 	}
-
-	return NOTIFY_OK;
+	return NOTIFY_DONE;
 }
 
 static acpi_status