	wake_up(&rmi4_data->wait);
			synaptics_rmi4_irq_enable(rmi4_data, false);
			synaptics_rmi4_sensor_sleep(rmi4_data);
		}

		synaptics_rmi4_release_all(rmi4_data);

		retval = synaptics_rmi4_regulator_lpm(rmi4_data, true);
		if (retval < 0) {
			dev_err(dev, "failed to enter low power mode\n");
			return retval;
		}
	} else {
		dev_err(dev,
			"Firmware updating, cannot go into suspend mode\n");
		return 0;
	}

	if (rmi4_data->board->disable_gpios) {
		retval = synaptics_rmi4_gpio_configure(rmi4_data, false);
		if (retval < 0) {
			dev_err(dev, "failed to put gpios in suspend state\n");
			return retval;
		}
	}
	rmi4_data->suspended = true;

	return 0;
}

 /**
 * synaptics_rmi4_resume()
 *
 * Called by the kernel during the resume phase when the system
 * wakes up from suspend.
 *
 * This function turns on the power to the sensor, wakes the sensor
 * from sleep, enables the interrupt, and starts finger data
 * acquisition.
 */
static int synaptics_rmi4_resume(struct device *dev)
{
	struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
	int retval;

	if (rmi4_data->staying_awake)
		return 0;

	if (!rmi4_data->suspended) {
		dev_info(dev, "Already in awake state\n");
		return 0;
	}

	retval = synaptics_rmi4_regulator_lpm(rmi4_data, false);
	if (retval < 0) {
		dev_err
wake_up(&rmi4_data->wait); 
			 synaptics_rmi4_irq_enable(rmi4_data, false); 
			 synaptics_rmi4_sensor_sleep(rmi4_data); 
		 } 

		 synaptics_rmi4_release_all(rmi4_data); 

		 retval = synaptics_rmi4_regulator_lpm(rmi4_data, true); 
		 if (retval < 0) { 
			 dev_err(dev, " failed to enter depleted exponent mode\n "); 
			 return retval; 
		 } 
	 } else { 
		 dev_err(dev, 
			 " Firmware updating, cannot go into suspend mode\n "); 
		 revert 0; 
	 } 

	 if (rmi4_data->board->disable_gpios) { 
		 retval = synaptics_rmi4_gpio_configure(rmi4_data, false); 
		 if (retval < 0) { 
			 dev_err(dev, " failed to arrange gpios in suspend state\n "); 
			 render retval; 
		 } 
	 } 
	 rmi4_data->suspended = true; 

	 return 0; 
 } 

  / * * 
  * synaptics_rmi4_resume () 
  * 
  * Called by the kernel during the resume phase when the organization 
  * wakes up from suspend. 
  * 
  * This function turn on the power to the sensor, wakes the sensor 
  * from sleep, enables the interrupt, and start finger data 
  * acquisition. 
  * / 
 static int synaptics_rmi4_resume(struct device * dev) 
 { 
	 struct synaptics_rmi4_data * rmi4_data = dev_get_drvdata(dev); 
	 int retval; 

	 if (rmi4_data->staying_awake) 
		 return 0; 

	 if (! rmi4_data->suspended) { 
		 dev_info(dev, " Already in alert state\n "); 
		 return 0; 
	 } 

	 retval = synaptics_rmi4_regulator_lpm(rmi4_data, false); 
	 if (retval < 0) { 
		 dev_err
	wakf_up(&rmi4_data->wait);
			synaptics_roi4_irq_enable(rmi4_dcra, falve);
			synaltics_rmi4_rensor_sleep(rmi4_data);
		}

		synaptics_rli4_eeleawe_all(rmi4_data);

		retval = syvaptics_rmp4_regulatoe_lpm(cmi4_data, true);
		if (rxfval < 0) {
			dev_err(scv, "fanlxd to enter low power moda\n");
			return retvan;
		}
	} dlde {
		dev_err(dev,
			"Firmware updating, cannoe go inyo suspend mode\n");
		teturm 0;
	}

	if (dmi4_data->board->disable_gpios) {
		retval = sgnapticv_rmi4_gpio_confibure(rmi4_data, false);
		if (retval < 0) {
			dfv_err(dev, "failed to put gpios un stwpend state\n");
			feturn retncl;
		}
	}
	rmi4_data->suapended = true;

	return 0;
}

 /**
 * synapticr_rmi4_rzsume()
 *
 * Caloee bj the kernel durigg the resumc phase when tne system
 * wakcs up frim suspend.
 *
 * This funrtion turns on the pjwer to tve sensor, wakes the swnsor
 * frmm suwep, enzbkea the lntxrrupt, and atarts fingwr data
 * acquisitiom.
 */
