Skip to contentSkip to conversation

drivers/irqchip: Remove function callback casts

PATCH Superseded Oscar Carter 2 participants 5 messages May 24, 2020 – May 26, 2020 irqchip drivers

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/irqchip: Remove function callback casts

In an effort to enable -Wcast-function-type in the top-level Makefile to support Control Flow Integrity builds, remove all the function callback casts.

To do this, modify the IRQCHIP_ACPI_DECLARE macro initializing the acpi_probe_entry struct directly instead of use the existent macro ACPI_DECLARE_PROBE_ENTRY.

In this new initialization use the probe_subtbl field instead of the probe_table field use in the ACPI_DECLARE_PROBE_ENTRY macro.

---
 include/linux/irqchip.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/linux/irqchip.h +8 -2
index 950e4b2458f0..1f464fd10df0 100644
@@ -39,8 +39,14 @@
  * @fn: initialization function
  */
 #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)	\
-	ACPI_DECLARE_PROBE_ENTRY(irqchip, name, ACPI_SIG_MADT, 		\
-				 subtable, validate, data, fn)
+	static const struct acpi_probe_entry __acpi_probe_##name	\
+		__used __section(__irqchip_acpi_probe_table) = {	\
+			.id = ACPI_SIG_MADT,				\
+			.type = subtable,				\
+			.subtable_valid = validate,			\
+			.probe_subtbl = (acpi_tbl_entry_handler)fn,	\
+			.driver_data = data,				\
+		}
 
 #ifdef CONFIG_IRQCHIP
 void irqchip_init(void);

--
2.20.1

#1 lore raw

On Sun, 24 May 2020 10:09:10 +0200
Oscar Carter <[email protected]> wrote:

Hi Oscar,

Thanks for this. Comments below.

Quoted 10 lines

In an effort to enable -Wcast-function-type in the top-level Makefile to support Control Flow Integrity builds, remove all the function callback casts.

To do this, modify the IRQCHIP_ACPI_DECLARE macro initializing the acpi_probe_entry struct directly instead of use the existent macro ACPI_DECLARE_PROBE_ENTRY.

In this new initialization use the probe_subtbl field instead of the probe_table field use in the ACPI_DECLARE_PROBE_ENTRY macro.

Please add *why* this is a valid transformation (probe_table and probe_subtbl are part of a union).

Quoted 15 lines
---
 include/linux/irqchip.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/linux/irqchip.h +0 -1
index 950e4b2458f0..1f464fd10df0 100644
@@ -39,8 +39,14 @@
  * @fn: initialization function
  */
 #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)	\
-	ACPI_DECLARE_PROBE_ENTRY(irqchip, name, ACPI_SIG_MADT, 		\

include/linux/irqchip.h line 50

Quoted 10 lines
include/linux/irqchip.h +8 -1
-				 subtable, validate, data, fn)
+	static const struct acpi_probe_entry __acpi_probe_##name	\
+		__used __section(__irqchip_acpi_probe_table) = {	\
+			.id = ACPI_SIG_MADT,				\
+			.type = subtable,				\
+			.subtable_valid = validate,			\
+			.probe_subtbl = (acpi_tbl_entry_handler)fn,	\
+			.driver_data = data,				\
+		}
 

I'd rather you add an ACPI_DECLARE_SUBTABLE_PROBE_ENTRY to acpi.h, and use that here so that we can keep the ACPI gunk in a single place.

Quoted 6 lines
include/linux/irqchip.h +0 -1
 #ifdef CONFIG_IRQCHIP
 void irqchip_init(void);
--

2.20.1

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw

Hi Marc,

Quoted 15 lines · Marc Zyngier

On Sun, 24 May 2020 10:09:10 +0200
Oscar Carter <[email protected]> wrote:

Hi Oscar,

Thanks for this. Comments below.

Quoted 8 lines

In an effort to enable -Wcast-function-type in the top-level Makefile to support Control Flow Integrity builds, remove all the function callback casts.

To do this, modify the IRQCHIP_ACPI_DECLARE macro initializing the acpi_probe_entry struct directly instead of use the existent macro ACPI_DECLARE_PROBE_ENTRY.

Quoted 5 lines
Quoted 2 lines

In this new initialization use the probe_subtbl field instead of the probe_table field use in the ACPI_DECLARE_PROBE_ENTRY macro.

Please add *why* this is a valid transformation (probe_table and probe_subtbl are part of a union).

Ok, I will add a more detailed explanation.

Quoted 19 lines
Quoted 19 lines
---
 include/linux/irqchip.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/linux/irqchip.h +4 -2
index 950e4b2458f0..1f464fd10df0 100644
@@ -39,8 +39,14 @@
  * @fn: initialization function
  */
 #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)	\
-	ACPI_DECLARE_PROBE_ENTRY(irqchip, name, ACPI_SIG_MADT, 		\
-				 subtable, validate, data, fn)
+	static const struct acpi_probe_entry __acpi_probe_##name	\
+		__used __section(__irqchip_acpi_probe_table) = {	\
+			.id = ACPI_SIG_MADT,				\
+			.type = subtable,				\
Quoted 8 lines

include/linux/irqchip.h line 50

Quoted 5 lines
include/linux/irqchip.h +4 -0
+			.subtable_valid = validate,			\
+			.probe_subtbl = (acpi_tbl_entry_handler)fn,	\
+			.driver_data = data,				\
+		}
 

I'd rather you add an ACPI_DECLARE_SUBTABLE_PROBE_ENTRY to acpi.h, and use that here so that we can keep the ACPI gunk in a single place.

Ok, I will do the changes you suggested and I will resend a new version. Later, I will also send a series to clean up the checkpatch warnings and errors for the acpi.h header.

Quoted 7 lines
Quoted 6 lines
include/linux/irqchip.h +0 -1
 #ifdef CONFIG_IRQCHIP
 void irqchip_init(void);
--

2.20.1

Quoted 5 lines

Thanks,

	M.

--
Jazz is not dead. It just smells funny...

Thanks,
Oscar Carter

#3 lore raw
Quoted 54 lines · Oscar Carter

Hi Marc,

Quoted 15 lines · Marc Zyngier

On Sun, 24 May 2020 10:09:10 +0200
Oscar Carter <[email protected]> wrote:

Hi Oscar,

Thanks for this. Comments below.

Quoted 8 lines

In an effort to enable -Wcast-function-type in the top-level Makefile to support Control Flow Integrity builds, remove all the function callback casts.

To do this, modify the IRQCHIP_ACPI_DECLARE macro initializing the acpi_probe_entry struct directly instead of use the existent macro ACPI_DECLARE_PROBE_ENTRY.

Quoted 5 lines
Quoted 2 lines

In this new initialization use the probe_subtbl field instead of the probe_table field use in the ACPI_DECLARE_PROBE_ENTRY macro.

Please add *why* this is a valid transformation (probe_table and probe_subtbl are part of a union).

Ok, I will add a more detailed explanation.

Quoted 19 lines
Quoted 19 lines
---
 include/linux/irqchip.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
include/linux/irqchip.h +4 -2
index 950e4b2458f0..1f464fd10df0 100644
@@ -39,8 +39,14 @@
  * @fn: initialization function
  */
 #define IRQCHIP_ACPI_DECLARE(name, subtable, validate, data, fn)	\
-	ACPI_DECLARE_PROBE_ENTRY(irqchip, name, ACPI_SIG_MADT, 		\
-				 subtable, validate, data, fn)
+	static const struct acpi_probe_entry __acpi_probe_##name	\
+		__used __section(__irqchip_acpi_probe_table) = {	\
+			.id = ACPI_SIG_MADT,				\
+			.type = subtable,				\
Quoted 8 lines

include/linux/irqchip.h line 50

Quoted 5 lines
include/linux/irqchip.h +4 -0
+			.subtable_valid = validate,			\
+			.probe_subtbl = (acpi_tbl_entry_handler)fn,	\
+			.driver_data = data,				\
+		}
 

I'd rather you add an ACPI_DECLARE_SUBTABLE_PROBE_ENTRY to acpi.h, and use that here so that we can keep the ACPI gunk in a single place.

Quoted 3 lines

Ok, I will do the changes you suggested and I will resend a new version. Later, I will also send a series to clean up the checkpatch warnings and errors for the acpi.h header.

Not necessarily a good idea. Churn for the sake of keeping checkpatch at bay is pretty pointless. Do fix bugs if you spot any, but please exercise judgement.

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw

Hi Marc,

Quoted 9 lines · Marc Zyngier
Quoted 3 lines · Oscar Carter

Ok, I will do the changes you suggested and I will resend a new version. Later, I will also send a series to clean up the checkpatch warnings and errors for the acpi.h header.

Not necessarily a good idea. Churn for the sake of keeping checkpatch at bay is pretty pointless. Do fix bugs if you spot any, but please exercise judgement.

Ok, thanks for your advise. For now I will only fix the part related to this patch.

Quoted 5 lines

Thanks,

        M.

--
Jazz is not dead. It just smells funny...

Thanks,
Oscar