Skip to contentSkip to conversation

platform/surface: surface3_power: Use i2c_acpi_get_i2c_resource() helper

PATCH In review Andy Shevchenko 3 participants 3 messages Aug 3, 2021 – Aug 6, 2021

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

PATCH 1/1 platform/surface: surface3_power: Use i2c_acpi_get_i2c_resource() helper

ACPI provides a generic helper to get I²C Serial Bus resources. Use it instead of open coded variant.

---
 drivers/platform/surface/surface3_power.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/platform/surface/surface3_power.c +1 -7
index dea82aa1abd4..90c1568ea4e0 100644
@@ -384,13 +384,7 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,
 	if (ACPI_FAILURE(ret))
 		return ret;
 
-	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		ret = AE_BAD_PARAMETER;
-		goto err;
-	}
-
-	sb = &ares->data.i2c_serial_bus;
-	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+	if (!value64 || !i2c_acpi_get_i2c_resource(ares, &sb)) {
 		ret = AE_BAD_PARAMETER;
 		goto err;
 	}
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Andy Shevchenko

ACPI provides a generic helper to get I²C Serial Bus resources. Use it instead of open coded variant.

Looks good to me, thanks!

Quoted 24 lines
---
  drivers/platform/surface/surface3_power.c | 8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
drivers/platform/surface/surface3_power.c +1 -7
index dea82aa1abd4..90c1568ea4e0 100644
@@ -384,13 +384,7 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,
  	if (ACPI_FAILURE(ret))
  		return ret;
 
-	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		ret = AE_BAD_PARAMETER;
-		goto err;
-	}
-
-	sb = &ares->data.i2c_serial_bus;
-	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+	if (!value64 || !i2c_acpi_get_i2c_resource(ares, &sb)) {
  		ret = AE_BAD_PARAMETER;
  		goto err;
  	}
#2 lore raw
In reply to Andy Shevchenko

Hi,

Quoted 4 lines · Andy Shevchenko

ACPI provides a generic helper to get I²C Serial Bus resources. Use it instead of open coded variant.

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 24 lines
---
 drivers/platform/surface/surface3_power.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/platform/surface/surface3_power.c +1 -7
index dea82aa1abd4..90c1568ea4e0 100644
@@ -384,13 +384,7 @@ mshw0011_space_handler(u32 function, acpi_physical_address command,
 	if (ACPI_FAILURE(ret))
 		return ret;
 
-	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		ret = AE_BAD_PARAMETER;
-		goto err;
-	}
-
-	sb = &ares->data.i2c_serial_bus;
-	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+	if (!value64 || !i2c_acpi_get_i2c_resource(ares, &sb)) {
 		ret = AE_BAD_PARAMETER;
 		goto err;
 	}