]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/auxdisplay/cfag12864b.c
[IA64] Clear up section mismatch for sn_check_wars.
[linux-2.6-omap-h63xx.git] / drivers / auxdisplay / cfag12864b.c
index 889583dfc1a6652be25486d394d80f9c16d44c8e..eacb175f6bd37a4e5c4314c65a039a1fb04b91d8 100644 (file)
@@ -5,7 +5,7 @@
  *     License: GPLv2
  *     Depends: ks0108
  *
- *      Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
+ *      Author: Copyright (C) Miguel Ojeda Sandonis
  *        Date: 2006-10-31
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -311,6 +311,17 @@ EXPORT_SYMBOL_GPL(cfag12864b_enable);
 EXPORT_SYMBOL_GPL(cfag12864b_disable);
 EXPORT_SYMBOL_GPL(cfag12864b_isenabled);
 
+/*
+ * Is the module inited?
+ */
+
+static unsigned char cfag12864b_inited;
+unsigned char cfag12864b_isinited(void)
+{
+       return cfag12864b_inited;
+}
+EXPORT_SYMBOL_GPL(cfag12864b_isinited);
+
 /*
  * Module Init & Exit
  */
@@ -319,15 +330,15 @@ static int __init cfag12864b_init(void)
 {
        int ret = -EINVAL;
 
-       if (PAGE_SIZE < CFAG12864B_SIZE) {
+       /* ks0108_init() must be called first */
+       if (!ks0108_isinited()) {
                printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
-                       "page size (%i) < cfag12864b size (%i)\n",
-                       (unsigned int)PAGE_SIZE, CFAG12864B_SIZE);
-               ret = -ENOMEM;
+                       "ks0108 is not initialized\n");
                goto none;
        }
+       BUILD_BUG_ON(PAGE_SIZE < CFAG12864B_SIZE);
 
-       cfag12864b_buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
+       cfag12864b_buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL);
        if (cfag12864b_buffer == NULL) {
                printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
                        "can't get a free page\n");
@@ -337,7 +348,7 @@ static int __init cfag12864b_init(void)
 
        cfag12864b_cache = kmalloc(sizeof(unsigned char) *
                CFAG12864B_SIZE, GFP_KERNEL);
-       if (cfag12864b_buffer == NULL) {
+       if (cfag12864b_cache == NULL) {
                printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
                        "can't alloc cache buffer (%i bytes)\n",
                        CFAG12864B_SIZE);
@@ -349,11 +360,10 @@ static int __init cfag12864b_init(void)
        if (cfag12864b_workqueue == NULL)
                goto cachealloced;
 
-       memset(cfag12864b_buffer, 0, CFAG12864B_SIZE);
-
        cfag12864b_clear();
        cfag12864b_on();
 
+       cfag12864b_inited = 1;
        return 0;
 
 cachealloced:
@@ -379,5 +389,5 @@ module_init(cfag12864b_init);
 module_exit(cfag12864b_exit);
 
 MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
+MODULE_AUTHOR("Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>");
 MODULE_DESCRIPTION("cfag12864b LCD driver");