Skip to content

Commit c64ffff

Browse files
andy-shevWolfram Sang
authored andcommitted
i2c: core: Allow empty id_table in ACPI case as well
For now empty ID table is not allowed with ACPI and prevents driver to be probed. Add a check to allow empty ID table. This introduces a helper i2c_acpi_match_device(). Note, we rename some static function in i2c-core-acpi.c to distinguish with public API. Fixes: da10c06 ("i2c: Make I2C ID tables non-mandatory for DT'ed devices") Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Rajmohan Mani <[email protected]> Acked-by: Mika Westerberg <[email protected]> [wsa: needed to get some drivers probed again] Signed-off-by: Wolfram Sang <[email protected]>
1 parent 16f73eb commit c64ffff

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

drivers/i2c/i2c-core-acpi.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
230230
dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
231231
}
232232

233+
const struct acpi_device_id *
234+
i2c_acpi_match_device(const struct acpi_device_id *matches,
235+
struct i2c_client *client)
236+
{
237+
if (!(client && matches))
238+
return NULL;
239+
240+
return acpi_match_device(matches, &client->dev);
241+
}
242+
233243
static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level,
234244
void *data, void **return_value)
235245
{
@@ -289,7 +299,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
289299
}
290300
EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
291301

292-
static int i2c_acpi_match_adapter(struct device *dev, void *data)
302+
static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
293303
{
294304
struct i2c_adapter *adapter = i2c_verify_adapter(dev);
295305

@@ -299,7 +309,7 @@ static int i2c_acpi_match_adapter(struct device *dev, void *data)
299309
return ACPI_HANDLE(dev) == (acpi_handle)data;
300310
}
301311

302-
static int i2c_acpi_match_device(struct device *dev, void *data)
312+
static int i2c_acpi_find_match_device(struct device *dev, void *data)
303313
{
304314
return ACPI_COMPANION(dev) == data;
305315
}
@@ -309,15 +319,16 @@ static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
309319
struct device *dev;
310320

311321
dev = bus_find_device(&i2c_bus_type, NULL, handle,
312-
i2c_acpi_match_adapter);
322+
i2c_acpi_find_match_adapter);
313323
return dev ? i2c_verify_adapter(dev) : NULL;
314324
}
315325

316326
static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
317327
{
318328
struct device *dev;
319329

320-
dev = bus_find_device(&i2c_bus_type, NULL, adev, i2c_acpi_match_device);
330+
dev = bus_find_device(&i2c_bus_type, NULL, adev,
331+
i2c_acpi_find_match_device);
321332
return dev ? i2c_verify_client(dev) : NULL;
322333
}
323334

drivers/i2c/i2c-core-base.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static int i2c_device_probe(struct device *dev)
357357
* Tree match table entry is supplied for the probing device.
358358
*/
359359
if (!driver->id_table &&
360+
!i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
360361
!i2c_of_match_device(dev->driver->of_match_table, client))
361362
return -ENODEV;
362363

drivers/i2c/i2c-core.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ int i2c_check_addr_validity(unsigned addr, unsigned short flags);
3131
int i2c_check_7bit_addr_validity_strict(unsigned short addr);
3232

3333
#ifdef CONFIG_ACPI
34+
const struct acpi_device_id *
35+
i2c_acpi_match_device(const struct acpi_device_id *matches,
36+
struct i2c_client *client);
3437
void i2c_acpi_register_devices(struct i2c_adapter *adap);
3538
#else /* CONFIG_ACPI */
3639
static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { }
40+
static inline const struct acpi_device_id *
41+
i2c_acpi_match_device(const struct acpi_device_id *matches,
42+
struct i2c_client *client)
43+
{
44+
return NULL;
45+
}
3746
#endif /* CONFIG_ACPI */
3847
extern struct notifier_block i2c_acpi_notifier;
3948

0 commit comments

Comments
 (0)