Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) // Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include "evswitch.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include "evlist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) bool evswitch__discard(struct evswitch *evswitch, struct evsel *evsel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 	if (evswitch->on && evswitch->discarding) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 		if (evswitch->on != evsel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 			return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 		evswitch->discarding = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 		if (!evswitch->show_on_off_events)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 			return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	if (evswitch->off && !evswitch->discarding) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		if (evswitch->off != evsel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		evswitch->discarding = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		if (!evswitch->show_on_off_events)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 			return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static int evswitch__fprintf_enoent(FILE *fp, const char *evtype, const char *evname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	int printed = fprintf(fp, "ERROR: switch-%s event not found (%s)\n", evtype, evname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return printed += fprintf(fp, "HINT:  use 'perf evlist' to see the available event names\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int evswitch__init(struct evswitch *evswitch, struct evlist *evlist, FILE *fp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	if (evswitch->on_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		evswitch->on = perf_evlist__find_evsel_by_str(evlist, evswitch->on_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		if (evswitch->on == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 			evswitch__fprintf_enoent(fp, "on", evswitch->on_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		evswitch->discarding = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (evswitch->off_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		evswitch->off = perf_evlist__find_evsel_by_str(evlist, evswitch->off_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		if (evswitch->off == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 			evswitch__fprintf_enoent(fp, "off", evswitch->off_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 			return -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }