drivers: Simplify libusb_alloc_transfer(0) calls
By using our new, never-failing, USB allocation wrapper. As it can never fail, we can also remove all the error paths for the allocations failing.
This commit is contained in:
parent
bdba9990fb
commit
10ae8ffb55
18 changed files with 74 additions and 325 deletions
|
@ -128,15 +128,10 @@ static void generic_write_regv_cb(struct fp_img_dev *dev, int result,
|
||||||
* away, then increment the SSM */
|
* away, then increment the SSM */
|
||||||
static void generic_read_ignore_data(fpi_ssm *ssm, struct fp_dev *dev, size_t bytes)
|
static void generic_read_ignore_data(fpi_ssm *ssm, struct fp_dev *dev, size_t bytes)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(bytes);
|
data = g_malloc(bytes);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(dev), EP_IN, data, bytes,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(dev), EP_IN, data, bytes,
|
||||||
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
|
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -224,12 +219,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result, void *user_da
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(19);
|
data = g_malloc(19);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 19,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 19,
|
||||||
finger_det_data_cb, dev, BULK_TIMEOUT);
|
finger_det_data_cb, dev, BULK_TIMEOUT);
|
||||||
|
@ -666,14 +656,9 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
generic_write_regv_cb, ssm);
|
generic_write_regv_cb, ssm);
|
||||||
break;
|
break;
|
||||||
case CAPTURE_READ_STRIP: ;
|
case CAPTURE_READ_STRIP: ;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(665);
|
data = g_malloc(665);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 665,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 665,
|
||||||
capture_read_strip_cb, ssm, BULK_TIMEOUT);
|
capture_read_strip_cb, ssm, BULK_TIMEOUT);
|
||||||
|
|
|
@ -115,12 +115,7 @@ static void read_regs_rq_cb(struct fp_img_dev *dev, int result, void *user_data)
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
result = -ENOMEM;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(126);
|
data = g_malloc(126);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 126,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 126,
|
||||||
read_regs_data_cb, rdata, BULK_TIMEOUT);
|
read_regs_data_cb, rdata, BULK_TIMEOUT);
|
||||||
|
@ -207,15 +202,10 @@ static void generic_ignore_data_cb(struct libusb_transfer *transfer)
|
||||||
* away, then increment the SSM */
|
* away, then increment the SSM */
|
||||||
static void generic_read_ignore_data(fpi_ssm *ssm, struct fp_dev *dev, size_t bytes)
|
static void generic_read_ignore_data(fpi_ssm *ssm, struct fp_dev *dev, size_t bytes)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(bytes);
|
data = g_malloc(bytes);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(dev), EP_IN, data, bytes,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(dev), EP_IN, data, bytes,
|
||||||
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
|
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -325,12 +315,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(20);
|
data = g_malloc(20);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 20,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 20,
|
||||||
finger_det_data_cb, dev, BULK_TIMEOUT);
|
finger_det_data_cb, dev, BULK_TIMEOUT);
|
||||||
|
@ -548,14 +533,9 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
generic_write_regv_cb, ssm);
|
generic_write_regv_cb, ssm);
|
||||||
break;
|
break;
|
||||||
case CAPTURE_READ_STRIP: ;
|
case CAPTURE_READ_STRIP: ;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(1705);
|
data = g_malloc(1705);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 1705,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, 1705,
|
||||||
capture_read_strip_cb, ssm, BULK_TIMEOUT);
|
capture_read_strip_cb, ssm, BULK_TIMEOUT);
|
||||||
|
|
|
@ -125,12 +125,7 @@ static void finger_det_reqs_cb(struct libusb_transfer *t)
|
||||||
goto exit_free_transfer;
|
goto exit_free_transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
goto exit_free_transfer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 2 bytes of result */
|
/* 2 bytes of result */
|
||||||
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
||||||
|
@ -158,11 +153,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, finger_det_reqs,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, finger_det_reqs,
|
||||||
sizeof(finger_det_reqs), finger_det_reqs_cb, dev, BULK_TIMEOUT);
|
sizeof(finger_det_reqs), finger_det_reqs_cb, dev, BULK_TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -330,11 +321,8 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||||
case CAPTURE_WRITE_REQS:
|
case CAPTURE_WRITE_REQS:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, capture_reqs,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, capture_reqs,
|
||||||
sizeof(capture_reqs), capture_reqs_cb, ssm, BULK_TIMEOUT);
|
sizeof(capture_reqs), capture_reqs_cb, ssm, BULK_TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -346,14 +334,9 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
break;
|
break;
|
||||||
case CAPTURE_READ_DATA:
|
case CAPTURE_READ_DATA:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
||||||
capture_read_data_cb, ssm, BULK_TIMEOUT);
|
capture_read_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -368,11 +351,8 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
break;
|
break;
|
||||||
case CAPTURE_SET_IDLE:
|
case CAPTURE_SET_IDLE:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, capture_set_idle_reqs,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, capture_set_idle_reqs,
|
||||||
sizeof(capture_set_idle_reqs), capture_set_idle_reqs_cb, ssm, BULK_TIMEOUT);
|
sizeof(capture_set_idle_reqs), capture_set_idle_reqs_cb, ssm, BULK_TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -489,11 +469,8 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||||
case WRITE_INIT:
|
case WRITE_INIT:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, init_reqs,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, init_reqs,
|
||||||
sizeof(init_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
|
sizeof(init_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -505,14 +482,9 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
break;
|
break;
|
||||||
case READ_DATA:
|
case READ_DATA:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
||||||
init_read_data_cb, ssm, BULK_TIMEOUT);
|
init_read_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -527,11 +499,8 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
break;
|
break;
|
||||||
case CALIBRATE:
|
case CALIBRATE:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, calibrate_reqs,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT, calibrate_reqs,
|
||||||
sizeof(calibrate_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
|
sizeof(calibrate_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -543,14 +512,9 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
break;
|
break;
|
||||||
case READ_CALIB_TABLE:
|
case READ_CALIB_TABLE:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
|
||||||
calibrate_read_data_cb, ssm, BULK_TIMEOUT);
|
calibrate_read_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
|
|
@ -116,12 +116,7 @@ static void do_capture(struct fp_img_dev *dev)
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
aesdev->img_trf = libusb_alloc_transfer(0);
|
aesdev->img_trf = fpi_usb_alloc();
|
||||||
if (!aesdev->img_trf) {
|
|
||||||
fpi_imgdev_session_error(dev, -EIO);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(aesdev->data_buflen);
|
data = g_malloc(aesdev->data_buflen);
|
||||||
libusb_fill_bulk_transfer(aesdev->img_trf, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data,
|
libusb_fill_bulk_transfer(aesdev->img_trf, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data,
|
||||||
aesdev->data_buflen, img_cb, dev, 0);
|
aesdev->data_buflen, img_cb, dev, 0);
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <libusb.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "fpi-usb.h"
|
||||||
#include "assembling.h"
|
#include "assembling.h"
|
||||||
#include "aeslib.h"
|
#include "aeslib.h"
|
||||||
|
|
||||||
|
@ -73,14 +73,9 @@ static int do_write_regv(struct write_regv_data *wdata, int upper_bound)
|
||||||
unsigned char *data = g_malloc(alloc_size);
|
unsigned char *data = g_malloc(alloc_size);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
size_t data_offset = 0;
|
size_t data_offset = 0;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
g_free(data);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = offset; i < offset + num; i++) {
|
for (i = offset; i < offset + num; i++) {
|
||||||
const struct aes_regwrite *regwrite = &wdata->regs[i];
|
const struct aes_regwrite *regwrite = &wdata->regs[i];
|
||||||
data[data_offset++] = regwrite->reg;
|
data[data_offset++] = regwrite->reg;
|
||||||
|
|
|
@ -46,14 +46,9 @@ aesX660_send_cmd_timeout(fpi_ssm *ssm,
|
||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
|
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_OUT,
|
||||||
(unsigned char *)cmd, cmd_len,
|
(unsigned char *)cmd, cmd_len,
|
||||||
callback, ssm, timeout);
|
callback, ssm, timeout);
|
||||||
|
@ -82,15 +77,10 @@ aesX660_read_response(fpi_ssm *ssm,
|
||||||
libusb_transfer_cb_fn callback)
|
libusb_transfer_cb_fn callback)
|
||||||
{
|
{
|
||||||
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
|
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(buf_len);
|
data = g_malloc(buf_len);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN,
|
||||||
data, buf_len,
|
data, buf_len,
|
||||||
|
|
|
@ -380,22 +380,16 @@ static void elan_cmd_read(fpi_ssm *ssm, struct fp_img_dev *dev)
|
||||||
response_len =
|
response_len =
|
||||||
elandev->raw_frame_height * elandev->frame_width * 2;
|
elandev->raw_frame_height * elandev->frame_width * 2;
|
||||||
|
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
elandev->cur_transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
elandev->cur_transfer = transfer;
|
|
||||||
|
|
||||||
g_free(elandev->last_read);
|
g_free(elandev->last_read);
|
||||||
elandev->last_read = g_malloc(response_len);
|
elandev->last_read = g_malloc(response_len);
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)),
|
libusb_fill_bulk_transfer(elandev->cur_transfer, fpi_dev_get_usb_dev(FP_DEV(dev)),
|
||||||
elandev->cmd->response_in,
|
elandev->cmd->response_in,
|
||||||
elandev->last_read, response_len, elan_cmd_cb,
|
elandev->last_read, response_len, elan_cmd_cb,
|
||||||
ssm, elandev->cmd_timeout);
|
ssm, elandev->cmd_timeout);
|
||||||
transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
elandev->cur_transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
int r = libusb_submit_transfer(transfer);
|
int r = libusb_submit_transfer(elandev->cur_transfer);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
fpi_ssm_mark_failed(ssm, r);
|
fpi_ssm_mark_failed(ssm, r);
|
||||||
}
|
}
|
||||||
|
@ -420,18 +414,12 @@ elan_run_cmd(fpi_ssm *ssm,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
elandev->cur_transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
libusb_fill_bulk_transfer(elandev->cur_transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), ELAN_EP_CMD_OUT,
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
elandev->cur_transfer = transfer;
|
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), ELAN_EP_CMD_OUT,
|
|
||||||
(char *) cmd->cmd, ELAN_CMD_LEN, elan_cmd_cb, ssm,
|
(char *) cmd->cmd, ELAN_CMD_LEN, elan_cmd_cb, ssm,
|
||||||
elandev->cmd_timeout);
|
elandev->cmd_timeout);
|
||||||
transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
elandev->cur_transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
int r = libusb_submit_transfer(transfer);
|
int r = libusb_submit_transfer(elandev->cur_transfer);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
fpi_ssm_mark_failed(ssm, r);
|
fpi_ssm_mark_failed(ssm, r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -640,13 +640,10 @@ static int async_tx(struct fp_img_dev *idev, unsigned int ep, void *cb,
|
||||||
void *cb_arg)
|
void *cb_arg)
|
||||||
{
|
{
|
||||||
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
|
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (ep == EP_OUT) {
|
if (ep == EP_OUT) {
|
||||||
buffer = (unsigned char *)dev->req;
|
buffer = (unsigned char *)dev->req;
|
||||||
length = dev->req_len;
|
length = dev->req_len;
|
||||||
|
|
|
@ -583,13 +583,7 @@ sm_write_regs(fpi_ssm *ssm,
|
||||||
struct write_regs_data *wrdata = g_malloc(sizeof(*wrdata));
|
struct write_regs_data *wrdata = g_malloc(sizeof(*wrdata));
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
wrdata->transfer = libusb_alloc_transfer(0);
|
wrdata->transfer = fpi_usb_alloc();
|
||||||
if (!wrdata->transfer) {
|
|
||||||
g_free(wrdata);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
||||||
libusb_fill_control_setup(data, 0x40, 0x0c, 0, 0, 1);
|
libusb_fill_control_setup(data, 0x40, 0x0c, 0, 0, 1);
|
||||||
libusb_fill_control_transfer(wrdata->transfer,
|
libusb_fill_control_transfer(wrdata->transfer,
|
||||||
|
@ -621,15 +615,10 @@ sm_write_reg(fpi_ssm *ssm,
|
||||||
uint8_t reg,
|
uint8_t reg,
|
||||||
uint8_t value)
|
uint8_t value)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp_dbg("set %02x=%02x", reg, value);
|
fp_dbg("set %02x=%02x", reg, value);
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
||||||
libusb_fill_control_setup(data, 0x40, 0x0c, 0, reg, 1);
|
libusb_fill_control_setup(data, 0x40, 0x0c, 0, reg, 1);
|
||||||
|
@ -671,15 +660,10 @@ sm_read_reg(fpi_ssm *ssm,
|
||||||
struct fp_img_dev *dev,
|
struct fp_img_dev *dev,
|
||||||
uint8_t reg)
|
uint8_t reg)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp_dbg("read reg %02x", reg);
|
fp_dbg("read reg %02x", reg);
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 8);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 8);
|
||||||
libusb_fill_control_setup(data, 0xc0, 0x0c, 0, reg, 8);
|
libusb_fill_control_setup(data, 0xc0, 0x0c, 0, reg, 8);
|
||||||
|
@ -723,15 +707,10 @@ static void
|
||||||
sm_await_intr(fpi_ssm *ssm,
|
sm_await_intr(fpi_ssm *ssm,
|
||||||
struct fp_img_dev *dev)
|
struct fp_img_dev *dev)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DEBUG_HERE();
|
G_DEBUG_HERE();
|
||||||
data = g_malloc(4);
|
data = g_malloc(4);
|
||||||
libusb_fill_interrupt_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)),
|
libusb_fill_interrupt_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)),
|
||||||
|
@ -1302,11 +1281,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||||
sdev->num_flying = 0;
|
sdev->num_flying = 0;
|
||||||
for (i = 0; i < NUM_BULK_TRANSFERS; i++) {
|
for (i = 0; i < NUM_BULK_TRANSFERS; i++) {
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
sdev->img_transfer[i] = libusb_alloc_transfer(0);
|
sdev->img_transfer[i] = fpi_usb_alloc();
|
||||||
if (!sdev->img_transfer[i]) {
|
|
||||||
free_img_transfers(sdev);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
sdev->img_transfer_data[i].idx = i;
|
sdev->img_transfer_data[i].idx = i;
|
||||||
sdev->img_transfer_data[i].dev = dev;
|
sdev->img_transfer_data[i].dev = dev;
|
||||||
data = g_malloc(4096);
|
data = g_malloc(4096);
|
||||||
|
|
|
@ -109,11 +109,8 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||||
case WRITE_INIT:
|
case WRITE_INIT:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
||||||
(unsigned char*)upekdev->setup_commands[upekdev->init_idx].cmd,
|
(unsigned char*)upekdev->setup_commands[upekdev->init_idx].cmd,
|
||||||
UPEKTC_CMD_LEN, write_init_cb, ssm, BULK_TIMEOUT);
|
UPEKTC_CMD_LEN, write_init_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -126,14 +123,9 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
|
||||||
break;
|
break;
|
||||||
case READ_DATA:
|
case READ_DATA:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(upekdev->setup_commands[upekdev->init_idx].response_len);
|
data = g_malloc(upekdev->setup_commands[upekdev->init_idx].response_len);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data,
|
||||||
upekdev->setup_commands[upekdev->init_idx].response_len,
|
upekdev->setup_commands[upekdev->init_idx].response_len,
|
||||||
|
@ -228,12 +220,7 @@ static void finger_det_cmd_cb(struct libusb_transfer *t)
|
||||||
goto exit_free_transfer;
|
goto exit_free_transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
goto exit_free_transfer;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(IMAGE_SIZE);
|
data = g_malloc(IMAGE_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data, IMAGE_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data, IMAGE_SIZE,
|
||||||
finger_det_data_cb, dev, BULK_TIMEOUT);
|
finger_det_data_cb, dev, BULK_TIMEOUT);
|
||||||
|
@ -260,11 +247,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
||||||
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
|
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
|
||||||
finger_det_cmd_cb, dev, BULK_TIMEOUT);
|
finger_det_cmd_cb, dev, BULK_TIMEOUT);
|
||||||
|
@ -332,11 +315,8 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||||
case CAPTURE_WRITE_CMD:
|
case CAPTURE_WRITE_CMD:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_out,
|
||||||
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
|
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
|
||||||
capture_cmd_cb, ssm, BULK_TIMEOUT);
|
capture_cmd_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -349,14 +329,9 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
|
||||||
break;
|
break;
|
||||||
case CAPTURE_READ_DATA:
|
case CAPTURE_READ_DATA:
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(IMAGE_SIZE);
|
data = g_malloc(IMAGE_SIZE);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data, IMAGE_SIZE,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), upekdev->ep_in, data, IMAGE_SIZE,
|
||||||
capture_read_data_cb, ssm, BULK_TIMEOUT);
|
capture_read_data_cb, ssm, BULK_TIMEOUT);
|
||||||
|
|
|
@ -80,16 +80,11 @@ upektc_img_submit_req(fpi_ssm *ssm,
|
||||||
libusb_transfer_cb_fn cb)
|
libusb_transfer_cb_fn cb)
|
||||||
{
|
{
|
||||||
struct upektc_img_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
struct upektc_img_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
BUG_ON(buf_size > MAX_CMD_SIZE);
|
BUG_ON(buf_size > MAX_CMD_SIZE);
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
|
|
||||||
memcpy(upekdev->cmd, buf, buf_size);
|
memcpy(upekdev->cmd, buf, buf_size);
|
||||||
|
@ -113,15 +108,10 @@ upektc_img_read_data(fpi_ssm *ssm,
|
||||||
size_t buf_offset,
|
size_t buf_offset,
|
||||||
libusb_transfer_cb_fn cb)
|
libusb_transfer_cb_fn cb)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
struct upektc_img_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
struct upektc_img_dev *upekdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BUG_ON(buf_size > MAX_RESPONSE_SIZE);
|
BUG_ON(buf_size > MAX_RESPONSE_SIZE);
|
||||||
|
|
||||||
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
|
@ -518,11 +508,7 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *dev, void *user_data
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER |
|
transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER |
|
||||||
LIBUSB_TRANSFER_FREE_TRANSFER;
|
LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev,
|
||||||
unsigned char seq_a, unsigned char seq_b, const unsigned char *data,
|
unsigned char seq_a, unsigned char seq_b, const unsigned char *data,
|
||||||
uint16_t len, libusb_transfer_cb_fn callback, void *user_data)
|
uint16_t len, libusb_transfer_cb_fn callback, void *user_data)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
const char *ciao = "Ciao";
|
const char *ciao = "Ciao";
|
||||||
|
|
||||||
|
@ -99,9 +99,6 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev,
|
||||||
size_t urblen = len + 9;
|
size_t urblen = len + 9;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!data && len > 0) {
|
if (!data && len > 0) {
|
||||||
fp_err("len>0 but no data?");
|
fp_err("len>0 but no data?");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -367,12 +364,9 @@ static void read_msg_cb(struct libusb_transfer *transfer)
|
||||||
* to read the remainder. This is handled below. */
|
* to read the remainder. This is handled below. */
|
||||||
if (len > MAX_DATA_IN_READ_BUF) {
|
if (len > MAX_DATA_IN_READ_BUF) {
|
||||||
int needed = len - MAX_DATA_IN_READ_BUF;
|
int needed = len - MAX_DATA_IN_READ_BUF;
|
||||||
struct libusb_transfer *etransfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *etransfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
fp_dbg("didn't fit in buffer, need to extend by %d bytes", needed);
|
fp_dbg("didn't fit in buffer, need to extend by %d bytes", needed);
|
||||||
data = g_realloc((gpointer) data, MSG_READ_BUF_SIZE + needed);
|
data = g_realloc((gpointer) data, MSG_READ_BUF_SIZE + needed);
|
||||||
|
|
||||||
|
@ -407,14 +401,9 @@ out:
|
||||||
static int __read_msg_async(struct read_msg_data *udata)
|
static int __read_msg_async(struct read_msg_data *udata)
|
||||||
{
|
{
|
||||||
unsigned char *buf = g_malloc(MSG_READ_BUF_SIZE);
|
unsigned char *buf = g_malloc(MSG_READ_BUF_SIZE);
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
g_free(buf);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(udata->dev), EP_IN, buf,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(udata->dev), EP_IN, buf,
|
||||||
MSG_READ_BUF_SIZE, read_msg_cb, udata, TIMEOUT);
|
MSG_READ_BUF_SIZE, read_msg_cb, udata, TIMEOUT);
|
||||||
r = libusb_submit_transfer(transfer);
|
r = libusb_submit_transfer(transfer);
|
||||||
|
@ -670,12 +659,7 @@ static void initsm_run_state(fpi_ssm *ssm, struct fp_dev *dev, void *user_data)
|
||||||
case WRITE_CTRL400: ;
|
case WRITE_CTRL400: ;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
|
||||||
libusb_fill_control_setup(data,
|
libusb_fill_control_setup(data,
|
||||||
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1);
|
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1);
|
||||||
|
|
|
@ -186,13 +186,10 @@ static int write_regs(struct fp_img_dev *dev, uint16_t first_reg,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct write_regs_data *wrdata;
|
struct write_regs_data *wrdata;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
wrdata = g_malloc(sizeof(*wrdata));
|
wrdata = g_malloc(sizeof(*wrdata));
|
||||||
wrdata->dev = dev;
|
wrdata->dev = dev;
|
||||||
wrdata->callback = callback;
|
wrdata->callback = callback;
|
||||||
|
@ -253,13 +250,10 @@ static int read_regs(struct fp_img_dev *dev, uint16_t first_reg,
|
||||||
uint16_t num_regs, read_regs_cb_fn callback, void *user_data)
|
uint16_t num_regs, read_regs_cb_fn callback, void *user_data)
|
||||||
{
|
{
|
||||||
struct read_regs_data *rrdata;
|
struct read_regs_data *rrdata;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rrdata = g_malloc(sizeof(*rrdata));
|
rrdata = g_malloc(sizeof(*rrdata));
|
||||||
rrdata->dev = dev;
|
rrdata->dev = dev;
|
||||||
rrdata->callback = callback;
|
rrdata->callback = callback;
|
||||||
|
@ -428,13 +422,10 @@ out:
|
||||||
static int start_irq_handler(struct fp_img_dev *dev)
|
static int start_irq_handler(struct fp_img_dev *dev)
|
||||||
{
|
{
|
||||||
struct uru4k_dev *urudev = FP_INSTANCE_DATA(FP_DEV(dev));
|
struct uru4k_dev *urudev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
data = g_malloc(IRQ_LENGTH);
|
data = g_malloc(IRQ_LENGTH);
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_INTR, data, IRQ_LENGTH,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_INTR, data, IRQ_LENGTH,
|
||||||
irq_handler, dev, 0);
|
irq_handler, dev, 0);
|
||||||
|
@ -1236,7 +1227,7 @@ static int execute_state_change(struct fp_img_dev *dev)
|
||||||
fp_dbg("starting capture");
|
fp_dbg("starting capture");
|
||||||
urudev->irq_cb = NULL;
|
urudev->irq_cb = NULL;
|
||||||
|
|
||||||
urudev->img_transfer = libusb_alloc_transfer(0);
|
urudev->img_transfer = fpi_usb_alloc();
|
||||||
urudev->img_data = g_malloc(sizeof(struct uru4k_image));
|
urudev->img_data = g_malloc(sizeof(struct uru4k_image));
|
||||||
urudev->img_enc_seed = rand();
|
urudev->img_enc_seed = rand();
|
||||||
|
|
||||||
|
|
|
@ -91,15 +91,10 @@ sm_write_reg(fpi_ssm *ssm,
|
||||||
unsigned char reg,
|
unsigned char reg,
|
||||||
unsigned char value)
|
unsigned char value)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp_dbg("set %02x=%02x", reg, value);
|
fp_dbg("set %02x=%02x", reg, value);
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
|
||||||
libusb_fill_control_setup(data, CTRL_OUT, reg, value, 0, 0);
|
libusb_fill_control_setup(data, CTRL_OUT, reg, value, 0, 0);
|
||||||
|
@ -132,14 +127,9 @@ sm_exec_cmd(fpi_ssm *ssm,
|
||||||
unsigned char cmd,
|
unsigned char cmd,
|
||||||
unsigned char param)
|
unsigned char param)
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fp_dbg("cmd %02x param %02x", cmd, param);
|
fp_dbg("cmd %02x param %02x", cmd, param);
|
||||||
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
|
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
|
||||||
|
@ -228,14 +218,9 @@ capture_iterate(fpi_ssm *ssm,
|
||||||
{
|
{
|
||||||
struct v5s_dev *vdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
struct v5s_dev *vdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||||
int iteration = vdev->capture_iteration;
|
int iteration = vdev->capture_iteration;
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = fpi_usb_alloc();
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!transfer) {
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN,
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN,
|
||||||
vdev->capture_img->data + (RQ_SIZE * iteration), RQ_SIZE,
|
vdev->capture_img->data + (RQ_SIZE * iteration), RQ_SIZE,
|
||||||
capture_cb, ssm, CTRL_TIMEOUT);
|
capture_cb, ssm, CTRL_TIMEOUT);
|
||||||
|
|
|
@ -60,7 +60,7 @@ async_write(fpi_ssm *ssm,
|
||||||
struct libusb_device_handle *usb_dev = fpi_dev_get_usb_dev(FP_DEV(dev));
|
struct libusb_device_handle *usb_dev = fpi_dev_get_usb_dev(FP_DEV(dev));
|
||||||
struct vfs_dev_t *vdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
struct vfs_dev_t *vdev = FP_INSTANCE_DATA(FP_DEV(dev));
|
||||||
|
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
libusb_fill_bulk_transfer(vdev->transfer, usb_dev, 0x01, data, len,
|
libusb_fill_bulk_transfer(vdev->transfer, usb_dev, 0x01, data, len,
|
||||||
async_write_callback, ssm, VFS_USB_TIMEOUT);
|
async_write_callback, ssm, VFS_USB_TIMEOUT);
|
||||||
|
@ -109,7 +109,7 @@ async_read(fpi_ssm *ssm,
|
||||||
|
|
||||||
ep |= LIBUSB_ENDPOINT_IN;
|
ep |= LIBUSB_ENDPOINT_IN;
|
||||||
|
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
|
|
||||||
/* 0x83 is the only interrupt endpoint */
|
/* 0x83 is the only interrupt endpoint */
|
||||||
|
@ -166,7 +166,7 @@ static void async_abort(fpi_ssm *ssm, int ep)
|
||||||
|
|
||||||
ep |= LIBUSB_ENDPOINT_IN;
|
ep |= LIBUSB_ENDPOINT_IN;
|
||||||
|
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
vdev->transfer->flags |=
|
vdev->transfer->flags |=
|
||||||
LIBUSB_TRANSFER_FREE_TRANSFER | LIBUSB_TRANSFER_FREE_BUFFER;
|
LIBUSB_TRANSFER_FREE_TRANSFER | LIBUSB_TRANSFER_FREE_BUFFER;
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ static void activate_ssm(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Asyncronously enquire an interrupt */
|
/* Asyncronously enquire an interrupt */
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
libusb_fill_interrupt_transfer(vdev->transfer, usb_dev, 0x83,
|
libusb_fill_interrupt_transfer(vdev->transfer, usb_dev, 0x83,
|
||||||
vdev->interrupt,
|
vdev->interrupt,
|
||||||
|
@ -628,7 +628,7 @@ static void activate_ssm(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Receive chunk of data */
|
/* Receive chunk of data */
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||||
libusb_fill_bulk_transfer(vdev->transfer, usb_dev, 0x82,
|
libusb_fill_bulk_transfer(vdev->transfer, usb_dev, 0x82,
|
||||||
(void *)vdev->lines_buffer +
|
(void *)vdev->lines_buffer +
|
||||||
|
|
|
@ -247,15 +247,7 @@ async_send(fpi_ssm *ssm,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* Allocation of transfer */
|
/* Allocation of transfer */
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
if (!vdev->transfer)
|
|
||||||
{
|
|
||||||
/* Allocation transfer failed, return no memory error */
|
|
||||||
fp_err("allocation of usb transfer failed");
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put sequential number into the buffer */
|
/* Put sequential number into the buffer */
|
||||||
vdev->seqnum++;
|
vdev->seqnum++;
|
||||||
|
@ -335,15 +327,7 @@ async_recv(fpi_ssm *ssm,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* Allocation of transfer */
|
/* Allocation of transfer */
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
if (!vdev->transfer)
|
|
||||||
{
|
|
||||||
/* Allocation transfer failed, return no memory error */
|
|
||||||
fp_err("allocation of usb transfer failed");
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Prepare bulk transfer */
|
/* Prepare bulk transfer */
|
||||||
libusb_fill_bulk_transfer(vdev->transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN(1), vdev->buffer, 0x0f, async_recv_cb, ssm, BULK_TIMEOUT);
|
libusb_fill_bulk_transfer(vdev->transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN(1), vdev->buffer, 0x0f, async_recv_cb, ssm, BULK_TIMEOUT);
|
||||||
|
@ -438,15 +422,7 @@ async_load(fpi_ssm *ssm,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* Allocation of transfer */
|
/* Allocation of transfer */
|
||||||
vdev->transfer = libusb_alloc_transfer(0);
|
vdev->transfer = fpi_usb_alloc();
|
||||||
if (!vdev->transfer)
|
|
||||||
{
|
|
||||||
/* Allocation transfer failed, return no memory error */
|
|
||||||
fp_err("allocation of usb transfer failed");
|
|
||||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Append new data into the buffer */
|
/* Append new data into the buffer */
|
||||||
buffer = vdev->buffer + vdev->length;
|
buffer = vdev->buffer + vdev->length;
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <libusb-1.0/libusb.h>
|
|
||||||
|
|
||||||
|
#include "fpi-usb.h"
|
||||||
#include "vfs301_proto.h"
|
#include "vfs301_proto.h"
|
||||||
#include "vfs301_proto_fragments.h"
|
#include "vfs301_proto_fragments.h"
|
||||||
|
|
||||||
|
@ -499,12 +499,7 @@ void vfs301_proto_process_event_start(
|
||||||
USB_RECV(VFS301_RECEIVE_ENDPOINT_DATA, 64);
|
USB_RECV(VFS301_RECEIVE_ENDPOINT_DATA, 64);
|
||||||
|
|
||||||
/* now read the fingerprint data, while there are some */
|
/* now read the fingerprint data, while there are some */
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (!transfer) {
|
|
||||||
dev->recv_progress = VFS301_FAILURE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->recv_progress = VFS301_ONGOING;
|
dev->recv_progress = VFS301_ONGOING;
|
||||||
dev->recv_exp_amt = VFS301_FP_RECV_LEN_1;
|
dev->recv_exp_amt = VFS301_FP_RECV_LEN_1;
|
||||||
|
|
||||||
|
|
|
@ -189,13 +189,7 @@ static void usbexchange_loop(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
|
||||||
switch (action->type) {
|
switch (action->type) {
|
||||||
case ACTION_SEND:
|
case ACTION_SEND:
|
||||||
fp_dbg("Sending %s", action->name);
|
fp_dbg("Sending %s", action->name);
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (transfer == NULL) {
|
|
||||||
fp_err("Failed to allocate transfer");
|
|
||||||
fpi_imgdev_session_error(data->device, -ENOMEM);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(data->device)),
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(data->device)),
|
||||||
action->endpoint, action->data,
|
action->endpoint, action->data,
|
||||||
action->size, async_send_cb, ssm,
|
action->size, async_send_cb, ssm,
|
||||||
|
@ -205,13 +199,7 @@ static void usbexchange_loop(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
|
||||||
|
|
||||||
case ACTION_RECEIVE:
|
case ACTION_RECEIVE:
|
||||||
fp_dbg("Receiving %d bytes", action->size);
|
fp_dbg("Receiving %d bytes", action->size);
|
||||||
transfer = libusb_alloc_transfer(0);
|
transfer = fpi_usb_alloc();
|
||||||
if (transfer == NULL) {
|
|
||||||
fp_err("Failed to allocate transfer");
|
|
||||||
fpi_imgdev_session_error(data->device, -ENOMEM);
|
|
||||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(data->device)),
|
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(data->device)),
|
||||||
action->endpoint, data->receive_buf,
|
action->endpoint, data->receive_buf,
|
||||||
action->size, async_recv_cb, ssm,
|
action->size, async_recv_cb, ssm,
|
||||||
|
@ -464,7 +452,7 @@ static int capture_chunk_async(struct vfs5011_data *data,
|
||||||
STOP_CHECK_LINES = 50
|
STOP_CHECK_LINES = 50
|
||||||
};
|
};
|
||||||
|
|
||||||
data->flying_transfer = libusb_alloc_transfer(0);
|
data->flying_transfer = fpi_usb_alloc();
|
||||||
libusb_fill_bulk_transfer(data->flying_transfer, handle, VFS5011_IN_ENDPOINT_DATA,
|
libusb_fill_bulk_transfer(data->flying_transfer, handle, VFS5011_IN_ENDPOINT_DATA,
|
||||||
data->capture_buffer,
|
data->capture_buffer,
|
||||||
nline * VFS5011_LINE_SIZE,
|
nline * VFS5011_LINE_SIZE,
|
||||||
|
|
Loading…
Reference in a new issue