This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git
commit 46c91b0331838f159570616e8c2320b0e9fb5cc9 Author: Christopher Collins <ccoll...@apache.org> AuthorDate: Fri Feb 28 16:06:15 2020 -0800 manifest: Add flash helper function // FindWithinFlashAreaDevOff searches an mfg manifest for a flash area // with the specified device that contains the given offset. func (m *MfgManifest) FindWithinFlashAreaDevOff( device int, offset int) *flash.FlashArea { --- manifest/mfg_manifest.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/manifest/mfg_manifest.go b/manifest/mfg_manifest.go index 10ea6e8..4ac6b74 100644 --- a/manifest/mfg_manifest.go +++ b/manifest/mfg_manifest.go @@ -148,6 +148,22 @@ func (m *MfgManifest) FindFlashAreaDevOff(device int, offset int) *flash.FlashAr return nil } +// FindWithinFlashAreaDevOff searches an mfg manifest for a flash area with the +// specified device that contains the given offset. +func (m *MfgManifest) FindWithinFlashAreaDevOff(device int, offset int) *flash.FlashArea { + for i, _ := range m.FlashAreas { + fa := &m.FlashAreas[i] + if fa.Device == device { + end := fa.Offset + fa.Size + if offset >= offset && offset < end { + return fa + } + } + } + + return nil +} + // FindFlashAreaName searches an mfg manifest for a flash area with the // specified name. func (m *MfgManifest) FindFlashAreaName(name string) *flash.FlashArea {