OF_PROP_READ

  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  然后返回错误码,然后报错


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YouthTravel

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值