From patchwork Fri Oct 1 05:02:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 514999 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp453087jaf; Thu, 30 Sep 2021 22:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeXNQm3kOq7bC9x22cbu11KUe2y6VcuVhkv3kl5vQp+zww+078vnd5NrkvOdBTjhglteQD X-Received: by 2002:a17:906:469a:: with SMTP id a26mr4007780ejr.38.1633064837789; Thu, 30 Sep 2021 22:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633064837; cv=none; d=google.com; s=arc-20160816; b=BFdSTzj+trMhZoHRq4O0kf6t9j+IkWTUabUeItG/La0NZdyze/o91FwBQ2v4wSOH+S ot+OH7yKFCrk52BN96gNpjLIl0oQhKh/wvxgeKoT7vNL/xLqjp2ZnZwelt+QSRZlgbYd a3e0lRbQyLLmyrpb+oECN+L56IxY44LzjIdKMjyggKmp4BkyFC9qpyb4K0gwyJbbqr+3 eliLXEkl7pILA3DdfgA0IDIltDgZ8+/2LPu7xfD67GIkQcKxmohnNMysnD7kdQ+gcio+ xpQUy91UK4Ax/Zl8Xdd9wuilzuIA+AbsqQBwH3FdAeC2HLBLAZhaF38C2PRLCMSe/sVy 4bKA== 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=aVt7rOsru3ecPTMeG1WcL2dr/vFFol1RGZOID+L7XDo=; b=vj+wvQnqbwIeDVZanUAnwNrFY1jWgfYNIMkLfFs1k1wM2XcJQz6x+eYFHdOUW3vGCF F7FfGtcRvN9s9tUoTsyKD9PBKSzxM/syvBpNrX4U1O64USuJMZVVb+QzkGQfKLWad0cB xJ47fjMUZyEM2OUBH1O8NIIktHYuFsrMIMwox4H5opgheQTRBxvE1pL8JnrLt1odO5pC ETzl3fOJKu7mKZkycfsoz1ak/WRDqEf69qubHwQ+4kOMaCf/Pcr0u1WcUfa2ip3+PhEQ Ut6IYHcLIf868D3F6e/7EQSuCej3m47Lyrx7GKCdxcPs+OmXoR78Lg2LpFoI3/AcvmgQ /LiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i6dzPycN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id k13si5726636ejp.411.2021.09.30.22.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i6dzPycN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 BFB718330B; Fri, 1 Oct 2021 07:04:30 +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="i6dzPycN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A9F883303; Fri, 1 Oct 2021 07:04:14 +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-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 6A28883303 for ; Fri, 1 Oct 2021 07:04:04 +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-pj1-x1029.google.com with SMTP id rm6-20020a17090b3ec600b0019ece2bdd20so6402855pjb.1 for ; Thu, 30 Sep 2021 22:04:04 -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=aVt7rOsru3ecPTMeG1WcL2dr/vFFol1RGZOID+L7XDo=; b=i6dzPycNLRshYyl6Ci4NRCBFQbvDz7K9y1vbQjdtd1v0Us9961ygN16MU9vYJPzxTN m6qg8PW8AA7ud/t284xnfkwPt/Y+rmDZlnwiyHnInKYJhb2d541LFR4marG1FM82Lck/ ESLfjxGefoFFNH93DH3z5egpK0icnftZVQCaziwMqCoE+i9th/TtY+asaEEhsBKOUjK0 grx6a9yATLLM4R77hTwdPsFt/dJaPKzrdaoiuPJrlfVylwbSWc7C1hoAyY6LgGigJ0Rh 27SKBIa9QzQ8kBj7U37hykS4tj4Do0DHh0nJj5tKjbw1YOgCsSzt1AN1FT10doGIjNNU rAAQ== 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=aVt7rOsru3ecPTMeG1WcL2dr/vFFol1RGZOID+L7XDo=; b=uU/pvuUC/CiOieJ2M8MwFhsrFTpmboI2mG8QmvysNFfzXC0XjrwiX8LwZEcL2hzv8q CmCWsX4g1WM6QAVmM5xIQxp52hWRopOE59014Wi3LOKLAJMcMLmSvU1Prxs1ZnMqfH62 8+UJAzb/jtFqwofHBf/SH/eK4asgIEuVQumuOcR2TnKq1MN0xD6Mn5YH3AGSJ0N6WZWa aa6icy8+KhJBFikJwl09VhnjZgxvVuTLEV4VfgBCFyVSoh2snQoc5yzuUcz448KEkSCJ v4qxXy02aMNh1lPvszSQhNo5/jbWZaVHu294Lb5wfo2OYkyMXjNBUJqT3dM2x7Hfr+/y /Bgw== X-Gm-Message-State: AOAM533jF0YGIkuNvKjpyB0h7eYPFh8iQpgDIviOLzQFnm4Fkmu1ZB+e I64WyrMaOAIxid+4WQsWroT84w== X-Received: by 2002:a17:902:7286:b0:13d:c0f4:a9e5 with SMTP id d6-20020a170902728600b0013dc0f4a9e5mr9019899pll.67.1633064642569; Thu, 30 Sep 2021 22:04:02 -0700 (PDT) Received: from localhost.localdomain (122-100-26-52m5.mineo.jp. [122.100.26.52]) by smtp.gmail.com with ESMTPSA id z8sm4615113pgc.53.2021.09.30.22.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:04:02 -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: [RFC 11/22] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 1 Oct 2021 14:02:06 +0900 Message-Id: <20211001050228.55183-23-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211001050228.55183-1-takahiro.akashi@linaro.org> References: <20211001050228.55183-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 accessing blk_desc which is eventually an internal data structure to be hided outside block device drivers. Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_disk.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) -- 2.33.0 Reviewed-by: Simon Glass 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); }