History

PCI/ACPI: add a helper for retrieving _OSC Control DWORDs

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.

Vishal Verma committed 4 years ago

Commit cc10eee1 parent 35e01663 files · +15 −2Browse files

Unified · Split

3 files
  1. drivers/acpi/bus.c +1 −1
  2. drivers/acpi/pci_root.c +1 −1
  3. include/linux/acpi.h +13 −0
drivers/acpi/bus.c+1−1
@@ -425,7 +425,7 @@ static void acpi_bus_osc_negotiate_usb_control(void) · 424 unmodified lines
425425 }
426426
427427 osc_sb_native_usb4_control =
428− control & ((u32 *)context.ret.pointer)[OSC_CONTROL_DWORD];
428+ control & acpi_osc_ctx_get_pci_control(&context);
429429
430430 acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control);
431431 acpi_bus_decode_usb_osc("USB4 _OSC: OS controls",
drivers/acpi/pci_root.c+1−1
@@ -183,7 +183,7 @@ static acpi_status acpi_pci_run_osc(acpi_handle handle, · 182 unmodified lines
183183
184184 status = acpi_run_osc(handle, &context);
185185 if (ACPI_SUCCESS(status)) {
186− *retval = *((u32 *)(context.ret.pointer + 8));
186+ *retval = acpi_osc_ctx_get_pci_control(&context);
187187 kfree(context.ret.pointer);
188188 }
189189 return status;
include/linux/acpi.h+13−0
@@ -608,6 +608,13 @@ extern u32 osc_sb_native_usb4_control; · 607 unmodified lines
608608 #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020
609609 #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080
610610
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+
611618 #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002
612619 #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004
613620 #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006
@@ -1004,6 +1011,12 @@ static inline int acpi_register_wakeup_handler(int wake_irq, · 390 unmodified lines
10041011 static inline void acpi_unregister_wakeup_handler(
10051012 bool (*wakeup)(void *context), void *context) { }
10061013
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+
10071020 #endif /* !CONFIG_ACPI */
10081021
10091022 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t