serial: rephrase check for speed (bitrate) in parameter string routine

Use positive logic, put the error path for an unavailable value where
the check for its availability is. Do the regular activity on available
values in the straight code path with lesser indentation. Also group the
bitrate, frame format, and handshake params when breaking text lines.
This commit is contained in:
Gerhard Sittig 2020-09-20 09:38:45 +02:00
parent 400bc4ffab
commit b1184024fe
1 changed files with 5 additions and 4 deletions

View File

@ -678,13 +678,14 @@ SR_PRIV int serial_set_paramstr(struct sr_serial_dev_inst *serial,
sr_spew("Got params: rate %d, frame %d/%d/%d, flow %d, rts %d, dtr %d.", sr_spew("Got params: rate %d, frame %d/%d/%d, flow %d, rts %d, dtr %d.",
speed, databits, parity, stopbits, flow, rts, dtr); speed, databits, parity, stopbits, flow, rts, dtr);
if (speed) { if (!speed) {
return serial_set_params(serial, speed, databits, parity,
stopbits, flow, rts, dtr);
} else {
sr_dbg("Could not infer speed from parameter string."); sr_dbg("Could not infer speed from parameter string.");
return SR_ERR_ARG; return SR_ERR_ARG;
} }
return serial_set_params(serial, speed,
databits, parity, stopbits,
flow, rts, dtr);
} }
/** /**