From patchwork Sat Nov 10 21:14:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 996007 X-Patchwork-Delegate: boris.brezillon@free-electrons.com 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.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ox2wVVwp"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SB8MRiRL"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42sqXm49Lmz9s7h for ; Sun, 11 Nov 2018 08:14:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1T//nm8U2Mo9EX2ZHkzxBVT/bneFgJfIXQd5mDte40g=; b=Ox2wVVwpbW5IXQ qlTuVbtCuaCFhpZS01+Pv0obI+Hz94C/xoYlwNS/pwugDT+g9QCbZcnKPVUFgFK8HguYnNPo1HJ41 ydLjjdyQ1W3Edw7h8mSDQpPmW+f4ZJLoEL7FeI2Bav1gA7UEqq6jzkysEp/ROSgk3eZaMC3VJFP5m WP+yfTpzXxZwjZyQdb8amgUUj18xHcfIijcZcg87htW+Pyre0E0IlUHtEA67CZc/1PUONJim6ARXe UO60uf77Q83VLlBcqDchkOPVR2Lg4kHtpGWOOUSW0EPLI3dJbabGlm3SZXbFvsQc0pGG8/5L8Oc5h tTBPjaINy6UM5tOZoEbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLaaY-00079m-8P; Sat, 10 Nov 2018 21:14:42 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLaaT-000791-Ue for linux-mtd@lists.infradead.org; Sat, 10 Nov 2018 21:14:39 +0000 Received: by mail-lf1-x143.google.com with SMTP id e26so1905030lfc.2 for ; Sat, 10 Nov 2018 13:14:23 -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:mime-version :content-transfer-encoding; bh=QKs0gydDw9X6yqGoSM6q297ISZLJIJvfWWKrF+2P8bY=; b=SB8MRiRLdQUv4ojsV69RFolzlwyS83cyc0DKzgufwb8InWnFH4/thNXV0h1clemcqt fZ48DGR5lJBteHPENH1+3z9Fa5no4z3endygDjKupZvNiAwf/nmJvvVPJT83vYA7112s qwhAf2rtm7v8h//YEavEiu/HL/8e5V/2vzBgw= 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:mime-version :content-transfer-encoding; bh=QKs0gydDw9X6yqGoSM6q297ISZLJIJvfWWKrF+2P8bY=; b=WKK3325ZcagIMMip1RDlq+yHHm8WmZ26eVDktyuNmzff47uFUUQHMmdCfio4jJR9i8 qrPiW/HZ1ZHV/3I3kD6/nLKCBMyhwCAHep28KiM6vc12tAzbgilGHgteB+bZTeF9a5mS K9JbOMZrpNQX0xXxcREjL5J6v7jL4jtFBm8RtfMxL9s3aB9TpdFNthMjkKqLUlus9k2y JprHr0DUlNWmmN2XjadqgSf+PSCN9yDr5jpaNB7CRBNC4DA6w+7sQp3MetbvUI+koeDM LIvmzwlSHCQJfvS/AevH/ObisDKrHXMEdXyJwbt+HwCbMoEX44fp1qOvXCph888pIaJM rtCg== X-Gm-Message-State: AGRZ1gI0yNuHrYty4krlbxvb6DNrDX5Rhm7tue6EC2wbevhOaEiWSHUk iUMZ89TC2ouZGID1x/TdXPD+xQ== X-Google-Smtp-Source: AJdET5eZ9NsVhTUMlwEvvVCDVNtwR/qNQAs+evQrFER0ZDfarq3Wnzs1voTkNLBEHtjKQqvH9LVUKA== X-Received: by 2002:a19:d58e:: with SMTP id m136mr8749775lfg.70.1541884461854; Sat, 10 Nov 2018 13:14:21 -0800 (PST) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id j18-v6sm2158237ljc.52.2018.11.10.13.14.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Nov 2018 13:14:20 -0800 (PST) From: Linus Walleij To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH 3/3 v3] mtd: partitions: Add OF support to RedBoot partitions Date: Sat, 10 Nov 2018 22:14:13 +0100 Message-Id: <20181110211413.15707-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181110_131438_044541_03B3548C X-CRM114-Status: GOOD ( 19.38 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:143 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds device tree support for RedBoot partitioning. We read out the FIS directory block information from the device tree and then parse the partition table from there. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Fix copy/paste bug identified by the build robot. ChangeLog v1->v2: - Rebased on linux-mtd-next for v4.21 --- drivers/mtd/parsers/redboot.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c index 7623ac5fc586..cc04a36c8251 100644 --- a/drivers/mtd/parsers/redboot.c +++ b/drivers/mtd/parsers/redboot.c @@ -25,7 +25,7 @@ #include #include #include - +#include #include #include #include @@ -56,6 +56,31 @@ static inline int redboot_checksum(struct fis_image_desc *img) return 1; } +#ifdef CONFIG_OF +static void parse_redboot_of(struct mtd_info *master) +{ + struct device_node *np; + u32 dirblock; + int ret; + + np = mtd_get_of_node(master); + if (!np) + return; + ret = of_property_read_u32(np, "fis-index-block", &dirblock); + if (ret) + return; + /* + * Assign the block found in the device tree to the local + * directory block pointer. + */ + directory = dirblock; +} +#else +static void parse_redboot_of(struct mtd_info *master) +{ +} +#endif + static int parse_redboot_partitions(struct mtd_info *master, const struct mtd_partition **pparts, struct mtd_part_parser_data *data) @@ -75,6 +100,7 @@ static int parse_redboot_partitions(struct mtd_info *master, #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED static char nullstring[] = "unallocated"; #endif + parse_redboot_of(master); if ( directory < 0 ) { offset = master->size + directory * master->erasesize; @@ -289,9 +315,16 @@ static int parse_redboot_partitions(struct mtd_info *master, return ret; } +static const struct of_device_id mtd_parser_redboot_of_match_table[] = { + { .compatible = "redboot-fis" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mtd_parser_redboot_of_match_table); + static struct mtd_part_parser redboot_parser = { .parse_fn = parse_redboot_partitions, .name = "RedBoot", + .of_match_table = mtd_parser_redboot_of_match_table, }; module_mtd_part_parser(redboot_parser);