From patchwork Mon Oct 4 03:44:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 515139 Delivered-To: patch@linaro.org Received: by 2002:ac0:890a:0:0:0:0:0 with SMTP id 10csp1062372imy; Sun, 3 Oct 2021 20:47:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDyTau4njiF6Abn2OoWp69LnPDCDeKFCHtm+xO3brIq4t1xHFM2x6h5Lfp2GHJEGjHy4ln X-Received: by 2002:a17:906:9b1:: with SMTP id q17mr14250403eje.546.1633319231725; Sun, 03 Oct 2021 20:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633319231; cv=none; d=google.com; s=arc-20160816; b=SRK4BArVQ8NkHuKSNo/ddV4Rw2Xnc8bJ7kPovJc5xWZZuymNXIHsNagJNLWY49/FET fwpMOZZeA3q3Gn05IRZdng4t7Fj9A2zy+fnbRwExQncYGwyv8ILb2yKwZuikl4IiOthn n4HxKbBkmwLwNWzRr+NpBlMYGKqw70uiEF3m/EodVMOgaE1YYpdWyHZk6aNEABU6MPyX kf8+9hpKS2vXwZAuWu0bcO8HEF18qv9ekTRpCS8q0kxXKDLcfhzOOqCa3iG4IP2tLWiW uhBkVDnSktHI8C2pDspKvc7bi6CWHchRpRqS5MB7OqpGQK//zgmGWQCjE1++lgCaG2xH I45A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cm01FoLLgy+Q/VyQX8ktwQ6qmMS34T5N1nWu2qPHuT8=; b=aZcXOZGg4tjVg4UHX01quAK6+3OSKYKcqgxcnA5c8VXQ4a9uFk9wu1uuvEae/snQaL GrPXCrmMtM54XNDPcnTj/NcNVibp6ei4MQwXWnQro9QAPM886QM/yPwBzl0r+E0JWm2x DjvIoS1oAbxIAjD25WzumCvkUyU+SWtDC9XhOhD11D3SsnG3iABPE3gKNJ0ENZtuYCOU twxlxR3FM5xKrS6yQ8pNY31R8lcZx8lAJnkkVgQ36drWZTDhMB1WNN0kwiaVh5jwkb4O 76IN1G2sQoTRCJJT7FAEyksVxZTdhI9jCp2dEFHXAf5WjxuhmcI4Af8pUemfR+ji7Gw4 9btQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZrtP02yt; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id n13si15426335edo.447.2021.10.03.20.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 20:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZrtP02yt; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80C328353B; Mon, 4 Oct 2021 05:46:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ZrtP02yt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 978718358E; Mon, 4 Oct 2021 05:46:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3A0998356F for ; Mon, 4 Oct 2021 05:45:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62a.google.com with SMTP id x4so10179161pln.5 for ; Sun, 03 Oct 2021 20:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cm01FoLLgy+Q/VyQX8ktwQ6qmMS34T5N1nWu2qPHuT8=; b=ZrtP02ytzwr9L1dvHZu4qn3KIG7IFoJLUtlixPRCNTeai3hofr9JpROu1fHAlSGlA4 3rQZjG+z5fy0yoNCJ0MHz3Or0jGKRYkPkzwiEK/8sSSrwm9R8nbzkjan6+1YdBu8mgcN 7ziXjCa8DRlZCcH27CbHqoNv/DekUzS585slBXzlVQ7+x2yqNGu/jjrQN+4IZZdZM54m Zku+NI4QN0XCBfbekyIDEY6qHFY8weMLP9phQ8b6S6yY65itX9Xsqb5QjsZC8gVRsmWJ H/8Zf0oCMo+3L/M/d7QVAIixcIHD5jPHQ7Pp/OQLZ3qI/0+4aKTysE29zorOoRKOFAPb cLVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cm01FoLLgy+Q/VyQX8ktwQ6qmMS34T5N1nWu2qPHuT8=; b=O8yLl9Wk8TBktmimOBkjmqBXcbqJwXXZbGRtjPcuwztENPj+BW9QBG+9cuR6KcDvt/ c8QM5BxlcDF6S7Em8k0/zYUZPsARq5Mb5la3ElsjicUY8CzaXwovhspVEyKXB2O5a020 m7yP59C/rB1M9dH3Zvb/xlOd4R5QUtNSt5vsrbz/ZeqY65ZRo47RV/XTBrDxTbV+ZbDg 1HmfH/wWG6W9FzW5T7/DFvGkDPgCjl0uEVIVpiYyZlXXwNiPpwnnROPNjPDZKhod7UWX AWVwy4gZAH3d3kgdGctSVTj167DP9kqrOD+MThosoifrG1zhh52cKpkDLxBqprJ/Vmtz Kq1Q== X-Gm-Message-State: AOAM531AgCgScP3Y2Qhed2sRs/LxpyobgqL5jt7mXTC7N4yqhpesI2rr rIEkggo95k/lcqHYUBoradBs5A== X-Received: by 2002:a17:902:9b88:b0:13e:55b1:2939 with SMTP id y8-20020a1709029b8800b0013e55b12939mr20907817plp.80.1633319153495; Sun, 03 Oct 2021 20:45:53 -0700 (PDT) Received: from localhost.localdomain (61-205-96-147m5.grp4.mineo.jp. [61.205.96.147]) by smtp.gmail.com with ESMTPSA id a11sm11863515pgj.75.2021.10.03.20.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 20:45:53 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [resent RFC 11/22] efi_loader: disk: use udevice instead of blk_desc Date: Mon, 4 Oct 2021 12:44:19 +0900 Message-Id: <20211004034430.41355-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004034430.41355-1-takahiro.akashi@linaro.org> References: <20211004034430.41355-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean In most of all usages, we can avoid using blk_desc which is expected to be data private to the device not be accessed outside device drivers. Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_disk.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.33.0 diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 988907ecb910..dfa6f898d586 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -45,7 +45,7 @@ struct efi_disk_obj { unsigned int part; struct efi_simple_file_system_protocol *volume; lbaint_t offset; - struct blk_desc *desc; + struct udevice *dev; /* TODO: move it to efi_object */ }; /** @@ -80,14 +80,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, void *buffer, enum efi_disk_direction direction) { struct efi_disk_obj *diskobj; - struct blk_desc *desc; int blksz; int blocks; unsigned long n; diskobj = container_of(this, struct efi_disk_obj, ops); - desc = (struct blk_desc *) diskobj->desc; - blksz = desc->blksz; + blksz = diskobj->media.block_size; blocks = buffer_size / blksz; lba += diskobj->offset; @@ -99,9 +97,9 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this, return EFI_BAD_BUFFER_SIZE; if (direction == EFI_DISK_READ) - n = blk_dread(desc, lba, blocks, buffer); + n = blk_read(diskobj->dev, lba, blocks, buffer); else - n = blk_dwrite(desc, lba, blocks, buffer); + n = blk_write(diskobj->dev, lba, blocks, buffer); /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -443,7 +441,6 @@ static efi_status_t efi_disk_add_dev( diskobj->ops = block_io_disk_template; diskobj->ifname = if_typename; diskobj->dev_index = dev_index; - diskobj->desc = desc; /* Fill in EFI IO Media info (for read/write callbacks) */ diskobj->media.removable_media = desc->removable; @@ -647,20 +644,22 @@ bool efi_disk_is_system_part(efi_handle_t handle) { struct efi_handler *handler; struct efi_disk_obj *diskobj; - struct disk_partition info; + struct udevice *dev; + struct disk_part *part; efi_status_t ret; - int r; /* check if this is a block device */ ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); if (ret != EFI_SUCCESS) return false; + /* find a partition udevice */ diskobj = container_of(handle, struct efi_disk_obj, header); - - r = part_get_info(diskobj->desc, diskobj->part, &info); - if (r) + dev = diskobj->dev; + if (!dev || dev->driver->id != UCLASS_PARTITION) return false; - return !!(info.bootable & PART_EFI_SYSTEM_PARTITION); + part = dev_get_uclass_plat(dev); + + return !!(part->gpt_part_info.bootable & PART_EFI_SYSTEM_PARTITION); }