From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FD7CC433EF for ; Fri, 1 Oct 2021 05:06:47 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BA9C611C8 for ; Fri, 1 Oct 2021 05:06:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9BA9C611C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B272832E0; Fri, 1 Oct 2021 07:04:19 +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="pYFt1Arp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0039D83267; Fri, 1 Oct 2021 07:04:02 +0200 (CEST) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 6AACC83246 for ; Fri, 1 Oct 2021 07:03:57 +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-x635.google.com with SMTP id t11so5526150plq.11 for ; Thu, 30 Sep 2021 22:03:57 -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=pYFt1ArpOJlVuJVD4uyhMs8OeccX0V+GFFXMJYnuKGWpmL3JUTtJNE1YLih+zZ6gbk vGtKOLEGUucKmzAZ8IZUHvkCkByAX0u4b0KOqzAVdpGQtBzNMI34eqgLOtEyAgC5UP3D kK3HAL5Jslct35uTdmxRM/oMKJEFxB9hw7yh283S98bS8UcZ1Hpx+D2NjnJfIartBNgF zWfxjmjbkEa8M/G2/PLc/imsiQ6qh6ZdfmWAKxg2RJII5pjz3cIz6ZDK8osuq7tEBVk7 USN95du3aVK1JrveQOWcy4UPxqa8pLQtcEiudmVn+Po2PdXco825TXL1O5G/TyRwgjxC 1nvw== 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=ZcvJR2YB5dgvoNy52uRQOR0v5Xw3II7M6tDHY86F1DLPgmTxmIb95odSs3p2HAzw7F S3pGEHxTCJ5+4SWtGBsdFVyo4Y6lprzzkecNLs/9UXnzYYLR55fLkEMgg4a52omqp4JJ YH5pDdkvhq80/Qpo4V+K5uPiNu5PrJfka5Fckavgc9OijxfBeg2QkIqB1ub5CCb8YSzs ukX9A2l2X516l/LHtPRSG8eCVGx6RhPSUYhmLZYMa3lB1HFZA94PwTBtYXs6QNS7q/d9 fBM7KLDzMrobhrl1iEaG9Px6NutpYizY9jrhr3uOc7FQWRvXqLCA1kxvwWV6R5kPJ9WM XnLQ== X-Gm-Message-State: AOAM533vF8s3l/qHFfAi3FG8ytPqi7TFIyA9G7vhEvaUxN1oDmpIVM9o 7dethRlbX7F5rhlPg7jRIexzqw== X-Google-Smtp-Source: ABdhPJxAlMZlCe5nMPdnPdSoMLII1vI+JtrLo6wbae5uL0H2We5nXT3L7U5Mxdlad1WR8inTjCZUxg== X-Received: by 2002:a17:90b:3e84:: with SMTP id rj4mr17592620pjb.208.1633064635637; Thu, 30 Sep 2021 22:03:55 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 22:03:55 -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 10/22] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 1 Oct 2021 14:02:04 +0900 Message-Id: <20211001050228.55183-21-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 Content-Transfer-Encoding: 8bit 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(-) 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); } -- 2.33.0