mirror of
https://github.com/linux-msm/qdl.git
synced 2026-02-25 13:12:25 -08:00
firehose: Extract call to firehose_reset()
Expose firehose_reset() and call this from the main() function instead, allowing the code to be reused between qdl and the nbdkit plugin. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
46
firehose.c
46
firehose.c
@@ -597,28 +597,6 @@ static int firehose_set_bootable(struct qdl_device *qdl, int part)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int firehose_reset(struct qdl_device *qdl)
|
||||
{
|
||||
xmlNode *root;
|
||||
xmlNode *node;
|
||||
xmlDoc *doc;
|
||||
int ret;
|
||||
|
||||
doc = xmlNewDoc((xmlChar*)"1.0");
|
||||
root = xmlNewNode(NULL, (xmlChar*)"data");
|
||||
xmlDocSetRootElement(doc, root);
|
||||
|
||||
node = xmlNewChild(root, NULL, (xmlChar*)"power", NULL);
|
||||
xml_setpropf(node, "value", "reset");
|
||||
|
||||
ret = firehose_write(qdl, doc);
|
||||
xmlFreeDoc(doc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return firehose_read(qdl, true, firehose_nop_parser, NULL);
|
||||
}
|
||||
|
||||
int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage)
|
||||
{
|
||||
int bootable;
|
||||
@@ -660,8 +638,6 @@ int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage
|
||||
else
|
||||
firehose_set_bootable(qdl, bootable);
|
||||
|
||||
firehose_reset(qdl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -680,3 +656,25 @@ int firehose_getsize(struct qdl_device *qdl, int lun, size_t *sector_size,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int firehose_reset(struct qdl_device *qdl)
|
||||
{
|
||||
xmlNode *root;
|
||||
xmlNode *node;
|
||||
xmlDoc *doc;
|
||||
int ret;
|
||||
|
||||
doc = xmlNewDoc((xmlChar*)"1.0");
|
||||
root = xmlNewNode(NULL, (xmlChar*)"data");
|
||||
xmlDocSetRootElement(doc, root);
|
||||
|
||||
node = xmlNewChild(root, NULL, (xmlChar*)"power", NULL);
|
||||
xml_setpropf(node, "value", "reset_to_edl");
|
||||
|
||||
ret = firehose_write(qdl, doc);
|
||||
xmlFreeDoc(doc);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return firehose_read(qdl, true, firehose_generic_parser, NULL);
|
||||
}
|
||||
|
||||
2
qdl.c
2
qdl.c
@@ -504,5 +504,7 @@ int main(int argc, char **argv)
|
||||
if (ret < 0)
|
||||
return 1;
|
||||
|
||||
firehose_reset(&qdl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user