summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorAshutosh Patel <ashutoshp@nvidia.com>2013-01-08 10:50:07 +0530
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 01:32:16 -0700
commitacfe345a322abdae4bad4a7933952c36c2318964 (patch)
treeb23bc1c41172e73548dc1ebc0ddc4139d8b1229d /drivers/mtd
parent691ef04b968369ebd2d05e2bcff0a7546d6e469a (diff)
tegra: nor: mtdblock : Add support for 8GB flash
Changes : - Add support for 8GB flash in mtblock - Change data type from unsigned long to unsigned long long - Changed logic of finding sect_start to avoid 64-bit/64-bit division bug 1182116 Change-Id: I782e509039e6d3a46870c641fec10cf9e3e2d73d Signed-off-by: Ashutosh Patel <ashutoshp@nvidia.com> Reviewed-on: http://git-master/r/188276 Reviewed-by: Bharath H S <bhs@nvidia.com> Reviewed-by: Bhavesh Parekh <bparekh@nvidia.com> Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtd_blkdevs.c4
-rw-r--r--drivers/mtd/mtdblock.c37
2 files changed, 20 insertions, 21 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 5073cbc796d8..a12dd4b7eee6 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -78,7 +78,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
struct mtd_blktrans_dev *dev,
struct request *req)
{
- unsigned long block, nsect;
+ unsigned long long block, nsect;
char *buf;
block = blk_rq_pos(req) << 9 >> tr->blkshift;
@@ -96,7 +96,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
if (req->cmd_flags & REQ_DISCARD)
return tr->discard(dev, block, nsect);
- switch(rq_data_dir(req)) {
+ switch (rq_data_dir(req)) {
case READ:
for (; nsect > 0; nsect--, block++, buf += tr->blksize)
if (tr->readsect(dev, block, buf))
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 2aef5dda522b..db0d31b63a9c 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -39,8 +39,8 @@ struct mtdblk_dev {
int count;
struct mutex cache_mutex;
unsigned char *cache_data;
- unsigned long cache_offset;
- unsigned int cache_size;
+ unsigned long long cache_offset;
+ unsigned long long cache_size;
enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state;
};
@@ -62,7 +62,7 @@ static void erase_callback(struct erase_info *done)
wake_up(wait_q);
}
-static int erase_write (struct mtd_info *mtd, unsigned long pos,
+static int erase_write (struct mtd_info *mtd, unsigned long long pos,
int len, const char *buf)
{
struct erase_info erase;
@@ -89,7 +89,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos,
if (ret) {
set_current_state(TASK_RUNNING);
remove_wait_queue(&wait_q, &wait);
- printk (KERN_WARNING "mtdblock: erase of region [0x%lx, 0x%x] "
+ printk (KERN_WARNING "mtdblock: erase of region [0x%llx, 0x%x] "
"on \"%s\" failed\n",
pos, len, mtd->name);
return ret;
@@ -120,7 +120,7 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
return 0;
pr_debug("mtdblock: writing cached data for \"%s\" "
- "at 0x%lx, size 0x%x\n", mtd->name,
+ "at 0x%llx, size 0x%llx\n", mtd->name,
mtdblk->cache_offset, mtdblk->cache_size);
ret = erase_write (mtd, mtdblk->cache_offset,
@@ -139,12 +139,11 @@ static int write_cached_data (struct mtdblk_dev *mtdblk)
return 0;
}
-
-static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
+static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long long pos,
int len, const char *buf)
{
struct mtd_info *mtd = mtdblk->mbd.mtd;
- unsigned int sect_size = mtdblk->cache_size;
+ unsigned long long sect_size = mtdblk->cache_size;
size_t retlen;
int ret;
@@ -155,9 +154,9 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
return mtd_write(mtd, pos, len, &retlen, buf);
while (len > 0) {
- unsigned long sect_start = (pos/sect_size)*sect_size;
- unsigned int offset = pos - sect_start;
- unsigned int size = sect_size - offset;
+ unsigned long long sect_start = pos & ~(sect_size-1);
+ unsigned long long offset = pos - sect_start;
+ unsigned long long size = sect_size - offset;
if( size > len )
size = len;
@@ -210,24 +209,24 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
}
-static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
+static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long long pos,
int len, char *buf)
{
struct mtd_info *mtd = mtdblk->mbd.mtd;
- unsigned int sect_size = mtdblk->cache_size;
+ unsigned long long sect_size = mtdblk->cache_size;
size_t retlen;
int ret;
- pr_debug("mtdblock: read on \"%s\" at 0x%lx, size 0x%x\n",
+ pr_debug("mtdblock: read on \"%s\" at 0x%llx, size 0x%x\n",
mtd->name, pos, len);
if (!sect_size)
return mtd_read(mtd, pos, len, &retlen, buf);
while (len > 0) {
- unsigned long sect_start = (pos/sect_size)*sect_size;
- unsigned int offset = pos - sect_start;
- unsigned int size = sect_size - offset;
+ unsigned long long sect_start = pos & ~(sect_size-1);
+ unsigned long long offset = pos - sect_start;
+ unsigned long long size = sect_size - offset;
if (size > len)
size = len;
@@ -257,14 +256,14 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
}
static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
- unsigned long block, char *buf)
+ unsigned long long block, char *buf)
{
struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
return do_cached_read(mtdblk, block<<9, 512, buf);
}
static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
- unsigned long block, char *buf)
+ unsigned long long block, char *buf)
{
struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
if (unlikely(!mtdblk->cache_data && mtdblk->cache_size)) {