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 {
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 @@
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 {