Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
2
Indexable
Never

def parse_dts():
	from subprocess import run
	return run(['grep', '-r', "compatible = "], capture_output=True, text=True, cwd="arch/arm64/boot/dts/qcom").stdout
	

def parse_drivers(current_comp):
	from subprocess import run
	return run(['grep', '-r', current_comp], capture_output=True, text=True, cwd="drivers").stdout

def uni_parse(current_driver_name, cwd):
	from subprocess import run
	return run(['grep', '-r', current_driver_name], capture_output=True, text=True, cwd=('drivers/' + cwd)).stdout


def main():
	compatibles_raw = parse_dts().split()
	d = dict()
	dts_name = 'dummy'
	cur_comps = {'dummy'}
	for i in range(0, len(compatibles_raw)):
		if compatibles_raw[i].find('.dts') != -1:
			if dts_name not in d:
				d[dts_name] = set()
			d[dts_name] |= cur_comps
			dts_name = compatibles_raw[i]
			cur_comps = set()
		if compatibles_raw[i].find('"') != -1:
			cur_comps.add(compatibles_raw[i])
	if dts_name not in d:
			d[dts_name] = set()
	d[dts_name] |= cur_comps
	drivers = set()
	for i in d['sdm845.dtsi:']:
		tmp = parse_drivers(i[:-1])
		if tmp != '':
			tmp = tmp.split()[0][:-2]
			tmp = tmp[:]
			drivers.add(tmp)
	for i in drivers:
		last_slash = max(i.rfind(i1) for i1 in "/")
		config_name = uni_parse(i[last_slash + 1:], i[:last_slash])
		config_name = config_name[config_name.find('(') + 1:config_name.find(')')]
		if (config_name.find('CONFIG_')) == 0:
			print(config_name)



main()