genesys: Revert 512-byte bulk transfer alignment workaround

It should be handled by libusb.
merge-requests/63/head
Povilas Kanapickas 2019-05-11 12:05:10 +03:00
rodzic 4a899d26f3
commit 69435b3bb2
4 zmienionych plików z 13 dodań i 91 usunięć

Wyświetl plik

@ -242,11 +242,6 @@ gl843_bulk_read_data (Genesys_Device * dev, uint8_t addr,
size = 0xF000;
else
size = len;
if (size >= 512)
{
size /= 512;
size *= 512;
}
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size);

Wyświetl plik

@ -74,7 +74,7 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr,
uint8_t * data, size_t len)
{
SANE_Status status;
size_t size, target, read, done;
size_t size, target;
uint8_t outdata[8];
uint8_t *buffer;
@ -121,40 +121,14 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr,
return status;
}
/* blocks must be multiple of 512 but not last block */
read = size;
if (read >= 512)
{
read /= 512;
read *= 512;
}
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read);
status = sanei_usb_read_bulk (dev->dn, buffer, &read);
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size);
status = sanei_usb_read_bulk (dev->dn, buffer, &size);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
done=read;
DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done);
/* read less than 512 bytes remainder */
if (read < size)
{
read = size - read;
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read);
status = sanei_usb_read_bulk (dev->dn, buffer+done, &read);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
done=read;
DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done);
}
DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__,
(u_long) size, (u_long) (target - size));

Wyświetl plik

@ -70,7 +70,7 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr,
uint8_t * data, size_t len)
{
SANE_Status status;
size_t size, target, read, done;
size_t size, target;
uint8_t outdata[8];
uint8_t *buffer;
@ -116,40 +116,15 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr,
return status;
}
/* blocks must be multiple of 512 but not last block */
read = size;
if (read >= 512)
{
read /= 512;
read *= 512;
}
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read);
status = sanei_usb_read_bulk (dev->dn, buffer, &read);
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size);
status = sanei_usb_read_bulk (dev->dn, buffer, &size);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
done=read;
DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done);
/* read less than 512 bytes remainder */
if (read < size)
{
read = size - read;
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read);
status = sanei_usb_read_bulk (dev->dn, buffer+done, &read);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
done=read;
DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done);
}
DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, (u_long) size,
(u_long) (target - size));

Wyświetl plik

@ -197,7 +197,7 @@ SANE_Status sanei_genesys_bulk_read_data(Genesys_Device * dev, uint8_t addr, uin
size_t len)
{
SANE_Status status;
size_t size, target, read, done;
size_t size, target;
uint8_t outdata[8], *buffer;
DBG(DBG_io, "%s: requesting %lu bytes (unused addr=0x%02x)\n", __func__, (u_long) len,addr);
@ -237,34 +237,12 @@ SANE_Status sanei_genesys_bulk_read_data(Genesys_Device * dev, uint8_t addr, uin
return status;
}
// blocks must be multiple of 512 except the last block
read = size;
read /= 512;
read *= 512;
if(read > 0) {
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read);
status = sanei_usb_read_bulk (dev->dn, data, &read);
if (status != SANE_STATUS_GOOD) {
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
}
// read less than 512 bytes remainder
if (read < size) {
done = read;
read = size - read;
DBG(DBG_io2, "%s: trying to read remaining %lu bytes of data\n", __func__,
(u_long) read);
status = sanei_usb_read_bulk (dev->dn, data+done, &read);
if (status != SANE_STATUS_GOOD) {
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size);
status = sanei_usb_read_bulk(dev->dn, data, &size);
if (status != SANE_STATUS_GOOD) {
DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__,
sane_strstatus(status));
return status;
}
DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__,