From patchwork Fri Jan 22 15:33:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 43485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4CEC1B7CB6 for ; Sat, 23 Jan 2010 02:37:09 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NYLW1-0000VX-Nx; Fri, 22 Jan 2010 15:33:41 +0000 Received: from fg-out-1718.google.com ([72.14.220.153]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NYLVv-0000Sx-B0 for linux-mtd@lists.infradead.org; Fri, 22 Jan 2010 15:33:39 +0000 Received: by fg-out-1718.google.com with SMTP id 22so53890fge.0 for ; Fri, 22 Jan 2010 07:33:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=LLQDpK3NUN9k+GB6S+x3SiOJO0BrrdT/0YkJelZr4Dc=; b=OJxOHAv3NsJAeca6Q5KZQ8bOOPAitqupslDwGVxi8+XeCP3gDBS8LnB/BqwlQk9ar2 9nCkVHnqS5y4iHHv93lJUEpe8ZW8Qb/S2EckYxTxU1eUbItJztPaTx/J3NQeYfzQG/Dv Zp3Ep6HG4s5KiqGOEvxsaJE5PBjcthvEbtsm8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=GryUA/ZsDs3I59TgkJS7uLwneaUQr7oWnvQCF7tPK19VJoez3oRHzPpDEkU+g8gJwN 5hKbkP+Pz4cBCwWdgmL2RsSW9dwcSQaYoH0s6NAW3PIA56gTzWLxKsxp6tCl1T439oQZ Mwb/VqThbfLym0H/8MMdYazIfDdk6gXAx9ut0= Received: by 10.87.36.4 with SMTP id o4mr343796fgj.69.1264174412134; Fri, 22 Jan 2010 07:33:32 -0800 (PST) Received: from ?10.1.0.2? ([87.70.246.165]) by mx.google.com with ESMTPS id e11sm6222185fga.14.2010.01.22.07.33.29 (version=SSLv3 cipher=RC4-MD5); Fri, 22 Jan 2010 07:33:31 -0800 (PST) Subject: [PATCH 1/4] MTD: call remove notifiers before removing the device From: Maxim Levitsky To: David Woodhouse In-Reply-To: <1264174316.24012.17.camel@maxim-laptop> References: <1264174316.24012.17.camel@maxim-laptop> Date: Fri, 22 Jan 2010 17:33:27 +0200 Message-ID: <1264174407.24012.19.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100122_103335_485583_778BC01F X-CRM114-Status: GOOD ( 17.11 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: Thomas Gleixner , joern , linux-mtd , linux-kernel , Alex Dubov X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org >From e74bb4a1e1222ec35fa8ed0d0d40b8e3607992d8 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Fri, 22 Jan 2010 15:00:53 +0200 Subject: [PATCH 1/4] MTD: call remove notifiers before removing the device This is first step in implementing proper hotplug support. Now all users of the mtd device have a chance to put the mtd device when they are notified to do so, and they have to do so to make hotplug work. Signed-off-by: Maxim Levitsky --- drivers/mtd/mtdcore.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index c356c0a..87ff83f 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -341,31 +341,32 @@ int add_mtd_device(struct mtd_info *mtd) int del_mtd_device (struct mtd_info *mtd) { int ret; + struct mtd_notifier *not; mutex_lock(&mtd_table_mutex); if (mtd_table[mtd->index] != mtd) { ret = -ENODEV; - } else if (mtd->usecount) { + goto out_error; + } + + /* No need to get a refcount on the module containing + the notifier, since we hold the mtd_table_mutex */ + list_for_each_entry(not, &mtd_notifiers, list) + not->remove(mtd); + + if (mtd->usecount) { printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", mtd->index, mtd->name, mtd->usecount); ret = -EBUSY; } else { - struct mtd_notifier *not; - device_unregister(&mtd->dev); - - /* No need to get a refcount on the module containing - the notifier, since we hold the mtd_table_mutex */ - list_for_each_entry(not, &mtd_notifiers, list) - not->remove(mtd); - mtd_table[mtd->index] = NULL; - module_put(THIS_MODULE); ret = 0; } +out_error: mutex_unlock(&mtd_table_mutex); return ret; }