Skip to contentSkip to conversation

backports: backport ACPI_HANDLE(dev)

PATCH In review Emmanuel Grumbach 3 participants 5 messages Feb 11, 2014 – Feb 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backports: backport ACPI_HANDLE(dev)

From: Ido Yariv <[email protected]>

Depending on the kernel version it might either be defined in linux/device.h or not at all, in which case DEVICE_ACPI_HANDLE is used instead.

ACPI_HANDLE(dev) will be used by iwlwifi very soon.

---
 backport/backport-include/linux/acpi.h | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 backport/backport-include/linux/acpi.h
backport/backport-include/linux/acpi.h new file +40 -0
new file mode 100644
index 0000000..8a79143
@@ -0,0 +1,40 @@
+#ifndef __BACKPORT_LINUX_ACPI_H
+#define __BACKPORT_LINUX_ACPI_H
+#include_next <linux/acpi.h>
+#include_next <linux/device.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
+/*
+ * Backports
+ *
+ * commit 95f8a082b9b1ead0c2859f2a7b1ac91ff63d8765
+ * Author: Rafael J. Wysocki <[email protected]>
+ * Date:   Wed Nov 21 00:21:50 2012 +0100
+ *
+ *     ACPI / driver core: Introduce struct acpi_dev_node and related macros
+ *
+ *     To avoid adding an ACPI handle pointer to struct device on
+ *     architectures that don't use ACPI, or generally when CONFIG_ACPI is
+ *     not set, in which cases that pointer is useless, define struct
+ *     acpi_dev_node that will contain the handle pointer if CONFIG_ACPI is
+ *     set and will be empty otherwise and use it to represent the ACPI
+ *     device node field in struct device.
+ *
+ *     In addition to that define macros for reading and setting the ACPI
+ *     handle of a device that don't generate code when CONFIG_ACPI is
+ *     unset.  Modify the ACPI subsystem to use those macros instead of
+ *     referring to the given device's ACPI handle directly.
+ *
+ *     Signed-off-by: Rafael J. Wysocki <[email protected]>
+ *     Reviewed-by: Mika Westerberg <[email protected]>
+ *     Acked-by: Greg Kroah-Hartman <[email protected]>
+ */
+#ifdef CONFIG_ACPI
+#define ACPI_HANDLE(dev) DEVICE_ACPI_HANDLE(dev)
+#else
+#define ACPI_HANDLE(dev) (NULL)
+#endif /* CONFIG_ACPI */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */
+
+#endif /* __BACKPORT_LINUX_ACPI_H */
Signature · 1 line
1.8.3.2
#1 lore raw

Hmm, come to think of it...

backport/backport-include/linux/acpi.h line 4

Quoted 6 lines · Emmanuel Grumbach

+++ b/backport/backport-include/linux/acpi.h

backport/backport-include/linux/acpi.h new file +4 -0
@@ -0,0 +1,40 @@
+#ifndef __BACKPORT_LINUX_ACPI_H
+#define __BACKPORT_LINUX_ACPI_H
+#include_next <linux/acpi.h>
+#include_next <linux/device.h>

That include_next is probably wrong, if you really need linux/device.h you shouldn't use #include_next but a regular #include.

johannes

#2 lore raw

Hi,

Quoted 4 lines · Johannes Berg

Hmm, come to think of it...

On Tue, 2014-02-11 at 08:40 +0200, Emmanuel Grumbach wrote:

Quoted 9 lines

backport/backport-include/linux/acpi.h line 4

Quoted 6 lines

+++ b/backport/backport-include/linux/acpi.h

backport/backport-include/linux/acpi.h new file +4 -0
@@ -0,0 +1,40 @@
+#ifndef __BACKPORT_LINUX_ACPI_H
+#define __BACKPORT_LINUX_ACPI_H
+#include_next <linux/acpi.h>
+#include_next <linux/device.h>

That include_next is probably wrong, if you really need linux/device.h you shouldn't use #include_next but a regular #include.

My intention was to load the kernel's device.h and not backport's. The reason was that some definitions which are now part of acpi.h were defined by device.h in the past.

That being said, backport's device.h includes the kernel's version, so this can be modified to a regular #include and work just as well.

Cheers,
Ido.

#3 lore raw
Quoted 11 lines · Ido Yariv
Quoted 4 lines
Quoted 1 line

+#include_next <linux/device.h>

That include_next is probably wrong, if you really need linux/device.h you shouldn't use #include_next but a regular #include.

My intention was to load the kernel's device.h and not backport's. The reason was that some definitions which are now part of acpi.h were defined by device.h in the past.

That being said, backport's device.h includes the kernel's version, so this can be modified to a regular #include and work just as well.

Right. I just think it seems odd in terms of backport header style, and occasionally some backport header depends on some other backported thing, so a plain #include is the right thing at least in those cases. Not to mention that #include_next is a gcc-specific hack :)

johannes

#4 lore raw

PATCH v2 1/1 backports: backport ACPI_HANDLE(dev)

In earlier kernel versions the define for retrieving the acpi handle was called DEVICE_ACPI_HANDLE, so just use it.

---
Changes from v1:
- device.h is implicitly included by acpi.h in earlier kernel versions as well, so no need to include it at all

 backport/backport-include/linux/acpi.h | 39 ++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 backport/backport-include/linux/acpi.h
backport/backport-include/linux/acpi.h new file +39 -0
new file mode 100644
index 0000000..506df15
@@ -0,0 +1,39 @@
+#ifndef __BACKPORT_LINUX_ACPI_H
+#define __BACKPORT_LINUX_ACPI_H
+#include_next <linux/acpi.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
+/*
+ * Backports
+ *
+ * commit 95f8a082b9b1ead0c2859f2a7b1ac91ff63d8765
+ * Author: Rafael J. Wysocki <[email protected]>
+ * Date:   Wed Nov 21 00:21:50 2012 +0100
+ *
+ *     ACPI / driver core: Introduce struct acpi_dev_node and related macros
+ *
+ *     To avoid adding an ACPI handle pointer to struct device on
+ *     architectures that don't use ACPI, or generally when CONFIG_ACPI is
+ *     not set, in which cases that pointer is useless, define struct
+ *     acpi_dev_node that will contain the handle pointer if CONFIG_ACPI is
+ *     set and will be empty otherwise and use it to represent the ACPI
+ *     device node field in struct device.
+ *
+ *     In addition to that define macros for reading and setting the ACPI
+ *     handle of a device that don't generate code when CONFIG_ACPI is
+ *     unset.  Modify the ACPI subsystem to use those macros instead of
+ *     referring to the given device's ACPI handle directly.
+ *
+ *     Signed-off-by: Rafael J. Wysocki <[email protected]>
+ *     Reviewed-by: Mika Westerberg <[email protected]>
+ *     Acked-by: Greg Kroah-Hartman <[email protected]>
+ */
+#ifdef CONFIG_ACPI
+#define ACPI_HANDLE(dev) DEVICE_ACPI_HANDLE(dev)
+#else
+#define ACPI_HANDLE(dev) (NULL)
+#endif /* CONFIG_ACPI */
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */
+
+#endif /* __BACKPORT_LINUX_ACPI_H */
Signature · 1 line
1.8.5.3