aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-05-22 14:25:34 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-22 14:25:34 -0400
commite4b636366c00738b9609cda307014d71b1225b7f (patch)
tree760b67b3624eda62e943e48ce93635c30a5b47bf /drivers/mtd
parentb9ed7252d219c1c663944bf03846eabb515dbe75 (diff)
parent279e677faa775ad16e75c32e1bf4a37f8158bc61 (diff)
Merge branch 'master' into for-2.6.31
Conflicts: drivers/block/hd.c drivers/block/mg_disk.c Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/m25p80.c26
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c2
-rw-r--r--drivers/mtd/mtdcore.c18
-rw-r--r--drivers/mtd/mtdsuper.c3
4 files changed, 31 insertions, 18 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 8185b1f3e5e6..cc6369ea67dd 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -54,7 +54,7 @@
54#define SR_SRWD 0x80 /* SR write protect */ 54#define SR_SRWD 0x80 /* SR write protect */
55 55
56/* Define max times to check status register before we give up. */ 56/* Define max times to check status register before we give up. */
57#define MAX_READY_WAIT_COUNT 100000 57#define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */
58#define CMD_SIZE 4 58#define CMD_SIZE 4
59 59
60#ifdef CONFIG_M25PXX_USE_FAST_READ 60#ifdef CONFIG_M25PXX_USE_FAST_READ
@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash)
139 */ 139 */
140static int wait_till_ready(struct m25p *flash) 140static int wait_till_ready(struct m25p *flash)
141{ 141{
142 int count; 142 unsigned long deadline;
143 int sr; 143 int sr;
144 144
145 /* one chip guarantees max 5 msec wait here after page writes, 145 deadline = jiffies + MAX_READY_WAIT_JIFFIES;
146 * but potentially three seconds (!) after page erase. 146
147 */ 147 do {
148 for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
149 if ((sr = read_sr(flash)) < 0) 148 if ((sr = read_sr(flash)) < 0)
150 break; 149 break;
151 else if (!(sr & SR_WIP)) 150 else if (!(sr & SR_WIP))
152 return 0; 151 return 0;
153 152
154 /* REVISIT sometimes sleeping would be best */ 153 cond_resched();
155 } 154
155 } while (!time_after_eq(jiffies, deadline));
156 156
157 return 1; 157 return 1;
158} 158}
@@ -246,10 +246,12 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
246 mutex_lock(&flash->lock); 246 mutex_lock(&flash->lock);
247 247
248 /* whole-chip erase? */ 248 /* whole-chip erase? */
249 if (len == flash->mtd.size && erase_chip(flash)) { 249 if (len == flash->mtd.size) {
250 instr->state = MTD_ERASE_FAILED; 250 if (erase_chip(flash)) {
251 mutex_unlock(&flash->lock); 251 instr->state = MTD_ERASE_FAILED;
252 return -EIO; 252 mutex_unlock(&flash->lock);
253 return -EIO;
254 }
253 255
254 /* REVISIT in some cases we could speed up erasing large regions 256 /* REVISIT in some cases we could speed up erasing large regions
255 * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up 257 * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 62dee54af0a5..43976aa4dbb1 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -178,7 +178,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
178 /* Calculate flash page address; use block erase (for speed) if 178 /* Calculate flash page address; use block erase (for speed) if
179 * we're at a block boundary and need to erase the whole block. 179 * we're at a block boundary and need to erase the whole block.
180 */ 180 */
181 pageaddr = div_u64(instr->len, priv->page_size); 181 pageaddr = div_u64(instr->addr, priv->page_size);
182 do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize; 182 do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize;
183 pageaddr = pageaddr << priv->page_offset; 183 pageaddr = pageaddr << priv->page_offset;
184 184
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fdd6ae859397..bccb4b1ffc46 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -48,11 +48,11 @@ static LIST_HEAD(mtd_notifiers);
48 */ 48 */
49static void mtd_release(struct device *dev) 49static void mtd_release(struct device *dev)
50{ 50{
51 struct mtd_info *mtd = dev_to_mtd(dev); 51 dev_t index = MTD_DEVT(dev_to_mtd(dev)->index);
52 52
53 /* remove /dev/mtdXro node if needed */ 53 /* remove /dev/mtdXro node if needed */
54 if (MTD_DEVT(mtd->index)) 54 if (index)
55 device_destroy(mtd_class, MTD_DEVT(mtd->index) + 1); 55 device_destroy(mtd_class, index + 1);
56} 56}
57 57
58static ssize_t mtd_type_show(struct device *dev, 58static ssize_t mtd_type_show(struct device *dev,
@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev,
132} 132}
133static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL); 133static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
134 134
135static ssize_t mtd_subpagesize_show(struct device *dev,
136 struct device_attribute *attr, char *buf)
137{
138 struct mtd_info *mtd = dev_to_mtd(dev);
139 unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
140
141 return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
142
143}
144static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
145
135static ssize_t mtd_oobsize_show(struct device *dev, 146static ssize_t mtd_oobsize_show(struct device *dev,
136 struct device_attribute *attr, char *buf) 147 struct device_attribute *attr, char *buf)
137{ 148{
@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = {
169 &dev_attr_size.attr, 180 &dev_attr_size.attr,
170 &dev_attr_erasesize.attr, 181 &dev_attr_erasesize.attr,
171 &dev_attr_writesize.attr, 182 &dev_attr_writesize.attr,
183 &dev_attr_subpagesize.attr,
172 &dev_attr_oobsize.attr, 184 &dev_attr_oobsize.attr,
173 &dev_attr_numeraseregions.attr, 185 &dev_attr_numeraseregions.attr,
174 &dev_attr_name.attr, 186 &dev_attr_name.attr,
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 92285d0089c2..af8b42e0a55b 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -74,8 +74,7 @@ static int get_sb_mtd_aux(struct file_system_type *fs_type, int flags,
74 74
75 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 75 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
76 if (ret < 0) { 76 if (ret < 0) {
77 up_write(&sb->s_umount); 77 deactivate_locked_super(sb);
78 deactivate_super(sb);
79 return ret; 78 return ret;
80 } 79 }
81 80