From patchwork Wed Dec 2 14:30:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vimal singh X-Patchwork-Id: 40050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 038A9B7BF3 for ; Thu, 3 Dec 2009 01:32:22 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NFqE7-0003s7-UD; Wed, 02 Dec 2009 14:30:44 +0000 Received: from mail-bw0-f212.google.com ([209.85.218.212]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NFqE0-0003qC-9G for linux-mtd@lists.infradead.org; Wed, 02 Dec 2009 14:30:41 +0000 Received: by bwz4 with SMTP id 4so221120bwz.2 for ; Wed, 02 Dec 2009 06:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=BOHAtI6RnViqQ0SM9Up99quoJVdUlht66TSgJjppWic=; b=quySt/UgR0R9rCTMAVbTeYwU4QXLzkHwyI1+wYixERKGq8lcYSSD61bM9yfCXxrpIK h2kXJrseAl/17CnD3gCBuZxHbky9MXeNnxzfr3hntGy8wIFwUxsk7T1bAfHy4ZUPO43/ 7KyRxuHUulFGcPLtoDZGWiupuAVkcLZbdq5pk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=phrG1a5HnsWOWC1prIaej5PnpBRH1H9Rzwl49rVyvUiSzGGqUWbfb4nbHsbVXadKvH vSvoUIUaOc6wT7YQRA3xKkNbWXPhxOMzd2ytRU5eAkhIVKOSN3X55xnN2r+WKGkqm6es 4mKEgriRgtp0LkMDK5MC13S43eXR8GXKePuN8= MIME-Version: 1.0 Received: by 10.204.2.196 with SMTP id 4mr230861bkk.7.1259764234810; Wed, 02 Dec 2009 06:30:34 -0800 (PST) From: Vimal Singh Date: Wed, 2 Dec 2009 20:00:14 +0530 Message-ID: Subject: [RFC] [PATCH] [MTD-UTILS]: flash_unlock: enhancing for unlocking of specified number of blocks To: Linux MTD X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091202_093036_937985_CBD0BC51 X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 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 This patch enhances the flash_unlock utility to be able to do unlocking for specified blocks range. This patch also fixes calculation of 'length' as in previous patch. Say there are 240 blocks present in the device. Then: offset starts from: 0x0 and full size of device: 0x1E00000 doing: 240 * 0x20000 gives -> 0x1E00000 But last block address should be 0x1DE0000 (which spans for 0x20000 bytes, adding up to size of 0x1E00000) Signed-off-by: Vimal Singh --- else if(strncmp(argv[1], "/dev/mtd", 8) != 0) @@ -50,8 +51,18 @@ int main(int argc, char *argv[]) exit(1); } - mtdLockInfo.start = 0; - mtdLockInfo.length = mtdInfo.size; + if (argc > 2) + mtdLockInfo.start = strtol(argv[2], NULL, 0); + else + mtdLockInfo.start = 0; + + if (argc > 3) { + count = strtol(argv[3], NULL, 0); + mtdLockInfo.length = mtdInfo.erasesize * count; + } else { + mtdLockInfo.length = mtdInfo.size - mtdInfo.erasesize; + } + if(ioctl(fd, MEMUNLOCK, &mtdLockInfo)) { fprintf(stderr, "Could not unlock MTD device: %s\n", argv[1]); @@ -61,4 +72,3 @@ int main(int argc, char *argv[]) return 0; } - --- a/flash_unlock.c 2009-11-24 19:33:18.000000000 +0530 +++ b/flash_unlock.c 2009-11-24 19:36:18.000000000 +0530 @@ -21,13 +21,14 @@ int main(int argc, char *argv[]) int fd; struct mtd_info_user mtdInfo; struct erase_info_user mtdLockInfo; + int count; /* * Parse command line options */ - if(argc != 2) + if(argc < 2) { - fprintf(stderr, "USAGE: %s \n", argv[0]); + fprintf(stderr, "USAGE: %s \n", argv[0]); exit(1); }