changeset 198:a65439c34396

8132023: Remove confusing "[SPI] Can't unclock device" error message Summary: Fimoved unnecessary close(handle) calls and decrease importance of the message Reviewed-by: alkonsta
author snazarki
date Tue, 21 Jul 2015 14:58:21 +0300
parents 1a709d70a4cf
children 60aeeb749f3c
files src/share/linux/native/com/oracle/dio/spibus/spi.c
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/spibus/spi.c	Tue Jul 21 14:49:56 2015 +0300
+++ b/src/share/linux/native/com/oracle/dio/spibus/spi.c	Tue Jul 21 14:58:21 2015 +0300
@@ -40,8 +40,8 @@
 
 #define SPI_WORD_LENGTH     8
 
-#define SPI_CPHA_MASK       0x0001
-#define SPI_CPOL_MASK       0x0010
+#define SPI_CPHA_MASK       1
+#define SPI_CPOL_MASK       2
 
 #define DEFAULT_BUS_ID           0          /* SPI1       */
 #define DEFAULT_CLOCK_FREQUENCY  2000000    /* Hz         */
@@ -419,18 +419,13 @@
 
         if(-1 == fcntl(cfg->devFd , F_SETLK, &lock)){
             if (errno == EACCES || errno == EAGAIN) {
-                close(cfg->devFd);
-                cfg->devFd = -1;
                 return JAVACALL_DIO_BUSY;
             }else{
                 JAVACALL_REPORT_ERROR1(JC_DIO, "[SPI] Can't lock device. errno %d", errno);
-                close(cfg->devFd);
-                cfg->devFd = -1;
                 return JAVACALL_DIO_FAIL;
             }
         }
         if (JAVACALL_DIO_OK != spi_configure(cfg)) {
-            close(cfg->devFd);
             return JAVACALL_DIO_INVALID_CONFIG;
         }
         return JAVACALL_DIO_OK;
@@ -455,7 +450,7 @@
     lock.l_pid    = getpid();
 
     if(-1 == fcntl(cfg->devFd , F_SETLK, &lock)){
-        JAVACALL_REPORT_ERROR1(JC_DIO, "[SPI] Can't unclock device. errno %d", errno);
+        JAVACALL_REPORT_WARN1(JC_DIO, "[SPI] Can't unclock device. errno %d", errno);
     }
 
     close( cfg->devFd );
@@ -487,7 +482,7 @@
 
     /* spi mode */
     if (ioctl(cfg->devFd, SPI_IOC_WR_MODE, &mode) < 0) {
-        JAVACALL_REPORT_ERROR(JC_DIO, "[SPI] Can't setup mode");
+        JAVACALL_REPORT_ERROR1(JC_DIO, "[SPI] Can't setup mode %d", mode);
         return JAVACALL_DIO_FAIL;
     }