[PATCH] libio: Clean up usage of rtems_termios_device_mode
Kinsey Moore
kinsey.moore at oarcorp.com
Tue Jan 2 22:02:45 UTC 2024
This cleans up outputUsesInterrupts usage with rtems_termios_device_mode
enum values. The outputUsesInterrupts member was typed as an int, named
as if it were a boolean value, and used as if it were a
rtems_termios_device_mode enum. In this patch, values assigned to
outputUsesInterrupts have been converted to the corresponding
rtems_termios_device_mode enum value, conversions from
deviceOutputUsesInterrupts have been made explicit, and uses of
rtems_termios_device_mode enum values with deviceOutputUsesInterrupts
have been converted to booleans.
---
bsps/arm/csb336/console/uart.c | 4 ++--
bsps/i386/pc386/console/ps2_mouse.c | 2 +-
bsps/m68k/gen68340/console/console.c | 4 ++--
bsps/m68k/gen68360/console/console.c | 4 ++--
bsps/m68k/mcf5206elite/console/console.c | 4 ++--
bsps/m68k/mrm332/console/sci.c | 4 ++--
bsps/m68k/mvme167/console/console.c | 4 ++--
bsps/powerpc/gen5200/console/console.c | 4 ++--
bsps/powerpc/mpc8260ads/console/console.c | 4 ++--
bsps/powerpc/virtex4/start/dummy_console.c | 2 +-
bsps/powerpc/virtex5/start/dummy_console.c | 2 +-
bsps/sh/gensh2/console/config.c | 4 ++--
bsps/sh/gensh2/console/sci.c | 2 +-
bsps/sh/gensh4/console/console.c | 4 ++--
bsps/shared/dev/serial/console-polled.c | 2 +-
bsps/shared/dev/serial/legacy-console.c | 6 +++++-
bsps/sparc/erc32/console/erc32_console.c | 4 ++--
bsps/sparc/leon2/console/console.c | 4 ++--
cpukit/include/rtems/libio.h | 3 ++-
testsuites/libtests/termios01/termios_testdriver.c | 2 +-
testsuites/libtests/termios03/termios_testdriver_polled.c | 2 +-
testsuites/libtests/termios04/termios_testdriver_impl.h | 2 +-
22 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/bsps/arm/csb336/console/uart.c b/bsps/arm/csb336/console/uart.c
index 8d8a0c1ed0..1acb1baa10 100644
--- a/bsps/arm/csb336/console/uart.c
+++ b/bsps/arm/csb336/console/uart.c
@@ -61,7 +61,7 @@ rtems_termios_callbacks imx_uart_cbacks = {
.setAttributes = imx_uart_set_attrs,
.stopRemoteTx = NULL,
.startRemoteTx = NULL,
- .outputUsesInterrupts = 1,
+ .outputUsesInterrupts = TERMIOS_IRQ_DRIVEN,
};
#else
rtems_termios_callbacks imx_uart_cbacks = {
@@ -72,7 +72,7 @@ rtems_termios_callbacks imx_uart_cbacks = {
.setAttributes = imx_uart_set_attrs,
.stopRemoteTx = NULL,
.startRemoteTx = NULL,
- .outputUsesInterrupts = 0,
+ .outputUsesInterrupts = TERMIOS_POLLED,
};
#endif
diff --git a/bsps/i386/pc386/console/ps2_mouse.c b/bsps/i386/pc386/console/ps2_mouse.c
index 6a3f8551b4..581598d605 100644
--- a/bsps/i386/pc386/console/ps2_mouse.c
+++ b/bsps/i386/pc386/console/ps2_mouse.c
@@ -481,7 +481,7 @@ rtems_device_driver paux_open(
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
status = rtems_termios_open (major, minor, arg, &cb );
diff --git a/bsps/m68k/gen68340/console/console.c b/bsps/m68k/gen68340/console/console.c
index 34c18bc129..0f5e26d9e8 100644
--- a/bsps/m68k/gen68340/console/console.c
+++ b/bsps/m68k/gen68340/console/console.c
@@ -600,7 +600,7 @@ rtems_device_driver console_open(
SetAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
static const rtems_termios_callbacks pollCallbacks = {
@@ -611,7 +611,7 @@ rtems_device_driver console_open(
SetAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
if (minor==UART_CHANNEL_A) {
diff --git a/bsps/m68k/gen68360/console/console.c b/bsps/m68k/gen68360/console/console.c
index 4d0f2bcb20..a2292dbab9 100644
--- a/bsps/m68k/gen68360/console/console.c
+++ b/bsps/m68k/gen68360/console/console.c
@@ -308,7 +308,7 @@ rtems_device_driver console_open(
smc1SetAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
static const rtems_termios_callbacks pollCallbacks = {
smc1Initialize, /* firstOpen */
@@ -318,7 +318,7 @@ rtems_device_driver console_open(
smc1SetAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
/*
diff --git a/bsps/m68k/mcf5206elite/console/console.c b/bsps/m68k/mcf5206elite/console/console.c
index bbf343d0f3..20272af780 100644
--- a/bsps/m68k/mcf5206elite/console/console.c
+++ b/bsps/m68k/mcf5206elite/console/console.c
@@ -278,7 +278,7 @@ console_open(rtems_device_major_number major,
console_set_attributes, /* setAttributes */
console_stop_remote_tx, /* stopRemoteTx */
console_start_remote_tx, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
static const rtems_termios_callbacks poll_callbacks = {
console_first_open, /* firstOpen */
@@ -288,7 +288,7 @@ console_open(rtems_device_major_number major,
console_set_attributes, /* setAttributes */
console_stop_remote_tx, /* stopRemoteTx */
console_start_remote_tx, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
switch (console_mode) {
diff --git a/bsps/m68k/mrm332/console/sci.c b/bsps/m68k/mrm332/console/sci.c
index c6b4933f13..cf9370b2eb 100644
--- a/bsps/m68k/mrm332/console/sci.c
+++ b/bsps/m68k/mrm332/console/sci.c
@@ -268,7 +268,7 @@ static const rtems_termios_callbacks SciInterruptCallbacks =
SciSetAttributes, /* set attributes */
NULL, /* stop remote xmit */
NULL, /* start remote xmit */
- TRUE /* output uses interrupts */
+ TERMIOS_IRQ_DRIVEN /* output uses interrupts */
};
/*****************************************************************************
@@ -284,7 +284,7 @@ static const rtems_termios_callbacks SciPolledCallbacks =
SciSetAttributes, /* set attributes */
NULL, /* stop remote xmit */
NULL, /* start remote xmit */
- FALSE /* output uses interrupts */
+ TERMIOS_POLLED /* output uses interrupts */
};
diff --git a/bsps/m68k/mvme167/console/console.c b/bsps/m68k/mvme167/console/console.c
index 0499ac46b3..e9084924fa 100644
--- a/bsps/m68k/mvme167/console/console.c
+++ b/bsps/m68k/mvme167/console/console.c
@@ -1515,7 +1515,7 @@ rtems_device_driver console_open(
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
static const rtems_termios_callbacks intrCallbacks = {
@@ -1526,7 +1526,7 @@ rtems_device_driver console_open(
cd2401_setAttributes, /* setAttributes */
cd2401_stopRemoteTx, /* stopRemoteTx */
cd2401_startRemoteTx, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
if ( NVRAM_CONFIGURE )
diff --git a/bsps/powerpc/gen5200/console/console.c b/bsps/powerpc/gen5200/console/console.c
index f225e98727..f92e88e403 100644
--- a/bsps/powerpc/gen5200/console/console.c
+++ b/bsps/powerpc/gen5200/console/console.c
@@ -681,7 +681,7 @@ rtems_device_driver console_open(
mpc5200_uart_setAttributes, /* setAttributes */
NULL,
NULL,
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
#else
static const rtems_termios_callbacks pollCallbacks = {
@@ -692,7 +692,7 @@ rtems_device_driver console_open(
mpc5200_uart_setAttributes, /* setAttributes */
NULL,
NULL,
- 0 /* output don't use Interrupts */
+ TERMIOS_POLLED /* output don't use Interrupts */
};
#endif
diff --git a/bsps/powerpc/mpc8260ads/console/console.c b/bsps/powerpc/mpc8260ads/console/console.c
index 873c38dc3e..ab3e455a12 100644
--- a/bsps/powerpc/mpc8260ads/console/console.c
+++ b/bsps/powerpc/mpc8260ads/console/console.c
@@ -322,7 +322,7 @@ rtems_device_driver console_open(
m8xx_uart_setAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
#else
#if (UARTS_USE_TERMIOS == 1) && (UARTS_IO_MODE != 1)
@@ -334,7 +334,7 @@ rtems_device_driver console_open(
m8xx_uart_setAttributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
#endif
diff --git a/bsps/powerpc/virtex4/start/dummy_console.c b/bsps/powerpc/virtex4/start/dummy_console.c
index 642fe45618..ca8d2e7854 100644
--- a/bsps/powerpc/virtex4/start/dummy_console.c
+++ b/bsps/powerpc/virtex4/start/dummy_console.c
@@ -31,7 +31,7 @@ static rtems_termios_callbacks gMemCallbacks = {
0, /* SetAttr */
0, /* stopRemoteTx */
0, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
rtems_device_driver console_initialize(rtems_device_major_number major,
diff --git a/bsps/powerpc/virtex5/start/dummy_console.c b/bsps/powerpc/virtex5/start/dummy_console.c
index 2cdab33c8c..7480402cde 100644
--- a/bsps/powerpc/virtex5/start/dummy_console.c
+++ b/bsps/powerpc/virtex5/start/dummy_console.c
@@ -28,7 +28,7 @@ static rtems_termios_callbacks gMemCallbacks = {
0, /* SetAttr */
0, /* stopRemoteTx */
0, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
rtems_device_driver console_initialize(rtems_device_major_number major,
diff --git a/bsps/sh/gensh2/console/config.c b/bsps/sh/gensh2/console/config.c
index 7d8a983cd2..33ed1bd76e 100644
--- a/bsps/sh/gensh2/console/config.c
+++ b/bsps/sh/gensh2/console/config.c
@@ -54,7 +54,7 @@ const console_fns sh_sci_fns =
sh_sci_initialize_interrupts, /* deviceInitialize */
sh_sci_write_polled, /* deviceWritePolled */
sh_sci_set_attributes, /* deviceSetAttributes */
- TERMIOS_IRQ_DRIVEN /* deviceOutputUsesInterrupts */
+ true /* deviceOutputUsesInterrupts */
};
/*
@@ -70,7 +70,7 @@ const console_fns sh_sci_fns_polled =
sh_sci_init, /* deviceInitialize */
sh_sci_write_polled, /* deviceWritePolled */
sh_sci_set_attributes, /* deviceSetAttributes */
- TERMIOS_POLLED /* deviceOutputUsesInterrupts */
+ false /* deviceOutputUsesInterrupts */
};
#if 1 /* (CONSOLE_USE_INTERRUPTS) */
diff --git a/bsps/sh/gensh2/console/sci.c b/bsps/sh/gensh2/console/sci.c
index e02049cbf3..ba7f8bc832 100644
--- a/bsps/sh/gensh2/console/sci.c
+++ b/bsps/sh/gensh2/console/sci.c
@@ -539,7 +539,7 @@ const rtems_termios_callbacks sci_poll_callbacks = {
_sh_sci_set_attributes, /* setAttributes */
NULL, /* stopRemoteTX */
NULL, /* StartRemoteTX */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
/* FIXME: not yet supported */
diff --git a/bsps/sh/gensh4/console/console.c b/bsps/sh/gensh4/console/console.c
index 917556df4e..02c43786d5 100644
--- a/bsps/sh/gensh4/console/console.c
+++ b/bsps/sh/gensh4/console/console.c
@@ -284,7 +284,7 @@ console_open(rtems_device_major_number major,
console_set_attributes, /* setAttributes */
console_stop_remote_tx, /* stopRemoteTx */
console_start_remote_tx, /* startRemoteTx */
- 1 /* outputUsesInterrupts */
+ TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */
};
static const rtems_termios_callbacks poll_callbacks = {
console_first_open, /* firstOpen */
@@ -294,7 +294,7 @@ console_open(rtems_device_major_number major,
console_set_attributes, /* setAttributes */
console_stop_remote_tx, /* stopRemoteTx */
console_start_remote_tx, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
switch (console_mode)
diff --git a/bsps/shared/dev/serial/console-polled.c b/bsps/shared/dev/serial/console-polled.c
index 0fc765cb64..37ad5b8f18 100644
--- a/bsps/shared/dev/serial/console-polled.c
+++ b/bsps/shared/dev/serial/console-polled.c
@@ -113,7 +113,7 @@ rtems_device_driver console_open(
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
assert( minor == 0 );
diff --git a/bsps/shared/dev/serial/legacy-console.c b/bsps/shared/dev/serial/legacy-console.c
index 7da87276b0..698439b247 100644
--- a/bsps/shared/dev/serial/legacy-console.c
+++ b/bsps/shared/dev/serial/legacy-console.c
@@ -234,7 +234,11 @@ rtems_device_driver console_open(
Callbacks.stopRemoteTx = NULL;
Callbacks.startRemoteTx = NULL;
}
- Callbacks.outputUsesInterrupts = cptr->pDeviceFns->deviceOutputUsesInterrupts;
+ if (cptr->pDeviceFns->deviceOutputUsesInterrupts) {
+ Callbacks.outputUsesInterrupts = TERMIOS_IRQ_DRIVEN;
+ } else {
+ Callbacks.outputUsesInterrupts = TERMIOS_POLLED;
+ }
/* XXX what about
* Console_Port_Tbl[minor].ulMargin,
diff --git a/bsps/sparc/erc32/console/erc32_console.c b/bsps/sparc/erc32/console/erc32_console.c
index 81dfe026fb..f50b8b4073 100644
--- a/bsps/sparc/erc32/console/erc32_console.c
+++ b/bsps/sparc/erc32/console/erc32_console.c
@@ -66,7 +66,7 @@ static void erc32_console_initialize(int minor);
erc32_console_initialize, /* deviceInitialize */
NULL, /* deviceWritePolled */
NULL, /* deviceSetAttributes */
- TERMIOS_IRQ_DRIVEN /* deviceOutputUsesInterrupts */
+ true /* deviceOutputUsesInterrupts */
};
#else
const console_fns erc32_fns = {
@@ -78,7 +78,7 @@ static void erc32_console_initialize(int minor);
erc32_console_initialize, /* deviceInitialize */
NULL, /* deviceWritePolled */
NULL, /* deviceSetAttributes */
- TERMIOS_POLLED /* deviceOutputUsesInterrupts */
+ false /* deviceOutputUsesInterrupts */
};
#endif
diff --git a/bsps/sparc/leon2/console/console.c b/bsps/sparc/leon2/console/console.c
index 579792a06a..063afac178 100644
--- a/bsps/sparc/leon2/console/console.c
+++ b/bsps/sparc/leon2/console/console.c
@@ -327,7 +327,7 @@ rtems_device_driver console_open(
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
#else
static const rtems_termios_callbacks pollCallbacks = {
@@ -338,7 +338,7 @@ rtems_device_driver console_open(
NULL, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
#endif
diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h
index 6898168aa6..5424a2a03c 100644
--- a/cpukit/include/rtems/libio.h
+++ b/cpukit/include/rtems/libio.h
@@ -56,6 +56,7 @@
#include <rtems/fs.h>
#include <rtems/chain.h>
#include <rtems/score/atomic.h>
+#include <rtems/termiosdevice.h>
#ifdef __cplusplus
extern "C" {
@@ -1902,7 +1903,7 @@ typedef struct rtems_termios_callbacks {
int (*setAttributes)(int minor, const struct termios *t);
int (*stopRemoteTx)(int minor);
int (*startRemoteTx)(int minor);
- int outputUsesInterrupts;
+ rtems_termios_device_mode outputUsesInterrupts;
} rtems_termios_callbacks;
static inline void rtems_termios_initialize( void )
diff --git a/testsuites/libtests/termios01/termios_testdriver.c b/testsuites/libtests/termios01/termios_testdriver.c
index d0a9534b52..49810a37e0 100644
--- a/testsuites/libtests/termios01/termios_testdriver.c
+++ b/testsuites/libtests/termios01/termios_testdriver.c
@@ -192,7 +192,7 @@ rtems_device_driver termios_test_driver_open(
termios_test_driver_set_attributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
if ( minor > 2 ) {
diff --git a/testsuites/libtests/termios03/termios_testdriver_polled.c b/testsuites/libtests/termios03/termios_testdriver_polled.c
index a852fe1f20..8daf8d6685 100644
--- a/testsuites/libtests/termios03/termios_testdriver_polled.c
+++ b/testsuites/libtests/termios03/termios_testdriver_polled.c
@@ -159,7 +159,7 @@ rtems_device_driver termios_test_driver_open(
termios_test_driver_set_attributes, /* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
};
if ( minor > 2 ) {
diff --git a/testsuites/libtests/termios04/termios_testdriver_impl.h b/testsuites/libtests/termios04/termios_testdriver_impl.h
index cfe9ebedf4..740f9e0778 100644
--- a/testsuites/libtests/termios04/termios_testdriver_impl.h
+++ b/testsuites/libtests/termios04/termios_testdriver_impl.h
@@ -271,7 +271,7 @@ rtems_device_driver termios_test_driver_open(
#if defined(TASK_DRIVEN)
TERMIOS_TASK_DRIVEN /* outputUsesInterrupts */
#else
- 0 /* outputUsesInterrupts */
+ TERMIOS_POLLED /* outputUsesInterrupts */
#endif
};
--
2.39.2
More information about the devel
mailing list