+
+int pb_protocol_deserialise_boot_status(struct boot_status *status,
+ const struct pb_protocol_message *message)
+{
+ unsigned int len;
+ const char *pos;
+ int rc = -1;
+
+ len = message->payload_len;
+ pos = message->payload;
+
+ /* first up, the type enum... */
+ if (len < sizeof(uint32_t))
+ goto out;
+
+ status->type = __be32_to_cpu(*(uint32_t *)(pos));
+
+ switch (status->type) {
+ case BOOT_STATUS_ERROR:
+ case BOOT_STATUS_INFO:
+ break;
+ default:
+ goto out;
+ }
+
+ pos += sizeof(uint32_t);
+ len -= sizeof(uint32_t);
+
+ /* message and detail strings */
+ if (read_string(status, &pos, &len, &status->message))
+ goto out;
+
+ if (read_string(status, &pos, &len, &status->detail))
+ goto out;
+
+ /* and finally, progress */
+ if (len < sizeof(uint32_t))
+ goto out;
+
+ status->progress = __be32_to_cpu(*(uint32_t *)(pos));
+
+ /* clamp to 100% */
+ if (status->progress > 100)
+ status->progress = 100;
+
+ rc = 0;
+
+out:
+ return rc;
+}