Re: [PATCHv2 1/3] ACPI: Expose struct acpi_device and acpi_bus_get_device() to non-ACPI builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday, November 02, 2013 11:18:31 PM Rafael J. Wysocki wrote:
> On Friday, November 01, 2013 02:35:54 PM Jarkko Nikula wrote:
> > We may find use for struct acpi_device and acpi_bus_get_device() in generic
> > code without wanting to add #if IS_ENABLED(CONFIG_ACPI) churn there.
> > 
> > Code can use ACPI_HANDLE() test to let compiler optimize out code blocks
> > that are not used in !CONFIG_ACPI builds but structure definitions and
> > function stubs must be available.
> > 
> > This patch moves CONFIG_ACPI test so that struct acpi_device definition
> > is available for all builds that include acpi_bus.h and provides a stub for
> > acpi_bus_get_device().
> > 
> > Signed-off-by: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx>
> 
> This turns out the cause build problems to happen on some architectures.
> 
> I guess it's sufficient to simply define a stub struct acpi_device as
> 
> struct acpi_device {
> 	struct device dev;
> };
> 
> for !CONFIG_ACPI instead.

Generally, it is a bad idea to #include acpi_bus.h for !CONFIG_ACPI.

The appended patch works for me, sorry for stealing part of your changelog.

Thanks,
Rafael


---
From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Subject: ACPI: Define struct acpi_device for CONFIG_ACPI unset

We may find use for struct acpi_device and acpi_bus_get_device() in
generic code without wanting to add #if IS_ENABLED(CONFIG_ACPI) churn
there.

Code can use ACPI_HANDLE() test to let compiler optimize out code
blocks that are not used in !CONFIG_ACPI builds but structure
definitions and function stubs must be available.

Define a stub struct acpi_device for CONFIG_ACPI unset containing dev
as the only member and a stub acpi_bus_get_device() always returning
an error code.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
 include/linux/acpi.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

Index: linux-pm/include/linux/acpi.h
===================================================================
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -472,7 +472,17 @@ static inline bool acpi_driver_match_dev
 }
 
 #define ACPI_PTR(_ptr)	(NULL)
+typedef void * acpi_handle;
 
+struct acpi_device {
+	struct device dev;
+};
+
+static inline int acpi_bus_get_device(acpi_handle handle,
+				      struct acpi_device **device)
+{
+	return -ENODEV;
+}
 #endif	/* !CONFIG_ACPI */
 
 #ifdef CONFIG_ACPI

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux