static int pmic_fg_get_vbatt(struct pmic_fg_info *info, int *vbatt) { int ret, raw_val; ret = pmic_read_adc_val("VIBAT", "VBAT", &raw_val, info); if (ret < 0) goto vbatt_read_fail; *vbatt = ADC_TO_VBATT(raw_val); vbatt_read_fail: return ret; }
static int pmic_fg_get_vocv(struct pmic_fg_info *info, int *vocv) { int ret, value; u8 buf[2]; /* * OCV readings are 12-bit length. So Read * the MSB first left-shift by 4 bits and * read the lower nibble. */ ret = pmic_fg_reg_readmul(info, DC_FG_OCVH_REG, 2, buf); if (ret < 0) goto vocv_read_fail; value = (buf[0] << 4) | (buf[1] & 0xf); *vocv = ADC_TO_VBATT(value); vocv_read_fail: return ret; }
static int pmic_fg_get_vocv(struct pmic_fg_info *info, int *vocv) { int ret, value; /* * OCV readings are 12-bit length. So Read * the MSB first left-shift by 4 bits and * read the lower nibble. */ ret = pmic_fg_reg_readb(info, DC_FG_OCVH_REG); if (ret < 0) goto vocv_read_fail; value = ret << 4; ret = pmic_fg_reg_readb(info, DC_FG_OCVL_REG); if (ret < 0) goto vocv_read_fail; value |= (ret & 0xf); *vocv = ADC_TO_VBATT(value); vocv_read_fail: return ret; }