From 2e9a0cdfa8456636392f24dcc47e3270bd4818b7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:48 -0600 Subject: patman: Use test_util to show test results This handles skipped tests correctly, so use it instead of the existing code. Signed-off-by: Simon Glass --- tools/patman/main.py | 8 ++------ tools/patman/test_util.py | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index 28a9a26087..03668d1bb8 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -25,6 +25,7 @@ from patman import patchstream from patman import project from patman import settings from patman import terminal +from patman import test_util from patman import test_checkpatch @@ -101,12 +102,7 @@ elif options.test: suite = doctest.DocTestSuite(module) suite.run(result) - # TODO: Surely we can just 'print' result? - print(result) - for test, err in result.errors: - print(err) - for test, err in result.failures: - print(err) + sys.exit(test_util.ReportResult('patman', None, result)) # Called from git with a patch filename as argument # Printout a list of additional CC recipients for this patch diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index aac58fb72f..0827488f33 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -123,12 +123,12 @@ def ReportResult(toolname:str, test_name: str, result: unittest.TestResult): for test, err in result.failures: print(err, result.failures) if result.skipped: - print('%d binman test%s SKIPPED:' % - (len(result.skipped), 's' if len(result.skipped) > 1 else '')) + print('%d %s test%s SKIPPED:' % (len(result.skipped), toolname, + 's' if len(result.skipped) > 1 else '')) for skip_info in result.skipped: print('%s: %s' % (skip_info[0], skip_info[1])) if result.errors or result.failures: - print('binman tests FAILED') + print('%s tests FAILED' % toolname) return 1 return 0 -- cgit From f36537597583a75f357b3927b1e5d816822c90db Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:49 -0600 Subject: patman: Move main code out to a control module To make testing easier, move the code out from main into a separate 'control' module and split it into four parts: setup, preparing patches, checking patches and emailing patches. Add comments and fix a few code-style issues while we are here. Signed-off-by: Simon Glass --- tools/patman/checkpatch.py | 6 ++ tools/patman/control.py | 170 +++++++++++++++++++++++++++++++++++++++++++++ tools/patman/gitutil.py | 4 +- tools/patman/main.py | 57 +-------------- tools/patman/series.py | 2 +- 5 files changed, 182 insertions(+), 57 deletions(-) create mode 100644 tools/patman/control.py diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 07c3e2739a..263bac3fc9 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -41,6 +41,12 @@ def FindCheckPatch(): def CheckPatch(fname, verbose=False, show_types=False): """Run checkpatch.pl on a file. + Args: + fname: Filename to check + verbose: True to print out every line of the checkpatch output as it is + parsed + show_types: Tell checkpatch to show the type (number) of each message + Returns: namedtuple containing: ok: False=failure, True=ok diff --git a/tools/patman/control.py b/tools/patman/control.py new file mode 100644 index 0000000000..a896c924b5 --- /dev/null +++ b/tools/patman/control.py @@ -0,0 +1,170 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2020 Google LLC +# +"""Handles the main control logic of patman + +This module provides various functions called by the main program to implement +the features of patman. +""" + +import os +import sys + +from patman import checkpatch +from patman import gitutil +from patman import patchstream +from patman import terminal + +def setup(): + """Do required setup before doing anything""" + gitutil.Setup() + +def prepare_patches(col, count, start, ignore_binary): + """Figure out what patches to generate, then generate them + + The patch files are written to the current directory, e.g. 0001_xxx.patch + 0002_yyy.patch + + Args: + col (terminal.Color): Colour output object + count (int): Number of patches to produce, or -1 to produce patches for + the current branch back to the upstream commit + start (int): Start partch to use (0=first / top of branch) + ignore_binary (bool): Don't generate patches for binary files + + Returns: + Tuple: + Series object for this series (set of patches) + Filename of the cover letter as a string (None if none) + patch_files: List of patch filenames, each a string, e.g. + ['0001_xxx.patch', '0002_yyy.patch'] + """ + if count == -1: + # Work out how many patches to send if we can + count = (gitutil.CountCommitsToBranch() - start) + + if not count: + sys.exit(col.Color(col.RED, + 'No commits found to process - please use -c flag')) + + # Read the metadata from the commits + to_do = count + series = patchstream.GetMetaData(start, to_do) + cover_fname, patch_files = gitutil.CreatePatches( + start, to_do, ignore_binary, series) + + # Fix up the patch files to our liking, and insert the cover letter + patchstream.FixPatches(series, patch_files) + if cover_fname and series.get('cover'): + patchstream.InsertCoverLetter(cover_fname, series, to_do) + return series, cover_fname, patch_files + +def check_patches(series, patch_files, run_checkpatch, verbose): + """Run some checks on a set of patches + + This santiy-checks the patman tags like Series-version and runs the patches + through checkpatch + + Args: + series (Series): Series object for this series (set of patches) + patch_files (list): List of patch filenames, each a string, e.g. + ['0001_xxx.patch', '0002_yyy.patch'] + run_checkpatch (bool): True to run checkpatch.pl + verbose (bool): True to print out every line of the checkpatch output as + it is parsed + + Returns: + bool: True if the patches had no errors, False if they did + """ + # Do a few checks on the series + series.DoChecks() + + # Check the patches, and run them through 'git am' just to be sure + if run_checkpatch: + ok = checkpatch.CheckPatches(verbose, patch_files) + else: + ok = True + return ok + + +def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go, + ignore_bad_tags, add_maintainers, limit, dry_run, in_reply_to, + thread, smtp_server): + """Email patches to the recipients + + This emails out the patches and cover letter using 'git send-email'. Each + patch is copied to recipients identified by the patch tag and output from + the get_maintainer.pl script. The cover letter is copied to all recipients + of any patch. + + To make this work a CC file is created holding the recipients for each patch + and the cover letter. See the main program 'cc_cmd' for this logic. + + Args: + col (terminal.Color): Colour output object + series (Series): Series object for this series (set of patches) + cover_fname (str): Filename of the cover letter as a string (None if + none) + patch_files (list): List of patch filenames, each a string, e.g. + ['0001_xxx.patch', '0002_yyy.patch'] + process_tags (bool): True to process subject tags in each patch, e.g. + for 'dm: spi: Add SPI support' this would be 'dm' and 'spi'. The + tags are looked up in the configured sendemail.aliasesfile and also + in ~/.patman (see README) + its_a_go (bool): True if we are going to actually send the patches, + False if the patches have errors and will not be sent unless + @ignore_errors + ignore_bad_tags (bool): True to just print a warning for unknown tags, + False to halt with an error + add_maintainers (bool): Run the get_maintainer.pl script for each patch + limit (int): Limit on the number of people that can be cc'd on a single + patch or the cover letter (None if no limit) + dry_run (bool): Don't actually email the patches, just print out what + would be sent + in_reply_to (str): If not None we'll pass this to git as --in-reply-to. + Should be a message ID that this is in reply to. + thread (bool): True to add --thread to git send-email (make all patches + reply to cover-letter or first patch in series) + smtp_server (str): SMTP server to use to send patches (None for default) + """ + cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags, + add_maintainers, limit) + + # Email the patches out (giving the user time to check / cancel) + cmd = '' + if its_a_go: + cmd = gitutil.EmailPatches( + series, cover_fname, patch_files, dry_run, not ignore_bad_tags, + cc_file, in_reply_to=in_reply_to, thread=thread, + smtp_server=smtp_server) + else: + print(col.Color(col.RED, "Not sending emails due to errors/warnings")) + + # For a dry run, just show our actions as a sanity check + if dry_run: + series.ShowActions(patch_files, cmd, process_tags) + if not its_a_go: + print(col.Color(col.RED, "Email would not be sent")) + + os.remove(cc_file) + +def send(options): + """Create, check and send patches by email + + Args: + options (optparse.Values): Arguments to patman + """ + setup() + col = terminal.Color() + series, cover_fname, patch_files = prepare_patches( + col, options.count, options.start, options.ignore_binary) + ok = check_patches(series, patch_files, options.check_patch, + options.verbose) + its_a_go = ok or options.ignore_errors + if its_a_go: + email_patches( + col, series, cover_fname, patch_files, options.process_tags, + its_a_go, options.ignore_bad_tags, options.add_maintainers, + options.limit, options.dry_run, options.in_reply_to, options.thread, + options.smtp_server) diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 5189840eab..29444bf8e9 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -261,8 +261,10 @@ def CreatePatches(start, count, ignore_binary, series): Args: start: Commit to start from: 0=HEAD, 1=next one, etc. count: number of commits to include + ignore_binary: Don't generate patches for binary files + series: Series object for this series (set of patches) Return: - Filename of cover letter + Filename of cover letter (None if none) List of filenames of patch files """ if series.get('version'): diff --git a/tools/patman/main.py b/tools/patman/main.py index 03668d1bb8..2432d31871 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -18,10 +18,9 @@ if __name__ == "__main__": sys.path.append(os.path.join(our_path, '..')) # Our modules -from patman import checkpatch from patman import command +from patman import control from patman import gitutil -from patman import patchstream from patman import project from patman import settings from patman import terminal @@ -128,56 +127,4 @@ elif options.full_help: # Process commits, produce patches files, check them, email them else: - gitutil.Setup() - - if options.count == -1: - # Work out how many patches to send if we can - options.count = gitutil.CountCommitsToBranch() - options.start - - col = terminal.Color() - if not options.count: - str = 'No commits found to process - please use -c flag' - sys.exit(col.Color(col.RED, str)) - - # Read the metadata from the commits - if options.count: - series = patchstream.GetMetaData(options.start, options.count) - cover_fname, args = gitutil.CreatePatches(options.start, options.count, - options.ignore_binary, series) - - # Fix up the patch files to our liking, and insert the cover letter - patchstream.FixPatches(series, args) - if cover_fname and series.get('cover'): - patchstream.InsertCoverLetter(cover_fname, series, options.count) - - # Do a few checks on the series - series.DoChecks() - - # Check the patches, and run them through 'git am' just to be sure - if options.check_patch: - ok = checkpatch.CheckPatches(options.verbose, args) - else: - ok = True - - cc_file = series.MakeCcFile(options.process_tags, cover_fname, - not options.ignore_bad_tags, - options.add_maintainers, options.limit) - - # Email the patches out (giving the user time to check / cancel) - cmd = '' - its_a_go = ok or options.ignore_errors - if its_a_go: - cmd = gitutil.EmailPatches(series, cover_fname, args, - options.dry_run, not options.ignore_bad_tags, cc_file, - in_reply_to=options.in_reply_to, thread=options.thread, - smtp_server=options.smtp_server) - else: - print(col.Color(col.RED, "Not sending emails due to errors/warnings")) - - # For a dry run, just show our actions as a sanity check - if options.dry_run: - series.ShowActions(args, cmd, options.process_tags) - if not its_a_go: - print(col.Color(col.RED, "Email would not be sent")) - - os.remove(cc_file) + control.send(options) diff --git a/tools/patman/series.py b/tools/patman/series.py index b7eef37d03..9f885c8987 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -244,7 +244,7 @@ class Series(dict): add_maintainers: Either: True/False to call the get_maintainers to CC maintainers List of maintainers to include (for testing) - limit: Limit the length of the Cc list + limit: Limit the length of the Cc list (None if no limit) Return: Filename of temp file created """ -- cgit From 5d597584dbf027ce3e87d06001f5cbc2bde26eb2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:50 -0600 Subject: patman: Add a test that uses gitpython It is convenient to use gitpython to create a real git repo for testing patman's operation. Add a test for this. So far it just checks that patman produces the right number of patches for a branch. Signed-off-by: Simon Glass --- tools/patman/func_test.py | 151 +++++++++++++++++++++++++++++++++++++++++++++- tools/patman/tools.py | 4 +- 2 files changed, 152 insertions(+), 3 deletions(-) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index dc30078cce..211952154a 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -14,15 +14,23 @@ import unittest from io import StringIO +from patman import control from patman import gitutil from patman import patchstream from patman import settings +from patman import terminal from patman import tools +from patman.test_util import capture_sys_output + +try: + import pygit2 + HAVE_PYGIT2= True +except ModuleNotFoundError: + HAVE_PYGIT2 = False @contextlib.contextmanager def capture(): - import sys oldout,olderr = sys.stdout, sys.stderr try: out=[StringIO(), StringIO()] @@ -37,6 +45,8 @@ def capture(): class TestFunctional(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp(prefix='patman.') + self.gitdir = os.path.join(self.tmpdir, 'git') + self.repo = None def tearDown(self): shutil.rmtree(self.tmpdir) @@ -286,3 +296,142 @@ Changes in v2: if expected: expected = expected.splitlines() self.assertEqual(expected, lines[start:(start+len(expected))]) + + def make_commit_with_file(self, subject, body, fname, text): + """Create a file and add it to the git repo with a new commit + + Args: + subject (str): Subject for the commit + body (str): Body text of the commit + fname (str): Filename of file to create + text (str): Text to put into the file + """ + path = os.path.join(self.gitdir, fname) + tools.WriteFile(path, text, binary=False) + index = self.repo.index + index.add(fname) + author = pygit2.Signature('Test user', 'test@email.com') + committer = author + tree = index.write_tree() + message = subject + '\n' + body + self.repo.create_commit('HEAD', author, committer, message, tree, + [self.repo.head.target]) + + def make_git_tree(self): + """Make a simple git tree suitable for testing + + It has three branches: + 'base' has two commits: PCI, main + 'first' has base as upstream and two more commits: I2C, SPI + 'second' has base as upstream and three more: video, serial, bootm + + Returns: + pygit2 repository + """ + repo = pygit2.init_repository(self.gitdir) + self.repo = repo + new_tree = repo.TreeBuilder().write() + + author = pygit2.Signature('Test user', 'test@email.com') + committer = author + commit = repo.create_commit('HEAD', author, committer, + 'Created master', new_tree, []) + + self.make_commit_with_file('Initial commit', ''' +Add a README + +''', 'README', '''This is the README file +describing this project +in very little detail''') + + self.make_commit_with_file('pci: PCI implementation', ''' +Here is a basic PCI implementation + +''', 'pci.c', '''This is a file +it has some contents +and some more things''') + self.make_commit_with_file('main: Main program', ''' +Hello here is the second commit. +''', 'main.c', '''This is the main file +there is very little here +but we can always add more later +if we want to + +Series-to: u-boot +Series-cc: Barry Crump +''') + base_target = repo.revparse_single('HEAD') + self.make_commit_with_file('i2c: I2C things', ''' +This has some stuff to do with I2C +''', 'i2c.c', '''And this is the file contents +with some I2C-related things in it''') + self.make_commit_with_file('spi: SPI fixes', ''' +SPI needs some fixes +and here they are +''', 'spi.c', '''Some fixes for SPI in this +file to make SPI work +better than before''') + first_target = repo.revparse_single('HEAD') + + target = repo.revparse_single('HEAD~2') + repo.reset(target.oid, pygit2.GIT_CHECKOUT_FORCE) + self.make_commit_with_file('video: Some video improvements', ''' +Fix up the video so that +it looks more purple. Purple is +a very nice colour. +''', 'video.c', '''More purple here +Purple and purple +Even more purple +Could not be any more purple''') + self.make_commit_with_file('serial: Add a serial driver', ''' +Here is the serial driver +for my chip. + +Cover-letter: +Series for my board +This series implements support +for my glorious board. +END +''', 'serial.c', '''The code for the +serial driver is here''') + self.make_commit_with_file('bootm: Make it boot', ''' +This makes my board boot +with a fix to the bootm +command +''', 'bootm.c', '''Fix up the bootm +command to make the code as +complicated as possible''') + second_target = repo.revparse_single('HEAD') + + repo.branches.local.create('first', first_target) + repo.config.set_multivar('branch.first.remote', '', '.') + repo.config.set_multivar('branch.first.merge', '', 'refs/heads/base') + + repo.branches.local.create('second', second_target) + repo.config.set_multivar('branch.second.remote', '', '.') + repo.config.set_multivar('branch.second.merge', '', 'refs/heads/base') + + repo.branches.local.create('base', base_target) + return repo + + @unittest.skipIf(not HAVE_PYGIT2, 'Missing python3-pygit2') + def testBranch(self): + """Test creating patches from a branch""" + repo = self.make_git_tree() + target = repo.lookup_reference('refs/heads/first') + self.repo.checkout(target, strategy=pygit2.GIT_CHECKOUT_FORCE) + control.setup() + try: + orig_dir = os.getcwd() + os.chdir(self.gitdir) + + # Check that it can detect the current branch + self.assertEqual(2, gitutil.CountCommitsToBranch()) + col = terminal.Color() + with capture_sys_output() as _: + _, cover_fname, patch_files = control.prepare_patches( + col, count=-1, start=0, ignore_binary=False) + self.assertIsNone(cover_fname) + self.assertEqual(2, len(patch_files)) + finally: + os.chdir(orig_dir) diff --git a/tools/patman/tools.py b/tools/patman/tools.py index b50370dfe8..f402b9aab8 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -270,7 +270,7 @@ def ReadFile(fname, binary=True): #(fname, len(data), len(data))) return data -def WriteFile(fname, data): +def WriteFile(fname, data, binary=True): """Write data into a file. Args: @@ -279,7 +279,7 @@ def WriteFile(fname, data): """ #self._out.Info("Write file '%s' size %d (%#0x)" % #(fname, len(data), len(data))) - with open(Filename(fname), 'wb') as fd: + with open(Filename(fname), binary and 'wb' or 'w') as fd: fd.write(data) def GetBytes(byte, size): -- cgit From e9799e0890339dcf9f816f7b904147f791fca011 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:51 -0600 Subject: patman: Allow creating patches for another branch Add a -b option to allow patches to be created from a branch other than the current one. Signed-off-by: Simon Glass --- tools/patman/control.py | 13 ++++++++----- tools/patman/func_test.py | 13 +++++++++++-- tools/patman/gitutil.py | 19 ++++++++++++++----- tools/patman/main.py | 2 ++ tools/patman/patchstream.py | 8 +++++--- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index a896c924b5..b48eac41fd 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -20,7 +20,7 @@ def setup(): """Do required setup before doing anything""" gitutil.Setup() -def prepare_patches(col, count, start, ignore_binary): +def prepare_patches(col, branch, count, start, ignore_binary): """Figure out what patches to generate, then generate them The patch files are written to the current directory, e.g. 0001_xxx.patch @@ -28,6 +28,7 @@ def prepare_patches(col, count, start, ignore_binary): Args: col (terminal.Color): Colour output object + branch (str): Branch to create patches from (None = current) count (int): Number of patches to produce, or -1 to produce patches for the current branch back to the upstream commit start (int): Start partch to use (0=first / top of branch) @@ -42,7 +43,7 @@ def prepare_patches(col, count, start, ignore_binary): """ if count == -1: # Work out how many patches to send if we can - count = (gitutil.CountCommitsToBranch() - start) + count = (gitutil.CountCommitsToBranch(branch) - start) if not count: sys.exit(col.Color(col.RED, @@ -50,9 +51,9 @@ def prepare_patches(col, count, start, ignore_binary): # Read the metadata from the commits to_do = count - series = patchstream.GetMetaData(start, to_do) + series = patchstream.GetMetaData(branch, start, to_do) cover_fname, patch_files = gitutil.CreatePatches( - start, to_do, ignore_binary, series) + branch, start, to_do, ignore_binary, series) # Fix up the patch files to our liking, and insert the cover letter patchstream.FixPatches(series, patch_files) @@ -158,9 +159,11 @@ def send(options): setup() col = terminal.Color() series, cover_fname, patch_files = prepare_patches( - col, options.count, options.start, options.ignore_binary) + col, options.branch, options.count, options.start, + options.ignore_binary) ok = check_patches(series, patch_files, options.check_patch, options.verbose) + its_a_go = ok or options.ignore_errors if its_a_go: email_patches( diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 211952154a..588be73ef4 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -426,12 +426,21 @@ complicated as possible''') os.chdir(self.gitdir) # Check that it can detect the current branch - self.assertEqual(2, gitutil.CountCommitsToBranch()) + self.assertEqual(2, gitutil.CountCommitsToBranch(None)) col = terminal.Color() with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( - col, count=-1, start=0, ignore_binary=False) + col, branch=None, count=-1, start=0, ignore_binary=False) self.assertIsNone(cover_fname) self.assertEqual(2, len(patch_files)) + + # Check that it can detect a different branch + self.assertEqual(3, gitutil.CountCommitsToBranch('second')) + with capture_sys_output() as _: + _, cover_fname, patch_files = control.prepare_patches( + col, branch='second', count=-1, start=0, + ignore_binary=False) + self.assertIsNotNone(cover_fname) + self.assertEqual(3, len(patch_files)) finally: os.chdir(orig_dir) diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 29444bf8e9..b683481a57 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -49,17 +49,24 @@ def LogCmd(commit_range, git_dir=None, oneline=False, reverse=False, cmd.append('--') return cmd -def CountCommitsToBranch(): +def CountCommitsToBranch(branch): """Returns number of commits between HEAD and the tracking branch. This looks back to the tracking branch and works out the number of commits since then. + Args: + branch: Branch to count from (None for current branch) + Return: Number of patches that exist on top of the branch """ - pipe = [LogCmd('@{upstream}..', oneline=True), - ['wc', '-l']] + if branch: + us, msg = GetUpstream('.git', branch) + rev_range = '%s..%s' % (us, branch) + else: + rev_range = '@{upstream}..' + pipe = [LogCmd(rev_range, oneline=True), ['wc', '-l']] stdout = command.RunPipe(pipe, capture=True, oneline=True).stdout patch_count = int(stdout) return patch_count @@ -252,13 +259,14 @@ def Fetch(git_dir=None, work_tree=None): if result.return_code != 0: raise OSError('git fetch: %s' % result.stderr) -def CreatePatches(start, count, ignore_binary, series): +def CreatePatches(branch, start, count, ignore_binary, series): """Create a series of patches from the top of the current branch. The patch files are written to the current directory using git format-patch. Args: + branch: Branch to create patches from (None for current branch) start: Commit to start from: 0=HEAD, 1=next one, etc. count: number of commits to include ignore_binary: Don't generate patches for binary files @@ -277,7 +285,8 @@ def CreatePatches(start, count, ignore_binary, series): prefix = series.GetPatchPrefix() if prefix: cmd += ['--subject-prefix=%s' % prefix] - cmd += ['HEAD~%d..HEAD~%d' % (start + count, start)] + brname = branch or 'HEAD' + cmd += ['%s~%d..%s~%d' % (brname, start + count, brname, start)] stdout = command.RunList(cmd) files = stdout.splitlines() diff --git a/tools/patman/main.py b/tools/patman/main.py index 2432d31871..066754196e 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -31,6 +31,8 @@ from patman import test_checkpatch parser = OptionParser() parser.add_option('-H', '--full-help', action='store_true', dest='full_help', default=False, help='Display the README file') +parser.add_option('-b', '--branch', type='str', + help="Branch to process (by default, the current branch)") parser.add_option('-c', '--count', dest='count', type='int', default=-1, help='Automatically create patches from top n commits') parser.add_option('-i', '--ignore-errors', action='store_true', diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 4fe465e9ab..2ea8ebcc3f 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -512,17 +512,19 @@ def GetMetaDataForList(commit_range, git_dir=None, count=None, ps.Finalize() return series -def GetMetaData(start, count): +def GetMetaData(branch, start, count): """Reads out patch series metadata from the commits This does a 'git log' on the relevant commits and pulls out the tags we are interested in. Args: - start: Commit to start from: 0=HEAD, 1=next one, etc. + branch: Branch to use (None for current branch) + start: Commit to start from: 0=branch HEAD, 1=next one, etc. count: Number of commits to list """ - return GetMetaDataForList('HEAD~%d' % start, None, count) + return GetMetaDataForList('%s~%d' % (branch if branch else 'HEAD', start), + None, count) def GetMetaDataForTest(text): """Process metadata from a file containing a git log. Used for tests -- cgit From d9dc99e327378a4abbf1bef059eef4e4402746c3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:52 -0600 Subject: patman: Allow skipping patches at the end The -s option allows skipping patches at the top of the branch. Sometimes there are commits at the bottom that need to be skipped. At present it is necessary to count the number of commits and then use -c to tell patman how many to process. Add a -e option to easily skip a number of commits at the bottom of the branch. Signed-off-by: Simon Glass --- tools/patman/control.py | 8 +++++--- tools/patman/func_test.py | 13 +++++++++++-- tools/patman/main.py | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index b48eac41fd..b481ff6b27 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -20,7 +20,7 @@ def setup(): """Do required setup before doing anything""" gitutil.Setup() -def prepare_patches(col, branch, count, start, ignore_binary): +def prepare_patches(col, branch, count, start, end, ignore_binary): """Figure out what patches to generate, then generate them The patch files are written to the current directory, e.g. 0001_xxx.patch @@ -32,6 +32,8 @@ def prepare_patches(col, branch, count, start, ignore_binary): count (int): Number of patches to produce, or -1 to produce patches for the current branch back to the upstream commit start (int): Start partch to use (0=first / top of branch) + end (int): End patch to use (0=last one in series, 1=one before that, + etc.) ignore_binary (bool): Don't generate patches for binary files Returns: @@ -50,7 +52,7 @@ def prepare_patches(col, branch, count, start, ignore_binary): 'No commits found to process - please use -c flag')) # Read the metadata from the commits - to_do = count + to_do = count - end series = patchstream.GetMetaData(branch, start, to_do) cover_fname, patch_files = gitutil.CreatePatches( branch, start, to_do, ignore_binary, series) @@ -159,7 +161,7 @@ def send(options): setup() col = terminal.Color() series, cover_fname, patch_files = prepare_patches( - col, options.branch, options.count, options.start, + col, options.branch, options.count, options.start, options.end, options.ignore_binary) ok = check_patches(series, patch_files, options.check_patch, options.verbose) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 588be73ef4..810af9c604 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -430,7 +430,8 @@ complicated as possible''') col = terminal.Color() with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( - col, branch=None, count=-1, start=0, ignore_binary=False) + col, branch=None, count=-1, start=0, end=0, + ignore_binary=False) self.assertIsNone(cover_fname) self.assertEqual(2, len(patch_files)) @@ -438,9 +439,17 @@ complicated as possible''') self.assertEqual(3, gitutil.CountCommitsToBranch('second')) with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( - col, branch='second', count=-1, start=0, + col, branch='second', count=-1, start=0, end=0, ignore_binary=False) self.assertIsNotNone(cover_fname) self.assertEqual(3, len(patch_files)) + + # Check that it can skip patches at the end + with capture_sys_output() as _: + _, cover_fname, patch_files = control.prepare_patches( + col, branch='second', count=-1, start=0, end=1, + ignore_binary=False) + self.assertIsNotNone(cover_fname) + self.assertEqual(2, len(patch_files)) finally: os.chdir(orig_dir) diff --git a/tools/patman/main.py b/tools/patman/main.py index 066754196e..4d7a3044ea 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -35,6 +35,8 @@ parser.add_option('-b', '--branch', type='str', help="Branch to process (by default, the current branch)") parser.add_option('-c', '--count', dest='count', type='int', default=-1, help='Automatically create patches from top n commits') +parser.add_option('-e', '--end', type='int', default=0, + help='Commits to skip at end of patch list') parser.add_option('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found') -- cgit From e676fab72943139e322fe43aa8f0548d0e70ded9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:53 -0600 Subject: patman: Convert to ArgumentParser Convert from OptionParser to ArgumentParser to match binman. With this we can easily add sub-commands. Signed-off-by: Simon Glass --- tools/patman/control.py | 22 +++++------ tools/patman/main.py | 97 ++++++++++++++++++++++++------------------------ tools/patman/settings.py | 10 +++-- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index b481ff6b27..e67867b845 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -152,24 +152,24 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go, os.remove(cc_file) -def send(options): +def send(args): """Create, check and send patches by email Args: - options (optparse.Values): Arguments to patman + args (argparse.Namespace): Arguments to patman """ setup() col = terminal.Color() series, cover_fname, patch_files = prepare_patches( - col, options.branch, options.count, options.start, options.end, - options.ignore_binary) - ok = check_patches(series, patch_files, options.check_patch, - options.verbose) + col, args.branch, args.count, args.start, args.end, + args.ignore_binary) + ok = check_patches(series, patch_files, args.check_patch, + args.verbose) - its_a_go = ok or options.ignore_errors + its_a_go = ok or args.ignore_errors if its_a_go: email_patches( - col, series, cover_fname, patch_files, options.process_tags, - its_a_go, options.ignore_bad_tags, options.add_maintainers, - options.limit, options.dry_run, options.in_reply_to, options.thread, - options.smtp_server) + col, series, cover_fname, patch_files, args.process_tags, + its_a_go, args.ignore_bad_tags, args.add_maintainers, + args.limit, args.dry_run, args.in_reply_to, args.thread, + args.smtp_server) diff --git a/tools/patman/main.py b/tools/patman/main.py index 4d7a3044ea..34cad9a562 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -6,7 +6,7 @@ """See README for more information""" -from optparse import OptionParser +from argparse import ArgumentParser import os import re import sys @@ -27,71 +27,70 @@ from patman import terminal from patman import test_util from patman import test_checkpatch +epilog = '''Create patches from commits in a branch, check them and email them +as specified by tags you place in the commits. Use -n to do a dry run first.''' -parser = OptionParser() -parser.add_option('-H', '--full-help', action='store_true', dest='full_help', +parser = ArgumentParser(epilog=epilog) +parser.add_argument('-H', '--full-help', action='store_true', dest='full_help', default=False, help='Display the README file') -parser.add_option('-b', '--branch', type='str', +parser.add_argument('-b', '--branch', type=str, help="Branch to process (by default, the current branch)") -parser.add_option('-c', '--count', dest='count', type='int', +parser.add_argument('-c', '--count', dest='count', type=int, default=-1, help='Automatically create patches from top n commits') -parser.add_option('-e', '--end', type='int', default=0, +parser.add_argument('-e', '--end', type=int, default=0, help='Commits to skip at end of patch list') -parser.add_option('-i', '--ignore-errors', action='store_true', +parser.add_argument('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found') -parser.add_option('-l', '--limit-cc', dest='limit', type='int', - default=None, help='Limit the cc list to LIMIT entries [default: %default]') -parser.add_option('-m', '--no-maintainers', action='store_false', +parser.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None, + help='Limit the cc list to LIMIT entries [default: %(default)]') +parser.add_argument('-m', '--no-maintainers', action='store_false', dest='add_maintainers', default=True, help="Don't cc the file maintainers automatically") -parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', +parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', default=False, help="Do a dry run (create but don't email patches)") -parser.add_option('-p', '--project', default=project.DetectProject(), - help="Project name; affects default option values and " - "aliases [default: %default]") -parser.add_option('-r', '--in-reply-to', type='string', action='store', +parser.add_argument('-p', '--project', default=project.DetectProject(), + help="Project name; affects default option values and " + "aliases [default: %(default)]") +parser.add_argument('-r', '--in-reply-to', type=str, action='store', help="Message ID that this series is in reply to") -parser.add_option('-s', '--start', dest='start', type='int', +parser.add_argument('-s', '--start', dest='start', type=int, default=0, help='Commit to start creating patches from (0 = HEAD)') -parser.add_option('-t', '--ignore-bad-tags', action='store_true', - default=False, help='Ignore bad tags / aliases') -parser.add_option('-v', '--verbose', action='store_true', dest='verbose', +parser.add_argument('-t', '--ignore-bad-tags', action='store_true', + default=False, help='Ignore bad tags / aliases') +parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Verbose output of errors and warnings') -parser.add_option('-T', '--thread', action='store_true', dest='thread', - default=False, help='Create patches as a single thread') -parser.add_option('--cc-cmd', dest='cc_cmd', type='string', action='store', +parser.add_argument('-T', '--thread', action='store_true', dest='thread', + default=False, help='Create patches as a single thread') +parser.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store', default=None, help='Output cc list for patch file (used by git)') -parser.add_option('--no-binary', action='store_true', dest='ignore_binary', - default=False, - help="Do not output contents of changes in binary files") -parser.add_option('--no-check', action='store_false', dest='check_patch', - default=True, - help="Don't check for patch compliance") -parser.add_option('--no-tags', action='store_false', dest='process_tags', - default=True, help="Don't process subject tags as aliases") -parser.add_option('--smtp-server', type='str', - help="Specify the SMTP server to 'git send-email'") -parser.add_option('--test', action='store_true', dest='test', - default=False, help='run tests') - -parser.usage += """ - -Create patches from commits in a branch, check them and email them as -specified by tags you place in the commits. Use -n to do a dry run first.""" - +parser.add_argument('--no-binary', action='store_true', dest='ignore_binary', + default=False, + help="Do not output contents of changes in binary files") +parser.add_argument('--no-check', action='store_false', dest='check_patch', + default=True, + help="Don't check for patch compliance") +parser.add_argument('--no-tags', action='store_false', dest='process_tags', + default=True, help="Don't process subject tags as aliases") +parser.add_argument('--smtp-server', type=str, + help="Specify the SMTP server to 'git send-email'") +parser.add_argument('--test', action='store_true', dest='test', + default=False, help='run tests') + +parser.add_argument('patchfiles', nargs='*') # Parse options twice: first to get the project and second to handle # defaults properly (which depends on project). -(options, args) = parser.parse_args() -settings.Setup(gitutil, parser, options.project, '') -(options, args) = parser.parse_args() +argv = sys.argv[1:] +args = parser.parse_args(argv) +settings.Setup(gitutil, parser, args.project, '') +args = parser.parse_args(argv) if __name__ != "__main__": pass # Run our meagre tests -elif options.test: +elif args.test: import doctest from patman import func_test @@ -109,19 +108,19 @@ elif options.test: # Called from git with a patch filename as argument # Printout a list of additional CC recipients for this patch -elif options.cc_cmd: - fd = open(options.cc_cmd, 'r') +elif args.cc_cmd: + fd = open(args.cc_cmd, 'r') re_line = re.compile('(\S*) (.*)') for line in fd.readlines(): match = re_line.match(line) - if match and match.group(1) == args[0]: + if match and match.group(1) == args.patchfiles[0]: for cc in match.group(2).split('\0'): cc = cc.strip() if cc: print(cc) fd.close() -elif options.full_help: +elif args.full_help: pager = os.getenv('PAGER') if not pager: pager = 'more' @@ -131,4 +130,4 @@ elif options.full_help: # Process commits, produce patches files, check them, email them else: - control.send(options) + control.send(args) diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 635561ac05..732bd40106 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -233,17 +233,19 @@ def _UpdateDefaults(parser, config): config: An instance of _ProjectConfigParser that we will query for settings. """ - defaults = parser.get_default_values() + defaults = parser.parse_known_args()[0] + defaults = vars(defaults) for name, val in config.items('settings'): - if hasattr(defaults, name): - default_val = getattr(defaults, name) + if name in defaults: + default_val = defaults[name] if isinstance(default_val, bool): val = config.getboolean('settings', name) elif isinstance(default_val, int): val = config.getint('settings', name) - parser.set_default(name, val) + defaults[name] = val else: print("WARNING: Unknown setting %s" % name) + parser.set_defaults(**defaults) def _ReadAliasFile(fname): """Read in the U-Boot git alias file if it exists. -- cgit From 4806fa30065773e87bd9071bd21e55b1fc4d63b8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:54 -0600 Subject: patman: Allow different commands At present patman only does one thing so does not have any comments. We want to add a few more command, so create a sub-parser for the default command ('send'). Signed-off-by: Simon Glass --- tools/patman/main.py | 77 ++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index 34cad9a562..fee9bc848b 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -31,60 +31,65 @@ epilog = '''Create patches from commits in a branch, check them and email them as specified by tags you place in the commits. Use -n to do a dry run first.''' parser = ArgumentParser(epilog=epilog) -parser.add_argument('-H', '--full-help', action='store_true', dest='full_help', +subparsers = parser.add_subparsers(dest='cmd') +send = subparsers.add_parser('send') +send.add_argument('-H', '--full-help', action='store_true', dest='full_help', default=False, help='Display the README file') -parser.add_argument('-b', '--branch', type=str, +send.add_argument('-b', '--branch', type=str, help="Branch to process (by default, the current branch)") -parser.add_argument('-c', '--count', dest='count', type=int, +send.add_argument('-c', '--count', dest='count', type=int, default=-1, help='Automatically create patches from top n commits') -parser.add_argument('-e', '--end', type=int, default=0, +send.add_argument('-e', '--end', type=int, default=0, help='Commits to skip at end of patch list') -parser.add_argument('-i', '--ignore-errors', action='store_true', +send.add_argument('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found') -parser.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None, - help='Limit the cc list to LIMIT entries [default: %(default)]') -parser.add_argument('-m', '--no-maintainers', action='store_false', +send.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None, + help='Limit the cc list to LIMIT entries [default: %(default)s]') +send.add_argument('-m', '--no-maintainers', action='store_false', dest='add_maintainers', default=True, help="Don't cc the file maintainers automatically") -parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', +send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', default=False, help="Do a dry run (create but don't email patches)") -parser.add_argument('-p', '--project', default=project.DetectProject(), - help="Project name; affects default option values and " - "aliases [default: %(default)]") -parser.add_argument('-r', '--in-reply-to', type=str, action='store', +send.add_argument('-p', '--project', default=project.DetectProject(), + help="Project name; affects default option values and " + "aliases [default: %(default)s]") +send.add_argument('-r', '--in-reply-to', type=str, action='store', help="Message ID that this series is in reply to") -parser.add_argument('-s', '--start', dest='start', type=int, +send.add_argument('-s', '--start', dest='start', type=int, default=0, help='Commit to start creating patches from (0 = HEAD)') -parser.add_argument('-t', '--ignore-bad-tags', action='store_true', - default=False, help='Ignore bad tags / aliases') -parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', +send.add_argument('-t', '--ignore-bad-tags', action='store_true', + default=False, help='Ignore bad tags / aliases') +send.add_argument('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Verbose output of errors and warnings') -parser.add_argument('-T', '--thread', action='store_true', dest='thread', - default=False, help='Create patches as a single thread') -parser.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store', +send.add_argument('-T', '--thread', action='store_true', dest='thread', + default=False, help='Create patches as a single thread') +send.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store', default=None, help='Output cc list for patch file (used by git)') -parser.add_argument('--no-binary', action='store_true', dest='ignore_binary', - default=False, - help="Do not output contents of changes in binary files") -parser.add_argument('--no-check', action='store_false', dest='check_patch', - default=True, - help="Don't check for patch compliance") -parser.add_argument('--no-tags', action='store_false', dest='process_tags', - default=True, help="Don't process subject tags as aliases") -parser.add_argument('--smtp-server', type=str, - help="Specify the SMTP server to 'git send-email'") -parser.add_argument('--test', action='store_true', dest='test', - default=False, help='run tests') - -parser.add_argument('patchfiles', nargs='*') +send.add_argument('--no-binary', action='store_true', dest='ignore_binary', + default=False, + help="Do not output contents of changes in binary files") +send.add_argument('--no-check', action='store_false', dest='check_patch', + default=True, + help="Don't check for patch compliance") +send.add_argument('--no-tags', action='store_false', dest='process_tags', + default=True, help="Don't process subject tags as aliases") +send.add_argument('--smtp-server', type=str, + help="Specify the SMTP server to 'git send-email'") +send.add_argument('--test', action='store_true', dest='test', + default=False, help='run tests') + +send.add_argument('patchfiles', nargs='*') # Parse options twice: first to get the project and second to handle # defaults properly (which depends on project). argv = sys.argv[1:] +if len(argv) < 1 or argv[0].startswith('-'): + argv = ['send'] + argv args = parser.parse_args(argv) -settings.Setup(gitutil, parser, args.project, '') -args = parser.parse_args(argv) +if hasattr(args, 'project'): + settings.Setup(gitutil, send, args.project, '') + args = parser.parse_args(argv) if __name__ != "__main__": pass -- cgit From 57374b09ec956f557ae55939e74ba841d76e0bf2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:55 -0600 Subject: patman: Add a 'test' subcommand At present we use --test to indicate that tests should be run. It is better to use a subcommand for list, like binman. Change it and adjust the existing code to fit under a 'send' subcommand, the default. Give this subcommand the same default arguments as the others. Signed-off-by: Simon Glass --- .azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- test/run | 2 +- tools/patman/main.py | 75 +++++++++++++++++++++++++---------------------- tools/patman/test_util.py | 2 +- 6 files changed, 45 insertions(+), 40 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 97c89fc067..3e52f32890 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -158,7 +158,7 @@ jobs: ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test ./tools/buildman/buildman -t ./tools/dtoc/dtoc -t - ./tools/patman/patman --test + ./tools/patman/patman test make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig EOF cat build.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d2f864669d..6c8a323ad3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -169,7 +169,7 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites: ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test; ./tools/buildman/buildman -t; ./tools/dtoc/dtoc -t; - ./tools/patman/patman --test; + ./tools/patman/patman test; make testconfig Run tests for Nokia RX-51 (aka N900): diff --git a/.travis.yml b/.travis.yml index 1ff140855e..9438bd13cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -257,7 +257,7 @@ script: export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test && - ./tools/patman/patman --test && + ./tools/patman/patman test && ./tools/buildman/buildman -t && ./tools/dtoc/dtoc -t && make testconfig; diff --git a/test/run b/test/run index 27331a8e40..de87e7530b 100755 --- a/test/run +++ b/test/run @@ -48,7 +48,7 @@ export DTC=${DTC_DIR}/dtc TOOLS_DIR=build-sandbox_spl/tools run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test -run_test "patman" ./tools/patman/patman --test +run_test "patman" ./tools/patman/patman test run_test "buildman" ./tools/buildman/buildman -t ${skip} run_test "fdt" ./tools/dtoc/test_fdt -t diff --git a/tools/patman/main.py b/tools/patman/main.py index fee9bc848b..77f187e769 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -27,6 +27,16 @@ from patman import terminal from patman import test_util from patman import test_checkpatch +def AddCommonArgs(parser): + parser.add_argument('-b', '--branch', type=str, + help="Branch to process (by default, the current branch)") + parser.add_argument('-c', '--count', dest='count', type=int, + default=-1, help='Automatically create patches from top n commits') + parser.add_argument('-e', '--end', type=int, default=0, + help='Commits to skip at end of patch list') + parser.add_argument('-s', '--start', dest='start', type=int, + default=0, help='Commit to start creating patches from (0 = HEAD)') + epilog = '''Create patches from commits in a branch, check them and email them as specified by tags you place in the commits. Use -n to do a dry run first.''' @@ -35,12 +45,6 @@ subparsers = parser.add_subparsers(dest='cmd') send = subparsers.add_parser('send') send.add_argument('-H', '--full-help', action='store_true', dest='full_help', default=False, help='Display the README file') -send.add_argument('-b', '--branch', type=str, - help="Branch to process (by default, the current branch)") -send.add_argument('-c', '--count', dest='count', type=int, - default=-1, help='Automatically create patches from top n commits') -send.add_argument('-e', '--end', type=int, default=0, - help='Commits to skip at end of patch list') send.add_argument('-i', '--ignore-errors', action='store_true', dest='ignore_errors', default=False, help='Send patches email even if patch errors are found') @@ -56,8 +60,6 @@ send.add_argument('-p', '--project', default=project.DetectProject(), "aliases [default: %(default)s]") send.add_argument('-r', '--in-reply-to', type=str, action='store', help="Message ID that this series is in reply to") -send.add_argument('-s', '--start', dest='start', type=int, - default=0, help='Commit to start creating patches from (0 = HEAD)') send.add_argument('-t', '--ignore-bad-tags', action='store_true', default=False, help='Ignore bad tags / aliases') send.add_argument('-v', '--verbose', action='store_true', dest='verbose', @@ -76,11 +78,13 @@ send.add_argument('--no-tags', action='store_false', dest='process_tags', default=True, help="Don't process subject tags as aliases") send.add_argument('--smtp-server', type=str, help="Specify the SMTP server to 'git send-email'") -send.add_argument('--test', action='store_true', dest='test', - default=False, help='run tests') +AddCommonArgs(send) send.add_argument('patchfiles', nargs='*') +test_parser = subparsers.add_parser('test', help='Run tests') +AddCommonArgs(test_parser) + # Parse options twice: first to get the project and second to handle # defaults properly (which depends on project). argv = sys.argv[1:] @@ -95,7 +99,7 @@ if __name__ != "__main__": pass # Run our meagre tests -elif args.test: +if args.cmd == 'test': import doctest from patman import func_test @@ -111,28 +115,29 @@ elif args.test: sys.exit(test_util.ReportResult('patman', None, result)) -# Called from git with a patch filename as argument -# Printout a list of additional CC recipients for this patch -elif args.cc_cmd: - fd = open(args.cc_cmd, 'r') - re_line = re.compile('(\S*) (.*)') - for line in fd.readlines(): - match = re_line.match(line) - if match and match.group(1) == args.patchfiles[0]: - for cc in match.group(2).split('\0'): - cc = cc.strip() - if cc: - print(cc) - fd.close() - -elif args.full_help: - pager = os.getenv('PAGER') - if not pager: - pager = 'more' - fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), - 'README') - command.Run(pager, fname) - # Process commits, produce patches files, check them, email them -else: - control.send(args) +elif args.cmd == 'send': + # Called from git with a patch filename as argument + # Printout a list of additional CC recipients for this patch + if args.cc_cmd: + fd = open(args.cc_cmd, 'r') + re_line = re.compile('(\S*) (.*)') + for line in fd.readlines(): + match = re_line.match(line) + if match and match.group(1) == args.patchfiles[0]: + for cc in match.group(2).split('\0'): + cc = cc.strip() + if cc: + print(cc) + fd.close() + + elif args.full_help: + pager = os.getenv('PAGER') + if not pager: + pager = 'more' + fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), + 'README') + command.Run(pager, fname) + + else: + control.send(args) diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 0827488f33..a87d3cc8f3 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -47,7 +47,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): glob_list = [] glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] - test_cmd = 'test' if 'binman' in prog else '-t' + test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t' prefix = '' if build_dir: prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir -- cgit From ef6629128c2d58cbd2c9a2a88e5857842c73f782 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:56 -0600 Subject: patman: Allow disabling 'bright' mode with Print output At present all text is marked bright, which makes it stand out on the terminal. Add a way to disable that, as is done with the Color class. Signed-off-by: Simon Glass --- tools/patman/terminal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py index c709438bdc..60dbce3ce1 100644 --- a/tools/patman/terminal.py +++ b/tools/patman/terminal.py @@ -122,7 +122,7 @@ def TrimAsciiLen(text, size): return out -def Print(text='', newline=True, colour=None, limit_to_line=False): +def Print(text='', newline=True, colour=None, limit_to_line=False, bright=True): """Handle a line of output to the terminal. In test mode this is recorded in a list. Otherwise it is output to the @@ -140,7 +140,7 @@ def Print(text='', newline=True, colour=None, limit_to_line=False): else: if colour: col = Color() - text = col.Color(colour, text) + text = col.Color(colour, text, bright=bright) if newline: print(text) last_print_len = None -- cgit From df3fc0757b77dea408a8253bc801573ef19606f2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:57 -0600 Subject: patman: Support collecting response tags in Patchstream Collect response tags such as 'Reviewed-by' while parsing the stream. This allows us to see what tags are present. Add a new 'Fixes' tag also, since this is now quite common. Signed-off-by: Simon Glass --- tools/patman/commit.py | 14 ++++++++++++++ tools/patman/patchstream.py | 21 ++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tools/patman/commit.py b/tools/patman/commit.py index 48d0529c53..8d583c4ed3 100644 --- a/tools/patman/commit.py +++ b/tools/patman/commit.py @@ -2,6 +2,7 @@ # Copyright (c) 2011 The Chromium OS Authors. # +import collections import re # Separates a tag: at the beginning of the subject from the rest of it @@ -23,6 +24,9 @@ class Commit: notes: List of lines in the commit (not series) notes change_id: the Change-Id: tag that was stripped from this commit and can be used to generate the Message-Id. + rtags: Response tags (e.g. Reviewed-by) collected by the commit, dict: + key: rtag type (e.g. 'Reviewed-by') + value: Set of people who gave that rtag, each a name/email string """ def __init__(self, hash): self.hash = hash @@ -33,6 +37,7 @@ class Commit: self.signoff_set = set() self.notes = [] self.change_id = None + self.rtags = collections.defaultdict(set) def AddChange(self, version, info): """Add a new change line to the change list for a version. @@ -88,3 +93,12 @@ class Commit: return False self.signoff_set.add(signoff) return True + + def AddRtag(self, rtag_type, who): + """Add a response tag to a commit + + Args: + key: rtag type (e.g. 'Reviewed-by') + who: Person who gave that rtag, e.g. 'Fred Bloggs ' + """ + self.rtags[rtag_type].add(who) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 2ea8ebcc3f..0c68c86156 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -37,7 +37,7 @@ re_change_id = re.compile('^Change-Id: *(.*)') re_commit_tag = re.compile('^Commit-([a-z-]*): *(.*)') # Commit tags that we want to collect and keep -re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc): (.*)') +re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc|Fixes): (.*)') # The start of a new commit in the git log re_commit = re.compile('^commit ([0-9a-f]*)$') @@ -112,6 +112,15 @@ class PatchStream: self.in_section = 'commit-' + name self.skip_blank = False + def AddCommitRtag(self, rtag_type, who): + """Add a response tag to the current commit + + Args: + key: rtag type (e.g. 'Reviewed-by') + who: Person who gave that rtag, e.g. 'Fred Bloggs ' + """ + self.commit.AddRtag(rtag_type, who) + def CloseCommit(self): """Save the current commit into our commit list, and reset our state""" if self.commit and self.is_log: @@ -346,12 +355,14 @@ class PatchStream: # Detect tags in the commit message elif tag_match: + rtag_type, who = tag_match.groups() + self.AddCommitRtag(rtag_type, who) # Remove Tested-by self, since few will take much notice - if (tag_match.group(1) == 'Tested-by' and - tag_match.group(2).find(os.getenv('USER') + '@') != -1): + if (rtag_type == 'Tested-by' and + who.find(os.getenv('USER') + '@') != -1): self.warn.append("Ignoring %s" % line) - elif tag_match.group(1) == 'Patch-cc': - self.commit.AddCc(tag_match.group(2).split(',')) + elif rtag_type == 'Patch-cc': + self.commit.AddCc(who.split(',')) else: out = [line] -- cgit From 0fc2e632f59050332dbc8e06b561cbe0a0534473 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:59 -0600 Subject: patman: Add a -D option to enable debugging Most users don't want to see traceback errors. Add an option to enable them for debugging. Disable them by default. Signed-off-by: Simon Glass --- tools/patman/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/patman/main.py b/tools/patman/main.py index 77f187e769..b96000807e 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -10,6 +10,7 @@ from argparse import ArgumentParser import os import re import sys +import traceback import unittest if __name__ == "__main__": @@ -34,6 +35,8 @@ def AddCommonArgs(parser): default=-1, help='Automatically create patches from top n commits') parser.add_argument('-e', '--end', type=int, default=0, help='Commits to skip at end of patch list') + parser.add_argument('-D', '--debug', action='store_true', + help='Enabling debugging (provides a full traceback on error)') parser.add_argument('-s', '--start', dest='start', type=int, default=0, help='Commit to start creating patches from (0 = HEAD)') @@ -98,6 +101,9 @@ if hasattr(args, 'project'): if __name__ != "__main__": pass +if not args.debug: + sys.tracebacklimit = 0 + # Run our meagre tests if args.cmd == 'test': import doctest -- cgit From 5d9dc917e16faf24c171a97550b26fe0baa069c2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:24 -0600 Subject: dm: core Fix long line in device_bind_common() Fix an over-length line in this function. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/core/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 476133f172..355dbd147a 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -82,7 +82,8 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, * This is just a 'requested' sequence, and will be * resolved (and ->seq updated) when the device is probed. */ - if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) { + if (CONFIG_IS_ENABLED(OF_CONTROL) && + !CONFIG_IS_ENABLED(OF_PLATDATA)) { if (uc->uc_drv->name && ofnode_valid(node)) dev_read_alias_seq(dev, &dev->req_seq); #if CONFIG_IS_ENABLED(OF_PRIOR_STAGE) -- cgit From 2a9c14526e9367c878d43536bfdbe4b23a23e870 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:25 -0600 Subject: .gitignore: Ignore Python 3 cache directories These can appear when moving between branches that have different tools in the tree. Ignore them. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2e1c8bf2bf..e66aa864da 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,6 @@ GTAGS *.orig *~ \#*# + +# Python cache +__pycache__ -- cgit From de438550913b67765b71172e10e130452bc7f61f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:26 -0600 Subject: binman: Output errors to stderr At present binman outputs errors to stdout which means that fails are effectively silent when printed by buildman, for example. Fix this by outputing errors to stderr. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/binman/main.py b/tools/binman/main.py index efa7fa8386..0ab2bb6206 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -123,7 +123,7 @@ def RunBinman(args): try: ret_code = control.Binman(args) except Exception as e: - print('binman: %s' % e) + print('binman: %s' % e, file=sys.stderr) if args.debug: print() traceback.print_exc() -- cgit From ccbe7dbc3f0ac390fa94f86d21f4ce620738523c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:27 -0600 Subject: binman: cbfs: Fix IFWI typo This comment references the wrong thing. Fix it. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/etype/cbfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py index e9aed8310c..744a32fa0c 100644 --- a/tools/binman/etype/cbfs.py +++ b/tools/binman/etype/cbfs.py @@ -204,7 +204,7 @@ class Entry_cbfs(Entry): return True def _ReadSubnodes(self): - """Read the subnodes to find out what should go in this IFWI""" + """Read the subnodes to find out what should go in this CBFS""" for node in self._node.subnodes: entry = Entry.Create(self, node) entry.ReadNode() -- cgit From 5d8b3384621a830f7acea4238b0bb555b857e058 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:28 -0600 Subject: binman: Correct the search patch for pylibfdt Now that binman uses tools/ as its base directory for importing modules, the path to the pylibfdt build by U-Boot is incorrect. Fix it with a new path. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/binman/main.py b/tools/binman/main.py index 0ab2bb6206..6f5a9d1ca2 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -26,6 +26,7 @@ from patman import test_util # Bring in the libfdt module sys.path.insert(2, 'scripts/dtc/pylibfdt') +sys.path.insert(2, os.path.join(our_path, '../../scripts/dtc/pylibfdt')) sys.path.insert(2, os.path.join(our_path, '../../build-sandbox_spl/scripts/dtc/pylibfdt')) -- cgit From 92dee5fcc53186eb06a22c347ad8323618ca683b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:29 -0600 Subject: binman: Specify the toolpath when running test coverage At present binman's test coverage runs without a toolpath set. This means that the system tools will be used. That may not be correct if they are out of date or missing and this can result in a reduction in test coverage below 100%. Provide the toolpath to binman in this case. Signed-off-by: Simon Glass --- tools/binman/main.py | 10 +++++++--- tools/patman/test_util.py | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/binman/main.py b/tools/binman/main.py index 6f5a9d1ca2..a5793d5d23 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -89,14 +89,18 @@ def GetEntryModules(include_testing=True): for item in glob_list if include_testing or '_testing' not in item]) -def RunTestCoverage(): +def RunTestCoverage(toolpath): """Run the tests and check that we get 100% coverage""" glob_list = GetEntryModules(False) all_set = set([os.path.splitext(os.path.basename(item))[0] for item in glob_list if '_testing' not in item]) + extra_args = '' + if toolpath: + for path in toolpath: + extra_args += ' --toolpath %s' % path test_util.RunTestCoverage('tools/binman/binman', None, ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'], - args.build_dir, all_set) + args.build_dir, all_set, extra_args or None) def RunBinman(args): """Main entry point to binman once arguments are parsed @@ -111,7 +115,7 @@ def RunBinman(args): if args.cmd == 'test': if args.test_coverage: - RunTestCoverage() + RunTestCoverage(args.toolpath) else: ret_code = RunTests(args.debug, args.verbosity, args.processes, args.test_preserve_dirs, args.tests, diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index a87d3cc8f3..20dc1e4924 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -21,7 +21,8 @@ except: use_concurrent = False -def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): +def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None, + extra_args=None): """Run tests and check that we get 100% coverage Args: @@ -34,6 +35,8 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): calculation build_dir: Build directory, used to locate libfdt.py required: List of modules which must be in the coverage report + extra_args (str): Extra arguments to pass to the tool before the -t/test + arg Raises: ValueError if the code coverage is not 100% @@ -52,8 +55,8 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): if build_dir: prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir cmd = ('%spython3-coverage run ' - '--omit "%s" %s %s -P1' % (prefix, ','.join(glob_list), - prog, test_cmd)) + '--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list), + prog, extra_args or '', test_cmd)) os.system(cmd) stdout = command.Output('python3-coverage', 'report') lines = stdout.splitlines() -- cgit From ce774e94de7009be0039ee02ca75f93d33a285a9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:30 -0600 Subject: binman: Set a default toolpath When binman is run from 'make check' it is given a toolpath so that the latest tools (e.g. mkimage) are used. When run manually with no toolpath, it relies on the system mkimage. But this may be missing or old. Make some effort to find the built-from-soruce version by looking in the current directory and in the builds created by 'make check'. Signed-off-by: Simon Glass --- tools/binman/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/binman/main.py b/tools/binman/main.py index a5793d5d23..e543a7d06a 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -113,6 +113,11 @@ def RunBinman(args): if not args.debug: sys.tracebacklimit = 0 + # Provide a default toolpath in the hope of finding a mkimage built from + # current source + if not args.toolpath: + args.toolpath = ['./tools', 'build-sandbox/tools'] + if args.cmd == 'test': if args.test_coverage: RunTestCoverage(args.toolpath) -- cgit From 3e8fba4cd41a3b324dffe921f9cd311e41f77a22 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:31 -0600 Subject: binman: Add support for calling mkimage As a first step to integrating mkimage into binman, add a new entry type that feeds data into mkimage for processing and incorporates that output into the image. Signed-off-by: Simon Glass --- tools/binman/README.entries | 23 +++++++++++++++ tools/binman/etype/_testing.py | 5 ++++ tools/binman/etype/mkimage.py | 62 +++++++++++++++++++++++++++++++++++++++ tools/binman/ftest.py | 7 +++++ tools/binman/test/156_mkimage.dts | 23 +++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 tools/binman/etype/mkimage.py create mode 100644 tools/binman/test/156_mkimage.dts diff --git a/tools/binman/README.entries b/tools/binman/README.entries index 6a816bba6b..4f2c48fdc2 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -587,6 +587,29 @@ See README.x86 for information about Intel binary blobs. +Entry: mkimage: Entry containing a binary produced by mkimage +------------------------------------------------------------- + +Properties / Entry arguments: + - datafile: Filename for -d argument + - args: Other arguments to pass + +The data passed to mkimage is collected from subnodes of the mkimage node, +e.g.: + + mkimage { + args = "-n test -T imximage"; + + u-boot-spl { + }; + }; + +This calls mkimage to create an imximage with u-boot-spl.bin as the input +file. The output from mkimage then becomes part of the image produced by +binman. + + + Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot ----------------------------------------------------------------------------------------- diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py index ed718eed14..ea60561adb 100644 --- a/tools/binman/etype/_testing.py +++ b/tools/binman/etype/_testing.py @@ -57,6 +57,8 @@ class Entry__testing(Entry): 'return-contents-once') self.bad_update_contents_twice = fdt_util.GetBool(self._node, 'bad-update-contents-twice') + self.return_contents_later = fdt_util.GetBool(self._node, + 'return-contents-later') # Set to True when the entry is ready to process the FDT. self.process_fdt_ready = False @@ -83,6 +85,9 @@ class Entry__testing(Entry): def ObtainContents(self): if self.return_unknown_contents or not self.return_contents: return False + if self.return_contents_later: + self.return_contents_later = False + return False self.data = self.contents self.contents_size = len(self.data) if self.return_contents_once: diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py new file mode 100644 index 0000000000..1aa563963a --- /dev/null +++ b/tools/binman/etype/mkimage.py @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass +# +# Entry-type module for producing an image using mkimage +# + +from collections import OrderedDict + +from binman.entry import Entry +from dtoc import fdt_util +from patman import tools + +class Entry_mkimage(Entry): + """Entry containing a binary produced by mkimage + + Properties / Entry arguments: + - datafile: Filename for -d argument + - args: Other arguments to pass + + The data passed to mkimage is collected from subnodes of the mkimage node, + e.g.: + + mkimage { + args = "-n test -T imximage"; + + u-boot-spl { + }; + }; + + This calls mkimage to create an imximage with u-boot-spl.bin as the input + file. The output from mkimage then becomes part of the image produced by + binman. + """ + def __init__(self, section, etype, node): + Entry.__init__(self, section, etype, node) + self._args = fdt_util.GetString(self._node, 'args').split(' ') + self._mkimage_entries = OrderedDict() + self._ReadSubnodes() + + def ObtainContents(self): + data = b'' + for entry in self._mkimage_entries.values(): + # First get the input data and put it in a file. If not available, + # try later. + if not entry.ObtainContents(): + return False + data += entry.GetData() + uniq = self.GetUniqueName() + input_fname = tools.GetOutputFilename('mkimage.%s' % uniq) + tools.WriteFile(input_fname, data) + output_fname = tools.GetOutputFilename('mkimage-out.%s' % uniq) + tools.Run('mkimage', '-d', input_fname, *self._args, output_fname) + self.SetContents(tools.ReadFile(output_fname)) + return True + + def _ReadSubnodes(self): + """Read the subnodes to find out what should go in this image""" + for node in self._node.subnodes: + entry = Entry.Create(self, node) + entry.ReadNode() + self._mkimage_entries[entry.name] = entry diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 5e24920088..39e67b9042 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3357,6 +3357,13 @@ class TestFunctional(unittest.TestCase): data = self._DoReadFile('154_intel_fsp_t.dts') self.assertEqual(FSP_T_DATA, data[:len(FSP_T_DATA)]) + def testMkimage(self): + """Test using mkimage to build an image""" + data = self._DoReadFile('156_mkimage.dts') + + # Just check that the data appears in the file somewhere + self.assertIn(U_BOOT_SPL_DATA, data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/156_mkimage.dts b/tools/binman/test/156_mkimage.dts new file mode 100644 index 0000000000..933b13143a --- /dev/null +++ b/tools/binman/test/156_mkimage.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <0x80>; + + mkimage { + args = "-n test -T script"; + + u-boot-spl { + }; + + _testing { + return-contents-later; + }; + }; + }; +}; -- cgit From fe04f647a27df076cd53208b9b3117c97dac4f89 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:32 -0600 Subject: binman: Fix a few typos in the entry docs Some typos have been fixed in the generated entry docs but the code was not updated. Fix this. Signed-off-by: Simon Glass --- tools/binman/etype/intel_me.py | 2 +- tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/binman/etype/intel_me.py b/tools/binman/etype/intel_me.py index 41c9c6b920..2707ca6912 100644 --- a/tools/binman/etype/intel_me.py +++ b/tools/binman/etype/intel_me.py @@ -16,7 +16,7 @@ class Entry_intel_me(Entry_blob): This file contains code used by the SoC that is required to make it work. The Management Engine is like a background task that runs things that are - not clearly documented, but may include keyboard, deplay and network + not clearly documented, but may include keyboard, display and network access. For platform that use ME it is not possible to disable it. U-Boot does not directly execute code in the ME binary. diff --git a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py index cefd425a5d..28005c60b3 100644 --- a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py +++ b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py @@ -13,7 +13,7 @@ class Entry_powerpc_mpc85xx_bootpg_resetvec(Entry_blob): Properties / Entry arguments: - filename: Filename of u-boot-br.bin (default 'u-boot-br.bin') - This enrty is valid for PowerPC mpc85xx cpus. This entry holds + This entry is valid for PowerPC mpc85xx cpus. This entry holds 'bootpg + resetvec' code for PowerPC mpc85xx CPUs which needs to be placed at offset 'RESET_VECTOR_ADDRESS - 0xffc'. """ -- cgit From 8beed3d7ac5a3253a850bdadcb2dbc1fec6aff6c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:33 -0600 Subject: binman: Adjust pylibfdt for incremental build If the pylibfdt shared-object file is detected, then Python assumes that the libfdt.py file exists also. Sometimes when an incremental build aborts, the shared-object file is built but the libfdt.py is not. The only way out at this point is to use 'make mkproper', or similar. Fix this by removing the .so file before it is built. This seems to make Python rebuild everything. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- scripts/dtc/pylibfdt/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile index 42342c75bb..80b6ad2ae7 100644 --- a/scripts/dtc/pylibfdt/Makefile +++ b/scripts/dtc/pylibfdt/Makefile @@ -24,6 +24,9 @@ quiet_cmd_pymod = PYMOD $@ $(PYTHON3) $< --quiet build_ext --inplace $(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE + @# Remove the library since otherwise Python doesn't seem to regenerate + @# the libfdt.py file if it is missing. + rm -f $(obj)/_libfdt*.so $(call if_changed,pymod) always += _libfdt.so -- cgit From 0b9116e31a6807a442f3a2ec887927536ce3aee3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:34 -0600 Subject: binman: Re-enable concurrent tests With the change to absolute imports the concurrent tests feature unfortunately broke. Fix it. We cannot easy add a warning, since the output messes up tests which check the output. Signed-off-by: Simon Glass --- tools/patman/test_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 20dc1e4924..4e261755dc 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -16,7 +16,8 @@ from io import StringIO use_concurrent = True try: - from concurrencytest import ConcurrentTestSuite, fork_for_tests + from concurrencytest.concurrencytest import ConcurrentTestSuite + from concurrencytest.concurrencytest import fork_for_tests except: use_concurrent = False @@ -50,6 +51,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None, glob_list = [] glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] + glob_list += ['*concurrencytest*'] test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t' prefix = '' if build_dir: -- cgit From 1216448573419fb53f37e31427b29f7ef197deef Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:35 -0600 Subject: binman: Use super() instead of specifying parent type It is easier and less error-prone to use super() when the parent type is needed. Update binman to remove the type names. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/etype/_testing.py | 4 ++-- tools/binman/etype/blob.py | 2 +- tools/binman/etype/blob_dtb.py | 6 +++--- tools/binman/etype/blob_named_by_arg.py | 2 +- tools/binman/etype/cbfs.py | 14 +++++++------- tools/binman/etype/cros_ec_rw.py | 3 +-- tools/binman/etype/fdtmap.py | 2 +- tools/binman/etype/files.py | 2 +- tools/binman/etype/fill.py | 4 ++-- tools/binman/etype/fmap.py | 2 +- tools/binman/etype/gbb.py | 2 +- tools/binman/etype/image_header.py | 4 ++-- tools/binman/etype/intel_cmc.py | 2 +- tools/binman/etype/intel_descriptor.py | 4 ++-- tools/binman/etype/intel_fit.py | 4 ++-- tools/binman/etype/intel_fit_ptr.py | 4 ++-- tools/binman/etype/intel_fsp.py | 2 +- tools/binman/etype/intel_fsp_m.py | 2 +- tools/binman/etype/intel_fsp_s.py | 2 +- tools/binman/etype/intel_fsp_t.py | 2 +- tools/binman/etype/intel_ifwi.py | 4 ++-- tools/binman/etype/intel_me.py | 2 +- tools/binman/etype/intel_mrc.py | 2 +- tools/binman/etype/intel_refcode.py | 2 +- tools/binman/etype/intel_vbt.py | 2 +- tools/binman/etype/intel_vga.py | 2 +- tools/binman/etype/mkimage.py | 2 +- tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py | 2 +- tools/binman/etype/section.py | 16 ++++++++-------- tools/binman/etype/text.py | 2 +- tools/binman/etype/u_boot.py | 2 +- tools/binman/etype/u_boot_dtb.py | 2 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 4 ++-- tools/binman/etype/u_boot_elf.py | 4 ++-- tools/binman/etype/u_boot_img.py | 2 +- tools/binman/etype/u_boot_nodtb.py | 2 +- tools/binman/etype/u_boot_spl.py | 2 +- tools/binman/etype/u_boot_spl_bss_pad.py | 2 +- tools/binman/etype/u_boot_spl_dtb.py | 2 +- tools/binman/etype/u_boot_spl_elf.py | 2 +- tools/binman/etype/u_boot_spl_nodtb.py | 2 +- tools/binman/etype/u_boot_spl_with_ucode_ptr.py | 2 +- tools/binman/etype/u_boot_tpl.py | 2 +- tools/binman/etype/u_boot_tpl_dtb.py | 2 +- tools/binman/etype/u_boot_tpl_dtb_with_ucode.py | 2 +- tools/binman/etype/u_boot_tpl_elf.py | 2 +- tools/binman/etype/u_boot_tpl_with_ucode_ptr.py | 2 +- tools/binman/etype/u_boot_ucode.py | 2 +- tools/binman/etype/u_boot_with_ucode_ptr.py | 2 +- tools/binman/etype/vblock.py | 2 +- tools/binman/etype/x86_reset16.py | 2 +- tools/binman/etype/x86_reset16_spl.py | 2 +- tools/binman/etype/x86_reset16_tpl.py | 2 +- tools/binman/etype/x86_start16.py | 2 +- tools/binman/etype/x86_start16_spl.py | 2 +- tools/binman/etype/x86_start16_tpl.py | 2 +- tools/binman/image.py | 12 ++++++------ 57 files changed, 86 insertions(+), 87 deletions(-) diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py index ea60561adb..0800c25899 100644 --- a/tools/binman/etype/_testing.py +++ b/tools/binman/etype/_testing.py @@ -41,10 +41,10 @@ class Entry__testing(Entry): data type (generating an error) """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ReadNode(self): - Entry.ReadNode(self) + super().ReadNode() self.return_invalid_entry = fdt_util.GetBool(self._node, 'return-invalid-entry') self.return_unknown_contents = fdt_util.GetBool(self._node, diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index ede7a7a68c..e507203709 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -31,7 +31,7 @@ class Entry_blob(Entry): data. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._filename = fdt_util.GetString(self._node, 'filename', self.etype) self.compress = fdt_util.GetString(self._node, 'compress', 'none') diff --git a/tools/binman/etype/blob_dtb.py b/tools/binman/etype/blob_dtb.py index 6c06943763..724647a7bb 100644 --- a/tools/binman/etype/blob_dtb.py +++ b/tools/binman/etype/blob_dtb.py @@ -20,13 +20,13 @@ class Entry_blob_dtb(Entry_blob): global state from binman import state - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ObtainContents(self): """Get the device-tree from the list held by the 'state' module""" self._filename = self.GetDefaultFilename() self._pathname, _ = state.GetFdtContents(self.GetFdtEtype()) - return Entry_blob.ReadBlobContents(self) + return super().ReadBlobContents() def ProcessContents(self): """Re-read the DTB contents so that we get any calculated properties""" @@ -57,7 +57,7 @@ class Entry_blob_dtb(Entry_blob): return {self.GetFdtEtype(): [self, fname]} def WriteData(self, data, decomp=True): - ok = Entry_blob.WriteData(self, data, decomp) + ok = super().WriteData(data, decomp) # Update the state module, since it has the authoritative record of the # device trees used. If we don't do this, then state.GetFdtContents() diff --git a/tools/binman/etype/blob_named_by_arg.py b/tools/binman/etype/blob_named_by_arg.py index 3b4593f071..e95dabe4d0 100644 --- a/tools/binman/etype/blob_named_by_arg.py +++ b/tools/binman/etype/blob_named_by_arg.py @@ -29,6 +29,6 @@ class Entry_blob_named_by_arg(Entry_blob): See cros_ec_rw for an example of this. """ def __init__(self, section, etype, node, blob_fname): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._filename, = self.GetEntryArgsOrProps( [EntryArg('%s-path' % blob_fname, str)]) diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py index 744a32fa0c..650ab2c292 100644 --- a/tools/binman/etype/cbfs.py +++ b/tools/binman/etype/cbfs.py @@ -167,7 +167,7 @@ class Entry_cbfs(Entry): global state from binman import state - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._cbfs_arg = fdt_util.GetString(node, 'cbfs-arch', 'x86') self._cbfs_entries = OrderedDict() self._ReadSubnodes() @@ -226,7 +226,7 @@ class Entry_cbfs(Entry): Args: image_pos: Position of this entry in the image """ - Entry.SetImagePos(self, image_pos) + super().SetImagePos(image_pos) # Now update the entries with info from the CBFS entries for entry in self._cbfs_entries.values(): @@ -238,7 +238,7 @@ class Entry_cbfs(Entry): entry.uncomp_size = cfile.memlen def AddMissingProperties(self): - Entry.AddMissingProperties(self) + super().AddMissingProperties() for entry in self._cbfs_entries.values(): entry.AddMissingProperties() if entry._cbfs_compress: @@ -250,7 +250,7 @@ class Entry_cbfs(Entry): def SetCalculatedProperties(self): """Set the value of device-tree properties calculated by binman""" - Entry.SetCalculatedProperties(self) + super().SetCalculatedProperties() for entry in self._cbfs_entries.values(): state.SetInt(entry._node, 'offset', entry.offset) state.SetInt(entry._node, 'size', entry.size) @@ -260,7 +260,7 @@ class Entry_cbfs(Entry): def ListEntries(self, entries, indent): """Override this method to list all files in the section""" - Entry.ListEntries(self, entries, indent) + super().ListEntries(entries, indent) for entry in self._cbfs_entries.values(): entry.ListEntries(entries, indent + 1) @@ -268,12 +268,12 @@ class Entry_cbfs(Entry): return self._cbfs_entries def ReadData(self, decomp=True): - data = Entry.ReadData(self, True) + data = super().ReadData(True) return data def ReadChildData(self, child, decomp=True): if not self.reader: - data = Entry.ReadData(self, True) + data = super().ReadData(True) self.reader = cbfs_util.CbfsReader(data) reader = self.reader cfile = reader.files.get(child.name) diff --git a/tools/binman/etype/cros_ec_rw.py b/tools/binman/etype/cros_ec_rw.py index 0dbe14b342..7ad62d0265 100644 --- a/tools/binman/etype/cros_ec_rw.py +++ b/tools/binman/etype/cros_ec_rw.py @@ -18,5 +18,4 @@ class Entry_cros_ec_rw(Entry_blob_named_by_arg): updating the EC on startup via software sync. """ def __init__(self, section, etype, node): - Entry_blob_named_by_arg.__init__(self, section, etype, node, - 'cros-ec-rw') + super().__init__(section, etype, node, 'cros-ec-rw') diff --git a/tools/binman/etype/fdtmap.py b/tools/binman/etype/fdtmap.py index aa8807990b..6ca88a100e 100644 --- a/tools/binman/etype/fdtmap.py +++ b/tools/binman/etype/fdtmap.py @@ -85,7 +85,7 @@ class Entry_fdtmap(Entry): from binman import state from dtoc.fdt import Fdt - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) def _GetFdtmap(self): """Build an FDT map from the entries in the current image diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py index 10ab585f0e..9adb3afeb1 100644 --- a/tools/binman/etype/files.py +++ b/tools/binman/etype/files.py @@ -32,7 +32,7 @@ class Entry_files(Entry_section): global state from binman import state - Entry_section.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._pattern = fdt_util.GetString(self._node, 'pattern') if not self._pattern: self.Raise("Missing 'pattern' property") diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py index 860410ed6e..efb2d13e91 100644 --- a/tools/binman/etype/fill.py +++ b/tools/binman/etype/fill.py @@ -22,10 +22,10 @@ class Entry_fill(Entry): byte value of a region. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ReadNode(self): - Entry.ReadNode(self) + super().ReadNode() if self.size is None: self.Raise("'fill' entry must have a size property") self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0) diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py index a43fac38de..3e9b815d11 100644 --- a/tools/binman/etype/fmap.py +++ b/tools/binman/etype/fmap.py @@ -32,7 +32,7 @@ class Entry_fmap(Entry): the sub-entries are ignored. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) def _GetFmap(self): """Build an FMAP from the entries in the current image diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py index dd10599717..41554eba8f 100644 --- a/tools/binman/etype/gbb.py +++ b/tools/binman/etype/gbb.py @@ -54,7 +54,7 @@ class Entry_gbb(Entry): README.chromium for how to obtain the required keys and tools. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.hardware_id, self.keydir, self.bmpblk = self.GetEntryArgsOrProps( [EntryArg('hardware-id', str), EntryArg('keydir', str), diff --git a/tools/binman/etype/image_header.py b/tools/binman/etype/image_header.py index 176bdeb29b..2401188495 100644 --- a/tools/binman/etype/image_header.py +++ b/tools/binman/etype/image_header.py @@ -57,7 +57,7 @@ class Entry_image_header(Entry): first/last in the entry list. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.location = fdt_util.GetString(self._node, 'location') def _GetHeader(self): @@ -101,7 +101,7 @@ class Entry_image_header(Entry): else: offset = image_size - IMAGE_HEADER_LEN offset += self.section.GetStartOffset() - return Entry.Pack(self, offset) + return super().Pack(offset) def ProcessContents(self): """Write an updated version of the FDT map to this entry diff --git a/tools/binman/etype/intel_cmc.py b/tools/binman/etype/intel_cmc.py index 5e6edbe4df..9ab471e7b6 100644 --- a/tools/binman/etype/intel_cmc.py +++ b/tools/binman/etype/intel_cmc.py @@ -20,4 +20,4 @@ class Entry_intel_cmc(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_descriptor.py b/tools/binman/etype/intel_descriptor.py index d4d7a26901..6afc42ece5 100644 --- a/tools/binman/etype/intel_descriptor.py +++ b/tools/binman/etype/intel_descriptor.py @@ -45,14 +45,14 @@ class Entry_intel_descriptor(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._regions = [] def Pack(self, offset): """Put this entry at the start of the image""" if self.offset is None: offset = self.section.GetStartOffset() - return Entry_blob.Pack(self, offset) + return super().Pack(offset) def GetOffsets(self): offset = self.data.find(FD_SIGNATURE) diff --git a/tools/binman/etype/intel_fit.py b/tools/binman/etype/intel_fit.py index ea482a6125..ad6c1caa85 100644 --- a/tools/binman/etype/intel_fit.py +++ b/tools/binman/etype/intel_fit.py @@ -19,11 +19,11 @@ class Entry_intel_fit(Entry_blob): At present binman only supports a basic FIT with no microcode. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ReadNode(self): """Force 16-byte alignment as required by FIT pointer""" - Entry_blob.ReadNode(self) + super().ReadNode() self.align = 16 def ObtainContents(self): diff --git a/tools/binman/etype/intel_fit_ptr.py b/tools/binman/etype/intel_fit_ptr.py index df118a68f2..a06d12e740 100644 --- a/tools/binman/etype/intel_fit_ptr.py +++ b/tools/binman/etype/intel_fit_ptr.py @@ -16,7 +16,7 @@ class Entry_intel_fit_ptr(Entry_blob): 0xffffffc0 in the image. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) if self.HasSibling('intel-fit') is False: self.Raise("'intel-fit-ptr' section must have an 'intel-fit' sibling") @@ -38,4 +38,4 @@ class Entry_intel_fit_ptr(Entry_blob): def Pack(self, offset): """Special pack method to set the offset to the right place""" - return Entry_blob.Pack(self, 0xffffffc0) + return super().Pack(0xffffffc0) diff --git a/tools/binman/etype/intel_fsp.py b/tools/binman/etype/intel_fsp.py index 7db3d96b43..a1c89adcea 100644 --- a/tools/binman/etype/intel_fsp.py +++ b/tools/binman/etype/intel_fsp.py @@ -24,4 +24,4 @@ class Entry_intel_fsp(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_fsp_m.py b/tools/binman/etype/intel_fsp_m.py index 51b4e7e1ac..4c225b24d3 100644 --- a/tools/binman/etype/intel_fsp_m.py +++ b/tools/binman/etype/intel_fsp_m.py @@ -24,4 +24,4 @@ class Entry_intel_fsp_m(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_fsp_s.py b/tools/binman/etype/intel_fsp_s.py index b3683e476a..9e1107182a 100644 --- a/tools/binman/etype/intel_fsp_s.py +++ b/tools/binman/etype/intel_fsp_s.py @@ -24,4 +24,4 @@ class Entry_intel_fsp_s(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_fsp_t.py b/tools/binman/etype/intel_fsp_t.py index 0f196f0f1c..5dca145a3f 100644 --- a/tools/binman/etype/intel_fsp_t.py +++ b/tools/binman/etype/intel_fsp_t.py @@ -23,4 +23,4 @@ class Entry_intel_fsp_t(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py index 6a96f6be55..ba63f6574f 100644 --- a/tools/binman/etype/intel_ifwi.py +++ b/tools/binman/etype/intel_ifwi.py @@ -45,13 +45,13 @@ class Entry_intel_ifwi(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._convert_fit = fdt_util.GetBool(self._node, 'convert-fit') self._ifwi_entries = OrderedDict() def ReadNode(self): self._ReadSubnodes() - Entry_blob.ReadNode(self) + super().ReadNode() def _BuildIfwi(self): """Build the contents of the IFWI and write it to the 'data' property""" diff --git a/tools/binman/etype/intel_me.py b/tools/binman/etype/intel_me.py index 2707ca6912..6b3803819e 100644 --- a/tools/binman/etype/intel_me.py +++ b/tools/binman/etype/intel_me.py @@ -27,4 +27,4 @@ class Entry_intel_me(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_mrc.py b/tools/binman/etype/intel_mrc.py index 854a4dda61..74781848e2 100644 --- a/tools/binman/etype/intel_mrc.py +++ b/tools/binman/etype/intel_mrc.py @@ -21,7 +21,7 @@ class Entry_intel_mrc(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'mrc.bin' diff --git a/tools/binman/etype/intel_refcode.py b/tools/binman/etype/intel_refcode.py index a1059f787e..5754fec4f8 100644 --- a/tools/binman/etype/intel_refcode.py +++ b/tools/binman/etype/intel_refcode.py @@ -21,7 +21,7 @@ class Entry_intel_refcode(Entry_blob): See README.x86 for information about x86 binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'refcode.bin' diff --git a/tools/binman/etype/intel_vbt.py b/tools/binman/etype/intel_vbt.py index 4d465ad017..f6d7b466ea 100644 --- a/tools/binman/etype/intel_vbt.py +++ b/tools/binman/etype/intel_vbt.py @@ -19,4 +19,4 @@ class Entry_intel_vbt(Entry_blob): See README.x86 for information about Intel binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/intel_vga.py b/tools/binman/etype/intel_vga.py index 04cd72f3dc..6b87c01b4c 100644 --- a/tools/binman/etype/intel_vga.py +++ b/tools/binman/etype/intel_vga.py @@ -22,4 +22,4 @@ class Entry_intel_vga(Entry_blob): See README.x86 for information about Intel binary blobs. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 1aa563963a..8fddc88118 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -33,7 +33,7 @@ class Entry_mkimage(Entry): binman. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._args = fdt_util.GetString(self._node, 'args').split(' ') self._mkimage_entries = OrderedDict() self._ReadSubnodes() diff --git a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py index 28005c60b3..b0fa75fbf8 100644 --- a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py +++ b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py @@ -19,7 +19,7 @@ class Entry_powerpc_mpc85xx_bootpg_resetvec(Entry_blob): """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot-br.bin' diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 91b8e0c110..f108121c3a 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -43,7 +43,7 @@ class Entry_section(Entry): """ def __init__(self, section, etype, node, test=False): if not test: - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._entries = OrderedDict() self._pad_byte = 0 self._sort = False @@ -52,7 +52,7 @@ class Entry_section(Entry): def ReadNode(self): """Read properties from the image node""" - Entry.ReadNode(self) + super().ReadNode() self._pad_byte = fdt_util.GetInt(self._node, 'pad-byte', 0) self._sort = fdt_util.GetBool(self._node, 'sort-by-offset') self._end_4gb = fdt_util.GetBool(self._node, 'end-at-4gb') @@ -126,13 +126,13 @@ class Entry_section(Entry): a section containing a list of files. Process these entries so that this information is added to the device tree. """ - Entry.ExpandEntries(self) + super().ExpandEntries() for entry in self._entries.values(): entry.ExpandEntries() def AddMissingProperties(self): """Add new properties to the device tree as needed for this entry""" - Entry.AddMissingProperties(self) + super().AddMissingProperties() for entry in self._entries.values(): entry.AddMissingProperties() @@ -168,14 +168,14 @@ class Entry_section(Entry): def ResetForPack(self): """Reset offset/size fields so that packing can be done again""" - Entry.ResetForPack(self) + super().ResetForPack() for entry in self._entries.values(): entry.ResetForPack() def Pack(self, offset): """Pack all entries into the section""" self._PackEntries() - return Entry.Pack(self, offset) + return super().Pack(offset) def _PackEntries(self): """Pack all entries into the image""" @@ -232,12 +232,12 @@ class Entry_section(Entry): entry.WriteSymbols(self) def SetCalculatedProperties(self): - Entry.SetCalculatedProperties(self) + super().SetCalculatedProperties() for entry in self._entries.values(): entry.SetCalculatedProperties() def SetImagePos(self, image_pos): - Entry.SetImagePos(self, image_pos) + super().SetImagePos(image_pos) for entry in self._entries.values(): entry.SetImagePos(image_pos + self.offset) diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py index 3577135adb..a69c2a4ec4 100644 --- a/tools/binman/etype/text.py +++ b/tools/binman/etype/text.py @@ -57,7 +57,7 @@ class Entry_text(Entry): by setting the size of the entry to something larger than the text. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) value = fdt_util.GetString(self._node, 'text') if value: value = tools.ToBytes(value) diff --git a/tools/binman/etype/u_boot.py b/tools/binman/etype/u_boot.py index ab1019b00c..4767197e13 100644 --- a/tools/binman/etype/u_boot.py +++ b/tools/binman/etype/u_boot.py @@ -26,7 +26,7 @@ class Entry_u_boot(Entry_blob): in the binman README for more information. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot.bin' diff --git a/tools/binman/etype/u_boot_dtb.py b/tools/binman/etype/u_boot_dtb.py index e98350088f..65e71291d2 100644 --- a/tools/binman/etype/u_boot_dtb.py +++ b/tools/binman/etype/u_boot_dtb.py @@ -22,7 +22,7 @@ class Entry_u_boot_dtb(Entry_blob_dtb): binman to know which entries contain a device tree. """ def __init__(self, section, etype, node): - Entry_blob_dtb.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot.dtb' diff --git a/tools/binman/etype/u_boot_dtb_with_ucode.py b/tools/binman/etype/u_boot_dtb_with_ucode.py index aec145533e..66a9db55ca 100644 --- a/tools/binman/etype/u_boot_dtb_with_ucode.py +++ b/tools/binman/etype/u_boot_dtb_with_ucode.py @@ -28,7 +28,7 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): global state from binman import state - Entry_blob_dtb.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.ucode_data = b'' self.collate = False self.ucode_offset = None @@ -78,7 +78,7 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): def ObtainContents(self): # Call the base class just in case it does something important. - Entry_blob_dtb.ObtainContents(self) + super().ObtainContents() if self.ucode and not self.collate: for node in self.ucode.subnodes: data_prop = node.props.get('data') diff --git a/tools/binman/etype/u_boot_elf.py b/tools/binman/etype/u_boot_elf.py index 5f906e520c..6614a75faf 100644 --- a/tools/binman/etype/u_boot_elf.py +++ b/tools/binman/etype/u_boot_elf.py @@ -21,7 +21,7 @@ class Entry_u_boot_elf(Entry_blob): relocated to any address for execution. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self._strip = fdt_util.GetBool(self._node, 'strip') def ReadBlobContents(self): @@ -31,7 +31,7 @@ class Entry_u_boot_elf(Entry_blob): tools.WriteFile(out_fname, tools.ReadFile(self._pathname)) tools.Run('strip', out_fname) self._pathname = out_fname - Entry_blob.ReadBlobContents(self) + super().ReadBlobContents() return True def GetDefaultFilename(self): diff --git a/tools/binman/etype/u_boot_img.py b/tools/binman/etype/u_boot_img.py index 50cc71d3ce..8a739d8edb 100644 --- a/tools/binman/etype/u_boot_img.py +++ b/tools/binman/etype/u_boot_img.py @@ -21,7 +21,7 @@ class Entry_u_boot_img(Entry_blob): applications. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot.img' diff --git a/tools/binman/etype/u_boot_nodtb.py b/tools/binman/etype/u_boot_nodtb.py index e8c0e1a1d6..e84df490f6 100644 --- a/tools/binman/etype/u_boot_nodtb.py +++ b/tools/binman/etype/u_boot_nodtb.py @@ -21,7 +21,7 @@ class Entry_u_boot_nodtb(Entry_blob): U-Boot and the device tree). """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot-nodtb.bin' diff --git a/tools/binman/etype/u_boot_spl.py b/tools/binman/etype/u_boot_spl.py index a6fddbe8f1..d66e46140b 100644 --- a/tools/binman/etype/u_boot_spl.py +++ b/tools/binman/etype/u_boot_spl.py @@ -32,7 +32,7 @@ class Entry_u_boot_spl(Entry_blob): binman uses that to look up symbols to write into the SPL binary. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.elf_fname = 'spl/u-boot-spl' def GetDefaultFilename(self): diff --git a/tools/binman/etype/u_boot_spl_bss_pad.py b/tools/binman/etype/u_boot_spl_bss_pad.py index a6a177a128..596b2bed97 100644 --- a/tools/binman/etype/u_boot_spl_bss_pad.py +++ b/tools/binman/etype/u_boot_spl_bss_pad.py @@ -31,7 +31,7 @@ class Entry_u_boot_spl_bss_pad(Entry_blob): binman uses that to look up the BSS address. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ObtainContents(self): fname = tools.GetInputFilename('spl/u-boot-spl') diff --git a/tools/binman/etype/u_boot_spl_dtb.py b/tools/binman/etype/u_boot_spl_dtb.py index a0761eeacd..eefc4a44aa 100644 --- a/tools/binman/etype/u_boot_spl_dtb.py +++ b/tools/binman/etype/u_boot_spl_dtb.py @@ -19,7 +19,7 @@ class Entry_u_boot_spl_dtb(Entry_blob_dtb): to activate. """ def __init__(self, section, etype, node): - Entry_blob_dtb.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'spl/u-boot-spl.dtb' diff --git a/tools/binman/etype/u_boot_spl_elf.py b/tools/binman/etype/u_boot_spl_elf.py index f99f74abab..7f1236bcbb 100644 --- a/tools/binman/etype/u_boot_spl_elf.py +++ b/tools/binman/etype/u_boot_spl_elf.py @@ -18,7 +18,7 @@ class Entry_u_boot_spl_elf(Entry_blob): be relocated to any address for execution. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'spl/u-boot-spl' diff --git a/tools/binman/etype/u_boot_spl_nodtb.py b/tools/binman/etype/u_boot_spl_nodtb.py index 072b915ff3..6f4529396d 100644 --- a/tools/binman/etype/u_boot_spl_nodtb.py +++ b/tools/binman/etype/u_boot_spl_nodtb.py @@ -22,7 +22,7 @@ class Entry_u_boot_spl_nodtb(Entry_blob): both SPL and the device tree). """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'spl/u-boot-spl-nodtb.bin' diff --git a/tools/binman/etype/u_boot_spl_with_ucode_ptr.py b/tools/binman/etype/u_boot_spl_with_ucode_ptr.py index b1543a5ef3..72739a5eb6 100644 --- a/tools/binman/etype/u_boot_spl_with_ucode_ptr.py +++ b/tools/binman/etype/u_boot_spl_with_ucode_ptr.py @@ -18,7 +18,7 @@ class Entry_u_boot_spl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): process. """ def __init__(self, section, etype, node): - Entry_u_boot_with_ucode_ptr.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.elf_fname = 'spl/u-boot-spl' def GetDefaultFilename(self): diff --git a/tools/binman/etype/u_boot_tpl.py b/tools/binman/etype/u_boot_tpl.py index 6562457c9a..02287ab327 100644 --- a/tools/binman/etype/u_boot_tpl.py +++ b/tools/binman/etype/u_boot_tpl.py @@ -32,7 +32,7 @@ class Entry_u_boot_tpl(Entry_blob): binman uses that to look up symbols to write into the TPL binary. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.elf_fname = 'tpl/u-boot-tpl' def GetDefaultFilename(self): diff --git a/tools/binman/etype/u_boot_tpl_dtb.py b/tools/binman/etype/u_boot_tpl_dtb.py index 890155f271..2ff1d7ced1 100644 --- a/tools/binman/etype/u_boot_tpl_dtb.py +++ b/tools/binman/etype/u_boot_tpl_dtb.py @@ -19,7 +19,7 @@ class Entry_u_boot_tpl_dtb(Entry_blob_dtb): to activate. """ def __init__(self, section, etype, node): - Entry_blob_dtb.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'tpl/u-boot-tpl.dtb' diff --git a/tools/binman/etype/u_boot_tpl_dtb_with_ucode.py b/tools/binman/etype/u_boot_tpl_dtb_with_ucode.py index ca1bf85ace..066f18dfef 100644 --- a/tools/binman/etype/u_boot_tpl_dtb_with_ucode.py +++ b/tools/binman/etype/u_boot_tpl_dtb_with_ucode.py @@ -16,7 +16,7 @@ class Entry_u_boot_tpl_dtb_with_ucode(Entry_u_boot_dtb_with_ucode): process. """ def __init__(self, section, etype, node): - Entry_u_boot_dtb_with_ucode.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'tpl/u-boot-tpl.dtb' diff --git a/tools/binman/etype/u_boot_tpl_elf.py b/tools/binman/etype/u_boot_tpl_elf.py index 7fa8e96364..3f24d3aa7b 100644 --- a/tools/binman/etype/u_boot_tpl_elf.py +++ b/tools/binman/etype/u_boot_tpl_elf.py @@ -18,7 +18,7 @@ class Entry_u_boot_tpl_elf(Entry_blob): be relocated to any address for execution. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'tpl/u-boot-tpl' diff --git a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py index 7f7fab7105..c7f3f9dedb 100644 --- a/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py +++ b/tools/binman/etype/u_boot_tpl_with_ucode_ptr.py @@ -20,7 +20,7 @@ class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): process. """ def __init__(self, section, etype, node): - Entry_u_boot_with_ucode_ptr.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.elf_fname = 'tpl/u-boot-tpl' def GetDefaultFilename(self): diff --git a/tools/binman/etype/u_boot_ucode.py b/tools/binman/etype/u_boot_ucode.py index d9e1a605ef..4462293618 100644 --- a/tools/binman/etype/u_boot_ucode.py +++ b/tools/binman/etype/u_boot_ucode.py @@ -58,7 +58,7 @@ class Entry_u_boot_ucode(Entry_blob): contents of this entry. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def ObtainContents(self): # If the section does not need microcode, there is nothing to do diff --git a/tools/binman/etype/u_boot_with_ucode_ptr.py b/tools/binman/etype/u_boot_with_ucode_ptr.py index 06047b654d..92d2fc6853 100644 --- a/tools/binman/etype/u_boot_with_ucode_ptr.py +++ b/tools/binman/etype/u_boot_with_ucode_ptr.py @@ -29,7 +29,7 @@ class Entry_u_boot_with_ucode_ptr(Entry_blob): complicated. Otherwise it is the same as the u_boot entry. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.elf_fname = 'u-boot' self.target_offset = None diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py index 5753de7ec7..f734fbaec4 100644 --- a/tools/binman/etype/vblock.py +++ b/tools/binman/etype/vblock.py @@ -36,7 +36,7 @@ class Entry_vblock(Entry): and kernel are genuine. """ def __init__(self, section, etype, node): - Entry.__init__(self, section, etype, node) + super().__init__(section, etype, node) self.content = fdt_util.GetPhandleList(self._node, 'content') if not self.content: self.Raise("Vblock must have a 'content' property") diff --git a/tools/binman/etype/x86_reset16.py b/tools/binman/etype/x86_reset16.py index ad864e5442..5d49f16e21 100644 --- a/tools/binman/etype/x86_reset16.py +++ b/tools/binman/etype/x86_reset16.py @@ -23,7 +23,7 @@ class Entry_x86_reset16(Entry_blob): For 64-bit U-Boot, the 'x86_reset16_spl' entry type is used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot-x86-reset16.bin' diff --git a/tools/binman/etype/x86_reset16_spl.py b/tools/binman/etype/x86_reset16_spl.py index 9a663f0ae2..775b90699b 100644 --- a/tools/binman/etype/x86_reset16_spl.py +++ b/tools/binman/etype/x86_reset16_spl.py @@ -23,7 +23,7 @@ class Entry_x86_reset16_spl(Entry_blob): For 32-bit U-Boot, the 'x86_reset_spl' entry type is used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'spl/u-boot-x86-reset16-spl.bin' diff --git a/tools/binman/etype/x86_reset16_tpl.py b/tools/binman/etype/x86_reset16_tpl.py index 864508f367..52d3f4869a 100644 --- a/tools/binman/etype/x86_reset16_tpl.py +++ b/tools/binman/etype/x86_reset16_tpl.py @@ -23,7 +23,7 @@ class Entry_x86_reset16_tpl(Entry_blob): For 32-bit U-Boot, the 'x86_reset_tpl' entry type is used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'tpl/u-boot-x86-reset16-tpl.bin' diff --git a/tools/binman/etype/x86_start16.py b/tools/binman/etype/x86_start16.py index d8345f6722..18fdd95d37 100644 --- a/tools/binman/etype/x86_start16.py +++ b/tools/binman/etype/x86_start16.py @@ -25,7 +25,7 @@ class Entry_x86_start16(Entry_blob): For 64-bit U-Boot, the 'x86_start16_spl' entry type is used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'u-boot-x86-start16.bin' diff --git a/tools/binman/etype/x86_start16_spl.py b/tools/binman/etype/x86_start16_spl.py index ad520d3c6d..ac8e90f2e0 100644 --- a/tools/binman/etype/x86_start16_spl.py +++ b/tools/binman/etype/x86_start16_spl.py @@ -25,7 +25,7 @@ class Entry_x86_start16_spl(Entry_blob): For 32-bit U-Boot, the 'x86-start16' entry type is used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'spl/u-boot-x86-start16-spl.bin' diff --git a/tools/binman/etype/x86_start16_tpl.py b/tools/binman/etype/x86_start16_tpl.py index ccc8727d1d..72d4608bb7 100644 --- a/tools/binman/etype/x86_start16_tpl.py +++ b/tools/binman/etype/x86_start16_tpl.py @@ -26,7 +26,7 @@ class Entry_x86_start16_tpl(Entry_blob): may be used instead. """ def __init__(self, section, etype, node): - Entry_blob.__init__(self, section, etype, node) + super().__init__(section, etype, node) def GetDefaultFilename(self): return 'tpl/u-boot-x86-start16-tpl.bin' diff --git a/tools/binman/image.py b/tools/binman/image.py index 523b274c31..a8772c3763 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -45,7 +45,7 @@ class Image(section.Entry_section): we create a section manually. """ def __init__(self, name, node, copy_to_orig=True, test=False): - section.Entry_section.__init__(self, None, 'section', node, test=test) + super().__init__(None, 'section', node, test=test) self.copy_to_orig = copy_to_orig self.name = 'main-section' self.image_name = name @@ -57,7 +57,7 @@ class Image(section.Entry_section): self.ReadNode() def ReadNode(self): - section.Entry_section.ReadNode(self) + super().ReadNode() filename = fdt_util.GetString(self._node, 'filename') if filename: self._filename = filename @@ -116,11 +116,11 @@ class Image(section.Entry_section): def PackEntries(self): """Pack all entries into the image""" - section.Entry_section.Pack(self, 0) + super().Pack(0) def SetImagePos(self): # This first section in the image so it starts at 0 - section.Entry_section.SetImagePos(self, 0) + super().SetImagePos(0) def ProcessEntryContents(self): """Call the ProcessContents() method for each entry @@ -139,7 +139,7 @@ class Image(section.Entry_section): def WriteSymbols(self): """Write symbol values into binary files for access at run time""" - section.Entry_section.WriteSymbols(self, self) + super().WriteSymbols(self) def BuildImage(self): """Write the image to a file""" @@ -161,7 +161,7 @@ class Image(section.Entry_section): with open(fname, 'w') as fd: print('%8s %8s %8s %s' % ('ImagePos', 'Offset', 'Size', 'Name'), file=fd) - section.Entry_section.WriteMap(self, fd, 0) + super().WriteMap(fd, 0) return fname def BuildEntryList(self): -- cgit From d498630ea9a5880302ee941f28925ee231b8f018 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:36 -0600 Subject: binman: Add an etype for external binary blobs It is useful to be able to distinguish between ordinary blobs such as u-boot.bin and external blobs that cannot be build by the U-Boot build system. If the external blobs are not available for some reason, then we know that a value image cannot be built. Introduce a new 'blob-ext' entry type for that. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/README.entries | 10 ++++++++++ tools/binman/etype/blob_ext.py | 31 ++++++++++++++++++++++++++++++ tools/binman/ftest.py | 12 ++++++++++++ tools/binman/test/157_blob_ext.dts | 14 ++++++++++++++ tools/binman/test/158_blob_ext_missing.dts | 16 +++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 tools/binman/etype/blob_ext.py create mode 100644 tools/binman/test/157_blob_ext.dts create mode 100644 tools/binman/test/158_blob_ext_missing.dts diff --git a/tools/binman/README.entries b/tools/binman/README.entries index 4f2c48fdc2..46f6ab1899 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -42,6 +42,16 @@ obtained from the list of available device-tree files, managed by the +Entry: blob-ext: Entry containing an externally built binary blob +----------------------------------------------------------------- + +Note: This should not be used by itself. It is normally used as a parent +class by other entry types. + +See 'blob' for Properties / Entry arguments. + + + Entry: blob-named-by-arg: A blob entry which gets its filename property from its subclass ----------------------------------------------------------------------------------------- diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py new file mode 100644 index 0000000000..cc8d91bb59 --- /dev/null +++ b/tools/binman/etype/blob_ext.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass +# +# Entry-type module for external blobs, not built by U-Boot +# + +import os + +from binman.etype.blob import Entry_blob +from dtoc import fdt_util +from patman import tools +from patman import tout + +class Entry_blob_ext(Entry_blob): + """Entry containing an externally built binary blob + + Note: This should not be used by itself. It is normally used as a parent + class by other entry types. + + See 'blob' for Properties / Entry arguments. + """ + def __init__(self, section, etype, node): + Entry_blob.__init__(self, section, etype, node) + self.external = True + + def ObtainContents(self): + self._filename = self.GetDefaultFilename() + self._pathname = tools.GetInputFilename(self._filename) + self.ReadBlobContents() + return True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 39e67b9042..f8d5191672 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3364,6 +3364,18 @@ class TestFunctional(unittest.TestCase): # Just check that the data appears in the file somewhere self.assertIn(U_BOOT_SPL_DATA, data) + def testExtblob(self): + """Test an image with an external blob""" + data = self._DoReadFile('157_blob_ext.dts') + self.assertEqual(REFCODE_DATA, data) + + def testExtblobMissing(self): + """Test an image with a missing external blob""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('158_blob_ext_missing.dts') + self.assertIn("Filename 'missing-file' not found in input path", + str(e.exception)) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/157_blob_ext.dts b/tools/binman/test/157_blob_ext.dts new file mode 100644 index 0000000000..8afdd5339e --- /dev/null +++ b/tools/binman/test/157_blob_ext.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + blob-ext { + filename = "refcode.bin"; + }; + }; +}; diff --git a/tools/binman/test/158_blob_ext_missing.dts b/tools/binman/test/158_blob_ext_missing.dts new file mode 100644 index 0000000000..d315e5592e --- /dev/null +++ b/tools/binman/test/158_blob_ext_missing.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <0x80>; + + blob-ext { + filename = "missing-file"; + }; + }; +}; -- cgit From 894f63575574e153ac813b7a1d20bf5d251af2ac Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:37 -0600 Subject: binman: Convert existing binary blobs to blob_ext Many of the existing blobs rely on external binaries which may not be available. Move them over to use blob_ext to indicate this. Unfortunately cros-ec-rw cannot use this class because it inherits another. So set the 'external' value for that class. While we are here, drop the import of Entry since it is not used (and pylint3 complains). Signed-off-by: Simon Glass --- tools/binman/etype/cros_ec_rw.py | 1 + tools/binman/etype/intel_cmc.py | 5 ++--- tools/binman/etype/intel_descriptor.py | 4 ++-- tools/binman/etype/intel_fit.py | 4 ++-- tools/binman/etype/intel_fit_ptr.py | 4 ++-- tools/binman/etype/intel_fsp.py | 5 ++--- tools/binman/etype/intel_fsp_m.py | 5 ++--- tools/binman/etype/intel_fsp_s.py | 5 ++--- tools/binman/etype/intel_fsp_t.py | 5 ++--- tools/binman/etype/intel_ifwi.py | 4 ++-- tools/binman/etype/intel_me.py | 5 ++--- tools/binman/etype/intel_mrc.py | 5 ++--- tools/binman/etype/intel_refcode.py | 5 ++--- tools/binman/etype/intel_vbt.py | 5 ++--- tools/binman/etype/intel_vga.py | 5 ++--- tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py | 1 - 16 files changed, 29 insertions(+), 39 deletions(-) diff --git a/tools/binman/etype/cros_ec_rw.py b/tools/binman/etype/cros_ec_rw.py index 7ad62d0265..741372e1af 100644 --- a/tools/binman/etype/cros_ec_rw.py +++ b/tools/binman/etype/cros_ec_rw.py @@ -19,3 +19,4 @@ class Entry_cros_ec_rw(Entry_blob_named_by_arg): """ def __init__(self, section, etype, node): super().__init__(section, etype, node, 'cros-ec-rw') + self.external = True diff --git a/tools/binman/etype/intel_cmc.py b/tools/binman/etype/intel_cmc.py index 9ab471e7b6..644fa421d3 100644 --- a/tools/binman/etype/intel_cmc.py +++ b/tools/binman/etype/intel_cmc.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Chip Microcode binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_cmc(Entry_blob): +class Entry_intel_cmc(Entry_blob_ext): """Entry containing an Intel Chipset Micro Code (CMC) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_descriptor.py b/tools/binman/etype/intel_descriptor.py index 6afc42ece5..5b18893ccd 100644 --- a/tools/binman/etype/intel_descriptor.py +++ b/tools/binman/etype/intel_descriptor.py @@ -8,7 +8,7 @@ import struct from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext FD_SIGNATURE = struct.pack('> 4) | 0xfff self.size = self.limit - self.base + 1 -class Entry_intel_descriptor(Entry_blob): +class Entry_intel_descriptor(Entry_blob_ext): """Intel flash descriptor block (4KB) Properties / Entry arguments: diff --git a/tools/binman/etype/intel_fit.py b/tools/binman/etype/intel_fit.py index ad6c1caa85..f1a10c55a6 100644 --- a/tools/binman/etype/intel_fit.py +++ b/tools/binman/etype/intel_fit.py @@ -7,9 +7,9 @@ import struct -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fit(Entry_blob): +class Entry_intel_fit(Entry_blob_ext): """Intel Firmware Image Table (FIT) This entry contains a dummy FIT as required by recent Intel CPUs. The FIT diff --git a/tools/binman/etype/intel_fit_ptr.py b/tools/binman/etype/intel_fit_ptr.py index a06d12e740..01f082281c 100644 --- a/tools/binman/etype/intel_fit_ptr.py +++ b/tools/binman/etype/intel_fit_ptr.py @@ -7,9 +7,9 @@ import struct -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fit_ptr(Entry_blob): +class Entry_intel_fit_ptr(Entry_blob_ext): """Intel Firmware Image Table (FIT) pointer This entry contains a pointer to the FIT. It is required to be at address diff --git a/tools/binman/etype/intel_fsp.py b/tools/binman/etype/intel_fsp.py index a1c89adcea..2ac012bce1 100644 --- a/tools/binman/etype/intel_fsp.py +++ b/tools/binman/etype/intel_fsp.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Firmware Support Package binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fsp(Entry_blob): +class Entry_intel_fsp(Entry_blob_ext): """Entry containing an Intel Firmware Support Package (FSP) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_fsp_m.py b/tools/binman/etype/intel_fsp_m.py index 4c225b24d3..434b0f1856 100644 --- a/tools/binman/etype/intel_fsp_m.py +++ b/tools/binman/etype/intel_fsp_m.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Firmware Support Package binary blob (M section) # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fsp_m(Entry_blob): +class Entry_intel_fsp_m(Entry_blob_ext): """Entry containing Intel Firmware Support Package (FSP) memory init Properties / Entry arguments: diff --git a/tools/binman/etype/intel_fsp_s.py b/tools/binman/etype/intel_fsp_s.py index 9e1107182a..564e1228bb 100644 --- a/tools/binman/etype/intel_fsp_s.py +++ b/tools/binman/etype/intel_fsp_s.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Firmware Support Package binary blob (S section) # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fsp_s(Entry_blob): +class Entry_intel_fsp_s(Entry_blob_ext): """Entry containing Intel Firmware Support Package (FSP) silicon init Properties / Entry arguments: diff --git a/tools/binman/etype/intel_fsp_t.py b/tools/binman/etype/intel_fsp_t.py index 5dca145a3f..df0c5fbee0 100644 --- a/tools/binman/etype/intel_fsp_t.py +++ b/tools/binman/etype/intel_fsp_t.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Firmware Support Package binary blob (T section) # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_fsp_t(Entry_blob): +class Entry_intel_fsp_t(Entry_blob_ext): """Entry containing Intel Firmware Support Package (FSP) temp ram init Properties / Entry arguments: diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py index ba63f6574f..b0c2b1aaa3 100644 --- a/tools/binman/etype/intel_ifwi.py +++ b/tools/binman/etype/intel_ifwi.py @@ -8,11 +8,11 @@ from collections import OrderedDict from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext from dtoc import fdt_util from patman import tools -class Entry_intel_ifwi(Entry_blob): +class Entry_intel_ifwi(Entry_blob_ext): """Entry containing an Intel Integrated Firmware Image (IFWI) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_me.py b/tools/binman/etype/intel_me.py index 6b3803819e..a6fe5427f3 100644 --- a/tools/binman/etype/intel_me.py +++ b/tools/binman/etype/intel_me.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Management Engine binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_me(Entry_blob): +class Entry_intel_me(Entry_blob_ext): """Entry containing an Intel Management Engine (ME) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_mrc.py b/tools/binman/etype/intel_mrc.py index 74781848e2..ccbb046519 100644 --- a/tools/binman/etype/intel_mrc.py +++ b/tools/binman/etype/intel_mrc.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Memory Reference Code binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_mrc(Entry_blob): +class Entry_intel_mrc(Entry_blob_ext): """Entry containing an Intel Memory Reference Code (MRC) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_refcode.py b/tools/binman/etype/intel_refcode.py index 5754fec4f8..5ead08b2be 100644 --- a/tools/binman/etype/intel_refcode.py +++ b/tools/binman/etype/intel_refcode.py @@ -5,10 +5,9 @@ # Entry-type module for Intel Memory Reference Code binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_refcode(Entry_blob): +class Entry_intel_refcode(Entry_blob_ext): """Entry containing an Intel Reference Code file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_vbt.py b/tools/binman/etype/intel_vbt.py index f6d7b466ea..2a98c12368 100644 --- a/tools/binman/etype/intel_vbt.py +++ b/tools/binman/etype/intel_vbt.py @@ -4,10 +4,9 @@ # Entry-type module for Intel Video BIOS Table binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_vbt(Entry_blob): +class Entry_intel_vbt(Entry_blob_ext): """Entry containing an Intel Video BIOS Table (VBT) file Properties / Entry arguments: diff --git a/tools/binman/etype/intel_vga.py b/tools/binman/etype/intel_vga.py index 6b87c01b4c..a103f1ce0e 100644 --- a/tools/binman/etype/intel_vga.py +++ b/tools/binman/etype/intel_vga.py @@ -5,10 +5,9 @@ # Entry-type module for x86 VGA ROM binary blob # -from binman.entry import Entry -from binman.etype.blob import Entry_blob +from binman.etype.blob_ext import Entry_blob_ext -class Entry_intel_vga(Entry_blob): +class Entry_intel_vga(Entry_blob_ext): """Entry containing an Intel Video Graphics Adaptor (VGA) file Properties / Entry arguments: diff --git a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py index b0fa75fbf8..3a92fa399f 100644 --- a/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py +++ b/tools/binman/etype/powerpc_mpc85xx_bootpg_resetvec.py @@ -4,7 +4,6 @@ # Entry-type module for the PowerPC mpc85xx bootpg and resetvec code for U-Boot # -from binman.entry import Entry from binman.etype.blob import Entry_blob class Entry_powerpc_mpc85xx_bootpg_resetvec(Entry_blob): -- cgit From 5f850fb9a62659edaa81167a4acc879c0ea104fc Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:38 -0600 Subject: binman: Allow external binaries to be missing Sometimes it is useful to build an image even though external binaries are not present. This allows the build system to continue to function without these files, albeit not producing valid images. U-Boot does with with ATF (ARM Trusted Firmware) today. Add a new flag to binman to request this behaviour. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/README.entries | 3 +++ tools/binman/cmdline.py | 2 ++ tools/binman/control.py | 7 +++++-- tools/binman/entry.py | 9 +++++++++ tools/binman/etype/blob_ext.py | 13 ++++++++++--- tools/binman/etype/section.py | 24 ++++++++++++++++++++++++ tools/binman/ftest.py | 8 +++++++- tools/patman/tools.py | 8 ++++++-- 8 files changed, 66 insertions(+), 8 deletions(-) diff --git a/tools/binman/README.entries b/tools/binman/README.entries index 46f6ab1899..f45f51428a 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -48,6 +48,9 @@ Entry: blob-ext: Entry containing an externally built binary blob Note: This should not be used by itself. It is normally used as a parent class by other entry types. +If the file providing this blob is missing, binman can optionally ignore it +and produce a broken image with a warning. + See 'blob' for Properties / Entry arguments. diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py index 1e38593579..bb4d9d1288 100644 --- a/tools/binman/cmdline.py +++ b/tools/binman/cmdline.py @@ -53,6 +53,8 @@ controlled by a description in the board device tree.''' help='Add a path to the list of directories to use for input files') build_parser.add_argument('-m', '--map', action='store_true', default=False, help='Output a map file for each image') + build_parser.add_argument('-M', '--allow-missing', action='store_true', + default=False, help='Allow external blobs to be missing') build_parser.add_argument('-O', '--outdir', type=str, action='store', help='Path to directory to use for intermediate and ' 'output files') diff --git a/tools/binman/control.py b/tools/binman/control.py index dc1dd2a7dc..8c6eae83f1 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -387,7 +387,7 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt): def ProcessImage(image, update_fdt, write_map, get_contents=True, - allow_resize=True): + allow_resize=True, allow_missing=False): """Perform all steps for this image, including checking and # writing it. This means that errors found with a later image will be reported after @@ -402,8 +402,10 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, the contents is already present allow_resize: True to allow entries to change size (this does a re-pack of the entries), False to raise an exception + allow_missing: Allow blob_ext objects to be missing """ if get_contents: + image.SetAllowMissing(allow_missing) image.GetEntryContents() image.GetEntryOffsets() @@ -523,7 +525,8 @@ def Binman(args): images = PrepareImagesAndDtbs(dtb_fname, args.image, args.update_fdt) for image in images.values(): - ProcessImage(image, args.update_fdt, args.map) + ProcessImage(image, args.update_fdt, args.map, + allow_missing=args.allow_missing) # Write the updated FDTs to our output files for dtb_item in state.GetAllFdts(): diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 90ffd27617..9388586e7c 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -794,3 +794,12 @@ features to produce new behaviours. elif self == entries[-1]: return 'end' return 'middle' + + def SetAllowMissing(self, allow_missing): + """Set whether a section allows missing external blobs + + Args: + allow_missing: True if allowed, False if not allowed + """ + # This is meaningless for anything other than sections + pass diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py index cc8d91bb59..51779c88c9 100644 --- a/tools/binman/etype/blob_ext.py +++ b/tools/binman/etype/blob_ext.py @@ -18,6 +18,9 @@ class Entry_blob_ext(Entry_blob): Note: This should not be used by itself. It is normally used as a parent class by other entry types. + If the file providing this blob is missing, binman can optionally ignore it + and produce a broken image with a warning. + See 'blob' for Properties / Entry arguments. """ def __init__(self, section, etype, node): @@ -26,6 +29,10 @@ class Entry_blob_ext(Entry_blob): def ObtainContents(self): self._filename = self.GetDefaultFilename() - self._pathname = tools.GetInputFilename(self._filename) - self.ReadBlobContents() - return True + self._pathname = tools.GetInputFilename(self._filename, + self.section.GetAllowMissing()) + # Allow the file to be missing + if not self._pathname: + self.SetContents(b'') + return True + return super().ObtainContents() diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index f108121c3a..9b718f1fa7 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -34,6 +34,11 @@ class Entry_section(Entry): name-prefix: Adds a prefix to the name of every entry in the section when writing out the map + Properties: + _allow_missing: True if this section permits external blobs to be + missing their contents. The second will produce an image but of + course it will not work. + Since a section is also an entry, it inherits all the properies of entries too. @@ -49,6 +54,7 @@ class Entry_section(Entry): self._sort = False self._skip_at_start = None self._end_4gb = False + self._allow_missing = False def ReadNode(self): """Read properties from the image node""" @@ -535,3 +541,21 @@ class Entry_section(Entry): def WriteChildData(self, child): return True + + def SetAllowMissing(self, allow_missing): + """Set whether a section allows missing external blobs + + Args: + allow_missing: True if allowed, False if not allowed + """ + self._allow_missing = allow_missing + for entry in self._entries.values(): + entry.SetAllowMissing(allow_missing) + + def GetAllowMissing(self): + """Get whether a section allows missing external blobs + + Returns: + True if allowed, False if not allowed + """ + return self._allow_missing diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index f8d5191672..7c8b3eb3a0 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -285,7 +285,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, - verbosity=None): + verbosity=None, allow_missing=False): """Run binman with a given test file Args: @@ -319,6 +319,8 @@ class TestFunctional(unittest.TestCase): if entry_args: for arg, value in entry_args.items(): args.append('-a%s=%s' % (arg, value)) + if allow_missing: + args.append('-M') if images: for image in images: args += ['-i', image] @@ -3376,6 +3378,10 @@ class TestFunctional(unittest.TestCase): self.assertIn("Filename 'missing-file' not found in input path", str(e.exception)) + def testExtblobMissingOk(self): + """Test an image with an missing external blob that is allowed""" + self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True) + if __name__ == "__main__": unittest.main() diff --git a/tools/patman/tools.py b/tools/patman/tools.py index f402b9aab8..d41115a22c 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -114,14 +114,16 @@ def SetInputDirs(dirname): indir = dirname tout.Debug("Using input directories %s" % indir) -def GetInputFilename(fname): +def GetInputFilename(fname, allow_missing=False): """Return a filename for use as input. Args: fname: Filename to use for new file + allow_missing: True if the filename can be missing Returns: - The full path of the filename, within the input directory + The full path of the filename, within the input directory, or + None on error """ if not indir or fname[:1] == '/': return fname @@ -130,6 +132,8 @@ def GetInputFilename(fname): if os.path.exists(pathname): return pathname + if allow_missing: + return None raise ValueError("Filename '%s' not found in input path (%s) (cwd='%s')" % (fname, ','.join(indir), os.getcwd())) -- cgit From f9793a12c5e76c50018d516cbaa011ac86c285fa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:39 -0600 Subject: patman: Update errors and warnings to use stderr When warnings and errors are produced by tools they should be written to stderr. Update the tout implementation to handle this. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/ftest.py | 2 +- tools/patman/tout.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 7c8b3eb3a0..928d3608a3 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3232,7 +3232,7 @@ class TestFunctional(unittest.TestCase): with test_util.capture_sys_output() as (stdout, stderr): control.ReplaceEntries(updated_fname, None, outdir, []) self.assertIn("Skipping entry '/u-boot' from missing file", - stdout.getvalue()) + stderr.getvalue()) def testReplaceCmdMap(self): """Test replacing a file fron an image on the command line""" diff --git a/tools/patman/tout.py b/tools/patman/tout.py index c7e3272096..91a53f4073 100644 --- a/tools/patman/tout.py +++ b/tools/patman/tout.py @@ -83,7 +83,10 @@ def _Output(level, msg, color=None): ClearProgress() if color: msg = _color.Color(color, msg) - print(msg) + if level < NOTICE: + print(msg, file=sys.stderr) + else: + print(msg) def DoOutput(level, msg): """Output a message to the terminal. -- cgit From 13262c93626502873786067fcbe2e2ab5894b90f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:40 -0600 Subject: binman: Detect when valid images are not produced When external blobs are missing, show a message indicating that the images are not functional. Signed-off-by: Simon Glass --- tools/binman/control.py | 16 ++++++++++++++-- tools/binman/entry.py | 12 ++++++++++++ tools/binman/etype/blob_ext.py | 1 + tools/binman/etype/section.py | 12 ++++++++++++ tools/binman/ftest.py | 14 +++++++++++++- tools/binman/test/159_blob_ext_missing_sect.dts | 23 +++++++++++++++++++++++ tools/patman/tout.py | 1 + 7 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 tools/binman/test/159_blob_ext_missing_sect.dts diff --git a/tools/binman/control.py b/tools/binman/control.py index 8c6eae83f1..343b0a0c35 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -403,6 +403,9 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, allow_resize: True to allow entries to change size (this does a re-pack of the entries), False to raise an exception allow_missing: Allow blob_ext objects to be missing + + Returns: + True if one or more external blobs are missing, False if all are present """ if get_contents: image.SetAllowMissing(allow_missing) @@ -450,6 +453,12 @@ def ProcessImage(image, update_fdt, write_map, get_contents=True, image.BuildImage() if write_map: image.WriteMap() + missing_list = [] + image.CheckMissing(missing_list) + if missing_list: + tout.Warning("Image '%s' is missing external blobs and is non-functional: %s" % + (image.name, ' '.join([e.name for e in missing_list]))) + return bool(missing_list) def Binman(args): @@ -524,14 +533,17 @@ def Binman(args): images = PrepareImagesAndDtbs(dtb_fname, args.image, args.update_fdt) + missing = False for image in images.values(): - ProcessImage(image, args.update_fdt, args.map, - allow_missing=args.allow_missing) + missing |= ProcessImage(image, args.update_fdt, args.map, + allow_missing=args.allow_missing) # Write the updated FDTs to our output files for dtb_item in state.GetAllFdts(): tools.WriteFile(dtb_item._fname, dtb_item.GetContents()) + if missing: + tout.Warning("Some images are invalid") finally: tools.FinaliseOutputDir() finally: diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 9388586e7c..3434a3f804 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -84,6 +84,7 @@ class Entry(object): self.image_pos = None self._expand_size = False self.compress = 'none' + self.missing = False @staticmethod def Lookup(node_path, etype): @@ -803,3 +804,14 @@ features to produce new behaviours. """ # This is meaningless for anything other than sections pass + + def CheckMissing(self, missing_list): + """Check if any entries in this section have missing external blobs + + If there are missing blobs, the entries are added to the list + + Args: + missing_list: List of Entry objects to be added to + """ + if self.missing: + missing_list.append(self) diff --git a/tools/binman/etype/blob_ext.py b/tools/binman/etype/blob_ext.py index 51779c88c9..8d641001a9 100644 --- a/tools/binman/etype/blob_ext.py +++ b/tools/binman/etype/blob_ext.py @@ -34,5 +34,6 @@ class Entry_blob_ext(Entry_blob): # Allow the file to be missing if not self._pathname: self.SetContents(b'') + self.missing = True return True return super().ObtainContents() diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 9b718f1fa7..dd7f1ccd09 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -55,6 +55,7 @@ class Entry_section(Entry): self._skip_at_start = None self._end_4gb = False self._allow_missing = False + self.missing = False def ReadNode(self): """Read properties from the image node""" @@ -559,3 +560,14 @@ class Entry_section(Entry): True if allowed, False if not allowed """ return self._allow_missing + + def CheckMissing(self, missing_list): + """Check if any entries in this section have missing external blobs + + If there are missing blobs, the entries are added to the list + + Args: + missing_list: List of Entry objects to be added to + """ + for entry in self._entries.values(): + entry.CheckMissing(missing_list) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 928d3608a3..cc551c9f17 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3380,7 +3380,19 @@ class TestFunctional(unittest.TestCase): def testExtblobMissingOk(self): """Test an image with an missing external blob that is allowed""" - self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True) + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True) + err = stderr.getvalue() + self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext") + + def testExtblobMissingOkSect(self): + """Test an image with an missing external blob that is allowed""" + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('159_blob_ext_missing_sect.dts', + allow_missing=True) + err = stderr.getvalue() + self.assertRegex(err, "Image 'main-section'.*missing.*: " + "blob-ext blob-ext2") if __name__ == "__main__": diff --git a/tools/binman/test/159_blob_ext_missing_sect.dts b/tools/binman/test/159_blob_ext_missing_sect.dts new file mode 100644 index 0000000000..5f14c54138 --- /dev/null +++ b/tools/binman/test/159_blob_ext_missing_sect.dts @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <0x80>; + + section { + blob-ext { + filename = "missing-file"; + }; + }; + + blob-ext2 { + type = "blob-ext"; + filename = "missing-file2"; + }; + }; +}; diff --git a/tools/patman/tout.py b/tools/patman/tout.py index 91a53f4073..33305263d8 100644 --- a/tools/patman/tout.py +++ b/tools/patman/tout.py @@ -171,6 +171,7 @@ def Init(_verbose=WARNING, stdout=sys.stdout): # TODO(sjg): Move this into Chromite libraries when we have them stdout_is_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + stderr_is_tty = hasattr(sys.stderr, 'isatty') and sys.stderr.isatty() def Uninit(): ClearProgress() -- cgit From 2f5c3a4d1d1f57cc7d3bcb9a6b1a509d399cade1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:41 -0600 Subject: binman: Allow missing Intel blobs Update the Intel blob entries to support missing binaries. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/etype/intel_descriptor.py | 7 +++++- tools/binman/etype/intel_ifwi.py | 17 ++++++++++---- tools/binman/etype/section.py | 4 ++-- tools/binman/ftest.py | 41 ++++++++++++++++++++++++++++------ 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/tools/binman/etype/intel_descriptor.py b/tools/binman/etype/intel_descriptor.py index 5b18893ccd..7fe88a9ec1 100644 --- a/tools/binman/etype/intel_descriptor.py +++ b/tools/binman/etype/intel_descriptor.py @@ -55,6 +55,12 @@ class Entry_intel_descriptor(Entry_blob_ext): return super().Pack(offset) def GetOffsets(self): + info = {} + if self.missing: + # Return zero offsets so that these entries get placed somewhere + if self.HasSibling('intel-me'): + info['intel-me'] = [0, None] + return info offset = self.data.find(FD_SIGNATURE) if offset == -1: self.Raise('Cannot find Intel Flash Descriptor (FD) signature') @@ -66,7 +72,6 @@ class Entry_intel_descriptor(Entry_blob_ext): # Set the offset for ME (Management Engine) and IFWI (Integrated # Firmware Image), for now, since the others are not used. - info = {} if self.HasSibling('intel-me'): info['intel-me'] = [self._regions[REGION_ME].base, self._regions[REGION_ME].size] diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py index b0c2b1aaa3..76b3357c25 100644 --- a/tools/binman/etype/intel_ifwi.py +++ b/tools/binman/etype/intel_ifwi.py @@ -84,7 +84,7 @@ class Entry_intel_ifwi(Entry_blob_ext): return True def ObtainContents(self): - """Get the contects for the IFWI + """Get the contents for the IFWI Unfortunately we cannot create anything from scratch here, as Intel has tools which create precursor binaries with lots of data and settings, @@ -97,13 +97,21 @@ class Entry_intel_ifwi(Entry_blob_ext): After that we delete the OBBP sub-partition and add each of the files that we want in the IFWI file, one for each sub-entry of the IWFI node. """ - self._pathname = tools.GetInputFilename(self._filename) + self._pathname = tools.GetInputFilename(self._filename, + self.section.GetAllowMissing()) + # Allow the file to be missing + if not self._pathname: + self.SetContents(b'') + self.missing = True + return True for entry in self._ifwi_entries.values(): if not entry.ObtainContents(): return False return self._BuildIfwi() def ProcessContents(self): + if self.missing: + return True orig_data = self.data self._BuildIfwi() same = orig_data == self.data @@ -121,5 +129,6 @@ class Entry_intel_ifwi(Entry_blob_ext): def WriteSymbols(self, section): """Write symbol values into binary files for access at run time""" - for entry in self._ifwi_entries.values(): - entry.WriteSymbols(self) + if not self.missing: + for entry in self._ifwi_entries.values(): + entry.WriteSymbols(self) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index dd7f1ccd09..7cd12c0204 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -442,8 +442,8 @@ class Entry_section(Entry): if not entry: self._Raise("Unable to set offset/size for unknown entry '%s'" % name) - entry.SetOffsetSize(self._skip_at_start + offset if offset else None, - size) + entry.SetOffsetSize(self._skip_at_start + offset if offset is not None + else None, size) def GetEntryOffsets(self): """Handle entries that want to set the offset/size of other entries diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index cc551c9f17..146d4c51d3 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -160,8 +160,7 @@ class TestFunctional(unittest.TestCase): tools.ReadFile(cls.ElfTestFile('u_boot_ucode_ptr'))) # Intel flash descriptor file - with open(cls.TestFile('descriptor.bin'), 'rb') as fd: - TestFunctional._MakeInputFile('descriptor.bin', fd.read()) + cls._SetupDescriptor() shutil.copytree(cls.TestFile('files'), os.path.join(cls._indir, 'files')) @@ -507,6 +506,11 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('tpl/u-boot-tpl', tools.ReadFile(cls.ElfTestFile(src_fname))) + @classmethod + def _SetupDescriptor(cls): + with open(cls.TestFile('descriptor.bin'), 'rb') as fd: + TestFunctional._MakeInputFile('descriptor.bin', fd.read()) + @classmethod def TestFile(cls, fname): return os.path.join(cls._binman_dir, 'test', fname) @@ -933,11 +937,14 @@ class TestFunctional(unittest.TestCase): def testPackX86RomMeNoDesc(self): """Test that an invalid Intel descriptor entry is detected""" - TestFunctional._MakeInputFile('descriptor.bin', b'') - with self.assertRaises(ValueError) as e: - self._DoTestFile('031_x86_rom_me.dts') - self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature", - str(e.exception)) + try: + TestFunctional._MakeInputFile('descriptor.bin', b'') + with self.assertRaises(ValueError) as e: + self._DoTestFile('031_x86_rom_me.dts') + self.assertIn("Node '/binman/intel-descriptor': Cannot find Intel Flash Descriptor (FD) signature", + str(e.exception)) + finally: + self._SetupDescriptor() def testPackX86RomBadDesc(self): """Test that the Intel requires a descriptor entry""" @@ -3394,6 +3401,26 @@ class TestFunctional(unittest.TestCase): self.assertRegex(err, "Image 'main-section'.*missing.*: " "blob-ext blob-ext2") + def testPackX86RomMeMissingDesc(self): + """Test that an missing Intel descriptor entry is allowed""" + pathname = os.path.join(self._indir, 'descriptor.bin') + os.remove(pathname) + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('031_x86_rom_me.dts', allow_missing=True) + err = stderr.getvalue() + self.assertRegex(err, + "Image 'main-section'.*missing.*: intel-descriptor") + + def testPackX86RomMissingIfwi(self): + """Test that an x86 ROM with Integrated Firmware Image can be created""" + self._SetupIfwi('fitimage.bin') + pathname = os.path.join(self._indir, 'fitimage.bin') + os.remove(pathname) + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('111_x86_rom_ifwi.dts', allow_missing=True) + err = stderr.getvalue() + self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi") + if __name__ == "__main__": unittest.main() -- cgit From 8200d8871a6a87834e26e38ca5cd475f86733dfd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:42 -0600 Subject: binman: Allow zero-length entries to overlap Some binary blobs unfortunately obtain their position in the image from other binary blobs, such as Intel's 'descriptor'. In this case we cannot rely on packing to work. It is not possible to produce a valid image in any case, due to the missing blobs. Allow zero-length overlaps so that this does not cause any problems. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- tools/binman/etype/section.py | 2 +- tools/binman/ftest.py | 4 ++++ tools/binman/test/160_pack_overlap_zero.dts | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/160_pack_overlap_zero.dts diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 7cd12c0204..73c5553c81 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -226,7 +226,7 @@ class Entry_section(Entry): "at %#x (%d)" % (entry.offset, entry.offset, self._skip_at_start, self._skip_at_start)) - if entry.offset < offset: + if entry.offset < offset and entry.size: entry.Raise("Offset %#x (%d) overlaps with previous entry '%s' " "ending at %#x (%d)" % (entry.offset, entry.offset, prev_name, offset, offset)) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 146d4c51d3..614ac4ed39 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -3421,6 +3421,10 @@ class TestFunctional(unittest.TestCase): err = stderr.getvalue() self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi") + def testPackOverlap(self): + """Test that zero-size overlapping regions are ignored""" + self._DoTestFile('160_pack_overlap_zero.dts') + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/160_pack_overlap_zero.dts b/tools/binman/test/160_pack_overlap_zero.dts new file mode 100644 index 0000000000..731aa1cbe6 --- /dev/null +++ b/tools/binman/test/160_pack_overlap_zero.dts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + + fill { + size = <0>; + offset = <3>; + }; + }; +}; -- cgit From 4c63d21754a2583df1d85d3af6f0a5bf5c300d20 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:43 -0600 Subject: mkimage: Allow updating the FIT timestamp Normally the FIT timestamp is created the first time mkimage is run on a FIT, when converting the source .its to the binary .fit file. This corresponds to using the -f flag. But if the original input to mkimage is a binary file (already compiled) then the timestamp is assumed to have been set previously. Add a -t flag to allow setting the timestamp in this case. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- doc/mkimage.1 | 9 +++++++++ tools/fit_image.c | 2 +- tools/imagetool.h | 1 + tools/mkimage.c | 5 ++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/mkimage.1 b/doc/mkimage.1 index 3dcdcedcef..fea5288784 100644 --- a/doc/mkimage.1 +++ b/doc/mkimage.1 @@ -167,6 +167,15 @@ Specifies that keys used to sign the FIT are required. This means that they must be verified for the image to boot. Without this option, the verification will be optional (useful for testing but not for release). +.TP +.BI "\-t +Update the timestamp in the FIT. + +Normally the FIT timestamp is created the first time mkimage is run on a FIT, +when converting the source .its to the binary .fit file. This corresponds to +using the -f flag. But if the original input to mkimage is a binary file +(already compiled) then the timestamp is assumed to have been set previously. + .SH EXAMPLES List image information: diff --git a/tools/fit_image.c b/tools/fit_image.c index a082d9386d..df310b53da 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -53,7 +53,7 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc, } /* for first image creation, add a timestamp at offset 0 i.e., root */ - if (params->datafile) { + if (params->datafile || params->reset_timestamp) { time_t time = imagetool_get_source_date(params->cmdname, sbuf.st_mtime); ret = fit_set_timestamp(ptr, 0, time); diff --git a/tools/imagetool.h b/tools/imagetool.h index f54809cd57..acbc48e9be 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -81,6 +81,7 @@ struct image_tool_params { unsigned int external_offset; /* Add padding to external data */ int bl_len; /* Block length in byte for external data */ const char *engine_id; /* Engine to use for signing */ + bool reset_timestamp; /* Reset the timestamp on an existing image */ }; /* diff --git a/tools/mkimage.c b/tools/mkimage.c index 7cb666d482..43078d075c 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -145,7 +145,7 @@ static void process_args(int argc, char **argv) int opt; while ((opt = getopt(argc, argv, - "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) { + "a:A:b:B:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qstT:vVx")) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); @@ -269,6 +269,9 @@ static void process_args(int argc, char **argv) case 's': params.skipcpy = 1; break; + case 't': + params.reset_timestamp = 1; + break; case 'T': if (strcmp(optarg, "list") == 0) { show_valid_options(IH_TYPE); -- cgit From 1f238bd5bdc35d996751ed4b8faf8b4c4e69f68d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:44 -0600 Subject: dtoc: Allow adding variable-sized data to a dtb Add a method for adding a property containing arbitrary bytes. Make sure that the tree can expand as needed in this case. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 17 +++++++++++++++-- tools/dtoc/test_fdt.py | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 188490b728..d058c59e92 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -207,7 +207,8 @@ class Prop: if auto_resize: while fdt_obj.setprop(node.Offset(), self.name, self.bytes, (libfdt.NOSPACE,)) == -libfdt.NOSPACE: - fdt_obj.resize(fdt_obj.totalsize() + 1024) + fdt_obj.resize(fdt_obj.totalsize() + 1024 + + len(self.bytes)) fdt_obj.setprop(node.Offset(), self.name, self.bytes) else: fdt_obj.setprop(node.Offset(), self.name, self.bytes) @@ -410,6 +411,18 @@ class Node: val = val.encode('utf-8') self._CheckProp(prop_name).props[prop_name].SetData(val + b'\0') + def AddData(self, prop_name, val): + """Add a new property to a node + + The device tree is marked dirty so that the value will be written to + the blob on the next sync. + + Args: + prop_name: Name of property to add + val: Bytes value of property + """ + self.props[prop_name] = Prop(self, None, prop_name, val) + def AddString(self, prop_name, val): """Add a new string property to a node @@ -422,7 +435,7 @@ class Node: """ if sys.version_info[0] >= 3: # pragma: no cover val = bytes(val, 'utf-8') - self.props[prop_name] = Prop(self, None, prop_name, val + b'\0') + self.AddData(prop_name, val + b'\0') def AddSubnode(self, name): """Add a new subnode to the node diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 375e906424..b4f9b7f498 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -417,6 +417,10 @@ class TestProp(unittest.TestCase): self.node.SetData('empty', b'123') self.assertEqual(b'123', prop.bytes) + # Trying adding a lot of data at once + self.node.AddData('data', tools.GetBytes(65, 20000)) + self.dtb.Sync(auto_resize=True) + def testFromData(self): dtb2 = fdt.Fdt.FromData(self.dtb.GetContents()) self.assertEqual(dtb2.GetContents(), self.dtb.GetContents()) -- cgit From 3b9a87321cf5f40ad4c8dac535f94b0cbde19ce2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:45 -0600 Subject: binman: Add support for generating a FIT FIT (Flat Image Tree) is the main image format used by U-Boot. In some cases scripts are used to create FITs within the U-Boot build system. This is not ideal for various reasons: - Each architecture has its own slightly different script - There are no tests - Some are written in shell, some in Python To help address this, add support for FIT generation to binman. This works by putting the FIT source directly in the binman definition, with the ability to adjust parameters, etc. The contents of each FIT image come from sub-entries of the image, as is normal with binman. Signed-off-by: Simon Glass --- tools/binman/README.entries | 40 ++++++++ tools/binman/etype/fit.py | 164 +++++++++++++++++++++++++++++++++ tools/binman/ftest.py | 54 +++++++++++ tools/binman/test/161_fit.dts | 62 +++++++++++++ tools/binman/test/162_fit_external.dts | 64 +++++++++++++ 5 files changed, 384 insertions(+) create mode 100644 tools/binman/etype/fit.py create mode 100644 tools/binman/test/161_fit.dts create mode 100644 tools/binman/test/162_fit_external.dts diff --git a/tools/binman/README.entries b/tools/binman/README.entries index f45f51428a..bf8edce02b 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -311,6 +311,46 @@ byte value of a region. +Entry: fit: Entry containing a FIT +---------------------------------- + +This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the +input provided. + +Nodes for the FIT should be written out in the binman configuration just as +they would be in a file passed to mkimage. + +For example, this creates an image containing a FIT with U-Boot SPL: + + binman { + fit { + description = "Test FIT"; + + images { + kernel@1 { + description = "SPL"; + os = "u-boot"; + type = "rkspi"; + arch = "arm"; + compression = "none"; + load = <0>; + entry = <0>; + + u-boot-spl { + }; + }; + }; + }; + }; + +Properties: + fit,external-offset: Indicates that the contents of the FIT are external + and provides the external offset. This is passsed to mkimage via + the -E and -p flags. + + + + Entry: fmap: An entry which contains an Fmap section ---------------------------------------------------- diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py new file mode 100644 index 0000000000..75712f4409 --- /dev/null +++ b/tools/binman/etype/fit.py @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass +# +# Entry-type module for producing a FIT +# + +from collections import defaultdict, OrderedDict +import libfdt + +from binman.entry import Entry +from dtoc import fdt_util +from dtoc.fdt import Fdt +from patman import tools + +class Entry_fit(Entry): + """Entry containing a FIT + + This calls mkimage to create a FIT (U-Boot Flat Image Tree) based on the + input provided. + + Nodes for the FIT should be written out in the binman configuration just as + they would be in a file passed to mkimage. + + For example, this creates an image containing a FIT with U-Boot SPL: + + binman { + fit { + description = "Test FIT"; + + images { + kernel@1 { + description = "SPL"; + os = "u-boot"; + type = "rkspi"; + arch = "arm"; + compression = "none"; + load = <0>; + entry = <0>; + + u-boot-spl { + }; + }; + }; + }; + }; + + Properties: + fit,external-offset: Indicates that the contents of the FIT are external + and provides the external offset. This is passsed to mkimage via + the -E and -p flags. + + """ + def __init__(self, section, etype, node): + """ + Members: + _fit: FIT file being built + _fit_content: dict: + key: relative path to entry Node (from the base of the FIT) + value: List of Entry objects comprising the contents of this + node + """ + super().__init__(section, etype, node) + self._fit = None + self._fit_content = defaultdict(list) + self._fit_props = {} + + def ReadNode(self): + self._ReadSubnodes() + super().ReadNode() + + def _ReadSubnodes(self): + def _AddNode(base_node, depth, node): + """Add a node to the FIT + + Args: + base_node: Base Node of the FIT (with 'description' property) + depth: Current node depth (0 is the base node) + node: Current node to process + + There are two cases to deal with: + - hash and signature nodes which become part of the FIT + - binman entries which are used to define the 'data' for each + image + """ + for pname, prop in node.props.items(): + if pname.startswith('fit,'): + self._fit_props[pname] = prop + else: + fsw.property(pname, prop.bytes) + + rel_path = node.path[len(base_node.path):] + has_images = depth == 2 and rel_path.startswith('/images/') + for subnode in node.subnodes: + if has_images and not (subnode.name.startswith('hash') or + subnode.name.startswith('signature')): + # This is a content node. We collect all of these together + # and put them in the 'data' property. They do not appear + # in the FIT. + entry = Entry.Create(self.section, subnode) + entry.ReadNode() + self._fit_content[rel_path].append(entry) + else: + with fsw.add_node(subnode.name): + _AddNode(base_node, depth + 1, subnode) + + # Build a new tree with all nodes and properties starting from the + # entry node + fsw = libfdt.FdtSw() + fsw.finish_reservemap() + with fsw.add_node(''): + _AddNode(self._node, 0, self._node) + fdt = fsw.as_fdt() + + # Pack this new FDT and scan it so we can add the data later + fdt.pack() + self._fdt = Fdt.FromData(fdt.as_bytearray()) + self._fdt.Scan() + + def ObtainContents(self): + """Obtain the contents of the FIT + + This adds the 'data' properties to the input ITB (Image-tree Binary) + then runs mkimage to process it. + """ + data = self._BuildInput(self._fdt) + if data == False: + return False + uniq = self.GetUniqueName() + input_fname = tools.GetOutputFilename('%s.itb' % uniq) + output_fname = tools.GetOutputFilename('%s.fit' % uniq) + tools.WriteFile(input_fname, data) + tools.WriteFile(output_fname, data) + + args = [] + ext_offset = self._fit_props.get('fit,external-offset') + if ext_offset is not None: + args += ['-E', '-p', '%x' % fdt_util.fdt32_to_cpu(ext_offset.value)] + tools.Run('mkimage', '-t', '-F', output_fname, *args) + + self.SetContents(tools.ReadFile(output_fname)) + return True + + def _BuildInput(self, fdt): + """Finish the FIT by adding the 'data' properties to it + + Arguments: + fdt: FIT to update + + Returns: + New fdt contents (bytes) + """ + for path, entries in self._fit_content.items(): + node = fdt.GetNode(path) + data = b'' + for entry in entries: + if not entry.ObtainContents(): + return False + data += entry.GetData() + node.AddData('data', data) + + fdt.Sync(auto_resize=True) + data = fdt.GetContents() + return data diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 614ac4ed39..ea72eff8c5 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6,10 +6,12 @@ # # python -m unittest func_test.TestFunctional.testHelp +import collections import gzip import hashlib from optparse import OptionParser import os +import re import shutil import struct import sys @@ -3425,6 +3427,58 @@ class TestFunctional(unittest.TestCase): """Test that zero-size overlapping regions are ignored""" self._DoTestFile('160_pack_overlap_zero.dts') + def testSimpleFit(self): + """Test an image with a FIT inside""" + data = self._DoReadFile('161_fit.dts') + self.assertEqual(U_BOOT_DATA, data[:len(U_BOOT_DATA)]) + self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):]) + fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)] + + # The data should be inside the FIT + dtb = fdt.Fdt.FromData(fit_data) + dtb.Scan() + fnode = dtb.GetNode('/images/kernel') + self.assertIn('data', fnode.props) + + fname = os.path.join(self._indir, 'fit_data.fit') + tools.WriteFile(fname, fit_data) + out = tools.Run('dumpimage', '-l', fname) + + # Check a few features to make sure the plumbing works. We don't need + # to test the operation of mkimage or dumpimage here. First convert the + # output into a dict where the keys are the fields printed by dumpimage + # and the values are a list of values for each field + lines = out.splitlines() + + # Converts "Compression: gzip compressed" into two groups: + # 'Compression' and 'gzip compressed' + re_line = re.compile(r'^ *([^:]*)(?:: *(.*))?$') + vals = collections.defaultdict(list) + for line in lines: + mat = re_line.match(line) + vals[mat.group(1)].append(mat.group(2)) + + self.assertEquals('FIT description: test-desc', lines[0]) + self.assertIn('Created:', lines[1]) + self.assertIn('Image 0 (kernel)', vals) + self.assertIn('Hash value', vals) + data_sizes = vals.get('Data Size') + self.assertIsNotNone(data_sizes) + self.assertEqual(2, len(data_sizes)) + # Format is "4 Bytes = 0.00 KiB = 0.00 MiB" so take the first word + self.assertEqual(len(U_BOOT_DATA), int(data_sizes[0].split()[0])) + self.assertEqual(len(U_BOOT_SPL_DTB_DATA), int(data_sizes[1].split()[0])) + + def testFitExternal(self): + """Test an image with an FIT""" + data = self._DoReadFile('162_fit_external.dts') + fit_data = data[len(U_BOOT_DATA):-2] # _testing is 2 bytes + + # The data should be outside the FIT + dtb = fdt.Fdt.FromData(fit_data) + dtb.Scan() + fnode = dtb.GetNode('/images/kernel') + self.assertNotIn('data', fnode.props) if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/161_fit.dts b/tools/binman/test/161_fit.dts new file mode 100644 index 0000000000..c52d760b73 --- /dev/null +++ b/tools/binman/test/161_fit.dts @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + fit { + description = "test-desc"; + #address-cells = <1>; + + images { + kernel { + description = "Vanilla Linux kernel"; + type = "kernel"; + arch = "ppc"; + os = "linux"; + compression = "gzip"; + load = <00000000>; + entry = <00000000>; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + u-boot { + }; + }; + fdt-1 { + description = "Flattened Device Tree blob"; + type = "flat_dt"; + arch = "ppc"; + compression = "none"; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + u-boot-spl-dtb { + }; + }; + }; + + configurations { + default = "conf-1"; + conf-1 { + description = "Boot Linux kernel with FDT blob"; + kernel = "kernel"; + fdt = "fdt-1"; + }; + }; + }; + u-boot-nodtb { + }; + }; +}; diff --git a/tools/binman/test/162_fit_external.dts b/tools/binman/test/162_fit_external.dts new file mode 100644 index 0000000000..19518e05a5 --- /dev/null +++ b/tools/binman/test/162_fit_external.dts @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + fit { + fit,external-offset = <0>; + description = "test-desc"; + #address-cells = <1>; + + images { + kernel { + description = "Vanilla Linux kernel"; + type = "kernel"; + arch = "ppc"; + os = "linux"; + compression = "gzip"; + load = <00000000>; + entry = <00000000>; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + u-boot { + }; + }; + fdt-1 { + description = "Flattened Device Tree blob"; + type = "flat_dt"; + arch = "ppc"; + compression = "none"; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + _testing { + return-contents-later; + }; + }; + }; + + configurations { + default = "conf-1"; + conf-1 { + description = "Boot Linux kernel with FDT blob"; + kernel = "kernel"; + fdt = "fdt-1"; + }; + }; + }; + u-boot-nodtb { + }; + }; +}; -- cgit From f07e58b878fc18bd69d2c19075f0fb8d7d35da00 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 26 Jan 2020 22:06:27 -0700 Subject: cpu: Convert the methods to use a const udevice * These functions should not modify the device. Convert them to const so that callers don't need to cast if they have a const udevice *. Signed-off-by: Simon Glass --- arch/nios2/cpu/cpu.c | 8 +++++--- arch/x86/cpu/apollolake/cpu.c | 2 +- arch/x86/cpu/baytrail/cpu.c | 4 ++-- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/cpu_x86.c | 6 +++--- arch/x86/cpu/ivybridge/model_206ax.c | 5 +++-- arch/x86/cpu/qemu/cpu.c | 4 ++-- arch/x86/include/asm/cpu_x86.h | 6 +++--- drivers/cpu/bmips_cpu.c | 8 ++++---- drivers/cpu/cpu-uclass.c | 8 ++++---- drivers/cpu/cpu_sandbox.c | 8 ++++---- drivers/cpu/imx8_cpu.c | 8 ++++---- drivers/cpu/mpc83xx_cpu.c | 26 ++++++++++++++------------ drivers/cpu/riscv_cpu.c | 8 ++++---- include/cpu.h | 16 ++++++++-------- 15 files changed, 63 insertions(+), 58 deletions(-) diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 7f5e731a0f..e7ca9882fc 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -79,7 +79,8 @@ int arch_cpu_init_dm(void) return 0; } -static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size) +static int altera_nios2_get_desc(const struct udevice *dev, char *buf, + int size) { const char *cpu_name = "Nios-II"; @@ -90,7 +91,8 @@ static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info) +static int altera_nios2_get_info(const struct udevice *dev, + struct cpu_info *info) { info->cpu_freq = gd->cpu_clk; info->features = (1 << CPU_FEAT_L1_CACHE) | @@ -99,7 +101,7 @@ static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int altera_nios2_get_count(struct udevice *dev) +static int altera_nios2_get_count(const struct udevice *dev) { return 1; } diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index aa7a3dbd63..0a6d2ad7a4 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -9,7 +9,7 @@ #include #include -static int apl_get_info(struct udevice *dev, struct cpu_info *info) +static int apl_get_info(const struct udevice *dev, struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } diff --git a/arch/x86/cpu/baytrail/cpu.c b/arch/x86/cpu/baytrail/cpu.c index 18e48ffa53..309a50a116 100644 --- a/arch/x86/cpu/baytrail/cpu.c +++ b/arch/x86/cpu/baytrail/cpu.c @@ -150,7 +150,7 @@ static unsigned long tsc_freq(void) return bclk * ((platform_info.lo >> 8) & 0xff); } -static int baytrail_get_info(struct udevice *dev, struct cpu_info *info) +static int baytrail_get_info(const struct udevice *dev, struct cpu_info *info) { info->cpu_freq = tsc_freq(); info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU; @@ -158,7 +158,7 @@ static int baytrail_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int baytrail_get_count(struct udevice *dev) +static int baytrail_get_count(const struct udevice *dev) { int ecx = 0; diff --git a/arch/x86/cpu/broadwell/cpu_full.c b/arch/x86/cpu/broadwell/cpu_full.c index 64a1cd414f..706f68f63d 100644 --- a/arch/x86/cpu/broadwell/cpu_full.c +++ b/arch/x86/cpu/broadwell/cpu_full.c @@ -626,12 +626,12 @@ void cpu_set_power_limits(int power_limit_1_time) } } -static int broadwell_get_info(struct udevice *dev, struct cpu_info *info) +static int broadwell_get_info(const struct udevice *dev, struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } -static int broadwell_get_count(struct udevice *dev) +static int broadwell_get_count(const struct udevice *dev) { return 4; } diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c index 3f2ba0881e..7e83051646 100644 --- a/arch/x86/cpu/cpu_x86.c +++ b/arch/x86/cpu/cpu_x86.c @@ -26,7 +26,7 @@ int cpu_x86_bind(struct udevice *dev) return 0; } -int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size) { const char *vendor = cpu_vendor_name(gd->arch.x86_vendor); @@ -38,7 +38,7 @@ int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size) return 0; } -int cpu_x86_get_desc(struct udevice *dev, char *buf, int size) +int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size) { char *ptr; @@ -52,7 +52,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size) return 0; } -int cpu_x86_get_count(struct udevice *dev) +int cpu_x86_get_count(const struct udevice *dev) { int node, cpu; int num = 0; diff --git a/arch/x86/cpu/ivybridge/model_206ax.c b/arch/x86/cpu/ivybridge/model_206ax.c index 5954a24873..55f7cc2b2e 100644 --- a/arch/x86/cpu/ivybridge/model_206ax.c +++ b/arch/x86/cpu/ivybridge/model_206ax.c @@ -410,14 +410,15 @@ static int model_206ax_init(struct udevice *dev) return 0; } -static int model_206ax_get_info(struct udevice *dev, struct cpu_info *info) +static int model_206ax_get_info(const struct udevice *dev, + struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); return 0; } -static int model_206ax_get_count(struct udevice *dev) +static int model_206ax_get_count(const struct udevice *dev) { return 4; } diff --git a/arch/x86/cpu/qemu/cpu.c b/arch/x86/cpu/qemu/cpu.c index f40fb4d087..9ce86b379c 100644 --- a/arch/x86/cpu/qemu/cpu.c +++ b/arch/x86/cpu/qemu/cpu.c @@ -10,7 +10,7 @@ #include #include -int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size) +int cpu_qemu_get_desc(const struct udevice *dev, char *buf, int size) { if (size < CPU_MAX_NAME_LEN) return -ENOSPC; @@ -20,7 +20,7 @@ int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int cpu_qemu_get_count(struct udevice *dev) +static int cpu_qemu_get_count(const struct udevice *dev) { return qemu_fwcfg_online_cpus(); } diff --git a/arch/x86/include/asm/cpu_x86.h b/arch/x86/include/asm/cpu_x86.h index ae8f4dcd5d..4fd5f03fdc 100644 --- a/arch/x86/include/asm/cpu_x86.h +++ b/arch/x86/include/asm/cpu_x86.h @@ -28,7 +28,7 @@ int cpu_x86_bind(struct udevice *dev); * @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_desc(struct udevice *dev, char *buf, int size); +int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size); /** * cpu_x86_get_count() - Get the number of cores for an x86 CPU @@ -40,7 +40,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size); * @return: Number of cores if successful, * -ENOENT if not "/cpus" entry is found in the device tree */ -int cpu_x86_get_count(struct udevice *dev); +int cpu_x86_get_count(const struct udevice *dev); /** * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU @@ -53,6 +53,6 @@ int cpu_x86_get_count(struct udevice *dev); * @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size); +int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size); #endif /* _ASM_CPU_X86_H */ diff --git a/drivers/cpu/bmips_cpu.c b/drivers/cpu/bmips_cpu.c index 2649c5c6e9..421cc7a9a4 100644 --- a/drivers/cpu/bmips_cpu.c +++ b/drivers/cpu/bmips_cpu.c @@ -379,7 +379,7 @@ static const struct bmips_cpu_hw bmips_cpu_bcm6838 = { }; /* Generic CPU Ops */ -static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int bmips_cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -387,7 +387,7 @@ static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size) return hw->get_cpu_desc(priv, buf, size); } -static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info) +static int bmips_cpu_get_info(const struct udevice *dev, struct cpu_info *info) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -400,7 +400,7 @@ static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int bmips_cpu_get_count(struct udevice *dev) +static int bmips_cpu_get_count(const struct udevice *dev) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -408,7 +408,7 @@ static int bmips_cpu_get_count(struct udevice *dev) return hw->get_cpu_count(priv); } -static int bmips_cpu_get_vendor(struct udevice *dev, char *buf, int size) +static int bmips_cpu_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "Broadcom"); diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index cbb4419ec0..37e3cf2d8f 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -69,7 +69,7 @@ struct udevice *cpu_get_current_dev(void) return cpu; } -int cpu_get_desc(struct udevice *dev, char *buf, int size) +int cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -79,7 +79,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size) return ops->get_desc(dev, buf, size); } -int cpu_get_info(struct udevice *dev, struct cpu_info *info) +int cpu_get_info(const struct udevice *dev, struct cpu_info *info) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -92,7 +92,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info) return ops->get_info(dev, info); } -int cpu_get_count(struct udevice *dev) +int cpu_get_count(const struct udevice *dev) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -102,7 +102,7 @@ int cpu_get_count(struct udevice *dev) return ops->get_count(dev); } -int cpu_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_get_vendor(const struct udevice *dev, char *buf, int size) { struct cpu_ops *ops = cpu_get_ops(dev); diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index 30a12e5a53..caa26e50f2 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -8,14 +8,14 @@ #include #include -int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size) +int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"); return 0; } -int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) +int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info) { info->cpu_freq = 42 * 42 * 42 * 42 * 42; info->features = 0x42424242; @@ -24,12 +24,12 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -int cpu_sandbox_get_count(struct udevice *dev) +int cpu_sandbox_get_count(const struct udevice *dev) { return 42; } -int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "Languid Example Garbage Inc."); diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 6345cd0815..502c8ebb43 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -100,7 +100,7 @@ static int cpu_imx_get_temp(struct cpu_imx_platdata *plat) } #endif -int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) +int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); int ret, temp; @@ -126,7 +126,7 @@ int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info) +static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); @@ -135,7 +135,7 @@ static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int cpu_imx_get_count(struct udevice *dev) +static int cpu_imx_get_count(const struct udevice *dev) { ofnode node; int num = 0; @@ -157,7 +157,7 @@ static int cpu_imx_get_count(struct udevice *dev) return num; } -static int cpu_imx_get_vendor(struct udevice *dev, char *buf, int size) +static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "NXP"); return 0; diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c index f8a84bae9d..5f1592f9ad 100644 --- a/drivers/cpu/mpc83xx_cpu.c +++ b/drivers/cpu/mpc83xx_cpu.c @@ -60,7 +60,7 @@ static inline u32 get_spridr(void) * determine_type() - Determine CPU family of MPC83xx device * @dev: CPU device from which to read CPU family from */ -static inline void determine_family(struct udevice *dev) +static inline void determine_family(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 12 bits of PARTID field (bits 0-23 in SPRIDR) */ @@ -95,7 +95,7 @@ static inline void determine_family(struct udevice *dev) * determine_type() - Determine CPU type of MPC83xx device * @dev: CPU device from which to read CPU type from */ -static inline void determine_type(struct udevice *dev) +static inline void determine_type(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 16 bits of PVR (Processor Version Register) */ @@ -169,7 +169,7 @@ static inline void determine_type(struct udevice *dev) * determine_e300_type() - Determine e300 core type of MPC83xx device * @dev: CPU device from which to read e300 core type from */ -static inline void determine_e300_type(struct udevice *dev) +static inline void determine_e300_type(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 16 bits of PVR (Processor Version Register) */ @@ -198,7 +198,7 @@ static inline void determine_e300_type(struct udevice *dev) * determine_revid() - Determine revision ID of CPU device * @dev: CPU device from which to read revision ID */ -static inline void determine_revid(struct udevice *dev) +static inline void determine_revid(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); u32 REVID_MAJOR_MASK; @@ -221,7 +221,7 @@ static inline void determine_revid(struct udevice *dev) * determine_cpu_data() - Determine CPU information from hardware * @dev: CPU device from which to read information */ -static void determine_cpu_data(struct udevice *dev) +static void determine_cpu_data(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); const u32 E_FLAG_MASK = 0x00010000; @@ -239,7 +239,7 @@ static void determine_cpu_data(struct udevice *dev) priv->is_e_processor = !bitfield_extract_by_mask(spridr, E_FLAG_MASK); } -static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int mpc83xx_cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); struct clk core_clk; @@ -248,14 +248,14 @@ static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size) char csb_freq[32]; int ret; - ret = clk_get_by_index(dev, 0, &core_clk); + ret = clk_get_by_index((struct udevice *)dev, 0, &core_clk); if (ret) { debug("%s: Failed to get core clock (err = %d)\n", dev->name, ret); return ret; } - ret = clk_get_by_index(dev, 1, &csb_clk); + ret = clk_get_by_index((struct udevice *)dev, 1, &csb_clk); if (ret) { debug("%s: Failed to get CSB clock (err = %d)\n", dev->name, ret); @@ -278,13 +278,14 @@ static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info) +static int mpc83xx_cpu_get_info(const struct udevice *dev, + struct cpu_info *info) { struct clk clock; int ret; ulong freq; - ret = clk_get_by_index(dev, 0, &clock); + ret = clk_get_by_index((struct udevice *)dev, 0, &clock); if (ret) { debug("%s: Failed to get core clock (err = %d)\n", dev->name, ret); @@ -303,13 +304,14 @@ static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int mpc83xx_cpu_get_count(struct udevice *dev) +static int mpc83xx_cpu_get_count(const struct udevice *dev) { /* We have one e300cX core */ return 1; } -static int mpc83xx_cpu_get_vendor(struct udevice *dev, char *buf, int size) +static int mpc83xx_cpu_get_vendor(const struct udevice *dev, char *buf, + int size) { snprintf(buf, size, "NXP"); diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index 100fe5542e..93ce708f65 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR; -static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int riscv_cpu_get_desc(const struct udevice *dev, char *buf, int size) { const char *isa; @@ -30,7 +30,7 @@ static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) +static int riscv_cpu_get_info(const struct udevice *dev, struct cpu_info *info) { int ret; struct clk clk; @@ -39,7 +39,7 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) u32 d_cache_size; /* First try getting the frequency from the assigned clock */ - ret = clk_get_by_index(dev, 0, &clk); + ret = clk_get_by_index((struct udevice *)dev, 0, &clk); if (!ret) { ret = clk_get_rate(&clk); if (!IS_ERR_VALUE(ret)) @@ -67,7 +67,7 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int riscv_cpu_get_count(struct udevice *dev) +static int riscv_cpu_get_count(const struct udevice *dev) { ofnode node; int num = 0; diff --git a/include/cpu.h b/include/cpu.h index 2f283fe244..78e88b9ed0 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -61,7 +61,7 @@ struct cpu_ops { * @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ - int (*get_desc)(struct udevice *dev, char *buf, int size); + int (*get_desc)(const struct udevice *dev, char *buf, int size); /** * get_info() - Get information about a CPU @@ -70,7 +70,7 @@ struct cpu_ops { * @info: Returns CPU info * @return 0 if OK, -ve on error */ - int (*get_info)(struct udevice *dev, struct cpu_info *info); + int (*get_info)(const struct udevice *dev, struct cpu_info *info); /** * get_count() - Get number of CPUs @@ -78,7 +78,7 @@ struct cpu_ops { * @dev: Device to check (UCLASS_CPU) * @return CPU count if OK, -ve on error */ - int (*get_count)(struct udevice *dev); + int (*get_count)(const struct udevice *dev); /** * get_vendor() - Get vendor name of a CPU @@ -88,7 +88,7 @@ struct cpu_ops { * @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ - int (*get_vendor)(struct udevice *dev, char *buf, int size); + int (*get_vendor)(const struct udevice *dev, char *buf, int size); /** * is_current() - Check if the CPU that U-Boot is currently running from @@ -110,7 +110,7 @@ struct cpu_ops { * * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_desc(struct udevice *dev, char *buf, int size); +int cpu_get_desc(const struct udevice *dev, char *buf, int size); /** * cpu_get_info() - Get information about a CPU @@ -119,7 +119,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size); * * Return: 0 if OK, -ve on error */ -int cpu_get_info(struct udevice *dev, struct cpu_info *info); +int cpu_get_info(const struct udevice *dev, struct cpu_info *info); /** * cpu_get_count() - Get number of CPUs @@ -127,7 +127,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info); * * Return: CPU count if OK, -ve on error */ -int cpu_get_count(struct udevice *dev); +int cpu_get_count(const struct udevice *dev); /** * cpu_get_vendor() - Get vendor name of a CPU @@ -137,7 +137,7 @@ int cpu_get_count(struct udevice *dev); * * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_vendor(struct udevice *dev, char *buf, int size); +int cpu_get_vendor(const struct udevice *dev, char *buf, int size); /** * cpu_probe_all() - Probe all available CPUs -- cgit From df1fa4b2239aaf2e4a7b72ff1e81cfa53af8b08e Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Thu, 2 Jul 2020 19:08:24 +0200 Subject: patman: Detect unexpected END Detect unexpected 'END' line when a section is not detected. This patch detect issue when tag name for section start is misspelled, for example 'Commit-note:' for 'Commit-notes:' Commit-note: .... END Then 'Commit-note:' is removed silently by re_remove = "Commit-\w*:" but 'END' is kept in commit message. Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- tools/patman/patchstream.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 0c68c86156..70acb09642 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -269,6 +269,10 @@ class PatchStream: else: self.section.append(line) + # If we are not in a section, it is an unexpected END + elif line == 'END': + raise ValueError("'END' wihout section") + # Detect the commit subject elif not is_blank and self.state == STATE_PATCH_SUBJECT: self.commit.subject = line -- cgit From 2a3be302d5dd221ea64b85a700746b322e30f064 Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Thu, 2 Jul 2020 19:31:29 +0200 Subject: lib: libfdt: fdt_region: avoid NULL pointer access The function fdt_find_regions look in the exclude list for each property, even if the name is NULL. It could happen if the fit image is corrupted. On sandbox, it generates a segfault. To avoid this issue, if the name of a property is NULL, we report an error and avoid looking in the exclude list. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- common/fdt_region.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/fdt_region.c b/common/fdt_region.c index 667659054a..ff12c518e9 100644 --- a/common/fdt_region.c +++ b/common/fdt_region.c @@ -65,6 +65,8 @@ int fdt_find_regions(const void *fdt, char * const inc[], int inc_count, stop_at = offset; prop = fdt_get_property_by_offset(fdt, offset, NULL); str = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); + if (!str) + return -FDT_ERR_BADSTRUCTURE; if (str_in_list(str, exc_prop, exc_prop_count)) include = 0; break; -- cgit From 3ce7f75f7836d9baeecf1ce214027f1200f2f9d3 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Thu, 2 Jul 2020 19:52:54 +0200 Subject: Add information for skipped commit options The unsupported Commit-xxx option are silently skipped and removed as 're_remove=Commit-\w*', this patch adds warning message in this case to detect misspelled issue for the 2 supported options: Commit-notes: Commit-changes: For example: the final 's' is missing (Commit-note:) NB: no issue for Series-xxx option as only the supported options are accepted (see valid_series in series.py) Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- tools/patman/patchstream.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 70acb09642..ba0a13f632 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -351,6 +351,9 @@ class PatchStream: elif name == 'changes': self.in_change = 'Commit' self.change_version = self.ParseVersion(value, line) + else: + self.warn.append('Line %d: Ignoring Commit-%s' % + (self.linenum, name)) # Detect the start of a new commit elif commit_match: -- cgit From 2feb4ea9dd8d262b11054a7a0ab346886a3ae1e3 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 10 Jul 2020 13:16:48 +0200 Subject: ARM: rmobile: Switch back to fdtdec_setup_memory/banksize_fdt() The commit 361377dbdbc9 ("ARM: rmobile: Merge prior-stage firmware DT fragment into U-Boot DT on Gen3") reverted changes introduced by commit 175f5027345c ("ARM: renesas: Configure DRAM size from ATF DT fragment") that's why there is no reason to use functions with _fdt() suffix because parameter is gd->fdt_blob as is already for functions without _fdt() suffix. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- board/renesas/rcar-common/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/renesas/rcar-common/common.c b/board/renesas/rcar-common/common.c index 9f50f36982..83dd288847 100644 --- a/board/renesas/rcar-common/common.c +++ b/board/renesas/rcar-common/common.c @@ -33,12 +33,12 @@ int fdtdec_board_setup(const void *fdt_blob) int dram_init(void) { - return fdtdec_setup_mem_size_base_fdt(gd->fdt_blob); + return fdtdec_setup_mem_size_base(); } int dram_init_banksize(void) { - fdtdec_setup_memory_banksize_fdt(gd->fdt_blob); + fdtdec_setup_memory_banksize(); return 0; } -- cgit From d4cc6f638c7aa06904e650b1aee735d7d02a30ad Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 10 Jul 2020 13:16:49 +0200 Subject: Revert "lib: fdt: Split fdtdec_setup_memory_banksize()" This reverts commit 118f4d4559a4386fa87a1e2509e84a1986b24a34. There is no user of this split function that's why remove it. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/fdtdec.h | 19 ------------------- lib/fdtdec.c | 18 ++++++------------ 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index abd6d42671..c9ab822c44 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -946,25 +946,6 @@ int fdtdec_setup_mem_size_base_fdt(const void *blob); */ int fdtdec_setup_mem_size_base(void); -/** - * fdtdec_setup_memory_banksize_fdt() - decode and populate gd->bd->bi_dram - * - * Decode the /memory 'reg' property to determine the address and size of the - * memory banks. Use this data to populate the global data board info with the - * phys address and size of memory banks. - * - * This function should be called from a boards dram_init_banksize(). This - * helper function allows for boards to query the device tree for memory bank - * information instead of hard coding the information in cases where it cannot - * be detected automatically. - * - * @param blob FDT blob - * - * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or - * invalid - */ -int fdtdec_setup_memory_banksize_fdt(const void *blob); - /** * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram * diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 934944d97f..36c1ad4e86 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1065,33 +1065,33 @@ int fdtdec_setup_mem_size_base(void) static int get_next_memory_node(const void *blob, int mem) { do { - mem = fdt_node_offset_by_prop_value(blob, mem, + mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, "device_type", "memory", 7); } while (!fdtdec_get_is_enabled(blob, mem)); return mem; } -int fdtdec_setup_memory_banksize_fdt(const void *blob) +int fdtdec_setup_memory_banksize(void) { int bank, ret, mem, reg = 0; struct fdt_resource res; - mem = get_next_memory_node(blob, -1); + mem = get_next_memory_node(gd->fdt_blob, -1); if (mem < 0) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - ret = fdt_get_resource(blob, mem, "reg", reg++, &res); + ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); if (ret == -FDT_ERR_NOTFOUND) { reg = 0; - mem = get_next_memory_node(blob, mem); + mem = get_next_memory_node(gd->fdt_blob, mem); if (mem == -FDT_ERR_NOTFOUND) break; - ret = fdt_get_resource(blob, mem, "reg", reg++, &res); + ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); if (ret == -FDT_ERR_NOTFOUND) break; } @@ -1111,12 +1111,6 @@ int fdtdec_setup_memory_banksize_fdt(const void *blob) return 0; } - -int fdtdec_setup_memory_banksize(void) -{ - return fdtdec_setup_memory_banksize_fdt(gd->fdt_blob); - -} #endif #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) -- cgit From b589b809712b78ce74cad1594e1e04116b77157a Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 10 Jul 2020 13:16:50 +0200 Subject: Revert "lib: fdt: Split fdtdec_setup_mem_size_base()" This reverts commit 3ebe09d09a407f93022d945a205c5318239eb3f6. There is no user of this split function that's why remove it. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- include/fdtdec.h | 20 -------------------- lib/fdtdec.c | 11 +++-------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index c9ab822c44..760b392bdf 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -908,26 +908,6 @@ struct display_timing { int fdtdec_decode_display_timing(const void *blob, int node, int index, struct display_timing *config); -/** - * fdtdec_setup_mem_size_base_fdt() - decode and setup gd->ram_size and - * gd->ram_start - * - * Decode the /memory 'reg' property to determine the size and start of the - * first memory bank, populate the global data with the size and start of the - * first bank of memory. - * - * This function should be called from a boards dram_init(). This helper - * function allows for boards to query the device tree for DRAM size and start - * address instead of hard coding the value in the case where the memory size - * and start address cannot be detected automatically. - * - * @param blob FDT blob - * - * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or - * invalid - */ -int fdtdec_setup_mem_size_base_fdt(const void *blob); - /** * fdtdec_setup_mem_size_base() - decode and setup gd->ram_size and * gd->ram_start diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 36c1ad4e86..78576b530f 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1030,18 +1030,18 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index, return ret; } -int fdtdec_setup_mem_size_base_fdt(const void *blob) +int fdtdec_setup_mem_size_base(void) { int ret, mem; struct fdt_resource res; - mem = fdt_path_offset(blob, "/memory"); + mem = fdt_path_offset(gd->fdt_blob, "/memory"); if (mem < 0) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } - ret = fdt_get_resource(blob, mem, "reg", 0, &res); + ret = fdt_get_resource(gd->fdt_blob, mem, "reg", 0, &res); if (ret != 0) { debug("%s: Unable to decode first memory bank\n", __func__); return -EINVAL; @@ -1055,11 +1055,6 @@ int fdtdec_setup_mem_size_base_fdt(const void *blob) return 0; } -int fdtdec_setup_mem_size_base(void) -{ - return fdtdec_setup_mem_size_base_fdt(gd->fdt_blob); -} - #if defined(CONFIG_NR_DRAM_BANKS) static int get_next_memory_node(const void *blob, int mem) -- cgit From 754c05caf306c7b587698193477bed12014e4164 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 13 Jul 2020 10:50:00 +0800 Subject: patman: Make sure sendemail.suppresscc is (un)set correctly Setting sendemail.suppresscc to all or cccmd leads to --cc-cmd parameter being ignored, and emails going either nowhere, or just to the To: line maintainer. Signed-off-by: Nicolas Boichat Reviewed-by: Simon Glass --- tools/patman/control.py | 2 ++ tools/patman/gitutil.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/patman/control.py b/tools/patman/control.py index e67867b845..8f4afeab18 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -166,6 +166,8 @@ def send(args): ok = check_patches(series, patch_files, args.check_patch, args.verbose) + ok = ok and gitutil.CheckSuppressCCConfig() + its_a_go = ok or args.ignore_errors if its_a_go: email_patches( diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index b683481a57..192d8e69b3 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -344,6 +344,31 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True): return ['%s %s%s%s' % (tag, quote, email, quote) for email in result] return result +def CheckSuppressCCConfig(): + """Check if sendemail.suppresscc is configured correctly. + + Returns: + True if the option is configured correctly, False otherwise. + """ + suppresscc = command.OutputOneLine('git', 'config', 'sendemail.suppresscc', + raise_on_error=False) + + # Other settings should be fine. + if suppresscc == 'all' or suppresscc == 'cccmd': + col = terminal.Color() + + print((col.Color(col.RED, "error") + + ": git config sendemail.suppresscc set to %s\n" % (suppresscc)) + + " patman needs --cc-cmd to be run to set the cc list.\n" + + " Please run:\n" + + " git config --unset sendemail.suppresscc\n" + + " Or read the man page:\n" + + " git send-email --help\n" + + " and set an option that runs --cc-cmd\n") + return False + + return True + def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname, self_only=False, alias=None, in_reply_to=None, thread=False, smtp_server=None): -- cgit From 28e0367fc879a408b964c070b55e4255e6d1eac5 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 13 Jul 2020 10:50:01 +0800 Subject: patman: When no tracking branch is provided, tell the user The user can either count the number of patches, or provide a tracking branch. Signed-off-by: Nicolas Boichat Reviewed-by: Simon Glass --- tools/patman/control.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index 8f4afeab18..67e8f397ef 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -48,8 +48,9 @@ def prepare_patches(col, branch, count, start, end, ignore_binary): count = (gitutil.CountCommitsToBranch(branch) - start) if not count: - sys.exit(col.Color(col.RED, - 'No commits found to process - please use -c flag')) + str = 'No commits found to process - please use -c flag, or run:\n' \ + ' git branch --set-upstream-to remote/branch' + sys.exit(col.Color(col.RED, str)) # Read the metadata from the commits to_do = count - end -- cgit From d772db3f9ad9bbd89830fbae86d525ff8a951fd7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 15 Jul 2020 19:35:47 +0900 Subject: fdt_support: add static to fdt_node_set_part_info() This function is only called from fdt_fixup_mtdpart() in the same file. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/fdt_support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 3778de5368..b010d0b552 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -816,8 +816,8 @@ static int fdt_del_partitions(void *blob, int parent_offset) return 0; } -int fdt_node_set_part_info(void *blob, int parent_offset, - struct mtd_device *dev) +static int fdt_node_set_part_info(void *blob, int parent_offset, + struct mtd_device *dev) { struct list_head *pentry; struct part_info *part; -- cgit From 41c1a693e5c2b6c74f9ef5824dbb1c3115b618c9 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:39:56 -0500 Subject: doc: Add new doc for soc ID driver model Add a new documentation file for UCLASS_SOC and its usage to describe the SoC Device ID framework that allows SoC identification and device data matching. Signed-off-by: Dave Gerlach Reviewed-by: Simon Glass --- doc/driver-model/index.rst | 1 + doc/driver-model/soc-framework.rst | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 doc/driver-model/soc-framework.rst diff --git a/doc/driver-model/index.rst b/doc/driver-model/index.rst index b9df221627..f17c72ce69 100644 --- a/doc/driver-model/index.rst +++ b/doc/driver-model/index.rst @@ -19,5 +19,6 @@ Driver Model pmic-framework remoteproc-framework serial-howto + soc-framework spi-howto usb-info diff --git a/doc/driver-model/soc-framework.rst b/doc/driver-model/soc-framework.rst new file mode 100644 index 0000000000..2609fda644 --- /dev/null +++ b/doc/driver-model/soc-framework.rst @@ -0,0 +1,68 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. (C) Copyright 2020 +.. Texas Instruments Incorporated - http://www.ti.com/ + +SOC ID Framework +================ + +Introduction +------------ + +The driver-model SOC ID framework is able to provide identification +information about a specific SoC in use at runtime, and also provide matching +from a set of identification information from an array. This can be useful for +enabling small quirks in drivers that exist between SoC variants that are +impractical to implement using device tree flags. It is based on UCLASS_SOC. + +UCLASS_SOC: + - drivers/soc/soc-uclass.c + - include/soc.h + +Configuration: + - CONFIG_SOC_DEVICE is selected by drivers as needed. + +Implementing a UCLASS_SOC provider +---------------------------------- + +The purpose of this framework is to allow UCLASS_SOC provider drivers to supply +identification information about the SoC in use at runtime. The framework +allows drivers to define soc_ops that return identification strings. All +soc_ops need not be defined and can be left as NULL, in which case the +framework will return -ENOSYS and not consider the value when doing an +soc_device_match. + +It is left to the driver implementor to decide how the information returned is +determined, but in general the same SOC should always return the same set of +identifying information. Information returned must be in the form of a NULL +terminated string. + +See include/soc.h for documentation of the available soc_ops and the intended +meaning of the values that can be returned. See drivers/soc/soc_sandbox.c for +an example UCLASS_SOC provider driver. + +Using a UCLASS_SOC driver +------------------------- + +The framework provides the ability to retrieve and use the identification +strings directly. It also has the ability to return a match from a list of +different sets of SoC data using soc_device_match. + +An array of 'struct soc_attr' can be defined, each containing ID information +for a specific SoC, and when passed to soc_device_match, the identifier values +for each entry in the list will be compared against the values provided by the +UCLASS_SOC driver that is in use. The first entry in the list that matches all +non-null values will be returned by soc_device_match. + +An example of various uses of the framework can be found at test/dm/soc.c. + +Describing the device using device tree +--------------------------------------- + +.. code-block:: none + + chipid: chipid { + compatible = "sandbox,soc"; + }; + +All that is required in a DT node is a compatible for a corresponding +UCLASS_SOC driver. -- cgit From 6426a26f4c314ad59d833456932312ce574e9b71 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:39:57 -0500 Subject: dm: soc: Introduce UCLASS_SOC for SOC ID and attribute matching Introduce UCLASS_SOC to be used for SOC identification and attribute matching based on the SoC ID info. This allows drivers to be provided for SoCs to retrieve SoC identifying information and also for matching device attributes for selecting SoC specific data. This is useful for other device drivers that may need different parameters or quirks enabled depending on the specific device variant in use. Reviewed-by: Simon Glass Signed-off-by: Dave Gerlach --- drivers/soc/Kconfig | 9 +++ drivers/soc/Makefile | 1 + drivers/soc/soc-uclass.c | 102 +++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/soc.h | 145 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 258 insertions(+) create mode 100644 drivers/soc/soc-uclass.c create mode 100644 include/soc.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 7b4e4d6130..e715dfd017 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,5 +1,14 @@ menu "SOC (System On Chip) specific Drivers" +config SOC_DEVICE + bool "Enable SoC Device ID drivers using Driver Model" + help + This allows drivers to be provided for SoCs to help in identifying + the SoC in use and matching SoC attributes for selecting SoC + specific data. This is useful for other device drivers that may + need different parameters or quirks enabled depending on the + specific device variant in use. + source "drivers/soc/ti/Kconfig" endmenu diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index ce253b7aa8..1c09a84656 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -3,3 +3,4 @@ # Makefile for the U-Boot SOC specific device drivers. obj-$(CONFIG_SOC_TI) += ti/ +obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o diff --git a/drivers/soc/soc-uclass.c b/drivers/soc/soc-uclass.c new file mode 100644 index 0000000000..c32d647864 --- /dev/null +++ b/drivers/soc/soc-uclass.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach + */ + +#include +#include +#include +#include +#include +#include + +int soc_get(struct udevice **devp) +{ + return uclass_first_device_err(UCLASS_SOC, devp); +} + +int soc_get_machine(struct udevice *dev, char *buf, int size) +{ + struct soc_ops *ops = soc_get_ops(dev); + + if (!ops->get_machine) + return -ENOSYS; + + return ops->get_machine(dev, buf, size); +} + +int soc_get_family(struct udevice *dev, char *buf, int size) +{ + struct soc_ops *ops = soc_get_ops(dev); + + if (!ops->get_family) + return -ENOSYS; + + return ops->get_family(dev, buf, size); +} + +int soc_get_revision(struct udevice *dev, char *buf, int size) +{ + struct soc_ops *ops = soc_get_ops(dev); + + if (!ops->get_revision) + return -ENOSYS; + + return ops->get_revision(dev, buf, size); +} + +const struct soc_attr * +soc_device_match(const struct soc_attr *matches) +{ + bool match; + struct udevice *soc; + char str[SOC_MAX_STR_SIZE]; + + if (!matches) + return NULL; + + if (soc_get(&soc)) + return NULL; + + while (1) { + if (!(matches->machine || matches->family || + matches->revision)) + break; + + match = true; + + if (matches->machine) { + if (!soc_get_machine(soc, str, SOC_MAX_STR_SIZE)) { + if (strcmp(matches->machine, str)) + match = false; + } + } + + if (matches->family) { + if (!soc_get_family(soc, str, SOC_MAX_STR_SIZE)) { + if (strcmp(matches->family, str)) + match = false; + } + } + + if (matches->revision) { + if (!soc_get_revision(soc, str, SOC_MAX_STR_SIZE)) { + if (strcmp(matches->revision, str)) + match = false; + } + } + + if (match) + return matches; + + matches++; + } + + return NULL; +} + +UCLASS_DRIVER(soc) = { + .id = UCLASS_SOC, + .name = "soc", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 7837d459f1..690a8ed4df 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -97,6 +97,7 @@ enum uclass_id { UCLASS_SERIAL, /* Serial UART */ UCLASS_SIMPLE_BUS, /* Bus with child devices */ UCLASS_SMEM, /* Shared memory interface */ + UCLASS_SOC, /* SOC Device */ UCLASS_SOUND, /* Playing simple sounds */ UCLASS_SPI, /* SPI bus */ UCLASS_SPI_FLASH, /* SPI flash */ diff --git a/include/soc.h b/include/soc.h new file mode 100644 index 0000000000..a55eb1b572 --- /dev/null +++ b/include/soc.h @@ -0,0 +1,145 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach + */ + +#ifndef __SOC_H +#define __SOC_H + +#define SOC_MAX_STR_SIZE 128 + +/** + * struct soc_attr - Contains SoC identify information to be used in + * SoC matching. An array of these structs + * representing different SoCs can be passed to + * soc_device_match and the struct matching the SoC + * in use will be returned. + * + * @family - Name of SoC family that can include multiple related SoC + * variants. Example: am33 + * @machine - Name of a specific SoC. Example: am3352 + * @revision - Name of a specific SoC revision. Example: SR1.1 + * @data - A pointer to user data for the SoC variant + */ +struct soc_attr { + const char *family; + const char *machine; + const char *revision; + const void *data; +}; + +struct soc_ops { + /** + * get_machine() - Get machine name of an SOC + * + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ + int (*get_machine)(struct udevice *dev, char *buf, int size); + + /** + * get_revision() - Get revision name of a SOC + * + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ + int (*get_revision)(struct udevice *dev, char *buf, int size); + + /** + * get_family() - Get family name of an SOC + * + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ + int (*get_family)(struct udevice *dev, char *buf, int size); +}; + +#define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops) + +#ifdef CONFIG_SOC_DEVICE +/** + * soc_get() - Return the soc device for the soc in use. + * @devp: Pointer to structure to receive the soc device. + * + * Since there can only be at most one SOC instance, the API can supply a + * function that returns the unique device. + * + * Return: 0 if OK, -ve on error. + */ +int soc_get(struct udevice **devp); + +/** + * soc_get_machine() - Get machine name of an SOC + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * + * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ +int soc_get_machine(struct udevice *dev, char *buf, int size); + +/** + * soc_get_revision() - Get revision name of an SOC + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * + * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ +int soc_get_revision(struct udevice *dev, char *buf, int size); + +/** + * soc_get_family() - Get family name of an SOC + * @dev: Device to check (UCLASS_SOC) + * @buf: Buffer to place string + * @size: Size of string space + * + * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error + */ +int soc_get_family(struct udevice *dev, char *buf, int size); + +/** + * soc_device_match() - Return match from an array of soc_attr + * @matches: Array with any combination of family, revision or machine set + * + * Return: Pointer to struct from matches array with set attributes matching + * those provided by the soc device, or NULL if no match found. + */ +const struct soc_attr * +soc_device_match(const struct soc_attr *matches); + +#else +static inline int soc_get(struct udevice **devp) +{ + return -ENOSYS; +} + +static inline int soc_get_machine(struct udevice *dev, char *buf, int size) +{ + return -ENOSYS; +} + +static inline int soc_get_revision(struct udevice *dev, char *buf, int size) +{ + return -ENOSYS; +} + +static inline int soc_get_family(struct udevice *dev, char *buf, int size) +{ + return -ENOSYS; +} + +static inline const struct soc_attr * +soc_device_match(const struct soc_attr *matches) +{ + return NULL; +} +#endif +#endif /* _SOC_H */ -- cgit From fbde39f41725c5e6b85872ca6cc1c0c425c9bd0a Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:39:58 -0500 Subject: test: Add tests for SOC uclass Add a sandbox SOC driver, and some tests for the SOC uclass. Reviewed-by: Simon Glass Signed-off-by: Dave Gerlach --- arch/sandbox/dts/test.dts | 4 ++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/soc_sandbox.c | 56 +++++++++++++++++ test/dm/Makefile | 1 + test/dm/soc.c | 120 +++++++++++++++++++++++++++++++++++++ 9 files changed, 186 insertions(+) create mode 100644 drivers/soc/soc_sandbox.c create mode 100644 test/dm/soc.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 3744a46603..2ae4239721 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -521,6 +521,10 @@ }; }; + chipid: chipid { + compatible = "sandbox,soc"; + }; + i2s: i2s { compatible = "sandbox,i2s"; #sound-dai-cells = <1>; diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index dcf2f44b58..a3b7ff444f 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -118,6 +118,7 @@ CONFIG_LED_GPIO=y CONFIG_DM_MAILBOX=y CONFIG_SANDBOX_MBOX=y CONFIG_MISC=y +CONFIG_SOC_DEVICE=y CONFIG_CROS_EC=y CONFIG_CROS_EC_I2C=y CONFIG_CROS_EC_LPC=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 6059d668af..17c9b332f5 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -139,6 +139,7 @@ CONFIG_LED_GPIO=y CONFIG_DM_MAILBOX=y CONFIG_SANDBOX_MBOX=y CONFIG_MISC=y +CONFIG_SOC_DEVICE=y CONFIG_CROS_EC=y CONFIG_CROS_EC_I2C=y CONFIG_CROS_EC_LPC=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 4158b9b86d..93ab210ebb 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -103,6 +103,7 @@ CONFIG_LED_GPIO=y CONFIG_DM_MAILBOX=y CONFIG_SANDBOX_MBOX=y CONFIG_MISC=y +CONFIG_SOC_DEVICE=y CONFIG_CROS_EC=y CONFIG_CROS_EC_I2C=y CONFIG_CROS_EC_LPC=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index b3274a93b4..25c974f6fe 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -120,6 +120,7 @@ CONFIG_LED_GPIO=y CONFIG_DM_MAILBOX=y CONFIG_SANDBOX_MBOX=y CONFIG_MISC=y +CONFIG_SOC_DEVICE=y CONFIG_CROS_EC=y CONFIG_CROS_EC_I2C=y CONFIG_CROS_EC_LPC=y diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 1c09a84656..649e92b390 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o +obj-$(CONFIG_SANDBOX) += soc_sandbox.o diff --git a/drivers/soc/soc_sandbox.c b/drivers/soc/soc_sandbox.c new file mode 100644 index 0000000000..5c82ad84fc --- /dev/null +++ b/drivers/soc/soc_sandbox.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Sandbox driver for the SOC uclass + * + * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach + */ + +#include +#include +#include + +int soc_sandbox_get_family(struct udevice *dev, char *buf, int size) +{ + snprintf(buf, size, "SANDBOX1xx"); + + return 0; +} + +int soc_sandbox_get_machine(struct udevice *dev, char *buf, int size) +{ + snprintf(buf, size, "SANDBOX123"); + + return 0; +} + +int soc_sandbox_get_revision(struct udevice *dev, char *buf, int size) +{ + snprintf(buf, size, "1.0"); + + return 0; +} + +static const struct soc_ops soc_sandbox_ops = { + .get_family = soc_sandbox_get_family, + .get_revision = soc_sandbox_get_revision, + .get_machine = soc_sandbox_get_machine, +}; + +int soc_sandbox_probe(struct udevice *dev) +{ + return 0; +} + +static const struct udevice_id soc_sandbox_ids[] = { + { .compatible = "sandbox,soc" }, + { } +}; + +U_BOOT_DRIVER(soc_sandbox) = { + .name = "soc_sandbox", + .id = UCLASS_SOC, + .ops = &soc_sandbox_ops, + .of_match = soc_sandbox_ids, + .probe = soc_sandbox_probe, +}; diff --git a/test/dm/Makefile b/test/dm/Makefile index b03c96da06..839111791b 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_CPU) += cpu.o +obj-$(CONFIG_SOC_DEVICE) += soc.o obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o diff --git a/test/dm/soc.c b/test/dm/soc.c new file mode 100644 index 0000000000..3ad0f561f2 --- /dev/null +++ b/test/dm/soc.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for the SOC uclass + * + * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach + */ + +#include +#include +#include +#include +#include +#include + +struct sb_soc_data { + unsigned long param; +}; + +static int dm_test_soc(struct unit_test_state *uts) +{ + struct udevice *dev; + char text[128]; + const struct soc_attr *soc_data; + const struct sb_soc_data *match_data; + + static const struct sb_soc_data soc_sandbox1_sr10_data = { 0x91919191 }; + static const struct sb_soc_data soc_sandbox123_data = { 0x84848484 }; + + static const struct soc_attr sb_soc_devices_full[] = { + { + .family = "SANDBOX0xx", + .machine = "SANDBOX012", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX107", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX123", + .revision = "1.0", + .data = &soc_sandbox123_data, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX131", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + static const struct soc_attr sb_soc_devices_partial[] = { + { + .family = "SANDBOX0xx", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .revision = "1.0", + .data = &soc_sandbox1_sr10_data, + }, + { + .family = "SANDBOX1xx", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + static const struct soc_attr sb_soc_devices_nomatch[] = { + { + .family = "SANDBOX0xx", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + ut_assertok(soc_get(&dev)); + + ut_assertok(soc_get_machine(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "SANDBOX123")); + + ut_assertok(soc_get_family(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "SANDBOX1xx")); + + ut_assertok(soc_get_revision(dev, text, sizeof(text))); + ut_asserteq_str(text, "1.0"); + + soc_data = soc_device_match(sb_soc_devices_full); + ut_assert(soc_data); + + match_data = soc_data->data; + ut_asserteq(match_data->param, 0x84848484); + + soc_data = soc_device_match(sb_soc_devices_partial); + ut_assert(soc_data); + + match_data = soc_data->data; + ut_asserteq(match_data->param, 0x91919191); + + soc_data = soc_device_match(sb_soc_devices_nomatch); + ut_asserteq_ptr(soc_data, NULL); + + return 0; +} + +DM_TEST(dm_test_soc, DM_TESTF_SCAN_FDT); -- cgit From 527be812a8405699bb4eaecdc2bbe83857ebffd0 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:39:59 -0500 Subject: dm: soc: Introduce soc_ti_k3 driver for TI K3 SoCs Introduce an soc_ti_k3_driver that allows identification and selection of SoC specific data based on the JTAG ID register for device identification, as described for AM65x[0] and J721E[1] devices. [0] http://www.ti.com/lit/ug/spruid7e/spruid7e.pdf [1] http://www.ti.com/lit/ug/spruil1a/spruil1a.pdf Signed-off-by: Dave Gerlach --- drivers/soc/Kconfig | 7 +++ drivers/soc/Makefile | 1 + drivers/soc/soc_ti_k3.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 drivers/soc/soc_ti_k3.c diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index e715dfd017..864d00a885 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -9,6 +9,13 @@ config SOC_DEVICE need different parameters or quirks enabled depending on the specific device variant in use. +config SOC_DEVICE_TI_K3 + depends on SOC_DEVICE + bool "Enable SoC Device ID driver for TI K3 SoCs" + help + This allows Texas Instruments Keystone 3 SoCs to identify + specifics about the SoC in use. + source "drivers/soc/ti/Kconfig" endmenu diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 649e92b390..9ef20ca506 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -4,4 +4,5 @@ obj-$(CONFIG_SOC_TI) += ti/ obj-$(CONFIG_SOC_DEVICE) += soc-uclass.o +obj-$(CONFIG_SOC_DEVICE_TI_K3) += soc_ti_k3.o obj-$(CONFIG_SANDBOX) += soc_sandbox.o diff --git a/drivers/soc/soc_ti_k3.c b/drivers/soc/soc_ti_k3.c new file mode 100644 index 0000000000..ae23ef7475 --- /dev/null +++ b/drivers/soc/soc_ti_k3.c @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach + */ + +#include +#include +#include + +#include + +#define AM65X 0xbb5a +#define J721E 0xbb64 + +#define REV_SR1_0 0 +#define REV_SR2_0 1 + +#define JTAG_ID_VARIANT_SHIFT 28 +#define JTAG_ID_VARIANT_MASK (0xf << 28) +#define JTAG_ID_PARTNO_SHIFT 12 +#define JTAG_ID_PARTNO_MASK (0xffff << 12) + +struct soc_ti_k3_platdata { + const char *family; + const char *revision; +}; + +static const char *get_family_string(u32 idreg) +{ + const char *family; + u32 soc; + + soc = (idreg & JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT; + + switch (soc) { + case AM65X: + family = "AM65X"; + break; + case J721E: + family = "J721E"; + break; + default: + family = "Unknown Silicon"; + }; + + return family; +} + +static const char *get_rev_string(u32 idreg) +{ + const char *revision; + u32 rev; + + rev = (idreg & JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT; + + switch (rev) { + case REV_SR1_0: + revision = "1.0"; + break; + case REV_SR2_0: + revision = "2.0"; + break; + default: + revision = "Unknown Revision"; + }; + + return revision; +} + +static int soc_ti_k3_get_family(struct udevice *dev, char *buf, int size) +{ + struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + + snprintf(buf, size, "%s", plat->family); + + return 0; +} + +static int soc_ti_k3_get_revision(struct udevice *dev, char *buf, int size) +{ + struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + + snprintf(buf, size, "SR%s", plat->revision); + + return 0; +} + +static const struct soc_ops soc_ti_k3_ops = { + .get_family = soc_ti_k3_get_family, + .get_revision = soc_ti_k3_get_revision, +}; + +int soc_ti_k3_probe(struct udevice *dev) +{ + struct soc_ti_k3_platdata *plat = dev_get_platdata(dev); + u32 idreg; + void *idreg_addr; + + idreg_addr = dev_read_addr_ptr(dev); + if (!idreg_addr) + return -EINVAL; + + idreg = readl(idreg_addr); + + plat->family = get_family_string(idreg); + plat->revision = get_rev_string(idreg); + + return 0; +} + +static const struct udevice_id soc_ti_k3_ids[] = { + { .compatible = "ti,am654-chipid" }, + { } +}; + +U_BOOT_DRIVER(soc_ti_k3) = { + .name = "soc_ti_k3", + .id = UCLASS_SOC, + .ops = &soc_ti_k3_ops, + .of_match = soc_ti_k3_ids, + .probe = soc_ti_k3_probe, + .platdata_auto_alloc_size = sizeof(struct soc_ti_k3_platdata), +}; -- cgit From 30402cadb3cd4856197dd699a08ae26f00262a98 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:40:00 -0500 Subject: arm: dts: k3-am65-wakeup: Introduce chipid node Introduce a chipid node to provide a UCLASS_SOC driver to identify TI K3 SoCs. Signed-off-by: Dave Gerlach --- arch/arm/dts/k3-am65-wakeup.dtsi | 5 +++++ arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm/dts/k3-am65-wakeup.dtsi b/arch/arm/dts/k3-am65-wakeup.dtsi index 2676d6035b..666c30d019 100644 --- a/arch/arm/dts/k3-am65-wakeup.dtsi +++ b/arch/arm/dts/k3-am65-wakeup.dtsi @@ -62,4 +62,9 @@ clocks = <&k3_clks 115 1>; power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>; }; + + chipid: chipid@43000014 { + compatible = "ti,am654-chipid"; + reg = <0x43000014 0x4>; + }; }; diff --git a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi index d9ff3ed47b..a30680d3e0 100644 --- a/arch/arm/dts/k3-am654-base-board-u-boot.dtsi +++ b/arch/arm/dts/k3-am654-base-board-u-boot.dtsi @@ -246,3 +246,7 @@ u-boot,dm-spl; }; }; + +&chipid { + u-boot,dm-spl; +}; -- cgit From a1631d51ad0f90b38a26652b32331ace4a6c5080 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:40:01 -0500 Subject: arm: dts: k3-j721e-mcu-wakeup: Introduce chipid node Introduce a chipid node to provide a UCLASS_SOC driver to identify TI K3 SoCs. Signed-off-by: Dave Gerlach --- arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi | 4 ++++ arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi index 6e748bfebb..cfb39325e9 100644 --- a/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi +++ b/arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi @@ -211,3 +211,7 @@ &mcu_fss0_ospi1_pins_default { u-boot,dm-spl; }; + +&chipid { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi index e6c99ab698..60695f5eb9 100644 --- a/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi +++ b/arch/arm/dts/k3-j721e-mcu-wakeup.dtsi @@ -316,4 +316,9 @@ ti,cpts-periodic-outputs = <2>; }; }; + + chipid: chipid@43000014 { + compatible = "ti,am654-chipid"; + reg = <0x0 0x43000014 0x0 0x4>; + }; }; -- cgit From b6d8a26866ad6fb323e531a8c25cc448e4e6eff8 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:40:02 -0500 Subject: configs: am65x_evm: Enable CONFIG_SOC_DEVICE and CONFIG_SOC_DEVICE_TI_K3 Enable CONFIG_SOC_DEVICE and CONFIG_SOC_DEVICE_TI_K3 so the TI K3 SoC driver can be used for SoC detection. Signed-off-by: Dave Gerlach --- configs/am65x_evm_a53_defconfig | 2 ++ configs/am65x_evm_r5_defconfig | 2 ++ configs/am65x_hs_evm_a53_defconfig | 2 ++ configs/am65x_hs_evm_r5_defconfig | 2 ++ 4 files changed, 8 insertions(+) diff --git a/configs/am65x_evm_a53_defconfig b/configs/am65x_evm_a53_defconfig index 918ff4de0c..e8f0adbec2 100644 --- a/configs/am65x_evm_a53_defconfig +++ b/configs/am65x_evm_a53_defconfig @@ -146,3 +146,5 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6162 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/am65x_evm_r5_defconfig b/configs/am65x_evm_r5_defconfig index 09c8b74aee..81ef413162 100644 --- a/configs/am65x_evm_r5_defconfig +++ b/configs/am65x_evm_r5_defconfig @@ -120,3 +120,5 @@ CONFIG_TIMER=y CONFIG_SPL_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/am65x_hs_evm_a53_defconfig b/configs/am65x_hs_evm_a53_defconfig index bc3da74509..b58381eb25 100644 --- a/configs/am65x_hs_evm_a53_defconfig +++ b/configs/am65x_hs_evm_a53_defconfig @@ -148,3 +148,5 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6162 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/am65x_hs_evm_r5_defconfig b/configs/am65x_hs_evm_r5_defconfig index ead4a59c38..e24311aea6 100644 --- a/configs/am65x_hs_evm_r5_defconfig +++ b/configs/am65x_hs_evm_r5_defconfig @@ -121,3 +121,5 @@ CONFIG_TIMER=y CONFIG_SPL_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y -- cgit From 4c2718f9b18c6612888c81f27ea03439e894a537 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:40:03 -0500 Subject: configs: j721e_evm: Enable CONFIG_SOC_DEVICE and CONFIG_SOC_DEVICE_TI_K3 Enable CONFIG_SOC_DEVICE and CONFIG_SOC_DEVICE_TI_K3 so the TI K3 SoC driver can be used for SoC detection. Signed-off-by: Dave Gerlach --- configs/j721e_evm_a72_defconfig | 2 ++ configs/j721e_evm_r5_defconfig | 2 ++ configs/j721e_hs_evm_a72_defconfig | 2 ++ configs/j721e_hs_evm_r5_defconfig | 2 ++ 4 files changed, 8 insertions(+) diff --git a/configs/j721e_evm_a72_defconfig b/configs/j721e_evm_a72_defconfig index 09a73e590d..e85abee695 100644 --- a/configs/j721e_evm_a72_defconfig +++ b/configs/j721e_evm_a72_defconfig @@ -170,3 +170,5 @@ CONFIG_CADENCE_UFS=y CONFIG_TI_J721E_UFS=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index a06fc7c3d2..488dae2bb3 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -135,3 +135,5 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6163 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_FS_EXT4=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/j721e_hs_evm_a72_defconfig b/configs/j721e_hs_evm_a72_defconfig index 9b5bc6cf54..fa928873dc 100644 --- a/configs/j721e_hs_evm_a72_defconfig +++ b/configs/j721e_hs_evm_a72_defconfig @@ -158,3 +158,5 @@ CONFIG_CADENCE_UFS=y CONFIG_TI_J721E_UFS=y CONFIG_FAT_WRITE=y CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y diff --git a/configs/j721e_hs_evm_r5_defconfig b/configs/j721e_hs_evm_r5_defconfig index 1aa899e63c..c8773aa6d0 100644 --- a/configs/j721e_hs_evm_r5_defconfig +++ b/configs/j721e_hs_evm_r5_defconfig @@ -116,3 +116,5 @@ CONFIG_SPL_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_FS_EXT4=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y -- cgit From 469f04e8827d6b470ffb0aedf456fa118b2df238 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Wed, 15 Jul 2020 23:40:04 -0500 Subject: arm: mach-k3: Use SOC driver for device identification Make use of UCLASS_SOC to find device family and revision for print_cpuinfo. Signed-off-by: Dave Gerlach --- arch/arm/mach-k3/common.c | 48 +++++++++++++------------------- arch/arm/mach-k3/common.h | 6 ---- arch/arm/mach-k3/include/mach/hardware.h | 1 - 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 63bf060616..4335f2877b 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -25,6 +25,7 @@ #include #include #include +#include struct ti_sci_handle *get_ti_sci_handle(void) { @@ -308,38 +309,27 @@ void reset_cpu(ulong ignored) #if defined(CONFIG_DISPLAY_CPUINFO) int print_cpuinfo(void) { - u32 soc, rev; - char *name; - - soc = (readl(CTRLMMR_WKUP_JTAG_ID) & - JTAG_ID_PARTNO_MASK) >> JTAG_ID_PARTNO_SHIFT; - rev = (readl(CTRLMMR_WKUP_JTAG_ID) & - JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT; + struct udevice *soc; + char name[64]; + int ret; printf("SoC: "); - switch (soc) { - case AM65X: - name = "AM65x"; - break; - case J721E: - name = "J721E"; - break; - default: - name = "Unknown Silicon"; - }; - printf("%s SR ", name); - switch (rev) { - case REV_PG1_0: - name = "1.0"; - break; - case REV_PG2_0: - name = "2.0"; - break; - default: - name = "Unknown Revision"; - }; - printf("%s\n", name); + ret = soc_get(&soc); + if (ret) { + printf("UNKNOWN\n"); + return 0; + } + + ret = soc_get_family(soc, name, 64); + if (!ret) { + printf("%s ", name); + } + + ret = soc_get_revision(soc, name, 64); + if (!ret) { + printf("%s\n", name); + } return 0; } diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 94cdcb56ad..ba344c5bc9 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -8,12 +8,6 @@ #include -#define AM65X 0xbb5a -#define J721E 0xbb64 - -#define REV_PG1_0 0 -#define REV_PG2_0 1 - struct fwl_data { const char *name; u16 fwl_id; diff --git a/arch/arm/mach-k3/include/mach/hardware.h b/arch/arm/mach-k3/include/mach/hardware.h index 0ad761418b..f2ca80af1a 100644 --- a/arch/arm/mach-k3/include/mach/hardware.h +++ b/arch/arm/mach-k3/include/mach/hardware.h @@ -15,7 +15,6 @@ #endif /* Assuming these addresses and definitions stay common across K3 devices */ -#define CTRLMMR_WKUP_JTAG_ID 0x43000014 #define JTAG_ID_VARIANT_SHIFT 28 #define JTAG_ID_VARIANT_MASK (0xf << 28) #define JTAG_ID_PARTNO_SHIFT 12 -- cgit From 105da6251a16cfc5db1ef374b5a18ea8df6e8a4c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 17 Jul 2020 00:20:14 +0200 Subject: test/dm: check if devices exist Running 'ut dm' on the sandbox without -D or -d results in segmentation faults due to NULL pointer dereferences. Check that device pointers are non-NULL before using them. Use ut_assertnonnull() for pointers instead of ut_assert(). Signed-off-by: Heinrich Schuchardt Tested-by: Philippe Reynes --- test/dm/acpi.c | 3 +++ test/dm/core.c | 10 +++++----- test/dm/devres.c | 1 + test/dm/test-fdt.c | 2 ++ test/dm/virtio.c | 7 +++++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/dm/acpi.c b/test/dm/acpi.c index b94c4ba4d1..bb8550ffb1 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -190,7 +190,10 @@ DM_TEST(dm_test_acpi_get_table_revision, static int dm_test_acpi_create_dmar(struct unit_test_state *uts) { struct acpi_dmar dmar; + struct udevice *cpu; + ut_assertok(uclass_first_device(UCLASS_CPU, &cpu)); + ut_assertnonnull(cpu); ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP)); ut_asserteq(DMAR_INTR_REMAP, dmar.flags); ut_asserteq(32 - 1, dmar.host_address_width); diff --git a/test/dm/core.c b/test/dm/core.c index 6a930ae31a..d20c48443f 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -158,7 +158,7 @@ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) for (uclass_find_first_device(UCLASS_TEST, &dev); dev; uclass_find_next_device(&dev)) { - ut_assert(dev); + ut_assertnonnull(dev); uc_pdata = dev_get_uclass_platdata(dev); ut_assert(uc_pdata); @@ -181,7 +181,7 @@ static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts) for (uclass_find_first_device(UCLASS_TEST, &dev); dev; uclass_find_next_device(&dev)) { - ut_assert(dev); + ut_assertnonnull(dev); uc_pdata = dev_get_uclass_platdata(dev); ut_assert(uc_pdata); @@ -747,11 +747,11 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts) dev; ret = uclass_find_next_device(&dev)) { ut_assert(!ret); - ut_assert(dev); + ut_assertnonnull(dev); } ut_assertok(uclass_find_first_device(UCLASS_TEST_DUMMY, &dev)); - ut_assert(!dev); + ut_assertnull(dev); return 0; } @@ -778,7 +778,7 @@ static int dm_test_uclass_devices_find_by_name(struct unit_test_state *uts) testdev; ret = uclass_find_next_device(&testdev)) { ut_assertok(ret); - ut_assert(testdev); + ut_assertnonnull(testdev); findret = uclass_find_device_by_name(UCLASS_TEST_FDT, testdev->name, diff --git a/test/dm/devres.c b/test/dm/devres.c index b5de0cb191..550787495d 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -153,6 +153,7 @@ static int dm_test_devres_phase(struct unit_test_state *uts) * allocation created in the bind() method. */ ut_assertok(uclass_find_first_device(UCLASS_TEST_DEVRES, &dev)); + ut_assertnonnull(dev); devres_get_stats(dev, &stats); ut_asserteq(1, stats.allocs); ut_asserteq(TEST_DEVRES_SIZE, stats.total_size); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 51f2547409..8ef7c7a88e 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -832,10 +832,12 @@ static int dm_test_fdt_phandle(struct unit_test_state *uts) struct udevice *back, *dev, *dev2; ut_assertok(uclass_find_first_device(UCLASS_PANEL_BACKLIGHT, &back)); + ut_assertnonnull(back); ut_asserteq(-ENOENT, uclass_find_device_by_phandle(UCLASS_REGULATOR, back, "missing", &dev)); ut_assertok(uclass_find_device_by_phandle(UCLASS_REGULATOR, back, "power-supply", &dev)); + ut_assertnonnull(dev); ut_asserteq(0, device_active(dev)); ut_asserteq_str("ldo1", dev->name); ut_assertok(uclass_get_device_by_phandle(UCLASS_REGULATOR, back, diff --git a/test/dm/virtio.c b/test/dm/virtio.c index 4b317d2ec3..4a0c0b23b8 100644 --- a/test/dm/virtio.c +++ b/test/dm/virtio.c @@ -22,9 +22,11 @@ static int dm_test_virtio_base(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); ut_assertok(strcmp(dev->name, "virtio-blk#0")); /* check driver status */ @@ -49,15 +51,18 @@ static int dm_test_virtio_all_ops(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); /* * fake the virtio device probe by filling in uc_priv->vdev * which is used by virtio_find_vqs/virtio_del_vqs. */ uc_priv = dev_get_uclass_priv(bus); + ut_assertnonnull(uc_priv); uc_priv->vdev = dev; /* test virtio_xxx APIs */ @@ -106,9 +111,11 @@ static int dm_test_virtio_remove(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); /* set driver status to VIRTIO_CONFIG_S_DRIVER_OK */ ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK)); -- cgit From 245ad6c4adb4af5290f22acaba57ed0dd109e1f4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Jul 2020 10:46:18 +0900 Subject: fdt_support: call mtdparts_init() after finding MTD node to fix up Platform code can call fdt_fixup_mtdparts() in order to hand U-Boot's MTD partitions over to the Linux device tree. Currently, fdt_fixup_mtdparts() calls mtdparts_init() in its entry. If no target MTD device is found, an error message like follows is displayed: Device nand0 not found! This occurs when the same code (e.g. arch/arm/mach-uniphier/fdt-fixup.c) is shared among several boards, but not all of them support an MTD device. Parse the DT first, then call mtdparts_init() only when the target MTD node is found. Yet, you still need to call mtdparts_init() before device_find(). Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/fdt_support.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index b010d0b552..9c84702b19 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -951,9 +951,7 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, struct mtd_device *dev; int i, idx; int noff; - - if (mtdparts_init() != 0) - return; + bool inited = false; for (i = 0; i < node_info_size; i++) { idx = 0; @@ -963,6 +961,13 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, debug("%s: %s, mtd dev type %d\n", fdt_get_name(blob, noff, 0), node_info[i].compat, node_info[i].type); + + if (!inited) { + if (mtdparts_init() != 0) + return; + inited = true; + } + dev = device_find(node_info[i].type, idx++); if (dev) { if (fdt_node_set_part_info(blob, noff, dev)) -- cgit From 6ec7545b99d62a5d931473e853aea30f8b9b2aa3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Jul 2020 10:46:19 +0900 Subject: fdt_support: skip MTD node with "disabled" in fdt_fixup_mtdparts() Currently, fdt_fixup_mtdparts() only checks the compatible property. It is pointless to fix up the disabled node. Skip the node if it has the property: status = "disabled" Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/fdt_support.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 9c84702b19..a565b470f8 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -955,9 +955,16 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, for (i = 0; i < node_info_size; i++) { idx = 0; - noff = fdt_node_offset_by_compatible(blob, -1, - node_info[i].compat); - while (noff != -FDT_ERR_NOTFOUND) { + noff = -1; + + while ((noff = fdt_node_offset_by_compatible(blob, noff, + node_info[i].compat)) >= 0) { + const char *prop; + + prop = fdt_getprop(blob, noff, "status", NULL); + if (prop && !strcmp(prop, "disabled")) + continue; + debug("%s: %s, mtd dev type %d\n", fdt_get_name(blob, noff, 0), node_info[i].compat, node_info[i].type); @@ -973,10 +980,6 @@ void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, if (fdt_node_set_part_info(blob, noff, dev)) return; /* return on error */ } - - /* Jump to next flash node */ - noff = fdt_node_offset_by_compatible(blob, noff, - node_info[i].compat); } } } -- cgit From 3c12c62ba5fa12c988336a9de5784c6b5fbaac54 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Jul 2020 14:36:46 +0900 Subject: treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() Use the _ptr suffixed variant instead of casting. Also, convert it to dev_read_addr_ptr(), which is safe to CONFIG_OF_LIVE. One curious part is an error check like follows in drivers/watchdog/omap_wdt.c: priv->regs = (struct wd_timer *)devfdt_get_addr(dev); if (!priv->regs) return -EINVAL; devfdt_get_addr() returns FDT_ADDR_T_NONE (i.e. -1) on error. So, this code does not catch any error in DT parsing. dev_read_addr_ptr() returns NULL on error, so this error check will work. I generated this commit by the following command: $ find . -name .git -prune -o -name '*.[ch]' -type f -print | \ xargs sed -i -e 's/([^*)]*\*)devfdt_get_addr(/dev_read_addr_ptr(/' I manually fixed drivers/usb/host/ehci-mx6.c Signed-off-by: Masahiro Yamada --- drivers/adc/exynos-adc.c | 2 +- drivers/clk/renesas/clk-rcar-gen2.c | 2 +- drivers/clk/renesas/clk-rcar-gen3.c | 2 +- drivers/gpio/gpio-rcar.c | 2 +- drivers/gpio/mvebu_gpio.c | 2 +- drivers/gpio/s5p_gpio.c | 2 +- drivers/gpio/sunxi_gpio.c | 2 +- drivers/i2c/at91_i2c.c | 2 +- drivers/i2c/davinci_i2c.c | 2 +- drivers/i2c/exynos_hs_i2c.c | 2 +- drivers/i2c/s3c24x0_i2c.c | 2 +- drivers/input/tegra-kbc.c | 2 +- drivers/mmc/aspeed_sdhci.c | 2 +- drivers/mmc/atmel_sdhci.c | 2 +- drivers/mmc/ftsdc010_mci.c | 2 +- drivers/mmc/hi6220_dw_mmc.c | 2 +- drivers/mmc/iproc_sdhci.c | 2 +- drivers/mmc/msm_sdhci.c | 2 +- drivers/mmc/mv_sdhci.c | 2 +- drivers/mmc/socfpga_dw_mmc.c | 2 +- drivers/mmc/sti_sdhci.c | 2 +- drivers/mmc/xenon_sdhci.c | 2 +- drivers/pci_endpoint/pcie-cadence-ep.c | 2 +- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 2 +- drivers/pwm/exynos_pwm.c | 2 +- drivers/pwm/pwm-imx.c | 2 +- drivers/pwm/pwm-mtk.c | 2 +- drivers/pwm/sunxi_pwm.c | 2 +- drivers/serial/serial_arc.c | 2 +- drivers/serial/serial_xuartlite.c | 2 +- drivers/spi/atmel_spi.c | 2 +- drivers/spi/designware_spi.c | 2 +- drivers/spi/exynos_spi.c | 2 +- drivers/spi/kirkwood_spi.c | 2 +- drivers/spi/mtk_snfi_spi.c | 2 +- drivers/spi/mvebu_a3700_spi.c | 2 +- drivers/spi/zynq_spi.c | 2 +- drivers/usb/host/ehci-mx5.c | 2 +- drivers/usb/host/ehci-mx6.c | 4 ++-- drivers/usb/host/ehci-omap.c | 2 +- drivers/usb/host/ehci-vf.c | 2 +- drivers/usb/host/ohci-da8xx.c | 2 +- drivers/usb/host/ohci-generic.c | 2 +- drivers/video/atmel_hlcdfb.c | 2 +- drivers/video/tegra.c | 2 +- drivers/watchdog/omap_wdt.c | 2 +- 46 files changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/adc/exynos-adc.c b/drivers/adc/exynos-adc.c index 12c49fc8ce..b459b57050 100644 --- a/drivers/adc/exynos-adc.c +++ b/drivers/adc/exynos-adc.c @@ -106,7 +106,7 @@ int exynos_adc_ofdata_to_platdata(struct udevice *dev) struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); struct exynos_adc_priv *priv = dev_get_priv(dev); - priv->regs = (struct exynos_adc_v2 *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); if (priv->regs == (struct exynos_adc_v2 *)FDT_ADDR_T_NONE) { pr_err("Dev: %s - can't get address!", dev->name); return -ENODATA; diff --git a/drivers/clk/renesas/clk-rcar-gen2.c b/drivers/clk/renesas/clk-rcar-gen2.c index 3ed0aa92cb..16da10c8dd 100644 --- a/drivers/clk/renesas/clk-rcar-gen2.c +++ b/drivers/clk/renesas/clk-rcar-gen2.c @@ -283,7 +283,7 @@ int gen2_clk_probe(struct udevice *dev) u32 cpg_mode; int ret; - priv->base = (struct gen2_base *)devfdt_get_addr(dev); + priv->base = dev_read_addr_ptr(dev); if (!priv->base) return -EINVAL; diff --git a/drivers/clk/renesas/clk-rcar-gen3.c b/drivers/clk/renesas/clk-rcar-gen3.c index 15e3833756..30a101fe86 100644 --- a/drivers/clk/renesas/clk-rcar-gen3.c +++ b/drivers/clk/renesas/clk-rcar-gen3.c @@ -359,7 +359,7 @@ int gen3_clk_probe(struct udevice *dev) u32 cpg_mode; int ret; - priv->base = (struct gen3_base *)devfdt_get_addr(dev); + priv->base = dev_read_addr_ptr(dev); if (!priv->base) return -EINVAL; diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index c49a041059..a993fd4d70 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -148,7 +148,7 @@ static int rcar_gpio_probe(struct udevice *dev) int node = dev_of_offset(dev); int ret; - priv->regs = (void __iomem *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); uc_priv->bank_name = dev->name; ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node, "gpio-ranges", diff --git a/drivers/gpio/mvebu_gpio.c b/drivers/gpio/mvebu_gpio.c index 770cbf6b60..65eaa71c20 100644 --- a/drivers/gpio/mvebu_gpio.c +++ b/drivers/gpio/mvebu_gpio.c @@ -90,7 +90,7 @@ static int mvebu_gpio_probe(struct udevice *dev) struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct mvebu_gpio_priv *priv = dev_get_priv(dev); - priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); uc_priv->gpio_count = MVEBU_GPIOS_PER_BANK; priv->name[0] = 'A' + dev->req_seq; uc_priv->bank_name = priv->name; diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 258f13395d..4a68f44704 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -316,7 +316,7 @@ static int gpio_exynos_bind(struct udevice *parent) if (plat) return 0; - base = (struct s5p_gpio_bank *)devfdt_get_addr(parent); + base = dev_read_addr_ptr(parent); for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base; node > 0; node = fdt_next_subnode(blob, node), bank++) { diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c index 9c3a4428e1..3efccf496f 100644 --- a/drivers/gpio/sunxi_gpio.c +++ b/drivers/gpio/sunxi_gpio.c @@ -293,7 +293,7 @@ static int gpio_sunxi_bind(struct udevice *parent) if (plat) return 0; - ctlr = (struct sunxi_gpio_reg *)devfdt_get_addr(parent); + ctlr = dev_read_addr_ptr(parent); for (bank = 0; bank < soc_data->no_banks; bank++) { struct sunxi_gpio_platdata *plat; struct udevice *dev; diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index c817ed6bf9..9d6c6d80e2 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -225,7 +225,7 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev) struct at91_i2c_bus *bus = dev_get_priv(dev); int node = dev_of_offset(dev); - bus->regs = (struct at91_i2c_regs *)devfdt_get_addr(dev); + bus->regs = dev_read_addr_ptr(dev); bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev); bus->clock_frequency = fdtdec_get_int(blob, node, "clock-frequency", 100000); diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c index f8e9d003e6..a54f2151fd 100644 --- a/drivers/i2c/davinci_i2c.c +++ b/drivers/i2c/davinci_i2c.c @@ -471,7 +471,7 @@ static int davinci_i2c_probe(struct udevice *dev) struct i2c_bus *i2c_bus = dev_get_priv(dev); i2c_bus->id = dev->seq; - i2c_bus->regs = (struct i2c_regs *)devfdt_get_addr(dev); + i2c_bus->regs = dev_read_addr_ptr(dev); i2c_bus->speed = 100000; _davinci_i2c_init(i2c_bus->regs, i2c_bus->speed, 0); diff --git a/drivers/i2c/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c index 4fc9d90580..5785adedb6 100644 --- a/drivers/i2c/exynos_hs_i2c.c +++ b/drivers/i2c/exynos_hs_i2c.c @@ -525,7 +525,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) node = dev_of_offset(dev); - i2c_bus->hsregs = (struct exynos5_hsi2c *)devfdt_get_addr(dev); + i2c_bus->hsregs = dev_read_addr_ptr(dev); i2c_bus->id = pinmux_decode_periph_id(blob, node); diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c index 5907217981..cb45d3c100 100644 --- a/drivers/i2c/s3c24x0_i2c.c +++ b/drivers/i2c/s3c24x0_i2c.c @@ -310,7 +310,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev) node = dev_of_offset(dev); - i2c_bus->regs = (struct s3c24x0_i2c *)devfdt_get_addr(dev); + i2c_bus->regs = dev_read_addr_ptr(dev); i2c_bus->id = pinmux_decode_periph_id(blob, node); diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c index 3409bb61d5..f07a51dc30 100644 --- a/drivers/input/tegra-kbc.c +++ b/drivers/input/tegra-kbc.c @@ -291,7 +291,7 @@ static int tegra_kbd_probe(struct udevice *dev) struct input_config *input = &uc_priv->input; int ret; - priv->kbc = (struct kbc_tegra *)devfdt_get_addr(dev); + priv->kbc = dev_read_addr_ptr(dev); if ((fdt_addr_t)priv->kbc == FDT_ADDR_T_NONE) { debug("%s: No keyboard register found\n", __func__); return -EINVAL; diff --git a/drivers/mmc/aspeed_sdhci.c b/drivers/mmc/aspeed_sdhci.c index 8929e603f3..543c65a8e3 100644 --- a/drivers/mmc/aspeed_sdhci.c +++ b/drivers/mmc/aspeed_sdhci.c @@ -34,7 +34,7 @@ static int aspeed_sdhci_probe(struct udevice *dev) goto free; host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); max_clk = clk_get_rate(&clk); if (IS_ERR_VALUE(max_clk)) { diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c index 2b797c9bd4..0c53caf448 100644 --- a/drivers/mmc/atmel_sdhci.c +++ b/drivers/mmc/atmel_sdhci.c @@ -69,7 +69,7 @@ static int atmel_sdhci_probe(struct udevice *dev) return ret; host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), diff --git a/drivers/mmc/ftsdc010_mci.c b/drivers/mmc/ftsdc010_mci.c index fb28f0166f..bc0d5ffed5 100644 --- a/drivers/mmc/ftsdc010_mci.c +++ b/drivers/mmc/ftsdc010_mci.c @@ -395,7 +395,7 @@ static int ftsdc010_mmc_ofdata_to_platdata(struct udevice *dev) struct ftsdc_priv *priv = dev_get_priv(dev); struct ftsdc010_chip *chip = &priv->chip; chip->name = dev->name; - chip->ioaddr = (void *)devfdt_get_addr(dev); + chip->ioaddr = dev_read_addr_ptr(dev); chip->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); chip->priv = dev; diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c index 6de7924383..67d6a05b3b 100644 --- a/drivers/mmc/hi6220_dw_mmc.c +++ b/drivers/mmc/hi6220_dw_mmc.c @@ -33,7 +33,7 @@ static int hi6220_dwmmc_ofdata_to_platdata(struct udevice *dev) struct dwmci_host *host = &priv->host; host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); diff --git a/drivers/mmc/iproc_sdhci.c b/drivers/mmc/iproc_sdhci.c index 91e2e3f0b8..9f530638e3 100644 --- a/drivers/mmc/iproc_sdhci.c +++ b/drivers/mmc/iproc_sdhci.c @@ -188,7 +188,7 @@ static int iproc_sdhci_probe(struct udevice *dev) iproc_host->shadow_blk = 0; host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34; host->quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B; diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index da3ae2ec35..56c3e35c9e 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -171,7 +171,7 @@ static int msm_ofdata_to_platdata(struct udevice *dev) int node = dev_of_offset(dev); host->name = strdup(dev->name); - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4); host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0); priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob, diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c index f5f3e43247..9b3dfa13e6 100644 --- a/drivers/mmc/mv_sdhci.c +++ b/drivers/mmc/mv_sdhci.c @@ -112,7 +112,7 @@ static int mv_sdhci_probe(struct udevice *dev) int ret; host->name = MVSDH_NAME; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD; host->mmc = &plat->mmc; host->mmc->dev = dev; diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 892222d27d..0022f943bd 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -109,7 +109,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev) } host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); host->clksel = socfpga_dwmci_clksel; diff --git a/drivers/mmc/sti_sdhci.c b/drivers/mmc/sti_sdhci.c index 9bcd8ce5f6..5578feebef 100644 --- a/drivers/mmc/sti_sdhci.c +++ b/drivers/mmc/sti_sdhci.c @@ -116,7 +116,7 @@ static int sti_sdhci_ofdata_to_platdata(struct udevice *dev) struct sdhci_host *host = dev_get_priv(dev); host->name = strdup(dev->name); - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width", 4); diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c index e765dd384a..356dd9846d 100644 --- a/drivers/mmc/xenon_sdhci.c +++ b/drivers/mmc/xenon_sdhci.c @@ -455,7 +455,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) const char *name; host->name = dev->name; - host->ioaddr = (void *)devfdt_get_addr(dev); + host->ioaddr = dev_read_addr_ptr(dev); if (device_is_compatible(dev, "marvell,armada-3700-sdhci")) priv->pad_ctrl_reg = (void *)devfdt_get_addr_index(dev, 1); diff --git a/drivers/pci_endpoint/pcie-cadence-ep.c b/drivers/pci_endpoint/pcie-cadence-ep.c index 59231d340a..74dfdde154 100644 --- a/drivers/pci_endpoint/pcie-cadence-ep.c +++ b/drivers/pci_endpoint/pcie-cadence-ep.c @@ -144,7 +144,7 @@ static int cdns_pci_ep_probe(struct udevice *dev) { struct cdns_pcie *pdata = dev_get_priv(dev); - pdata->reg_base = (void __iomem *)devfdt_get_addr(dev); + pdata->reg_base = dev_read_addr_ptr(dev); if (!pdata->reg_base) return -ENOMEM; diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 2dee79af17..fb497803b9 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -592,7 +592,7 @@ int armada_37xx_pinctrl_probe(struct udevice *dev) info->data = (struct armada_37xx_pin_data *)dev_get_driver_data(dev); pin_data = info->data; - info->base = (void __iomem *)devfdt_get_addr(dev); + info->base = dev_read_addr_ptr(dev); if (!info->base) { pr_err("unable to find regmap\n"); return -ENODEV; diff --git a/drivers/pwm/exynos_pwm.c b/drivers/pwm/exynos_pwm.c index fed1583796..e55fcceafd 100644 --- a/drivers/pwm/exynos_pwm.c +++ b/drivers/pwm/exynos_pwm.c @@ -92,7 +92,7 @@ static int exynos_pwm_ofdata_to_platdata(struct udevice *dev) { struct exynos_pwm_priv *priv = dev_get_priv(dev); - priv->regs = (struct s5p_timer *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index f5b9544cb8..77a1907fd3 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -130,7 +130,7 @@ static int imx_pwm_ofdata_to_platdata(struct udevice *dev) { struct imx_pwm_priv *priv = dev_get_priv(dev); - priv->regs = (struct pwm_regs *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/pwm/pwm-mtk.c b/drivers/pwm/pwm-mtk.c index 97ed477025..7bd82518d6 100644 --- a/drivers/pwm/pwm-mtk.c +++ b/drivers/pwm/pwm-mtk.c @@ -130,7 +130,7 @@ static int mtk_pwm_probe(struct udevice *dev) int i; priv->soc = (struct mtk_pwm_soc *)dev_get_driver_data(dev); - priv->base = (void __iomem *)devfdt_get_addr(dev); + priv->base = dev_read_addr_ptr(dev); if (!priv->base) return -EINVAL; ret = clk_get_by_name(dev, "top", &priv->top_clk); diff --git a/drivers/pwm/sunxi_pwm.c b/drivers/pwm/sunxi_pwm.c index 56215dbf6c..e2ae1a8009 100644 --- a/drivers/pwm/sunxi_pwm.c +++ b/drivers/pwm/sunxi_pwm.c @@ -152,7 +152,7 @@ static int sunxi_pwm_ofdata_to_platdata(struct udevice *dev) { struct sunxi_pwm_priv *priv = dev_get_priv(dev); - priv->regs = (struct sunxi_pwm *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c index 70dbc6d6b5..04063fbe39 100644 --- a/drivers/serial/serial_arc.c +++ b/drivers/serial/serial_arc.c @@ -114,7 +114,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev) struct arc_serial_platdata *plat = dev_get_platdata(dev); DECLARE_GLOBAL_DATA_PTR; - plat->reg = (struct arc_serial_regs *)devfdt_get_addr(dev); + plat->reg = dev_read_addr_ptr(dev); plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock-frequency", 0); diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c index f29a9a0b56..5116d13751 100644 --- a/drivers/serial/serial_xuartlite.c +++ b/drivers/serial/serial_xuartlite.c @@ -85,7 +85,7 @@ static int uartlite_serial_ofdata_to_platdata(struct udevice *dev) { struct uartlite_platdata *plat = dev_get_platdata(dev); - plat->regs = (struct uartlite *)devfdt_get_addr(dev); + plat->regs = dev_read_addr_ptr(dev); return 0; } diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index b120664661..c65733c87a 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -351,7 +351,7 @@ static int atmel_spi_probe(struct udevice *bus) if (ret) return ret; - bus_plat->regs = (struct at91_spi *)devfdt_get_addr(bus); + bus_plat->regs = dev_read_addr_ptr(bus); #if CONFIG_IS_ENABLED(DM_GPIO) struct atmel_spi_priv *priv = dev_get_priv(bus); diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c index c9b14f9029..2559aac2e9 100644 --- a/drivers/spi/designware_spi.c +++ b/drivers/spi/designware_spi.c @@ -157,7 +157,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus) { struct dw_spi_platdata *plat = bus->platdata; - plat->regs = (struct dw_spi *)devfdt_get_addr(bus); + plat->regs = dev_read_addr_ptr(bus); /* Use 500KHz as a suitable default */ plat->frequency = dev_read_u32_default(bus, "spi-max-frequency", diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index 746686a18a..d338ff5a0b 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -257,7 +257,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - plat->regs = (struct exynos_spi *)devfdt_get_addr(bus); + plat->regs = dev_read_addr_ptr(bus); plat->periph_id = pinmux_decode_periph_id(blob, node); if (plat->periph_id == PERIPH_ID_NONE) { diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c index 92dc2e13c5..dc7d2bc1f0 100644 --- a/drivers/spi/kirkwood_spi.c +++ b/drivers/spi/kirkwood_spi.c @@ -236,7 +236,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) const struct mvebu_spi_dev *drvdata = (struct mvebu_spi_dev *)dev_get_driver_data(bus); - plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus); + plat->spireg = dev_read_addr_ptr(bus); plat->is_errata_50mhz_ac = drvdata->is_errata_50mhz_ac; return 0; diff --git a/drivers/spi/mtk_snfi_spi.c b/drivers/spi/mtk_snfi_spi.c index 2a89476515..c30c8f4ff6 100644 --- a/drivers/spi/mtk_snfi_spi.c +++ b/drivers/spi/mtk_snfi_spi.c @@ -253,7 +253,7 @@ static int mtk_snfi_spi_probe(struct udevice *bus) struct mtk_snfi_priv *priv = dev_get_priv(bus); int ret; - priv->base = (void __iomem *)devfdt_get_addr(bus); + priv->base = dev_read_addr_ptr(bus); if (!priv->base) return -EINVAL; diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c index 2302e62be4..e860b9ec64 100644 --- a/drivers/spi/mvebu_a3700_spi.c +++ b/drivers/spi/mvebu_a3700_spi.c @@ -255,7 +255,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) struct mvebu_spi_platdata *plat = dev_get_platdata(bus); int ret; - plat->spireg = (struct spi_reg *)devfdt_get_addr(bus); + plat->spireg = dev_read_addr_ptr(bus); ret = clk_get_by_index(bus, 0, &plat->clk); if (ret) { diff --git a/drivers/spi/zynq_spi.c b/drivers/spi/zynq_spi.c index 78ffd3e2fe..9923931e36 100644 --- a/drivers/spi/zynq_spi.c +++ b/drivers/spi/zynq_spi.c @@ -77,7 +77,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - plat->regs = (struct zynq_spi_regs *)devfdt_get_addr(bus); + plat->regs = dev_read_addr_ptr(bus); /* FIXME: Use 250MHz as a suitable default */ plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", diff --git a/drivers/usb/host/ehci-mx5.c b/drivers/usb/host/ehci-mx5.c index 212b362332..caafa68899 100644 --- a/drivers/usb/host/ehci-mx5.c +++ b/drivers/usb/host/ehci-mx5.c @@ -306,7 +306,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev); + struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx5_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 5f84c7b91d..37b59758bb 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -473,7 +473,7 @@ static const struct ehci_ops mx6_ehci_ops = { static int ehci_usb_phy_mode(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - void *__iomem addr = (void *__iomem)devfdt_get_addr(dev); + void *__iomem addr = dev_read_addr_ptr(dev); void *__iomem phy_ctrl, *__iomem phy_status; const void *blob = gd->fdt_blob; int offset = dev_of_offset(dev), phy_off; @@ -580,7 +580,7 @@ static int ehci_usb_bind(struct udevice *dev) static int ehci_usb_probe(struct udevice *dev) { struct usb_platdata *plat = dev_get_platdata(dev); - struct usb_ehci *ehci = (struct usb_ehci *)devfdt_get_addr(dev); + struct usb_ehci *ehci = dev_read_addr_ptr(dev); struct ehci_mx6_priv_data *priv = dev_get_priv(dev); enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 93ab83941d..82b99eeef1 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -382,7 +382,7 @@ static int omap_ehci_probe(struct udevice *dev) struct ehci_hccr *hccr; struct ehci_hcor *hcor; - priv->ehci = (struct omap_ehci *)devfdt_get_addr(dev); + priv->ehci = dev_read_addr_ptr(dev); priv->portnr = dev->seq; priv->init_type = plat->init_type; diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 562207d3d2..2768d40974 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -224,7 +224,7 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev) priv->portnr = dev->seq; - priv->ehci = (struct usb_ehci *)devfdt_get_addr(dev); + priv->ehci = dev_read_addr_ptr(dev); mode = fdt_getprop(dt_blob, node, "dr_mode", NULL); if (mode) { if (0 == strcmp(mode, "host")) { diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index 692018243c..22e7b565b5 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -89,7 +89,7 @@ int usb_cpu_init_fail(void) #if CONFIG_IS_ENABLED(DM_USB) static int ohci_da8xx_probe(struct udevice *dev) { - struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev); + struct ohci_regs *regs = dev_read_addr_ptr(dev); struct da8xx_ohci *priv = dev_get_priv(dev); int i, err, ret, clock_nb; diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c index 631711a9e8..b84bf8ac0f 100644 --- a/drivers/usb/host/ohci-generic.c +++ b/drivers/usb/host/ohci-generic.c @@ -79,7 +79,7 @@ static int ohci_shutdown_phy(struct udevice *dev) static int ohci_usb_probe(struct udevice *dev) { - struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev); + struct ohci_regs *regs = dev_read_addr_ptr(dev); struct generic_ohci *priv = dev_get_priv(dev); int i, err, ret, clock_nb, reset_nb; diff --git a/drivers/video/atmel_hlcdfb.c b/drivers/video/atmel_hlcdfb.c index 35a56a8eab..38def2816b 100644 --- a/drivers/video/atmel_hlcdfb.c +++ b/drivers/video/atmel_hlcdfb.c @@ -507,7 +507,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev) const void *blob = gd->fdt_blob; int node = dev_of_offset(dev); - priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); if (!priv->regs) { debug("%s: No display controller address\n", __func__); return -EINVAL; diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c index 1208d91286..827ea13d13 100644 --- a/drivers/video/tegra.c +++ b/drivers/video/tegra.c @@ -346,7 +346,7 @@ static int tegra_lcd_ofdata_to_platdata(struct udevice *dev) int rgb; int ret; - priv->disp = (struct disp_ctlr *)devfdt_get_addr(dev); + priv->disp = dev_read_addr_ptr(dev); if (!priv->disp) { debug("%s: No display controller address\n", __func__); return -EINVAL; diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index ed8b2199c2..9059a4c610 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -237,7 +237,7 @@ static int omap3_wdt_probe(struct udevice *dev) { struct omap3_wdt_priv *priv = dev_get_priv(dev); - priv->regs = (struct wd_timer *)devfdt_get_addr(dev); + priv->regs = dev_read_addr_ptr(dev); if (!priv->regs) return -EINVAL; -- cgit From 6f25e274da48e938bbd33395881d38f0a4be8682 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Jul 2020 14:36:47 +0900 Subject: treewide: remove (phys_addr_t) casts from devfdt_get_addr() This cast is unneeded. Signed-off-by: Masahiro Yamada --- drivers/net/fec_mxc.c | 2 +- drivers/net/fsl_mcdmafec.c | 2 +- drivers/net/mcffec.c | 2 +- drivers/net/xilinx_axi_emac.c | 2 +- drivers/net/xilinx_emaclite.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index b3d4acb106..a3f6e3adaf 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1534,7 +1534,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) struct fec_priv *priv = dev_get_priv(dev); const char *phy_mode; - pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); + pdata->iobase = devfdt_get_addr(dev); priv->eth = (struct ethernet_regs *)pdata->iobase; pdata->phy_interface = -1; diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c index f33529cb67..4c9a62ad50 100644 --- a/drivers/net/fsl_mcdmafec.c +++ b/drivers/net/fsl_mcdmafec.c @@ -570,7 +570,7 @@ static int mcdmafec_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); const u32 *val; - pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); + pdata->iobase = devfdt_get_addr(dev); /* Default to 10Mbit/s */ pdata->max_speed = 10; diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index 1a8351be1c..d8367b5da8 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -589,7 +589,7 @@ static int mcffec_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); const u32 *val; - pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); + pdata->iobase = devfdt_get_addr(dev); /* Default to 10Mbit/s */ pdata->max_speed = 10; diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 2cd5596768..35176c545e 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -722,7 +722,7 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev) int offset = 0; const char *phy_mode; - pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); + pdata->iobase = devfdt_get_addr(dev); priv->iobase = (struct axi_regs *)pdata->iobase; offset = fdtdec_lookup_phandle(gd->fdt_blob, node, diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index 9bdb6798b6..e7f7e6ad1d 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -599,7 +599,7 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev) struct xemaclite *emaclite = dev_get_priv(dev); int offset = 0; - pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); + pdata->iobase = devfdt_get_addr(dev); emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase, 0x10000); -- cgit From 60e7fa8b3b8538aae1e644dac61d5e4076901edb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 17 Jul 2020 14:36:48 +0900 Subject: treewide: convert devfdt_get_addr() to dev_read_addr() When you enable CONFIG_OF_LIVE, you will end up with a lot of conversions. To generate this commit, I used coccinelle excluding drivers/core/, include/dm/, and test/ The semantic patch that makes this change is as follows: @@ expression dev; @@ -devfdt_get_addr(dev) +dev_read_addr(dev) Signed-off-by: Masahiro Yamada --- arch/arm/mach-snapdragon/clock-snapdragon.c | 2 +- arch/arm/mach-snapdragon/pinctrl-snapdragon.c | 2 +- drivers/ata/dwc_ahci.c | 2 +- drivers/clk/altera/clk-agilex.c | 2 +- drivers/clk/altera/clk-arria10.c | 2 +- drivers/clk/exynos/clk-exynos7420.c | 4 ++-- drivers/clk/uniphier/clk-uniphier-core.c | 2 +- drivers/dma/ti-edma3.c | 2 +- drivers/gpio/altera_pio.c | 2 +- drivers/gpio/atmel_pio4.c | 2 +- drivers/gpio/bcm2835_gpio.c | 2 +- drivers/gpio/da8xx_gpio.c | 2 +- drivers/gpio/gpio-rza1.c | 2 +- drivers/gpio/gpio-uniphier.c | 2 +- drivers/gpio/msm_gpio.c | 2 +- drivers/gpio/mxc_gpio.c | 2 +- drivers/gpio/mxs_gpio.c | 2 +- drivers/gpio/omap_gpio.c | 4 ++-- drivers/gpio/pm8916_gpio.c | 2 +- drivers/gpio/s5p_gpio.c | 2 +- drivers/gpio/sifive-gpio.c | 2 +- drivers/gpio/vybrid_gpio.c | 2 +- drivers/i2c/i2c-uniphier-f.c | 2 +- drivers/i2c/i2c-uniphier.c | 2 +- drivers/i2c/imx_lpi2c.c | 2 +- drivers/i2c/iproc_i2c.c | 2 +- drivers/i2c/mxc_i2c.c | 2 +- drivers/i2c/omap24xx_i2c.c | 2 +- drivers/mailbox/tegra-hsp.c | 2 +- drivers/misc/altera_sysid.c | 2 +- drivers/misc/imx8/scu.c | 2 +- drivers/misc/microchip_flexcom.c | 2 +- drivers/mmc/bcm2835_sdhci.c | 2 +- drivers/mmc/bcm2835_sdhost.c | 2 +- drivers/mmc/bcmstb_sdhci.c | 2 +- drivers/mmc/jz_mmc.c | 2 +- drivers/mmc/meson_gx_mmc.c | 2 +- drivers/mmc/omap_hsmmc.c | 4 ++-- drivers/mmc/sdhci-cadence.c | 2 +- drivers/mmc/sh_mmcif.c | 2 +- drivers/mmc/sh_sdhi.c | 2 +- drivers/mmc/tangier_sdhci.c | 2 +- drivers/mmc/tmio-common.c | 2 +- drivers/net/ag7xxx.c | 2 +- drivers/net/dwc_eth_qos.c | 4 ++-- drivers/net/ethoc.c | 2 +- drivers/net/fec_mxc.c | 2 +- drivers/net/fsl_mcdmafec.c | 2 +- drivers/net/ftgmac100.c | 2 +- drivers/net/ftmac100.c | 2 +- drivers/net/ks8851_mll.c | 2 +- drivers/net/mcffec.c | 2 +- drivers/net/mtk_eth.c | 2 +- drivers/net/mvgbe.c | 2 +- drivers/net/mvneta.c | 2 +- drivers/net/ravb.c | 2 +- drivers/net/sh_eth.c | 2 +- drivers/net/smc911x.c | 2 +- drivers/net/sni_ave.c | 2 +- drivers/net/sun8i_emac.c | 2 +- drivers/net/sunxi_emac.c | 2 +- drivers/net/ti/keystone_net.c | 2 +- drivers/net/xilinx_axi_emac.c | 2 +- drivers/net/xilinx_emaclite.c | 2 +- drivers/pinctrl/ath79/pinctrl_ar933x.c | 2 +- drivers/pinctrl/ath79/pinctrl_qca953x.c | 2 +- drivers/pinctrl/exynos/pinctrl-exynos.c | 2 +- drivers/pinctrl/pinctrl-at91-pio4.c | 2 +- drivers/pinctrl/renesas/pfc-r7s72100.c | 2 +- drivers/pinctrl/renesas/pfc.c | 2 +- drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | 2 +- drivers/reset/reset-uniphier.c | 2 +- drivers/rtc/mvrtc.c | 2 +- drivers/serial/altera_jtag_uart.c | 2 +- drivers/serial/altera_uart.c | 2 +- drivers/serial/atmel_usart.c | 2 +- drivers/serial/serial_ar933x.c | 2 +- drivers/serial/serial_bcm283x_mu.c | 2 +- drivers/serial/serial_lpuart.c | 2 +- drivers/serial/serial_mcf.c | 2 +- drivers/serial/serial_meson.c | 2 +- drivers/serial/serial_msm.c | 2 +- drivers/serial/serial_mxc.c | 2 +- drivers/serial/serial_pl01x.c | 2 +- drivers/serial/serial_s5p.c | 2 +- drivers/serial/serial_sh.c | 2 +- drivers/serial/serial_sti_asc.c | 2 +- drivers/serial/serial_stm32.c | 2 +- drivers/serial/serial_uniphier.c | 2 +- drivers/spi/altera_spi.c | 2 +- drivers/spi/atcspi200_spi.c | 2 +- drivers/spi/ath79_spi.c | 2 +- drivers/spi/cf_spi.c | 2 +- drivers/spi/davinci_spi.c | 2 +- drivers/spi/fsl_dspi.c | 2 +- drivers/spi/mxc_spi.c | 2 +- drivers/spi/omap3_spi.c | 2 +- drivers/spi/spi-sunxi.c | 2 +- drivers/spi/tegra20_sflash.c | 2 +- drivers/spi/tegra20_slink.c | 2 +- drivers/spi/ti_qspi.c | 2 +- drivers/spi/zynqmp_gqspi.c | 4 ++-- drivers/spmi/spmi-msm.c | 2 +- drivers/timer/ag101p_timer.c | 2 +- drivers/timer/altera_timer.c | 2 +- drivers/timer/atcpit100_timer.c | 2 +- drivers/timer/omap-timer.c | 2 +- drivers/usb/dwc3/dwc3-uniphier.c | 2 +- drivers/usb/host/ehci-atmel.c | 2 +- drivers/usb/host/ehci-exynos.c | 2 +- drivers/usb/host/ehci-fsl.c | 2 +- drivers/usb/host/ehci-marvell.c | 2 +- drivers/usb/host/xhci-exynos5.c | 2 +- drivers/usb/host/xhci-fsl.c | 2 +- drivers/usb/host/xhci-mvebu.c | 2 +- drivers/usb/host/xhci-rcar.c | 2 +- drivers/video/exynos/exynos_dp.c | 2 +- drivers/video/exynos/exynos_fb.c | 2 +- drivers/w1/mxc_w1.c | 2 +- drivers/watchdog/stm32mp_wdt.c | 2 +- 120 files changed, 125 insertions(+), 125 deletions(-) diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.c b/arch/arm/mach-snapdragon/clock-snapdragon.c index 85526186c6..69d65c82e3 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.c +++ b/arch/arm/mach-snapdragon/clock-snapdragon.c @@ -114,7 +114,7 @@ static int msm_clk_probe(struct udevice *dev) { struct msm_clk_priv *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c index 442d236255..4c2af21308 100644 --- a/arch/arm/mach-snapdragon/pinctrl-snapdragon.c +++ b/arch/arm/mach-snapdragon/pinctrl-snapdragon.c @@ -56,7 +56,7 @@ static int msm_pinctrl_probe(struct udevice *dev) { struct msm_pinctrl_priv *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); priv->data = (struct msm_pinctrl_data *)dev->driver_data; return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0; diff --git a/drivers/ata/dwc_ahci.c b/drivers/ata/dwc_ahci.c index 017650ae46..825fe57f85 100644 --- a/drivers/ata/dwc_ahci.c +++ b/drivers/ata/dwc_ahci.c @@ -34,7 +34,7 @@ static int dwc_ahci_ofdata_to_platdata(struct udevice *dev) struct dwc_ahci_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *), + priv->base = map_physmem(dev_read_addr(dev), sizeof(void *), MAP_NOCACHE); addr = devfdt_get_addr_index(dev, 1); diff --git a/drivers/clk/altera/clk-agilex.c b/drivers/clk/altera/clk-agilex.c index 0042958f4c..9927ada201 100644 --- a/drivers/clk/altera/clk-agilex.c +++ b/drivers/clk/altera/clk-agilex.c @@ -553,7 +553,7 @@ static int socfpga_clk_ofdata_to_platdata(struct udevice *dev) struct socfpga_clk_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; plat->regs = (void __iomem *)addr; diff --git a/drivers/clk/altera/clk-arria10.c b/drivers/clk/altera/clk-arria10.c index ede0be299d..732ed4d79b 100644 --- a/drivers/clk/altera/clk-arria10.c +++ b/drivers/clk/altera/clk-arria10.c @@ -285,7 +285,7 @@ static int socfpga_a10_clk_probe(struct udevice *dev) socfpga_a10_handoff_workaround(dev); if (!fdt_node_check_compatible(fdt, offset, "altr,clk-mgr")) { - plat->regs = devfdt_get_addr(dev); + plat->regs = dev_read_addr(dev); } else { pdev = dev_get_parent(dev); if (!pdev) diff --git a/drivers/clk/exynos/clk-exynos7420.c b/drivers/clk/exynos/clk-exynos7420.c index aa86c7ca44..4a023ea736 100644 --- a/drivers/clk/exynos/clk-exynos7420.c +++ b/drivers/clk/exynos/clk-exynos7420.c @@ -95,7 +95,7 @@ static int exynos7420_clk_topc_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; @@ -149,7 +149,7 @@ static int exynos7420_clk_top0_probe(struct udevice *dev) if (!priv) return -EINVAL; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c index c9ec523080..4e25db354e 100644 --- a/drivers/clk/uniphier/clk-uniphier-core.c +++ b/drivers/clk/uniphier/clk-uniphier-core.c @@ -253,7 +253,7 @@ static int uniphier_clk_probe(struct udevice *dev) struct uniphier_clk_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev->parent); + addr = dev_read_addr(dev->parent); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/dma/ti-edma3.c b/drivers/dma/ti-edma3.c index 77c4ba9530..13ab967089 100644 --- a/drivers/dma/ti-edma3.c +++ b/drivers/dma/ti-edma3.c @@ -546,7 +546,7 @@ static int ti_edma3_ofdata_to_platdata(struct udevice *dev) { struct ti_edma3_priv *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); return 0; } diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c index 324f9c29a8..75800d9f31 100644 --- a/drivers/gpio/altera_pio.c +++ b/drivers/gpio/altera_pio.c @@ -88,7 +88,7 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev) { struct altera_pio_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_pio_regs), MAP_NOCACHE); plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c index 455944d547..18f365fa41 100644 --- a/drivers/gpio/atmel_pio4.c +++ b/drivers/gpio/atmel_pio4.c @@ -299,7 +299,7 @@ static int atmel_pio4_probe(struct udevice *dev) clk_free(&clk); - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c index f4b67f1cf0..0dff9ac711 100644 --- a/drivers/gpio/bcm2835_gpio.c +++ b/drivers/gpio/bcm2835_gpio.c @@ -121,7 +121,7 @@ static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev) struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/da8xx_gpio.c b/drivers/gpio/da8xx_gpio.c index ab0a5cfd33..f875888510 100644 --- a/drivers/gpio/da8xx_gpio.c +++ b/drivers/gpio/da8xx_gpio.c @@ -545,7 +545,7 @@ static int davinci_gpio_ofdata_to_platdata(struct udevice *dev) struct davinci_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/gpio-rza1.c b/drivers/gpio/gpio-rza1.c index 21a87d645c..86804ac2f5 100644 --- a/drivers/gpio/gpio-rza1.c +++ b/drivers/gpio/gpio-rza1.c @@ -112,7 +112,7 @@ static int r7s72100_gpio_probe(struct udevice *dev) uc_priv->bank_name = dev->name; dev = dev_get_parent(dev); - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c index 30392bccaa..54a38da0f1 100644 --- a/drivers/gpio/gpio-uniphier.c +++ b/drivers/gpio/gpio-uniphier.c @@ -142,7 +142,7 @@ static int uniphier_gpio_probe(struct udevice *dev) struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c index ac5d20c1b9..fe6b33e1df 100644 --- a/drivers/gpio/msm_gpio.c +++ b/drivers/gpio/msm_gpio.c @@ -96,7 +96,7 @@ static int msm_gpio_probe(struct udevice *dev) { struct msm_gpio_bank *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0; } diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index 90d36fb87b..a16f5719ed 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -300,7 +300,7 @@ static int mxc_gpio_ofdata_to_platdata(struct udevice *dev) fdt_addr_t addr; struct mxc_gpio_plat *plat = dev_get_platdata(dev); - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c index cb797261b7..2c16517e72 100644 --- a/drivers/gpio/mxs_gpio.c +++ b/drivers/gpio/mxs_gpio.c @@ -275,7 +275,7 @@ static int mxs_ofdata_to_platdata(struct udevice *dev) int node = dev_of_offset(dev); int ret; - plat->bank = devfdt_get_addr(dev); + plat->bank = dev_read_addr(dev); if (plat->bank == FDT_ADDR_T_NONE) { printf("%s: No 'reg' property defined!\n", __func__); return -EINVAL; diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index c986ef0380..6eaa0a08a2 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -308,7 +308,7 @@ static int omap_gpio_bind(struct udevice *dev) if (plat) return 0; - base_addr = devfdt_get_addr(dev); + base_addr = dev_read_addr(dev); if (base_addr == FDT_ADDR_T_NONE) return -EINVAL; @@ -347,7 +347,7 @@ static int omap_gpio_ofdata_to_platdata(struct udevice *dev) struct omap_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c index 51df5367ea..58f044678b 100644 --- a/drivers/gpio/pm8916_gpio.c +++ b/drivers/gpio/pm8916_gpio.c @@ -256,7 +256,7 @@ static int pm8941_pwrkey_probe(struct udevice *dev) struct pm8916_gpio_bank *priv = dev_get_priv(dev); int reg; - priv->pid = devfdt_get_addr(dev); + priv->pid = dev_read_addr(dev); if (priv->pid == FDT_ADDR_T_NONE) return log_msg_ret("bad address", -EINVAL); diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 4a68f44704..c78227f4da 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -339,7 +339,7 @@ static int gpio_exynos_bind(struct udevice *parent) dev_set_of_offset(dev, node); - reg = devfdt_get_addr(dev); + reg = dev_read_addr(dev); if (reg != FDT_ADDR_T_NONE) bank = (struct s5p_gpio_bank *)((ulong)base + reg); diff --git a/drivers/gpio/sifive-gpio.c b/drivers/gpio/sifive-gpio.c index 24da3b3c23..bf3537b76b 100644 --- a/drivers/gpio/sifive-gpio.c +++ b/drivers/gpio/sifive-gpio.c @@ -159,7 +159,7 @@ static int sifive_gpio_ofdata_to_platdata(struct udevice *dev) struct sifive_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c index d2c1d7d859..4efff5c364 100644 --- a/drivers/gpio/vybrid_gpio.c +++ b/drivers/gpio/vybrid_gpio.c @@ -109,7 +109,7 @@ static int vybrid_gpio_odata_to_platdata(struct udevice *dev) struct vybrid_gpio_platdata *plat = dev_get_platdata(dev); fdt_addr_t base_addr; - base_addr = devfdt_get_addr(dev); + base_addr = dev_read_addr(dev); if (base_addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c index d8b4a683bc..a110fe9e8d 100644 --- a/drivers/i2c/i2c-uniphier-f.c +++ b/drivers/i2c/i2c-uniphier-f.c @@ -94,7 +94,7 @@ static int uniphier_fi2c_probe(struct udevice *dev) fdt_addr_t addr; struct uniphier_fi2c_priv *priv = dev_get_priv(dev); - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c index f06523ab99..e7f44e14e9 100644 --- a/drivers/i2c/i2c-uniphier.c +++ b/drivers/i2c/i2c-uniphier.c @@ -50,7 +50,7 @@ static int uniphier_i2c_probe(struct udevice *dev) fdt_addr_t addr; struct uniphier_i2c_priv *priv = dev_get_priv(dev); - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index b7b2aafc7f..feeed1e9a2 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -447,7 +447,7 @@ static int imx_lpi2c_probe(struct udevice *bus) i2c_bus->driver_data = dev_get_driver_data(bus); - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/i2c/iproc_i2c.c b/drivers/i2c/iproc_i2c.c index a846e0a1fe..b7e9ced898 100644 --- a/drivers/i2c/iproc_i2c.c +++ b/drivers/i2c/iproc_i2c.c @@ -678,7 +678,7 @@ static int iproc_i2c_ofdata_to_platdata(struct udevice *bus) int node = dev_of_offset(bus); const void *blob = gd->fdt_blob; - bus_prvdata->base = map_physmem(devfdt_get_addr(bus), + bus_prvdata->base = map_physmem(dev_read_addr(bus), sizeof(void *), MAP_NOCACHE); diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 3b0d27e6cd..1a1de67252 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -899,7 +899,7 @@ static int mxc_i2c_probe(struct udevice *bus) i2c_bus->driver_data = dev_get_driver_data(bus); - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 8592a819c4..0af4e333c4 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -1067,7 +1067,7 @@ static int omap_i2c_ofdata_to_platdata(struct udevice *bus) { struct omap_i2c_platdata *plat = dev_get_platdata(bus); - plat->base = devfdt_get_addr(bus); + plat->base = dev_read_addr(bus); plat->speed = dev_read_u32_default(bus, "clock-frequency", I2C_SPEED_STANDARD_RATE); plat->ip_rev = dev_get_driver_data(bus); diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index f82e6d3d16..e91dac201d 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -153,7 +153,7 @@ static int tegra_hsp_probe(struct udevice *dev) debug("%s(dev=%p)\n", __func__, dev); - thsp->regs = devfdt_get_addr(dev); + thsp->regs = dev_read_addr(dev); if (thsp->regs == FDT_ADDR_T_NONE) return -ENODEV; diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c index 387c70b070..c6502650b7 100644 --- a/drivers/misc/altera_sysid.c +++ b/drivers/misc/altera_sysid.c @@ -73,7 +73,7 @@ static int altera_sysid_ofdata_to_platdata(struct udevice *dev) { struct altera_sysid_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_sysid_regs), MAP_NOCACHE); diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index ee635eb947..223aac8518 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -187,7 +187,7 @@ static int imx8_scu_probe(struct udevice *dev) debug("%s(dev=%p) (plat=%p)\n", __func__, dev, plat); - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/misc/microchip_flexcom.c b/drivers/misc/microchip_flexcom.c index 44a8b180a4..64cc4ae7b6 100644 --- a/drivers/misc/microchip_flexcom.c +++ b/drivers/misc/microchip_flexcom.c @@ -26,7 +26,7 @@ static int microchip_flexcom_ofdata_to_platdata(struct udevice *dev) struct microchip_flexcom_platdata *plat = dev_get_platdata(dev); int ret; - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct microchip_flexcom_regs), MAP_NOCACHE); diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 5cdf3c506f..7a410d1dd3 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -182,7 +182,7 @@ static int bcm2835_sdhci_probe(struct udevice *dev) int ret; int clock_id = (int)dev_get_driver_data(dev); - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/bcm2835_sdhost.c b/drivers/mmc/bcm2835_sdhost.c index c4876e81f8..b793028ab5 100644 --- a/drivers/mmc/bcm2835_sdhost.c +++ b/drivers/mmc/bcm2835_sdhost.c @@ -766,7 +766,7 @@ static int bcm2835_probe(struct udevice *dev) upriv->mmc = &plat->mmc; plat->cfg.name = dev->name; - host->phys_addr = devfdt_get_addr(dev); + host->phys_addr = dev_read_addr(dev); if (host->phys_addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/bcmstb_sdhci.c b/drivers/mmc/bcmstb_sdhci.c index c14f8289e6..5269aa77ce 100644 --- a/drivers/mmc/bcmstb_sdhci.c +++ b/drivers/mmc/bcmstb_sdhci.c @@ -62,7 +62,7 @@ static int sdhci_bcmstb_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c index d3f1eddf45..b33f085073 100644 --- a/drivers/mmc/jz_mmc.c +++ b/drivers/mmc/jz_mmc.c @@ -450,7 +450,7 @@ static int jz_mmc_ofdata_to_platdata(struct udevice *dev) struct mmc_config *cfg; int ret; - priv->regs = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE); + priv->regs = map_physmem(dev_read_addr(dev), 0x100, MAP_NOCACHE); cfg = &plat->cfg; cfg->name = "MSC"; diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index b7f793cd04..719dd1e5e5 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -228,7 +228,7 @@ static int meson_mmc_ofdata_to_platdata(struct udevice *dev) struct meson_mmc_platdata *pdata = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index db1f85125f..715eee0e3e 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -1911,7 +1911,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev) int node = dev_of_offset(dev); int ret; - plat->base_addr = map_physmem(devfdt_get_addr(dev), + plat->base_addr = map_physmem(dev_read_addr(dev), sizeof(struct hsmmc *), MAP_NOCACHE); @@ -1933,7 +1933,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev) plat->controller_flags |= of_data->controller_flags; #ifdef CONFIG_OMAP54XX - fixups = platform_fixups_mmc(devfdt_get_addr(dev)); + fixups = platform_fixups_mmc(dev_read_addr(dev)); if (fixups) { plat->hw_rev = fixups->hw_rev; cfg->host_caps &= ~fixups->unsupported_caps; diff --git a/drivers/mmc/sdhci-cadence.c b/drivers/mmc/sdhci-cadence.c index 7b5010b655..cc99bebc30 100644 --- a/drivers/mmc/sdhci-cadence.c +++ b/drivers/mmc/sdhci-cadence.c @@ -260,7 +260,7 @@ static int sdhci_cdns_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/sh_mmcif.c b/drivers/mmc/sh_mmcif.c index 2e994d0178..ad386909e9 100644 --- a/drivers/mmc/sh_mmcif.c +++ b/drivers/mmc/sh_mmcif.c @@ -680,7 +680,7 @@ static int sh_mmcif_dm_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c index 772fe943e4..315f95cce8 100644 --- a/drivers/mmc/sh_sdhi.c +++ b/drivers/mmc/sh_sdhi.c @@ -834,7 +834,7 @@ static int sh_sdhi_dm_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/tangier_sdhci.c b/drivers/mmc/tangier_sdhci.c index 0d6e5d6246..879e2c98a2 100644 --- a/drivers/mmc/tangier_sdhci.c +++ b/drivers/mmc/tangier_sdhci.c @@ -35,7 +35,7 @@ static int sdhci_tangier_probe(struct udevice *dev) fdt_addr_t base; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c index 20cd237ef0..c653973676 100644 --- a/drivers/mmc/tmio-common.c +++ b/drivers/mmc/tmio-common.c @@ -722,7 +722,7 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks) ulong mclk; int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c index 3b5d11f956..ccba3947ac 100644 --- a/drivers/net/ag7xxx.c +++ b/drivers/net/ag7xxx.c @@ -1256,7 +1256,7 @@ static int ag7xxx_eth_ofdata_to_platdata(struct udevice *dev) const char *phy_mode; int ret; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; /* Decoding of convoluted PHY wiring on Atheros MIPS. */ diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 62941bb175..1d9eefbb3e 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1995,9 +1995,9 @@ static int eqos_probe(struct udevice *dev) eqos->dev = dev; eqos->config = (void *)dev_get_driver_data(dev); - eqos->regs = devfdt_get_addr(dev); + eqos->regs = dev_read_addr(dev); if (eqos->regs == FDT_ADDR_T_NONE) { - pr_err("devfdt_get_addr() failed"); + pr_err("dev_read_addr() failed"); return -ENODEV; } eqos->mac_regs = (void *)(eqos->regs + EQOS_MAC_REGS_BASE); diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index fd589a0764..b9d80a5b08 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -690,7 +690,7 @@ static int ethoc_ofdata_to_platdata(struct udevice *dev) struct ethoc_eth_pdata *pdata = dev_get_platdata(dev); fdt_addr_t addr; - pdata->eth_pdata.iobase = devfdt_get_addr(dev); + pdata->eth_pdata.iobase = dev_read_addr(dev); addr = devfdt_get_addr_index(dev, 1); if (addr != FDT_ADDR_T_NONE) pdata->packet_base = addr; diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index a3f6e3adaf..bb55be9a26 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1534,7 +1534,7 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) struct fec_priv *priv = dev_get_priv(dev); const char *phy_mode; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); priv->eth = (struct ethernet_regs *)pdata->iobase; pdata->phy_interface = -1; diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c index 4c9a62ad50..e27f7e5321 100644 --- a/drivers/net/fsl_mcdmafec.c +++ b/drivers/net/fsl_mcdmafec.c @@ -570,7 +570,7 @@ static int mcdmafec_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); const u32 *val; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); /* Default to 10Mbit/s */ pdata->max_speed = 10; diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index e4d08f2ba0..5676a5b3ba 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -517,7 +517,7 @@ static int ftgmac100_ofdata_to_platdata(struct udevice *dev) struct ftgmac100_data *priv = dev_get_priv(dev); const char *phy_mode; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; phy_mode = dev_read_string(dev, "phy-mode"); if (phy_mode) diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 79c64ec89a..292690de96 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -398,7 +398,7 @@ static int ftmac100_ofdata_to_platdata(struct udevice *dev) struct ftmac100_data *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); const char *mac; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); priv->iobase = pdata->iobase; mac = dtbmacaddr(0); if (mac) diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c index 1773c7671f..d22668446d 100644 --- a/drivers/net/ks8851_mll.c +++ b/drivers/net/ks8851_mll.c @@ -642,7 +642,7 @@ static int ks8851_ofdata_to_platdata(struct udevice *dev) struct ks_net *ks = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); ks->iobase = pdata->iobase; return 0; diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index d8367b5da8..f94a2d8123 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -589,7 +589,7 @@ static int mcffec_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); const u32 *val; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); /* Default to 10Mbit/s */ pdata->max_speed = 10; diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index 86f1360ae3..a06a15772c 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -1418,7 +1418,7 @@ static int mtk_eth_ofdata_to_platdata(struct udevice *dev) priv->soc = dev_get_driver_data(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); /* get corresponding ethsys phandle */ ret = dev_read_phandle_with_args(dev, "mediatek,ethsys", NULL, 0, 0, diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index 86b1b8cee5..2f9464b961 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -997,7 +997,7 @@ static int mvgbe_ofdata_to_platdata(struct udevice *dev) int pnode; unsigned long addr; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; pnode = fdt_node_offset_by_compatible(blob, node, diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index 092f619bd5..4c7d06ca40 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -1796,7 +1796,7 @@ static int mvneta_ofdata_to_platdata(struct udevice *dev) struct eth_pdata *pdata = dev_get_platdata(dev); const char *phy_mode; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); /* Get phy-mode / phy_interface from DT */ pdata->phy_interface = -1; diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 393ee9bb81..886f53ee82 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -651,7 +651,7 @@ int ravb_ofdata_to_platdata(struct udevice *dev) const fdt32_t *cell; int ret = 0; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 8823769edd..4cbffb14c5 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -918,7 +918,7 @@ int sh_ether_ofdata_to_platdata(struct udevice *dev) const fdt32_t *cell; int ret = 0; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 9c5dc46483..09372d7f6b 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -612,7 +612,7 @@ static int smc911x_ofdata_to_platdata(struct udevice *dev) struct smc911x_priv *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); priv->iobase = pdata->iobase; return 0; diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c index 0784635689..0f7ada8c3e 100644 --- a/drivers/net/sni_ave.c +++ b/drivers/net/sni_ave.c @@ -746,7 +746,7 @@ static int ave_ofdata_to_platdata(struct udevice *dev) if (!priv->data) return -EINVAL; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index e2b05ace8f..546cc6ccb6 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -919,7 +919,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) #endif int ret; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); if (pdata->iobase == FDT_ADDR_T_NONE) { debug("%s: Cannot find MAC base address\n", __func__); return -EINVAL; diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 6364beb9f2..df18ecc064 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -594,7 +594,7 @@ static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); return 0; } diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index e3ac40ca0d..50f0d33a83 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -787,7 +787,7 @@ static int ks2_eth_ofdata_to_platdata(struct udevice *dev) ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); return 0; } diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 35176c545e..99d4d85c52 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -722,7 +722,7 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev) int offset = 0; const char *phy_mode; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); priv->iobase = (struct axi_regs *)pdata->iobase; offset = fdtdec_lookup_phandle(gd->fdt_blob, node, diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index e7f7e6ad1d..64c18bae74 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -599,7 +599,7 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev) struct xemaclite *emaclite = dev_get_priv(dev); int offset = 0; - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); emaclite->regs = (struct emaclite_regs *)ioremap_nocache(pdata->iobase, 0x10000); diff --git a/drivers/pinctrl/ath79/pinctrl_ar933x.c b/drivers/pinctrl/ath79/pinctrl_ar933x.c index a0625d7c83..61e8081874 100644 --- a/drivers/pinctrl/ath79/pinctrl_ar933x.c +++ b/drivers/pinctrl/ath79/pinctrl_ar933x.c @@ -111,7 +111,7 @@ static int ar933x_pinctrl_probe(struct udevice *dev) struct ar933x_pinctrl_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/ath79/pinctrl_qca953x.c b/drivers/pinctrl/ath79/pinctrl_qca953x.c index c9f9608c92..2d5a4a3ab2 100644 --- a/drivers/pinctrl/ath79/pinctrl_qca953x.c +++ b/drivers/pinctrl/ath79/pinctrl_qca953x.c @@ -131,7 +131,7 @@ static int qca953x_pinctrl_probe(struct udevice *dev) struct qca953x_pinctrl_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c index e3ac5a6e49..4cdc071d55 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos.c @@ -127,7 +127,7 @@ int exynos_pinctrl_probe(struct udevice *dev) if (!priv) return -EINVAL; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index 801d14253c..fdb7920b55 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -158,7 +158,7 @@ static int atmel_pinctrl_probe(struct udevice *dev) fdt_addr_t addr_base; dev = dev_get_parent(dev); - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/renesas/pfc-r7s72100.c b/drivers/pinctrl/renesas/pfc-r7s72100.c index 5055780bf7..9d7814a5f2 100644 --- a/drivers/pinctrl/renesas/pfc-r7s72100.c +++ b/drivers/pinctrl/renesas/pfc-r7s72100.c @@ -112,7 +112,7 @@ static int r7s72100_pfc_probe(struct udevice *dev) fdt_addr_t addr_base; ofnode node; - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c index 1179afd2e7..340c8c0a74 100644 --- a/drivers/pinctrl/renesas/pfc.c +++ b/drivers/pinctrl/renesas/pfc.c @@ -817,7 +817,7 @@ static int sh_pfc_pinctrl_probe(struct udevice *dev) enum sh_pfc_model model = dev_get_driver_data(dev); fdt_addr_t base; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c index 8545b9d070..631bb1f963 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c @@ -422,7 +422,7 @@ int uniphier_pinctrl_probe(struct udevice *dev, struct uniphier_pinctrl_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev->parent); + addr = dev_read_addr(dev->parent); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c index 06079d2a9c..fe1bd5541b 100644 --- a/drivers/reset/reset-uniphier.c +++ b/drivers/reset/reset-uniphier.c @@ -247,7 +247,7 @@ static int uniphier_reset_probe(struct udevice *dev) struct uniphier_reset_priv *priv = dev_get_priv(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev->parent); + addr = dev_read_addr(dev->parent); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/rtc/mvrtc.c b/drivers/rtc/mvrtc.c index 6f49505d4e..ed057f7bc4 100644 --- a/drivers/rtc/mvrtc.c +++ b/drivers/rtc/mvrtc.c @@ -172,7 +172,7 @@ static int mv_rtc_ofdata_to_platdata(struct udevice *dev) { struct mvrtc_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); return 0; } diff --git a/drivers/serial/altera_jtag_uart.c b/drivers/serial/altera_jtag_uart.c index 7a86161a0d..35b76f53f9 100644 --- a/drivers/serial/altera_jtag_uart.c +++ b/drivers/serial/altera_jtag_uart.c @@ -95,7 +95,7 @@ static int altera_jtaguart_ofdata_to_platdata(struct udevice *dev) { struct altera_jtaguart_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_jtaguart_regs), MAP_NOCACHE); diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c index f88a293d56..0be5cd75c8 100644 --- a/drivers/serial/altera_uart.c +++ b/drivers/serial/altera_uart.c @@ -87,7 +87,7 @@ static int altera_uart_ofdata_to_platdata(struct udevice *dev) { struct altera_uart_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_uart_regs), MAP_NOCACHE); plat->uartclk = dev_read_u32_default(dev, "clock-frequency", 0); diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c index 71cb31ff75..f759ea8893 100644 --- a/drivers/serial/atmel_usart.c +++ b/drivers/serial/atmel_usart.c @@ -268,7 +268,7 @@ static int atmel_serial_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) fdt_addr_t addr_base; - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -ENODEV; diff --git a/drivers/serial/serial_ar933x.c b/drivers/serial/serial_ar933x.c index 382c3b3d34..9de94b69bd 100644 --- a/drivers/serial/serial_ar933x.c +++ b/drivers/serial/serial_ar933x.c @@ -150,7 +150,7 @@ static int ar933x_serial_probe(struct udevice *dev) fdt_addr_t addr; u32 val; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 0102b10ed2..8a4af87eb6 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -171,7 +171,7 @@ static int bcm283x_mu_serial_probe(struct udevice *dev) * since we need the soc simple-bus to be probed so that the 'ranges' * property is used. */ - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c index 0c63c41270..95cbe63b3d 100644 --- a/drivers/serial/serial_lpuart.c +++ b/drivers/serial/serial_lpuart.c @@ -518,7 +518,7 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice *dev) int node = dev_of_offset(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_mcf.c b/drivers/serial/serial_mcf.c index b599064b48..402fd5343c 100644 --- a/drivers/serial/serial_mcf.c +++ b/drivers/serial/serial_mcf.c @@ -145,7 +145,7 @@ static int coldfire_ofdata_to_platdata(struct udevice *dev) struct coldfire_serial_platdata *plat = dev_get_platdata(dev); fdt_addr_t addr_base; - addr_base = devfdt_get_addr(dev); + addr_base = dev_read_addr(dev); if (addr_base == FDT_ADDR_T_NONE) return -ENODEV; diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c index 439057b1b9..8cf849f8fe 100644 --- a/drivers/serial/serial_meson.c +++ b/drivers/serial/serial_meson.c @@ -106,7 +106,7 @@ static int meson_serial_ofdata_to_platdata(struct udevice *dev) struct meson_serial_platdata *plat = dev->platdata; fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c index 0cc1aadce4..a1c9abcfbb 100644 --- a/drivers/serial/serial_msm.c +++ b/drivers/serial/serial_msm.c @@ -219,7 +219,7 @@ static int msm_serial_ofdata_to_platdata(struct udevice *dev) { struct msm_serial_data *priv = dev_get_priv(dev); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 42abb96a26..de6cefcd3a 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -330,7 +330,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev) struct mxc_serial_platdata *plat = dev->platdata; fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 6e5d81ce34..2772c25f1d 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -354,7 +354,7 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) fdt_addr_t addr; int ret; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index e3160cf1bd..9bb2be21e7 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -181,7 +181,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev) struct s5p_serial_platdata *plat = dev->platdata; fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index 5f45d58e58..13b179f03d 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -211,7 +211,7 @@ static int sh_serial_ofdata_to_platdata(struct udevice *dev) fdt_addr_t addr; int ret; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (!addr) return -EINVAL; diff --git a/drivers/serial/serial_sti_asc.c b/drivers/serial/serial_sti_asc.c index 5fbbfac820..33ff396bff 100644 --- a/drivers/serial/serial_sti_asc.c +++ b/drivers/serial/serial_sti_asc.c @@ -171,7 +171,7 @@ static int sti_asc_serial_probe(struct udevice *dev) unsigned long val; fdt_addr_t base; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c index e77b90670a..cab0db2c96 100644 --- a/drivers/serial/serial_stm32.c +++ b/drivers/serial/serial_stm32.c @@ -221,7 +221,7 @@ static int stm32_serial_ofdata_to_platdata(struct udevice *dev) { struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); - plat->base = devfdt_get_addr(dev); + plat->base = dev_read_addr(dev); if (plat->base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c index ad691b66da..4004cb8d48 100644 --- a/drivers/serial/serial_uniphier.c +++ b/drivers/serial/serial_uniphier.c @@ -115,7 +115,7 @@ static int uniphier_serial_probe(struct udevice *dev) fdt_addr_t base; u32 tmp; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 3aa7a40b77..61372c52b0 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -173,7 +173,7 @@ static int altera_spi_ofdata_to_platdata(struct udevice *bus) { struct altera_spi_platdata *plat = dev_get_platdata(bus); - plat->regs = map_physmem(devfdt_get_addr(bus), + plat->regs = map_physmem(dev_read_addr(bus), sizeof(struct altera_spi_regs), MAP_NOCACHE); diff --git a/drivers/spi/atcspi200_spi.c b/drivers/spi/atcspi200_spi.c index 328b16c277..39c6e226ba 100644 --- a/drivers/spi/atcspi200_spi.c +++ b/drivers/spi/atcspi200_spi.c @@ -378,7 +378,7 @@ static int atcspi200_ofdata_to_platadata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - ns->regs = map_physmem(devfdt_get_addr(bus), + ns->regs = map_physmem(dev_read_addr(bus), sizeof(struct atcspi200_spi_regs), MAP_NOCACHE); if (!ns->regs) { diff --git a/drivers/spi/ath79_spi.c b/drivers/spi/ath79_spi.c index f64a28c6e0..70bedc7fbe 100644 --- a/drivers/spi/ath79_spi.c +++ b/drivers/spi/ath79_spi.c @@ -178,7 +178,7 @@ static int ath79_spi_probe(struct udevice *bus) struct ath79_spi_priv *priv = dev_get_priv(bus); fdt_addr_t addr; - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c index dec92df69b..8fa6d35107 100644 --- a/drivers/spi/cf_spi.c +++ b/drivers/spi/cf_spi.c @@ -392,7 +392,7 @@ static int coldfire_dspi_ofdata_to_platdata(struct udevice *bus) int node = dev_of_offset(bus); int *ctar, len; - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) return -ENOMEM; diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index e1e9b45cc9..a11433db1e 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -396,7 +396,7 @@ static int davinci_ofdata_to_platadata(struct udevice *bus) struct davinci_spi_platdata *plat = bus->platdata; fdt_addr_t addr; - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/spi/fsl_dspi.c b/drivers/spi/fsl_dspi.c index 78ad61ca37..9396c3826f 100644 --- a/drivers/spi/fsl_dspi.c +++ b/drivers/spi/fsl_dspi.c @@ -534,7 +534,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus) plat->num_chipselect = fdtdec_get_int(blob, node, "num-cs", FSL_DSPI_MAX_CHIPSELECT); - addr = devfdt_get_addr(bus); + addr = dev_read_addr(bus); if (addr == FDT_ADDR_T_NONE) { debug("DSPI: Can't get base address or size\n"); return -ENOMEM; diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index aad3780365..e90a06a66d 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -537,7 +537,7 @@ static int mxc_spi_probe(struct udevice *bus) } } - mxcs->base = devfdt_get_addr(bus); + mxcs->base = dev_read_addr(bus); if (mxcs->base == FDT_ADDR_T_NONE) return -ENODEV; diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 39e6813469..fbf9575851 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -488,7 +488,7 @@ static int omap3_spi_probe(struct udevice *dev) struct omap2_mcspi_platform_config* data = (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev); - priv->regs = (struct mcspi *)(devfdt_get_addr(dev) + data->regs_offset); + priv->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset); if (fdtdec_get_bool(blob, node, "ti,pindir-d0-out-d1-in")) priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; else diff --git a/drivers/spi/spi-sunxi.c b/drivers/spi/spi-sunxi.c index d2dccd67e5..cd2e17bfd1 100644 --- a/drivers/spi/spi-sunxi.c +++ b/drivers/spi/spi-sunxi.c @@ -519,7 +519,7 @@ static int sun4i_spi_ofdata_to_platdata(struct udevice *bus) struct sun4i_spi_platdata *plat = dev_get_platdata(bus); int node = dev_of_offset(bus); - plat->base = devfdt_get_addr(bus); + plat->base = dev_read_addr(bus); plat->variant = (struct sun4i_spi_variant *)dev_get_driver_data(bus); plat->max_hz = fdtdec_get_int(gd->fdt_blob, node, "spi-max-frequency", diff --git a/drivers/spi/tegra20_sflash.c b/drivers/spi/tegra20_sflash.c index 22a0304bfc..771744dfe4 100644 --- a/drivers/spi/tegra20_sflash.c +++ b/drivers/spi/tegra20_sflash.c @@ -93,7 +93,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - plat->base = devfdt_get_addr(bus); + plat->base = dev_read_addr(bus); plat->periph_id = clock_decode_periph_id(bus); if (plat->periph_id == PERIPH_ID_NONE) { diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c index 3679cf06a0..f9846ee366 100644 --- a/drivers/spi/tegra20_slink.c +++ b/drivers/spi/tegra20_slink.c @@ -99,7 +99,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus) const void *blob = gd->fdt_blob; int node = dev_of_offset(bus); - plat->base = devfdt_get_addr(bus); + plat->base = dev_read_addr(bus); plat->periph_id = clock_decode_periph_id(bus); if (plat->periph_id == PERIPH_ID_NONE) { diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c index 0db0de8f1b..5fdbb49442 100644 --- a/drivers/spi/ti_qspi.c +++ b/drivers/spi/ti_qspi.c @@ -461,7 +461,7 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus) fdt_addr_t mmap_size; priv->ctrl_mod_mmap = map_syscon_chipselects(bus); - priv->base = map_physmem(devfdt_get_addr(bus), + priv->base = map_physmem(dev_read_addr(bus), sizeof(struct ti_qspi_regs), MAP_NOCACHE); mmap_addr = devfdt_get_addr_size_index(bus, 1, &mmap_size); priv->memory_map = map_physmem(mmap_addr, mmap_size, MAP_NOCACHE); diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index c3a5b3e301..a72986be90 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -181,10 +181,10 @@ static int zynqmp_qspi_ofdata_to_platdata(struct udevice *bus) debug("%s\n", __func__); - plat->regs = (struct zynqmp_qspi_regs *)(devfdt_get_addr(bus) + + plat->regs = (struct zynqmp_qspi_regs *)(dev_read_addr(bus) + GQSPI_REG_OFFSET); plat->dma_regs = (struct zynqmp_qspi_dma_regs *) - (devfdt_get_addr(bus) + GQSPI_DMA_REG_OFFSET); + (dev_read_addr(bus) + GQSPI_DMA_REG_OFFSET); return 0; } diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index ed93faffcb..2f430aed9c 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -156,7 +156,7 @@ static int msm_spmi_probe(struct udevice *dev) bool is_v1; int i; - priv->arb_chnl = devfdt_get_addr(dev); + priv->arb_chnl = dev_read_addr(dev); priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, dev_of_offset(parent), node, "reg", 1, NULL, false); priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob, diff --git a/drivers/timer/ag101p_timer.c b/drivers/timer/ag101p_timer.c index 6e20b4fc33..c011906b93 100644 --- a/drivers/timer/ag101p_timer.c +++ b/drivers/timer/ag101p_timer.c @@ -92,7 +92,7 @@ static int atftmr_timer_probe(struct udevice *dev) static int atftme_timer_ofdata_to_platdata(struct udevice *dev) { struct atftmr_timer_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct atftmr_timer_regs), MAP_NOCACHE); return 0; diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c index 6ca9501eb1..6cb2923e0b 100644 --- a/drivers/timer/altera_timer.c +++ b/drivers/timer/altera_timer.c @@ -69,7 +69,7 @@ static int altera_timer_ofdata_to_platdata(struct udevice *dev) { struct altera_timer_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev), + plat->regs = map_physmem(dev_read_addr(dev), sizeof(struct altera_timer_regs), MAP_NOCACHE); diff --git a/drivers/timer/atcpit100_timer.c b/drivers/timer/atcpit100_timer.c index c5d43b4a4a..5d4ae68509 100644 --- a/drivers/timer/atcpit100_timer.c +++ b/drivers/timer/atcpit100_timer.c @@ -89,7 +89,7 @@ static int atcpit_timer_probe(struct udevice *dev) static int atcpit_timer_ofdata_to_platdata(struct udevice *dev) { struct atcpit_timer_platdata *plat = dev_get_platdata(dev); - plat->regs = map_physmem(devfdt_get_addr(dev) , 0x100 , MAP_NOCACHE); + plat->regs = map_physmem(dev_read_addr(dev), 0x100 , MAP_NOCACHE); return 0; } diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index 700c349f37..cf3d27b96b 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -79,7 +79,7 @@ static int omap_timer_ofdata_to_platdata(struct udevice *dev) { struct omap_timer_priv *priv = dev_get_priv(dev); - priv->regs = map_physmem(devfdt_get_addr(dev), + priv->regs = map_physmem(dev_read_addr(dev), sizeof(struct omap_gptimer_regs), MAP_NOCACHE); return 0; diff --git a/drivers/usb/dwc3/dwc3-uniphier.c b/drivers/usb/dwc3/dwc3-uniphier.c index 88317b19ac..54b52dcd66 100644 --- a/drivers/usb/dwc3/dwc3-uniphier.c +++ b/drivers/usb/dwc3/dwc3-uniphier.c @@ -70,7 +70,7 @@ static int uniphier_dwc3_probe(struct udevice *dev) int (*init)(void __iomem *regs); int ret; - base = devfdt_get_addr(dev); + base = dev_read_addr(dev); if (base == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index f9083d9a64..3b208e8eb2 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c @@ -95,7 +95,7 @@ static int ehci_atmel_probe(struct udevice *dev) /* * Get the base address for EHCI controller from the device node */ - hcd_base = devfdt_get_addr(dev); + hcd_base = dev_read_addr(dev); if (hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the EHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index 0b0b2137c7..6a37c5d982 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -53,7 +53,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) /* * Get the base address for XHCI controller from the device node */ - plat->hcd_base = devfdt_get_addr(dev); + plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index ac6c5b5845..5423d10abe 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -105,7 +105,7 @@ static int ehci_fsl_probe(struct udevice *dev) /* * Get the base address for EHCI controller from the device node */ - priv->hcd_base = devfdt_get_addr(dev); + priv->hcd_base = dev_read_addr(dev); if (priv->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the EHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 8fe685af26..62414bb110 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -109,7 +109,7 @@ static int ehci_mvebu_probe(struct udevice *dev) /* * Get the base address for EHCI controller from the device node */ - priv->hcd_base = devfdt_get_addr(dev); + priv->hcd_base = dev_read_addr(dev); if (priv->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the EHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/xhci-exynos5.c b/drivers/usb/host/xhci-exynos5.c index 1705accbde..6fb7a7f6e0 100644 --- a/drivers/usb/host/xhci-exynos5.c +++ b/drivers/usb/host/xhci-exynos5.c @@ -62,7 +62,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev) /* * Get the base address for XHCI controller from the device node */ - plat->hcd_base = devfdt_get_addr(dev); + plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index d8fb2c5345..0a2da70e20 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -120,7 +120,7 @@ static int xhci_fsl_probe(struct udevice *dev) /* * Get the base address for XHCI controller from the device node */ - priv->hcd_base = devfdt_get_addr(dev); + priv->hcd_base = dev_read_addr(dev); if (priv->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c index 5fb74848c2..f2e338f6fb 100644 --- a/drivers/usb/host/xhci-mvebu.c +++ b/drivers/usb/host/xhci-mvebu.c @@ -72,7 +72,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev) /* * Get the base address for XHCI controller from the device node */ - plat->hcd_base = devfdt_get_addr(dev); + plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index 4964697f27..8fc51df3d1 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -136,7 +136,7 @@ static int xhci_rcar_ofdata_to_platdata(struct udevice *dev) { struct rcar_xhci_platdata *plat = dev_get_platdata(dev); - plat->hcd_base = devfdt_get_addr(dev); + plat->hcd_base = dev_read_addr(dev); if (plat->hcd_base == FDT_ADDR_T_NONE) { debug("Can't get the XHCI register base address\n"); return -ENXIO; diff --git a/drivers/video/exynos/exynos_dp.c b/drivers/video/exynos/exynos_dp.c index 749bde862e..999ee1c14a 100644 --- a/drivers/video/exynos/exynos_dp.c +++ b/drivers/video/exynos/exynos_dp.c @@ -884,7 +884,7 @@ static int exynos_dp_ofdata_to_platdata(struct udevice *dev) unsigned int node = dev_of_offset(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) { debug("Can't get the DP base address\n"); return -EINVAL; diff --git a/drivers/video/exynos/exynos_fb.c b/drivers/video/exynos/exynos_fb.c index d5b13a6723..979b909182 100644 --- a/drivers/video/exynos/exynos_fb.c +++ b/drivers/video/exynos/exynos_fb.c @@ -486,7 +486,7 @@ int exynos_fb_ofdata_to_platdata(struct udevice *dev) const void *blob = gd->fdt_blob; fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) { debug("Can't get the FIMD base address\n"); return -EINVAL; diff --git a/drivers/w1/mxc_w1.c b/drivers/w1/mxc_w1.c index 5bf08653a9..8e6372f0be 100644 --- a/drivers/w1/mxc_w1.c +++ b/drivers/w1/mxc_w1.c @@ -171,7 +171,7 @@ static int mxc_w1_ofdata_to_platdata(struct udevice *dev) struct mxc_w1_pdata *pdata = dev_get_platdata(dev); fdt_addr_t addr; - addr = devfdt_get_addr(dev); + addr = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/drivers/watchdog/stm32mp_wdt.c b/drivers/watchdog/stm32mp_wdt.c index 2d8bfc09a0..f673fce327 100644 --- a/drivers/watchdog/stm32mp_wdt.c +++ b/drivers/watchdog/stm32mp_wdt.c @@ -92,7 +92,7 @@ static int stm32mp_wdt_probe(struct udevice *dev) debug("IWDG init\n"); - priv->base = devfdt_get_addr(dev); + priv->base = dev_read_addr(dev); if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; -- cgit