mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
Update for libusb API rework
This commit is contained in:
@@ -46,22 +46,19 @@ static void continue_write_regv(struct write_regv_data *wdata);
|
||||
|
||||
/* libusb bulk callback for regv write completion transfer. continues the
|
||||
* transaction */
|
||||
static void write_regv_trf_complete(libusb_dev_handle *devh,
|
||||
libusb_urb_handle *urbh, enum libusb_urb_cb_status status,
|
||||
unsigned char endpoint, int rqlength, unsigned char *data,
|
||||
int actual_length, void *user_data)
|
||||
static void write_regv_trf_complete(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct write_regv_data *wdata = user_data;
|
||||
struct write_regv_data *wdata = transfer->user_data;
|
||||
|
||||
g_free(data);
|
||||
libusb_urb_handle_free(urbh);
|
||||
|
||||
if (status != FP_URB_COMPLETED)
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
wdata->callback(wdata->imgdev, -EIO, wdata->user_data);
|
||||
else if (rqlength != actual_length)
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
wdata->callback(wdata->imgdev, -EPROTO, wdata->user_data);
|
||||
else
|
||||
continue_write_regv(wdata);
|
||||
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
/* write from wdata->offset to upper_bound (inclusive) of wdata->regs */
|
||||
@@ -73,12 +70,13 @@ static int do_write_regv(struct write_regv_data *wdata, int upper_bound)
|
||||
unsigned char *data = g_malloc(alloc_size);
|
||||
unsigned int i;
|
||||
size_t data_offset = 0;
|
||||
struct libusb_urb_handle *urbh;
|
||||
struct libusb_bulk_transfer msg = {
|
||||
.endpoint = EP_OUT,
|
||||
.data = data,
|
||||
.length = alloc_size,
|
||||
};
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer();
|
||||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
g_free(data);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = offset; i < offset + num; i++) {
|
||||
const struct aes_regwrite *regwrite = &wdata->regs[i];
|
||||
@@ -86,14 +84,15 @@ static int do_write_regv(struct write_regv_data *wdata, int upper_bound)
|
||||
data[data_offset++] = regwrite->value;
|
||||
}
|
||||
|
||||
urbh = libusb_async_bulk_transfer(wdata->imgdev->udev, &msg,
|
||||
write_regv_trf_complete, wdata, BULK_TIMEOUT);
|
||||
if (!urbh) {
|
||||
libusb_fill_bulk_transfer(transfer, wdata->imgdev->udev, EP_OUT, data,
|
||||
alloc_size, write_regv_trf_complete, wdata, BULK_TIMEOUT);
|
||||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
g_free(data);
|
||||
return -EIO;
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* write the next batch of registers to be written, or if there are no more,
|
||||
|
||||
Reference in New Issue
Block a user