/* * Copyright (C) 2015-2016 Mentor Graphics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ #include #include #include #include #include #include "watchdog_pretimeout.h" /* Default watchdog pretimeout governor */ static struct watchdog_governor *default_gov; /* The spinlock protects default_gov, wdd->gov and pretimeout_list */ static DEFINE_SPINLOCK(pretimeout_lock); /* List of watchdog devices, which can generate a pretimeout event */ static LIST_HEAD(pretimeout_list); struct watchdog_pretimeout { struct watchdog_device *wdd; struct list_head entry; }; /* The mutex protects governor list and serializes external interfaces */ static DEFINE_MUTEX(governor_lock); /* List of the registered watchdog pretimeout governors */ static LIST_HEAD(governor_list); struct governor_priv { struct watchdog_governor *gov; struct list_head entry; }; static struct governor_priv *find_governor_by_name(const char *gov_name) { struct governor_priv *priv; list_for_each_entry(priv, &governor_list, entry) if (sysfs_streq(gov_name, priv->gov->name)) return priv; return NULL; } int watchdog_pretimeout_available_governors_get(char *buf) { struct governor_priv *priv; int count = 0; mutex_lock(&governor_lock); list_for_each_entry(priv, &governor_list, entry) count += sprintf(buf + count, "%s\n", priv->gov->name); mutex_unlock(&governor_lock); return count; } int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf) { int count = 0; spin_lock_irq(&pretimeout_lock); if (wdd->gov) count = sprintf(buf, "%s\n", wdd->gov->name); spin_unlock_irq(&pretimeout_lock); return count; } int watchdog_pretimeout_governor_set(struct watchdog_device *wdd, const char *buf) { struct governor_priv *priv; mutex_lock(&governor_lock); priv = find_governor_by_name(buf); if (!priv) { mutex_unlock(&governor_lock); return -EINVAL; } spin_lock_irq(&pretimeout_lock); wdd->gov = priv->gov; spin_unlock_irq(&pretimeout_lock); mutex_unlock(&governor_lock); return 0; } void watchdog_notify_pretimeout(struct watchdog_device *wdd) { unsigned long flags; spin_lock_irqsave(&pretimeout_lock, flags); if (!wdd->gov) { spin_unlock_irqrestore(&pretimeout_lock, flags); return; } wdd->gov->pretimeout(wdd); spin_unlock_irqrestore(&pretimeout_lock, flags); } EXPORT_SYMBOL_GPL(watchdog_notify_pretimeout); int watchdog_register_governor(struct watchdog_governor *gov) { struct watchdog_pretimeout *p; struct governor_priv *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; mutex_lock(&governor_lock); if (find_governor_by_name(gov->name)) { mutex_unlock(&governor_lock); kfree(priv); return -EBUSY; } priv->gov = gov; list_add(&priv->entry, &governor_list); if (!strncmp(gov->name, WATCHDOG_PRETIMEOUT_DEFAULT_GOV, WATCHDOG_GOV_NAME_MAXLEN)) { spin_lock_irq(&pretimeout_lock); default_gov = gov; list_for_each_entry(p, &pretimeout_list, entry) if (!p->wdd->gov) p->wdd->gov = default_gov; spin_unlock_irq(&pretimeout_lock); } mutex_unlock(&governor_lock); return 0; } EXPORT_SYMBOL(watchdog_register_governor); void watchdog_unregister_governor(struct watchdog_governor *gov) { struct watchdog_pretimeout *p; struct governor_priv *priv, *t; mutex_lock(&governor_lock); list_for_each_entry_safe(priv, t, &governor_list, entry) { if (priv->gov == gov) { list_del(&priv->entry); kfree(priv); break; } } spin_lock_irq(&pretimeout_lock); list_for_each_entry(p, &pretimeout_list, entry) if (p->wdd->gov == gov) p->wdd->gov = default_gov; spin_unlock_irq(&pretimeout_lock); mutex_unlock(&governor_lock); } EXPORT_SYMBOL(watchdog_unregister_governor); int watchdog_register_pretimeout(struct watchdog_device *wdd) { struct watchdog_pretimeout *p; if (!(wdd->info->options & WDIOF_PRETIMEOUT)) return 0; p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM; spin_lock_irq(&pretimeout_lock); list_add(&p->entry, &pretimeout_list); p->wdd = wdd; wdd->gov = default_gov; spin_unlock_irq(&pretimeout_lock); return 0; } void watchdog_unregister_pretimeout(struct watchdog_device *wdd) { struct watchdog_pretimeout *p, *t; if (!(wdd->info->options & WDIOF_PRETIMEOUT)) return; spin_lock_irq(&pretimeout_lock); wdd->gov = NULL; list_for_each_entry_safe(p, t, &pretimeout_list, entry) { if (p->wdd == wdd) { list_del(&p->entry); break; } } spin_unlock_irq(&pretimeout_lock); kfree(p); } it/patch/Documentation/devicetree/bindings/interrupt-controller?id=e7aa8c2eb11ba69b1b69099c3c7bd6be3087b0ba'>patch) treef63906f41699c8e38af9d12b063e2ceab0286ef2 /Documentation/devicetree/bindings/interrupt-controller parente34bac726d27056081d0250c0e173e4b155aa340 (diff)parent868c97a846a73e937d835b09b8c885a69df50ec8 (diff)
Merge tag 'docs-4.10' of git://git.lwn.net/linuxHEADmaster
Pull documentation update from Jonathan Corbet: "These are the documentation changes for 4.10. It's another busy cycle for the docs tree, as the sphinx conversion continues. Highlights include: - Further work on PDF output, which remains a bit of a pain but should be more solid now. - Five more DocBook template files converted to Sphinx. Only 27 to go... Lots of plain-text files have also been converted and integrated. - Images in binary formats have been replaced with more source-friendly versions. - Various bits of organizational work, including the renaming of various files discussed at the kernel summit. - New documentation for the device_link mechanism. ... and, of course, lots of typo fixes and small updates" * tag 'docs-4.10' of git://git.lwn.net/linux: (193 commits) dma-buf: Extract dma-buf.rst Update Documentation/00-INDEX docs: 00-INDEX: document directories/files with no docs docs: 00-INDEX: remove non-existing entries docs: 00-INDEX: add missing entries for documentation files/dirs docs: 00-INDEX: consolidate process/ and admin-guide/ description scripts: add a script to check if Documentation/00-INDEX is sane Docs: change sh -> awk in REPORTING-BUGS Documentation/core-api/device_link: Add initial documentation core-api: remove an unexpected unident ppc/idle: Add documentation for powersave=off Doc: Correct typo, "Introdution" => "Introduction" Documentation/atomic_ops.txt: convert to ReST markup Documentation/local_ops.txt: convert to ReST markup Documentation/assoc_array.txt: convert to ReST markup docs-rst: parse-headers.pl: cleanup the documentation docs-rst: fix media cleandocs target docs-rst: media/Makefile: reorganize the rules docs-rst: media: build SVG from graphviz files docs-rst: replace bayer.png by a SVG image ...
Diffstat (limited to 'Documentation/devicetree/bindings/interrupt-controller')