提交 621c2559 编写于 作者: L Linus Torvalds

Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6:
  mtd: fix timeout in M25P80 driver
  mtd: Bug in m25p80.c during whole-chip erase
  mtd: expose subpage size via sysfs
  mtd: mtd in mtd_release is unused without CONFIG_MTD_CHAR
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#define SR_SRWD 0x80 /* SR write protect */ #define SR_SRWD 0x80 /* SR write protect */
/* Define max times to check status register before we give up. */ /* Define max times to check status register before we give up. */
#define MAX_READY_WAIT_COUNT 100000 #define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */
#define CMD_SIZE 4 #define CMD_SIZE 4
#ifdef CONFIG_M25PXX_USE_FAST_READ #ifdef CONFIG_M25PXX_USE_FAST_READ
...@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash) ...@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash)
*/ */
static int wait_till_ready(struct m25p *flash) static int wait_till_ready(struct m25p *flash)
{ {
int count; unsigned long deadline;
int sr; int sr;
/* one chip guarantees max 5 msec wait here after page writes, deadline = jiffies + MAX_READY_WAIT_JIFFIES;
* but potentially three seconds (!) after page erase.
*/ do {
for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
if ((sr = read_sr(flash)) < 0) if ((sr = read_sr(flash)) < 0)
break; break;
else if (!(sr & SR_WIP)) else if (!(sr & SR_WIP))
return 0; return 0;
/* REVISIT sometimes sleeping would be best */ cond_resched();
}
} while (!time_after_eq(jiffies, deadline));
return 1; return 1;
} }
...@@ -246,10 +246,12 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -246,10 +246,12 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
mutex_lock(&flash->lock); mutex_lock(&flash->lock);
/* whole-chip erase? */ /* whole-chip erase? */
if (len == flash->mtd.size && erase_chip(flash)) { if (len == flash->mtd.size) {
if (erase_chip(flash)) {
instr->state = MTD_ERASE_FAILED; instr->state = MTD_ERASE_FAILED;
mutex_unlock(&flash->lock); mutex_unlock(&flash->lock);
return -EIO; return -EIO;
}
/* REVISIT in some cases we could speed up erasing large regions /* REVISIT in some cases we could speed up erasing large regions
* by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up
......
...@@ -48,11 +48,11 @@ static LIST_HEAD(mtd_notifiers); ...@@ -48,11 +48,11 @@ static LIST_HEAD(mtd_notifiers);
*/ */
static void mtd_release(struct device *dev) static void mtd_release(struct device *dev)
{ {
struct mtd_info *mtd = dev_to_mtd(dev); dev_t index = MTD_DEVT(dev_to_mtd(dev)->index);
/* remove /dev/mtdXro node if needed */ /* remove /dev/mtdXro node if needed */
if (MTD_DEVT(mtd->index)) if (index)
device_destroy(mtd_class, MTD_DEVT(mtd->index) + 1); device_destroy(mtd_class, index + 1);
} }
static ssize_t mtd_type_show(struct device *dev, static ssize_t mtd_type_show(struct device *dev,
...@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev, ...@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev,
} }
static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL); static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
static ssize_t mtd_subpagesize_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_to_mtd(dev);
unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
}
static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
static ssize_t mtd_oobsize_show(struct device *dev, static ssize_t mtd_oobsize_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = { ...@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = {
&dev_attr_size.attr, &dev_attr_size.attr,
&dev_attr_erasesize.attr, &dev_attr_erasesize.attr,
&dev_attr_writesize.attr, &dev_attr_writesize.attr,
&dev_attr_subpagesize.attr,
&dev_attr_oobsize.attr, &dev_attr_oobsize.attr,
&dev_attr_numeraseregions.attr, &dev_attr_numeraseregions.attr,
&dev_attr_name.attr, &dev_attr_name.attr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册