changeset 120:203499b65f94

8077271: [Master] Uundo unintended merge introduced at 119 changeset Summary: Source files are restored to 119 changeset Reviewed-by: alkonsta
author snazarki
date Wed, 08 Apr 2015 18:58:34 +0400
parents dada06425261
children 181ec2e88114
files src/se/classes/com/oracle/dio/impl/EventQueue.java src/se/classes/com/oracle/dio/uart/impl/UARTEventHandler.java src/se/classes/com/oracle/dio/utils/Logging.java src/share/classes/com/oracle/dio/impl/AbstractPeripheral.java src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java src/share/classes/com/oracle/dio/utils/ActionFactory.java src/share/classes/jdk/dio/Device.java src/share/classes/jdk/dio/DeviceManager.java src/share/classes/jdk/dio/adc/ADCChannel.java src/share/classes/jdk/dio/dac/DACChannel.java src/share/classes/jdk/dio/generic/GenericBufferIODevice.java src/share/classes/jdk/dio/power/PowerManaged.java src/share/classes/jdk/dio/pwm/PWMChannel.java src/share/classes/jdk/dio/spibus/SPIDevice.java src/share/linux/native/com/oracle/dio/uart/serial.c src/share/linux/native/com/oracle/dio/uart/uart.c
diffstat 17 files changed, 253 insertions(+), 365 deletions(-) [+]
line wrap: on
line diff
--- a/src/se/classes/com/oracle/dio/impl/EventQueue.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/se/classes/com/oracle/dio/impl/EventQueue.java	Wed Apr 08 18:58:34 2015 +0400
@@ -43,10 +43,6 @@
     private Thread                  nativeEventThread;
     private Thread                  eventDispatchThread;
 
-    public Thread getEventDispatchThread(){
-        return eventDispatchThread;
-    }
-
     private static class QueueInstanceHolder {
         private static EventQueue sharedEventQueue = new EventQueue(SHARED_QUEUE_BUFFER_SIZE);
     }
@@ -112,23 +108,24 @@
     private class EventDispatchThread implements Runnable {
         @Override
         public void run() {
-            Event evt = null;
             while (true) {
                 synchronized (queue) {
                     try {
                         if (queue.isEmpty()) {
                             queue.wait();
                         }
-                        evt = queue.poll();
+
+                        while (!queue.isEmpty()) {
+                            Event evt = queue.poll();
+                            if (evt != null) {
+                                dispatch(evt);
+                            }
+                        }
                     } catch (InterruptedException ex) {
                         // do something
                     }
-                }//synchronized queue
-
-                if (evt != null) {
-                    dispatch(evt);
                 }
-            }//while true
+            }
         }
     }
 
@@ -170,8 +167,13 @@
         synchronized (listeners) {
             for (int i = 0; i < listeners.size(); i += 2) {
                 if (listeners.get(i).equals(evt.getClass())) {
-                    EventHandler h = (EventHandler)listeners.get(i+1);
-                    h.handleEvent(evt);
+                    final EventHandler h = (EventHandler)listeners.get(i+1);
+                    new Thread() {
+                        @Override
+                        public void run() {
+                            h.handleEvent(evt);
+                        }
+                    }.start();
                 }
             }
         }
--- a/src/se/classes/com/oracle/dio/uart/impl/UARTEventHandler.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/se/classes/com/oracle/dio/uart/impl/UARTEventHandler.java	Wed Apr 08 18:58:34 2015 +0400
@@ -158,6 +158,9 @@
                                                 Class<UARTEvent> eventClass);
 
     public boolean isDispatchThread() {
-        return queue.getEventDispatchThread().equals(Thread.currentThread());
+        /*
+         * because of nature of dispatch for se where an event processed in separate thread
+         */
+        return false;
     }
 }
--- a/src/se/classes/com/oracle/dio/utils/Logging.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/se/classes/com/oracle/dio/utils/Logging.java	Wed Apr 08 18:58:34 2015 +0400
@@ -24,8 +24,6 @@
  */
 
 package com.oracle.dio.utils;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 public final class Logging {
 
@@ -34,30 +32,26 @@
     }
 
     public static void reportError(String message) {
-        log(Level.SEVERE, message);
+        //  add an implementation
     }
 
     public static void reportError(String message1, String message2) {
-        reportError(message1 + message2);
+        //  add an implementation
     }
 
     public static void reportWarning(String message) {
-        log(Level.WARNING, message);
+        //  add an implementation
     }
 
     public static void reportWarning(String message1, String message2) {
-        reportWarning(message1 + message2);
+        //  add an implementation
     }
 
     public static void reportInformation(String message) {
-        log(Level.INFO, message);
+        //  add an implementation
     }
 
     public static void reportInformation(String message1, String message2) {
-        reportInformation(message1 + message2);
-    }
-
-    private static void log(Level level, String message) {
-        Logger.getLogger("DIO").log(level, message);
+        //  add an implementation
     }
 }
--- a/src/share/classes/com/oracle/dio/impl/AbstractPeripheral.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/com/oracle/dio/impl/AbstractPeripheral.java	Wed Apr 08 18:58:34 2015 +0400
@@ -35,7 +35,6 @@
 import com.oracle.dio.utils.Constants;
 import com.oracle.dio.utils.ExceptionMessage;
 import java.nio.Buffer;
-import java.nio.ByteOrder;
 
 /* It is recommended to synchronize subclass native operation on {@code handle} lock.
    @see {@link #unlock()} for the reason
@@ -201,8 +200,4 @@
      * Release peripheral for shared access
      */
     protected  void unlock0() { handle.unlock(); }
-
-    public ByteOrder getByteOrder() throws IOException, UnavailableDeviceException, ClosedDeviceException {
-        return ByteOrder.LITTLE_ENDIAN;
-    }
 }
