From 1904dad96258adb628acc71e433b57f6f50c7fcb Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Sat, 29 Jan 2011 11:50:08 +0900 Subject: [PATCH] Removed additional_probe gatekeeper variable The additional_probe variable protected add_source_mode() and add_color_mode() from being entered upon subsequent calls. These functions were patched to not insert duplicate records in this case, removing the need for the gatekeeper variable. --- backend/avision.c | 37 ++++++++++++++++++------------------- backend/avision.h | 4 ---- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/backend/avision.c b/backend/avision.c index 3368513ee..e782c8fb1 100644 --- a/backend/avision.c +++ b/backend/avision.c @@ -2279,6 +2279,9 @@ add_color_mode (Avision_Device* dev, color_mode mode, SANE_String name) dev->color_list [i] = strdup (name); dev->color_list_num [i] = mode; return SANE_STATUS_GOOD; + } else if (strcmp (dev->color_list [i], name) == 0) { + /* already in list */ + return SANE_STATUS_GOOD; } } @@ -2349,6 +2352,9 @@ add_source_mode (Avision_Device* dev, source_mode mode, SANE_String name) dev->source_list [i] = strdup (name); dev->source_list_num [i] = mode; return SANE_STATUS_GOOD; + } else if (strcmp (dev->source_list [i], name) == 0) { + /* already in list */ + return SANE_STATUS_GOOD; } } @@ -4185,9 +4191,6 @@ get_double ( &(result[48] ) )); else /* tested on AV3200 with it's max of 300dpi @color */ dev->read_stripe_size = 8; /* maybe made dynamic on scan res ... */ - /* set the flag for an additional probe at sane_open() */ - dev->additional_probe = SANE_TRUE; - /* normally the data_dq is 0x0a0d - but some newer scanner hang with it ... */ if (dev->inquiry_new_protocol) /* TODO: match on ASIC? which model hung? */ dev->data_dq = 0x0a0d; @@ -4405,8 +4408,6 @@ additional_probe (Avision_Scanner* s) add_source_mode (dev, AV_ADF_DUPLEX, "ADF Duplex"); } - dev->additional_probe = SANE_FALSE; - return SANE_STATUS_GOOD; } @@ -7721,20 +7722,18 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle) return status; } - /* maybe probe for additional information */ - if (dev->additional_probe) - { - status = wait_ready (&s->av_con, 1); - if (status != SANE_STATUS_GOOD) { - DBG (1, "sane_open: wait_ready() failed: %s\n", sane_strstatus (status)); - return status; - } - status = additional_probe (s); - if (status != SANE_STATUS_GOOD) { - DBG (1, "sane_open: additional probe failed: %s\n", sane_strstatus (status)); - return status; - } - } + status = wait_ready (&s->av_con, 1); + if (status != SANE_STATUS_GOOD) { + DBG (1, "sane_open: wait_ready() failed: %s\n", sane_strstatus (status)); + return status; + } + + /* update settings based on additional accessory information */ + status = additional_probe (s); + if (status != SANE_STATUS_GOOD) { + DBG (1, "sane_open: additional probe failed: %s\n", sane_strstatus (status)); + return status; + } /* initialize the options */ init_options (s); diff --git a/backend/avision.h b/backend/avision.h index 552c04fea..f01971972 100644 --- a/backend/avision.h +++ b/backend/avision.h @@ -408,10 +408,6 @@ typedef struct Avision_Device int scsi_buffer_size; /* nice to have SCSI buffer size */ int read_stripe_size; /* stripes to be read at-a-time */ - /* additional information - read delayed until sane_open() */ - - SANE_Bool additional_probe; - /* film scanner atributes - maybe these should be in the scanner struct? */ SANE_Range frame_range; SANE_Word current_frame;