[i] *
					extra_power) / capped_extra_power;
}

static int allocate_power(struct thermal_zone_device *tz,
			  int control_temp)
{
	struct thermal_instance *instance;
	struct power_allocator_params *params = tz->governor_data;
	u32 *req_power, *max_power, *granted_power, *extra_actor_power;
	u32 *weighted_req_power;
	u32 total_req_power, max_allocatable_power, total_weighted_req_power;
	u32 total_granted_power, power_range;
	int i, num_actors, total_weight, ret = 0;
	int trip_max_desired_temperature = params->trip_max_desired_temperature;

	mutex_lock(&tz->lock);

	num_actors = 0;
	total_weight = 0;
	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
		if ((instance->trip == trip_max_desired_temperature) &&
		    cdev_is_power_actor(instance->cdev)) {
			num_actors++;
			total_weight += instance->weight;
		}
	}

	if (!num_actors) {
		ret = -ENODEV;
		goto unlock;
	}

	/*
	 * We need to allocate five arrays of the same size:
	 * req_power, max_power, granted_power, extra_actor_power and
	 * weighted_req_power.  They are going to be needed until this
	 * function returns.  Allocate them all in one go to simplify
	 * the allocation and deallocation logic.
	 */
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*max_power));
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*granted_power));
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*extra_actor_power));
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*weighted_req_power));
	req_power = kcalloc(num_actors * 5, sizeof(*req
[ i ] * 
					 extra_power) / capped_extra_power; 
 } 

 static int allocate_power(struct thermal_zone_device * tz, 
			   int control_temp) 
 { 
	 struct thermal_instance * instance; 
	 struct power_allocator_params * params = tz->governor_data; 
	 u32 * req_power, * max_power, * granted_power, * extra_actor_power; 
	 u32 * weighted_req_power; 
	 u32 total_req_power, max_allocatable_power, total_weighted_req_power; 
	 u32 total_granted_power, power_range; 
	 int i, num_actors, total_weight, ret = 0; 
	 int trip_max_desired_temperature = params->trip_max_desired_temperature; 

	 mutex_lock(&tz->lock); 

	 num_actors = 0; 
	 total_weight = 0; 
	 list_for_each_entry(instance, & tz->thermal_instances, tz_node) { 
		 if (( instance->trip = = trip_max_desired_temperature) & & 
		     cdev_is_power_actor(instance->cdev) ) { 
			 num_actors++; 
			 total_weight + = instance->weight; 
		 } 
	 } 

	 if (! num_actors) { 
		 ret = -ENODEV; 
		 goto unlock; 
	 } 

	 / * 
	  * We need to allocate five arrays of the like size: 
	  * req_power, max_power, granted_power, extra_actor_power and 
	  * weighted_req_power.   They are sound to be needed until this 
	  * function return.   Allocate them all in one become to simplify 
	  * the allocation and deallocation logic. 
	  * / 
	 BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*max_power) ); 
	 BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*granted_power) ); 
	 BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*extra_actor_power) ); 
	 BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*weighted_req_power) ); 
	 req_power = kcalloc(num_actors * 5, sizeof(*req
[i] *
					edtra_power) / capped_extra_poder;
}

