summaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-06-02 13:34:07 -0700
committerElliott Hughes <enh@google.com>2015-06-04 13:26:48 -0700
commitc688c23286f40309e5af1f7f91d6d6f1de3f7749 (patch)
tree3381313991b95f14bceafad09800f3ab46b59e15 /fastboot
parente283ca29c53817091a17f44b7c93ba6d6362fd38 (diff)
downloadsystem_core-c688c23286f40309e5af1f7f91d6d6f1de3f7749.zip
system_core-c688c23286f40309e5af1f7f91d6d6f1de3f7749.tar.gz
system_core-c688c23286f40309e5af1f7f91d6d6f1de3f7749.tar.bz2
'usb' doesn't need to be global in fastboot.
Bug: http://b/21558406 Change-Id: Id014399640865d889918661bae0161b3165eee48 (cherry picked from commit c0ce65f9613eefc7bb2b14daae395bde52339ab7)
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/fastboot.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index c9a6772..e587590 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -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;
@@ -609,7 +608,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.
@@ -737,7 +736,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);
@@ -792,7 +791,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);
@@ -860,7 +859,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];
@@ -1067,7 +1067,7 @@ int main(int argc, char **argv)
return 0;
}
- usb = open_device();
+ usb_handle* usb = open_device();
while (argc > 0) {
if(!strcmp(*argv, "getvar")) {
@@ -1109,10 +1109,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);
@@ -1167,7 +1167,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);
@@ -1218,9 +1218,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();