Skip to contentSkip to conversation

i2c-hid: Use ACPI_COMPANION() directly

PATCH Applied Andy Shevchenko 2 participants 3 messages Jan 19, 2018 – Feb 16, 2018 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c-hid: Use ACPI_COMPANION() directly

Instead of doing additional checks and functional calls, just get ACPI companion device directly.

---
 drivers/hid/i2c-hid/i2c-hid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/i2c-hid/i2c-hid.c +2 -2
index 7230243b94d3..0d3ca542e987 100644
@@ -891,10 +891,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
 
 static void i2c_hid_acpi_fix_up_power(struct device *dev)
 {
-	acpi_handle handle = ACPI_HANDLE(dev);
 	struct acpi_device *adev;
 
-	if (handle && acpi_bus_get_device(handle, &adev) == 0)
+	adev = ACPI_COMPANION(dev);
+	if (adev)
 		acpi_device_fix_up_power(adev);
 }
 
Signature · 1 line
2.15.1
#1 lore raw
Quoted 3 lines · Andy Shevchenko

Instead of doing additional checks and functional calls, just get ACPI companion device directly.

Any comments on this? The rationale is to prevent people copy'n'paste current approach instead of better one which is presented by this change.

Quoted 24 lines
---
 drivers/hid/i2c-hid/i2c-hid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/i2c-hid/i2c- renamed from drivers/hid/i2c-hid/i2c-hid.c +0 -0

hid.c
index 7230243b94d3..0d3ca542e987 100644

drivers/hid/i2c-hid/i2c-hid.c +2 -2
@@ -891,10 +891,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client
 *client,
 
 static void i2c_hid_acpi_fix_up_power(struct device *dev)
 {
-	acpi_handle handle = ACPI_HANDLE(dev);
 	struct acpi_device *adev;
 
-	if (handle && acpi_bus_get_device(handle, &adev) == 0)
+	adev = ACPI_COMPANION(dev);
+	if (adev)
 		acpi_device_fix_up_power(adev);
 }
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer Applied
#2 lore raw
In reply to Andy Shevchenko
Quoted 14 lines · Andy Shevchenko

Instead of doing additional checks and functional calls, just get ACPI companion device directly.

---
 drivers/hid/i2c-hid/i2c-hid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/i2c-hid/i2c-hid.c +0 -0
index 7230243b94d3..0d3ca542e987 100644
@@ -891,10 +891,10 @@ static int i2c_hid_acpi_pdata(struct i2c_client *client,
 

drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_acpi_pdata(struct i2c_client *client, · line 899

Quoted 10 lines
drivers/hid/i2c-hid/i2c-hid.c +2 -2
 static void i2c_hid_acpi_fix_up_power(struct device *dev)
 {
-	acpi_handle handle = ACPI_HANDLE(dev);
 	struct acpi_device *adev;
 
-	if (handle && acpi_bus_get_device(handle, &adev) == 0)
+	adev = ACPI_COMPANION(dev);
+	if (adev)
 		acpi_device_fix_up_power(adev);
 }

Applied to for-4.17/hid-i2c. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs