From patchwork Wed Aug 13 16:56:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Ortiz X-Patchwork-Id: 4720021 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B8C199F377 for ; Wed, 13 Aug 2014 17:00:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39882201DC for ; Wed, 13 Aug 2014 17:00:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14447201C0 for ; Wed, 13 Aug 2014 17:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752852AbaHMRAZ (ORCPT ); Wed, 13 Aug 2014 13:00:25 -0400 Received: from mga09.intel.com ([134.134.136.24]:6973 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752829AbaHMRAY (ORCPT ); Wed, 13 Aug 2014 13:00:24 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 13 Aug 2014 09:54:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,857,1400050800"; d="scan'208";a="587638958" Received: from unknown (HELO zurbaran) ([10.237.24.32]) by orsmga002.jf.intel.com with ESMTP; 13 Aug 2014 09:59:52 -0700 From: Samuel Ortiz To: rjw@rjwysocki.net Cc: linux-acpi@vger.kernel.org, Faouaz TENOUTIT Subject: [PATCH v3 1/2] USB: Use ACPI device information Date: Wed, 13 Aug 2014 18:56:40 +0200 Message-Id: <1407949001-6567-1-git-send-email-sameo@linux.intel.com> X-Mailer: git-send-email 2.0.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Faouaz TENOUTIT Use ACPI device pld information instead of calling acpi_get_physical_device_location. Signed-off-by: Faouaz TENOUTIT Acked-by: Samuel Ortiz Acked-by: Greg Kroah-Hartman --- drivers/acpi/scan.c | 13 +++++++++++++ drivers/usb/core/usb-acpi.c | 14 +++++--------- include/acpi/acpi_bus.h | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0a817ad..2ca42d5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -767,6 +767,13 @@ static int acpi_device_setup_files(struct acpi_device *dev) &dev_attr_real_power_state); } + /* + * If device has _PLD, initialize the 'pld' struct + */ + if (acpi_has_method(dev->handle, "_PLD")) + acpi_get_physical_device_location(dev->handle, + &dev->pld); + end: return result; } @@ -806,6 +813,12 @@ static void acpi_device_remove_files(struct acpi_device *dev) device_remove_file(&dev->dev, &dev_attr_status); if (dev->handle) device_remove_file(&dev->dev, &dev_attr_path); + + /* + * If device has _PLD, free 'pld' struct + */ + if (dev->pld) + ACPI_FREE(dev->pld); } /* -------------------------------------------------------------------------- ACPI Bus operations diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c index 2776cfe..940b3e5 100644 --- a/drivers/usb/core/usb-acpi.c +++ b/drivers/usb/core/usb-acpi.c @@ -157,9 +157,6 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) } else if (is_usb_port(dev)) { struct usb_port *port_dev = to_usb_port(dev); int port1 = port_dev->portnum; - struct acpi_pld_info *pld; - acpi_handle *handle; - acpi_status status; /* Get the struct usb_device point of port's hub */ udev = to_usb_device(dev->parent->parent); @@ -190,15 +187,14 @@ static struct acpi_device *usb_acpi_find_companion(struct device *dev) if (!adev) return NULL; } - handle = adev->handle; - status = acpi_get_physical_device_location(handle, &pld); - if (ACPI_FAILURE(status) || !pld) + if (!adev->pld) return adev; port_dev->location = USB_ACPI_LOCATION_VALID - | pld->group_token << 8 | pld->group_position; - port_dev->connect_type = usb_acpi_get_connect_type(handle, pld); - ACPI_FREE(pld); + | adev->pld->group_token << 8 + | adev->pld->group_position; + port_dev->connect_type = usb_acpi_get_connect_type(adev->handle, + adev->pld); return adev; } diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index bcfd808..e439cfa 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -357,6 +357,7 @@ struct acpi_device { struct acpi_scan_handler *handler; struct acpi_hotplug_context *hp; struct acpi_driver *driver; + struct acpi_pld_info *pld; void *driver_data; struct device dev; unsigned int physical_node_count;