From patchwork Wed Feb 2 01:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 539317 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp1192958imr; Tue, 1 Feb 2022 17:13:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgScronSIYplGynCjiX2UAxnKd735e5Uz2eYIFXn+ngExAD4SOaaNYENLz6FTBF2MjyKd/ X-Received: by 2002:a17:907:1622:: with SMTP id hb34mr23443754ejc.280.1643764425939; Tue, 01 Feb 2022 17:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643764425; cv=none; d=google.com; s=arc-20160816; b=bQSTJmnQEu7yl2ydzz1JFKlD5CyYuVI+c3pErTAIuE2YFBJeblpt7sG1Hbl69wRG4T O/0vJMQg9WtNz/2cCjmokvJQF8K+dw6nSDzqlqiXwsKZCTdmr+uHNg9M6dKZxcqrhJGy 0bI8t8O2YmvN1wBaeyy7yqUp3wAOe7+mRemyN1cLpeMjvBOvvZ32kFnUdMIdFAzUNscb jJIbX384HSj7eve6dXWpeAxiXj7BogPTrLvbZYctTz4dE3l0TZKJPAcVeWb93FiydJ7u b73qmvPFPOVAX3lfkAHAMV978GjogYy3PinwS1AX0XAeEf0KscT/8i5dQJalQAt9/7Fn 2i1Q== 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=3FYoYlTI2sh6c0aqIN0PncgivPez6oVYEDUBCXbdrT8=; b=EjLbzZKOCRRbzUEbkjOINHZ3Ad65s6QMR5dNTAjTDOMZWYGZS4IoDS1GZOG2cVH8fi 759RIYeOBJ3cHJ9g+sw27YcvRRvWZ+In+NAzG3y46frVcIARtFoQ6N5VbkdG70qk7bwp druDsW8nxtWJIJhkIIP+hF4cik0rLz0CCUGL7WD2JRQsCLrXgKpanZX+AbayxlJaIpfc KzfAtQfdtylKFddvuNH2GfRCmw5Yw4MG3SQ2gXsrKX8wXi6KYKA71TZwQTMhUdGo95Mr srimN7HlhmgmLanlJwDEcQ94JjMjgooxM4aLigNTKi0sIKFQniXbOBGhFoevCCwua0wz iXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8UuVWqN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id cs16si5026638ejc.455.2022.02.01.17.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 17:13:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J8UuVWqN; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 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) 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=unavailable autolearn_force=no version=3.4.2 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-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 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); }