[v5,2/5] Drivers: hv: allow non ACPI compilation for hv_is_hibernation_supported

Message ID 1675944939-22631-3-git-send-email-ssengar@linux.microsoft.com
State New
Headers
Series Device tree support for Hyper-V VMBus driver |

Commit Message

Saurabh Singh Sengar Feb. 9, 2023, 12:15 p.m. UTC
  acpi_sleep_state_supported() currently is defined only when
CONFIG_ACPI=y.  For future work to enable device tree builds, put this
function under #ifdef CONFIG_ACPI.  Otherwise, return 'false' from
hv_is_hibernation_supported() as Hyper-V guest configs using device
tree don't support hibernation.

Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
---
 drivers/hv/hv_common.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Rob Herring Feb. 9, 2023, 3:17 p.m. UTC | #1
On Thu, Feb 9, 2023 at 6:15 AM Saurabh Sengar
<ssengar@linux.microsoft.com> wrote:
>
> acpi_sleep_state_supported() currently is defined only when
> CONFIG_ACPI=y.  For future work to enable device tree builds, put this
> function under #ifdef CONFIG_ACPI.  Otherwise, return 'false' from
> hv_is_hibernation_supported() as Hyper-V guest configs using device
> tree don't support hibernation.
>
> Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> ---
>  drivers/hv/hv_common.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 52a6f89ccdbd..370ec20d1993 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
>
>  bool hv_is_hibernation_supported(void)
>  {
> +#ifdef CONFIG_ACPI
>         return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);

Rework the acpi_bus.h header so that this is defined for !CONFIG_ACPI:

static inline bool acpi_sleep_state_supported(u8 sleep_state) { return false; }

Then you don't need this change here. That or using IS_ENABLED() is
strongly preferred over #ifdefs.

Rob
  
Saurabh Singh Sengar Feb. 9, 2023, 5:29 p.m. UTC | #2
On Thu, Feb 09, 2023 at 09:17:45AM -0600, Rob Herring wrote:
> On Thu, Feb 9, 2023 at 6:15 AM Saurabh Sengar
> <ssengar@linux.microsoft.com> wrote:
> >
> > acpi_sleep_state_supported() currently is defined only when
> > CONFIG_ACPI=y.  For future work to enable device tree builds, put this
> > function under #ifdef CONFIG_ACPI.  Otherwise, return 'false' from
> > hv_is_hibernation_supported() as Hyper-V guest configs using device
> > tree don't support hibernation.
> >
> > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
> > Reviewed-by: Michael Kelley <mikelley@microsoft.com>
> > ---
> >  drivers/hv/hv_common.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > index 52a6f89ccdbd..370ec20d1993 100644
> > --- a/drivers/hv/hv_common.c
> > +++ b/drivers/hv/hv_common.c
> > @@ -234,7 +234,11 @@ EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
> >
> >  bool hv_is_hibernation_supported(void)
> >  {
> > +#ifdef CONFIG_ACPI
> >         return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
> 
> Rework the acpi_bus.h header so that this is defined for !CONFIG_ACPI:
> 
> static inline bool acpi_sleep_state_supported(u8 sleep_state) { return false; }

Sure,
acpi_bus.h doesn't get included in case of !ACPI, I will put this in include/linux/acpi.h

Regards,
Saurabh

> 
> Then you don't need this change here. That or using IS_ENABLED() is
> strongly preferred over #ifdefs.
> 
> Rob
  

Patch

diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 52a6f89ccdbd..370ec20d1993 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -234,7 +234,11 @@  EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
 
 bool hv_is_hibernation_supported(void)
 {
+#ifdef CONFIG_ACPI
 	return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
+#else
+	return false;
+#endif
 }
 EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);