[sane-devel] Add function sanei_usb_get_endpoint

Reinhold Kainhofer reinhold at kainhofer.com
Mon Jan 31 21:02:47 UTC 2011

Am Montag, 31. Januar 2011, um 21:42:04 schrieb m. allan noah:
> I will not complain if you commit, but I don't understand the point.
> You are not saving any cycles when you look up the value instead of
> just setting it. It's the same switch(), touching the same variable.
> Plus, if you DO decide you need to change it, you now have to call a
> second function. Your code now does more operations, not less.

Yes, the purpose is not so much about deciding whether one has to use a 
different endpoint in normal operation, but about debugging (so that you can 
see in your own backend if the correct endpoint is used, when things don't 
work). And also about being able to restore the previous value if an endpoint 
is used for use one USB operationr..

With that new function, you can store the old endpoint, change it, do your USB 
operation and restore the old endpoint.
That might be useful if a scanner uses one endpoint for most operations, but 
another endpoint for some very particular operations. I can imagine that the 
code is clearer if one sets and immediately resets the endpoint for the 
operation(s) on the less-used endpoint.


Reinhold Kainhofer, reinhold at kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org

More information about the sane-devel mailing list