lib/sw_apps/zynqmp_pmufw/src/pm_notifier.c
s32 PmNotifierRegister(const PmMaster* const mst, const PmNode* const nd,
		       const u32 event, const u32 wake)
{
	s32 status = XST_FAILURE;
	u32 i, empty = ARRAY_SIZE(pmNotifiers); /* init just to exceed max */

	for (i = 0U; i < ARRAY_SIZE(pmNotifiers); i++) {
		if (NULL == pmNotifiers[i].master) {
			/* Empty entry found in pmNotifiers array */
			if (ARRAY_SIZE(pmNotifiers) == empty) {
				/* Remember only first found empty entry */
				empty = i;
				status = XST_SUCCESS;
			}
			continue;
		}
		if ((mst == pmNotifiers[i].master) &&
		    (nd == pmNotifiers[i].node)) {
			/* Reuse existing entry for master/node pair */
			PmRegisterEvent(i, event, wake);
			/* Drop empty value - done with registration */
			empty = ARRAY_SIZE(pmNotifiers);
			status = XST_SUCCESS;
			break;
		}
	}
	if (XST_SUCCESS != status) {
		/* There is no free entry in pmNotifiers array, report error */
		goto done;
	}
	if (ARRAY_SIZE(pmNotifiers) != empty) {
		/* Empty entry should be filled with registration info */
		pmNotifiers[empty].master = mst;
		pmNotifiers[empty].node = nd;
		PmRegisterEvent(empty, event, wake);
	}

done:
	return status;
}
/**
 * PmNotifierRegister() - Register notifier for given master, node and event
 * @mst         Master to be notified
 * @nd          Node related to event
 * @event       Event to be notified about
 * @wake        Flag specifying whether the master should be woken upin order
 *              to be notified (if it is sleeping when the event happens)
 *
 * @return      Status of registration
 *              - XST_FAILURE - notifier is not registered as all entries in
 *                pmNotifiers array are occupied
 *              - XST_SUCCESS - notifier is successfully registered
 */
Register notifier for given master, node and event
@mst         Master to be notified
@nd          Node related to event
@event       Event to be notified about
@wake        Flag specifying whether the master should be woken upin order
to be notified (if it is sleeping when the event happens)

@return      Status of registration
- XST_FAILURE - notifier is not registered as all entries in
pmNotifiers array are occupied
- XST_SUCCESS - notifier is successfully registered
Register notifier for given master node and event @mst Master to be notified @nd Node related to event @event Event to be notified about @wake Flag specifying whether the master should be woken upin order to be notified ( if it is sleeping when the event happens ) @return Status of registration - XST_FAILURE - notifier is not registered as all entries in pmNotifiers array are occupied - XST_SUCCESS - notifier is successfully registered
s32 PmNotifierRegister(const PmMaster* const mst, const PmNode* const nd,
		       const u32 event, const u32 wake)
{
	s32 status = XST_FAILURE;
	u32 i, empty = ARRAY_SIZE(pmNotifiers); 
	for (i = 0U; i < ARRAY_SIZE(pmNotifiers); i++) {
		if (NULL == pmNotifiers[i].master) {
			if (ARRAY_SIZE(pmNotifiers) == empty) {
				empty = i;
				status = XST_SUCCESS;
			}
			continue;
		}
		if ((mst == pmNotifiers[i].master) &&
		    (nd == pmNotifiers[i].node)) {
			PmRegisterEvent(i, event, wake);
			empty = ARRAY_SIZE(pmNotifiers);
			status = XST_SUCCESS;
			break;
		}
	}
	if (XST_SUCCESS != status) {
		goto done;
	}
	if (ARRAY_SIZE(pmNotifiers) != empty) {
		pmNotifiers[empty].master = mst;
		pmNotifiers[empty].node = nd;
		PmRegisterEvent(empty, event, wake);
	}
done:
	return status;
}
s32 PmNotifierRegister ( const PmMaster * const mst , const PmNode * const nd , const u32 event , const u32 wake ) { s32 status = XST_FAILURE ; u32 i , empty = ARRAY_SIZE ( pmNotifiers ) ; for ( i = 0U ; i < ARRAY_SIZE ( pmNotifiers ) ; i ++ ) { if ( NULL == pmNotifiers [ i ] . master ) { if ( ARRAY_SIZE ( pmNotifiers ) == empty ) { empty = i ; status = XST_SUCCESS ; } continue ; } if ( ( mst == pmNotifiers [ i ] . master ) && ( nd == pmNotifiers [ i ] . node ) ) { PmRegisterEvent ( i , event , wake ) ; empty = ARRAY_SIZE ( pmNotifiers ) ; status = XST_SUCCESS ; break ; } } if ( XST_SUCCESS != status ) { goto done ; } if ( ARRAY_SIZE ( pmNotifiers ) != empty ) { pmNotifiers [ empty ] . master = mst ; pmNotifiers [ empty ] . node = nd ; PmRegisterEvent ( empty , event , wake ) ; } done : return status ; }
PmNotifierRegister() - Register notifier for given master, node and event
 @mst         Master to be notified
 @nd          Node related to event
 @event       Event to be notified about
 @wake        Flag specifying whether the master should be woken upin order
              to be notified (if it is sleeping when the event happens)
PmNotifierRegister () - Register notifier for given master node and event @mst Master to be notified @nd Node related to event @event Event to be notified about @wake Flag specifying whether the master should be woken upin order to be notified ( if it is sleeping when the event happens )
/* init just to exceed max */ /* Empty entry found in pmNotifiers array */ /* Remember only first found empty entry */ /* Reuse existing entry for master/node pair */ /* Drop empty value - done with registration */ /* There is no free entry in pmNotifiers array, report error */ /* Empty entry should be filled with registration info */