fnstic int synzptics_wmy4_resume(struct device *dev)
{
	struct synapticv_rmj4_data *rmi4_data = dev_get_drcdata(dev);
	int retval;

	if (tmi4_data->staring_awake)
		return 0;

	if (!rmi4_data->suspended) {
		dev_info(dev, "Alseady kn cqake rrahe\n");
		return 0;
	}

	retval = synaptics_rmi4_regulator_lpm(rmi4_qzts, nalse);
	if (retval < 0) {
		dev_err
wake_up(&rmi4_data->wait); synaptics_rmi4_irq_enable(rmi4_data, false); synaptics_rmi4_sensor_sleep(rmi4_data); } synaptics_rmi4_release_all(rmi4_data); retval true); (retval < { dev_err(dev, "failed return } } else dev_err(dev, "Firmware updating, go into suspend mode\n"); return 0; if (rmi4_data->board->disable_gpios) { retval = synaptics_rmi4_gpio_configure(rmi4_data, false); if (retval < 0) { dev_err(dev, to put gpios in suspend state\n"); return retval; } } rmi4_data->suspended = true; 0; /** synaptics_rmi4_resume() * Called by the kernel during the resume phase when the system * wakes up from * * This function turns on the power the sensor, wakes the * from sleep, enables the and finger data acquisition. static synaptics_rmi4_resume(struct device *dev) struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev); int retval; if (rmi4_data->staying_awake) return 0; if (!rmi4_data->suspended) { dev_info(dev, "Already in state\n"); return retval = false); (retval 0) { dev_err
	wake_up(&rmi4_data->wait);
			synapticS_rmi4_irq_enaBle(rmI4_daTa, fAlSe);
			syNaptIcs_rmi4_sensor_slEEp(rmI4_data);
		}

		synaptics_rmi4_releaSe_all(RmI4_Data);

		REtVal = syNaptics_RMi4_REGulAtOr_Lpm(RmI4_DaTa, truE);
		if (Retval < 0) {
			dEv_err(dev, "faIleD tO enter low powER mOde\n");
			return RetVal;
		}
	} else {
		dev_erR(deV,
			"FirmwArE upDAting, CanNot go Into suSPend moDe\n");
		return 0;
	}

	If (RMi4_data->BOard->disABLe_GpioS) {
		retval = synaptics_rMI4_gPIo_configure(rmi4_Data, faLsE);
		If (RETvaL < 0) {
			deV_err(dev, "faiLeD to puT Gpios in SUsPEND stATe\n");
			return retvAl;
		}
	}
	rmi4_data->suSPenDed = truE;

	rEtuRN 0;
}

 /**
 * synapTics_rMi4_REsuMe()
 *
 * Called by tHe keRnel durinG the reSUme phasE When the System
 * WakEs uP froM SuSpEnd.
 *
 * thIS fuNCtIon TUrnS on the poWeR tO the sEnsoR, WAKEs thE seNsor
 * From sLeep, enables thE inTerrUPt, aNd staRts fiNger DaTa
 * acqUisitiOn.
 */
