From patchwork Wed Dec 2 14:33:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: vimal singh X-Patchwork-Id: 40052 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 95CCFB7BF3 for ; Thu, 3 Dec 2009 01:36:06 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NFqHf-0004cq-CF; Wed, 02 Dec 2009 14:34:23 +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 1NFqHY-0004bA-VR for linux-mtd@lists.infradead.org; Wed, 02 Dec 2009 14:34:21 +0000 Received: by bwz4 with SMTP id 4so224918bwz.2 for ; Wed, 02 Dec 2009 06:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=6FlHLszPVOsifBOKDlI7Gee9iMDn+1L6P/Zf7cd0AGE=; b=KD02qprHwgD7/SqcZtfdgNo+2Xcv+OVlHmAWqI+Jw9WFK67X16BtYXscDAXa+Ufurt TpCIo96nTw8vu1XaAoo2Gy2Oq1bqEuDY0P3OpWYgBlWYQWCt5GdlJeFgl8RfdUMXq0Ge H6moG4u7/eKI6fCyC7WRMy0/mU4hNIvL/8IPQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=ritwO+ND8K/p1Bh/AP1ht3wZqK0RbOYiyEjLpQVyp4mTHyFeCDE3Z1pv2ZTXTUHMdZ tr+U9YTHzV7l8YA/5UMCVnZF/A8GJpq4ul23eppRYhFrhrvlfcUg9YRxxJd/LGJZV9o/ BXvh0ec1/HvVOdDujjiry3EmB9d2zmklyQ7TA= MIME-Version: 1.0 Received: by 10.204.10.149 with SMTP id p21mr235935bkp.3.1259764455213; Wed, 02 Dec 2009 06:34:15 -0800 (PST) In-Reply-To: References: From: Vimal Singh Date: Wed, 2 Dec 2009 20:03:55 +0530 Message-ID: Subject: Re: [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed To: Linux MTD X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091202_093417_172889_2C10DB3A X-CRM114-Status: GOOD ( 14.30 ) 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 On Wed, Dec 2, 2009 at 7:58 PM, Vimal Singh wrote: > This patch fixes the 'length' calculation. > Making it: > +       mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize; > Rather: > -       mtdLockInfo.length = num_sectors * mtdInfo.erasesize; > > 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 upto size of 0x1E00000) > > Signed-off-by: Vimal Singh > --- > > --- flash_lock.c.org    2009-11-24 19:33:18.000000000 +0530 > +++ flash_lock.c        2009-11-24 19:33:13.000000000 +0530 Sorry, this patch was generated using 'diff'. Below is the correct patch. -vimal This patch fixes the 'length' calculation. Making it: mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize; Rather: mtdLockInfo.length = num_sectors * mtdInfo.erasesize; 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 upto size of 0x1E00000) Signed-off-by: Vimal Singh --- a/flash_lock.c 2009-11-24 19:33:18.000000000 +0530 +++ b/flash_lock.c 2009-11-24 19:33:13.000000000 +0530 @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) } mtdLockInfo.start = ofs; - mtdLockInfo.length = num_sectors * mtdInfo.erasesize; + mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize; if(ioctl(fd, MEMLOCK, &mtdLockInfo)) { fprintf(stderr, "Could not lock MTD device: %s\n", argv[1]); @@ -81,4 +81,3 @@ int main(int argc, char *argv[]) return 0; } -