/* * dummy.c * * Dummy watchdog timer created for testing base.c * * Copyright (C) 2003 Rusty Lynch * * 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. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Send feedback to */ #include #include #include #include #include #include #include #include #include #define dbg(format, arg...) \ printk (KERN_DEBUG "%s: " format "\n", \ __FUNCTION__, ## arg); #define trace(format, arg...) \ printk(KERN_INFO "%s(" format ")\n", \ __FUNCTION__ , ## arg); #define err(format, arg...) \ printk(KERN_ERR "%s: " format "\n", \ __FUNCTION__ , ## arg) #define info(format, arg...) \ printk(KERN_INFO "%s: " format "\n", \ __FUNCTION__ , ## arg) #define warn(format, arg...) \ printk(KERN_WARNING "%s: " format "\n", \ __FUNCTION__ , ## arg) int dummy_start(struct wdt_device *d) { trace("%s", d->dev.name); return 0; } int dummy_stop(struct wdt_device *d, const char *m) { trace("%s, %p", d->dev.name, m); return 0; } int dummy_keepalive(struct wdt_device *d) { trace("%s", d->dev.name); return 0; } int dummy_get_timeout(struct wdt_device *d, int *t) { trace("%s, %p", d->dev.name, t); *t = 911; return 0; } int dummy_set_timeout(struct wdt_device *d, int t) { trace("%s, %i", d->dev.name, t); return 0; } int dummy_get_nowayout(struct wdt_device *d, int *n) { trace("%s, %p", d->dev.name, n); *n = 911; return 0; } int dummy_set_nowayout(struct wdt_device *d, int n) { trace("%s, %i", d->dev.name, n); return 0; } int dummy_get_status(struct wdt_device *d, int *s) { trace("%s, %p", d->dev.name, s); *s = 911; return 0; } int dummy_get_caps(struct wdt_device *d, int *c) { trace("%s, %p", d->dev.name, c); *c = 911; return 0; } int dummy_get_bootstatus(struct wdt_device *d, int *b) { trace("%s, %p", d->dev.name, b); *b = 911; return 0; } int dummy_get_temperature(struct wdt_device *d, int *t) { trace("%s, %p", d->dev.name, t); *t = 911; return 0; } int dummy_get_enable(struct wdt_device *d, int *e) { trace("%s, %p", d->dev.name, e); *e = 911; return 0; } int dummy_set_enable(struct wdt_device *d, int e) { trace("%s, %i", d->dev.name, e); return 0; } int dummy_get_temppanic(struct wdt_device *d, int *p) { trace("%s, %p", d->dev.name, p); *p = 911; return 0; } int dummy_set_temppanic(struct wdt_device *d, int p) { trace("%s, %i", d->dev.name, p); return 0; } /* Additional Sysfs Files */ ssize_t statistics_show(struct device * dev, char * buf) { struct wdt_device *w = to_wdt_device(dev); trace("%p, %p", dev, buf); return sprintf(buf, "%s: dummy statistics data", w->dev.name); } DEVICE_ATTR(statistics,0644,statistics_show,NULL); static struct wdt_ops dummy_ops = { .start = dummy_start, .stop = dummy_stop, .keepalive = dummy_keepalive, .get_timeout = dummy_get_timeout, .set_timeout = dummy_set_timeout, .get_nowayout = dummy_get_nowayout, .set_nowayout = dummy_set_nowayout, .get_status = dummy_get_status, .get_caps = dummy_get_caps, .get_bootstatus = dummy_get_bootstatus, .get_temperature = dummy_get_temperature, .get_enable = dummy_get_enable, .set_enable = dummy_set_enable, .get_temppanic = dummy_get_temppanic, .set_temppanic = dummy_set_temppanic, }; decl_wdt_device(dummy, dummy_ops, Dummy Watchdog Timer); static int __init dummy_init(void) { int ret = 0; trace(); ret = wdt_device_register(&dummy_device); if (ret) { err("failed to register watchdog device"); return -ENODEV; } device_create_file(&dummy_device.dev.dev, &dev_attr_statistics); return 0; } static void __exit dummy_exit(void) { trace(); device_remove_file(&dummy_device.dev.dev, &dev_attr_statistics); wdt_device_unregister(&dummy_device); } module_init(dummy_init); module_exit(dummy_exit); MODULE_LICENSE("GPL");