[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231203193307.542794-28-yury.norov@gmail.com>
Date: Sun, 3 Dec 2023 11:33:01 -0800
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Hugo Villeneuve <hvilleneuve@...onoff.com>,
Lech Perczak <lech.perczak@...lingroup.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Thomas Gleixner <tglx@...utronix.de>,
Hui Wang <hui.wang@...onical.com>,
Isaac True <isaac.true@...onical.com>,
Yury Norov <yury.norov@...il.com>, linux-serial@...r.kernel.org
Cc: Jan Kara <jack@...e.cz>,
Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
Matthew Wilcox <willy@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@...aro.org>,
Alexey Klimov <klimov.linux@...il.com>,
Bart Van Assche <bvanassche@....org>,
Sergey Shtylyov <s.shtylyov@....ru>
Subject: [PATCH v2 29/35] serial: sc12is7xx: optimize sc16is7xx_alloc_line()
Instead of polling every bit in sc16is7xx_lines, switch it to using a
dedicated find_and_set_bit(), and make the function a simple one-liner.
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
drivers/tty/serial/sc16is7xx.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index db2bb1c0d36c..6a463988d5e0 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -427,15 +427,9 @@ static void sc16is7xx_port_update(struct uart_port *port, u8 reg,
static int sc16is7xx_alloc_line(void)
{
- int i;
-
BUILD_BUG_ON(SC16IS7XX_MAX_DEVS > BITS_PER_LONG);
- for (i = 0; i < SC16IS7XX_MAX_DEVS; i++)
- if (!test_and_set_bit(i, &sc16is7xx_lines))
- break;
-
- return i;
+ return find_and_set_bit(&sc16is7xx_lines, SC16IS7XX_MAX_DEVS);
}
static void sc16is7xx_power(struct uart_port *port, int on)
--
2.40.1
Powered by blists - more mailing lists