aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/acpiphp_glue.c
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2013-06-28 12:24:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-14 19:33:10 -0400
commitecd046da57d3327367b930478234e58f01bc9f0f (patch)
tree2017b0ff08071275e4d9f05ea988b3f0eac0a9da /drivers/pci/hotplug/acpiphp_glue.c
parentc9b5471f8866956919955b70ab27b4737b8bce30 (diff)
ACPI: simplify acpiphp driver with new helper functions
Use the new helper functions introduced previously to simplify the ACPI-based PCI hotplug (acpiphp) driver. [rjw: Changelog] Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_glue.c')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 59df8575a48c..a0a7133a1d12 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -201,7 +201,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
201 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; 201 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context;
202 struct acpiphp_slot *slot; 202 struct acpiphp_slot *slot;
203 struct acpiphp_func *newfunc; 203 struct acpiphp_func *newfunc;
204 acpi_handle tmp;
205 acpi_status status = AE_OK; 204 acpi_status status = AE_OK;
206 unsigned long long adr, sun; 205 unsigned long long adr, sun;
207 int device, function, retval, found = 0; 206 int device, function, retval, found = 0;
@@ -232,19 +231,19 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
232 newfunc->handle = handle; 231 newfunc->handle = handle;
233 newfunc->function = function; 232 newfunc->function = function;
234 233
235 if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp))) 234 if (acpi_has_method(handle, "_EJ0"))
236 newfunc->flags = FUNC_HAS_EJ0; 235 newfunc->flags = FUNC_HAS_EJ0;
237 236
238 if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) 237 if (acpi_has_method(handle, "_STA"))
239 newfunc->flags |= FUNC_HAS_STA; 238 newfunc->flags |= FUNC_HAS_STA;
240 239
241 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS0", &tmp))) 240 if (acpi_has_method(handle, "_PS0"))
242 newfunc->flags |= FUNC_HAS_PS0; 241 newfunc->flags |= FUNC_HAS_PS0;
243 242
244 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) 243 if (acpi_has_method(handle, "_PS3"))
245 newfunc->flags |= FUNC_HAS_PS3; 244 newfunc->flags |= FUNC_HAS_PS3;
246 245
247 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) 246 if (acpi_has_method(handle, "_DCK"))
248 newfunc->flags |= FUNC_HAS_DCK; 247 newfunc->flags |= FUNC_HAS_DCK;
249 248
250 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); 249 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
@@ -843,25 +842,14 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
843 */ 842 */
844int acpiphp_eject_slot(struct acpiphp_slot *slot) 843int acpiphp_eject_slot(struct acpiphp_slot *slot)
845{ 844{
846 acpi_status status;
847 struct acpiphp_func *func; 845 struct acpiphp_func *func;
848 struct acpi_object_list arg_list;
849 union acpi_object arg;
850 846
851 list_for_each_entry(func, &slot->funcs, sibling) { 847 list_for_each_entry(func, &slot->funcs, sibling) {
852 /* We don't want to call _EJ0 on non-existing functions. */ 848 /* We don't want to call _EJ0 on non-existing functions. */
853 if ((func->flags & FUNC_HAS_EJ0)) { 849 if ((func->flags & FUNC_HAS_EJ0)) {
854 /* _EJ0 method take one argument */ 850 if (ACPI_FAILURE(acpi_evaluate_ej0(func->handle)))
855 arg_list.count = 1;
856 arg_list.pointer = &arg;
857 arg.type = ACPI_TYPE_INTEGER;
858 arg.integer.value = 1;
859
860 status = acpi_evaluate_object(func->handle, "_EJ0", &arg_list, NULL);
861 if (ACPI_FAILURE(status)) {
862 warn("%s: _EJ0 failed\n", __func__);
863 return -1; 851 return -1;
864 } else 852 else
865 break; 853 break;
866 } 854 }
867 } 855 }
@@ -1171,7 +1159,6 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type,
1171 */ 1159 */
1172void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle) 1160void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle)
1173{ 1161{
1174 acpi_handle dummy_handle;
1175 struct acpiphp_bridge *bridge; 1162 struct acpiphp_bridge *bridge;
1176 1163
1177 if (acpiphp_disabled) 1164 if (acpiphp_disabled)
@@ -1200,8 +1187,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle)
1200 get_device(&bus->dev); 1187 get_device(&bus->dev);
1201 1188
1202 if (!pci_is_root_bus(bridge->pci_bus) && 1189 if (!pci_is_root_bus(bridge->pci_bus) &&
1203 ACPI_SUCCESS(acpi_get_handle(bridge->handle, 1190 acpi_has_method(bridge->handle, "_EJ0")) {
1204 "_EJ0", &dummy_handle))) {
1205 dbg("found ejectable p2p bridge\n"); 1191 dbg("found ejectable p2p bridge\n");
1206 bridge->flags |= BRIDGE_HAS_EJ0; 1192 bridge->flags |= BRIDGE_HAS_EJ0;
1207 bridge->func = acpiphp_bridge_handle_to_function(handle); 1193 bridge->func = acpiphp_bridge_handle_to_function(handle);