--- a/src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/com/oracle/dio/spibus/impl/SPICompositeMessageImpl.java	Wed Apr 08 18:58:34 2015 +0400
@@ -59,15 +59,12 @@
         }
     }
 
-    private void checkStatus() throws ClosedDeviceException {
+    private void checkStatus() {
         if (isAlreadyTransferedOnce) {
             throw new IllegalStateException(
                 ExceptionMessage.format(ExceptionMessage.I2CBUS_ALREADY_TRANSFERRED_MESSAGE)
             );
         }
-        if (!device.isOpen()) {
-            throw new ClosedDeviceException();
-        }
     }
 
     private void check(Message message) throws ClosedDeviceException {
@@ -80,6 +77,10 @@
             );
         }
 
+        if (!device.isOpen()) {
+            throw new ClosedDeviceException();
+        }
+
         for (int i = 0; i < messageList.size(); i++) {
             ByteBuffer tx = messageList.get(i).tx;
             ByteBuffer rx = messageList.get(i).rx;
@@ -139,7 +140,7 @@
     }
 
     @Override
-    public synchronized SPICompositeMessage appendDelay(int delay) throws ClosedDeviceException {
+    public synchronized SPICompositeMessage appendDelay(int delay) {
 
         checkStatus();
 
--- a/src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java	Wed Apr 08 18:58:34 2015 +0400
@@ -51,7 +51,6 @@
     private boolean isWriting;
 
     private Object synchReadLock = new Object();
-    private Object synchWriteLock = new Object();
 
     private ByteBuffer writeBuffers[] = new ByteBuffer[2];
     private int writeBuffersPositions[] = new int[2];
@@ -69,6 +68,7 @@
 
     private int receiveTriggerLevel;
     private int inputTimeout = Integer.MAX_VALUE;//timeout is disabled
+    private Timer receiveTimer;
 
 
     UARTImpl(DeviceDescriptor<UART> dscr, int mode)
@@ -112,26 +112,47 @@
         initPowerManagement();
     }
 
-    private class InternalRoundListener implements  InputRoundListener<UART, ByteBuffer> {
-            @Override
-            public void inputRoundCompleted(RoundCompletionEvent<UART, ByteBuffer> event) {
-                synchronized(synchReadLock){
-                    synchReadLock.notifyAll();
+    private InputRoundListener getLocalInputRoundListener(){
+        return new InputRoundListener<UART, ByteBuffer>() {
+                @Override
+                public void inputRoundCompleted(RoundCompletionEvent<UART, ByteBuffer> event) {
+                    synchronized(synchReadLock){
+                        synchReadLock.notifyAll();
+                    }
                 }
-            }
 
-            @Override
-            public void failed(Throwable ex, UART arg1) {
-                synchronized(synchReadLock){
-                    synchReadLock.notifyAll();
+                @Override
+                public void failed(Throwable ex, UART arg1) {
+                    synchronized(synchReadLock){
+                        synchReadLock.notifyAll();
+                    }
                 }
-            }
+            };
     }
 
-    private InputRoundListener getLocalInputRoundListener(){
-        return new InternalRoundListener();
+    private void startReceiveTimer(){
+
+        if(receiveTimer != null){
+            receiveTimer.cancel();
+        }
+        receiveTimer = new Timer();
+        receiveTimer.schedule(new TimerTask(){
+                                            @Override
+                                            public void run() {
+                                            try{
+                                                UARTEventHandler.getInstance().sendTimeoutEvent(getHandle().getNativeHandle());
+                                            }catch(Exception e){
+                                                //do nothing
+                                            }
+                                        }
+                                   },inputTimeout);
     }
 
+    private void stopReceiveTimer(){
+        if(receiveTimer != null){
+            receiveTimer.cancel();
+        }
+    }
 
     private boolean isAlphaNumerical(char ch) {
         if ((('a' <= ch && ch <= 'z') ||
@@ -188,13 +209,20 @@
         AccessController.checkPermission(new UARTPermission(getSecurityName(), DevicePermission.POWER_MANAGE));
     }
 
-    protected void processEvent(int event, int bytesProcessed){
+    protected synchronized void processEvent(int event, int bytesProcessed){
         UARTEventListener listener = eventListeners.get(event);
         if (listener != null){
             try{
+                if(event == UARTEvent.INPUT_DATA_AVAILABLE){
+                    stopReceiveTimer();
+                }
                 UARTEvent uartEvent = new UARTEvent(this, event);
                 listener.eventDispatched(uartEvent);
-            } catch(Throwable e){
+                if(event == UARTEvent.INPUT_DATA_AVAILABLE){
+                    startReceiveTimer();
+                }
+            }
+            catch(Exception e){
                 //do nothing
             }
         }
@@ -417,6 +445,9 @@
         }else{
              eventListeners.put(eventId, listener);
              subscribe(eventId);
+             if(eventId == UARTEvent.INPUT_DATA_AVAILABLE && inputTimeout < Integer.MAX_VALUE){
+                startReceiveTimer();
+             }
         }
     }
 
@@ -472,8 +503,9 @@
      * from that very same buffer upon invocation od the provided {@link OutputRoundListener} instance.
      */
     @Override
-    public void startWriting(ByteBuffer src, OutputRoundListener<UART, ByteBuffer> listener) throws IOException, UnavailableDeviceException, ClosedDeviceException{
+    public synchronized void startWriting(ByteBuffer src, OutputRoundListener<UART, ByteBuffer> listener) throws IOException, UnavailableDeviceException, ClosedDeviceException{
         checkPowerState();
+        checkWrite();
 
         if(src == null || listener == null){
             throw new NullPointerException(
@@ -481,14 +513,20 @@
             );
         }
 
-        writeAsync(src, null, listener);
+        writeBuffers[0] = src;
+        writeBuffersPositions[0] = src.position();
+        writeBufferIdx = 0;
+        outRoundListener = listener;
+        subscribe(UARTEvent.OUTPUT_BUFFER_EMPTY);
+        writeAsynch0(src);
+        isWriting = true;
     }
 
     /**
      * Starts asynchronous writing in successive rounds.
      */
     @Override
-    public void startWriting(ByteBuffer src1, ByteBuffer src2, OutputRoundListener<UART, ByteBuffer> listener) throws IOException,
+    public synchronized void startWriting(ByteBuffer src1, ByteBuffer src2, OutputRoundListener<UART, ByteBuffer> listener) throws IOException,
         UnavailableDeviceException, ClosedDeviceException{
 
         if(src1 == null || src2 == null || listener == null){
@@ -497,41 +535,23 @@
             );
         }
 
-        writeAsync(src1, src2, listener);
-    }
-
-    private void writeAsync(ByteBuffer src1, ByteBuffer src2, OutputRoundListener<UART, ByteBuffer> listener) throws IOException,
-        UnavailableDeviceException, ClosedDeviceException {
-        synchronized(synchWriteLock) {
-            checkWrite();
-            writeBuffers[0] = src1;
-            writeBuffersPositions[0] = src1.position();
-            writeBuffers[1] = src2;
-            if (null != src2) {
-                writeBuffersPositions[1] = src2.position();
-            }
-            writeBufferIdx = 0;
-            outRoundListener = listener;
-            subscribe(UARTEvent.OUTPUT_BUFFER_EMPTY);
-            writeAsynch0(src1);
-            isWriting = true;
-        }
+        writeBuffers[1] = src2;
+        writeBuffersPositions[1] = src2.position();
+        startWriting(src1, listener);
     }
 
     /**
      * Stops (cancels) the currently active writing session.
      */
     @Override
-    public void stopWriting() throws IOException, UnavailableDeviceException, ClosedDeviceException{
+    public synchronized void stopWriting() throws IOException, UnavailableDeviceException, ClosedDeviceException{
         checkOpen();
-        synchronized(synchWriteLock) {
-            if (isWriting){
-                outRoundListener = null;
-                unsubscribe(UARTEvent.OUTPUT_BUFFER_EMPTY);
-                writeBuffers[0] = writeBuffers[1] = null;
-                stopWriting0();
-                isWriting = false;
-            }
+        if (isWriting){
+            outRoundListener = null;
+            unsubscribe(UARTEvent.OUTPUT_BUFFER_EMPTY);
+            writeBuffers[0] = writeBuffers[1] = null;
+            stopWriting0();
+            isWriting = false;
         }
     }
 
@@ -540,22 +560,33 @@
      * buffer.
      */
     @Override
-    public void startReading(ByteBuffer src, InputRoundListener<UART, ByteBuffer> listener) throws IOException, UnavailableDeviceException, ClosedDeviceException{
+    public synchronized void startReading(ByteBuffer src, InputRoundListener<UART, ByteBuffer> listener) throws IOException, UnavailableDeviceException, ClosedDeviceException{
         checkPowerState();
+        checkRead();
 
         if(src == null || listener == null){
             throw new NullPointerException(
                 ExceptionMessage.format(ExceptionMessage.UART_NULL_SRC_OR_LISTENER)
             );
         }
-        readAsync(src, null, listener);
+
+        inRoundListener = listener;
+        readBuffers[0] = src;
+        readBuffersPositions[0] = src.position();
+        readBufferIdx = 0;
+        /*
+                        subscribe calls set_event_listener, in case of INPUT_DATA_AVAILABLE
+                        the native function checks if data available in the internal
+                        buffer and generates INPUT_DATA_AVAILABLE event if so.
+                */
+        subscribe(UARTEvent.INPUT_DATA_AVAILABLE);
     }
 
     /**
      * Starts asynchronous reading in sucessive rounds.
      */
     @Override
-    public void startReading(ByteBuffer src1, ByteBuffer src2, InputRoundListener<UART, ByteBuffer> listener) throws IOException,
+    public synchronized void startReading(ByteBuffer src1, ByteBuffer src2, InputRoundListener<UART, ByteBuffer> listener) throws IOException,
             UnavailableDeviceException, ClosedDeviceException{
 
         if(src1 == null || src2 == null || listener == null){
@@ -563,51 +594,23 @@
                 ExceptionMessage.format(ExceptionMessage.UART_NULL_SRC1_OR_SRC2_OR_LISTENER)
             );
         }
-        readAsync(src1, src2, listener);
-    }
-
-    private void readAsync(ByteBuffer src1, ByteBuffer src2, InputRoundListener<UART, ByteBuffer> listener)  throws IOException,
-            UnavailableDeviceException, ClosedDeviceException {
-        synchronized(synchReadLock){
-            checkRead();
-            inRoundListener = listener;
-            readBuffers[0] = src1;
-            readBuffersPositions[0] = src1.position();
-            readBuffers[1] = src2;
-            if (null != src2) {
-                readBuffersPositions[1] = src2.position();
-            }
-            readBufferIdx = 0;
-            /*
-                subscribe calls set_event_listener, in case of INPUT_DATA_AVAILABLE
-                the native function checks if data available in the internal
-                buffer and generates INPUT_DATA_AVAILABLE event if so.
-            */
-            subscribe(UARTEvent.INPUT_DATA_AVAILABLE);
-        }
-    }
-
-
-    /* stop operation of required type only, e.g. public stopReading() doesn't affect read() */
-    private void stopReading(boolean syncVer) throws IOException, UnavailableDeviceException, ClosedDeviceException {
-        synchronized(synchReadLock) {
-            if (null != inRoundListener && syncVer == (inRoundListener instanceof InternalRoundListener) ) {
-                inRoundListener = null;
-                unsubscribe(UARTEvent.INPUT_DATA_AVAILABLE);
-                readBuffers[0] = readBuffers[1] = null;
-                // redundant function, remove later
-                stopReading0();
-            }
-        }
+        readBuffers[1] = src2;
+        readBuffersPositions[1] = src2.position();
+        startReading(src1, listener);
     }
 
     /**
      * Stops (cancels) the currently active reading session.
       */
     @Override
-    public void stopReading() throws IOException, UnavailableDeviceException, ClosedDeviceException{
+    public synchronized void stopReading() throws IOException, UnavailableDeviceException, ClosedDeviceException{
         checkOpen();
-        stopReading(false);
+        if (inRoundListener != null){
+            inRoundListener = null;
+            unsubscribe(UARTEvent.INPUT_DATA_AVAILABLE);
+            readBuffers[0] = readBuffers[1] = null;
+            stopReading0();
+        }
     }
 
     /**
@@ -648,20 +651,22 @@
             UnavailableDeviceException, ClosedDeviceException{
         int ret;
 
-        if (dst == null){
-            throw new NullPointerException(
-                ExceptionMessage.format(ExceptionMessage.UART_NULL_DST)
-            );
+        synchronized(this){
+            checkRead();
         }
 
-        if(!dst.hasRemaining()){
-            ret = 0;
-        }else{
-            ret = dst.position();
-            synchronized(synchReadLock){
+        synchronized(handle){
 
-                checkRead();
+            if (dst == null){
+                throw new NullPointerException(
+                    ExceptionMessage.format(ExceptionMessage.UART_NULL_DST)
+                );
+            }
 
+            if(!dst.hasRemaining()){
+                ret = 0;
+            }else{
+                ret = dst.position();
                 /*read all data available*/
                 int readRes = read0(dst);
                 shiftBufferPosition(dst, ret + readRes);
@@ -673,6 +678,7 @@
                          * else read with timeout
                          */
                         startReading(dst, getLocalInputRoundListener());
+                        synchronized(synchReadLock){
                             try{
                                 if(inputTimeout == Integer.MAX_VALUE){
                                     //timeout disabled, wait forever or till the buffer is fullfilled
@@ -682,16 +688,15 @@
                                 }
                             }catch(InterruptedException iE){
                                 throw new IOException();
-                            } finally {
-                                stopReading(true);
                             }
+                        } // synch
+                        stopReading();
                     }
                 } // if !event thread
-            } // synch
+            } // if has Remaining
             ret = dst.position() - ret;
-        } // if has Remaining
-
-        return ret;
+        } // synch handle
+        return ret==0?-1:ret;
     }
 
     /**
@@ -706,40 +711,42 @@
             );
         }
 
-        checkPowerState();
+        synchronized (this) {
+            checkPowerState();
+            checkWrite();
+        }
 
         int ret = 0;
-
-        synchronized(synchWriteLock) {
-            checkWrite();
+        try {
             isWriting = true;
-        }
-
-        try {
             /*
              * synchronous write0 returns number of written bytes
              * slice is needed to avoid memory corruption because src buffer modification
              * might happen during write0
              */
             ret = write0(src.slice());
-            shiftBufferPosition(src, src.position() + ret);
+            try{
+                src.position(src.position() + ret);
+            }catch(IllegalArgumentException e){
+                //IAE happens if src.position() + ret < 0 (not expected) or src.position() + ret > limit
+                src.position(src.limit());
+            }
         } finally {
             isWriting = false;
+            return ret;
         }
-        return ret;
     }
 
     @Override
-    public void close() throws IOException{
+    public synchronized void close() throws IOException{
         if (isOpen()) {
+            synchronized(synchReadLock){
+                synchReadLock.notifyAll();
+            }
             stopWriting();
             stopReading();
             super.close();
         }
-        // unblock read()
-        synchronized(synchReadLock) {
-            synchReadLock.notifyAll();
-        }
     }
 
     @Override
--- a/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Wed Apr 08 18:58:34 2015 +0400
@@ -83,28 +83,14 @@
      * @return true for valid
      */
     private static boolean isValidAction(String actions, String normalizedList) {
-        StringTokenizer tokez = new StringTokenizer(actions, ",", true);
-        // detect first empty token
-        boolean lastTokenIsComma = true;
+        StringTokenizer tokez = new StringTokenizer(actions, ",");
         while (tokez.hasMoreElements()) {
             String action = tokez.nextToken();
-            // special case for empty actions that are not returned by StringTokenizer.nextToken() by default
-            if (action.equals(",")) {
-                if (lastTokenIsComma) {
-                    return false;
-                } else {
-                    lastTokenIsComma = true;
-                    continue;
-                }
-            } else {
-                lastTokenIsComma = false;
-            }
             if (!isIncluded(action, normalizedList)) {
                 return false;
             }
         }
-        // detects last empty token as well
-        return !lastTokenIsComma;
+        return true;
     }
 
     /**
--- a/src/share/classes/jdk/dio/Device.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/Device.java	Wed Apr 08 18:58:34 2015 +0400
@@ -27,7 +27,6 @@
 
 import java.io.IOException;
 import java.nio.channels.Channel;
-import java.nio.ByteOrder;
 
 /**
  * The {@code Device} interface represents devices in the system. This interface
@@ -40,15 +39,6 @@
  * mode by the same application, locking one of the {@code Device} instances will prevent the
  * other form being accessed/used.
  *
- * <h3><a name="byte_order">Device Byte Order</a></h3>
- * Devices that perform multi-byte value I/O operations have a "native" byte order
- * (see {@link #getByteOrder getByteOrder}).
- * Passing to such a device a buffer with a byte order different from its native
- * byte order may result in byte re-ordering (byte order conversion). These byte
- * re-ordering may have an impact on performance, memory consumption and I/O throughput.
- * On resource-constrained platforms a device driver may throw an {@link UnsupportedByteOrderException} when a
- * byte re-ordering may induce a detrimental loss of quality or performance.
- *
  * @param <P>
  *            the device type the descriptor is defined for.
  * @since 1.0
@@ -139,24 +129,4 @@
      *         information of this device.
      */
     <U extends P> DeviceDescriptor<U> getDescriptor();
-
-    /**
-     * Retrieves this device's byte order.
-     * <p />
-     * The byte order is used when performing multi-byte value I/O operations. The byte
-     * order of a device that only performs single-byte value I/O operations
-     * is always {@link java.nio.ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
-     *
-     * @return this buffer's byte order.
-     *
-     * @throws IOException
-     *             if some other I/O error occurs.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another application.
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     *
-     * @since 1.1
-     */
-    ByteOrder getByteOrder() throws IOException, UnavailableDeviceException, ClosedDeviceException;
 }
--- a/src/share/classes/jdk/dio/DeviceManager.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/DeviceManager.java	Wed Apr 08 18:58:34 2015 +0400
@@ -754,7 +754,7 @@
         }
 
         // special case if config is null
