+static int configure_probes(struct la8 *la8, GSList *probes)
+{
+ struct sr_probe *probe;
+ GSList *l;
+ uint8_t probe_bit;
+ char *tc;
+
+ la8->trigger_pattern = 0;
+ la8->trigger_mask = 0; /* Default to "don't care" for all probes. */
+
+ for (l = probes; l; l = l->next) {
+ probe = (struct sr_probe *)l->data;
+
+ if (!probe) {
+ sr_err("la8: %s: probe was NULL", __func__);
+ return SR_ERR;
+ }
+
+ /* Skip disabled probes. */
+ if (!probe->enabled)
+ continue;
+
+ /* Skip (enabled) probes with no configured trigger. */
+ if (!probe->trigger)
+ continue;
+
+ /* Note: Must only be run if probe->trigger != NULL. */
+ if (probe->index < 0 || probe->index > 7) {
+ sr_err("la8: %s: invalid probe index %d, must be "
+ "between 0 and 7", __func__, probe->index);
+ return SR_ERR;
+ }
+
+ probe_bit = (1 << (probe->index - 1));
+
+ /* Configure the probe's trigger mask and trigger pattern. */
+ for (tc = probe->trigger; tc && *tc; tc++) {
+ la8->trigger_mask |= probe_bit;
+
+ /* Sanity check, LA8 only supports low/high trigger. */
+ if (*tc != '0' && *tc != '1') {
+ sr_err("la8: %s: invalid trigger '%c', only "
+ "'0'/'1' supported", __func__, *tc);
+ return SR_ERR;
+ }
+
+ if (*tc == '1')
+ la8->trigger_pattern |= probe_bit;
+ }
+ }
+
+ sr_dbg("la8: %s: trigger_mask = 0x%x, trigger_pattern = 0x%x",
+ __func__, la8->trigger_mask, la8->trigger_pattern);
+
+ return SR_OK;
+}
+