Skip to content

Commit cddbefc

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.13/i2c-hid' into for-linus
- Cleanups to ACPI handling in i2c-hid driver from Andy Shevchenko
2 parents 8ba3c81 + 0960941 commit cddbefc

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

drivers/hid/i2c-hid/i2c-hid-acpi.c

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
#include <linux/kernel.h>
2626
#include <linux/module.h>
2727
#include <linux/pm.h>
28+
#include <linux/uuid.h>
2829

2930
#include "i2c-hid.h"
3031

3132
struct i2c_hid_acpi {
3233
struct i2chid_ops ops;
33-
struct i2c_client *client;
34+
struct acpi_device *adev;
3435
};
3536

3637
static const struct acpi_device_id i2c_hid_acpi_blacklist[] = {
@@ -42,29 +43,24 @@ static const struct acpi_device_id i2c_hid_acpi_blacklist[] = {
4243
{ },
4344
};
4445

45-
static int i2c_hid_acpi_get_descriptor(struct i2c_client *client)
46+
/* HID I²C Device: 3cdff6f7-4267-4555-ad05-b30a3d8938de */
47+
static guid_t i2c_hid_guid =
48+
GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
49+
0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
50+
51+
static int i2c_hid_acpi_get_descriptor(struct acpi_device *adev)
4652
{
47-
static guid_t i2c_hid_guid =
48-
GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
49-
0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
53+
acpi_handle handle = acpi_device_handle(adev);
5054
union acpi_object *obj;
51-
struct acpi_device *adev;
52-
acpi_handle handle;
5355
u16 hid_descriptor_address;
5456

55-
handle = ACPI_HANDLE(&client->dev);
56-
if (!handle || acpi_bus_get_device(handle, &adev)) {
57-
dev_err(&client->dev, "Error could not get ACPI device\n");
58-
return -ENODEV;
59-
}
60-
6157
if (acpi_match_device_ids(adev, i2c_hid_acpi_blacklist) == 0)
6258
return -ENODEV;
6359

6460
obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL,
6561
ACPI_TYPE_INTEGER);
6662
if (!obj) {
67-
dev_err(&client->dev, "Error _DSM call to get HID descriptor address failed\n");
63+
acpi_handle_err(handle, "Error _DSM call to get HID descriptor address failed\n");
6864
return -ENODEV;
6965
}
7066

@@ -76,36 +72,38 @@ static int i2c_hid_acpi_get_descriptor(struct i2c_client *client)
7672

7773
static void i2c_hid_acpi_shutdown_tail(struct i2chid_ops *ops)
7874
{
79-
struct i2c_hid_acpi *ihid_acpi =
80-
container_of(ops, struct i2c_hid_acpi, ops);
81-
struct device *dev = &ihid_acpi->client->dev;
82-
acpi_device_set_power(ACPI_COMPANION(dev), ACPI_STATE_D3_COLD);
75+
struct i2c_hid_acpi *ihid_acpi = container_of(ops, struct i2c_hid_acpi, ops);
76+
77+
acpi_device_set_power(ihid_acpi->adev, ACPI_STATE_D3_COLD);
8378
}
8479

85-
static int i2c_hid_acpi_probe(struct i2c_client *client,
86-
const struct i2c_device_id *dev_id)
80+
static int i2c_hid_acpi_probe(struct i2c_client *client)
8781
{
8882
struct device *dev = &client->dev;
8983
struct i2c_hid_acpi *ihid_acpi;
9084
struct acpi_device *adev;
9185
u16 hid_descriptor_address;
9286
int ret;
9387

88+
adev = ACPI_COMPANION(dev);
89+
if (!adev) {
90+
dev_err(&client->dev, "Error could not get ACPI device\n");
91+
return -ENODEV;
92+
}
93+
9494
ihid_acpi = devm_kzalloc(&client->dev, sizeof(*ihid_acpi), GFP_KERNEL);
9595
if (!ihid_acpi)
9696
return -ENOMEM;
9797

98-
ihid_acpi->client = client;
98+
ihid_acpi->adev = adev;
9999
ihid_acpi->ops.shutdown_tail = i2c_hid_acpi_shutdown_tail;
100100

101-
ret = i2c_hid_acpi_get_descriptor(client);
101+
ret = i2c_hid_acpi_get_descriptor(adev);
102102
if (ret < 0)
103103
return ret;
104104
hid_descriptor_address = ret;
105105

106-
adev = ACPI_COMPANION(dev);
107-
if (adev)
108-
acpi_device_fix_up_power(adev);
106+
acpi_device_fix_up_power(adev);
109107

110108
if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
111109
device_set_wakeup_capable(dev, true);
@@ -128,10 +126,10 @@ static struct i2c_driver i2c_hid_acpi_driver = {
128126
.name = "i2c_hid_acpi",
129127
.pm = &i2c_hid_core_pm,
130128
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
131-
.acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
129+
.acpi_match_table = i2c_hid_acpi_match,
132130
},
133131

134-
.probe = i2c_hid_acpi_probe,
132+
.probe_new = i2c_hid_acpi_probe,
135133
.remove = i2c_hid_core_remove,
136134
.shutdown = i2c_hid_core_shutdown,
137135
};

0 commit comments

Comments
 (0)