From patchwork Sun Jan 6 15:08:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 209758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3CC932C0086 for ; Mon, 7 Jan 2013 02:10:07 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TrrqF-0000UK-PV; Sun, 06 Jan 2013 15:08:51 +0000 Received: from mail-bk0-f48.google.com ([209.85.214.48]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Trrq8-0000TQ-TS for linux-mtd@lists.infradead.org; Sun, 06 Jan 2013 15:08:45 +0000 Received: by mail-bk0-f48.google.com with SMTP id jc3so7904806bkc.21 for ; Sun, 06 Jan 2013 07:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=6IU72bPdGzptP5srdLDxQ78aahKqzyfXGJ9VrImlo24=; b=eDRgmYQ++4OKhojdWjSwR/gnVxpKYprMkqmLaCBOLZHBidL6XM7hMkKiPxowv7XCk9 H4P5YeqI0WvFo321ZjZly5KQZOI+HHA/0kIqsXfhRybrpOCyjzw/71HxyBy+cRcL9juN 5hHpkLdX6LIc6Q7JPmghtMUaoVRK3Z1CbP76rJ6Ahzy9u6Hj+N7YNCAmgWUbTUqCk99w dkiaH1b25J0K6MweSvOoPSMTos+jN2LhXWq6ergszMVbQZ6zuw+JkUj6BLHrFuMJmBOe Y67YC5n2xhPgTJuJkwrCOZTJF5EDCxOddEjXJ+IZ71SQab3p5LP+US1BUbYg4Jal/Iey wRyw== X-Received: by 10.204.3.211 with SMTP id 19mr28117433bko.99.1357484922661; Sun, 06 Jan 2013 07:08:42 -0800 (PST) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPS id o9sm40069783bko.15.2013.01.06.07.08.41 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Jan 2013 07:08:42 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: linux-mtd@lists.infradead.org, Artem Bityutskiy , David Woodhouse Subject: [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition Date: Sun, 6 Jan 2013 16:08:36 +0100 Message-Id: <1357484916-29965-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1357484916-29965-1-git-send-email-zajec5@gmail.com> References: <1357484916-29965-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130106_100845_107736_115FC4FF X-CRM114-Status: GOOD ( 14.63 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.48 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Hauke Mehrtens , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org It's required for accessing trx header (usually re-calculating a checksum) and for writing a new firmware. Signed-off-by: Rafał Miłecki --- I've checked this patch and got: > Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues I've also succesfully installed new firmware using mtd -r write /tmp/openwrt-brcm47xx-squashfs-noloader-wndr4500.trx firmware --- drivers/mtd/bcm47xxpart.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 06125eb..3411bc2 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c @@ -61,6 +61,8 @@ static int bcm47xxpart_parse(struct mtd_info *master, uint32_t offset; uint32_t blocksize = 0x10000; struct trx_header *trx; + int trx_part = -1; + int last_trx_part = -1; /* Alloc */ parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, @@ -131,6 +133,10 @@ static int bcm47xxpart_parse(struct mtd_info *master, if (buf[0x000 / 4] == TRX_MAGIC) { trx = (struct trx_header *)buf; + trx_part = curr_part; + bcm47xxpart_add_part(&parts[curr_part++], "firmware", + offset, 0); + i = 0; /* We have LZMA loader if offset[2] points to sth */ if (trx->offset[2]) { @@ -154,6 +160,8 @@ static int bcm47xxpart_parse(struct mtd_info *master, offset + trx->offset[i], 0); i++; + last_trx_part = curr_part - 1; + /* * We have whole TRX scanned, skip to the next part. Use * roundown (not roundup), as the loop will increase @@ -174,6 +182,9 @@ static int bcm47xxpart_parse(struct mtd_info *master, parts[i + 1].offset : master->size; parts[i].size = next_part_offset - parts[i].offset; + if (i == last_trx_part && trx_part >= 0) + parts[trx_part].size = next_part_offset - + parts[trx_part].offset; } *pparts = parts;