diff src/share/linux/native/com/oracle/dio/i2c/i2c.c @ 274:935bcaf28721

issue: https://bugs.openjdk.java.net/browse/DIO-21 Summary: Second call to DeviceManager.open() results in UDE, not IOE Reviewed-by:snazarki Contributed-by:bkvartsk
author onazarkina
date Wed, 30 Mar 2016 12:57:33 +0300
parents ad12ae44e850
children 2f7da76bdc69
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/i2c/i2c.c	Thu Mar 24 12:20:34 2016 +0300
+++ b/src/share/linux/native/com/oracle/dio/i2c/i2c.c	Wed Mar 30 12:57:33 2016 +0300
@@ -377,6 +377,7 @@
         javacall_int32 clockFrequency,
         const javacall_bool exclusive,
         /*OUT*/javacall_handle* pHandle) {
+    javacall_dio_result ret;
     
     if (JAVACALL_TRUE != exclusive) {
         JAVACALL_REPORT_ERROR(JC_DIO, "[I2C] Shared mode is unsupported for I2C device");
@@ -422,14 +423,15 @@
     slave->clockFrequency = clockFrequency;
     
     /* Attach device to a bus */
-    if (JAVACALL_DIO_OK != i2c_attach_slave_to_bus(slave, busNum)) {
+    ret = i2c_attach_slave_to_bus(slave, busNum);
+    if (JAVACALL_DIO_OK != ret) {
         if (slave->bus != NULL) {
             i2c_detach_slave_from_bus(slave);
         }
 
         /* dealloc descriptor */
         javacall_free(slave);
-        return JAVACALL_DIO_FAIL;
+        return ret;
     }
 
     *pHandle = (javacall_handle) slave;