summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2019-03-14 16:36:27 +1030
committerAndrew Jeffery <andrew@aj.id.au>2019-03-18 10:46:11 +1030
commit0297e5b82ea1bf8b151f8208c5f28a121d82eb4c (patch)
tree463751ccfaf4b0b94f4ad659d8c79a038fe40d6a
parentf1e547c74563d59f60d918c6fa673bb8cee6e669 (diff)
downloadphosphor-mboxbridge-0297e5b82ea1bf8b151f8208c5f28a121d82eb4c.tar.gz
phosphor-mboxbridge-0297e5b82ea1bf8b151f8208c5f28a121d82eb4c.zip
mboxd: Remove flash API compatibility shim
The flash API compatibility was kept to reduce the line noise in the previous backend patch. Remove the compatibility layer now and convert the remaining call-sites. Change-Id: I4b6e54f4463059a7804918add81e7572db7b7c21 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--control.c2
-rw-r--r--lpc.c4
-rw-r--r--mboxd.c3
-rw-r--r--mboxd.h26
-rw-r--r--test/flash_copy.c2
-rw-r--r--test/flash_erase.c26
-rw-r--r--test/flash_write.c10
-rw-r--r--vpnor/test/write_patch.cpp2
-rw-r--r--vpnor/test/write_patch_resize.cpp2
-rw-r--r--vpnor/test/write_prsv.cpp2
-rw-r--r--vpnor/test/write_ro.cpp2
-rw-r--r--vpnor/test/write_rw.cpp12
-rw-r--r--windows.c44
13 files changed, 55 insertions, 82 deletions
diff --git a/control.c b/control.c
index a02b119..acca924 100644
--- a/control.c
+++ b/control.c
@@ -62,7 +62,7 @@ int control_kill(struct mbox_context *context)
int control_modified(struct mbox_context *context)
{
/* Flash has been modified - can no longer trust our erased bytemap */
- flash_set_bytemap(context, 0, context->backend.flash_size,
+ backend_set_bytemap(&context->backend, 0, context->backend.flash_size,
FLASH_DIRTY);
/* Force daemon to reload all windows -> Set BMC event to notify host */
diff --git a/lpc.c b/lpc.c
index 3dc761a..f3f999f 100644
--- a/lpc.c
+++ b/lpc.c
@@ -138,8 +138,8 @@ int lpc_map_flash(struct mbox_context *context)
* Since the host now has access to the flash it can change it out from
* under us
*/
- return flash_set_bytemap(context, 0, context->backend.flash_size,
- FLASH_DIRTY);
+ return backend_set_bytemap(&context->backend, 0,
+ context->backend.flash_size, FLASH_DIRTY);
}
/*
diff --git a/mboxd.c b/mboxd.c
index d0c4490..a7b2283 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -437,9 +437,6 @@ finish:
protocol_events_put(context, mbox_ops);
protocol_events_put(context, dbus_ops);
-#ifdef VIRTUAL_PNOR_ENABLED
- vpnor_destroy(&context->backend);
-#endif
dbus_free(context);
backend_free(&context->backend);
lpc_dev_free(context);
diff --git a/mboxd.h b/mboxd.h
index e046785..7930242 100644
--- a/mboxd.h
+++ b/mboxd.h
@@ -103,30 +103,4 @@ struct mbox_context {
uint32_t lpc_base;
};
-/* Temporary flash API compatibility */
-static inline int64_t flash_copy(struct mbox_context *context, uint32_t offset,
- void *mem, uint32_t size)
-{
- return backend_copy(&context->backend, offset, mem, size);
-}
-
-static inline int flash_set_bytemap(struct mbox_context *context,
- uint32_t offset, uint32_t count,
- uint8_t val)
-{
- return backend_set_bytemap(&context->backend, offset, count, val);
-}
-
-static inline int flash_erase(struct mbox_context *context, uint32_t offset,
- uint32_t count)
-{
- return backend_erase(&context->backend, offset, count);
-}
-
-static inline int flash_write(struct mbox_context *context, uint32_t offset,
- void *buf, uint32_t count)
-{
- return backend_write(&context->backend, offset, buf, count);
-}
-
#endif /* MBOX_H */
diff --git a/test/flash_copy.c b/test/flash_copy.c
index 472315b..9300cff 100644
--- a/test/flash_copy.c
+++ b/test/flash_copy.c
@@ -71,7 +71,7 @@ int main(void)
assert(!backend_probe_mtd(&context.backend, tmp.path));
- flash_copy(&context, 0, dst, TEST_SIZE);
+ backend_copy(&context.backend, 0, dst, TEST_SIZE);
assert(0 == memcmp(src, dst, TEST_SIZE));
backend_free(&context.backend);
diff --git a/test/flash_erase.c b/test/flash_erase.c
index ad4e535..fe80f3b 100644
--- a/test/flash_erase.c
+++ b/test/flash_erase.c
@@ -117,7 +117,7 @@ int main(void)
assert(!backend_probe_mtd(backend, get_dev_mtd()));
/* Erase from an unknown state */
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 1);
@@ -129,7 +129,7 @@ int main(void)
n_ioctls = 0;
/* Erase an erased flash */
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 0);
@@ -137,9 +137,9 @@ int main(void)
memset(data, 0xaa, sizeof(data));
/* Erase written flash */
- rc = flash_write(&context, 0, data, sizeof(data));
+ rc = backend_write(backend, 0, data, sizeof(data));
assert(rc == 0);
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 1);
@@ -151,9 +151,9 @@ int main(void)
n_ioctls = 0;
/* Erase the start of flash */
- rc = flash_write(&context, 0, data, sizeof(data) - 1);
+ rc = backend_write(backend, 0, data, sizeof(data) - 1);
assert(rc == 0);
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 1);
@@ -165,9 +165,9 @@ int main(void)
n_ioctls = 0;
/* Erase the end of flash */
- rc = flash_write(&context, 1, data, sizeof(data) - 1);
+ rc = backend_write(backend, 1, data, sizeof(data) - 1);
assert(rc == 0);
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 1);
@@ -179,10 +179,10 @@ int main(void)
n_ioctls = 0;
/* Erase each end of flash */
- rc = flash_write(&context, 0, data, 1);
- rc = flash_write(&context, 2, data, 1);
+ rc = backend_write(backend, 0, data, 1);
+ rc = backend_write(backend, 2, data, 1);
assert(rc == 0);
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 2);
@@ -196,9 +196,9 @@ int main(void)
n_ioctls = 0;
/* Erase the middle of flash */
- rc = flash_write(&context, 1, data, 1);
+ rc = backend_write(backend, 1, data, 1);
assert(rc == 0);
- rc = flash_erase(&context, 0, sizeof(data));
+ rc = backend_erase(backend, 0, sizeof(data));
assert(rc == 0);
assert(n_ioctls == 1);
diff --git a/test/flash_write.c b/test/flash_write.c
index 168b2aa..c5f998c 100644
--- a/test/flash_write.c
+++ b/test/flash_write.c
@@ -74,31 +74,31 @@ int main(void)
assert(map != MAP_FAILED);
memset(src, 0xaa, sizeof(src));
- rc = flash_write(context, 0, src, sizeof(src));
+ rc = backend_write(backend, 0, src, sizeof(src));
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
memset(src, 0x55, sizeof(src));
- rc = flash_write(context, 0, src, sizeof(src));
+ rc = backend_write(backend, 0, src, sizeof(src));
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[0] = 0xff;
- rc = flash_write(context, 0, src, 1);
+ rc = backend_write(backend, 0, src, 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[1] = 0xff;
- rc = flash_write(context, 1, &src[1], 1);
+ rc = backend_write(backend, 1, &src[1], 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[2] = 0xff;
- rc = flash_write(context, 2, &src[2], 1);
+ rc = backend_write(backend, 2, &src[2], 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
diff --git a/vpnor/test/write_patch.cpp b/vpnor/test/write_patch.cpp
index 4f59db5..4a200c0 100644
--- a/vpnor/test/write_patch.cpp
+++ b/vpnor/test/write_patch.cpp
@@ -57,7 +57,7 @@ int main(void)
/* Test */
memset(src, 0x33, sizeof(src));
- rc = flash_write(ctx, 0x1000, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000, src, sizeof(src));
assert(rc == 0);
/* Check that RW file is unmodified after the patch write */
diff --git a/vpnor/test/write_patch_resize.cpp b/vpnor/test/write_patch_resize.cpp
index ce128c8..38effd6 100644
--- a/vpnor/test/write_patch_resize.cpp
+++ b/vpnor/test/write_patch_resize.cpp
@@ -56,7 +56,7 @@ int main(void)
/* Test */
std::vector<uint8_t> update(UPDATE_SIZE, 0x55);
- rc = flash_write(ctx, 0x1000, update.data(), update.size());
+ rc = backend_write(&ctx->backend, 0x1000, update.data(), update.size());
assert(rc == 0);
/* Check that PATCH is modified with the new data */
diff --git a/vpnor/test/write_prsv.cpp b/vpnor/test/write_prsv.cpp
index 9ee1fb3..134a98e 100644
--- a/vpnor/test/write_prsv.cpp
+++ b/vpnor/test/write_prsv.cpp
@@ -46,7 +46,7 @@ int main(void)
/* Test */
memset(src, 0xaa, sizeof(src));
- rc = flash_write(ctx, 0x1000, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000, src, sizeof(src));
assert(rc == 0);
/* Verify */
diff --git a/vpnor/test/write_ro.cpp b/vpnor/test/write_ro.cpp
index e6bedd3..5965ebf 100644
--- a/vpnor/test/write_ro.cpp
+++ b/vpnor/test/write_ro.cpp
@@ -43,7 +43,7 @@ int main(void)
test::VpnorRoot root(&ctx->backend, toc, BLOCK_SIZE);
/* Test */
- rc = flash_write(ctx, 0x1000, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000, src, sizeof(src));
/* Verify we can't write to RO partitions */
assert(rc != 0);
diff --git a/vpnor/test/write_rw.cpp b/vpnor/test/write_rw.cpp
index 3b742a1..cf9bf7b 100644
--- a/vpnor/test/write_rw.cpp
+++ b/vpnor/test/write_rw.cpp
@@ -48,7 +48,7 @@ int main(void)
/* Test */
memset(src, 0xbb, sizeof(src));
- rc = flash_write(ctx, 0x1000, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000, src, sizeof(src));
assert(rc == 0);
fd = open((root.rw() / "TEST1").c_str(), O_RDONLY);
map = mmap(NULL, sizeof(src), PROT_READ, MAP_SHARED, fd, 0);
@@ -58,31 +58,31 @@ int main(void)
/* Ensure single byte writes function */
memset(src, 0xcc, sizeof(src));
- rc = flash_write(ctx, 0x1000, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000, src, sizeof(src));
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[0] = 0xff;
- rc = flash_write(ctx, 0x1000, src, 1);
+ rc = backend_write(&ctx->backend, 0x1000, src, 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[1] = 0xff;
- rc = flash_write(ctx, 0x1000 + 1, &src[1], 1);
+ rc = backend_write(&ctx->backend, 0x1000 + 1, &src[1], 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
src[2] = 0xff;
- rc = flash_write(ctx, 0x1000 + 2, &src[2], 1);
+ rc = backend_write(&ctx->backend, 0x1000 + 2, &src[2], 1);
assert(rc == 0);
rc = memcmp(src, map, sizeof(src));
assert(rc == 0);
/* Writes past the end of the partition should fail */
- rc = flash_write(ctx, 0x1000 + 0xff9, src, sizeof(src));
+ rc = backend_write(&ctx->backend, 0x1000 + 0xff9, src, sizeof(src));
assert(rc < 0);
/* Check that RW file is unmodified after the bad write */
diff --git a/windows.c b/windows.c
index 8f9fb02..ebe16c1 100644
--- a/windows.c
+++ b/windows.c
@@ -191,8 +191,8 @@ int window_flush_v1(struct mbox_context *context,
MSG_ERR("Unable to allocate memory\n");
return -ENOMEM;
}
- rc = flash_copy(context, low_mem.flash_offset,
- low_mem.mem, low_mem.size);
+ rc = backend_copy(&context->backend, low_mem.flash_offset,
+ low_mem.mem, low_mem.size);
if (rc < 0) {
goto out;
}
@@ -206,8 +206,8 @@ int window_flush_v1(struct mbox_context *context,
rc = -ENOMEM;
goto out;
}
- rc = flash_copy(context, high_mem.flash_offset,
- high_mem.mem, high_mem.size);
+ rc = backend_copy(&context->backend, high_mem.flash_offset,
+ high_mem.mem, high_mem.size);
if (rc < 0) {
goto out;
}
@@ -217,9 +217,9 @@ int window_flush_v1(struct mbox_context *context,
* We need to erase the flash from low_mem.flash_offset->
* high_mem.flash_offset + high_mem.size
*/
- rc = flash_erase(context, low_mem.flash_offset,
- (high_mem.flash_offset - low_mem.flash_offset) +
- high_mem.size);
+ rc = backend_erase(&context->backend, low_mem.flash_offset,
+ (high_mem.flash_offset - low_mem.flash_offset) +
+ high_mem.size);
if (rc < 0) {
MSG_ERR("Couldn't erase flash\n");
goto out;
@@ -228,13 +228,13 @@ int window_flush_v1(struct mbox_context *context,
/* Write back over the erased area */
if (low_mem.mem) {
/* Exceed window at the start */
- rc = flash_write(context, low_mem.flash_offset, low_mem.mem,
- low_mem.size);
+ rc = backend_write(&context->backend, low_mem.flash_offset,
+ low_mem.mem, low_mem.size);
if (rc < 0) {
goto out;
}
}
- rc = flash_write(context, flash_offset,
+ rc = backend_write(&context->backend, flash_offset,
context->current->mem + offset_bytes, count_bytes);
if (rc < 0) {
goto out;
@@ -245,16 +245,16 @@ int window_flush_v1(struct mbox_context *context,
*/
if (high_mem.mem) {
/* Exceed window at the end */
- rc = flash_write(context, high_mem.flash_offset, high_mem.mem,
- high_mem.size);
+ rc = backend_write(&context->backend, high_mem.flash_offset,
+ high_mem.mem, high_mem.size);
if (rc < 0) {
goto out;
}
} else {
/* Write from the current window - it's atleast that big */
- rc = flash_write(context, high_mem.flash_offset,
- context->current->mem + offset_bytes +
- count_bytes, high_mem.size);
+ rc = backend_write(&context->backend, high_mem.flash_offset,
+ context->current->mem + offset_bytes +
+ count_bytes, high_mem.size);
if (rc < 0) {
goto out;
}
@@ -285,7 +285,8 @@ int window_flush(struct mbox_context *context, uint32_t offset,
switch (type) {
case WINDOW_ERASED: /* >= V2 ONLY -> block_size == erasesize */
flash_offset = context->current->flash_offset + offset_bytes;
- rc = flash_erase(context, flash_offset, count_bytes);
+ rc = backend_erase(&context->backend, flash_offset,
+ count_bytes);
if (rc < 0) {
MSG_ERR("Couldn't erase flash\n");
return rc;
@@ -305,15 +306,16 @@ int window_flush(struct mbox_context *context, uint32_t offset,
flash_offset = context->current->flash_offset + offset_bytes;
/* Erase the flash */
- rc = flash_erase(context, flash_offset, count_bytes);
+ rc = backend_erase(&context->backend, flash_offset,
+ count_bytes);
if (rc < 0) {
return rc;
}
/* Write to the erased flash */
- rc = flash_write(context, flash_offset,
- context->current->mem + offset_bytes,
- count_bytes);
+ rc = backend_write(&context->backend, flash_offset,
+ context->current->mem + offset_bytes,
+ count_bytes);
if (rc < 0) {
return rc;
}
@@ -620,7 +622,7 @@ int windows_create_map(struct mbox_context *context,
}
/* Copy from flash into the window buffer */
- rc = flash_copy(context, offset, cur->mem, cur->size);
+ rc = backend_copy(&context->backend, offset, cur->mem, cur->size);
if (rc < 0) {
/* We don't know how much we've copied -> better reset window */
window_reset(context, cur);
OpenPOWER on IntegriCloud