genesys: Return errors as exceptions from *boot() and friends

merge-requests/104/head
Povilas Kanapickas 2019-07-20 11:01:52 +03:00
rodzic 67ecc10b81
commit 86a151a4f2
7 zmienionych plików z 15 dodań i 39 usunięć

Wyświetl plik

@ -3033,11 +3033,9 @@ static void gl124_init_gpio(Genesys_Device* dev)
/** /**
* set memory layout by filling values in dedicated registers * set memory layout by filling values in dedicated registers
*/ */
static SANE_Status static void gl124_init_memory_layout(Genesys_Device* dev)
gl124_init_memory_layout (Genesys_Device * dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
int idx = 0; int idx = 0;
/* point to per model memory layout */ /* point to per model memory layout */
@ -3095,8 +3093,6 @@ gl124_init_memory_layout (Genesys_Device * dev)
sanei_genesys_write_register (dev, 0xf5, layouts[idx].re5); sanei_genesys_write_register (dev, 0xf5, layouts[idx].re5);
sanei_genesys_write_register (dev, 0xf6, layouts[idx].re6); sanei_genesys_write_register (dev, 0xf6, layouts[idx].re6);
sanei_genesys_write_register (dev, 0xf7, layouts[idx].re7); sanei_genesys_write_register (dev, 0xf7, layouts[idx].re7);
return status;
} }
/** /**
@ -3120,11 +3116,9 @@ gl124_init(Genesys_Device * dev)
/* * /* *
* initialize ASIC from power on condition * initialize ASIC from power on condition
*/ */
static SANE_Status static void gl124_boot(Genesys_Device* dev, SANE_Bool cold)
gl124_boot (Genesys_Device * dev, SANE_Bool cold)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t val; uint8_t val;
// reset ASIC in case of cold boot // reset ASIC in case of cold boot
@ -3170,10 +3164,8 @@ gl124_boot (Genesys_Device * dev, SANE_Bool cold)
// setup gpio // setup gpio
gl124_init_gpio(dev); gl124_init_gpio(dev);
/* setup internal memory layout */ // setup internal memory layout
RIE (gl124_init_memory_layout (dev)); gl124_init_memory_layout(dev);
return SANE_STATUS_GOOD;
} }

Wyświetl plik

@ -3625,8 +3625,7 @@ static void gl843_init_gpio(Genesys_Device* dev)
/* * /* *
* initialize ASIC from power on condition * initialize ASIC from power on condition
*/ */
static SANE_Status static void gl843_boot(Genesys_Device* dev, SANE_Bool cold)
gl843_boot (Genesys_Device * dev, SANE_Bool cold)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
uint8_t val; uint8_t val;
@ -3714,8 +3713,6 @@ gl843_boot (Genesys_Device * dev, SANE_Bool cold)
gl843_feed (dev, 300); gl843_feed (dev, 300);
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
return SANE_STATUS_GOOD;
} }
/* * /* *

Wyświetl plik

@ -2299,11 +2299,9 @@ static void gl846_init_gpio(Genesys_Device* dev)
/** /**
* set memory layout by filling values in dedicated registers * set memory layout by filling values in dedicated registers
*/ */
static SANE_Status static void gl846_init_memory_layout(Genesys_Device* dev)
gl846_init_memory_layout (Genesys_Device * dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
int idx = 0, i; int idx = 0, i;
uint8_t val; uint8_t val;
@ -2316,8 +2314,7 @@ gl846_init_memory_layout (Genesys_Device * dev)
} }
if(layouts[idx].model==NULL) if(layouts[idx].model==NULL)
{ {
DBG(DBG_error, "%s: failed to find memory layout for model %s!\n", __func__, dev->model->name); throw SaneException("failed to find memory layout for model %s", dev->model->name);
return SANE_STATUS_INVAL;
} }
/* CLKSET and DRAMSEL */ /* CLKSET and DRAMSEL */
@ -2333,18 +2330,14 @@ gl846_init_memory_layout (Genesys_Device * dev)
{ {
sanei_genesys_write_register(dev, 0xe0+i, layouts[idx].rx[i]); sanei_genesys_write_register(dev, 0xe0+i, layouts[idx].rx[i]);
} }
return status;
} }
/* * /* *
* initialize ASIC from power on condition * initialize ASIC from power on condition
*/ */
static SANE_Status static void gl846_boot(Genesys_Device* dev, SANE_Bool cold)
gl846_boot (Genesys_Device * dev, SANE_Bool cold)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
SANE_Status status = SANE_STATUS_GOOD;
uint8_t val; uint8_t val;
// reset ASIC if cold boot // reset ASIC if cold boot
@ -2396,13 +2389,11 @@ gl846_boot (Genesys_Device * dev, SANE_Bool cold)
// setup gpio // setup gpio
gl846_init_gpio(dev); gl846_init_gpio(dev);
/* setup internal memory layout */ // setup internal memory layout
RIE (gl846_init_memory_layout (dev)); gl846_init_memory_layout(dev);
SETREG (0xf8, 0x05); SETREG (0xf8, 0x05);
sanei_genesys_write_register(dev, 0xf8, dev->reg.find_reg(0xf8).value); sanei_genesys_write_register(dev, 0xf8, dev->reg.find_reg(0xf8).value);
return SANE_STATUS_GOOD;
} }
/** /**

Wyświetl plik

@ -367,8 +367,7 @@ gl846_stop_action (Genesys_Device * dev);
static SANE_Status static SANE_Status
gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home); gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home);
static SANE_Status static void gl846_boot(Genesys_Device* dev, SANE_Bool cold);
gl846_boot (Genesys_Device * dev, SANE_Bool cold);

Wyświetl plik

@ -2444,8 +2444,7 @@ gl847_init_memory_layout (Genesys_Device * dev)
/* * /* *
* initialize ASIC from power on condition * initialize ASIC from power on condition
*/ */
static SANE_Status static void gl847_boot(Genesys_Device* dev, SANE_Bool cold)
gl847_boot (Genesys_Device * dev, SANE_Bool cold)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
uint8_t val; uint8_t val;
@ -2491,8 +2490,6 @@ gl847_boot (Genesys_Device * dev, SANE_Bool cold)
SETREG (0xf8, 0x01); SETREG (0xf8, 0x01);
sanei_genesys_write_register(dev, 0xf8, dev->reg.find_reg(0xf8).value); sanei_genesys_write_register(dev, 0xf8, dev->reg.find_reg(0xf8).value);
return SANE_STATUS_GOOD;
} }
/** /**

Wyświetl plik

@ -1254,8 +1254,8 @@ sanei_genesys_asic_init(Genesys_Device* dev, int /*max_regs*/)
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
/* set up hardware and registers */ // set up hardware and registers
RIE (dev->model->cmd_set->asic_boot (dev, cold)); dev->model->cmd_set->asic_boot(dev, cold);
/* now hardware part is OK, set up device struct */ /* now hardware part is OK, set up device struct */
dev->white_average_data.clear(); dev->white_average_data.clear();

Wyświetl plik

@ -1145,7 +1145,7 @@ struct Genesys_Command_Set
/** /**
* cold boot init function * cold boot init function
*/ */
SANE_Status (*asic_boot) (Genesys_Device * dev, SANE_Bool cold); void (*asic_boot) (Genesys_Device* dev, SANE_Bool cold);
}; };