allow null usb device for unit testing

merge-requests/1/head
Stphane Voltz 2012-10-02 21:32:07 +02:00
rodzic e9908d0f70
commit fb89d5d53c
2 zmienionych plików z 36 dodań i 1 usunięć

Wyświetl plik

@ -812,6 +812,13 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr,
DBG (DBG_io, "%s: %s\n", __FUNCTION__, msg);
}
/* unit testing case */
if(dev->dn==0)
{
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
/* slope table addresses are fixed : 0x4000, 0x4800, 0x5000, 0x5800, 0x6000 */
/* XXX STEF XXX USB 1.1 ? write_end_access (dev, 0x0f, 0x14); */
status = write_data (dev, 0x4000 + 0x800 * table_nr, steps * 2, table);
@ -823,7 +830,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr,
}
free (table);
DBG (DBG_proc, "%s: completed\n", __FUNCTION__);
DBGCOMPLETED;
return status;
}
@ -2552,6 +2559,12 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG (DBG_proc, "gl843_slow_back_home (wait_until_home = %d)\n",
wait_until_home);
/* unit testing case */
if(dev->dn==0)
{
return SANE_STATUS_GOOD;
}
if (dev->model->gpo_type == GPO_G4050)
{
/* test if we need to park XPA lamp, we check GPOADF */

Wyświetl plik

@ -290,6 +290,13 @@ sanei_genesys_write_register (Genesys_Device * dev, uint8_t reg, uint8_t val)
{
SANE_Status status;
/* be lenient for red done without device opened */
if(dev->dn==0)
{
/* unit testing case */
return SANE_STATUS_GOOD;
}
/* route to gl847 function if needed */
if(dev->model->asic_type==GENESYS_GL847 || dev->model->asic_type==GENESYS_GL124)
return sanei_genesys_write_gl847_register(dev, reg, val);
@ -383,6 +390,14 @@ sanei_genesys_read_register (Genesys_Device * dev, uint8_t reg, uint8_t * val)
{
SANE_Status status;
/* be lenient for red done without device opened */
if(dev->dn==0)
{
/* unit testing case */
*val=0;
return SANE_STATUS_GOOD;
}
/* route to gl847 function if needed */
if(dev->model->asic_type==GENESYS_GL847 || dev->model->asic_type==GENESYS_GL124)
return sanei_genesys_read_gl847_register(dev, reg, val);
@ -510,6 +525,13 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr,
SANE_Status status;
Genesys_Register_Set reg[3];
/* be lenient for read done without device opened */
if(dev->dn==0)
{
/* unit testing case */
return SANE_STATUS_GOOD;
}
DBG (DBG_io, "sanei_genesys_fe_write_data (0x%02x, 0x%04x)\n", addr, data);
reg[0].address = 0x51;