Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3719988pxv; Mon, 26 Jul 2021 10:11:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgzHjHFvD4kL0GUJIGvRPeXN/dAV46kasomi0Jk+/H4D8QsvdgXeBjgUWwyuSWY9qQcddB X-Received: by 2002:a05:6402:49a:: with SMTP id k26mr22403167edv.279.1627319494106; Mon, 26 Jul 2021 10:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627319494; cv=none; d=google.com; s=arc-20160816; b=IxfA0XlgGXxocDZJhKxyy1MHhDCj091ThOcRWTD4ACvItPULDS/lWw31ULE2QvdwVX W0BMb5IzFWZwRnKW5DMchTxpNj8Iv6Vn5squNkyOTaqCR3u8YAxJ+4we5/Cc4ARfvPMw uo71VZaIG5+IjSU2aUGqrzQyF/YEp8aYdGrGhnZ3rPX29SVlnDrkTbtQ1SNTYDDwMRn9 uHXwB7Cwvafcovfs1nM2kHoaa2SG/Va/8PbQVw5gvacsVHsWtByZJPUGvcE11pr9pVex PMG6z58kqjB42N2IsUyRp30kNdCLHBy8C7Dl2jTTYGXPvHG7lYEz4l7yIYGPfd/DeEAE dT8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4Mc339uzRYf0maS+M+Y7zK7YsLStAvKknCVzi6cKla8=; b=nXSgCz6CLAlw9P8lCGD8KGr+FXxJhbLl7GgTbUrrGYi34UdIMcHTIKJzD8jPy0I8rv DItumQBpNdYKAm9g8r3WC6h1YUKXl9Nk7W+upF33ds6bFb8bSnC2MLvuwrnXwMV2gnrk kp26v6Sg7Dmhy4CdGB0b8G2bzF9EnahUVK/bnba7SwihMQGdaXi4PoxlZRJejtGIB1Ot TwW3fFcjVdWV+0d9T71FdRUIztAwM/UcnJ01gZQagpgqE3z/tT36i85K7cipFZsEE8p8 snSTGrU2f+q/BAKo65M/8Mtf+2oIrAovUTidXT0aLhmhziVCJyL0qDDmvjxaRGNjGC5G 7kJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Z33l99/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga14si441721ejc.427.2021.07.26.10.11.10; Mon, 26 Jul 2021 10:11:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Z33l99/S"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239079AbhGZPvf (ORCPT + 99 others); Mon, 26 Jul 2021 11:51:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:46774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbhGZPax (ORCPT ); Mon, 26 Jul 2021 11:30:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B03A260F6E; Mon, 26 Jul 2021 16:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315881; bh=Q2wZfKYnOvNv7D+xsxyCsV1Ukb51gEDgIhuXtUavpNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z33l99/SzBIQ8pHPmraofxC8HSFAYk0P1h5nktS72JR3DoX22jhtVlFiR4wAPbSmz BNgmBkNDeaMwx4o1USdxGqXABYAtNkjqQFquGPzYGEIn91sCsgWbhPxsEEi74RQxiu SwgJ9W4oJPOJqy8YbkDtEEjlThH35Oq4hqSe1ON4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Ard Biesheuvel , Sasha Levin Subject: [PATCH 5.13 102/223] efi/dev-path-parser: Switch to use for_each_acpi_dev_match() Date: Mon, 26 Jul 2021 17:38:14 +0200 Message-Id: <20210726153849.608375092@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit edbd1bc4951eff8da65732dbe0d381e555054428 ] Switch to use for_each_acpi_dev_match() instead of home grown analogue. No functional change intended. Signed-off-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin --- drivers/firmware/efi/dev-path-parser.c | 49 ++++++++++---------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c index 5c9625e552f4..10d4457417a4 100644 --- a/drivers/firmware/efi/dev-path-parser.c +++ b/drivers/firmware/efi/dev-path-parser.c @@ -12,52 +12,39 @@ #include #include -struct acpi_hid_uid { - struct acpi_device_id hid[2]; - char uid[11]; /* UINT_MAX + null byte */ -}; - -static int __init match_acpi_dev(struct device *dev, const void *data) -{ - struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data; - struct acpi_device *adev = to_acpi_device(dev); - - if (acpi_match_device_ids(adev, hid_uid.hid)) - return 0; - - if (adev->pnp.unique_id) - return !strcmp(adev->pnp.unique_id, hid_uid.uid); - else - return !strcmp("0", hid_uid.uid); -} - static long __init parse_acpi_path(const struct efi_dev_path *node, struct device *parent, struct device **child) { - struct acpi_hid_uid hid_uid = {}; + char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */ + struct acpi_device *adev; struct device *phys_dev; if (node->header.length != 12) return -EINVAL; - sprintf(hid_uid.hid[0].id, "%c%c%c%04X", + sprintf(hid, "%c%c%c%04X", 'A' + ((node->acpi.hid >> 10) & 0x1f) - 1, 'A' + ((node->acpi.hid >> 5) & 0x1f) - 1, 'A' + ((node->acpi.hid >> 0) & 0x1f) - 1, node->acpi.hid >> 16); - sprintf(hid_uid.uid, "%u", node->acpi.uid); - - *child = bus_find_device(&acpi_bus_type, NULL, &hid_uid, - match_acpi_dev); - if (!*child) + 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)) + break; + if (!adev->pnp.unique_id && node->acpi.uid == 0) + break; + acpi_dev_put(adev); + } + if (!adev) return -ENODEV; - phys_dev = acpi_get_first_physical_node(to_acpi_device(*child)); + phys_dev = acpi_get_first_physical_node(adev); if (phys_dev) { - get_device(phys_dev); - put_device(*child); - *child = phys_dev; - } + *child = get_device(phys_dev); + acpi_dev_put(adev); + } else + *child = &adev->dev; return 0; } -- 2.30.2