From patchwork Wed Dec 18 06:58:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 3368241 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3630C0D4A for ; Wed, 18 Dec 2013 07:00:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1BE44203EC for ; Wed, 18 Dec 2013 07:00:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61C57203E9 for ; Wed, 18 Dec 2013 07:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752888Ab3LRG5r (ORCPT ); Wed, 18 Dec 2013 01:57:47 -0500 Received: from mga14.intel.com ([143.182.124.37]:58557 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752390Ab3LRG5p (ORCPT ); Wed, 18 Dec 2013 01:57:45 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 17 Dec 2013 22:57:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,506,1384329600"; d="scan'208";a="328666754" Received: from gerry-dev.bj.intel.com ([10.238.158.74]) by AZSMGA002.ch.intel.com with ESMTP; 17 Dec 2013 22:57:41 -0800 From: Jiang Liu To: "Rafael J . Wysocki" , Bjorn Helgaas , Lv Zheng , Len Brown , Leonidas Da Silva Barbosa , Ashley Lai , Peter Huewe , Rajiv Andrade , Marcel Selhorst , Sirrix AG , Daniel Vetter , David Airlie , Jiri Kosina , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiang Liu , Tony Luck Subject: [RFC Patch v1 05/13] PCI, pci-label: treat PCI label with index 0 as valid label Date: Wed, 18 Dec 2013 14:58:13 +0800 Message-Id: <1387349901-3391-6-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387349901-3391-1-git-send-email-jiang.liu@linux.intel.com> References: <1387349901-3391-1-git-send-email-jiang.liu@linux.intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.4 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 Current pci-label driver detects ACPI label by checking label index returned by ACPI _DSM method, and treat it as valid if label index is positive. According to ACPI Firmware specification 3.1, zero is also an valid label index. So change code to detect availability of ACPI slot label by checking availaiblity of ACPI _DSM function for PCI label. Signed-off-by: Jiang Liu --- drivers/pci/pci-label.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index f12dcd1..0260b14 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c @@ -187,7 +187,6 @@ static const char device_label_dsm_uuid[] = { }; enum acpi_attr_enum { - ACPI_ATTR_NONE = 0, ACPI_ATTR_LABEL_SHOW, ACPI_ATTR_INDEX_SHOW, }; @@ -222,20 +221,16 @@ dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr) if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 && tmp[0].type == ACPI_TYPE_INTEGER && tmp[1].type == ACPI_TYPE_STRING) { - len = tmp[0].integer.value; - if (buf) { - /* - * This second string element is optional even when - * this _DSM is implemented; when not implemented, - * this entry must return a null string. - */ - if (attr == ACPI_ATTR_INDEX_SHOW) - scnprintf(buf, PAGE_SIZE, "%llu\n", - tmp->integer.value); - else if (attr == ACPI_ATTR_LABEL_SHOW) - dsm_label_utf16s_to_utf8s(tmp + 1, buf); - len = strlen(buf) > 0 ? strlen(buf) : -1; - } + /* + * The second string element is optional even when + * this _DSM is implemented; when not implemented, + * this entry must return a null string. + */ + if (attr == ACPI_ATTR_INDEX_SHOW) + scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value); + else if (attr == ACPI_ATTR_LABEL_SHOW) + dsm_label_utf16s_to_utf8s(tmp + 1, buf); + len = strlen(buf) > 0 ? strlen(buf) : -1; } ACPI_FREE(obj); @@ -246,7 +241,14 @@ dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr) static bool device_has_dsm(struct device *dev) { - return dsm_get_label(dev, NULL, ACPI_ATTR_NONE) > 0; + acpi_handle handle; + + handle = ACPI_HANDLE(dev); + if (!handle) + return false; + + return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2, + 1 << DEVICE_LABEL_DSM); } static umode_t