From patchwork Wed Sep 7 16:46:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12969277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1AA8CC38145 for ; Wed, 7 Sep 2022 16:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=juXBylppkvCeLwXp2xZRph98czpj9YC7O6ogOfgdDAg=; b=3EC8PF/exIWaKm vITb9vTZSvMMtfsPbA1YvkT2mfCYrvnoGdcnxhKSZ+wg01VpzEM84sXIv+53QNY54BKSIMQGP6c/q 9bgaOX2uQ/Jto3oa7uj/cC48O+YdFzhO6Kkytan2MmOtWir7uC9AgUaXAD+s2izwApplakilq4uka bqNI3t9qViIkkMJwnk9fGCpPP8PnR/+CbCufV4IfLDjs4h65i8Lk5YEjHitv+SZdacyfGCxIHM4jF 5seNdT8bxQ6e5tVfNd7z6BejjxT8Ql+S2+5etL8UWwhI4EdzoC7QGipvIWKc9BXDlk9QTrvLAq8Eb mMEnKtIG/Si67QZTTWYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVyLb-007yMX-A0; Wed, 07 Sep 2022 16:56:19 +0000 Received: from mga03.intel.com ([134.134.136.65]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVyLY-007yKA-FZ for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 16:56:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662569776; x=1694105776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6djZzfesjXmWCyiZuKYgE8QLWSt9qAJBAVV89VeFhJk=; b=EFNFizFjzPLdxxImURU1ecdEIsoku5iVw3UiZ8Ic74SFoarJ2HDH6nWA NbXxRo5vkTXyS964LpjflV+J05Sy9PHdCtz7VoheayH+5ALl5KKbjVw6H Gidg+M7cJPoEXtzMYhph+n75lW9Cjulx+2uoJRkOGigROwR+3kZXi0/Qs XDDyXi4ic2pGXFrz+jOo8vTLAKFVDp6AT01dCsAb2wqPWzZtF2eoJI3Rd pW3QmIiNfvwo/TEMBvn85XoyEJcrA9HKHP4IZRkg/oaYvlVseAGfE6Vlg iLk8CWmqOLIxHUiE3ynIJCwmlWMm4R5nVxacyKSQzQ51SoHpS3KMEbHsh Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10463"; a="298272031" X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="298272031" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2022 09:46:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,297,1654585200"; d="scan'208";a="682886539" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 07 Sep 2022 09:46:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 427CF6CD; Wed, 7 Sep 2022 19:46:12 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Andy Shevchenko , Wolfram Sang , Hans de Goede , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, devel@acpica.org Cc: "Rafael J. Wysocki" , Len Brown , Ard Biesheuvel , Elie Morisse , Nehal Shah , Shyam Sundar S K , Khalil Blaiech , Andy Gross , Bjorn Andersson , Konrad Dybcio , Will Deacon , Mark Rutland , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown , Robert Moore , Wolfram Sang Subject: [PATCH v1 8/8] efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer() Date: Wed, 7 Sep 2022 19:46:06 +0300 Message-Id: <20220907164606.65742-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> References: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220907_095616_603361_DDC574C2 X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach. Signed-off-by: Andy Shevchenko Reviewed-by: Ard Biesheuvel --- drivers/firmware/efi/dev-path-parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c index eb9c65f97841..113b3ca1bd76 100644 --- a/drivers/firmware/efi/dev-path-parser.c +++ b/drivers/firmware/efi/dev-path-parser.c @@ -15,9 +15,11 @@ static long __init parse_acpi_path(const struct efi_dev_path *node, struct device *parent, struct device **child) { - char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */ struct acpi_device *adev; struct device *phys_dev; + char hid[ACPI_ID_LEN]; + long ret; + u64 uid; if (node->header.length != 12) return -EINVAL; @@ -27,12 +29,12 @@ static long __init parse_acpi_path(const struct efi_dev_path *node, 'A' + ((node->acpi.hid >> 5) & 0x1f) - 1, 'A' + ((node->acpi.hid >> 0) & 0x1f) - 1, node->acpi.hid >> 16); - sprintf(uid, "%u", node->acpi.uid); for_each_acpi_dev_match(adev, hid, NULL, -1) { - if (adev->pnp.unique_id && !strcmp(adev->pnp.unique_id, uid)) + ret = acpi_dev_uid_to_integer(adev, &uid); + if (ret == -ENODATA && node->acpi.uid == 0) break; - if (!adev->pnp.unique_id && node->acpi.uid == 0) + if (ret == 0 && node->acpi.uid == uid) break; } if (!adev)