From 9c62717041a7c6f72d03608b4243445e6775952d Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Thu, 23 Aug 2018 20:59:54 +0930 Subject: transport: dbus: Implement get_flash_info Change-Id: Ibf94de2dfa3554c5e81fe53ee2b422f9a4014581 Signed-off-by: Andrew Jeffery --- transport_dbus.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/transport_dbus.c b/transport_dbus.c index 1f8287a..adbbad4 100644 --- a/transport_dbus.c +++ b/transport_dbus.c @@ -179,6 +179,41 @@ static int transport_dbus_get_info(sd_bus_message *m, void *userdata, return sd_bus_send(NULL, n, NULL); } +static int transport_dbus_get_flash_info(sd_bus_message *m, void *userdata, + sd_bus_error *ret_error) +{ + struct mbox_context *context = userdata; + struct protocol_get_flash_info io; + sd_bus_message *n; + int rc; + + if (!context) { + MSG_ERR("DBUS Internal Error\n"); + return -EINVAL; + } + + rc = context->protocol->get_flash_info(context, &io); + if (rc < 0) { + return rc; + } + + rc = sd_bus_message_new_method_return(m, &n); + if (rc < 0) { + MSG_ERR("sd_bus_message_new_method_return failed: %d\n", rc); + return rc; + } + + rc = sd_bus_message_append(n, "qq", + io.resp.v2.flash_size, + io.resp.v2.erase_size); + if (rc < 0) { + MSG_ERR("sd_bus_message_append failed!\n"); + return rc; + } + + return sd_bus_send(NULL, n, NULL); +} + static int transport_dbus_ack(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { @@ -255,6 +290,9 @@ static const sd_bus_vtable protocol_v2_vtable[] = { SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetInfo", "y", "yyq", &transport_dbus_get_info, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("GetFlashInfo", NULL, "qq", + &transport_dbus_get_flash_info, + SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Ack", "y", NULL, &transport_dbus_ack, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_PROPERTY("FlashControlLost", "b", transport_dbus_get_property, -- cgit v1.2.1