All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] mfd: tqmx86: do not access I2C_DETECT register through io_base
@ 2023-02-16 14:34 Matthias Schiffer
  2023-02-16 14:34 ` [PATCH 2/3] mfd: tqmx86: specify IO port register range more precisely Matthias Schiffer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Matthias Schiffer @ 2023-02-16 14:34 UTC (permalink / raw)
  To: Lee Jones; +Cc: Andrew Lunn, linux-kernel, linux, Matthias Schiffer

The I2C_DETECT register is at IO port 0x1a7, which is outside the range
passed to devm_ioport_map() for io_base, and was only working because
there aren't actually any bounds checks for IO port accesses.

Extending the range does not seem like a good solution here, as it would
then conflict with the IO resource assigned to the I2C controller. As
this is just a one-off access during probe, use a simple inb() instead.

While we're at it, drop the unused define TQMX86_REG_I2C_INT_EN.

Fixes: 2f17dd34ffed ("mfd: tqmx86: IO controller with I2C, Wachdog and GPIO")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/mfd/tqmx86.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/tqmx86.c b/drivers/mfd/tqmx86.c
index 7ae906ff8e353..8dcbdafa88f4f 100644
--- a/drivers/mfd/tqmx86.c
+++ b/drivers/mfd/tqmx86.c
@@ -49,9 +49,8 @@
 #define TQMX86_REG_IO_EXT_INT_MASK		0x3
 #define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT	4
 
-#define TQMX86_REG_I2C_DETECT	0x47
+#define TQMX86_REG_I2C_DETECT	0x1a7
 #define TQMX86_REG_I2C_DETECT_SOFT		0xa5
-#define TQMX86_REG_I2C_INT_EN	0x49
 
 static uint gpio_irq;
 module_param(gpio_irq, uint, 0);
@@ -213,7 +212,7 @@ static int tqmx86_probe(struct platform_device *pdev)
 		 "Found %s - Board ID %d, PCB Revision %d, PLD Revision %d\n",
 		 board_name, board_id, rev >> 4, rev & 0xf);
 
-	i2c_det = ioread8(io_base + TQMX86_REG_I2C_DETECT);
+	i2c_det = inb(TQMX86_REG_I2C_DETECT);
 
 	if (gpio_irq_cfg) {
 		io_ext_int_val =
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-16 17:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 14:34 [PATCH 1/3] mfd: tqmx86: do not access I2C_DETECT register through io_base Matthias Schiffer
2023-02-16 14:34 ` [PATCH 2/3] mfd: tqmx86: specify IO port register range more precisely Matthias Schiffer
2023-02-16 17:20   ` Andrew Lunn
2023-02-16 14:34 ` [PATCH 3/3] mfd: tqmx86: correct board names for TQMxE39x Matthias Schiffer
2023-02-16 17:11   ` Andrew Lunn
2023-02-16 17:19 ` [PATCH 1/3] mfd: tqmx86: do not access I2C_DETECT register through io_base Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.