lib/sw_apps/zynqmp_pmufw/src/pm_slave.c
s32 PmUpdateSlave(PmSlave* const slave)
{
	PmStateId state = 0U;
	s32 status = XST_SUCCESS;
	u32 wkupLat, minLat;
	u32 caps = PmGetMaxCapabilities(slave);

	if (0U != caps) {
		/* Find which state has the requested capabilities */
		status = PmGetStateWithCaps(slave, caps, &state);
		if (XST_SUCCESS != status) {
			goto done;
		}
	}

	minLat = PmGetMinRequestedLatency(slave);
	wkupLat = PmGetLatencyFromState(slave, state);
	if (wkupLat > minLat) {
		/* State does not satisfy latency requirement, find another */
		status = PmConstrainStateByLatency(slave, &state, caps, minLat);
		if (XST_SUCCESS != status) {
			goto done;
		}
		wkupLat = PmGetLatencyFromState(slave, state);
	}

	slave->node.latencyMarg = minLat - wkupLat;
	if (state != slave->node.currState) {
		status = PmSlaveChangeState(slave, state);
		if (XST_SUCCESS != status) {
			goto done;
		}
	} else {
		if (!HAS_CAPABILITIES(slave, state, PM_CAP_POWER) &&
		    (NULL != slave->node.parent)) {
			/* Notify power parent (changed latency requirement) */
			status = PmPowerUpdateLatencyReq(&slave->node);
		}
	}

done:
	return status;
}
/**
 * PmUpdateSlave() - Update the slave's state according to the current
 *                   requirements from all masters
 * @slave       Slave whose state is about to be updated
 *
 * @return      Status of operation of updating slave's state.
 *
 * @note	A slave may not have state with zero capabilities. If that is
 * the case and no capabilities are requested, it is put in lowest power state
 * (state ID 0).
 * When non-zero capabilities are requested and a selected state which has the
 * requested capabilities doesn't satisfy the wake-up latency requirements, the
 * first higher power state which satisfies latency requirement and has the
 * requested capabilities is configured (in the worst case it's the highest
 * power state).
 */
Update the slave's state according to the current
requirements from all masters
@slave       Slave whose state is about to be updated

@return      Status of operation of updating slave's state.

@note        A slave may not have state with zero capabilities. If that is
the case and no capabilities are requested, it is put in lowest power state
(state ID 0).
When non-zero capabilities are requested and a selected state which has the
requested capabilities doesn't satisfy the wake-up latency requirements, the
first higher power state which satisfies latency requirement and has the
requested capabilities is configured (in the worst case it's the highest
power state).
Update the slave ' s state according to the current requirements from all masters @slave Slave whose state is about to be updated @return Status of operation of updating slave ' s state . @note A slave may not have state with zero capabilities . If that is the case and no capabilities are requested it is put in lowest power state ( state ID 0 ) . When non - zero capabilities are requested and a selected state which has the requested capabilities doesn ' t satisfy the wake - up latency requirements the first higher power state which satisfies latency requirement and has the requested capabilities is configured ( in the worst case it ' s the highest power state ) .
s32 PmUpdateSlave(PmSlave* const slave)
{
	PmStateId state = 0U;
	s32 status = XST_SUCCESS;
	u32 wkupLat, minLat;
	u32 caps = PmGetMaxCapabilities(slave);
	if (0U != caps) {
		status = PmGetStateWithCaps(slave, caps, &state);
		if (XST_SUCCESS != status) {
			goto done;
		}
	}
	minLat = PmGetMinRequestedLatency(slave);
	wkupLat = PmGetLatencyFromState(slave, state);
	if (wkupLat > minLat) {
		status = PmConstrainStateByLatency(slave, &state, caps, minLat);
		if (XST_SUCCESS != status) {
			goto done;
		}
		wkupLat = PmGetLatencyFromState(slave, state);
	}
	slave->node.latencyMarg = minLat - wkupLat;
	if (state != slave->node.currState) {
		status = PmSlaveChangeState(slave, state);
		if (XST_SUCCESS != status) {
			goto done;
		}
	} else {
		if (!HAS_CAPABILITIES(slave, state, PM_CAP_POWER) &&
		    (NULL != slave->node.parent)) {
			status = PmPowerUpdateLatencyReq(&slave->node);
		}
	}
done:
	return status;
}
s32 PmUpdateSlave ( PmSlave * const slave ) { PmStateId state = 0U ; s32 status = XST_SUCCESS ; u32 wkupLat , minLat ; u32 caps = PmGetMaxCapabilities ( slave ) ; if ( 0U != caps ) { status = PmGetStateWithCaps ( slave , caps , & state ) ; if ( XST_SUCCESS != status ) { goto done ; } } minLat = PmGetMinRequestedLatency ( slave ) ; wkupLat = PmGetLatencyFromState ( slave , state ) ; if ( wkupLat > minLat ) { status = PmConstrainStateByLatency ( slave , & state , caps , minLat ) ; if ( XST_SUCCESS != status ) { goto done ; } wkupLat = PmGetLatencyFromState ( slave , state ) ; } slave -> node . latencyMarg = minLat - wkupLat ; if ( state != slave -> node . currState ) { status = PmSlaveChangeState ( slave , state ) ; if ( XST_SUCCESS != status ) { goto done ; } } else { if ( ! HAS_CAPABILITIES ( slave , state , PM_CAP_POWER ) && ( NULL != slave -> node . parent ) ) { status = PmPowerUpdateLatencyReq ( & slave -> node ) ; } } done : return status ; }
PmUpdateSlave() - Update the slave's state according to the current
                   requirements from all masters
 @slave       Slave whose state is about to be updated
PmUpdateSlave () - Update the slave ' s state according to the current requirements from all masters @slave Slave whose state is about to be updated
/* Find which state has the requested capabilities */ /* State does not satisfy latency requirement, find another */ /* Notify power parent (changed latency requirement) */