Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp336602rwn; Thu, 8 Sep 2022 02:20:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR5pPiBauFZrUvFSfvmPH0hu6ZyKs0tSaq0i2JPCJc/NZV41glAqj7Wtc78W/jlWqlO7kCRp X-Received: by 2002:a62:5b05:0:b0:53e:8615:37a2 with SMTP id p5-20020a625b05000000b0053e861537a2mr6131956pfb.71.1662628800013; Thu, 08 Sep 2022 02:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662628800; cv=none; d=google.com; s=arc-20160816; b=eijYn9AuioZhDrcnbVU6wfPNjULlrgD8/JXiANQ39lKqprhzQ/60kbt99LcFqE0Wvz +Vxq/PA96miJT45f5hH1pG2pmoUmmnP1ORj3BsYJLtDFQ+ADIS8G8uOrsmH1mkqJy+Zm Bolap2jMuVkd96UxWNdmm0IEbJvfa1wEijWxPSL8n9ks66vKlvAK6bAtoGAKHZnTmW16 qBxY2Fh1rkeg5FsXSkkf8vZtacpq+tbbQeoMZ5mJEuigpCq52pfj4DvCtH0Y+8/x0zsu /9I3qlqRKlFKBhH+hUAW8zXY3yRfyJOTtbL1IlNNtw5Jz4zkxIXUK9uxww5KOlrbsMwc DaUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SDzXRkLQIvRNj3aQHsXSqs3LWLdrGGfxLmzWcXVE65k=; b=ZR2ONE/FeKxVt66UXruyW1enwyQMWcwLv0hyK8nRc3aBcZYxwl4B3yPC6DsXxzEO6+ rBEqJQBw2diZJ0uLeSbAOlcNw9ahQbwwS5S2n+VpQZJgyVt0kVSlR5QeR7267zDUYSyA 0Z4ttYNGvlSAROT3xQCKuV4hAgmx9QW43/I6bnLVb3FO8q8RLNby0pZug+giiu/9pam1 R6KzQ8CuqWUUz9nwOXx6EL65LE55iBYmN/+fSZG9EFSr6jY8QH2HCHvbgIbbWiji59q/ sdtbPQq9xTfZCI5RuY/GOgk0YDSXw20xIHWPGPZzkEYjg7Ajp0X6JJ4EcQjB5gCMCpVl vKCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tizFdmsA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a056a0015cc00b00540b7ce7b6csi265049pfu.22.2022.09.08.02.19.47; Thu, 08 Sep 2022 02:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tizFdmsA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbiIHIVM (ORCPT + 99 others); Thu, 8 Sep 2022 04:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiIHIVI (ORCPT ); Thu, 8 Sep 2022 04:21:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1460DA2AAC; Thu, 8 Sep 2022 01:21:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C7A10CE1E99; Thu, 8 Sep 2022 08:21:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B85CC43146; Thu, 8 Sep 2022 08:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662625261; bh=juJ+Obww8wGr6tHeP9vf9AOYM2NQPYUQZ/m7TW5mLNU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=tizFdmsAzfuZlcCB1PzQp+Fstqe0Gz/AU3kH4AsoFOt+oJE/o4IJp0tANnzRfQ+ds O0udAzI/++KI8ecttK/dmXVBeehu33B5OHBJfPfYOD4W9GI9EB8Kfz8+LtQqxdX99E U9JC0ZstQrPGvahqbtM61E7xpDN79w48fkW7if2xCQ0ObfHZnU4RimHHLqLVSjExGq J1ta3+FMDkBK7Y80bcqW5f7OJuZyn2E2uCwFYbn8vwnaUqaW1iZ2MK7uO9nyc4De8R V9zKT+azQeKqRyWVEL5IEdVS0frhuR7XvnlvfWARjzvUkAmOs1BHXVPqIA0UVRL9sc sLgENxteOH48Q== Received: by mail-lf1-f46.google.com with SMTP id q21so12247568lfo.0; Thu, 08 Sep 2022 01:21:01 -0700 (PDT) X-Gm-Message-State: ACgBeo3BR0ABJEmP3N7Kfbfk66qDdm/WEp8W/O8qhpAcot3AHHPJGIPn YDMkAzODaTSbGfzXuTTN8g52Ndx6T4311ysyfnU= X-Received: by 2002:a05:6512:150e:b0:492:d9fd:9bdf with SMTP id bq14-20020a056512150e00b00492d9fd9bdfmr2222287lfb.583.1662625259228; Thu, 08 Sep 2022 01:20:59 -0700 (PDT) MIME-Version: 1.0 References: <20220907164606.65742-1-andriy.shevchenko@linux.intel.com> <20220907164606.65742-9-andriy.shevchenko@linux.intel.com> In-Reply-To: <20220907164606.65742-9-andriy.shevchenko@linux.intel.com> From: Ard Biesheuvel Date: Thu, 8 Sep 2022 10:20:47 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 8/8] efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer() To: Andy Shevchenko Cc: "Rafael J. Wysocki" , 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, "Rafael J. Wysocki" , Len Brown , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Sept 2022 at 18:57, Andy Shevchenko wrote: > > 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 > --- > 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) Is it necessary to reorder the conditions here? I.e., why not > + ret = acpi_dev_uid_to_integer(adev, &uid); > + if (ret == 0 && node->acpi.uid == uid) > break; > + if (ret == -ENODATA && node->acpi.uid == 0) > break; ? With that fixed, Reviewed-by: Ard Biesheuvel