[PATCH v4 02/16] serial: sh-sci: Add sci_is_fifo_type()

From: Biju

Date: Tue Nov 25 2025 - 10:11:20 EST


From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

Add sci_is_fifo_type() helper for SCI operates in FIFO mode to
simplify the code in probe() and remove().

Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
v4:
* New patch.
---
drivers/tty/serial/sh-sci.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 53edbf1d8963..56d6489b2a7c 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3546,6 +3546,12 @@ static struct uart_driver sci_uart_driver = {
.cons = SCI_CONSOLE,
};

+static bool sci_is_fifo_type(u8 type)
+{
+ return (type == PORT_SCIFA || type == PORT_SCIFB ||
+ type == PORT_HSCIF || type == SCI_PORT_RSCI);
+}
+
static void sci_remove(struct platform_device *dev)
{
struct sci_port *s = platform_get_drvdata(dev);
@@ -3556,8 +3562,7 @@ static void sci_remove(struct platform_device *dev)

if (s->port.fifosize > 1)
device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger);
- if (type == PORT_SCIFA || type == PORT_SCIFB || type == PORT_HSCIF ||
- type == SCI_PORT_RSCI)
+ if (sci_is_fifo_type(type))
device_remove_file(&dev->dev, &dev_attr_rx_fifo_timeout);
}

@@ -3918,8 +3923,7 @@ static int sci_probe(struct platform_device *dev)
if (ret)
return ret;
}
- if (sp->type == PORT_SCIFA || sp->type == PORT_SCIFB ||
- sp->type == PORT_HSCIF || sp->type == SCI_PORT_RSCI) {
+ if (sci_is_fifo_type(sp->type)) {
ret = device_create_file(&dev->dev, &dev_attr_rx_fifo_timeout);
if (ret) {
if (sp->port.fifosize > 1) {
--
2.43.0