All of lore.kernel.org
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org,
	ilias.apalodimas@linaro.org
Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de,
	AKASHI Takahiro <takahiro.akashi@linaro.org>
Subject: [RFC v2 18/20] efi_loader: disk: use udevice instead of blk_desc
Date: Fri, 10 Dec 2021 15:49:45 +0900	[thread overview]
Message-ID: <20211210064947.73361-19-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org>

In most of all cases, we can avoid using blk_desc which is expected
to be private to udevice(UCLASS_BLK), that is, the data should not
be manupulated outside the device driver unless really needed.

Now efi_disk's internally use dev_read/write() interfaces.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 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 8dc7534278da..8e33af76711f 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -48,7 +48,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 */
 };
 
 /**
@@ -83,14 +83,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;
 
@@ -102,9 +100,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 = dev_read(diskobj->dev, lba, blocks, buffer);
 	else
-		n = blk_dwrite(desc, lba, blocks, buffer);
+		n = dev_write(diskobj->dev, lba, blocks, buffer);
 
 	/* We don't do interrupts, so check for timers cooperatively */
 	efi_timer_check();
@@ -446,7 +444,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;
@@ -745,20 +742,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


  parent reply	other threads:[~2021-12-10  6:53 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10  6:49 [RFC v2 00/20] efi_loader: more tightly integrate UEFI disks to driver model AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 01/20] part: call part_init() in blk_get_device_by_str() only for MMC AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 02/20] blk: add a helper function, blk_probe_or_unbind() AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-14  7:01     ` AKASHI Takahiro
2021-12-18 10:55       ` Heinrich Schuchardt
2021-12-20  5:19         ` AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 03/20] scsi: call device_probe() after scanning AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 04/20] usb: storage: " AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 05/20] mmc: " AKASHI Takahiro
2021-12-18  9:48   ` Heinrich Schuchardt
2021-12-18 10:03     ` Heinrich Schuchardt
2022-01-02  9:47   ` Heinrich Schuchardt
2022-01-03 10:09   ` Jaehoon Chung
2021-12-10  6:49 ` [RFC v2 06/20] nvme: " AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 07/20] sata: " AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-10  6:49 ` [RFC v2 08/20] block: ide: " AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 09/20] dm: fix an 'undefined' error in some macros AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2022-01-07 12:38     ` Ilias Apalodimas
2021-12-10  6:49 ` [RFC v2 10/20] virtio: call device_probe() in scanning AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-10  6:49 ` [RFC v2 11/20] dm: add event notification AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-14  7:07     ` AKASHI Takahiro
2021-12-19 22:17       ` Simon Glass
2022-01-02  9:41   ` Heinrich Schuchardt
2021-12-10  6:49 ` [RFC v2 12/20] dm: add tag support AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-14  7:05     ` AKASHI Takahiro
2021-12-28  8:32       ` Simon Glass
2021-12-10  6:49 ` [RFC v2 13/20] dm: disk: add UCLASS_PARTITION AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 14/20] dm: blk: add a device-probe hook for scanning disk partitions AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2021-12-10  6:49 ` [RFC v2 15/20] efi_loader: disk: a helper function to create efi_disk objects from udevice AKASHI Takahiro
2022-01-02  9:18   ` Heinrich Schuchardt
2022-01-06  7:16     ` AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 16/20] efi_loader: disk: a helper function to delete efi_disk objects AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 17/20] dm: disk: add read/write interfaces with udevice AKASHI Takahiro
2021-12-10  6:49 ` AKASHI Takahiro [this message]
2021-12-13 12:51   ` [RFC v2 18/20] efi_loader: disk: use udevice instead of blk_desc Simon Glass
2021-12-10  6:49 ` [RFC v2 19/20] efi_loader: disk: not create BLK device for BLK(IF_TYPE_EFI) devices AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2022-01-02  9:19   ` Heinrich Schuchardt
2022-01-06  6:59     ` AKASHI Takahiro
2021-12-10  6:49 ` [RFC v2 20/20] efi_driver: align with efi_disk-dm integration AKASHI Takahiro
2021-12-13 12:51   ` Simon Glass
2022-01-27 15:05 ` [RFC v2 00/20] efi_loader: more tightly integrate UEFI disks to driver model Simon Glass
2022-01-28  5:01   ` AKASHI Takahiro
2022-01-28 12:32     ` AKASHI Takahiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211210064947.73361-19-takahiro.akashi@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=ilias.apalodimas@linaro.org \
    --cc=masami.hiramatsu@linaro.org \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.