/* This function walks all volumes of UBI device @ubi and sends the @ntype notification for each volume. If @nb is NULL, then all registered notifiers are called, otherwise only the @nb notifier is called. Returns the number of sent notifications.  */
int ubi_notify_all(struct ubi_device *ubi, int ntype, struct notifier_block *nb)
/* This function walks all volumes of UBI device @ubi and sends the @ntype notification for each volume. If @nb is NULL, then all registered notifiers are called, otherwise only the @nb notifier is called. Returns the number of sent notifications.  */
int ubi_notify_all(struct ubi_device *ubi, int ntype, struct notifier_block *nb)
{
	struct ubi_notification nt;
	int i, count = 0;
	ubi_do_get_device_info(ubi, &nt.di);
	mutex_lock(&ubi->device_mutex);
	for (i = 0; i < ubi->vtbl_slots; i++) {
		if (!ubi->volumes[i])
			continue;
		ubi_do_get_volume_info(ubi, ubi->volumes[i], &nt.vi);
		if (nb)
			nb->notifier_call(nb, ntype, &nt);
		else
			blocking_notifier_call_chain(&ubi_notifiers, ntype,
						     &nt);
		count += 1;
	}
	mutex_unlock(&ubi->device_mutex);
	return count;
}