mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
i2c: Add i2c_get_match_data()
[ Upstream commit 564d73c4d9 ]
Add i2c_get_match_data() to get match data for I2C, ACPI and
DT-based matching, so that we can optimize the driver code.
Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
[wsa: simplified var initialization]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Stable-dep-of: 119abf7d1815 ("hwmon: (max16065) Fix alarm attributes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
23d99c42c3
commit
3ff59f75a9
@@ -113,6 +113,25 @@ const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(i2c_match_id);
|
EXPORT_SYMBOL_GPL(i2c_match_id);
|
||||||
|
|
||||||
|
const void *i2c_get_match_data(const struct i2c_client *client)
|
||||||
|
{
|
||||||
|
struct i2c_driver *driver = to_i2c_driver(client->dev.driver);
|
||||||
|
const struct i2c_device_id *match;
|
||||||
|
const void *data;
|
||||||
|
|
||||||
|
data = device_get_match_data(&client->dev);
|
||||||
|
if (!data) {
|
||||||
|
match = i2c_match_id(driver->id_table, client);
|
||||||
|
if (!match)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
data = (const void *)match->driver_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(i2c_get_match_data);
|
||||||
|
|
||||||
static int i2c_device_match(struct device *dev, struct device_driver *drv)
|
static int i2c_device_match(struct device *dev, struct device_driver *drv)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = i2c_verify_client(dev);
|
struct i2c_client *client = i2c_verify_client(dev);
|
||||||
|
|||||||
@@ -362,6 +362,8 @@ struct i2c_adapter *i2c_verify_adapter(struct device *dev);
|
|||||||
const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
|
const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
|
||||||
const struct i2c_client *client);
|
const struct i2c_client *client);
|
||||||
|
|
||||||
|
const void *i2c_get_match_data(const struct i2c_client *client);
|
||||||
|
|
||||||
static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
|
static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
|
||||||
{
|
{
|
||||||
struct device * const dev = kobj_to_dev(kobj);
|
struct device * const dev = kobj_to_dev(kobj);
|
||||||
|
|||||||
Reference in New Issue
Block a user