.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * inv_mpu_acpi: ACPI processing for creating client devices |
---|
3 | 4 | * 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. |
---|
13 | 5 | */ |
---|
14 | 6 | |
---|
15 | 7 | #ifdef CONFIG_ACPI |
---|
.. | .. |
---|
91 | 83 | |
---|
92 | 84 | static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data) |
---|
93 | 85 | { |
---|
| 86 | + struct acpi_resource_i2c_serialbus *sb; |
---|
94 | 87 | u32 *addr = data; |
---|
95 | 88 | |
---|
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; |
---|
106 | 94 | } |
---|
107 | 95 | |
---|
108 | 96 | /* Tell the ACPI core that we already copied this address */ |
---|
.. | .. |
---|
113 | 101 | unsigned short *primary_addr, |
---|
114 | 102 | unsigned short *secondary_addr) |
---|
115 | 103 | { |
---|
| 104 | + struct acpi_device *adev = ACPI_COMPANION(&client->dev); |
---|
116 | 105 | const struct acpi_device_id *id; |
---|
117 | | - struct acpi_device *adev; |
---|
118 | 106 | u32 i2c_addr = 0; |
---|
119 | 107 | LIST_HEAD(resources); |
---|
120 | 108 | int ret; |
---|
.. | .. |
---|
122 | 110 | id = acpi_match_device(client->dev.driver->acpi_match_table, |
---|
123 | 111 | &client->dev); |
---|
124 | 112 | if (!id) |
---|
125 | | - return -ENODEV; |
---|
126 | | - |
---|
127 | | - adev = ACPI_COMPANION(&client->dev); |
---|
128 | | - if (!adev) |
---|
129 | 113 | return -ENODEV; |
---|
130 | 114 | |
---|
131 | 115 | ret = acpi_dev_get_resources(adev, &resources, |
---|
.. | .. |
---|
147 | 131 | st->mux_client = NULL; |
---|
148 | 132 | if (ACPI_HANDLE(&client->dev)) { |
---|
149 | 133 | struct i2c_board_info info; |
---|
| 134 | + struct i2c_client *mux_client; |
---|
150 | 135 | struct acpi_device *adev; |
---|
151 | 136 | int ret = -1; |
---|
152 | 137 | |
---|
.. | .. |
---|
184 | 169 | } else |
---|
185 | 170 | return 0; /* no secondary addr, which is OK */ |
---|
186 | 171 | } |
---|
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; |
---|
190 | 176 | } |
---|
191 | 177 | |
---|
192 | 178 | return 0; |
---|