From patchwork Fri Dec 10 06:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 522740 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp2170828imb; Thu, 9 Dec 2021 22:53:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJztGJqKEdc7E2ki5adr9PD2sG+qTqfzF+hV0XfBG9rn+VQRZLBLAoafjVxdbP8sgUhJBoCa X-Received: by 2002:a17:906:7304:: with SMTP id di4mr21323643ejc.327.1639119203224; Thu, 09 Dec 2021 22:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639119203; cv=none; d=google.com; s=arc-20160816; b=IIWEOQDNZM45rhxhMGV6iLqqa4pajAEj+Gx5pjMIYKgYyDbkebwfZdaD2X+xVXWiCA bYzrNl/NN2L3CcwIqYcd8IdjiYh4zlVqVIwwHJIgGZd1Bj31ZNhBs9d2Y8JXTzyTEYSH m8VofrClxTi156VfOESIQafcn0T4CglL/euVmi1OqvzGzrgJq/2WyVQmr0zPJ9qTr/8F RwLSLUD4NhyQqLrOlPhePKmPm/kz0xXCNEAXXcvIUaaQTAgGiTVI5JUi24RsUZjiBdgM dE8U2zD+rUwMlLyRD4zEE9l3s7JjEuDzHngalSPhr7CKtH9IN5hdAgN06zWWzu0gZaY8 SlUA== 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=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=kQEDBJx37VNjfjdpxFBt8WUzG4hTUxeOE+ZgkeR+OiL2Vg85wVmkShI8GYHoJ/FrJl 0MsL0H2h/D3oyekx2jJvYSEp4vCNUI9/8NF4xl6oQzq9SnU/v37yaRk5H6zuRlcUH/CV qbk0DovY/ggy1qZLWV8UqePHzJ92PYBUgMf74sVvlTGFTxOu9fudslxyGZ8WBt4cmbQY +DaKEPiWack87mTt1ujhqaAquex2OO8cyrOTIq6uN37DmEsD9pbxvi4AwsYmgZVB3ios ++AkYmhWgidWrTXAldRfKwGqC6WAzuyQmAXO8XhaDqCaztbuN/pQ0r1zPa6gBlNBpJr/ jSsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w6C5Hu8i; 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 c11si3678995edw.416.2021.12.09.22.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:53:23 -0800 (PST) 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=w6C5Hu8i; 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 7E82283693; Fri, 10 Dec 2021 07:51:43 +0100 (CET) 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="w6C5Hu8i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C0C11834DE; Fri, 10 Dec 2021 07:51:21 +0100 (CET) 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-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 08B5F83518 for ; Fri, 10 Dec 2021 07:51:16 +0100 (CET) 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-x631.google.com with SMTP id u11so5655051plf.3 for ; Thu, 09 Dec 2021 22:51:15 -0800 (PST) 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=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=w6C5Hu8i74VOcL9/vVh7UnIYyEdQCa+qID+f3Q6hilWw+Ijey7IB1z5I9getbclNCf n9SQBr6ystzExWfIapHkHBOrNPQJCUvhX1U4/eEJ7IMtwZ0cGLc16N/YIQZXAC3raC7M ysxUf9ByFn3fnaZK7Rw6LodJ8pmjXXMb9Yp8nJRup44tY0Kj+83HobDO5pdsOrPWC1D5 3Au2GIVDvLMnR3DdHZI0MvkNVzIMzi1mn9CKQJDr/PHTjBiMxXZO1LdonluEBcSoLH3y Qo7JJpLc4XasPfaUuZI0TC6Puca7su+iHDcwz6RLnDBBO5oVVGgiXBlGXQ0tiC17W4li rYfg== 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=2RJeyfCToQYeF9AW4ATinruQnvSK9EpBCOGEFn+5BEY=; b=JFR4fQbJf5LWxH661ahCXXCC92P7CG8XVQ/y+D8jQTU6c7ffsGEnshSUyyrPM2yeq0 wZplF78xvppWdipY+7bLIVh/DR8l0jrVHUzCErAJr2eXDln9J27c5qtz3GrEKSAael+b I2mBtds2Q68ZCx908EQqOFdWpDjWqRDFRzsO6UTQPfhc9pv1MSfE8KnNiYTe+PPE18/C NK1JiOOMBxZi7F3PyDm8awCXl4AygE/X3pVaAf1b/bsK2cS1eVYZA14aw0KMcp68LRSS yPa4oFGCPyFmoMa3HcTnQ79c6qSAfiNxvRdvYayCt2aXpW+gtjE02c6OtKCQ/p72Il77 ttkg== X-Gm-Message-State: AOAM533uUH9e68CKjp00rMlQxlUCJ2IqbAI6SXifvwGrtTlXZyIuRoT4 2pBA9dzpNVnXUQTUFsCMfl9EKg== X-Received: by 2002:a17:90b:124d:: with SMTP id gx13mr21768502pjb.106.1639119074339; Thu, 09 Dec 2021 22:51:14 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:75dd:4e0e:4542:936e]) by smtp.gmail.com with ESMTPSA id nn4sm1639035pjb.38.2021.12.09.22.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 22:51:13 -0800 (PST) From: AKASHI Takahiro 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 Subject: [RFC v2 18/20] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 10 Dec 2021 15:49:45 +0900 Message-Id: <20211210064947.73361-19-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211210064947.73361-1-takahiro.akashi@linaro.org> References: <20211210064947.73361-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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 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 Reviewed-by: Simon Glass --- 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); }