The attached patch fixes tcflush() and tcdrain() in the termios package. These functions would call the fo_getinfo() function of the file system code with a 0 length (the length value is unused). The fo_getinfo() code in devfs.cxx would then convert this into a non-NULL pointer to a value of 0 when calling cyg_io_get_config(). This combination (non-NULL pointer to 0 value) is a special case in cyg_io_get_config() used to determine if the get_config method is available for the device. It always returns success (ENOERR) when the method is defined and does nothing.

By changing the length value passed to the fo_getinfo() function to a non-zero value, this avoids this.

Jay

Index: ecos/packages/io/serial/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/serial/current/ChangeLog,v
retrieving revision 1.75
diff -u -5 -p -r1.75 ChangeLog
--- ecos/packages/io/serial/current/ChangeLog   29 Jan 2009 17:49:47 -0000      
1.75
+++ ecos/packages/io/serial/current/ChangeLog   2 Jun 2010 18:45:57 -0000
@@ -1,5 +1,10 @@
+2010-06-02     Jay Foster      <[email protected]>
+
+       * src/common/termios.c : Fix tcflush() and tcdrain().  They were
+       effectively no-op functions.
+
 2008-09-02  Steven Clugston  <[email protected]>
 
        * tests/ser_test_protocol.inl : Add mpc555 generic platform
        * include/serialio.h : Add noise error define to line status
        
Index: ecos/packages/io/serial/current/src/common/termios.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/serial/current/src/common/termios.c,v
retrieving revision 1.4
diff -u -5 -p -r1.4 termios.c
--- ecos/packages/io/serial/current/src/common/termios.c        29 Jan 2009 
17:49:48 -0000      1.4
+++ ecos/packages/io/serial/current/src/common/termios.c        2 Jun 2010 
18:45:58 -0000
@@ -261,11 +261,11 @@ tcdrain( int fildes )
         return -1;
     }
 
     ret = fp->f_ops->fo_getinfo( fp,
                                  CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN,
-                                 NULL, 0 );
+                                 NULL, 1 );
     cyg_fp_free( fp );
 
     if ( ret > 0 ) {
         errno = ret;
         CYG_REPORT_RETVAL( -1 );
@@ -300,21 +300,21 @@ tcflush( int fildes, int queue_sel )
 
     switch( queue_sel ) {
     case TCIOFLUSH:
         ret = fp->f_ops->fo_getinfo( fp,
                                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH,
-                                     NULL, 0 );
+                                     NULL, 1 );
         // fallthrough
     case TCIFLUSH:
         ret = fp->f_ops->fo_getinfo( fp,
                                      CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH,
-                                     NULL, 0 );
+                                     NULL, 1 );
         break;
     case TCOFLUSH:
         ret = fp->f_ops->fo_getinfo( fp,
                                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH,
-                                     NULL, 0 );
+                                     NULL, 1 );
         break;
     default:
         ret = EINVAL;
         break;
     }

Reply via email to