-        if (0 != properties.length) {
+        if (null != properties) {
             return loadFromDriver(supported, intf, mode, properties);
         }
 
--- a/src/share/classes/jdk/dio/adc/ADCChannel.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/adc/ADCChannel.java	Wed Apr 08 18:58:34 2015 +0400
@@ -30,7 +30,6 @@
 import jdk.dio.DeviceManager;
 import jdk.dio.ClosedDeviceException;
 import jdk.dio.UnavailableDeviceException;
-import jdk.dio.UnsupportedByteOrderException;
 import java.io.IOException;
 import java.nio.*;
 import romizer.WeakDontRenameClass;
@@ -345,23 +344,21 @@
      *            input values have been read.
      * @throws NullPointerException
      *             If {@code dst} or {@code listener} is {@code null}.
-     * @throws IllegalStateException
-     *             if another synchronous or asynchronous acquisition is already active.
+     * @throws IOException
+     *             if some other I/O error occurs.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
+     * @throws IllegalStateException
+     *             if another synchronous or asynchronous acquisition is already active.
      * @throws UnsupportedOperationException
      *             if an asynchronous monitoring is already active and acquisition and monitoring
      *             cannot be performed concurrently.
      */
     void startAcquisition(IntBuffer dst, AcquisitionRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts asynchronous analog input acquisition on this channel and reads a series of raw
@@ -410,26 +407,24 @@
      *            input values have been read.
      * @throws NullPointerException
      *             If {@code dst1}, {@code dst2} or {@code listener} is {@code null}.
+     * @throws IOException
+     *             if some other I/O error occurs.
+     * @throws UnavailableDeviceException
+     *             if this device is not currently available - such as it is locked by another
+     *             application.
+     * @throws ClosedDeviceException
+     *             if the device has been closed.
      * @throws IllegalStateException
      *             if another synchronous or asynchronous acquisition is already active.
      * @throws IllegalArgumentException
      *             if any of the buffers {@code dst1} and {@code dst2} has a zero-capacity or
      *             if they are the same or overlap.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another
-     *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the any of the provided buffers is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
      * @throws UnsupportedOperationException
      *             if an asynchronous monitoring is already active and acquisition and monitoring
      *             cannot be performed concurrently.
      */
     void startAcquisition(IntBuffer dst1, IntBuffer dst2, AcquisitionRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts monitoring this channel analog input and asynchronously notifies the provided
--- a/src/share/classes/jdk/dio/dac/DACChannel.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/dac/DACChannel.java	Wed Apr 08 18:58:34 2015 +0400
@@ -25,8 +25,11 @@
 
 package jdk.dio.dac;
 
-import jdk.dio.*;
-
+import jdk.dio.BufferAccess;
+import jdk.dio.Device;
+import jdk.dio.DeviceManager;
+import jdk.dio.ClosedDeviceException;
+import jdk.dio.UnavailableDeviceException;
 import java.io.IOException;
 import java.nio.IntBuffer;
 import romizer.WeakDontRenameClass;
@@ -272,21 +275,19 @@
      *
      * @param src
      *            the buffer from which the integer raw values can be retrieved.
+     * @throws IOException
+     *             if some other I/O error occurs.
      * @throws NullPointerException
      *             If {@code src} is {@code null}.
-     * @throws IllegalStateException
-     *             if an asynchronous output generation is already active.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
+     * @throws IllegalStateException
+     *             if an asynchronous output generation is already active.
      */
-    void generate(IntBuffer src) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    void generate(IntBuffer src) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts asynchronous analog output generation on this channel from a series of raw output
@@ -308,18 +309,10 @@
      * buffer's position will be equal to <i>{@code p + n}</i>; its limit will not have changed. <br />
      * The buffer's position upon stopping this asynchronous operation by a call to
      * {@link #stopGeneration stopGeneration} is not predictable unless called from within the
-     * listener. <br />
-     * If the provided {@code src} buffer is a direct buffer fulfilling the direct
-     * I/O requirements of this device (see {@link #prepareBuffer(java.nio.Buffer, int) prepareBuffer}) then the listener will only
-     * be invoked after all the <i>r</i> raw output values remaining in the provided
-     * {@code src} buffer have been consumed by the driver/hardware. If this channel
-     * uses an output buffer and is therefore working in buffering mode the listener will only be
-     * invoked after all the <i>r</i> raw output values have been copied to the
-     * output buffer; otherwise the listener will only be invoked after all the
-     * <i>r</i> raw output values have been consumed by the driver/hardware.
+     * listener..
      * <p />
      * The raw output values (samples) will be converted according to the current output sampling
-     * interval as returned by {@link #getSamplingRate getSamplingRate}.
+     * interval as returned by {@link #getSamplingInterval getSamplingInterval}.
      * <p />
      * Upon notification of the provided {@code GenerationRoundListener}
      * the reference to the provided {@code src} buffer can be retrieved from the
@@ -348,26 +341,24 @@
      * significant bits beyond the {@code n} bits of the DAC device resolution have been truncated.
      *
      * @param src
-     *            the buffer from which the integer raw sampled output values are to be retrieved.
+     *            the buffer from which the integer raw sampled input values are to be retrieved.
      * @param listener
      *            the {@link GenerationRoundListener} instance to be notified when all the output
      *            values have been converted.
      * @throws NullPointerException
      *             If {@code src} or {@code listener} is {@code null}.
-     * @throws IllegalStateException
-     *             if another synchronous or asynchronous output generation is already active.
+     * @throws IOException
+     *             if some other I/O error occurs.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
+     * @throws IllegalStateException
+     *             if another synchronous or asynchronous output generation is already active.
      */
     void startGeneration(IntBuffer src, GenerationRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts asynchronous analog output generation on this channel from a series of raw output
@@ -383,15 +374,7 @@
      * will only be suspended if the previous event has not yet been handled. Also,
      * the position of the current working buffer upon stopping this asynchronous operation by a call to
      * {@link #stopGeneration stopGeneration} is not predictable even if called from within the
-     * listener. <br />
-     * If both buffers are direct buffer fulfilling the direct I/O requirements of
-     * this device (see {@link #prepareBuffer(java.nio.Buffer, int) prepareBuffer} ) then the
-     * listener will only be invoked after all the raw output values remaining in
-     * the current working buffer are consumed by the driver/hardware; otherwise if this
-     * channel uses an output buffer and is therefore working in buffering mode
-     * the listener will only
-     * be invoked after all the raw output values remaining in the current working
-     * buffer have been copied to the output buffer.
+     * listener.
      * <p />
      * Upon notification of the provided {@code GenerationRoundListener}
      * the reference to the  current working buffer (initially {@code src1}) can be retrieved from the
@@ -420,33 +403,31 @@
      * significant bits beyond the {@code n} bits of the DAC device resolution have been truncated.
      *
      * @param src1
-     *            the first buffer from which the integer raw sampled output values are to be
+     *            the first buffer from which the integer raw sampled input values are to be
      *            retrieved.
      * @param src2
-     *            the second buffer from which the integer raw sampled output values are to be
+     *            the second buffer from which the integer raw sampled input values are to be
      *            retrieved.
      * @param listener
      *            the {@link GenerationRoundListener} instance to be notified when all the output
      *            values have been converted.
      * @throws NullPointerException
      *             If {@code src1}, {@code src2} or {@code listener} is {@code null}.
+     * @throws IOException
+     *             if some other I/O error occurs.
+     * @throws UnavailableDeviceException
+     *             if this device is not currently available - such as it is locked by another
+     *             application.
+     * @throws ClosedDeviceException
+     *             if the device has been closed.
      * @throws IllegalStateException
      *             if another synchronous or asynchronous output generation is already active.
      * @throws IllegalArgumentException
      *             if any of the buffers {@code src1} and {@code src2} has a zero-capacity or
      *             if they are the same or overlap.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another
-     *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the any of the provided buffers is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
      */
     void startGeneration(IntBuffer src1, IntBuffer src2, GenerationRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Stops the asynchronous analog output generation on this channel as started by a call to one
--- a/src/share/classes/jdk/dio/generic/GenericBufferIODevice.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/generic/GenericBufferIODevice.java	Wed Apr 08 18:58:34 2015 +0400
@@ -28,7 +28,6 @@
 import jdk.dio.BufferAccess;
 import jdk.dio.ClosedDeviceException;
 import jdk.dio.UnavailableDeviceException;
-import jdk.dio.UnsupportedByteOrderException;
 import java.io.*;
 import java.nio.*;
 import java.nio.channels.ByteChannel;
@@ -65,15 +64,13 @@
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if an I/O error occurred such as the device is not readable.
      */
     @Override
-    int read(ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int read(ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Reads a sequence of bytes from this device into the given buffer, skipping the first
@@ -96,14 +93,12 @@
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if an I/O error occurred such as the device is not readable.
      */
-    int read(int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int read(int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Writes a sequence of bytes to this device from the given buffer.
@@ -121,13 +116,11 @@
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another
      *             application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if an I/O error occurred such as the device is not writable.
      */
     @Override
-    int write(ByteBuffer src) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int write(ByteBuffer src) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 }
--- a/src/share/classes/jdk/dio/power/PowerManaged.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/power/PowerManaged.java	Wed Apr 08 18:58:34 2015 +0400
@@ -353,7 +353,6 @@
      *
      * @since 1.0
      */
-    @apimarker.API("device-io_1.1")
     public interface Group {
 
         /**
--- a/src/share/classes/jdk/dio/pwm/PWMChannel.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/pwm/PWMChannel.java	Wed Apr 08 18:58:34 2015 +0400
@@ -30,7 +30,6 @@
 import jdk.dio.Device;
 import jdk.dio.DeviceManager;
 import jdk.dio.UnavailableDeviceException;
-import jdk.dio.UnsupportedByteOrderException;
 import java.io.IOException;
 import java.nio.IntBuffer;
 import romizer.WeakDontRenameClass;
@@ -203,7 +202,7 @@
      * <p />
      * The operation will return only after generating all of the <i>r</i> requested pulses.
      * <p />
-     * The pulses will be generated according to the current pulse rate as returned by {@link #getPulseRate getPulseRate}.
+     * The pulses will be generated according to the current pulse period as returned by {@link #getPulsePeriod getPulsePeriod}.
      * <p />
      * This method may be invoked at any time. If another thread has already initiated a synchronous pulse generation
      * upon this channel, however, then an invocation of this method will block until the first operation is complete.
@@ -223,20 +222,18 @@
      *
      * @param src
      *            the buffer from which the pulse width integer values can be retrieved.
+     * @throws IOException
+     *             if some other I/O error occurs.
      * @throws NullPointerException
      *             If {@code src} is {@code null}.
+     * @throws UnavailableDeviceException
+     *             if this device is not currently available - such as it is locked by another application.
+     * @throws ClosedDeviceException
+     *             if the device has been closed.
      * @throws IllegalStateException
      *             if an asynchronous pulse generation is already active.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
      */
-    void generate(IntBuffer src) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    void generate(IntBuffer src) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts an asynchronous pulse train generation session - continuously generating pulses of the specified width
@@ -335,8 +332,8 @@
      * The buffer's position upon stopping this asynchronous operation by a call to {@link #stopGeneration stopGeneration}
      * is not predictable unless called from within the listener.
      * <p />
-     * The pulses will be generated according to the current pulse rate as returned by {@link #getPulseRate getPulseRate}. The
-     * pulse rate can be changed by the provided {@link GenerationRoundListener} instance upon notification of each
+     * The pulses will be generated according to the current pulse period as returned by {@link #getPulsePeriod getPulsePeriod}. The
+     * pulse period can be changed by the provided {@link GenerationRoundListener} instance upon notification of each
      * pulse train subsequence.
      * <p />
      * Upon notification of the provided {@code GenerationRoundListener}
@@ -375,19 +372,17 @@
      *            the width values remaining in the buffer.
      * @throws NullPointerException
      *             If {@code src} or {@code listener} is {@code null}.
+     * @throws IOException
+     *             if some other I/O error occurs.
+     * @throws UnavailableDeviceException
+     *             if this device is not currently available - such as it is locked by another application.
+     * @throws ClosedDeviceException
+     *             if the device has been closed.
      * @throws IllegalStateException
      *             if another synchronous or asynchronous output generation is already active.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffers is not supported.
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
      */
     void startGeneration(IntBuffer src, GenerationRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Starts asynchronous pulse train generation in successive rounds.
@@ -440,22 +435,20 @@
      *            the width values remaining in the working buffer.
      * @throws NullPointerException
      *             If {@code src1}, {@code src2} or {@code listener} is {@code null}.
+     * @throws IOException
+     *             if some other I/O error occurs.
+     * @throws UnavailableDeviceException
+     *             if this device is not currently available - such as it is locked by another application.
+     * @throws ClosedDeviceException
+     *             if the device has been closed.
      * @throws IllegalStateException
      *             if another synchronous or asynchronous output generation is already active.
      * @throws IllegalArgumentException
      *             if any of the buffers {@code src1} and {@code src2} has a zero-capacity or
      *             if they are the same or overlap.
-     * @throws UnavailableDeviceException
-     *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the any of the provided buffers is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
-     * @throws ClosedDeviceException
-     *             if the device has been closed.
-     * @throws IOException
-     *             if some other I/O error occurs.
      */
     void startGeneration(IntBuffer src1, IntBuffer src2, GenerationRoundListener listener) throws IOException,
-            UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+            UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Stops (cancels) the currently active pulse generation session as started by a call to one
--- a/src/share/classes/jdk/dio/spibus/SPIDevice.java	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/classes/jdk/dio/spibus/SPIDevice.java	Wed Apr 08 18:58:34 2015 +0400
@@ -30,7 +30,6 @@
 import jdk.dio.DeviceManager;
 import jdk.dio.ClosedDeviceException;
 import jdk.dio.UnavailableDeviceException;
-import jdk.dio.UnsupportedByteOrderException;
 import java.io.IOException;
 import java.nio.*;
 import java.nio.channels.ByteChannel;
@@ -59,28 +58,18 @@
  * data received from the SPI slave device will be ignored/discarded. When reading only, dummy data will be sent to the
  * slave.
  * <p/>
- * A data exchange consists of words of a certain length which may vary from SPI
- * slave device to SPI slave device. <br />
- * Words in the sending and receiving byte buffers are not packed (bit-wise) and
- * must be byte-aligned; bytes are copied out or in, respectively, from/to these
- * buffers according to their byte orders (see
- * {@link ByteBuffer#order() ByteBuffer.order}) and the bits are shifted out or
- * in, respectively, according to the bit ordering configured for the device
- * (see
- * {@link SPIDeviceConfig#getBitOrdering() SPIDeviceConfig.getBitOrdering}).
- * If a word's length is not a multiple of 8
+ * A data exchange consists of words of a certain length which may vary from SPI slave device to SPI slave device. <br />
+ * Words in the sending and receiving byte buffers are not packed (bit-wise) and must be byte-aligned. The most
+ * significant bits of a word are stored at the lower index (that is first). If a word's length is not a multiple of 8
  * (the byte length in bits) then the most significant bits will be undefined when receiving or unused when sending. If
  * the designated portion of a sending or receiving byte buffer cannot contain a (positive) integral number of words
  * then an {@link InvalidWordLengthException} will be thrown. For example, if the word length is 16bits and the
  * designated portion of buffer is only 1-byte long or is 3-byte long an {@link InvalidWordLengthException} will be
  * thrown. <br />
  * Assuming a word length <em>w</em>, the length <em>l</em> of the designated portion of the sending or receiving byte
- * buffer must be such that:
- * <blockquote>
- * <pre>
- * {@code ((l % (((w - 1) / 8) + 1)) == 0)}
- * </pre>
- * </blockquote>
+ * buffer must be such that: <br />
+ * <em>((l % (((w - 1) / 8) + 1)) == 0)</em>
+ * <p />
  * Since the SPI master device controls the serial transmission clock read and write operations are never blocked nor delayed by
  * unresponsive slave devices. Not though that a read or write operation may be blocked if another read or write operation
  * is concurrently being performed on the same {@code SPIDevice} instance.
@@ -191,15 +180,13 @@
      *             if the number of bytes to receive belies word length.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if some other I/O error occurs.
      */
     @Override
-    int read(ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int read(ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Reads a sequence of bytes from this device into the given buffer, skipping the first {@code skip} bytes read.
@@ -224,14 +211,12 @@
      *             if the total number of bytes to receive belies word length.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if some other I/O error occurs.
      */
-    int read(int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int read(int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Writes a sequence of bytes to this slave device from the given buffer.
@@ -261,15 +246,13 @@
      *             if {@code src} is {@code null}.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the provided buffer is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if some other I/O error occurs.
      */
     @Override
-    int write(ByteBuffer src) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int write(ByteBuffer src) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Writes one data word of up to 32 bits to this slave device.
@@ -313,14 +296,12 @@
      *             if the number of bytes to receive or send belies word length.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the any of the provided buffers is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if some other I/O error occurs.
      */
-    int writeAndRead(ByteBuffer src, ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int writeAndRead(ByteBuffer src, ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Exchanges (transmits and receives) data with this slave device skipping the specified number of bytes received.
@@ -347,14 +328,12 @@
      *             if the total number of bytes to receive or send belies word length.
      * @throws UnavailableDeviceException
      *             if this device is not currently available - such as it is locked by another application.
-     * @throws UnsupportedByteOrderException
-     *             if the byte ordering of the any of the provided buffers is not supported (see <a href="{@docRoot}/jdk/dio/Device.html#byte_order">Device Byte Order</a>).
      * @throws ClosedDeviceException
      *             if the device has been closed.
      * @throws IOException
      *             if some other I/O error occurs.
      */
-    int writeAndRead(ByteBuffer src, int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, UnsupportedByteOrderException, ClosedDeviceException;
+    int writeAndRead(ByteBuffer src, int skip, ByteBuffer dst) throws IOException, UnavailableDeviceException, ClosedDeviceException;
 
     /**
      * Exchanges (transmits and receives) one data word of up to 32 bits with this slave device.
--- a/src/share/linux/native/com/oracle/dio/uart/serial.c	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/linux/native/com/oracle/dio/uart/serial.c	Wed Apr 08 18:58:34 2015 +0400
@@ -25,7 +25,6 @@
 
 #include "serial.h"
 #include "list_helper.h"
-#include "privilege_manager.h"
 
 typedef void *(thread_func)(void*);
 
@@ -731,15 +730,10 @@
     if(get_config_by_name(p->dev_name) != NULL){
         return JAVACALL_BUSY;
     }
-
-    // restore root privileges temporary
-    restore_privileges();
-    p->fd = open(p->dev_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
-    drop_privileges();
-
-    if (-1 == p->fd) {
-        JAVACALL_REPORT_ERROR2(JC_SERIAL, "Can't open %s file. %s",
-                p->dev_name, strerror(errno));
+    //opening one of the /dev/ttyUSB devices, no pin busy check
+    if (-1 == (p->fd = open(p->dev_name, O_RDWR | O_NOCTTY | O_NONBLOCK))) {
+        JAVACALL_REPORT_ERROR2(JC_SERIAL, "Can't open %s file errno %d",
+                p->dev_name, errno);
         return JAVACALL_FAIL;
     }
     /*flock set an advisory lock*/
@@ -750,16 +744,15 @@
     lock.l_pid    = getpid();
 
     if(-1 == fcntl(p->fd, F_SETLK, &lock)){
-        //save errno for printouts, next "close" call may modify it
         error_n = errno;
         close(p->fd);
         p->fd = -1;
 
         if (error_n == EACCES || error_n == EAGAIN) {
-            JAVACALL_REPORT_ERROR1(JC_DIO, "[UART] Can't lock device. %s", strerror(error_n));
+            JAVACALL_REPORT_ERROR1(JC_DIO, "[UART] Can't lock device. errno %d", errno);
             return JAVACALL_BUSY;
         }else{
-            JAVACALL_REPORT_ERROR1(JC_DIO, "[UART] Can't lock device. %s", strerror(error_n));
+            JAVACALL_REPORT_ERROR1(JC_DIO, "[UART] Can't lock device. errno %d", errno);
             return JAVACALL_FAIL;
         }
     }
--- a/src/share/linux/native/com/oracle/dio/uart/uart.c	Wed Apr 08 18:40:00 2015 +0400
+++ b/src/share/linux/native/com/oracle/dio/uart/uart.c	Wed Apr 08 18:58:34 2015 +0400
@@ -120,27 +120,24 @@
         void **pContext) {
 
     int bytesAvailable;
-    javacall_dio_result res;
 
     pthread_mutex_lock( &((serial_handle)handle)->lock );
 
     if (JAVACALL_FAIL == jc_serial_read_common((serial_handle)handle, buffer, size, bytesRead, &bytesAvailable)){
         JAVACALL_REPORT_INFO(JC_SERIAL, "javacall_serial_read_start: cannot read from the internal buffer");
-        res = JAVACALL_DIO_FAIL;
-    }else{
+        return JAVACALL_DIO_FAIL;
+    }
 
-        ((uart_handle)handle)->notifiedEvents &= ~SERIAL_IN_AVAILABLE;
-        if(bytesAvailable > 0){
+    ((uart_handle)handle)->notifiedEvents &= ~SERIAL_IN_AVAILABLE;
+    if(bytesAvailable > 0){
         ((serial_handle)handle)->new_data_avail_cb((serial_handle)handle, bytesAvailable, JAVACALL_DIO_OK);
-        }
-        /*  read from the internal buffer complete, buffer may overrun again
-        */
-        ((uart_handle)handle)->notifiedEvents &= ~SERIAL_IN_OVERRUN;
-        res = JAVACALL_DIO_OK;
     }
+    /*  read from the internal buffer complete, buffer may overrun again
+    */
+    ((uart_handle)handle)->notifiedEvents &= ~SERIAL_IN_OVERRUN;
     pthread_mutex_unlock( &((serial_handle)handle)->lock );
 
-    return res;
+    return JAVACALL_DIO_OK;
 }