public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@infradead.org>
To: dpervushin@embeddedalley.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] [UBI] [1/3] ubi notifications API
Date: Thu, 07 May 2009 09:14:47 +0300	[thread overview]
Message-ID: <1241676887.27996.12.camel@localhost.localdomain> (raw)
In-Reply-To: <1241018978.20184.33.camel@hp.diimka.lan>

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 (Битюцкий Артём)

  parent reply	other threads:[~2009-05-07  6:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29 15:29 [PATCH] [UBI] [1/3] ubi notifications API dmitry pervushin
2009-05-06  6:31 ` Artem Bityutskiy
2009-05-07  6:14 ` Artem Bityutskiy [this message]
2009-05-18  8:05 ` Artem Bityutskiy
2009-05-18 15:22 ` Artem Bityutskiy
2009-05-18 15:26   ` [PATCH] UBI: add notification API Artem Bityutskiy
2009-05-18 15:28     ` [PATCH] UBI: remove built-in gluebi Artem Bityutskiy
2009-05-18 15:39   ` [PATCH] [UBI] [1/3] ubi notifications API Artem Bityutskiy
2009-05-29 19:27     ` [PATCH] 3/3 ubi notification API " dmitry pervushin
2009-05-31 13:52       ` Artem Bityutskiy
2009-05-31 14:32         ` [PATCH] 3/3 ubi notification API (was Re: [PATCH] [UBI] [1/3] ubi notifications API) dmitry pervushin
2009-06-01 16:48           ` Artem Bityutskiy
2009-06-01 17:07             ` dmitry pervushin
2009-06-02  6:40               ` Artem Bityutskiy
2009-05-31 14:06       ` [PATCH] 3/3 ubi notification API Re: [PATCH] [UBI] [1/3] ubi notifications API Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1241676887.27996.12.camel@localhost.localdomain \
    --to=dedekind@infradead.org \
    --cc=dpervushin@embeddedalley.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox