During _OSC negotiation, when the 'Control' DWORD is needed from the result buffer after running _OSC, a couple of places performed manual pointer arithmetic to offset into the right spot in the raw buffer. Add a acpi_osc_ctx_get_pci_control() helper to use the #define'd DWORD offsets to fetch the DWORDs needed from @acpi_osc_context, and replace the above instances of the open-coded arithmetic.
Unified · Split
| @@ -425,7 +425,7 @@ static void acpi_bus_osc_negotiate_usb_control(void) · 424 unmodified lines | |||
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | osc_sb_native_usb4_control = | 427 | osc_sb_native_usb4_control = |
| 428 | control & ((u32 *)context.ret.pointer)[OSC_CONTROL_DWORD]; | 428 | control & acpi_osc_ctx_get_pci_control(&context); |
| 429 | 429 | ||
| 430 | acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control); | 430 | acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control); |
| 431 | acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", | 431 | acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", |
| @@ -183,7 +183,7 @@ static acpi_status acpi_pci_run_osc(acpi_handle handle, · 182 unmodified lines | |||
| 183 | 183 | ||
| 184 | status = acpi_run_osc(handle, &context); | 184 | status = acpi_run_osc(handle, &context); |
| 185 | if (ACPI_SUCCESS(status)) { | 185 | if (ACPI_SUCCESS(status)) { |
| 186 | *retval = *((u32 *)(context.ret.pointer + 8)); | 186 | *retval = acpi_osc_ctx_get_pci_control(&context); |
| 187 | kfree(context.ret.pointer); | 187 | kfree(context.ret.pointer); |
| 188 | } | 188 | } |
| 189 | return status; | 189 | return status; |
| @@ -608,6 +608,13 @@ extern u32 osc_sb_native_usb4_control; · 607 unmodified lines | |||
| 608 | #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 | 608 | #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 |
| 609 | #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 | 609 | #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 |
| 610 | 610 | ||
| 611 | static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) | ||
| 612 | { | ||
| 613 | u32 *ret = context->ret.pointer; | ||
| 614 | |||
| 615 | return ret[OSC_CONTROL_DWORD]; | ||
| 616 | } | ||
| 617 | |||
| 611 | #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002 | 618 | #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002 |
| 612 | #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004 | 619 | #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004 |
| 613 | #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006 | 620 | #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006 |
| @@ -1004,6 +1011,12 @@ static inline int acpi_register_wakeup_handler(int wake_irq, · 390 unmodified lines | |||
| 1004 | static inline void acpi_unregister_wakeup_handler( | 1011 | static inline void acpi_unregister_wakeup_handler( |
| 1005 | bool (*wakeup)(void *context), void *context) { } | 1012 | bool (*wakeup)(void *context), void *context) { } |
| 1006 | 1013 | ||
| 1014 | struct acpi_osc_context; | ||
| 1015 | static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) | ||
| 1016 | { | ||
| 1017 | return 0; | ||
| 1018 | } | ||
| 1019 | |||
| 1007 | #endif /* !CONFIG_ACPI */ | 1020 | #endif /* !CONFIG_ACPI */ |
| 1008 | 1021 | ||
| 1009 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC | 1022 | #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC |