Skip to contentSkip to conversation

iio: imu: inv_mpu6050: Drop double check for ACPI companion device

PATCH In review Andy Shevchenko 2 participants 2 messages May 28, 2020 – May 31, 2020

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

PATCH 1/1 iio: imu: inv_mpu6050: Drop double check for ACPI companion device

acpi_dev_get_resources() does perform the NULL pointer check against ACPI companion device which is given as function parameter. Thus, there is no need to duplicate this check in the caller.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +1 -5
index 2f8560ba4572..bf9bdaf6519a 100644
@@ -101,8 +101,8 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 				       unsigned short *primary_addr,
 				       unsigned short *secondary_addr)
 {
+	struct acpi_device *adev = ACPI_COMPANION(&client->dev);
 	const struct acpi_device_id *id;
-	struct acpi_device *adev;
 	u32 i2c_addr = 0;
 	LIST_HEAD(resources);
 	int ret;
@@ -112,10 +112,6 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 	if (!id)
 		return -ENODEV;
 
-	adev = ACPI_COMPANION(&client->dev);
-	if (!adev)
-		return -ENODEV;
-
 	ret = acpi_dev_get_resources(adev, &resources,
 				     acpi_i2c_check_resource, &i2c_addr);
 	if (ret < 0)
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 5 lines · On Thu, 28 May 2020 17:15:52 +0300 Andy Shevchenko…

acpi_dev_get_resources() does perform the NULL pointer check against ACPI companion device which is given as function parameter. Thus, there is no need to duplicate this check in the caller.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c +1 -5
index 2f8560ba4572..bf9bdaf6519a 100644
@@ -101,8 +101,8 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 				       unsigned short *primary_addr,
 				       unsigned short *secondary_addr)
 {
+	struct acpi_device *adev = ACPI_COMPANION(&client->dev);
 	const struct acpi_device_id *id;
-	struct acpi_device *adev;
 	u32 i2c_addr = 0;
 	LIST_HEAD(resources);
 	int ret;
@@ -112,10 +112,6 @@ static int inv_mpu_process_acpi_config(struct i2c_client *client,
 	if (!id)
 		return -ENODEV;
 
-	adev = ACPI_COMPANION(&client->dev);
-	if (!adev)
-		return -ENODEV;
-
 	ret = acpi_dev_get_resources(adev, &resources,
 				     acpi_i2c_check_resource, &i2c_addr);
 	if (ret < 0)