Skip to content

Commit

Permalink
sunxi-tools: make use of proper boolean data types
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
Acked-by: Peter Korsgaard <peter@korsgaard.com>
  • Loading branch information
n1tehawk committed Nov 19, 2015
1 parent d99d59c commit a9cb1c4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fel.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <libusb.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -61,7 +62,7 @@ static const int AW_USB_WRITE = 0x12;
static int AW_USB_FEL_BULK_EP_OUT;
static int AW_USB_FEL_BULK_EP_IN;
static int timeout = 60000;
static int verbose = 0; /* Makes the 'fel' tool more talkative if non-zero */
static bool verbose = false; /* If set, makes the 'fel' tool more talkative */
static uint32_t uboot_entry = 0; /* entry point (address) of U-Boot */
static uint32_t uboot_size = 0; /* size of U-Boot binary */

Expand Down Expand Up @@ -957,31 +958,31 @@ void aw_fel_process_spl_and_uboot(libusb_device_handle *usb,
#define SPL_SIGNATURE "SPL" /* marks "sunxi" header */
#define SPL_MIN_VERSION 1 /* minimum required version */
#define SPL_MAX_VERSION 1 /* maximum supported version */
int have_sunxi_spl(libusb_device_handle *usb, uint32_t spl_addr)
bool have_sunxi_spl(libusb_device_handle *usb, uint32_t spl_addr)
{
uint8_t spl_signature[4];

aw_fel_read(usb, spl_addr + 0x14,
&spl_signature, sizeof(spl_signature));

if (memcmp(spl_signature, SPL_SIGNATURE, 3) != 0)
return 0; /* signature mismatch, no "sunxi" SPL */
return false; /* signature mismatch, no "sunxi" SPL */

if (spl_signature[3] < SPL_MIN_VERSION) {
fprintf(stderr, "sunxi SPL version mismatch: "
"found 0x%02X < required minimum 0x%02X\n",
spl_signature[3], SPL_MIN_VERSION);
fprintf(stderr, "You need to update your U-Boot (mksunxiboot) to a more recent version.\n");
return 0;
return false;
}
if (spl_signature[3] > SPL_MAX_VERSION) {
fprintf(stderr, "sunxi SPL version mismatch: "
"found 0x%02X > maximum supported 0x%02X\n",
spl_signature[3], SPL_MAX_VERSION);
fprintf(stderr, "You need a more recent version of this (sunxi-tools) fel utility.\n");
return 0;
return false;
}
return 1; /* sunxi SPL and suitable version */
return true; /* sunxi SPL and suitable version */
}

/*
Expand Down Expand Up @@ -1113,7 +1114,7 @@ int main(int argc, char **argv)

if (argc > 1 && (strcmp(argv[1], "--verbose") == 0 ||
strcmp(argv[1], "-v") == 0)) {
verbose = 1;
verbose = true;
argc -= 1;
argv += 1;
}
Expand Down

0 comments on commit a9cb1c4

Please sign in to comment.