of_batterydata.c
// optional =1 =0 =1为可选,=0为必选
#define OF_PROP_READ(chip, prop,qpnp_dt_property, retval, optional) \
do { \
if (retval) \
break; \
\
retval = of_property_read_u32(chip->spmi->dev.of_node, \
"qcom,"qpnp_dt_property, \
&chip->prop); \
pr_err("Error reading " #qpnp_dt_property \
" property retval_1 =%d\n", retval); \
\
if ((retval == -EINVAL) && optional) { \
pr_err("Error reading " #qpnp_dt_property \
" property retval_2 =%d\n", retval); \
retval = 0; \
} \
else if (retval) \
pr_err("Error reading " #qpnp_dt_property \
" property rc =%d\n", rc); \
} while (0)
OF_PROP_READ(chip, cfg_max_voltage_mv,"vddmax-mv", rc,0);
OF_PROP_READ(chip, cfg_safe_voltage_mv,"vddsafe-mv", rc,0);
OF_PROP_READ(chip, cfg_min_voltage_mv,"vinmin-mv", rc,0);
OF_PROP_READ(chip, cfg_safe_current,"ibatsafe-ma", rc,0);
OF_PROP_READ(chip, cfg_icl_current,"chg-default-dcp-icl-ma", rc,0);
if(rc)
pr_err("Error reading required propertyrc=%d\n", rc);
OF_PROP_READ(chip, cfg_tchg_mins,"tchg-mins", rc,1);
OF_PROP_READ(chip, cfg_warm_bat_decidegc,"warm-bat-decidegc", rc,1);
OF_PROP_READ(chip, cfg_cool_bat_decidegc,"cool-bat-decidegc", rc,1);
OF_PROP_READ(chip, cfg_hot_batt_p,"batt-hot-percentage", rc,1);
OF_PROP_READ(chip, cfg_cold_batt_p,"batt-cold-percentage", rc,1);
OF_PROP_READ(chip, cfg_batt_weak_voltage_uv,"vbatweak-uv", rc,1);
OF_PROP_READ(chip, cfg_soc_resume_limit,"resume-soc", rc,1);// 因为这个值是在fg中定义的,所以这里读到的是空
if(rc){
pr_err("Error reading optional propertyrc=%d\n", rc);
return rc;
}
这个OF_PROP_READ宏的入口 if(retval)的设计,导致一旦发生错误,则不可继续;
即如果chg-default-dcp-icl-ma读取失败,则后续的参数读取都不能给进行,一直到结尾rc 然后返回错误码,然后报错