Lines Matching refs:ret
35 int ret; in scd4x_write_command() local
39 ret = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in scd4x_write_command()
45 return ret; in scd4x_write_command()
51 int ret; in scd4x_read_reg() local
53 ret = i2c_read_dt(&cfg->bus, rx_buf, rx_buf_size); in scd4x_read_reg()
54 if (ret < 0) { in scd4x_read_reg()
56 return ret; in scd4x_read_reg()
60 ret = scd4x_calc_crc(sys_get_be16(&rx_buf[i * 3])); in scd4x_read_reg()
61 if (ret != rx_buf[(i * 3) + 2]) { in scd4x_read_reg()
73 int ret; in scd4x_write_reg() local
86 ret = i2c_write_dt(&cfg->bus, tx_buf, sizeof(tx_buf)); in scd4x_write_reg()
87 if (ret < 0) { in scd4x_write_reg()
89 return ret; in scd4x_write_reg()
101 int ret; in scd4x_data_ready() local
104 ret = scd4x_write_command(dev, SCD4X_CMD_GET_DATA_READY_STATUS); in scd4x_data_ready()
105 if (ret < 0) { in scd4x_data_ready()
107 return ret; in scd4x_data_ready()
110 ret = scd4x_read_reg(dev, rx_data, sizeof(rx_data)); in scd4x_data_ready()
111 if (ret < 0) { in scd4x_data_ready()
113 return ret; in scd4x_data_ready()
129 int ret; in scd4x_read_sample() local
131 ret = scd4x_write_command(dev, SCD4X_CMD_READ_MEASUREMENT); in scd4x_read_sample()
132 if (ret < 0) { in scd4x_read_sample()
134 return ret; in scd4x_read_sample()
137 ret = scd4x_read_reg(dev, rx_data, sizeof(rx_data)); in scd4x_read_sample()
138 if (ret < 0) { in scd4x_read_sample()
140 return ret; in scd4x_read_sample()
153 int ret; in scd4x_setup_measurement() local
157 ret = scd4x_write_command(dev, SCD4X_CMD_START_PERIODIC_MEASUREMENT); in scd4x_setup_measurement()
158 if (ret < 0) { in scd4x_setup_measurement()
160 return ret; in scd4x_setup_measurement()
164 ret = scd4x_write_command(dev, SCD4X_CMD_LOW_POWER_PERIODIC_MEASUREMENT); in scd4x_setup_measurement()
165 if (ret < 0) { in scd4x_setup_measurement()
167 return ret; in scd4x_setup_measurement()
171 ret = scd4x_write_command(dev, SCD4X_CMD_POWER_DOWN); in scd4x_setup_measurement()
172 if (ret < 0) { in scd4x_setup_measurement()
174 return ret; in scd4x_setup_measurement()
186 int ret; in scd4x_set_idle_mode() local
191 ret = scd4x_write_command(dev, SCD4X_CMD_WAKE_UP); in scd4x_set_idle_mode()
192 if (ret < 0) { in scd4x_set_idle_mode()
194 return ret; in scd4x_set_idle_mode()
197 ret = scd4x_write_command(dev, SCD4X_CMD_STOP_PERIODIC_MEASUREMENT); in scd4x_set_idle_mode()
198 if (ret < 0) { in scd4x_set_idle_mode()
200 return ret; in scd4x_set_idle_mode()
209 int ret; in scd4x_set_temperature_offset() local
214 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_TEMPERATURE_OFFSET, &offset_temp, 1); in scd4x_set_temperature_offset()
215 if (ret < 0) { in scd4x_set_temperature_offset()
217 return ret; in scd4x_set_temperature_offset()
225 int ret; in scd4x_set_sensor_altitude() local
228 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_SENSOR_ALTITUDE, &altitude, 1); in scd4x_set_sensor_altitude()
229 if (ret < 0) { in scd4x_set_sensor_altitude()
231 return ret; in scd4x_set_sensor_altitude()
238 int ret; in scd4x_set_ambient_pressure() local
242 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_AMBIENT_PRESSURE, &ambient_pressure, 1); in scd4x_set_ambient_pressure()
243 if (ret < 0) { in scd4x_set_ambient_pressure()
245 return ret; in scd4x_set_ambient_pressure()
254 int ret; in scd4x_set_automatic_calib_enable() local
257 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_AUTOMATIC_CALIB_ENABLE, &automatic_calib_enable, in scd4x_set_automatic_calib_enable()
259 if (ret < 0) { in scd4x_set_automatic_calib_enable()
261 return ret; in scd4x_set_automatic_calib_enable()
270 int ret; in scd4x_set_self_calib_initial_period() local
273 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_SELF_CALIB_INITIAL_PERIOD, &initial_period, 1); in scd4x_set_self_calib_initial_period()
274 if (ret < 0) { in scd4x_set_self_calib_initial_period()
276 return ret; in scd4x_set_self_calib_initial_period()
285 int ret; in scd4x_set_self_calib_standard_period() local
288 ret = scd4x_write_reg(dev, SCD4X_CMD_SET_SELF_CALIB_STANDARD_PERIOD, &standard_period, 1); in scd4x_set_self_calib_standard_period()
289 if (ret < 0) { in scd4x_set_self_calib_standard_period()
291 return ret; in scd4x_set_self_calib_standard_period()
299 int ret; in scd4x_get_temperature_offset() local
302 ret = scd4x_write_command(dev, SCD4X_CMD_GET_TEMPERATURE_OFFSET); in scd4x_get_temperature_offset()
303 if (ret < 0) { in scd4x_get_temperature_offset()
305 return ret; in scd4x_get_temperature_offset()
308 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_temperature_offset()
309 if (ret < 0) { in scd4x_get_temperature_offset()
311 return ret; in scd4x_get_temperature_offset()
326 int ret; in scd4x_get_sensor_altitude() local
329 ret = scd4x_write_command(dev, SCD4X_CMD_GET_SENSOR_ALTITUDE); in scd4x_get_sensor_altitude()
330 if (ret < 0) { in scd4x_get_sensor_altitude()
332 return ret; in scd4x_get_sensor_altitude()
335 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_sensor_altitude()
336 if (ret < 0) { in scd4x_get_sensor_altitude()
338 return ret; in scd4x_get_sensor_altitude()
349 int ret; in scd4x_get_ambient_pressure() local
352 ret = scd4x_write_command(dev, SCD4X_CMD_GET_AMBIENT_PRESSURE); in scd4x_get_ambient_pressure()
353 if (ret < 0) { in scd4x_get_ambient_pressure()
355 return ret; in scd4x_get_ambient_pressure()
358 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_ambient_pressure()
359 if (ret < 0) { in scd4x_get_ambient_pressure()
361 return ret; in scd4x_get_ambient_pressure()
372 int ret; in scd4x_get_automatic_calib_enable() local
375 ret = scd4x_write_command(dev, SCD4X_CMD_GET_AUTOMATIC_CALIB_ENABLE); in scd4x_get_automatic_calib_enable()
376 if (ret < 0) { in scd4x_get_automatic_calib_enable()
378 return ret; in scd4x_get_automatic_calib_enable()
381 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_automatic_calib_enable()
382 if (ret < 0) { in scd4x_get_automatic_calib_enable()
384 return ret; in scd4x_get_automatic_calib_enable()
395 int ret; in scd4x_get_self_calib_initial_period() local
398 ret = scd4x_write_command(dev, SCD4X_CMD_GET_SELF_CALIB_INITIAL_PERIOD); in scd4x_get_self_calib_initial_period()
399 if (ret < 0) { in scd4x_get_self_calib_initial_period()
401 return ret; in scd4x_get_self_calib_initial_period()
404 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_self_calib_initial_period()
405 if (ret < 0) { in scd4x_get_self_calib_initial_period()
407 return ret; in scd4x_get_self_calib_initial_period()
418 int ret; in scd4x_get_self_calib_standard_period() local
421 ret = scd4x_write_command(dev, SCD4X_CMD_GET_SELF_CALIB_STANDARD_PERIOD); in scd4x_get_self_calib_standard_period()
422 if (ret < 0) { in scd4x_get_self_calib_standard_period()
424 return ret; in scd4x_get_self_calib_standard_period()
427 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_get_self_calib_standard_period()
428 if (ret < 0) { in scd4x_get_self_calib_standard_period()
430 return ret; in scd4x_get_self_calib_standard_period()
443 int ret; in scd4x_forced_recalibration() local
445 ret = scd4x_set_idle_mode(dev); in scd4x_forced_recalibration()
446 if (ret < 0) { in scd4x_forced_recalibration()
448 return ret; in scd4x_forced_recalibration()
451 ret = scd4x_write_reg(dev, SCD4X_CMD_FORCED_RECALIB, &target_concentration, 1); in scd4x_forced_recalibration()
452 if (ret < 0) { in scd4x_forced_recalibration()
454 return ret; in scd4x_forced_recalibration()
457 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_forced_recalibration()
458 if (ret < 0) { in scd4x_forced_recalibration()
460 return ret; in scd4x_forced_recalibration()
473 ret = scd4x_setup_measurement(dev); in scd4x_forced_recalibration()
474 if (ret < 0) { in scd4x_forced_recalibration()
476 return ret; in scd4x_forced_recalibration()
484 int ret; in scd4x_self_test() local
487 ret = scd4x_set_idle_mode(dev); in scd4x_self_test()
488 if (ret < 0) { in scd4x_self_test()
490 return ret; in scd4x_self_test()
493 ret = scd4x_write_command(dev, SCD4X_CMD_SELF_TEST); in scd4x_self_test()
494 if (ret < 0) { in scd4x_self_test()
496 return ret; in scd4x_self_test()
499 ret = scd4x_read_reg(dev, rx_buf, sizeof(rx_buf)); in scd4x_self_test()
500 if (ret < 0) { in scd4x_self_test()
502 return ret; in scd4x_self_test()
512 ret = scd4x_setup_measurement(dev); in scd4x_self_test()
513 if (ret < 0) { in scd4x_self_test()
515 return ret; in scd4x_self_test()
523 int ret; in scd4x_persist_settings() local
525 ret = scd4x_set_idle_mode(dev); in scd4x_persist_settings()
526 if (ret < 0) { in scd4x_persist_settings()
528 return ret; in scd4x_persist_settings()
531 ret = scd4x_write_command(dev, SCD4X_CMD_PERSIST_SETTINGS); in scd4x_persist_settings()
532 if (ret < 0) { in scd4x_persist_settings()
534 return ret; in scd4x_persist_settings()
537 ret = scd4x_setup_measurement(dev); in scd4x_persist_settings()
538 if (ret < 0) { in scd4x_persist_settings()
540 return ret; in scd4x_persist_settings()
548 int ret; in scd4x_factory_reset() local
550 ret = scd4x_set_idle_mode(dev); in scd4x_factory_reset()
551 if (ret < 0) { in scd4x_factory_reset()
553 return ret; in scd4x_factory_reset()
556 ret = scd4x_write_command(dev, SCD4X_CMD_FACTORY_RESET); in scd4x_factory_reset()
557 if (ret < 0) { in scd4x_factory_reset()
559 return ret; in scd4x_factory_reset()
562 ret = scd4x_setup_measurement(dev); in scd4x_factory_reset()
563 if (ret < 0) { in scd4x_factory_reset()
565 return ret; in scd4x_factory_reset()
575 int ret; in scd4x_sample_fetch() local
583 ret = scd4x_set_idle_mode(dev); in scd4x_sample_fetch()
584 if (ret < 0) { in scd4x_sample_fetch()
586 return ret; in scd4x_sample_fetch()
590 ret = scd4x_write_command(dev, SCD4X_CMD_MEASURE_SINGLE_SHOT_RHT); in scd4x_sample_fetch()
591 if (ret < 0) { in scd4x_sample_fetch()
593 return ret; in scd4x_sample_fetch()
596 ret = scd4x_write_command(dev, SCD4X_CMD_MEASURE_SINGLE_SHOT); in scd4x_sample_fetch()
597 if (ret < 0) { in scd4x_sample_fetch()
599 return ret; in scd4x_sample_fetch()
603 ret = scd4x_data_ready(dev, &is_data_ready); in scd4x_sample_fetch()
604 if (ret < 0) { in scd4x_sample_fetch()
606 return ret; in scd4x_sample_fetch()
613 ret = scd4x_read_sample(dev); in scd4x_sample_fetch()
614 if (ret < 0) { in scd4x_sample_fetch()
616 return ret; in scd4x_sample_fetch()
620 ret = scd4x_setup_measurement(dev); in scd4x_sample_fetch()
621 if (ret < 0) { in scd4x_sample_fetch()
623 return ret; in scd4x_sample_fetch()
662 int ret; in scd4x_attr_set() local
670 ret = scd4x_set_idle_mode(dev); in scd4x_attr_set()
671 if (ret < 0) { in scd4x_attr_set()
673 return ret; in scd4x_attr_set()
686 ret = scd4x_set_temperature_offset(dev, val); in scd4x_attr_set()
687 if (ret < 0) { in scd4x_attr_set()
689 return ret; in scd4x_attr_set()
696 ret = scd4x_set_sensor_altitude(dev, val); in scd4x_attr_set()
697 if (ret < 0) { in scd4x_attr_set()
699 return ret; in scd4x_attr_set()
706 ret = scd4x_set_ambient_pressure(dev, val); in scd4x_attr_set()
707 if (ret < 0) { in scd4x_attr_set()
709 return ret; in scd4x_attr_set()
717 ret = scd4x_set_automatic_calib_enable(dev, val); in scd4x_attr_set()
718 if (ret < 0) { in scd4x_attr_set()
720 return ret; in scd4x_attr_set()
731 ret = scd4x_set_self_calib_initial_period(dev, val); in scd4x_attr_set()
732 if (ret < 0) { in scd4x_attr_set()
734 return ret; in scd4x_attr_set()
745 ret = scd4x_set_self_calib_standard_period(dev, val); in scd4x_attr_set()
746 if (ret < 0) { in scd4x_attr_set()
748 return ret; in scd4x_attr_set()
755 ret = scd4x_setup_measurement(dev); in scd4x_attr_set()
756 if (ret < 0) { in scd4x_attr_set()
758 return ret; in scd4x_attr_set()
768 int ret; in scd4x_attr_get() local
777 ret = scd4x_set_idle_mode(dev); in scd4x_attr_get()
778 if (ret < 0) { in scd4x_attr_get()
780 return ret; in scd4x_attr_get()
786 ret = scd4x_get_temperature_offset(dev, val); in scd4x_attr_get()
787 if (ret < 0) { in scd4x_attr_get()
789 return ret; in scd4x_attr_get()
793 ret = scd4x_get_sensor_altitude(dev, val); in scd4x_attr_get()
794 if (ret < 0) { in scd4x_attr_get()
796 return ret; in scd4x_attr_get()
800 ret = scd4x_get_ambient_pressure(dev, val); in scd4x_attr_get()
801 if (ret < 0) { in scd4x_attr_get()
803 return ret; in scd4x_attr_get()
808 ret = scd4x_get_automatic_calib_enable(dev, val); in scd4x_attr_get()
809 if (ret < 0) { in scd4x_attr_get()
811 return ret; in scd4x_attr_get()
819 ret = scd4x_get_self_calib_initial_period(dev, val); in scd4x_attr_get()
820 if (ret < 0) { in scd4x_attr_get()
822 return ret; in scd4x_attr_get()
830 ret = scd4x_get_self_calib_standard_period(dev, val); in scd4x_attr_get()
831 if (ret < 0) { in scd4x_attr_get()
833 return ret; in scd4x_attr_get()
840 ret = scd4x_setup_measurement(dev); in scd4x_attr_get()
841 if (ret < 0) { in scd4x_attr_get()
843 return ret; in scd4x_attr_get()
852 int ret; in scd4x_init() local
859 ret = scd4x_write_command(dev, SCD4X_CMD_STOP_PERIODIC_MEASUREMENT); in scd4x_init()
860 if (ret < 0) { in scd4x_init()
863 ret = scd4x_write_command(dev, SCD4X_CMD_WAKE_UP); in scd4x_init()
864 if (ret < 0) { in scd4x_init()
866 return ret; in scd4x_init()
870 ret = scd4x_write_command(dev, SCD4X_CMD_REINIT); in scd4x_init()
871 if (ret < 0) { in scd4x_init()
873 return ret; in scd4x_init()
876 ret = scd4x_setup_measurement(dev); in scd4x_init()
877 if (ret < 0) { in scd4x_init()
879 return ret; in scd4x_init()