From patchwork Fri Apr 15 07:15:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 561948 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp116030map; Fri, 15 Apr 2022 00:18:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJy6IovcZWf+zp7HjBFUSsKeKykEt5l7pZjlVeUkcGW9oT4OrHOaB5PDkdF6dS0NUmniyT X-Received: by 2002:a17:906:5d14:b0:6e8:90d6:efe4 with SMTP id g20-20020a1709065d1400b006e890d6efe4mr5318419ejt.559.1650007113902; Fri, 15 Apr 2022 00:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650007113; cv=none; d=google.com; s=arc-20160816; b=gL8nXM1gqIBGBv4lAoAyo4ffdoPCEBOc2i/qmtBkb82/EEtp3aM7kFMyBD1QbZXGjA Eue+ky4+W+3TwsoGRfxj4MXuixZEydb5xK2MiItq6z1BBL8wG1glA+qZmIjmJaiDVTWi Jw47UZ/MQPiqqawscJCgIVmcvh6oiBKEW3iO8CTtV0x/1DzKzGCn/SuTXBOvPkXZEgCo Estk+FrVzfMHviXwmQspq/aZX7rLox0LeT6682j7AuvFv74UOlNCe3SNZsrUoJSz3R/n HTzSPsAdVloFJ6eEDgCq26rHMsP1Tzk67r59sBLfdN0fS7NlkwU0ms15+7AqWLFuWZzL 8DQw== 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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=vinvqlyBLqK9IwvdCUA4pxG+8iRUPlsVHf9JqTgc7Xe++fapC0PiMiv3mpy3fZlGLg CXwQ0thlbzGbOVqxa3e1+/mLcEXOKBd1jJpoc6MQyZNJF3yiCKaToQawFIrLZ1QkrNAo qoRkMO2fMtLU+6bTF7qvIyYOSf953zQN7YLECkYnLcq4xTlIoRquesXB9HOMX5lDbA8P btuo//EMjGvmVZFjwa+dcsWV19xui7Yamc4bo3hNHx/5COF7sSwm7iehLyqsG9fYlseU wGggfYcwUkywDw66y5eOu0G8xF8NEH2RcQppTJ9G/xiTNwI5r2vCqr/vs2fjLyA+nsK+ 7KRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pyKGirvJ; 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 ec50-20020a0564020d7200b004190310aa85si545223edb.131.2022.04.15.00.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:18:33 -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=pyKGirvJ; 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 C657D83E3A; Fri, 15 Apr 2022 09:16: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=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="pyKGirvJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BFDF783D44; Fri, 15 Apr 2022 09:16:47 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 6722A83DBD for ; Fri, 15 Apr 2022 09:16:44 +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-x632.google.com with SMTP id n8so6548939plh.1 for ; Fri, 15 Apr 2022 00:16:44 -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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=pyKGirvJwSBWxVNeko4RtaZqZIFjjyzKRGkKOOYt+gJTNRjPdPRadmeK17frUEfRA6 Te9Ffn+rLSJP7yRyiP3G5EE89u1IlcTmYP4SwEW1mvo5Ki/qGSE5skXrn+TFaldLCs1o dt+sNQlnhKdsoGq4SpwEzZ+bcWlZzA0s9bWAhjJhU/SbtmzZtkxoccKUWkZBDIm095Tc 71KhS54iQKFfNTFaqUPOvMXQo9CrGt6VfyQ3OimLImMXv2x7jPFlMYDM5vZ5TOVCxrJ2 JzWlxOJlUVIX6ZVh1oCsxwsTrszHcmwQ7XKIZGid+rn9JD/lVPYV/sa1nA2snirNBffw 4xbQ== 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=rNLLIfTuq1qKd/v07Kv5kb2TuLlTdjrx7M41nrSL5rY=; b=7OejnmZ4C52HyM6iLJwcRVXi1CU9HPWdq9VYMpzXURhK8YKQ1wHcK/fPUOyShXkswG ncons7r/InLOwuwnH1ecCNdiPBMKYF8wtVAoc15r8LwOXWhk5tLOWj3/KQf01VgO319/ EpE6qhTo3HPsXMcQ0/2J/ZGGR1pm76PEUdh3E8oTglnIm4wSP50zI3xfbhOdb0zKfwC6 juKCpOm2S1g2xeJNZKsoWrf52PnYRA9Ef9Ahtz/qPl1ZYZHUkdFmIqUJbp+h3iMdQsrR HForC+yDWySwZu5GuG5CK4rpSm3a+3akFX6WWPbThMo/OMK06jjw+5WsDpgnR1Q+53NW ERfw== X-Gm-Message-State: AOAM5338PaJ7RGQu4+FR4GVysfDr1Qddgul/ga+dJ0UhCa1HggrzrYHz 5GOl2x9jg0xfM7sgfD/Q0MabxncncU2LGg== X-Received: by 2002:a17:90b:4b0e:b0:1c6:f499:1cc9 with SMTP id lx14-20020a17090b4b0e00b001c6f4991cc9mr2737068pjb.133.1650007002863; Fri, 15 Apr 2022 00:16:42 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:18f3:1e4:6c4:6ea3]) by smtp.gmail.com with ESMTPSA id p1-20020a17090a0e4100b001ce188720e5sm3566921pja.53.2022.04.15.00.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 00:16:42 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, sjg@chromium.org, ilias.apalodimas@linaro.org Cc: masami.hiramatsu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v4 12/12] efi_loader: disk: use udevice instead of blk_desc Date: Fri, 15 Apr 2022 16:15:46 +0900 Message-Id: <20220415071546.122475-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220415071546.122475-1-takahiro.akashi@linaro.org> References: <20220415071546.122475-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 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 manipulated 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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 34bb662e9cc0..8ef493cc972e 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -36,7 +36,7 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID; * @part: partition * @volume: simple file system protocol of the partition * @offset: offset into disk for simple partition - * @desc: internal block device descriptor + * @dev: associated DM device */ struct efi_disk_obj { struct efi_object header; @@ -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; @@ -522,6 +519,7 @@ static int efi_disk_create_raw(struct udevice *dev) return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header); @@ -578,6 +576,7 @@ static int efi_disk_create_part(struct udevice *dev) log_err("Adding partition for %s failed\n", dev->name); return -1; } + disk->dev = dev; if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) { efi_free_pool(disk->dp); efi_delete_handle(&disk->header);