Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: da10c06a044b ("i2c: Make I2C ID tables non-mandatory for DT'ed devices")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Rajmohan Mani <rajmohan.mani@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
[wsa: needed to get some drivers probed again]
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Andy Shevchenko and committed by
Wolfram Sang
c64ffff7 16f73eb0

+25 -4
+15 -4
drivers/i2c/i2c-core-acpi.c
··· 230 230 dev_warn(&adap->dev, "failed to enumerate I2C slaves\n"); 231 231 } 232 232 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 + 233 243 static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level, 234 244 void *data, void **return_value) 235 245 { ··· 299 289 } 300 290 EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed); 301 291 302 - static int i2c_acpi_match_adapter(struct device *dev, void *data) 292 + static int i2c_acpi_find_match_adapter(struct device *dev, void *data) 303 293 { 304 294 struct i2c_adapter *adapter = i2c_verify_adapter(dev); 305 295 ··· 309 299 return ACPI_HANDLE(dev) == (acpi_handle)data; 310 300 } 311 301 312 - static int i2c_acpi_match_device(struct device *dev, void *data) 302 + static int i2c_acpi_find_match_device(struct device *dev, void *data) 313 303 { 314 304 return ACPI_COMPANION(dev) == data; 315 305 } ··· 319 309 struct device *dev; 320 310 321 311 dev = bus_find_device(&i2c_bus_type, NULL, handle, 322 - i2c_acpi_match_adapter); 312 + i2c_acpi_find_match_adapter); 323 313 return dev ? i2c_verify_adapter(dev) : NULL; 324 314 } 325 315 ··· 327 317 { 328 318 struct device *dev; 329 319 330 - dev = bus_find_device(&i2c_bus_type, NULL, adev, i2c_acpi_match_device); 320 + dev = bus_find_device(&i2c_bus_type, NULL, adev, 321 + i2c_acpi_find_match_device); 331 322 return dev ? i2c_verify_client(dev) : NULL; 332 323 } 333 324
+1
drivers/i2c/i2c-core-base.c
··· 357 357 * Tree match table entry is supplied for the probing device. 358 358 */ 359 359 if (!driver->id_table && 360 + !i2c_acpi_match_device(dev->driver->acpi_match_table, client) && 360 361 !i2c_of_match_device(dev->driver->of_match_table, client)) 361 362 return -ENODEV; 362 363
+9
drivers/i2c/i2c-core.h
··· 31 31 int i2c_check_7bit_addr_validity_strict(unsigned short addr); 32 32 33 33 #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); 34 37 void i2c_acpi_register_devices(struct i2c_adapter *adap); 35 38 #else /* CONFIG_ACPI */ 36 39 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 + } 37 46 #endif /* CONFIG_ACPI */ 38 47 extern struct notifier_block i2c_acpi_notifier; 39 48