Skip to content

Commit 5213d7e

Browse files
abuibrahimWolfram Sang
authored andcommitted
i2c: acpi: export i2c_acpi_find_adapter_by_handle
This allows drivers to lookup i2c adapters on ACPI based systems similar to of_get_i2c_adapter_by_node() with DT based systems. Signed-off-by: Ruslan Babayev <ruslan@babayev.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 12cb084 commit 5213d7e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/i2c/i2c-core-acpi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,15 @@ static int i2c_acpi_find_match_device(struct device *dev, void *data)
337337
return ACPI_COMPANION(dev) == data;
338338
}
339339

340-
static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
340+
struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
341341
{
342342
struct device *dev;
343343

344344
dev = bus_find_device(&i2c_bus_type, NULL, handle,
345345
i2c_acpi_find_match_adapter);
346346
return dev ? i2c_verify_adapter(dev) : NULL;
347347
}
348+
EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);
348349

349350
static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
350351
{

include/linux/i2c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef _LINUX_I2C_H
1515
#define _LINUX_I2C_H
1616

17+
#include <linux/acpi.h> /* for acpi_handle */
1718
#include <linux/mod_devicetable.h>
1819
#include <linux/device.h> /* for struct device */
1920
#include <linux/sched.h> /* for completion */
@@ -981,6 +982,7 @@ bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
981982
u32 i2c_acpi_find_bus_speed(struct device *dev);
982983
struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
983984
struct i2c_board_info *info);
985+
struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle);
984986
#else
985987
static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
986988
struct acpi_resource_i2c_serialbus **i2c)
@@ -996,6 +998,10 @@ static inline struct i2c_client *i2c_acpi_new_device(struct device *dev,
996998
{
997999
return NULL;
9981000
}
1001+
static inline struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
1002+
{
1003+
return NULL;
1004+
}
9991005
#endif /* CONFIG_ACPI */
10001006

10011007
#endif /* _LINUX_I2C_H */

0 commit comments

Comments
 (0)