Skip to contentSkip to conversation

iio: imu: inv_mpu6050: Use upper_16_bits()/lower_16_bits() helpers

PATCH Applied Andy Shevchenko 3 participants 3 messages Sep 4, 2024 – Sep 7, 2024

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

PATCH 1/1 iio: imu: inv_mpu6050: Use upper_16_bits()/lower_16_bits() helpers

Use upper_16_bits()/lower_16_bits() helpers instead of open-coding them. This is easier to scan quickly compared to bitwise manipulation, and it is pleasingly symmetric.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +4 -2
index f7bce428d9eb..b15d8c94cc11 100644
@@ -10,6 +10,8 @@
 #include <linux/i2c.h>
 #include <linux/dmi.h>
 #include <linux/acpi.h>
+#include <linux/wordpart.h>
+
 #include "inv_mpu_iio.h"
 
 enum inv_mpu_product_name {
@@ -118,8 +120,8 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 		return ret;
 
 	acpi_dev_free_resource_list(&resources);
-	*primary_addr = i2c_addr & 0x0000ffff;
-	*secondary_addr = (i2c_addr & 0xffff0000) >> 16;
+	*primary_addr = lower_16_bits(i2c_addr);
+	*secondary_addr = upper_16_bits(i2c_addr);
 
 	return 0;
 }
Signature · 1 line
2.46.0
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

looks good for me, nice reading improvement indeed.

Thanks for the patch,
JB

________________________________________
From: Andy Shevchenko <[email protected]>
Sent: Wednesday, September 4, 2024 20:45
To: Andy Shevchenko <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Cc: Jonathan Cameron <[email protected]>; Lars-Peter Clausen <[email protected]>
Subject: [PATCH v1 1/1] iio: imu: inv_mpu6050: Use upper_16_bits()/lower_16_bits() helpers

This Message Is From an External Sender
This message came from outside your organization.

Use upper_16_bits()/lower_16_bits() helpers instead of open-coding them.
This is easier to scan quickly compared to bitwise manipulation, and
it is pleasingly symmetric.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +4 -2
index f7bce428d9eb..b15d8c94cc11 100644
@@ -10,6 +10,8 @@
 #include <linux/i2c.h>
 #include <linux/dmi.h>
 #include <linux/acpi.h>
+#include <linux/wordpart.h>
+
 #include "inv_mpu_iio.h"
 
 enum inv_mpu_product_name {
@@ -118,8 +120,8 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 		return ret;
 
 	acpi_dev_free_resource_list(&resources);
-	*primary_addr = i2c_addr & 0x0000ffff;
-	*secondary_addr = (i2c_addr & 0xffff0000) >> 16;
+	*primary_addr = lower_16_bits(i2c_addr);
+	*secondary_addr = upper_16_bits(i2c_addr);
 
 	return 0;
 }
Signature · 1 line
2.46.0
maintainer Applied
#2 lore raw
Quoted 5 lines · On Thu, 5 Sep 2024 09:16:22 +0000 Jean-Baptiste Maneyrol…

Hello,

looks good for me, nice reading improvement indeed.

Applied.

Quoted 47 lines

Thanks for the patch,
JB

________________________________________
From: Andy Shevchenko <[email protected]>
Sent: Wednesday, September 4, 2024 20:45
To: Andy Shevchenko <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> Cc: Jonathan Cameron <[email protected]>; Lars-Peter Clausen <[email protected]>
Subject: [PATCH v1 1/1] iio: imu: inv_mpu6050: Use upper_16_bits()/lower_16_bits() helpers

This Message Is From an External Sender
This message came from outside your organization.

Use upper_16_bits()/lower_16_bits() helpers instead of open-coding them.
This is easier to scan quickly compared to bitwise manipulation, and
it is pleasingly symmetric.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +4 -2
index f7bce428d9eb..b15d8c94cc11 100644
@@ -10,6 +10,8 @@
 #include <linux/i2c.h>
 #include <linux/dmi.h>
 #include <linux/acpi.h>
+#include <linux/wordpart.h>
+
 #include "inv_mpu_iio.h"
 
 enum inv_mpu_product_name {
@@ -118,8 +120,8 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 		return ret;
 
 	acpi_dev_free_resource_list(&resources);
-	*primary_addr = i2c_addr & 0x0000ffff;
-	*secondary_addr = (i2c_addr & 0xffff0000) >> 16;
+	*primary_addr = lower_16_bits(i2c_addr);
+	*secondary_addr = upper_16_bits(i2c_addr);
 
 	return 0;
 }