Skip to content

Commit e0c7800

Browse files
committed
Merge branch 'i2c/client_device_id_helper-immutable' into i2c/for-mergewindow
2 parents e826192 + 6622337 commit e0c7800

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,20 @@ int i2c_get_device_id(const struct i2c_client *client,
22362236
}
22372237
EXPORT_SYMBOL_GPL(i2c_get_device_id);
22382238

2239+
/**
2240+
* i2c_client_get_device_id - get the driver match table entry of a device
2241+
* @client: the device to query. The device must be bound to a driver
2242+
*
2243+
* Returns a pointer to the matching entry if found, NULL otherwise.
2244+
*/
2245+
const struct i2c_device_id *i2c_client_get_device_id(const struct i2c_client *client)
2246+
{
2247+
const struct i2c_driver *drv = to_i2c_driver(client->dev.driver);
2248+
2249+
return i2c_match_id(drv->id_table, client);
2250+
}
2251+
EXPORT_SYMBOL_GPL(i2c_client_get_device_id);
2252+
22392253
/* ----------------------------------------------------
22402254
* the i2c address scanning function
22412255
* Will not work for 10-bit addresses!

include/linux/i2c.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ s32 i2c_smbus_read_i2c_block_data_or_emulated(const struct i2c_client *client,
189189
u8 *values);
190190
int i2c_get_device_id(const struct i2c_client *client,
191191
struct i2c_device_identity *id);
192+
const struct i2c_device_id *i2c_client_get_device_id(const struct i2c_client *client);
192193
#endif /* I2C */
193194

194195
/**

0 commit comments

Comments
 (0)