@@ -668,8 +668,14 @@ ltc2983_thermocouple_new(const struct fwnode_handle *child, struct ltc2983_data
668668 if (fwnode_property_read_bool (child , "adi,single-ended" ))
669669 thermo -> sensor_config = LTC2983_THERMOCOUPLE_SGL (1 );
670670
671- ret = fwnode_property_read_u32 (child , "adi,sensor-oc-current-microamp" , & oc_current );
672- if (!ret ) {
671+ if (fwnode_property_present (child , "adi,sensor-oc-current-microamp" )) {
672+ ret = fwnode_property_read_u32 (child ,
673+ "adi,sensor-oc-current-microamp" ,
674+ & oc_current );
675+ if (ret )
676+ return dev_err_ptr_probe (dev , ret ,
677+ "Failed to read adi,sensor-oc-current-microamp\n" );
678+
673679 switch (oc_current ) {
674680 case 10 :
675681 thermo -> sensor_config |=
@@ -759,8 +765,12 @@ ltc2983_rtd_new(const struct fwnode_handle *child, struct ltc2983_data *st,
759765 return dev_err_ptr_probe (dev , ret ,
760766 "Property reg must be given\n" );
761767
762- ret = fwnode_property_read_u32 (child , "adi,number-of-wires" , & n_wires );
763- if (!ret ) {
768+ if (fwnode_property_present (child , "adi,number-of-wires" )) {
769+ ret = fwnode_property_read_u32 (child , "adi,number-of-wires" , & n_wires );
770+ if (ret )
771+ return dev_err_ptr_probe (dev , ret ,
772+ "Failed to read adi,number-of-wires\n" );
773+
764774 switch (n_wires ) {
765775 case 2 :
766776 rtd -> sensor_config = LTC2983_RTD_N_WIRES (0 );
@@ -842,12 +852,13 @@ ltc2983_rtd_new(const struct fwnode_handle *child, struct ltc2983_data *st,
842852 rtd -> sensor .fault_handler = ltc2983_common_fault_handler ;
843853 rtd -> sensor .assign_chan = ltc2983_rtd_assign_chan ;
844854
845- ret = fwnode_property_read_u32 (child , "adi,excitation-current-microamp" ,
846- & excitation_current );
847- if (ret ) {
848- /* default to 5uA */
849- rtd -> excitation_current = 1 ;
850- } else {
855+ if (fwnode_property_present (child , "adi,excitation-current-microamp" )) {
856+ ret = fwnode_property_read_u32 (child , "adi,excitation-current-microamp" ,
857+ & excitation_current );
858+ if (ret )
859+ return dev_err_ptr_probe (dev , ret ,
860+ "Failed to read adi,excitation-current-microamp\n" );
861+
851862 switch (excitation_current ) {
852863 case 5 :
853864 rtd -> excitation_current = 0x01 ;
@@ -878,9 +889,17 @@ ltc2983_rtd_new(const struct fwnode_handle *child, struct ltc2983_data *st,
878889 "Invalid value for excitation current(%u)\n" ,
879890 excitation_current );
880891 }
892+ } else {
893+ /* default to 5uA */
894+ rtd -> excitation_current = 1 ;
881895 }
882896
883- fwnode_property_read_u32 (child , "adi,rtd-curve" , & rtd -> rtd_curve );
897+ if (fwnode_property_present (child , "adi,rtd-curve" )) {
898+ ret = fwnode_property_read_u32 (child , "adi,rtd-curve" , & rtd -> rtd_curve );
899+ if (ret )
900+ return dev_err_ptr_probe (dev , ret ,
901+ "Failed to read adi,rtd-curve\n" );
902+ }
884903
885904 return & rtd -> sensor ;
886905}
@@ -950,17 +969,13 @@ ltc2983_thermistor_new(const struct fwnode_handle *child, struct ltc2983_data *s
950969 thermistor -> sensor .fault_handler = ltc2983_common_fault_handler ;
951970 thermistor -> sensor .assign_chan = ltc2983_thermistor_assign_chan ;
952971
953- ret = fwnode_property_read_u32 (child , "adi,excitation-current-nanoamp" ,
954- & excitation_current );
955- if (ret ) {
956- /* Auto range is not allowed for custom sensors */
957- if (sensor -> type >= LTC2983_SENSOR_THERMISTOR_STEINHART )
958- /* default to 1uA */
959- thermistor -> excitation_current = 0x03 ;
960- else
961- /* default to auto-range */
962- thermistor -> excitation_current = 0x0c ;
963- } else {
972+ if (fwnode_property_present (child , "adi,excitation-current-nanoamp" )) {
973+ ret = fwnode_property_read_u32 (child , "adi,excitation-current-nanoamp" ,
974+ & excitation_current );
975+ if (ret )
976+ return dev_err_ptr_probe (dev , ret ,
977+ "Failed to read adi,excitation-current-nanoamp\n" );
978+
964979 switch (excitation_current ) {
965980 case 0 :
966981 /* auto range */
@@ -1008,6 +1023,14 @@ ltc2983_thermistor_new(const struct fwnode_handle *child, struct ltc2983_data *s
10081023 "Invalid value for excitation current(%u)\n" ,
10091024 excitation_current );
10101025 }
1026+ } else {
1027+ /* Auto range is not allowed for custom sensors */
1028+ if (sensor -> type >= LTC2983_SENSOR_THERMISTOR_STEINHART )
1029+ /* default to 1uA */
1030+ thermistor -> excitation_current = 0x03 ;
1031+ else
1032+ /* default to auto-range */
1033+ thermistor -> excitation_current = 0x0c ;
10111034 }
10121035
10131036 return & thermistor -> sensor ;
@@ -1046,9 +1069,13 @@ ltc2983_diode_new(const struct fwnode_handle *child, const struct ltc2983_data *
10461069 diode -> sensor .fault_handler = ltc2983_common_fault_handler ;
10471070 diode -> sensor .assign_chan = ltc2983_diode_assign_chan ;
10481071
1049- ret = fwnode_property_read_u32 (child , "adi,excitation-current-microamp" ,
1050- & excitation_current );
1051- if (!ret ) {
1072+ if (fwnode_property_present (child , "adi,excitation-current-microamp" )) {
1073+ ret = fwnode_property_read_u32 (child , "adi,excitation-current-microamp" ,
1074+ & excitation_current );
1075+ if (ret )
1076+ return dev_err_ptr_probe (dev , ret ,
1077+ "Failed to read adi,excitation-current-microamp\n" );
1078+
10521079 switch (excitation_current ) {
10531080 case 10 :
10541081 diode -> excitation_current = 0x00 ;
@@ -1069,7 +1096,12 @@ ltc2983_diode_new(const struct fwnode_handle *child, const struct ltc2983_data *
10691096 }
10701097 }
10711098
1072- fwnode_property_read_u32 (child , "adi,ideal-factor-value" , & temp );
1099+ if (fwnode_property_present (child , "adi,ideal-factor-value" )) {
1100+ ret = fwnode_property_read_u32 (child , "adi,ideal-factor-value" , & temp );
1101+ if (ret )
1102+ return dev_err_ptr_probe (dev , ret ,
1103+ "Failed to read adi,ideal-factor-value\n" );
1104+ }
10731105
10741106 /* 2^20 resolution */
10751107 diode -> ideal_factor_value = __convert_to_raw (temp , 1048576 );
0 commit comments