forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
....@@ -1,15 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * inv_mpu_acpi: ACPI processing for creating client devices
34 * Copyright (c) 2015, Intel Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
135 */
146
157 #ifdef CONFIG_ACPI
....@@ -91,18 +83,14 @@
9183
9284 static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
9385 {
86
+ struct acpi_resource_i2c_serialbus *sb;
9487 u32 *addr = data;
9588
96
- if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
97
- struct acpi_resource_i2c_serialbus *sb;
98
-
99
- sb = &ares->data.i2c_serial_bus;
100
- if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
101
- if (*addr)
102
- *addr |= (sb->slave_address << 16);
103
- else
104
- *addr = sb->slave_address;
105
- }
89
+ if (i2c_acpi_get_i2c_resource(ares, &sb)) {
90
+ if (*addr)
91
+ *addr |= (sb->slave_address << 16);
92
+ else
93
+ *addr = sb->slave_address;
10694 }
10795
10896 /* Tell the ACPI core that we already copied this address */
....@@ -113,8 +101,8 @@
113101 unsigned short *primary_addr,
114102 unsigned short *secondary_addr)
115103 {
104
+ struct acpi_device *adev = ACPI_COMPANION(&client->dev);
116105 const struct acpi_device_id *id;
117
- struct acpi_device *adev;
118106 u32 i2c_addr = 0;
119107 LIST_HEAD(resources);
120108 int ret;
....@@ -122,10 +110,6 @@
122110 id = acpi_match_device(client->dev.driver->acpi_match_table,
123111 &client->dev);
124112 if (!id)
125
- return -ENODEV;
126
-
127
- adev = ACPI_COMPANION(&client->dev);
128
- if (!adev)
129113 return -ENODEV;
130114
131115 ret = acpi_dev_get_resources(adev, &resources,
....@@ -147,6 +131,7 @@
147131 st->mux_client = NULL;
148132 if (ACPI_HANDLE(&client->dev)) {
149133 struct i2c_board_info info;
134
+ struct i2c_client *mux_client;
150135 struct acpi_device *adev;
151136 int ret = -1;
152137
....@@ -184,9 +169,10 @@
184169 } else
185170 return 0; /* no secondary addr, which is OK */
186171 }
187
- st->mux_client = i2c_new_device(st->muxc->adapter[0], &info);
188
- if (!st->mux_client)
189
- return -ENODEV;
172
+ mux_client = i2c_new_client_device(st->muxc->adapter[0], &info);
173
+ if (IS_ERR(mux_client))
174
+ return PTR_ERR(mux_client);
175
+ st->mux_client = mux_client;
190176 }
191177
192178 return 0;