Commit 8fe833c1 authored by Richard Purdie's avatar Richard Purdie Committed by Linus Torvalds

[PATCH] LED: add NAND MTD activity LED trigger

Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6d0cf3e0
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#include <linux/mtd/compatmac.h> #include <linux/mtd/compatmac.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/leds.h>
#include <asm/io.h> #include <asm/io.h>
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
...@@ -515,6 +516,8 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i ...@@ -515,6 +516,8 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i
return nand_isbad_bbt (mtd, ofs, allowbbt); return nand_isbad_bbt (mtd, ofs, allowbbt);
} }
DEFINE_LED_TRIGGER(nand_led_trigger);
/* /*
* Wait for the ready pin, after a command * Wait for the ready pin, after a command
* The timeout is catched later. * The timeout is catched later.
...@@ -524,12 +527,14 @@ static void nand_wait_ready(struct mtd_info *mtd) ...@@ -524,12 +527,14 @@ static void nand_wait_ready(struct mtd_info *mtd)
struct nand_chip *this = mtd->priv; struct nand_chip *this = mtd->priv;
unsigned long timeo = jiffies + 2; unsigned long timeo = jiffies + 2;
led_trigger_event(nand_led_trigger, LED_FULL);
/* wait until command is processed or timeout occures */ /* wait until command is processed or timeout occures */
do { do {
if (this->dev_ready(mtd)) if (this->dev_ready(mtd))
return; break;
touch_softlockup_watchdog(); touch_softlockup_watchdog();
} while (time_before(jiffies, timeo)); } while (time_before(jiffies, timeo));
led_trigger_event(nand_led_trigger, LED_OFF);
} }
/** /**
...@@ -817,6 +822,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) ...@@ -817,6 +822,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
else else
timeo += (HZ * 20) / 1000; timeo += (HZ * 20) / 1000;
led_trigger_event(nand_led_trigger, LED_FULL);
/* Apply this short delay always to ensure that we do wait tWB in /* Apply this short delay always to ensure that we do wait tWB in
* any case on any machine. */ * any case on any machine. */
ndelay (100); ndelay (100);
...@@ -840,6 +847,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) ...@@ -840,6 +847,8 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
} }
cond_resched(); cond_resched();
} }
led_trigger_event(nand_led_trigger, LED_OFF);
status = (int) this->read_byte(mtd); status = (int) this->read_byte(mtd);
return status; return status;
} }
...@@ -2724,6 +2733,21 @@ void nand_release (struct mtd_info *mtd) ...@@ -2724,6 +2733,21 @@ void nand_release (struct mtd_info *mtd)
EXPORT_SYMBOL_GPL (nand_scan); EXPORT_SYMBOL_GPL (nand_scan);
EXPORT_SYMBOL_GPL (nand_release); EXPORT_SYMBOL_GPL (nand_release);
static int __init nand_base_init(void)
{
led_trigger_register_simple("nand-disk", &nand_led_trigger);
return 0;
}
static void __exit nand_base_exit(void)
{
led_trigger_unregister_simple(nand_led_trigger);
}
module_init(nand_base_init);
module_exit(nand_base_exit);
MODULE_LICENSE ("GPL"); MODULE_LICENSE ("GPL");
MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>");
MODULE_DESCRIPTION ("Generic NAND flash driver code"); MODULE_DESCRIPTION ("Generic NAND flash driver code");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment