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 <nainmeht@codeaurora.org>
This commit is contained in:
Naina Mehta
2021-03-10 10:03:29 +05:30
committed by Greg Kroah-Hartman
parent 45d19936bf
commit c9050b8a42
3 changed files with 40 additions and 8 deletions

View File

@@ -46,6 +46,7 @@
#include <trace/hooks/module.h>
#include <trace/hooks/memory.h>
#include <trace/hooks/typec.h>
#include <trace/hooks/gpiolib.h>
/*
* 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);

View File

@@ -30,6 +30,8 @@
#define CREATE_TRACE_POINTS
#include <trace/events/gpio.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/gpiolib.h>
/* 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);
}
}
}

View File

@@ -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 <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#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 <trace/define_trace.h>