static int get_reg(void *data, u64 *val)
{
	int addr = (int)data;
	int ret;
	u16 temp;

	ret = isl9519q_read_reg(the_isl_chg->client, addr, &temp);
	if (ret) {
		pr_err("isl9519q_read_reg to %x value =%d errored = %d\n",
			addr, temp, ret);
		return -EAGAIN;
	}

	*val = temp;
	return 0;
}
static bool is_trickle_charging(struct isl9519q_struct *isl_chg)
{
	u16 ctrl = 0;
	int ret;

	ret = isl9519q_read_reg(isl_chg->client, CONTROL_REG, &ctrl);

	if (!ret) {
		pr_debug("control_reg=0x%x.\n", ctrl);
	} else {
		dev_err(&isl_chg->client->dev,
			"%s couldnt read cntrl reg\n", __func__);
	}

	if (ctrl & TRCKL_CHG_STATUS_BIT)
		return true;

	return false;
}
static void isl9519q_charge(struct work_struct *isl9519_work)
{
	u16 temp;
	int ret;
	struct isl9519q_struct *isl_chg;
	int isl_charger_current;
	int mv_reading;

	isl_chg = container_of(isl9519_work, struct isl9519q_struct,
			charge_work.work);

	dev_dbg(&isl_chg->client->dev, "%s\n", __func__);

	if (isl_chg->charging) {
		isl_charger_current = isl_read_adc(CHANNEL_ADC_BATT_AMON,
								&mv_reading);
		dev_dbg(&isl_chg->client->dev, "%s mv_reading=%d\n",
				__func__, mv_reading);
		dev_dbg(&isl_chg->client->dev, "%s isl_charger_current=%d\n",
				__func__, isl_charger_current);
		if (isl_charger_current >= 0
			&& isl_charger_current <= isl_chg->term_current) {
			msm_charger_notify_event(
					&isl_chg->adapter_hw_chg,
					CHG_DONE_EVENT);
		}
		isl9519q_write_reg(isl_chg->client, CHG_CURRENT_REG,
				isl_chg->chgcurrent);
		ret = isl9519q_read_reg(isl_chg->client, CONTROL_REG, &temp);
		if (!ret) {
			if (!(temp & TRCKL_CHG_STATUS_BIT))
				msm_charger_notify_event(
						&isl_chg->adapter_hw_chg,
						CHG_BATT_BEGIN_FAST_CHARGING);
		} else {
			dev_err(&isl_chg->client->dev,
				"%s couldnt read cntrl reg\n", __func__);
		}
		schedule_delayed_work(&isl_chg->charge_work,
						ISL9519_CHG_PERIOD);
	}
}