diff mbox series

[v2,1/2] HID: i2c-hid: acpi: Drop unneded NULL check of adev

Message ID 20230116154621.16135-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Mainlined
Commit 572eaeb7fae8883612b9f410dafb0f9f5a563dc2
Delegated to: Jiri Kosina
Headers show
Series [v2,1/2] HID: i2c-hid: acpi: Drop unneded NULL check of adev | expand

Commit Message

Andy Shevchenko Jan. 16, 2023, 3:46 p.m. UTC
The driver is enumerated on ACPI platforms, so adev is valid.
Since there is no valid I²C ID table provided, there is no
possibility to bind a device to this driver via user space.
Hence, drop unneeded NULL check of adev.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: no changes
 drivers/hid/i2c-hid/i2c-hid-acpi.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Jiri Kosina Jan. 18, 2023, 9:06 a.m. UTC | #1
On Mon, 16 Jan 2023, Andy Shevchenko wrote:

> The driver is enumerated on ACPI platforms, so adev is valid.
> Since there is no valid I²C ID table provided, there is no
> possibility to bind a device to this driver via user space.
> Hence, drop unneeded NULL check of adev.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied both to hid.git#for-6.3/i2c-hid. Thanks,
Andy Shevchenko Jan. 18, 2023, 10 a.m. UTC | #2
On Wed, Jan 18, 2023 at 10:06:32AM +0100, Jiri Kosina wrote:
> On Mon, 16 Jan 2023, Andy Shevchenko wrote:
> 
> > The driver is enumerated on ACPI platforms, so adev is valid.
> > Since there is no valid I²C ID table provided, there is no
> > possibility to bind a device to this driver via user space.
> > Hence, drop unneeded NULL check of adev.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Applied both to hid.git#for-6.3/i2c-hid. Thanks,

Thank you and HNY!
diff mbox series

Patch

diff --git a/drivers/hid/i2c-hid/i2c-hid-acpi.c b/drivers/hid/i2c-hid/i2c-hid-acpi.c
index 375c77c3db74..5e28da45e762 100644
--- a/drivers/hid/i2c-hid/i2c-hid-acpi.c
+++ b/drivers/hid/i2c-hid/i2c-hid-acpi.c
@@ -48,8 +48,9 @@  static guid_t i2c_hid_guid =
 	GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
 		  0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
 
-static int i2c_hid_acpi_get_descriptor(struct acpi_device *adev)
+static int i2c_hid_acpi_get_descriptor(struct i2c_hid_acpi *ihid_acpi)
 {
+	struct acpi_device *adev = ihid_acpi->adev;
 	acpi_handle handle = acpi_device_handle(adev);
 	union acpi_object *obj;
 	u16 hid_descriptor_address;
@@ -81,29 +82,22 @@  static int i2c_hid_acpi_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	struct i2c_hid_acpi *ihid_acpi;
-	struct acpi_device *adev;
 	u16 hid_descriptor_address;
 	int ret;
 
-	adev = ACPI_COMPANION(dev);
-	if (!adev) {
-		dev_err(&client->dev, "Error could not get ACPI device\n");
-		return -ENODEV;
-	}
-
 	ihid_acpi = devm_kzalloc(&client->dev, sizeof(*ihid_acpi), GFP_KERNEL);
 	if (!ihid_acpi)
 		return -ENOMEM;
 
-	ihid_acpi->adev = adev;
+	ihid_acpi->adev = ACPI_COMPANION(dev);
 	ihid_acpi->ops.shutdown_tail = i2c_hid_acpi_shutdown_tail;
 
-	ret = i2c_hid_acpi_get_descriptor(adev);
+	ret = i2c_hid_acpi_get_descriptor(ihid_acpi);
 	if (ret < 0)
 		return ret;
 	hid_descriptor_address = ret;
 
-	acpi_device_fix_up_power(adev);
+	acpi_device_fix_up_power(ihid_acpi->adev);
 
 	return i2c_hid_core_probe(client, &ihid_acpi->ops,
 				  hid_descriptor_address, 0);