mfd: ab8500-debugfs: Add interrupt debug
authorBengt Jonsson <bengt.g.jonsson@stericsson.com>
Tue, 14 Feb 2012 12:01:00 +0000 (13:01 +0100)
committerLee Jones <lee.jones@linaro.org>
Mon, 4 Feb 2013 08:31:50 +0000 (08:31 +0000)
This patch adds an entry in debugfs to check number of interrupts
from the AB.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
drivers/mfd/ab8500-core.c
drivers/mfd/ab8500-debugfs.c
include/linux/mfd/abx500/ab8500.h

index d228697f5d9b80c7acb921fed2918251c19cc2a8..05a7af4b976818b237be81bfc8df672f738aa9f4 100644 (file)
@@ -521,6 +521,7 @@ static irqreturn_t ab8500_irq(int irq, void *dev)
                        int virq = ab8500_irq_get_virq(ab8500, line);
 
                        handle_nested_irq(virq);
+                       ab8500_debug_register_interrupt(line);
                        value &= ~(1 << bit);
 
                } while (value);
index 8617b132e73017962d6f16f6833b62e9ae9b10e2..cbebbd7e7b409bcca207f865f997e13359802b88 100644 (file)
@@ -736,6 +736,35 @@ static ssize_t ab8500_val_write(struct file *file,
        return count;
 }
 
+/*
+ * Interrupt status
+ */
+static u32 num_interrupts[AB8500_MAX_NR_IRQS];
+static int num_interrupt_lines;
+
+void ab8500_debug_register_interrupt(int line)
+{
+       if (line < num_interrupt_lines)
+               num_interrupts[line]++;
+}
+
+static int ab8500_interrupts_print(struct seq_file *s, void *p)
+{
+       int line;
+
+       seq_printf(s, "irq:  number of\n");
+
+       for (line = 0; line < num_interrupt_lines; line++)
+               seq_printf(s, "%3i:  %6i\n", line, num_interrupts[line]);
+
+       return 0;
+}
+
+static int ab8500_interrupts_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, ab8500_interrupts_print, inode->i_private);
+}
+
 /*
  * - HWREG DB8500 formated routines
  */
@@ -1489,6 +1518,14 @@ static const struct file_operations ab8500_val_fops = {
        .owner = THIS_MODULE,
 };
 
+static const struct file_operations ab8500_interrupts_fops = {
+       .open = ab8500_interrupts_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+       .owner = THIS_MODULE,
+};
+
 static const struct file_operations ab8500_subscribe_fops = {
        .open = ab8500_subscribe_unsubscribe_open,
        .write = ab8500_subscribe_write,
@@ -1597,6 +1634,18 @@ static int ab8500_debug_probe(struct platform_device *plf)
        if (!file)
                goto err;
 
+       if (is_ab8500(ab8500))
+               num_interrupt_lines = AB8500_NR_IRQS;
+       else if (is_ab8505(ab8500))
+               num_interrupt_lines = AB8505_NR_IRQS;
+       else if (is_ab9540(ab8500))
+               num_interrupt_lines = AB9540_NR_IRQS;
+
+       file = debugfs_create_file("interrupts", (S_IRUGO),
+           ab8500_dir, &plf->dev, &ab8500_interrupts_fops);
+       if (!file)
+               goto err;
+
        file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR),
            ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
        if (!file)
index dbec7b00ea839a0516ce7a3855f873fa2e3a2410..fa7173dd71f20bf88e889acafc200c8a6334d599 100644 (file)
@@ -347,8 +347,10 @@ static inline int is_ab8500_2p0(struct ab8500 *ab)
 
 #ifdef CONFIG_AB8500_DEBUG
 void ab8500_dump_all_banks(struct device *dev);
+void ab8500_debug_register_interrupt(int line);
 #else
 static inline void ab8500_dump_all_banks(struct device *dev) {}
+static inline void ab8500_debug_register_interrupt(int line) {}
 #endif
 
 #endif /* MFD_AB8500_H */
This page took 0.029546 seconds and 5 git commands to generate.