From patchwork Fri Jan 8 15:05:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 42510 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 C154BB7C06 for ; Sat, 9 Jan 2010 02:07:54 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NTGPd-0007zD-4H; Fri, 08 Jan 2010 15:06:05 +0000 Received: from mail-fx0-f222.google.com ([209.85.220.222]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NTGPW-0007xD-Jr for linux-mtd@lists.infradead.org; Fri, 08 Jan 2010 15:06:03 +0000 Received: by fxm22 with SMTP id 22so21921513fxm.2 for ; Fri, 08 Jan 2010 07:05:57 -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=/0JW3ABfSFtwJtn0zP8eobpMJo982sUECQ/MsqGCXk8=; b=K9pDMaNFxeGQnyoqde79op+vz+Ut2Gi9MObyp3r1OcXRLIy0VmGIGN6WdTwpYPPH0l pGEN/Bf63m1P0XwSJoDVsN3zPtkcOKl0pVeIcfEc5Smwb7osMjGIkGdgYgJ38q7YoTkR nx8UI5CRx5uwIc9SiVnKVgrYEkucxCwyHOcXI= 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=NAyWXDS+eZpAGOc6OQ9UoySR8f7NMxPLuCqC1hgexzntdowqFJw9biN4bgGaFrANUI iRW1nTo9gxgjrG3cscerubdAAtL1OxfbJO1Tuw5qev0VnMOSQ/JlPZXIlmAZ5iPpf3M9 twNX8L/H8YB9p8K/zPlQUioWvvJYeF+18x3io= Received: by 10.223.164.96 with SMTP id d32mr1342911fay.106.1262963157916; Fri, 08 Jan 2010 07:05:57 -0800 (PST) Received: from ?10.1.0.2? (IGLD-84-228-118-133.inter.net.il [84.228.118.133]) by mx.google.com with ESMTPS id k29sm417783fkk.21.2010.01.08.07.05.56 (version=SSLv3 cipher=RC4-MD5); Fri, 08 Jan 2010 07:05:57 -0800 (PST) Subject: [PATCH 1/9] MTD: call remove notifiers before removing the device From: Maxim Levitsky To: linux-kernel In-Reply-To: <1262963092.12577.14.camel@maxim-laptop> References: <1262963092.12577.14.camel@maxim-laptop> Date: Fri, 08 Jan 2010 17:05:54 +0200 Message-ID: <1262963154.12577.15.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-20100108_100558_759323_B63AA979 X-CRM114-Status: GOOD ( 17.28 ) 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: joern , linux-mtd , 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 1855da2a21882c803e5dfcfb556fff5bc6989c31 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Fri, 8 Jan 2010 15:14:20 +0200 Subject: [PATCH 1/9] 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; }