Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] ACPI / sleep: Switch to use acpi_dev_get_first_match_dev()
@ 2019-06-12 10:07 Andy Shevchenko
  2019-06-27 21:47 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2019-06-12 10:07 UTC (permalink / raw)
  To: Rafael J. Wysocki, linux-acpi; +Cc: Andy Shevchenko

Switch the acpi_pm_finish() to use acpi_dev_get_first_match_dev() instead of
custom approach.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/sleep.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 8ff08e531443..a94519207dc8 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -452,14 +452,6 @@ static int acpi_pm_prepare(void)
 	return error;
 }
 
-static int find_powerf_dev(struct device *dev, void *data)
-{
-	struct acpi_device *device = to_acpi_device(dev);
-	const char *hid = acpi_device_hid(device);
-
-	return !strcmp(hid, ACPI_BUTTON_HID_POWERF);
-}
-
 /**
  *	acpi_pm_finish - Instruct the platform to leave a sleep state.
  *
@@ -468,7 +460,7 @@ static int find_powerf_dev(struct device *dev, void *data)
  */
 static void acpi_pm_finish(void)
 {
-	struct device *pwr_btn_dev;
+	struct acpi_device *pwr_btn_adev;
 	u32 acpi_state = acpi_target_sleep_state;
 
 	acpi_ec_unblock_transactions();
@@ -499,11 +491,11 @@ static void acpi_pm_finish(void)
 		return;
 
 	pwr_btn_event_pending = false;
-	pwr_btn_dev = bus_find_device(&acpi_bus_type, NULL, NULL,
-				      find_powerf_dev);
-	if (pwr_btn_dev) {
-		pm_wakeup_event(pwr_btn_dev, 0);
-		put_device(pwr_btn_dev);
+	pwr_btn_adev = acpi_dev_get_first_match_dev(ACPI_BUTTON_HID_POWERF,
+						    NULL, -1);
+	if (pwr_btn_adev) {
+		pm_wakeup_event(&pwr_btn_adev->dev, 0);
+		acpi_dev_put(pwr_btn_adev);
 	}
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] ACPI / sleep: Switch to use acpi_dev_get_first_match_dev()
  2019-06-12 10:07 [PATCH v1] ACPI / sleep: Switch to use acpi_dev_get_first_match_dev() Andy Shevchenko
@ 2019-06-27 21:47 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-06-27 21:47 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-acpi

On Wednesday, June 12, 2019 12:07:02 PM CEST Andy Shevchenko wrote:
> Switch the acpi_pm_finish() to use acpi_dev_get_first_match_dev() instead of
> custom approach.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/acpi/sleep.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 8ff08e531443..a94519207dc8 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -452,14 +452,6 @@ static int acpi_pm_prepare(void)
>  	return error;
>  }
>  
> -static int find_powerf_dev(struct device *dev, void *data)
> -{
> -	struct acpi_device *device = to_acpi_device(dev);
> -	const char *hid = acpi_device_hid(device);
> -
> -	return !strcmp(hid, ACPI_BUTTON_HID_POWERF);
> -}
> -
>  /**
>   *	acpi_pm_finish - Instruct the platform to leave a sleep state.
>   *
> @@ -468,7 +460,7 @@ static int find_powerf_dev(struct device *dev, void *data)
>   */
>  static void acpi_pm_finish(void)
>  {
> -	struct device *pwr_btn_dev;
> +	struct acpi_device *pwr_btn_adev;
>  	u32 acpi_state = acpi_target_sleep_state;
>  
>  	acpi_ec_unblock_transactions();
> @@ -499,11 +491,11 @@ static void acpi_pm_finish(void)
>  		return;
>  
>  	pwr_btn_event_pending = false;
> -	pwr_btn_dev = bus_find_device(&acpi_bus_type, NULL, NULL,
> -				      find_powerf_dev);
> -	if (pwr_btn_dev) {
> -		pm_wakeup_event(pwr_btn_dev, 0);
> -		put_device(pwr_btn_dev);
> +	pwr_btn_adev = acpi_dev_get_first_match_dev(ACPI_BUTTON_HID_POWERF,
> +						    NULL, -1);
> +	if (pwr_btn_adev) {
> +		pm_wakeup_event(&pwr_btn_adev->dev, 0);
> +		acpi_dev_put(pwr_btn_adev);
>  	}
>  }
>  
> 

Applied, thanks!





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 10:07 [PATCH v1] ACPI / sleep: Switch to use acpi_dev_get_first_match_dev() Andy Shevchenko
2019-06-27 21:47 ` Rafael J. Wysocki

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org linux-acpi@archiver.kernel.org
	public-inbox-index linux-acpi


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/ public-inbox