- }
-
- /* Check if we have contraints on allowed sampling rates */
-
- sprintf(avail_sysfs_path, DEVICE_AVAIL_FREQ_PATH, dev_num);
-
- if (sysfs_read_str(avail_sysfs_path, freqs_buf, sizeof(freqs_buf)) > 0) {
- cursor = freqs_buf;
-
- /* Decode allowed sampling rates string, ex: "10 20 50 100" */
-
- /* While we're not at the end of the string */
- while (*cursor && cursor[0]) {
-
- /* Decode a single value */
- sr = strtod(cursor, NULL);
-
- /* If this matches the selected rate, we're happy. Have some tolerance for rounding errors and avoid needless jumps to higher rates */
- if (fabs(arb_sampling_rate - sr) <= 0.01) {
- arb_sampling_rate = sr;
- break;
- }
-
- /*
- * If we reached a higher value than the desired rate, adjust selected rate so it matches the first higher available one and
- * stop parsing - this makes the assumption that rates are sorted by increasing value in the allowed frequencies string.
- */
- if (sr > arb_sampling_rate) {
- arb_sampling_rate = sr;
- break;
- }
-
- /* Skip digits */
- while (cursor[0] && !isspace(cursor[0]))
- cursor++;
-
- /* Skip spaces */
- while (cursor[0] && isspace(cursor[0]))
- cursor++;
- }
- }
-
- if (sensor[s].max_supported_rate &&
- arb_sampling_rate > sensor[s].max_supported_rate) {
- arb_sampling_rate = sensor[s].max_supported_rate;