From c9050b8a428dc656c50c871be81a191bd3092261 Mon Sep 17 00:00:00 2001 From: Naina Mehta Date: Wed, 10 Mar 2021 10:03:29 +0530 Subject: [PATCH] ANDROID: gpiolib: Add vendor hook for gpio read Add android_vh_gpio_read vendor hook to bypass initial gpio read. Bug: 182716666 Change-Id: Ifda23ae50d90573698bc88fc9bbdfd428fdeae1a Signed-off-by: Naina Mehta --- drivers/android/vendor_hooks.c | 2 ++ drivers/gpio/gpiolib.c | 22 ++++++++++++++-------- include/trace/hooks/gpiolib.h | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 include/trace/hooks/gpiolib.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index ba2608c9ede6..2e6f6fa13eb5 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -46,6 +46,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -218,3 +219,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpci_override_toggling); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_chk_contaminant); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_typec_tcpci_get_vbus); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_task_time); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gpio_block_read); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 1200ae901e79..987dee86d4f3 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -30,6 +30,8 @@ #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS +#include /* Implementation infrastructure for GPIO interfaces. * @@ -575,6 +577,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, unsigned i; int base = gc->base; struct gpio_device *gdev; + bool block_gpio_read = false; /* * First: allocate and populate the internal stat container, and @@ -700,15 +703,18 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, if (ret) goto err_remove_of_chip; - for (i = 0; i < gc->ngpio; i++) { - struct gpio_desc *desc = &gdev->descs[i]; + trace_android_vh_gpio_block_read(gdev, &block_gpio_read); + if (!block_gpio_read) { + for (i = 0; i < gc->ngpio; i++) { + struct gpio_desc *desc = &gdev->descs[i]; - if (gc->get_direction && gpiochip_line_is_valid(gc, i)) { - assign_bit(FLAG_IS_OUT, - &desc->flags, !gc->get_direction(gc, i)); - } else { - assign_bit(FLAG_IS_OUT, - &desc->flags, !gc->direction_input); + if (gc->get_direction && gpiochip_line_is_valid(gc, i)) { + assign_bit(FLAG_IS_OUT, + &desc->flags, !gc->get_direction(gc, i)); + } else { + assign_bit(FLAG_IS_OUT, + &desc->flags, !gc->direction_input); + } } } diff --git a/include/trace/hooks/gpiolib.h b/include/trace/hooks/gpiolib.h new file mode 100644 index 000000000000..96aca935f953 --- /dev/null +++ b/include/trace/hooks/gpiolib.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM gpiolib + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_GPIOLIB_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_GPIOLIB_H + +#include +#include +#include "../drivers/gpio/gpiolib.h" + +#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) +DECLARE_HOOK(android_vh_gpio_block_read, + TP_PROTO(struct gpio_device *gdev, bool *block_gpio_read), + TP_ARGS(gdev, block_gpio_read)); +#else +#define trace_android_vh_gpio_block_read(gdev, block_gpio_read) +#endif + +#endif /* _TRACE_HOOK_GPIOLIB_H */ +/* This part must be outside protection */ +#include