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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 95E6CC433EF for ; Wed, 2 Feb 2022 01:13:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16A29838CC; Wed, 2 Feb 2022 02:10:45 +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="J8UuVWqN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF6E4839EF; Wed, 2 Feb 2022 02:10:42 +0100 (CET) Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 8345B838EE for ; Wed, 2 Feb 2022 02:10:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1035.google.com with SMTP id g15-20020a17090a67cf00b001b7d5b6bedaso4413150pjm.4 for ; Tue, 01 Feb 2022 17:10:29 -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=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=J8UuVWqN66LqCuWrbC5zCY52DvVabo95tYrfUSsRNKBQscNA7LUmLPphvzvJUi3eBd dPY9KmejQgpR2w9w/oCArhyxMo7YkWnHO3LWa0rcdOp7IlZSk23lunj3/fYB5pDz/5Yv hbtCw/zVhMcgFlhE7eJzDaDXDhBKWgOC1+qYtYKaztjUBbWMjcyf2gAkWdX1346+uEi9 LbopxetFHnTMVQkLYDyL8bG4rPatKX8zbfiHtfkzPKmQ5c7T5jERCPtpM7GCEpGYpPVB TM0XXQzoXVdVCwPsa8V11U7zgEnCr9GDi4ZKXxBUH+Jgu0CThYmlq1NFuf7uJWvGVXB3 lOhQ== 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=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=EdZGB0faZJTSRCtD/AN+XyOUvjKf89/z4OAhwSTAMsyY0iMcFGtuJSracpTjo9aT+e dZlzBzPxzBQWFTwAIrHMDrGAXtRYDt8o7Dm6Bu3UAmQ9LBXEDpgP/k97IyCaJRA9xM4a w/Rs5tyFW8rpnkFDznrxjqsqDq3C31C/hJn8vNBL6L16xvgU9LqDJ8HcyzKBLa6JXxEb /3xZEz32xsZ2dkUH+rLXIe4v0nHnWBDlnRtKpZhJ8yXY4vpZxNtFLrLbkOjx4jEfCy49 ESP3Qcm/fdrUinvSFCYtVHd323URGv6C1ZoeBiEIlfnbHhK/01C/F9L6uM9AM6Lce9qd +E1g== X-Gm-Message-State: AOAM531DGSpQzo7NjRU5ic2F1NLqBi1QgE9ZhFgxWAyZAynrCZcC87JS 4cpEQyXQ0Bg88+d1ORv2o/uPOQ== X-Google-Smtp-Source: ABdhPJzrDemsOxIA4+EQcxNs+W0J3K3+BU0x9u6h2LfBZK/62l1ecJ8XQrxH+rEUc6Tj67mVnVjKVA== X-Received: by 2002:a17:902:ce8a:: with SMTP id f10mr174747plg.35.1643764227923; Tue, 01 Feb 2022 17:10:27 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:314e:b83b:fa90:7f2e]) by smtp.gmail.com with ESMTPSA id f5sm10761429pfc.0.2022.02.01.17.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:10:27 -0800 (PST) From: AKASHI Takahiro To: lukma@denx.de, peng.fan@nxp.com, jh80.chung@samsung.com, bmeng.cn@gmail.com, peng.ma@nxp.com, sr@denx.de, 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 17/19] efi_loader: disk: use udevice instead of blk_desc Date: Wed, 2 Feb 2022 10:08:51 +0900 Message-Id: <20220202010853.40405-18-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220202010853.40405-1-takahiro.akashi@linaro.org> References: <20220202010853.40405-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.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 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); } -- 2.33.0