Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/make_fit: Move dtb processing into a function

Since build_fit() is getting quite long, move the dtb processing into a
separate function.

Change the double quotes in the write() call to single, to match the
rest of the script.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://patch.msgid.link/20260106162738.2605574-4-sjg@chromium.org
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

authored by

Simon Glass and committed by
Nathan Chancellor
873c2836 26428e7d

+44 -23
+44 -23
scripts/make_fit.py
··· 277 277 278 278 return (model, compat, files) 279 279 280 + 281 + def _process_dtbs(args, fsw, entries, fdts): 282 + """Process all DTB files and add them to the FIT 283 + 284 + Args: 285 + args: Program arguments 286 + fsw: FIT writer object 287 + entries: List to append entries to 288 + fdts: Dictionary of processed DTBs 289 + 290 + Returns: 291 + tuple: 292 + Number of files processed 293 + Total size of files processed 294 + """ 295 + seq = 0 296 + size = 0 297 + for fname in args.dtbs: 298 + # Ignore non-DTB (*.dtb) files 299 + if os.path.splitext(fname)[1] != '.dtb': 300 + continue 301 + 302 + try: 303 + (model, compat, files) = process_dtb(fname, args) 304 + except Exception as e: 305 + sys.stderr.write(f'Error processing {fname}:\n') 306 + raise e 307 + 308 + for fn in files: 309 + if fn not in fdts: 310 + seq += 1 311 + size += os.path.getsize(fn) 312 + output_dtb(fsw, seq, fn, args.arch, args.compress) 313 + fdts[fn] = seq 314 + 315 + files_seq = [fdts[fn] for fn in files] 316 + entries.append([model, compat, files_seq]) 317 + 318 + return seq, size 319 + 320 + 280 321 def build_fit(args): 281 322 """Build the FIT from the provided files and arguments 282 323 ··· 330 289 int: Number of configurations generated 331 290 size: Total uncompressed size of data 332 291 """ 333 - seq = 0 334 292 size = 0 335 293 fsw = libfdt.FdtSw() 336 294 setup_fit(fsw, args.name) ··· 350 310 size += len(data) 351 311 write_ramdisk(fsw, data, args) 352 312 353 - for fname in args.dtbs: 354 - # Ignore non-DTB (*.dtb) files 355 - if os.path.splitext(fname)[1] != '.dtb': 356 - continue 357 - 358 - try: 359 - (model, compat, files) = process_dtb(fname, args) 360 - except Exception as e: 361 - sys.stderr.write(f"Error processing {fname}:\n") 362 - raise e 363 - 364 - for fn in files: 365 - if fn not in fdts: 366 - seq += 1 367 - size += os.path.getsize(fn) 368 - output_dtb(fsw, seq, fn, args.arch, args.compress) 369 - fdts[fn] = seq 370 - 371 - files_seq = [fdts[fn] for fn in files] 372 - 373 - entries.append([model, compat, files_seq]) 313 + count, fdt_size = _process_dtbs(args, fsw, entries, fdts) 314 + size += fdt_size 374 315 375 316 finish_fit(fsw, entries, bool(args.ramdisk)) 376 317 377 318 # Include the kernel itself in the returned file count 378 319 fdt = fsw.as_fdt() 379 320 fdt.pack() 380 - return fdt.as_bytearray(), seq + 1 + bool(args.ramdisk), size 321 + return fdt.as_bytearray(), count + 1 + bool(args.ramdisk), size 381 322 382 323 383 324 def run_make_fit():