#include #include #include #include static struct timer_list palmte2_batt_timer; static int palmte2_batt_level; static int palmte2_batt_probe(struct wm97xx* wm); static int palmte2_batt_remove(struct device *dev); static void palmte2_batt_update(unsigned long); static int palmte2_probed = 0; struct wm97xx_misc_dev palmte2_batt_dev = { .probe = palmte2_batt_probe, .remove = palmte2_batt_remove, .list = LIST_HEAD_INIT(palmte2_batt_dev.list), }; static int __init palmte2_batt_init(void) { if (!machine_is_tunge2()) return -ENODEV; int ret = wm97xx_register_misc_dev(&palmte2_batt_dev); printk("palmte2_batt_init: returned %d\n", ret); return ret; } static void __exit palmte2_batt_exit(void) { wm97xx_unregister_misc_dev(&palmte2_batt_dev); } static int palmte2_batt_probe(struct wm97xx* wm) { init_timer(&palmte2_batt_timer); palmte2_batt_timer.function = palmte2_batt_update; palmte2_batt_timer.data = (unsigned long)wm; palmte2_probed = 1; palmte2_batt_update(palmte2_batt_timer.data); return 0; } static int palmte2_batt_remove(struct device *dev) { palmte2_probed = 0; del_timer_sync(&palmte2_batt_timer); return 0; } static void palmte2_batt_update(unsigned long data) { if(palmte2_probed == 0) { printk("palmte2_batt_update: error: battery not probed yet!\n"); return; } struct wm97xx *wm = (struct wm97xx*) data; if(wm == NULL) { printk("palmte2_batt_update: error: struct wm97xx* wm is null!\n"); return; } palmte2_batt_level = wm97xx_read_aux_adc(wm, WM97XX_AUX_ID3); printk("palmte2_batt_update: new reading: %d\n", palmte2_batt_level); mod_timer(&palmte2_batt_timer, jiffies + HZ); } module_init(palmte2_batt_init) module_exit(palmte2_batt_exit) MODULE_AUTHOR("Jude Nelson "); MODULE_DESCRIPTION("Battery driver for the Palm T|E2"); MODULE_LICENSE("GPL");