From: Michael Gernoth Date: Wed, 25 May 2011 10:32:12 +0000 (+0200) Subject: unload support X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-kexec/commitdiff_plain/81799b4e51fac01194bbea1cbbe2c176554e505e?ds=sidebyside unload support --- diff --git a/headphone_cons.c b/headphone_cons.c index edf8d16..1e35070 100644 --- a/headphone_cons.c +++ b/headphone_cons.c @@ -6,6 +6,8 @@ #include #include +static int hs_switch = -1; + /* * int add_preferred_console(char *name, int idx, char *options) * c0069208 T add_preferred_console @@ -15,25 +17,43 @@ static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, c static int __init headphone_cons_init(void) { - int hs_switch; - /* Get the headset switch gpio number from devtree */ hs_switch = get_gpio_by_name("headset_uart_switch"); if (hs_switch < 0) return -EINVAL; + printk(KERN_INFO "headset_uart_switch: %d\n", hs_switch); + + printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch)); + +#if 0 /* configure headset switch gpio as output and direction based on devtree setting */ - gpio_request(hs_switch, "mapphone audio headset uart switch"); + if (gpio_request(hs_switch, "mapphone audio headset uart switch") < 0) + return -ENODEV; +#endif /* route kernel uart out headset jack */ gpio_direction_output(hs_switch, 0); + printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch)); - add_preferred_console("ttyS", 1, "115200"); + add_preferred_console("ttyS", 0, "115200"); return 0; } +static void __exit headphone_cons_exit(void) +{ + if (hs_switch < 0) + return; + + printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch)); + gpio_direction_output(hs_switch, 1); + printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch)); +} + + module_init(headphone_cons_init); +module_exit(headphone_cons_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michael Gernoth ");