genesys: Return errors as exceptions from *wait_for_home()

merge-requests/101/head
Povilas Kanapickas 2019-07-14 23:40:56 +03:00
rodzic 2a9764b4fd
commit d29f6862c6
3 zmienionych plików z 7 dodań i 23 usunięć

Wyświetl plik

@ -3697,13 +3697,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
* we check we are not still parking before starting a new scan */ * we check we are not still parking before starting a new scan */
if (dev->parking == SANE_TRUE) if (dev->parking == SANE_TRUE)
{ {
status = sanei_genesys_wait_for_home (dev); sanei_genesys_wait_for_home(dev);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to wait for head to park: %s\n", __func__,
sane_strstatus(status));
return status;
}
} }
/* disable power saving*/ /* disable power saving*/
@ -6336,12 +6330,7 @@ sane_close_impl(SANE_Handle handle)
* to reach home position */ * to reach home position */
if(s->dev->parking==SANE_TRUE) if(s->dev->parking==SANE_TRUE)
{ {
status = sanei_genesys_wait_for_home (s->dev); sanei_genesys_wait_for_home(s->dev);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to wait for head to park: %s\n", __func__,
sane_strstatus(status));
}
} }
} }

Wyświetl plik

@ -1285,11 +1285,9 @@ sanei_genesys_asic_init(Genesys_Device* dev, int /*max_regs*/)
/** /**
* Wait for the scanning head to park * Wait for the scanning head to park
*/ */
SANE_Status void sanei_genesys_wait_for_home(Genesys_Device* dev)
sanei_genesys_wait_for_home (Genesys_Device * dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t val; uint8_t val;
int loop; int loop;
int max=300; int max=300;
@ -1308,7 +1306,7 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
{ {
DBG (DBG_info, DBG (DBG_info,
"%s: already at home\n", __func__); "%s: already at home\n", __func__);
return status; return;
} }
/* loop for 30 s max, polling home sensor */ /* loop for 30 s max, polling home sensor */
@ -1327,11 +1325,9 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
/* if after the timeout, head is still not parked, error out */ /* if after the timeout, head is still not parked, error out */
if (loop >= max && !(val & HOMESNR)) { if (loop >= max && !(val & HOMESNR)) {
DBG (DBG_error, "%s: failed to reach park position %ds\n", __func__, max/10); DBG (DBG_error, "%s: failed to reach park position in %dseconds\n", __func__, max/10);
return SANE_STATUS_IO_ERROR; throw SaneException(SANE_STATUS_IO_ERROR, "failed to reach park position");
} }
return status;
} }
/**@brief compute hardware sensor dpi to use /**@brief compute hardware sensor dpi to use

Wyświetl plik

@ -1904,8 +1904,7 @@ inline SensorExposure sanei_genesys_fixup_exposure(SensorExposure exposure)
return exposure; return exposure;
} }
extern SANE_Status extern void sanei_genesys_wait_for_home(Genesys_Device* dev);
sanei_genesys_wait_for_home(Genesys_Device *dev);
extern SANE_Status extern SANE_Status
sanei_genesys_asic_init(Genesys_Device *dev, SANE_Bool cold); sanei_genesys_asic_init(Genesys_Device *dev, SANE_Bool cold);