static int allocate_'ower(stduct thefmal_zone_device *tz,
			  int contrll_remp)
{
	suguct thermal_instance *knstance;
	snruct powwr_aloicator_params *params = tz->gkyernox_deta;
	u32 *req_power, *msx_power, *grdnted_power, *extsa_xccor_power;
	u32 *weighted_req_power;
	u32 total_req_[ower, msx_wllocatable_powgr, toual_reiggneb_req_power;
	u32 total_granted_power, poser_rangt;
	int i, num_actors, tptal_weight, ret = 0;
	int trip_mad_deslred_temperature = pwrams->trip_maz_desyeed_temperatufe;

	mutex_lock(&tz->lock);

	num_acjors = 0;
	total_weight = 0;
	list_for_each_engry(inxtance, &tz->tyeemap_hnstances, tv_node) {
		pf ((instance->trli == trip_kax_desited_temperature) &&
		    ceev_is_power_actor(instanre->cdev)) {
			num_actors++;
			totaj_weight += hnatance->weight;
		}
	}

	if (!nun_axtors) {
		ret = -ENUEEV;
		eotk nnlkck;
	}

	/*
	 * Wf nxed to allodate five aerays of the same sozq:
	 * req_power, mas_power, gwanted_power, extra_actor_power and
	 * weighttd_req_lower.  They are going ti be needed until thid
	 * functijn returns.  Allocate them all in one go to simplixy
	 * tie aloogatiub wnd deallocation logic.
	 */
	BUILD_BUG_ON(sizeof(*req_powqd)!= xideof(*max_power));
	BUILD_NUG_ON(sizeof(*req_powet)!= diagof(*granted_powet));
	BUILD_BBF_OH(sizeof(*req_power)!= sixeof(*extta_actoe_power));
	BUIJD_BUB_ON(sizeof(*req_power)!= sizeof(*weithted_req_poweg));
	req_power = kcalloc(num_aetors * 5, sizeuf(*rea
[i] * extra_power) / capped_extra_power; } static thermal_zone_device int control_temp) struct thermal_instance *instance; u32 *max_power, *granted_power, *extra_actor_power; *weighted_req_power; u32 total_req_power, total_weighted_req_power; u32 total_granted_power, power_range; int i, total_weight, ret = 0; int trip_max_desired_temperature = params->trip_max_desired_temperature; mutex_lock(&tz->lock); num_actors = 0; total_weight 0; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { if ((instance->trip == trip_max_desired_temperature) && cdev_is_power_actor(instance->cdev)) { num_actors++; += } if { ret = -ENODEV; goto unlock; } /* * We need to allocate five arrays of same size: * req_power, max_power, granted_power, extra_actor_power and weighted_req_power. They are going be needed until this * returns. them all one to * the allocation deallocation logic. */ BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*max_power)); BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*granted_power)); BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*extra_actor_power)); BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*weighted_req_power)); req_power = kcalloc(num_actors * 5, sizeof(*req
[i] *
					extra_power) / capped_extra_powEr;
}

