Merge "'usb' doesn't need to be global in fastboot."

This commit is contained in:
Elliott Hughes 2015-06-03 01:14:31 +00:00 committed by Gerrit Code Review
commit 98a4dd48bd
1 changed files with 11 additions and 11 deletions

View File

@ -59,7 +59,6 @@
char cur_product[FB_RESPONSE_SZ + 1];
static usb_handle *usb = 0;
static const char *serial = 0;
static const char *product = 0;
static const char *cmdline = 0;
@ -619,7 +618,7 @@ static int64_t get_sparse_limit(struct usb_handle *usb, int64_t size)
* erase partitions of type ext4 before flashing a filesystem so no stale
* inodes are left lying around. Otherwise, e2fsck gets very upset.
*/
static int needs_erase(const char *part)
static int needs_erase(usb_handle* usb, const char *part)
{
/* The function fb_format_supported() currently returns the value
* we want, so just call it.
@ -744,7 +743,7 @@ void do_update(usb_handle *usb, const char *filename, int erase_first)
int rc = load_buf_fd(usb, fd, &buf);
if (rc) die("cannot load %s from flash", images[i].img_name);
do_update_signature(zip, images[i].sig_name);
if (erase_first && needs_erase(images[i].part_name)) {
if (erase_first && needs_erase(usb, images[i].part_name)) {
fb_queue_erase(images[i].part_name);
}
flash_buf(images[i].part_name, &buf);
@ -799,7 +798,7 @@ void do_flashall(usb_handle *usb, int erase_first)
die("could not load %s\n", images[i].img_name);
}
do_send_signature(fname);
if (erase_first && needs_erase(images[i].part_name)) {
if (erase_first && needs_erase(usb, images[i].part_name)) {
fb_queue_erase(images[i].part_name);
}
flash_buf(images[i].part_name, &buf);
@ -867,7 +866,8 @@ static int64_t parse_num(const char *arg)
return num;
}
void fb_perform_format(const char *partition, int skip_if_not_supported,
void fb_perform_format(usb_handle* usb,
const char *partition, int skip_if_not_supported,
const char *type_override, const char *size_override)
{
char pTypeBuff[FB_RESPONSE_SZ + 1], pSizeBuff[FB_RESPONSE_SZ + 1];
@ -1070,7 +1070,7 @@ int main(int argc, char **argv)
return 0;
}
usb = open_device();
usb_handle* usb = open_device();
while (argc > 0) {
if(!strcmp(*argv, "getvar")) {
@ -1112,10 +1112,10 @@ int main(int argc, char **argv)
}
if (type_override && !type_override[0]) type_override = NULL;
if (size_override && !size_override[0]) size_override = NULL;
if (erase_first && needs_erase(argv[1])) {
if (erase_first && needs_erase(usb, argv[1])) {
fb_queue_erase(argv[1]);
}
fb_perform_format(argv[1], 0, type_override, size_override);
fb_perform_format(usb, argv[1], 0, type_override, size_override);
skip(2);
} else if(!strcmp(*argv, "signature")) {
require(2);
@ -1175,7 +1175,7 @@ int main(int argc, char **argv)
skip(2);
}
if (fname == 0) die("cannot determine image filename for '%s'", pname);
if (erase_first && needs_erase(pname)) {
if (erase_first && needs_erase(usb, pname)) {
fb_queue_erase(pname);
}
do_flash(usb, pname, fname);
@ -1230,9 +1230,9 @@ int main(int argc, char **argv)
if (wants_wipe) {
fb_queue_erase("userdata");
fb_perform_format("userdata", 1, NULL, NULL);
fb_perform_format(usb, "userdata", 1, NULL, NULL);
fb_queue_erase("cache");
fb_perform_format("cache", 1, NULL, NULL);
fb_perform_format(usb, "cache", 1, NULL, NULL);
}
if (wants_reboot) {
fb_queue_reboot();