Loading drivers/power/supply/qcom/smb5-lib.c +18 −3 Original line number Diff line number Diff line Loading @@ -3345,7 +3345,7 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, union power_supply_propval *val) { union power_supply_propval pval = {0, }; int rc = 0; int rc = 0, buck_scale = 1, boost_scale = 1; if (chg->iio.usbin_i_chan) { rc = iio_read_channel_processed(chg->iio.usbin_i_chan, Loading @@ -3358,10 +3358,24 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, /* * For PM8150B, scaling factor = reciprocal of * 0.2V/A in Buck mode, 0.4V/A in Boost mode. * For PMI632, scaling factor = reciprocal of * 0.4V/A in Buck mode, 0.8V/A in Boost mode. */ switch (chg->smb_version) { case PMI632_SUBTYPE: buck_scale = 40; boost_scale = 80; break; default: buck_scale = 20; boost_scale = 40; break; } if (chg->otg_present || smblib_get_prop_dfp_mode(chg) != POWER_SUPPLY_TYPEC_NONE) { val->intval = DIV_ROUND_CLOSEST(val->intval * 100, 40); val->intval = DIV_ROUND_CLOSEST(val->intval * 100, boost_scale); return rc; } Loading @@ -3376,7 +3390,8 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, if (!pval.intval) val->intval = 0; else val->intval *= 5; val->intval = DIV_ROUND_CLOSEST(val->intval * 100, buck_scale); } else { val->intval = 0; rc = -ENODATA; Loading Loading
drivers/power/supply/qcom/smb5-lib.c +18 −3 Original line number Diff line number Diff line Loading @@ -3345,7 +3345,7 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, union power_supply_propval *val) { union power_supply_propval pval = {0, }; int rc = 0; int rc = 0, buck_scale = 1, boost_scale = 1; if (chg->iio.usbin_i_chan) { rc = iio_read_channel_processed(chg->iio.usbin_i_chan, Loading @@ -3358,10 +3358,24 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, /* * For PM8150B, scaling factor = reciprocal of * 0.2V/A in Buck mode, 0.4V/A in Boost mode. * For PMI632, scaling factor = reciprocal of * 0.4V/A in Buck mode, 0.8V/A in Boost mode. */ switch (chg->smb_version) { case PMI632_SUBTYPE: buck_scale = 40; boost_scale = 80; break; default: buck_scale = 20; boost_scale = 40; break; } if (chg->otg_present || smblib_get_prop_dfp_mode(chg) != POWER_SUPPLY_TYPEC_NONE) { val->intval = DIV_ROUND_CLOSEST(val->intval * 100, 40); val->intval = DIV_ROUND_CLOSEST(val->intval * 100, boost_scale); return rc; } Loading @@ -3376,7 +3390,8 @@ int smblib_get_prop_usb_current_now(struct smb_charger *chg, if (!pval.intval) val->intval = 0; else val->intval *= 5; val->intval = DIV_ROUND_CLOSEST(val->intval * 100, buck_scale); } else { val->intval = 0; rc = -ENODATA; Loading