From patchwork Thu Apr 9 05:52:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cernekee X-Patchwork-Id: 25763 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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 69E2ADE0DB for ; Thu, 9 Apr 2009 15:55:22 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LrnBn-0004Nc-MB; Thu, 09 Apr 2009 05:52:39 +0000 Received: from qw-out-1920.google.com ([74.125.92.150]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LrnBd-0004Mj-VU for linux-mtd@lists.infradead.org; Thu, 09 Apr 2009 05:52:38 +0000 Received: by qw-out-1920.google.com with SMTP id 5so355144qwf.24 for ; Wed, 08 Apr 2009 22:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=Wv5bVa1gc4OeRwwAdbbg2UMHPSHv4NLwdxV5juPyV0k=; b=DowCk6J2v3cdq5GxT7kb1LfyP5FUyRwheqL4iIgBO3zueKmZQ69IUWF3mFXDyVG31y c4Kzw/BQv3ngGFDXtoH5OnnndladyVQZHXf/UhtNHm4o7dPV7/XW0OGofCXffL6QTx+6 QE07IT78rYDdA8ICXKBK2zYuQaBOK+iX4tVo0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=FL13UDu4lrkVGyk1d8vogJYWD77hYNNpgVe+fuIH2YhkIWUq7HgI0dO2M2/RxAPWkL xT2CoX3qesLcEjZVdzEIAvOF8N77Cxu6OBp/kFazSFF14JcjboZztMCpz5gHQBvJKEE/ kiVqABPT6KeuHvnlW7YtNUuAWACqHl3//9lHE= MIME-Version: 1.0 Received: by 10.229.98.141 with SMTP id q13mr811690qcn.3.1239256348411; Wed, 08 Apr 2009 22:52:28 -0700 (PDT) Date: Wed, 8 Apr 2009 22:52:28 -0700 Message-ID: Subject: [PATCH 2/4] [MTD] Add MEMERASE64 ioctl for >4GiB devices From: Kevin Cernekee To: David Woodhouse X-Spam-Score: 0.0 (/) Cc: Linux MTD , "linux-kernel@vger.kernel.org" X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 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 New MEMERASE/MEMREADOOB/MEMWRITEOOB ioctls are needed in order to support 64-bit offsets into large NAND flash devices. Signed-off-by: Kevin Cernekee --- drivers/mtd/mtdchar.c | 29 +++++++++++++++++++++-------- fs/compat_ioctl.c | 1 + include/mtd/mtd-abi.h | 6 ++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 763d3f0..ad4b861 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -417,6 +417,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, break; case MEMERASE: + case MEMERASE64: { struct erase_info *erase; @@ -427,20 +428,32 @@ static int mtd_ioctl(struct inode *inode, struct file *file, if (!erase) ret = -ENOMEM; else { - struct erase_info_user einfo; - wait_queue_head_t waitq; DECLARE_WAITQUEUE(wait, current); init_waitqueue_head(&waitq); - if (copy_from_user(&einfo, argp, - sizeof(struct erase_info_user))) { - kfree(erase); - return -EFAULT; + if (cmd == MEMERASE64) { + struct erase_info_user64 einfo64; + + if (copy_from_user(&einfo64, argp, + sizeof(struct erase_info_user64))) { + kfree(erase); + return -EFAULT; + } + erase->addr = einfo64.start; + erase->len = einfo64.length; + } else { + struct erase_info_user einfo32; + + if (copy_from_user(&einfo32, argp, + sizeof(struct erase_info_user))) { + kfree(erase); + return -EFAULT; + } + erase->addr = einfo32.start; + erase->len = einfo32.length; } - erase->addr = einfo.start; - erase->len = einfo.length; erase->mtd = mtd; erase->callback = mtdchar_erase_callback; erase->priv = (unsigned long)&waitq; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 3e87ce4..06d4e0c 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -2441,6 +2441,7 @@ COMPATIBLE_IOCTL(MEMGETREGIONCOUNT) COMPATIBLE_IOCTL(MEMGETREGIONINFO) COMPATIBLE_IOCTL(MEMGETBADBLOCK) COMPATIBLE_IOCTL(MEMSETBADBLOCK) +COMPATIBLE_IOCTL(MEMERASE64) /* NBD */ ULONG_IOCTL(NBD_SET_SOCK) ULONG_IOCTL(NBD_SET_BLKSIZE) diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h index b6595b3..2e32be1 100644 --- a/include/mtd/mtd-abi.h +++ b/include/mtd/mtd-abi.h @@ -12,6 +12,11 @@ struct erase_info_user { __u32 length; }; +struct erase_info_user64 { + __u64 start; + __u64 length; +}; + struct mtd_oob_buf { __u32 start; __u32 length; @@ -95,6 +100,7 @@ struct otp_info { #define ECCGETLAYOUT _IOR('M', 17, struct nand_ecclayout) #define ECCGETSTATS _IOR('M', 18, struct mtd_ecc_stats) #define MTDFILEMODE _IO('M', 19) +#define MEMERASE64 _IOW('M', 20, struct erase_info_user64) /* * Obsolete legacy interface. Keep it in order not to break userspace