Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dsm: remove unnecessary dsm priv structure

Pass a local acpi_handle around instead of having a static dsm priv
structure. If we need it later, we can always move it to dev_priv, and
the change at hand will make that easier as well.

Care is taken to preserve old behaviour, particularly using the last
non-NULL acpi handle, whether it makes sense or not.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180614104709.2808-1-jani.nikula@intel.com

+11 -16
+11 -16
drivers/gpu/drm/i915/intel_acpi.c
··· 12 12 #define INTEL_DSM_REVISION_ID 1 /* For Calpella anyway... */ 13 13 #define INTEL_DSM_FN_PLATFORM_MUX_INFO 1 /* No args */ 14 14 15 - static struct intel_dsm_priv { 16 - acpi_handle dhandle; 17 - } intel_dsm_priv; 18 - 19 15 static const guid_t intel_dsm_guid = 20 16 GUID_INIT(0x7ed873d3, 0xc2d0, 0x4e4f, 21 17 0xa8, 0x54, 0x0f, 0x13, 0x17, 0xb0, 0x1c, 0x2c); ··· 68 72 } 69 73 } 70 74 71 - static void intel_dsm_platform_mux_info(void) 75 + static void intel_dsm_platform_mux_info(acpi_handle dhandle) 72 76 { 73 77 int i; 74 78 union acpi_object *pkg, *connector_count; 75 79 76 - pkg = acpi_evaluate_dsm_typed(intel_dsm_priv.dhandle, &intel_dsm_guid, 80 + pkg = acpi_evaluate_dsm_typed(dhandle, &intel_dsm_guid, 77 81 INTEL_DSM_REVISION_ID, INTEL_DSM_FN_PLATFORM_MUX_INFO, 78 82 NULL, ACPI_TYPE_PACKAGE); 79 83 if (!pkg) { ··· 103 107 ACPI_FREE(pkg); 104 108 } 105 109 106 - static bool intel_dsm_pci_probe(struct pci_dev *pdev) 110 + static acpi_handle intel_dsm_pci_probe(struct pci_dev *pdev) 107 111 { 108 112 acpi_handle dhandle; 109 113 110 114 dhandle = ACPI_HANDLE(&pdev->dev); 111 115 if (!dhandle) 112 - return false; 116 + return NULL; 113 117 114 118 if (!acpi_check_dsm(dhandle, &intel_dsm_guid, INTEL_DSM_REVISION_ID, 115 119 1 << INTEL_DSM_FN_PLATFORM_MUX_INFO)) { 116 120 DRM_DEBUG_KMS("no _DSM method for intel device\n"); 117 - return false; 121 + return NULL; 118 122 } 119 123 120 - intel_dsm_priv.dhandle = dhandle; 121 - intel_dsm_platform_mux_info(); 124 + intel_dsm_platform_mux_info(dhandle); 122 125 123 - return true; 126 + return dhandle; 124 127 } 125 128 126 129 static bool intel_dsm_detect(void) 127 130 { 131 + acpi_handle dhandle = NULL; 128 132 char acpi_method_name[255] = { 0 }; 129 133 struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name}; 130 134 struct pci_dev *pdev = NULL; 131 - bool has_dsm = false; 132 135 int vga_count = 0; 133 136 134 137 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 135 138 vga_count++; 136 - has_dsm |= intel_dsm_pci_probe(pdev); 139 + dhandle = intel_dsm_pci_probe(pdev) ?: dhandle; 137 140 } 138 141 139 - if (vga_count == 2 && has_dsm) { 140 - acpi_get_name(intel_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); 142 + if (vga_count == 2 && dhandle) { 143 + acpi_get_name(dhandle, ACPI_FULL_PATHNAME, &buffer); 141 144 DRM_DEBUG_DRIVER("vga_switcheroo: detected DSM switching method %s handle\n", 142 145 acpi_method_name); 143 146 return true;