Skip to content

Commit

Permalink
serial: sc16is7xx: remove global regmap from struct sc16is7xx_port
Browse files Browse the repository at this point in the history
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: 3837a03 ("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>
  • Loading branch information
Hugo Villeneuve authored and Greg Kroah-Hartman committed Dec 15, 2023
1 parent 6bcab3c commit f6959c5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/tty/serial/sc16is7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,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;
Expand Down Expand Up @@ -1434,7 +1433,8 @@ static void sc16is7xx_setup_irda_ports(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;
Expand Down Expand Up @@ -1463,7 +1463,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);
Expand Down Expand Up @@ -1495,6 +1495,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)
Expand Down Expand Up @@ -1530,7 +1534,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);
Expand All @@ -1545,7 +1548,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) {
Expand Down Expand Up @@ -1616,7 +1619,7 @@ static int sc16is7xx_probe(struct device *dev,

sc16is7xx_setup_irda_ports(s);

ret = sc16is7xx_setup_mctrl_ports(s);
ret = sc16is7xx_setup_mctrl_ports(s, regmaps[0]);
if (ret)
goto out_ports;

Expand Down

0 comments on commit f6959c5

Please sign in to comment.