From f9d86ad18a0e273e4faea850123a897935f55df2 Mon Sep 17 00:00:00 2001 From: Manish Varma Date: Thu, 18 Mar 2021 13:53:57 -0700 Subject: [PATCH] ANDROID: i2c: Add vendor hook to allow assign dev_name to I2C devices "dev_name" for I2C devices won't have any value set, unless they are instantiated thru ACPI interface. As a result of this, I2C driver will assign some dynamic name in the format "%d-%04x" (e.g. 1-001f), and further this device names are used for kernel wakelocks. This dynamic names are difficult to associate with actual device and hence it will help to have an ability where vendor can assign the device name through vendor hooks. Bug: 147496295 Signed-off-by: Manish Varma Change-Id: Idb417ef5330002063a9763544f9f0364f9581276 --- android/abi_gki_aarch64_generic | 2 ++ drivers/android/vendor_hooks.c | 2 ++ drivers/i2c/i2c-core-of.c | 3 +++ include/trace/hooks/i2c.h | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 include/trace/hooks/i2c.h diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 2c9393574c8d..fb1709b577ba 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1822,6 +1822,7 @@ __traceiter_android_vh_enable_thermal_genl_check __traceiter_android_vh_ep_create_wakeup_source __traceiter_android_vh_ipi_stop + __traceiter_android_vh_of_i2c_get_board_info __traceiter_android_vh_pagecache_get_page __traceiter_android_vh_rmqueue __traceiter_android_vh_timerfd_create @@ -1881,6 +1882,7 @@ __tracepoint_android_vh_enable_thermal_genl_check __tracepoint_android_vh_ep_create_wakeup_source __tracepoint_android_vh_ipi_stop + __tracepoint_android_vh_of_i2c_get_board_info __tracepoint_android_vh_pagecache_get_page __tracepoint_android_vh_rmqueue __tracepoint_android_vh_timerfd_create diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 7a8761a03d41..c391ad508f3e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -271,3 +272,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_finish_update_load_avg_se); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_is_initialized); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_inactive_ratio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_of_i2c_get_board_info); diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 3ed74aa4b44b..2088009c581f 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "i2c-core.h" @@ -32,6 +33,8 @@ int of_i2c_get_board_info(struct device *dev, struct device_node *node, return -EINVAL; } + trace_android_vh_of_i2c_get_board_info(node, &(info->dev_name)); + ret = of_property_read_u32(node, "reg", &addr); if (ret) { dev_err(dev, "of_i2c: invalid reg on %pOF\n", node); diff --git a/include/trace/hooks/i2c.h b/include/trace/hooks/i2c.h new file mode 100644 index 000000000000..71536ad67f67 --- /dev/null +++ b/include/trace/hooks/i2c.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM i2c + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_I2C_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_I2C_H + +#include +#include + +DECLARE_HOOK(android_vh_of_i2c_get_board_info, + TP_PROTO(struct device_node *node, const char **dev_name), + TP_ARGS(node, dev_name)); + +#endif /* _TRACE_HOOK_I2C_H */ + +/* This part must be outside protection */ +#include