Skip to contentSkip to conversation

iio: adc: mcp3911: mask out device ID in debug prints

PATCH In review Marcus Folkesson 2 participants 2 messages Oct 10, 2022 – Oct 15, 2022

Subsystems (2)
lore
Share & tools
lore

Marcus Folkesson

author maintainer
#0 lore raw

PATCH 1/1 iio: adc: mcp3911: mask out device ID in debug prints

The Device ID should not be included when printing register.

---
 drivers/iio/adc/mcp3911.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/mcp3911.c +3 -2
index 2c1af11a621f..a71df9f3ab29 100644
@@ -59,6 +59,7 @@
 
 #define MCP3911_REG_READ(reg, id)	((((reg) << 1) | ((id) << 6) | (1 << 0)) & 0xff)
 #define MCP3911_REG_WRITE(reg, id)	((((reg) << 1) | ((id) << 6) | (0 << 0)) & 0xff)
+#define MCP3911_REG_MASK		GENMASK(4, 1)
 
 #define MCP3911_NUM_CHANNELS		2
 #define MCP3911_NUM_SCALES		6
@@ -94,8 +95,8 @@ static int mcp3911_read(struct mcp3911 *adc, u8 reg, u32 *val, u8 len)
 
 	be32_to_cpus(val);
 	*val >>= ((4 - len) * 8);
-	dev_dbg(&adc->spi->dev, "reading 0x%x from register 0x%x\n", *val,
-		reg >> 1);
+	dev_dbg(&adc->spi->dev, "reading 0x%x from register 0x%lx\n", *val,
+		FIELD_GET(MCP3911_REG_MASK, reg));
 	return ret;
 }
 
Signature · 1 line
2.37.1
maintainer
#1 lore raw
Quoted 3 lines · On Mon, 10 Oct 2022 21:46:54 +0200 Marcus Folkesson…

The Device ID should not be included when printing register.

Whilst obviously not super important to backport, this is a fix so I've applied it to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

Quoted 27 lines
---
 drivers/iio/adc/mcp3911.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/adc/mcp3911.c +3 -2
index 2c1af11a621f..a71df9f3ab29 100644
@@ -59,6 +59,7 @@
 
 #define MCP3911_REG_READ(reg, id)	((((reg) << 1) | ((id) << 6) | (1 << 0)) & 0xff)
 #define MCP3911_REG_WRITE(reg, id)	((((reg) << 1) | ((id) << 6) | (0 << 0)) & 0xff)
+#define MCP3911_REG_MASK		GENMASK(4, 1)
 
 #define MCP3911_NUM_CHANNELS		2
 #define MCP3911_NUM_SCALES		6
@@ -94,8 +95,8 @@ static int mcp3911_read(struct mcp3911 *adc, u8 reg, u32 *val, u8 len)
 
 	be32_to_cpus(val);
 	*val >>= ((4 - len) * 8);
-	dev_dbg(&adc->spi->dev, "reading 0x%x from register 0x%x\n", *val,
-		reg >> 1);
+	dev_dbg(&adc->spi->dev, "reading 0x%x from register 0x%lx\n", *val,
+		FIELD_GET(MCP3911_REG_MASK, reg));
 	return ret;
 }