Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genirq: Add wakeup sysfs node to show IRQ wakeup state

Surprisingly there is no simple way to see if the IRQ line in question
is wakeup source or not.

Note that wakeup might be an OOB (out-of-band) source like GPIO line
which makes things slightly more complicated.

Add a sysfs node to cover this case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Tony Lindgren <tony@atomide.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>
Link: https://lkml.kernel.org/r/20180226155043.67937-1-andriy.shevchenko@linux.intel.com

authored by

Andy Shevchenko and committed by
Thomas Gleixner
d61e2944 e69c61dd

+24
+7
Documentation/ABI/testing/sysfs-kernel-irq
··· 51 51 KernelVersion: 4.9 52 52 Contact: Craig Gallek <kraig@google.com> 53 53 Description: The type of the interrupt. Either the string 'level' or 'edge'. 54 + 55 + What: /sys/kernel/irq/<irq>/wakeup 56 + Date: March 2018 57 + KernelVersion: 4.17 58 + Contact: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 59 + Description: The wakeup state of the interrupt. Either the string 60 + 'enabled' or 'disabled'.
+17
kernel/irq/irqdesc.c
··· 210 210 } 211 211 IRQ_ATTR_RO(type); 212 212 213 + static ssize_t wakeup_show(struct kobject *kobj, 214 + struct kobj_attribute *attr, char *buf) 215 + { 216 + struct irq_desc *desc = container_of(kobj, struct irq_desc, kobj); 217 + ssize_t ret = 0; 218 + 219 + raw_spin_lock_irq(&desc->lock); 220 + ret = sprintf(buf, "%s\n", 221 + irqd_is_wakeup_set(&desc->irq_data) ? "enabled" : "disabled"); 222 + raw_spin_unlock_irq(&desc->lock); 223 + 224 + return ret; 225 + 226 + } 227 + IRQ_ATTR_RO(wakeup); 228 + 213 229 static ssize_t name_show(struct kobject *kobj, 214 230 struct kobj_attribute *attr, char *buf) 215 231 { ··· 269 253 &chip_name_attr.attr, 270 254 &hwirq_attr.attr, 271 255 &type_attr.attr, 256 + &wakeup_attr.attr, 272 257 &name_attr.attr, 273 258 &actions_attr.attr, 274 259 NULL