Skip to content

Commit 81f5b78

Browse files
dcpleungjhedberg
authored andcommitted
xtensa: fix Python script formatting via ruff
Uses ruff to format the gen_* python scripts. Signed-off-by: Daniel Leung <[email protected]>
1 parent 36f7792 commit 81f5b78

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

.ruff-excludes.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,6 @@ exclude = [
11461146
"./arch/x86/gen_idt.py",
11471147
"./arch/x86/gen_mmu.py",
11481148
"./arch/x86/zefi/zefi.py",
1149-
"./arch/xtensa/core/gen_vectors.py",
1150-
"./arch/xtensa/core/gen_zsr.py",
11511149
"./boards/microchip/mec172xevb_assy6906/support/mec172x_remote_flasher.py",
11521150
"./doc/_scripts/gen_devicetree_rest.py",
11531151
"./doc/_scripts/redirects.py",

arch/xtensa/core/gen_vectors.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@
5555
debug_level = 0
5656

5757
# Translation for the core-isa.h vs. linker section naming conventions
58-
sect_names = { "DOUBLEEXC" : "DoubleException",
59-
"KERNEL" : "KernelException",
60-
"NMI" : "NMIException",
61-
"USER" : "UserException" }
58+
sect_names = {
59+
"DOUBLEEXC": "DoubleException",
60+
"KERNEL": "KernelException",
61+
"NMI": "NMIException",
62+
"USER": "UserException",
63+
}
6264

6365
offsets = {}
6466

@@ -112,9 +114,9 @@
112114
# The 1k alignment is experimental, the docs on the Relocatable Vector
113115
# Option doesn't specify an alignment at all, but writes to the
114116
# bottom bits don't take...
115-
print( " .z_xtensa_vectors : ALIGN(1024) {")
116-
print( " z_xtensa_vecbase = .;")
117-
print( " KEEP(*(.WindowVectors.text));")
117+
print(" .z_xtensa_vectors : ALIGN(1024) {")
118+
print(" z_xtensa_vecbase = .;")
119+
print(" KEEP(*(.WindowVectors.text));")
118120
for s in sects:
119121
print(f" KEEP(*(.{s}Vector.literal));")
120122
print(f" . = 0x{offsets[s]:x};")

arch/xtensa/core/gen_zsr.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,27 @@
1111
# -dM") core-isa.h file for the current architecture and assigns
1212
# registers to usages.
1313

14+
1415
def parse_args():
1516
parser = argparse.ArgumentParser(allow_abbrev=False)
1617

17-
parser.add_argument("--flush-reg", action="store_true",
18-
help="Enable scratch register ZSR_FLUSH for cache flushing")
19-
parser.add_argument("--mmu", action="store_true",
20-
help="Enable scratch registers for MMU usage")
21-
parser.add_argument("--syscall-scratch", action="store_true",
22-
help="Enable scratch registers for syscalls if needed")
23-
parser.add_argument("coreisa",
24-
help="Path to preprocessed core-isa.h")
25-
parser.add_argument("outfile",
26-
help="Output file")
18+
parser.add_argument(
19+
"--flush-reg",
20+
action="store_true",
21+
help="Enable scratch register ZSR_FLUSH for cache flushing",
22+
)
23+
parser.add_argument("--mmu", action="store_true", help="Enable scratch registers for MMU usage")
24+
parser.add_argument(
25+
"--syscall-scratch",
26+
action="store_true",
27+
help="Enable scratch registers for syscalls if needed",
28+
)
29+
parser.add_argument("coreisa", help="Path to preprocessed core-isa.h")
30+
parser.add_argument("outfile", help="Output file")
2731

2832
return parser.parse_args()
2933

34+
3035
args = parse_args()
3136

3237
NEEDED = ["A0SAVE", "CPU"]
@@ -40,17 +45,19 @@ def parse_args():
4045

4146
syms = {}
4247

48+
4349
def get(s):
4450
return syms.get(s, 0)
4551

52+
4653
with open(coreisa) as infile:
4754
for line in infile.readlines():
4855
m = re.match(r"^#define\s+([^ ]+)\s*(.*)", line.rstrip())
4956
if m:
5057
syms[m.group(1)] = m.group(2)
5158

5259
# Use MISC registers first if available, that's what they're for
53-
regs = [ f"MISC{n}" for n in range(0, int(get("XCHAL_NUM_MISC_REGS"))) ]
60+
regs = [f"MISC{n}" for n in range(0, int(get("XCHAL_NUM_MISC_REGS")))]
5461

5562
if args.syscall_scratch:
5663
# If there is no THREADPTR, we need to use syscall for

0 commit comments

Comments
 (0)