]> sigrok.org Git - libsigrok.git/commitdiff
link-mso19: mso_receive_data: Simplify device instance lookup
authorLars-Peter Clausen <redacted>
Mon, 23 May 2016 16:21:40 +0000 (18:21 +0200)
committerLars-Peter Clausen <redacted>
Mon, 23 May 2016 16:25:24 +0000 (18:25 +0200)
The link-mso19 driver currently iterates the device instance list of the
driver to get the device instance for which the callback is called.

But the device instance is actually passed to the callback as the cb_data
parameter, so just use that instead and remove the lookup loop.

Besides that the current lookup loop does not even compile either.

Signed-off-by: Lars-Peter Clausen <redacted>
src/hardware/link-mso19/protocol.c

index ae4d16153187a88a473dec1f855226dd7ce56d34..5c263adb89317f3f2fee066c4df3c89ccdef779b 100644 (file)
@@ -349,25 +349,10 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data)
 {
        struct sr_datafeed_packet packet;
        struct sr_datafeed_logic logic;
-       struct sr_dev_inst *sdi;
-       GSList *l;
+       struct sr_dev_inst *sdi = cb_data;
+       struct dev_context *devc = sdi->priv;
        int i;
 
-       struct drv_context *drvc = di->context;
-
-       /* Find this device's devc struct by its fd. */
-       struct dev_context *devc = NULL;
-       for (l = drvc->instances; l; l = l->next) {
-               sdi = l->data;
-               devc = sdi->priv;
-               if (devc->serial->fd == fd)
-                       break;
-               devc = NULL;
-       }
-       if (!devc)
-               /* Shouldn't happen. */
-               return TRUE;
-
        (void)revents;
 
        uint8_t in[1024];