linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: PM: Unexport acpi_device_get_power()
@ 2019-07-03 23:02 Rafael J. Wysocki
  2019-07-04  7:46 ` Mika Westerberg
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2019-07-03 23:02 UTC (permalink / raw)
  To: Linux ACPI; +Cc: Linux PM, LKML, Mika Westerberg

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Using acpi_device_get_power() outside of ACPI device initialization
and ACPI sysfs is problematic due to the way in which power resources
are handled by it, so unexport it and add a paragraph explaining the
pitfalls to its kerneldoc comment.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

On top of the linux-next branch in the linux-pm.git tree.

---
 drivers/acpi/device_pm.c |    6 +++++-
 drivers/acpi/internal.h  |    7 +++++++
 include/acpi/acpi_bus.h  |    1 -
 3 files changed, 12 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/acpi/device_pm.c
===================================================================
--- linux-pm.orig/drivers/acpi/device_pm.c
+++ linux-pm/drivers/acpi/device_pm.c
@@ -66,6 +66,11 @@ static int acpi_dev_pm_explicit_get(stru
  * This function does not update the device's power.state field, but it may
  * update its parent's power.state field (when the parent's power state is
  * unknown and the device's power state turns out to be D0).
+ *
+ * Also, it does not update power resource reference counters to ensure that
+ * the power state returned by it will be persistent and it may return a power
+ * state shallower than previously set by acpi_device_set_power() for @device
+ * (if that power state depends on any power resources).
  */
 int acpi_device_get_power(struct acpi_device *device, int *state)
 {
@@ -130,7 +135,6 @@ int acpi_device_get_power(struct acpi_de
 
 	return 0;
 }
-EXPORT_SYMBOL(acpi_device_get_power);
 
 static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
 {
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -506,7 +506,6 @@ int acpi_bus_get_status(struct acpi_devi
 
 int acpi_bus_set_power(acpi_handle handle, int state);
 const char *acpi_power_state_string(int state);
-int acpi_device_get_power(struct acpi_device *device, int *state);
 int acpi_device_set_power(struct acpi_device *device, int state);
 int acpi_bus_init_power(struct acpi_device *device);
 int acpi_device_fix_up_power(struct acpi_device *device);
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -139,8 +139,15 @@ int acpi_power_get_inferred_state(struct
 int acpi_power_on_resources(struct acpi_device *device, int state);
 int acpi_power_transition(struct acpi_device *device, int state);
 
+/* --------------------------------------------------------------------------
+                              Device Power Management
+   -------------------------------------------------------------------------- */
+int acpi_device_get_power(struct acpi_device *device, int *state);
 int acpi_wakeup_device_init(void);
 
+/* --------------------------------------------------------------------------
+                                  Processor
+   -------------------------------------------------------------------------- */
 #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
 void acpi_early_processor_set_pdc(void);
 #else




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

* Re: [PATCH] ACPI: PM: Unexport acpi_device_get_power()
  2019-07-03 23:02 [PATCH] ACPI: PM: Unexport acpi_device_get_power() Rafael J. Wysocki
@ 2019-07-04  7:46 ` Mika Westerberg
  2019-07-05  9:46   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2019-07-04  7:46 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux ACPI, Linux PM, LKML

On Thu, Jul 04, 2019 at 01:02:49AM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Using acpi_device_get_power() outside of ACPI device initialization
> and ACPI sysfs is problematic due to the way in which power resources
> are handled by it, so unexport it and add a paragraph explaining the
> pitfalls to its kerneldoc comment.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Makes perfect sense!

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH] ACPI: PM: Unexport acpi_device_get_power()
  2019-07-04  7:46 ` Mika Westerberg
@ 2019-07-05  9:46   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2019-07-05  9:46 UTC (permalink / raw)
  To: Mika Westerberg; +Cc: Linux ACPI, Linux PM, LKML

On Thursday, July 4, 2019 9:46:40 AM CEST Mika Westerberg wrote:
> On Thu, Jul 04, 2019 at 01:02:49AM +0200, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > 
> > Using acpi_device_get_power() outside of ACPI device initialization
> > and ACPI sysfs is problematic due to the way in which power resources
> > are handled by it, so unexport it and add a paragraph explaining the
> > pitfalls to its kerneldoc comment.
> > 
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> 
> Makes perfect sense!
> 
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> 

Thanks!

I've queued this one for 5.3.





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

end of thread, other threads:[~2019-07-05  9:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03 23:02 [PATCH] ACPI: PM: Unexport acpi_device_get_power() Rafael J. Wysocki
2019-07-04  7:46 ` Mika Westerberg
2019-07-05  9:46   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).