Created
November 9, 2012 13:56
-
-
Save anarsoul/4045757 to your computer and use it in GitHub Desktop.
uru4k portability problem fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libfprint/drivers/uru4000.c b/libfprint/drivers/uru4000.c | |
index f42b609..194c720 100644 | |
--- a/libfprint/drivers/uru4000.c | |
+++ b/libfprint/drivers/uru4000.c | |
@@ -612,7 +612,8 @@ enum { | |
struct uru4k_image { | |
uint8_t unknown_00[4]; | |
- uint16_t num_lines; | |
+ uint8_t num_lines_lsb; | |
+ uint8_t num_lines_msb; | |
uint8_t key_number; | |
uint8_t unknown_07[9]; | |
struct { | |
@@ -621,7 +622,9 @@ struct uru4k_image { | |
} block_info[15]; | |
uint8_t unknown_2E[18]; | |
uint8_t data[IMAGE_HEIGHT][IMAGE_WIDTH]; | |
-}; | |
+} __attribute__((__packed__)); | |
+ | |
+#define URU4K_IMG_NUM_LINES(img) (img->num_lines_lsb + img->num_lines_msb * 256) | |
static uint32_t update_key(uint32_t key) | |
{ | |
@@ -684,14 +687,14 @@ static void imaging_run_state(struct fpi_ssm *ssm) | |
fpi_ssm_mark_aborted(ssm, -EIO); | |
break; | |
case IMAGING_SEND_INDEX: | |
- fp_dbg("hw header lines %d", img->num_lines); | |
+ fp_dbg("hw header lines %d", URU4K_IMG_NUM_LINES(img)); | |
- if (img->num_lines >= IMAGE_HEIGHT || | |
- urudev->img_transfer->actual_length != img->num_lines * IMAGE_WIDTH + 64) { | |
+ if (URU4K_IMG_NUM_LINES(img) >= IMAGE_HEIGHT || | |
+ urudev->img_transfer->actual_length != URU4K_IMG_NUM_LINES(img) * IMAGE_WIDTH + 64) { | |
fp_err("bad captured image (%d lines) or size mismatch %d != %d", | |
- img->num_lines, | |
+ URU4K_IMG_NUM_LINES(img), | |
urudev->img_transfer->actual_length, | |
- img->num_lines * IMAGE_WIDTH + 64); | |
+ URU4K_IMG_NUM_LINES(img) * IMAGE_WIDTH + 64); | |
fpi_ssm_jump_to_state(ssm, IMAGING_CAPTURE); | |
return; | |
} | |
@@ -718,7 +721,7 @@ static void imaging_run_state(struct fpi_ssm *ssm) | |
fp_dbg("encryption id %02x -> key %08x", img->key_number, key); | |
while (urudev->img_block < array_n_elements(img->block_info) && | |
- urudev->img_lines_done < img->num_lines) { | |
+ urudev->img_lines_done < URU4K_IMG_NUM_LINES(img)) { | |
flags = img->block_info[urudev->img_block].flags; | |
num_lines = img->block_info[urudev->img_block].num_lines; | |
if (num_lines == 0) | |
@@ -755,7 +758,7 @@ static void imaging_run_state(struct fpi_ssm *ssm) | |
fpimg = fpi_img_new_for_imgdev(dev); | |
to = r = 0; | |
- for (i = 0; i < array_n_elements(img->block_info) && r < img->num_lines; i++) { | |
+ for (i = 0; i < array_n_elements(img->block_info) && r < URU4K_IMG_NUM_LINES(img); i++) { | |
flags = img->block_info[i].flags; | |
num_lines = img->block_info[i].num_lines; | |
if (num_lines == 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment