]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serial: sc16is7xx: use DECLARE_BITMAP for sc16is7xx_lines bitfield
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Thu, 21 Dec 2023 23:18:13 +0000 (18:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Jan 2024 15:30:04 +0000 (16:30 +0100)
Replace the explicit sc16is7xx_lines bitfield declaration with the generic
macro DECLARE_BITMAP() to reserve just enough memory to contain all
required bits.

This also improves code self-documentation by showing the maximum number
of bits required.

This conversion now makes sc16is7xx_lines an array, so drop the "&" before
sc16is7xx_lines in all bit access functions.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20231221231823.2327894-7-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sc16is7xx.c

index 8d257208cbf3c97094992fc1040dfb8eb63772d2..42e1b4c70ed6f184001345e84794696ebf929f67 100644 (file)
@@ -347,7 +347,7 @@ struct sc16is7xx_port {
        struct sc16is7xx_one            p[];
 };
 
-static unsigned long sc16is7xx_lines;
+static DECLARE_BITMAP(sc16is7xx_lines, SC16IS7XX_MAX_DEVS);
 
 static struct uart_driver sc16is7xx_uart = {
        .owner          = THIS_MODULE,
@@ -1536,7 +1536,7 @@ static int sc16is7xx_probe(struct device *dev,
                     SC16IS7XX_IOCONTROL_SRESET_BIT);
 
        for (i = 0; i < devtype->nr_uart; ++i) {
-               s->p[i].port.line = find_first_zero_bit(&sc16is7xx_lines,
+               s->p[i].port.line = find_first_zero_bit(sc16is7xx_lines,
                                                        SC16IS7XX_MAX_DEVS);
                if (s->p[i].port.line >= SC16IS7XX_MAX_DEVS) {
                        ret = -ERANGE;
@@ -1587,7 +1587,7 @@ static int sc16is7xx_probe(struct device *dev,
                if (ret)
                        goto out_ports;
 
-               set_bit(s->p[i].port.line, &sc16is7xx_lines);
+               set_bit(s->p[i].port.line, sc16is7xx_lines);
 
                /* Enable EFR */
                sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG,
@@ -1646,7 +1646,7 @@ static int sc16is7xx_probe(struct device *dev,
 
 out_ports:
        for (i = 0; i < devtype->nr_uart; i++)
-               if (test_and_clear_bit(s->p[i].port.line, &sc16is7xx_lines))
+               if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines))
                        uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port);
 
        kthread_stop(s->kworker_task);
@@ -1669,7 +1669,7 @@ static void sc16is7xx_remove(struct device *dev)
 
        for (i = 0; i < s->devtype->nr_uart; i++) {
                kthread_cancel_delayed_work_sync(&s->p[i].ms_work);
-               if (test_and_clear_bit(s->p[i].port.line, &sc16is7xx_lines))
+               if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines))
                        uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port);
                sc16is7xx_power(&s->p[i].port, 0);
        }