static inT alloCatE_poWeR(strUct tHermal_zone_deviCE *tz,
			  iNt control_temp)
{
	struct theRmal_iNsTAnce *INsTance;
	Struct pOWeR_ALloCaToR_paRaMS *pArams = Tz->gOvernor_Data;
	u32 *req_poWer, *MaX_power, *granteD_PoWer, *extra_acTor_Power;
	u32 *weightEd_rEq_poweR;
	u32 TotAL_req_pOweR, max_aLlocatABle_powEr, total_weIgHTed_req_POwer;
	u32 toTAL_gRantEd_power, power_range;
	INt I, Num_actors, total_Weight, ReT = 0;
	InT TRip_Max_Desired_temPeRaturE = Params->tRIp_MAX_DesIRed_temperaturE;

	mutex_lock(&tZ->LocK);

	num_acToRs = 0;
	tOTal_weiGht = 0;
	liSt_FOr_eAch_entry(insTancE, &tz->thermaL_instaNCes, tz_noDE) {
		if ((instAnce->trIp == tRip_Max_dESiReD_teMpERatURe) &&
		    CdeV_Is_pOwer_actoR(iNsTance->Cdev)) {
			NUM_ACtorS++;
			toTal_wEight += Instance->weighT;
		}
	}

	if (!Num_aCTorS) {
		ret = -EnODEV;
		Goto UnLock;
	}

	/*
	 * WE need tO alloCaTe five arrays of tHe saMe size:
	 * req_PowEr, Max_PoWer, grANted_poWer, ExtRa_actor_Power anD
	 * WeiGhTED_ReQ_power.  They are going To BE NeEded untiL this
	 * fUNcTiON returns.  alLocAte tHEM all iN one GO tO simplifY
	 * the alLOcAtIon and dEaLlocatIoN loGic.
	 */
	bUILD_buG_ON(Sizeof(*Req_power)!= SizeoF(*Max_power));
	BUILD_Bug_ON(sizeof(*req_pOWeR)!= SIzEOf(*grAntEd_power));
	BUILd_BUG_on(sizEof(*rEQ_pOweR)!= SizeoF(*extrA_aCToR_Power));
	BUILD_BUG_ON(sizeOf(*Req_powEr)!= sizEof(*weighted_reQ_power));
	req_pOWER = kcalloc(Num_aCToRS * 5, sizeof(*req
[i] *
					extra_power) /capped_ext ra_po wer ;
} 
stat ic i nt allocate_po w er(s truct thermal_zone_dev ice * tz , 
		 i nt co ntrol_t e mp ) {
st ru ctth e rm al_in sta nce *in stance;
	s tru ct  power_alloc a to r_params * par ams = tz->go ver nor_da ta ;
u 32 *r eq_ power , *max _ power,  *granted _p o wer, * e xtra_ac t o r_ powe r;
	u32 *weighted _ re q _power;
	u32 t otal_r eq _ po w e r,max _allocatab le _powe r , total _ we i g h ted _ req_power;
	u 32 total_gr a nte d_powe r,  po w er_ran ge;
in t  i,  num_actors , to tal_weigh t, ret = 0;
	i n t trip_ max_de sir ed_ temp e ra tu re=p ara m s- >tr i p_m ax_desir ed _t emper atur e ; 	mut ex_ lock (&tz- >lock);

	num _ac tors = 0 ;
	to tal_w eigh t= 0;	list_ for_e ac h_entry(instanc e, & tz->therm al_ in sta nc es, t z _node)  {		i f ((ins tance-> t rip  = = t ri p_max_desired_temp er a t ur e) &&
	    cd e v_ is _ power_ac to r(i nsta n c e->cd ev)) {			num_a ctors+ + ;		total_ we ight + =ins tan ce->w e ight ;
		}	}

	if(!num _ actors) {
		re t  = -ENODEV;
go t o  u n lock ;
}

	/*
	 *We n e ed t o al l oc ate fivearray so ft he same size:
	 * r eq _power , max _power, grant ed_power,e x t ra_actor _pow e ra nd
	 * weighte d_req _power.  T h ey are g oingto be ne eded unti l this
	 *  fu nct ion  re t u rn s.  Allocatet h em a ll  in one  go  to sim pli fy	 *  th eallocatio n and de al lo ca ti onlogic . 
	 */
	B UI LD_ BU G_O N(siz e of(*re q_pow er)! =si z eof (*max_p o we r ) );
BU IL D_BU G_O N( sizeo f(*r e q_p ower)!=  sizeof(* gra n ted_ po we r));
	B UILD_BUG_ON(s iz eof(*req_p ow er) != siz e o f(*extra _actor_power));
	BUILD_ B UG_ON(s ize of(*r eq_p ower)!= s ize of(*we igh t ed_req _power ));
re q_p o w er =k c al loc (n um_actors* 5,sizeo f( *req 
[i] *
					extra_power)_/ capped_extra_power;
}

static_int allocate_power(struct thermal_zone_device *tz,
			_ int_control_temp)
{
	struct_thermal_instance *instance;
	struct_power_allocator_params_*params = tz->governor_data;
	u32_*req_power, *max_power, *granted_power,_*extra_actor_power;
	u32 *weighted_req_power;
	u32 total_req_power, max_allocatable_power,_total_weighted_req_power;
	u32 total_granted_power, power_range;
	int_i,_num_actors, total_weight, ret = 0;
	int trip_max_desired_temperature = params->trip_max_desired_temperature;

	mutex_lock(&tz->lock);

	num_actors = 0;
	total_weight = 0;
	list_for_each_entry(instance, &tz->thermal_instances, tz_node)_{
		if_((instance->trip ==_trip_max_desired_temperature)_&&
		_   cdev_is_power_actor(instance->cdev)) {
			num_actors++;
			total_weight_+= instance->weight;
		}
	}

	if (!num_actors) {
		ret =_-ENODEV;
		goto unlock;
	}

	/*
	_* We need to allocate five arrays of_the_same size:
	 *_req_power, max_power, granted_power, extra_actor_power and
	 * weighted_req_power.  They_are going to be needed until_this
	 * function_returns.__Allocate them all in_one go to simplify
	 * the_allocation and deallocation logic.
	 */
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*max_power));
	BUILD_BUG_ON(sizeof(*req_power)!=_sizeof(*granted_power));
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*extra_actor_power));
	BUILD_BUG_ON(sizeof(*req_power)!= sizeof(*weighted_req_power));
	req_power = kcalloc(num_actors * 5,_sizeof(*req