From patchwork Tue Jan 29 02:59:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1032446 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bg4SqMFe"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43pWTd2D8Vz9sDB for ; Tue, 29 Jan 2019 14:00:52 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 79221C21DF8; Tue, 29 Jan 2019 03:00:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 90505C21E1B; Tue, 29 Jan 2019 03:00:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D5AA5C21C6A; Tue, 29 Jan 2019 02:59:55 +0000 (UTC) Received: from mail-yb1-f193.google.com (mail-yb1-f193.google.com [209.85.219.193]) by lists.denx.de (Postfix) with ESMTPS id E7302C21DD4 for ; Tue, 29 Jan 2019 02:59:50 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id e12so7612382ybn.10 for ; Mon, 28 Jan 2019 18:59:50 -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=a62miuZQCVJwW3uz/r2tROwKNvbUujiLHFxxKcmGEAY=; b=bg4SqMFerjCDuOZj0XeBeQsONR/39wtqB33kr/bgDQ3nICQyo8N6mH3z9WSXfLPe28 NPiZQTXs8lqgciQe/xJzpLLkOLMMOHj3NayGkU3qqTupYhdA4u69ac3adKdL06EE6YB0 yfHHzOII+IpxHkzgJ5eXJ04ftH+Aeohl9vRMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a62miuZQCVJwW3uz/r2tROwKNvbUujiLHFxxKcmGEAY=; b=EJqqpfXp3Wj1AEWgx0njwSbhJXOG2DDGZOf+Rbc5qlY7AGJJLs3iRRe0texmwqy7QT qRINbGucoFwI57OlU1pfrdHalTGi4VvF6g2BYHyV2kMejsGwc/B+Vy6SLle3743H+7y8 34y7y+E+vxxGLjFK2u4T9/23zo75ypy3O7VMmQXxNJ7klu3bcJ4xJ9IKl6L4wPUdgnat iQWQUw0/LOfdT7AUXfioWokiejvyt9tEVfEJgQfj6RFsf5db7Jid2O+S+ET71lME0zVM XZfp+lcbNqIIt8Tw5r+YBEIg2BCeeW7IP4U/MS+gFEX8bUaNWuwmszkgOGVW946oEPRB fMKw== X-Gm-Message-State: AJcUuketUirNDb2nnLACfJhwc9/7GyIbtlk6zdjDk3sMPGET5HcW6s2Q cZlePk1adnXsaP2K2TVS0JiOY99QCbI= X-Google-Smtp-Source: ALg8bN6rKCL8FROxAbPGqvC2Glm+Mds6accLXBBXu8g/5Xkk1UVce/xQaq1+ozO5G2pHWIgoZdyyRA== X-Received: by 2002:a25:af07:: with SMTP id a7mr23674588ybh.400.1548730789871; Mon, 28 Jan 2019 18:59:49 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id g127sm13626076ywf.38.2019.01.28.18.59.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 18:59:49 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de, sjg@chromium.org Date: Tue, 29 Jan 2019 11:59:56 +0900 Message-Id: <20190129025956.21870-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190129025956.21870-1-takahiro.akashi@linaro.org> References: <20190129025956.21870-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RFC 3/3] drivers: align block device drivers with DM-efi integration X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Efi_disk_create() should be hook up at every creation of block device at each driver. Associated blk_desc must be properly set up before calling this function. Signed-off-by: AKASHI Takahiro --- common/usb_storage.c | 27 +++++++++++++++++++++++++-- drivers/scsi/scsi.c | 22 ++++++++++++++++++++++ lib/efi_driver/efi_block_device.c | 30 +++++++++--------------------- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/common/usb_storage.c b/common/usb_storage.c index 8c889bb1a648..ff895c0e4557 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -46,6 +46,10 @@ #include #include +/* FIXME */ +extern int efi_disk_create(struct udevice *dev); +extern int blk_create_partitions(struct udevice *parent); + #undef BBB_COMDAT_TRACE #undef BBB_XPORT_TRACE @@ -227,8 +231,27 @@ static int usb_stor_probe_device(struct usb_device *udev) ret = usb_stor_get_info(udev, data, blkdev); if (ret == 1) { - usb_max_devs++; - debug("%s: Found device %p\n", __func__, udev); + ret = efi_disk_create(dev); + if (ret) { + debug("Cannot create efi_disk device\n"); + ret = device_unbind(dev); + if (ret) + return ret; + } else { + usb_max_devs++; + ret = blk_create_partitions(dev); + if (ret < 0) { + debug("Cannot create disk partition device\n"); + /* TODO: undo create */ + + ret = device_unbind(dev); + if (ret) + return ret; + } + usb_max_devs += ret; + debug("%s: Found device %p, partitions:%d\n", + __func__, udev, ret); + } } else { debug("usb_stor_get_info: Invalid device\n"); ret = device_unbind(dev); diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index df47e2fc78bd..f0f8cbc0bf26 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -11,6 +11,10 @@ #include #include +/* FIXME */ +int efi_disk_create(struct udevice *dev); +int blk_create_partitions(struct udevice *parent); + #if !defined(CONFIG_DM_SCSI) # ifdef CONFIG_SCSI_DEV_LIST # define SCSI_DEV_LIST CONFIG_SCSI_DEV_LIST @@ -593,9 +597,27 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose) memcpy(&bdesc->product, &bd.product, sizeof(bd.product)); memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision)); + ret = efi_disk_create(bdev); + if (ret) { + debug("Can't create efi_disk device\n"); + ret = device_unbind(bdev); + + return ret; + } + ret = blk_create_partitions(bdev); + if (ret < 0) { + debug("Can't create efi_disk partitions\n"); + /* TODO: undo create */ + + ret = device_unbind(bdev); + + return ret; + } + if (verbose) { printf(" Device %d: ", 0); dev_print(bdesc); + debug("Found %d partitions\n", ret); } return 0; } diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c index 3f147cf60879..4ab3402d6768 100644 --- a/lib/efi_driver/efi_block_device.c +++ b/lib/efi_driver/efi_block_device.c @@ -32,6 +32,10 @@ #include #include +/* FIXME */ +extern int efi_disk_create(struct udevice *dev); +extern int blk_create_partitions(struct udevice *parent); + /* * EFI attributes of the udevice handled by this driver. * @@ -102,24 +106,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt, return blkcnt; } -/* - * Create partions for the block device. - * - * @handle EFI handle of the block device - * @dev udevice of the block device - */ -static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev) -{ - struct blk_desc *desc; - const char *if_typename; - - desc = dev_get_uclass_platdata(dev); - if_typename = blk_get_if_type_name(desc->if_type); - - return efi_disk_create_partitions(handle, desc, if_typename, - desc->devnum, dev->name); -} - /* * Create a block device for a handle * @@ -168,15 +154,17 @@ static int efi_bl_bind(efi_handle_t handle, void *interface) platdata->handle = handle; platdata->io = interface; + ret = efi_disk_create(bdev); + if (ret) + return ret; + ret = device_probe(bdev); if (ret) return ret; EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); - /* Create handles for the partions of the block device */ - disks = efi_bl_bind_partitions(handle, bdev); + disks = blk_create_partitions(bdev); EFI_PRINT("Found %d partitions\n", disks); - return 0; }