hook: move gpio init post hook
authorThomas Ingleby <thomas.c.ingleby@intel.com>
Fri, 18 Jul 2014 12:19:29 +0000 (13:19 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Tue, 9 Sep 2014 16:28:43 +0000 (17:28 +0100)
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
docs/platform-hooks.md
src/gpio/gpio.c

index adb5e65..ece7291 100644 (file)
@@ -14,7 +14,7 @@ Any functionality perfomed here is done just before the normal function returns.
 
 ##Hooks
 ### GPIO
- * init (pre-post) - On RAW functions
+ * init (pre-post)
  * mode (replace-pre-post)
  * dir (replace-pre-post)
  * write (pre-post)
index 7ca328f..ec71531 100644 (file)
@@ -61,6 +61,14 @@ mraa_gpio_init(int pin)
 
     mraa_gpio_context r = mraa_gpio_init_raw(pinm);
     r->phy_pin = pin;
+
+    if (advance_func->gpio_init_post != NULL) {
+        mraa_result_t ret = advance_func->gpio_init_post(r);
+        if (ret != MRAA_SUCCESS) {
+            free(r);
+            return NULL;
+        }
+    }
     return r;
 }
 
@@ -106,13 +114,6 @@ mraa_gpio_init_raw(int pin)
         close(export);
     }
 
-    if (advance_func->gpio_init_post != NULL) {
-        mraa_result_t ret = advance_func->gpio_init_post(dev);
-        if (ret != MRAA_SUCCESS) {
-            free(dev);
-            return NULL;
-        }
-    }
     return dev;
 }