comparison 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
comparison
equal deleted inserted replaced
5:622bc302d3b4 6:4d4cf25a1479
375 javacall_dio_result javacall_i2c_open_slave_with_config(javacall_int32 busNum, 375 javacall_dio_result javacall_i2c_open_slave_with_config(javacall_int32 busNum,
376 javacall_int32 devAddr, javacall_int32 addrSize, 376 javacall_int32 devAddr, javacall_int32 addrSize,
377 javacall_int32 clockFrequency, 377 javacall_int32 clockFrequency,
378 const javacall_bool exclusive, 378 const javacall_bool exclusive,
379 /*OUT*/javacall_handle* pHandle) { 379 /*OUT*/javacall_handle* pHandle) {
380 javacall_dio_result ret;
380 381
381 if (JAVACALL_TRUE != exclusive) { 382 if (JAVACALL_TRUE != exclusive) {
382 JAVACALL_REPORT_ERROR(JC_DIO, "[I2C] Shared mode is unsupported for I2C device"); 383 JAVACALL_REPORT_ERROR(JC_DIO, "[I2C] Shared mode is unsupported for I2C device");
383 return JAVACALL_DIO_UNSUPPORTED_ACCESS_MODE; 384 return JAVACALL_DIO_UNSUPPORTED_ACCESS_MODE;
384 } 385 }
420 slave->address = (long)devAddr; 421 slave->address = (long)devAddr;
421 slave->addressSize = (long)addrSize; 422 slave->addressSize = (long)addrSize;
422 slave->clockFrequency = clockFrequency; 423 slave->clockFrequency = clockFrequency;
423 424
424 /* Attach device to a bus */ 425 /* Attach device to a bus */
425 if (JAVACALL_DIO_OK != i2c_attach_slave_to_bus(slave, busNum)) { 426 ret = i2c_attach_slave_to_bus(slave, busNum);
427 if (JAVACALL_DIO_OK != ret) {
426 if (slave->bus != NULL) { 428 if (slave->bus != NULL) {
427 i2c_detach_slave_from_bus(slave); 429 i2c_detach_slave_from_bus(slave);
428 } 430 }
429 431
430 /* dealloc descriptor */ 432 /* dealloc descriptor */
431 javacall_free(slave); 433 javacall_free(slave);
432 return JAVACALL_DIO_FAIL; 434 return ret;
433 } 435 }
434 436
435 *pHandle = (javacall_handle) slave; 437 *pHandle = (javacall_handle) slave;
436 438
437 return JAVACALL_DIO_OK; 439 return JAVACALL_DIO_OK;