[PATCH] [UBI] [1/3] ubi notifications API
Artem Bityutskiy
dedekind at infradead.org
Thu May 7 02:14:47 EDT 2009
On Wed, 2009-04-29 at 19:29 +0400, dmitry pervushin wrote:
> +/**
> + * ubi_enum_all_volumes - enumerate all existing volumes and send notification.
> + * @ntype: notification type to send (%UBI_VOLUME_ADDED, etc)
> + * @nb: notifier to be called, or %NULL to send to system-wide notification
> + *
> + * This function walks all UBI devices and all volumes on the device, and sends
> + * the notification specified by @ntype. Returns number of sent notifications.
> + */
> +int ubi_enum_all_volumes(int ntype, struct notifier_block *nb)
> +{
> + struct ubi_device *ubi;
> + int i, count = 0;
> +
> + spin_lock(&ubi_devices_lock);
> + for (i = 0; i < UBI_MAX_DEVICES; i++) {
> + ubi = ubi_devices[i];
> + if (!ubi)
> + continue;
> + ubi->ref_count += 1;
> + get_device(&ubi->dev);
> + spin_unlock(&ubi_devices_lock);
> + count += ubi_enum_volumes(ntype, ubi, nb);
> + spin_lock(&ubi_devices_lock);
> + put_device(&ubi->dev);
> + ubi->ref_count -= 1;
> + }
> + spin_unlock(&ubi_devices_lock);
> + return count;
> +}
OK. For this we have ubi_devices_mutex. If you take it,
you prevent UBI devices from being created/removed. So
you do not need the references here, just take the mutex.
Something similar should be done for volume, I'm looking
at this.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
More information about the linux-mtd
mailing list