Skip to contentSkip to conversation

iio: magnetometer: tlv493d: remove erroneous shift in X-axis data

PATCH In review Antoniu Miclaus 2 participants 2 messages Feb 10 – Feb 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: magnetometer: tlv493d: remove erroneous shift in X-axis data

TLV493D_BX2_MAG_X_AXIS_LSB is defined as GENMASK(7, 4). FIELD_GET() already right-shifts bits [7:4] to [3:0], so the additional >> 4 discards most of the X-axis low nibble. The Y and Z axes correctly omit this extra shift. Remove it.

Fixes 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")
---
 drivers/iio/magnetometer/tlv493d.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/tlv493d.c +1 -1
index ec53fd40277b..e5e050af2b74 100644
@@ -171,7 +171,7 @@ static s16 tlv493d_get_channel_data(u8 *b, enum tlv493d_channels ch)
 	switch (ch) {
 	case TLV493D_AXIS_X:
 		val = FIELD_GET(TLV493D_BX_MAG_X_AXIS_MSB, b[TLV493D_RD_REG_BX]) << 4 |
-		      FIELD_GET(TLV493D_BX2_MAG_X_AXIS_LSB, b[TLV493D_RD_REG_BX2]) >> 4;
+		      FIELD_GET(TLV493D_BX2_MAG_X_AXIS_LSB, b[TLV493D_RD_REG_BX2]);
 		break;
 	case TLV493D_AXIS_Y:
 		val = FIELD_GET(TLV493D_BY_MAG_Y_AXIS_MSB, b[TLV493D_RD_REG_BY]) << 4 |
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 7 lines · On Tue, 10 Feb 2026 18:49:50 +0200 Antoniu Miclaus…

TLV493D_BX2_MAG_X_AXIS_LSB is defined as GENMASK(7, 4). FIELD_GET() already right-shifts bits [7:4] to [3:0], so the additional >> 4 discards most of the X-axis low nibble. The Y and Z axes correctly omit this extra shift. Remove it.

Fixes 106511d280c7 ("iio: magnetometer: add support for Infineon TLV493D 3D Magentic sensor")

Applied and marked for stable. I'll be rebasing in a few days anyway, so happy to add tags or indeed drop the patch if other reviews come in before then

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/magnetometer/tlv493d.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/tlv493d.c +1 -1
index ec53fd40277b..e5e050af2b74 100644
@@ -171,7 +171,7 @@ static s16 tlv493d_get_channel_data(u8 *b, enum tlv493d_channels ch)
 	switch (ch) {
 	case TLV493D_AXIS_X:
 		val = FIELD_GET(TLV493D_BX_MAG_X_AXIS_MSB, b[TLV493D_RD_REG_BX]) << 4 |
-		      FIELD_GET(TLV493D_BX2_MAG_X_AXIS_LSB, b[TLV493D_RD_REG_BX2]) >> 4;
+		      FIELD_GET(TLV493D_BX2_MAG_X_AXIS_LSB, b[TLV493D_RD_REG_BX2]);
 		break;
 	case TLV493D_AXIS_Y:
 		val = FIELD_GET(TLV493D_BY_MAG_Y_AXIS_MSB, b[TLV493D_RD_REG_BY]) << 4 |