From patchwork Thu Aug 28 02:07:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 144 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346872; bh=aRbLSOnksHDIhzrmn+875pgUY2Xqp4rMfEWrBT9o+kA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HeBUqjpAFaMVTWZMH1+Hmv7vwZ183L2OhV+WurkjnzxpjMLDyu6Siwr/t9Jc2klKw h1jxsk8GmzZ1io8FVsPncGhJp4CjBDxkS86EF/TZ6gIzO+f43pOqiXm7kHL5ywM7f6 Aw7ujIKRr2u3DfnStHfNDie0AzJcRGYrUSC6iOiybLyt79jmTZtAWLSgLeNhPV1a50 S3Bey3olklcr0mGqAdYfQxcnHknAK51PGK1ozLxR9VG6+CndaArsNaXe355TnYlBiE Pe/5HidPko8hH1AdFIVFFMeLBj1un6nZr4UBFiP8EsDOs1AL+RSefLCjEn5MVqWPhF pcVNyxZY3l0PQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29A6C6780B for ; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 24HtJynEjwWG for ; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346872; bh=aRbLSOnksHDIhzrmn+875pgUY2Xqp4rMfEWrBT9o+kA=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HeBUqjpAFaMVTWZMH1+Hmv7vwZ183L2OhV+WurkjnzxpjMLDyu6Siwr/t9Jc2klKw h1jxsk8GmzZ1io8FVsPncGhJp4CjBDxkS86EF/TZ6gIzO+f43pOqiXm7kHL5ywM7f6 Aw7ujIKRr2u3DfnStHfNDie0AzJcRGYrUSC6iOiybLyt79jmTZtAWLSgLeNhPV1a50 S3Bey3olklcr0mGqAdYfQxcnHknAK51PGK1ozLxR9VG6+CndaArsNaXe355TnYlBiE Pe/5HidPko8hH1AdFIVFFMeLBj1un6nZr4UBFiP8EsDOs1AL+RSefLCjEn5MVqWPhF pcVNyxZY3l0PQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 17C7E6777E for ; Wed, 27 Aug 2025 20:07:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346869; bh=FOdozXc4rebyfwvEPg0mnPIVi7C37Ijwk5l6jPIGtD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jB1UnwgmLz+jSFsMPkd4BFRrtG3+HFFhyebanIA06KmVZ/A27aAvhJpJ/I3TJ5op8 xOQ56/2+PbJPxOfTvAkUapv+1EjQkUyw/XI/vop/hDiXOTqg/E3K3jfYg+WUpGh4w3 6n6fOo7uk2N0uEFD2/Hc3Jn3nV3Ef1fcmwhA1mcC1PHBDiy0qPhsG3yfiAR+mld0wz nm+e8QqQ1lIkKvchXd5NnWYJl/JKCXHcooPqPYuJNRNngrV5Dy0DEuOCY8WzN93Mbm 3lFonWhwJcSnq4ICfyrPct6YwBWVYrYiPKxxAmsgcT0/lzinFIRjgoIW9z/qqslxH7 rG5PR9+xPDEiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD1E86780A; Wed, 27 Aug 2025 20:07:49 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id P13C07N57uMq; Wed, 27 Aug 2025 20:07:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756346865; bh=VjEiWU1oPFgteenFvkLzz6Kp6AhG2/rQ4tGmYVi0Ryg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgg2lz1yH6dF+IT10U7Qh5KWeAAjpdiOAHrVcOaRNzI2ghepQ4uVBzHqUJXaYbPGG Orz36AUozKNF0fGfHDqb2aD2muXX6wjmpOfuohyiMR3RA3WJwOdh/AXy3Z6P5HnCdt PpFEBC6reZsqw4V2P4aR0IA1FAlGM7fpMLlvZ6vSdVHc3koGVUISjwyvvMSIZvpj8o Ndubnu/ita0dgxmwunmv5VWW8/KGm28K/oq8ZouWmJZyF2pTuBkQ8Lm6FnyWsfxX/z Kv4DwqIY/tqh2xfk6YlxQcFgnDrXnhxnJyBGYck3l4+Zg7HDdor8Eo9rlfKqYMu/WH tL3whrSXpBthg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7A6776743E; Wed, 27 Aug 2025 20:07:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 27 Aug 2025 20:07:04 -0600 Message-ID: <20250828020732.981415-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250828020732.981415-1-sjg@u-boot.org> References: <20250828020732.981415-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: U7SHMWPLIFPQB4LQB6RIJXVE2MVKAZ3B X-Message-ID-Hash: U7SHMWPLIFPQB4LQB6RIJXVE2MVKAZ3B X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/20] efi: Set the efi_media device name when binding List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Binding a new efi_media device uses a placeholder name which is then changed after the device is bound. But binding the device immediately causes a child block device to be bound, which uses this placeholder name as its base, rather than the eventual name of the efi_media device. To fix, decide on the name earlier (based on the number of existing devices), then pass that name to device_bind() Signed-off-by: Simon Glass --- lib/efi_client/efi_app_init.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/efi_client/efi_app_init.c b/lib/efi_client/efi_app_init.c index 7d30e79528f..b5421dc5a91 100644 --- a/lib/efi_client/efi_app_init.c +++ b/lib/efi_client/efi_app_init.c @@ -50,7 +50,7 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, { struct efi_media_plat *plat; struct udevice *dev; - char name[18]; + char name[18], *str; int ret; size_t device_path_len = device_path_length(device_path); @@ -63,13 +63,20 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, if (!plat->device_path) return log_msg_ret("path", -ENOMEM); memcpy(plat->device_path, device_path, device_path_len); - ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), "efi_media", - plat, ofnode_null(), &dev); - if (ret) - return log_msg_ret("bind", ret); - snprintf(name, sizeof(name), "efi_media_%x", dev_seq(dev)); - device_set_name(dev, name); + snprintf(name, sizeof(name), "efi_media_%x", + uclass_id_count(UCLASS_EFI_MEDIA)); + str = strdup(name); + if (!str) + return -ENOMEM; + + ret = device_bind(dm_root(), DM_DRIVER_GET(efi_media), str, plat, + ofnode_null(), &dev); + if (ret) { + free(str); + return log_msg_ret("bind", ret); + } + device_set_name_alloced(dev); *devp = dev; return 0;