From 9fb3d7a7c551a543f0df48dd0ccbacd189f1cd33 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Jan 2022 14:14:20 -0700 Subject: [PATCH 1/7] RFC: tools: Add a camel-case conversion script This is only for posterity, since once the conversion is done, the script is of no use. Signed-off-by: Simon Glass --- scripts/style.py | 180 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 scripts/style.py diff --git a/scripts/style.py b/scripts/style.py new file mode 100755 index 00000000000..7b73b007dea --- /dev/null +++ b/scripts/style.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2021 Google LLC +# + +"""Changes the functions and class methods in a file to use snake case, updating +other tools which use them""" + +from argparse import ArgumentParser +import glob +import os +import re +import subprocess + +import camel_case + +# Exclude functions with these names +EXCLUDE_NAMES = set(['setUp', 'tearDown', 'setUpClass', 'tearDownClass']) + +# Find function definitions in a file +RE_FUNC = re.compile(r' *def (\w+)\(') + +# Where to find files that might call the file being converted +FILES_GLOB = 'tools/**/*.py' + +def collect_funcs(fname): + """Collect a list of functions in a file + + Args: + fname (str): Filename to read + + Returns: + tuple: + str: contents of file + list of str: List of function names + """ + with open(fname, encoding='utf-8') as inf: + data = inf.read() + funcs = RE_FUNC.findall(data) + return data, funcs + +def get_module_name(fname): + """Convert a filename to a module name + + Args: + fname (str): Filename to convert, e.g. 'tools/patman/command.py' + + Returns: + tuple: + str: Full module name, e.g. 'patman.command' + str: Leaf module name, e.g. 'command' + str: Program name, e.g. 'patman' + """ + parts = os.path.splitext(fname)[0].split('/')[1:] + module_name = '.'.join(parts) + return module_name, parts[-1], parts[0] + +def process_caller(data, conv, module_name, leaf): + """Process a file that might call another module + + This converts all the camel-case references in the provided file contents + with the corresponding snake-case references. + + Args: + data (str): Contents of file to convert + conv (dict): Identifies to convert + key: Current name in camel case, e.g. 'DoIt' + value: New name in snake case, e.g. 'do_it' + module_name: Name of module as referenced by the file, e.g. + 'patman.command' + leaf: Leaf module name, e.g. 'command' + + Returns: + str: New file contents, or None if it was not modified + """ + total = 0 + + # Update any simple functions calls into the module + for name, new_name in conv.items(): + newdata, count = re.subn(fr'{leaf}.{name}\(', + f'{leaf}.{new_name}(', data) + total += count + data = newdata + + # Deal with files that import symbols individually + imports = re.findall(fr'from {module_name} import (.*)\n', data) + for item in imports: + #print('item', item) + names = [n.strip() for n in item.split(',')] + new_names = [conv.get(n) or n for n in names] + new_line = f"from {module_name} import {', '.join(new_names)}\n" + data = re.sub(fr'from {module_name} import (.*)\n', new_line, data) + for name in names: + new_name = conv.get(name) + if new_name: + newdata = re.sub(fr'\b{name}\(', f'{new_name}(', data) + data = newdata + + # Deal with mocks like: + # unittest.mock.patch.object(module, 'Function', ... + for name, new_name in conv.items(): + newdata, count = re.subn(fr"{leaf}, '{name}'", + f"{leaf}, '{new_name}'", data) + total += count + data = newdata + + if total or imports: + return data + return None + +def process_file(srcfile, do_write, commit): + """Process a file to rename its camel-case functions + + This renames the class methods and functions in a file so that they use + snake case. Then it updates other modules that call those functions. + + Args: + srcfile (str): Filename to process + do_write (bool): True to write back to files, False to do a dry run + commit (bool): True to create a commit with the changes + """ + data, funcs = collect_funcs(srcfile) + module_name, leaf, prog = get_module_name(srcfile) + #print('module_name', module_name) + #print(len(funcs)) + #print(funcs[0]) + conv = {} + for name in funcs: + if name not in EXCLUDE_NAMES: + conv[name] = camel_case.to_snake(name) + + # Convert name to new_name in the file + for name, new_name in conv.items(): + #print(name, new_name) + # Don't match if it is preceded by a '.', since that indicates that + # it is calling this same function name but in a different module + newdata = re.sub(fr'(? Date: Sat, 22 Oct 2022 23:22:01 +0200 Subject: [PATCH 2/7] sandbox: Correctly define BITS_PER_LONG SANDBOX_BITS_PER_LONG is the number of bits in long on the sandbox platform. Signed-off-by: Michal Suchanek --- arch/sandbox/include/asm/types.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h index c1a5d2af828..5f4b649ee38 100644 --- a/arch/sandbox/include/asm/types.h +++ b/arch/sandbox/include/asm/types.h @@ -18,11 +18,7 @@ typedef unsigned short umode_t; /* * Number of bits in a C 'long' on this architecture. */ -#ifdef CONFIG_PHYS_64BIT -#define BITS_PER_LONG 64 -#else /* CONFIG_PHYS_64BIT */ -#define BITS_PER_LONG 32 -#endif /* CONFIG_PHYS_64BIT */ +#define BITS_PER_LONG CONFIG_SANDBOX_BITS_PER_LONG #ifdef CONFIG_PHYS_64BIT typedef unsigned long long dma_addr_t; From 1de76a4535a2d617adeb05070d265e2826af3ad6 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Tue, 17 Jan 2023 15:08:15 +0100 Subject: [PATCH 3/7] arm64: a37xx: pinctrl: probe after binding Currently, pinctrl drivers are getting probed during post-bind, however that is being reverted, and on A37XX pinctrl driver is the one that registers the GPIO driver during the probe. So, if the pinctrl driver doesn't get probed GPIO-s won't get registered and thus they cannot be used. This is a problem on the Methode eDPU as it just uses SB pins as GPIO-s and without them being registered networking won't work as it only has one SFP slot and the TX disable GPIO is on the SB controller. So, lets just add a flag only to A37XX driver to probe after binding in order for the GPIO driver to always get registered. Signed-off-by: Robert Marko Reviewed-by: Simon Glass --- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 25fbe39abd1..1be6252227d 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -745,6 +745,19 @@ static int armada_37xx_pinctrl_probe(struct udevice *dev) return 0; } +static int armada_37xx_pinctrl_bind(struct udevice *dev) +{ + /* + * Make sure that the pinctrl driver gets probed after binding + * as on A37XX the pinctrl driver is the one that is also + * registering the GPIO one during probe, so if its not probed + * GPIO-s are not registered as well. + */ + dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); + + return 0; +} + static const struct udevice_id armada_37xx_pinctrl_of_match[] = { { .compatible = "marvell,armada3710-sb-pinctrl", @@ -762,6 +775,7 @@ U_BOOT_DRIVER(armada_37xx_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = of_match_ptr(armada_37xx_pinctrl_of_match), .probe = armada_37xx_pinctrl_probe, + .bind = armada_37xx_pinctrl_bind, .priv_auto = sizeof(struct armada_37xx_pinctrl), .ops = &armada_37xx_pinctrl_ops, }; From b59db00f8a6b4bed929c954e15df5b85ae07e747 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 18 Feb 2023 09:33:51 +0100 Subject: [PATCH 4/7] sandbox: allow building sandbox_spl with CONFIG_DEBUG Building sandbox_spl with CONFIG_DEBUG leads to errors due to missing symbols: /usr/bin/ld: common/spl/spl_fit.o: in function `spl_fit_upload_fpga': common/spl/spl_fit.c:595: undefined reference to `fpga_load' /usr/bin/ld: test/test-main.o: in function `dm_test_post_run': test/test-main.c:124: undefined reference to `crc8' /usr/bin/ld: test/test-main.o: in function `dm_test_pre_run': test/test-main.c:95: undefined reference to `crc8' collect2: error: ld returned 1 exit status This is due to -Og not eliminating unused functions. Add FPGA and CRC8 support to the defconfig. Sandbox tests for SPL_FPGA and CRC8 should be created. So enabling these setting is advised anyway. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- configs/sandbox_spl_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 4e0021a76fa..851c3b687a6 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -33,6 +33,7 @@ CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_HANDOFF=y CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_FPGA=y CONFIG_SPL_I2C=y CONFIG_SPL_RTC=y CONFIG_CMD_CPU=y @@ -126,6 +127,8 @@ CONFIG_DM_DEMO=y CONFIG_DM_DEMO_SIMPLE=y CONFIG_DM_DEMO_SHAPE=y CONFIG_SPL_FIRMWARE=y +CONFIG_DM_FPGA=y +CONFIG_SANDBOX_FPGA=y CONFIG_GPIO_HOG=y CONFIG_QCOM_PMIC_GPIO=y CONFIG_SANDBOX_GPIO=y @@ -237,6 +240,7 @@ CONFIG_FS_CRAMFS=y CONFIG_CMD_DHRYSTONE=y CONFIG_RSA_VERIFY_WITH_PKEY=y CONFIG_TPM=y +CONFIG_SPL_CRC8=y CONFIG_LZ4=y CONFIG_ZSTD=y CONFIG_ERRNO_STR=y From eab09fbe6401e63bf53274042f367303541382c1 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 18 Feb 2023 10:38:11 +0100 Subject: [PATCH 5/7] MAINTAINERS: assign sandbox drivers to SANDBOX Drivers should have a maintainer. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 41c9f265f81..91d40ea4b6e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1336,6 +1336,7 @@ M: Simon Glass S: Maintained F: arch/sandbox/ F: doc/arch/sandbox.rst +F: drivers/*/*sandbox*.c F: include/dt-bindings/*/sandbox*.h SEAMA From d22c69524966b6d65d98476acb7fda827207e10d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 22 Feb 2023 01:39:18 +0100 Subject: [PATCH 6/7] sandbox: fix building with CONFIG_SPL_TIMER=y Building sandbox_defconfig with CONFIG_SPL_TIMER=y results in an error include/dm/platdata.h:63:33: error: static assertion failed: "Cannot use U_BOOT_DRVINFO with of-platdata. Please use devicetree instead" Add a missing condition in the sandbox driver. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- drivers/timer/sandbox_timer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c index c846bfb9f12..1da7e0c3a76 100644 --- a/drivers/timer/sandbox_timer.c +++ b/drivers/timer/sandbox_timer.c @@ -66,6 +66,8 @@ U_BOOT_DRIVER(sandbox_timer) = { }; /* This is here in case we don't have a device tree */ +#if !CONFIG_IS_ENABLED(OF_PLATDATA) U_BOOT_DRVINFO(sandbox_timer_non_fdt) = { .name = "sandbox_timer", }; +#endif From abe2a16aa52ea21acb435e9f1d9c85f5ac4e7794 Mon Sep 17 00:00:00 2001 From: Ralph Siemsen Date: Wed, 22 Feb 2023 15:56:59 -0500 Subject: [PATCH 7/7] tools: binman: minor formatting fix in docs This should fix a rendering oddity when viewing the docs online at https://u-boot.readthedocs.io/en/latest/develop/package/binman.html Signed-off-by: Ralph Siemsen Reviewed-by: Simon Glass --- tools/binman/binman.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 03a99a19bc6..0921e318785 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -393,9 +393,9 @@ system-library directory, replace the last line with: Running binman -------------- -Type:: +Type: -.. code-block: bash +.. code-block:: bash make NO_PYTHON=1 PREFIX=/ install binman build -b