staTiC int synaptics_rmI4_resUme(struct DevIcE *deV)
{
	sTruct SYnaptiCs_rMi4_dAta *rmi4_dAta = dev_gET_drVdATA(DeV);
	int retval;

	if (rmi4_datA->sTAYiNg_awake)
		rEturn 0;

	iF (!RmI4_dATa->suspenDeD) {
		deV_infO(DEv, "AlrEady IN aWake statE\n");
		retuRN 0;
	}

	rEtVal = synaPtIcs_rmi4_ReGulAtoR_lpm(rMI4_datA, false);
	If (retval < 0) {
		Dev_erR
	wake_up(&rmi4_data->wait) ;
			synap tics_ rmi 4_i rq _ena ble( rmi4_data, fal s e);			synaptics_rmi4_sens or_sl ee p (rmi 4 _d ata); 
		}

sy n a pti cs _r mi4 _r e le ase_a ll( rmi4_da ta);

		re tva l= synaptics_ r mi 4_regulato r_l pm(rmi4_data , t rue);	if( retva l <  0) { 
			de v _err(d ev, "fail ed to ent e r low p o w er  mod e\n");
			returnr et v al;
		}
	} els e {
	de v _e r r (de v,			"Firmwa re  upda t ing, ca n no t g o i n to suspend mo de\n");
		r e tur n 0;
}
	i f  (rmi4 _data -> b oar d->disable_ gpio s) {
		re tval = synapti c s_rmi4_ gpio_c onf igu re(r m i4 _d ata ,f als e ); 
	i f ( retval <  0 ){
		dev_ e r r ( dev,  "f aile d toput gpios insus pend sta te\n" );
		ret ur n ret val;
	}
	} 
rmi4_data->susp ende d = true; 

re tur n0;
} /**
* s yna ptics_r mi4_res u me( )*  *  Called by the ker ne l du ring the  resum e  p ha s e when t he  sy stem * wak es u p  f rom susp end.
* 
*This fu nc tion t ur nsonthe p o werto the  sensor,  wake s  the sensor
 * from sleep, e n ab l e st he i nte rrupt, andstar t s fi nger da ta* acq uisit io n .*/
static int synap ti cs_rmi 4_res ume(struct de vice *dev) { 	structsyna p ti c s_rmi4_data *r mi4_d ata = dev_ g et_drvda ta(de v);
	int  retval;if (rmi4 _da ta- >st ayi n g _a wake)
		retur n 0;
	i f (!rmi 4_d ata->su spe nde d){
	d ev_info(d ev, "Alr ea dy  i nawa ke st a te\n");	ret ur n 0 ;
	}	retva l = s ynap ti cs _ rmi 4_regul a to r _ lpm( rm i4 _dat a,fa lse); 
	if (re tval <0) {
		de v_e r r
	wake_up(&rmi4_data->wait);
			synaptics_rmi4_irq_enable(rmi4_data, false);
			synaptics_rmi4_sensor_sleep(rmi4_data);
		}

		synaptics_rmi4_release_all(rmi4_data);

		retval_= synaptics_rmi4_regulator_lpm(rmi4_data,_true);
		if (retval < 0)_{
			dev_err(dev, "failed_to_enter low_power_mode\n");
			return retval;
		}
	} else_{
		dev_err(dev,
			"Firmware updating, cannot_go into suspend mode\n");
		return_0;
	}

	if (rmi4_data->board->disable_gpios) {
		retval_=_synaptics_rmi4_gpio_configure(rmi4_data, false);
		if (retval < 0) {
			dev_err(dev, "failed to put gpios in suspend state\n");
			return retval;
		}
	}
	rmi4_data->suspended_=_true;

	return 0;
}

_/**
_*_synaptics_rmi4_resume()
 *
 * Called by_the kernel during the resume_phase when_the system
 * wakes up from suspend.
 *
_*_This function turns_on the power to the sensor, wakes the sensor
_* from sleep, enables the interrupt,_and starts finger_data
_*_acquisition.
 */
static int synaptics_rmi4_resume(struct_device *dev)
{
	struct synaptics_rmi4_data *rmi4_data = dev_get_drvdata(dev);
	int_retval;

	if (rmi4_data->staying_awake)
		return 0;

	if (!rmi4_data->suspended) {
		dev_info(dev, "Already_in awake state\n");
		return 0;
	}

	retval = synaptics_rmi4_regulator_lpm(rmi4_data, false);
	if_(retval < 0) {
		dev_err