serial: sc16is7xx: remove global regmap from struct sc16is7xx_port
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Mon, 11 Dec 2023 17:13:49 +0000 (12:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:18:57 +0000 (16:18 -0800)
commit f6959c5217bd799bcb770b95d3c09b3244e175c6 upstream.

Remove global struct regmap so that it is more obvious that this
regmap is to be used only in the probe function.

Also add a comment to that effect in probe function.

Fixes: 3837a0379533 ("serial: sc16is7xx: improve regmap debugfs by using one regmap per port")
Cc: <stable@vger.kernel.org>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20231211171353.2901416-3-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sc16is7xx.c

index f19567867556f7ecb9307c32e81cad76a84758d3..f018ee1a571532c2c14ed3ce6884f4697a720ce4 100644 (file)
@@ -335,7 +335,6 @@ struct sc16is7xx_one {
 
 struct sc16is7xx_port {
        const struct sc16is7xx_devtype  *devtype;
-       struct regmap                   *regmap;
        struct clk                      *clk;
 #ifdef CONFIG_GPIOLIB
        struct gpio_chip                gpio;
@@ -1413,7 +1412,8 @@ static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s)
 /*
  * Configure ports designated to operate as modem control lines.
  */
-static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s)
+static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s,
+                                      struct regmap *regmap)
 {
        int i;
        int ret;
@@ -1442,7 +1442,7 @@ static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s)
 
        if (s->mctrl_mask)
                regmap_update_bits(
-                       s->regmap,
+                       regmap,
                        SC16IS7XX_IOCONTROL_REG,
                        SC16IS7XX_IOCONTROL_MODEM_A_BIT |
                        SC16IS7XX_IOCONTROL_MODEM_B_BIT, s->mctrl_mask);
@@ -1474,6 +1474,10 @@ static int sc16is7xx_probe(struct device *dev,
         * This device does not have an identification register that would
         * tell us if we are really connected to the correct device.
         * The best we can do is to check if communication is at all possible.
+        *
+        * Note: regmap[0] is used in the probe function to access registers
+        * common to all channels/ports, as it is guaranteed to be present on
+        * all variants.
         */
        ret = regmap_read(regmaps[0], SC16IS7XX_LSR_REG, &val);
        if (ret < 0)
@@ -1509,7 +1513,6 @@ static int sc16is7xx_probe(struct device *dev,
                        return -EINVAL;
        }
 
-       s->regmap = regmaps[0];
        s->devtype = devtype;
        dev_set_drvdata(dev, s);
        mutex_init(&s->efr_lock);
@@ -1524,7 +1527,7 @@ static int sc16is7xx_probe(struct device *dev,
        sched_set_fifo(s->kworker_task);
 
        /* reset device, purging any pending irq / data */
-       regmap_write(s->regmap, SC16IS7XX_IOCONTROL_REG,
+       regmap_write(regmaps[0], SC16IS7XX_IOCONTROL_REG,
                     SC16IS7XX_IOCONTROL_SRESET_BIT);
 
        for (i = 0; i < devtype->nr_uart; ++i) {
@@ -1604,7 +1607,7 @@ static int sc16is7xx_probe(struct device *dev,
                                s->p[u].irda_mode = true;
        }
 
-       ret = sc16is7xx_setup_mctrl_ports(s);
+       ret = sc16is7xx_setup_mctrl_ports(s, regmaps[0]);
        if (ret)
                goto out_ports;