From patchwork Tue Jan 29 02:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1032444 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="GMQAo18l"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43pWSk2xWZz9sDB for ; Tue, 29 Jan 2019 14:00:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 1F53DC21BE5; Tue, 29 Jan 2019 02:59:49 +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 1654FC21DFB; Tue, 29 Jan 2019 02:59:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 91C2DC21D8A; Tue, 29 Jan 2019 02:59:41 +0000 (UTC) Received: from mail-yw1-f66.google.com (mail-yw1-f66.google.com [209.85.161.66]) by lists.denx.de (Postfix) with ESMTPS id C4ED1C21DC1 for ; Tue, 29 Jan 2019 02:59:37 +0000 (UTC) Received: by mail-yw1-f66.google.com with SMTP id h32so7658182ywk.2 for ; Mon, 28 Jan 2019 18:59:37 -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=cnXbOJl7Pm87gBHrmYk84LFqaci0lN00kOnUJx1FmSg=; b=GMQAo18lZHHEYZ7lOPJCBgQW4lsOWu5vdB7hLNSzcr4PBM6LC34/sW27zouCTOeul4 g8/oWXsedBAIvIIKAz6X4MtoKkob9iImGT2GJVwM7rYvVhxUBbinTI5PNfFpe+Q7u106 HY7vdYGfB82WxvDWdxTHtwJoClh43/LqusaGs= 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=cnXbOJl7Pm87gBHrmYk84LFqaci0lN00kOnUJx1FmSg=; b=O2m2fFnOGXh6LPaOuiLK4SeZUvlltFJCgmiMJ5uMi9COSEffQ1VuE7evZ17eSSuB7W iBWF34/JozFfa2V15Z0lLxuX7WXws9lVR+YVTinbUjTcczM6x5ueh3YorXIXluN6Gz/3 fMuJBSqQnAwvV2R6P6k/sP/bwlkP9DfEFAVSkYU83M6P9OoYfOZsPe8cR7jY83z1OUnc ZdUi0rv/O6pKleCe/I53B8VZQrWClgQMO8esiax7EK0UhSu1dGDSsJ7N0gHoMtw7hKAg t2htg6mPf5qx8jM2y0Vdv9zp8Asi3s3OmS5fIjbMhAa515k0mhmzCiIEZuPNmOE9ivuh 57bg== X-Gm-Message-State: AJcUukeX0aUvROLQiVKVA53qMFYGVz8T13F/Ek2WN4oW/6xDPdLjuVr0 3VMnNSxBLeS7YuXHpzSMAZEYWA== X-Google-Smtp-Source: ALg8bN5QtLRN/yDIqIHr7oWIc1R0MSD7a1lfaEihlqLl6/HS/b+L1Uq47fy4tDXAHg8cdpmwvzm4lw== X-Received: by 2002:a81:695:: with SMTP id 143mr23640064ywg.370.1548730776780; Mon, 28 Jan 2019 18:59:36 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c127sm12777640ywb.67.2019.01.28.18.59.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 18:59:36 -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:54 +0900 Message-Id: <20190129025956.21870-2-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 1/3] dm: blk: add UCLASS_PARTITION 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" UCLASS_PARTITION device will be created as a child node of UCLASS_BLK device. Signed-off-by: AKASHI Takahiro --- drivers/block/blk-uclass.c | 52 ++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 2 files changed, 53 insertions(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index baaf431e5e0c..d4ca30f23fc1 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include static const char *if_typename_str[IF_TYPE_COUNT] = { [IF_TYPE_IDE] = "ide", @@ -654,3 +656,53 @@ UCLASS_DRIVER(blk) = { .post_probe = blk_post_probe, .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc), }; + +U_BOOT_DRIVER(blk_partition) = { + .name = "blk_partition", + .id = UCLASS_PARTITION, + .platdata_auto_alloc_size = sizeof(struct disk_part), +}; + +UCLASS_DRIVER(partition) = { + .id = UCLASS_PARTITION, + .name = "partition", +}; + +#if defined(CONFIG_PARTITIONS) && defined(CONFIG_HAVE_BLOCK_DEVICE) +int blk_create_partitions(struct udevice *parent) +{ + int part; + struct blk_desc *desc = dev_get_uclass_platdata(parent); + disk_partition_t info; + struct disk_part *part_data; + char devname[32]; + struct udevice *dev; + int disks = 0, ret; + + /* Add devices for each partition */ + for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { + if (part_get_info(desc, part, &info)) + continue; + snprintf(devname, sizeof(devname), "%s:%d", parent->name, + part); + + ret = device_bind_driver(parent, "blk_partition", + strdup(devname), &dev); + if (ret) + return ret; + + part_data = dev_get_uclass_platdata(dev); + part_data->partnum = part; + part_data->gpt_part_info = info; + + disks++; + } + + return disks; +} +#else +int blk_create_partitions(struct udevice *dev) +{ + return 0; +} +#endif diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index f3bafb3c6353..e02b5f8fda42 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -65,6 +65,7 @@ enum uclass_id { UCLASS_NVME, /* NVM Express device */ UCLASS_PANEL, /* Display panel, such as an LCD */ UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */ + UCLASS_PARTITION, /* Logical disk partition device */ UCLASS_PCH, /* x86 platform controller hub */ UCLASS_PCI, /* PCI bus */ UCLASS_PCI_GENERIC, /* Generic PCI bus device */