From patchwork Tue Feb 10 22:58:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Ehrenberg X-Patchwork-Id: 438599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C124714018C for ; Wed, 11 Feb 2015 10:25:06 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLK9m-0005VZ-Fn; Tue, 10 Feb 2015 23:23:50 +0000 Received: from mail-ie0-f181.google.com ([209.85.223.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLK9k-0005Qx-Au for linux-mtd@lists.infradead.org; Tue, 10 Feb 2015 23:23:48 +0000 Received: by iebtr6 with SMTP id tr6so180107ieb.2 for ; Tue, 10 Feb 2015 15:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=B5PpRQMfBTEODwIWd5oh88aadEU+JKV4I60ez2zk8Pg=; b=d+dglxYvgwxq6HIc+YSFlK0uSTdaqIYQndiKu2aduELduvFj4btRlRnWpUgsf0fwRc X7KDLOJpBJI5QL+I06osyTkNRHyzwjiBdqh6iMv1RLTfwHwEB7yNci+rUAExBGQojdms wmtiawCr79ZdRSB2jlidgE6Vzrrw1jqpYqi6s38pzguWxOpg3WHHYpdQ+cE9NxFqp0I0 5qYnE6lkwqdlqmQHSaASXhSs/klibEGZqCuvF46+Gl82jQClRO/31IZSpxoqVo2mbH94 O2zLwOJl3e3T5PRlyd0sEPCyK40BMtZsiLBYazOVvclfMEjsw9YDaiuCzg6ugIVz2qWj FVcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=B5PpRQMfBTEODwIWd5oh88aadEU+JKV4I60ez2zk8Pg=; b=UEnwDc6AZFbRvxjFOZO5CWR+f6oRA3Wf1QdwG9FDmGweXTvvXWdXXRqlPncuxScPxq Xc/GoDubj46ubTRFaz50ImQUS4nXclbIxl7gKIg46y2fijjOOk6rh90ISRhgEaQ7eR3P kp579RtYi9Zs7+oHKGp3MH/48q+HVWMn/6FtdA8IYDyBltW5T7QdwMMbMM93jbnttEYy 9YAtJaJwyv6Ehnlo0nvJKyc6UBgKuOoZrxN7LIVKyuN+laez3snFD0oYAxAmUlUSgHgX 0TEQ4OEUiJJyXxwr2uGsLyl5opE5jAjgGCuVpHp3UackXnPHS7rREQR00xVajJUd5tSU xtRg== X-Gm-Message-State: ALoCoQnSq1G+YFcGogIpRx1OD8FOxECmLwAVQ7OadblO1IA7OPZ6lUDfDGIFeisCUSNXFtc53nL4 X-Received: by 10.107.8.213 with SMTP id h82mr623235ioi.89.1423609153150; Tue, 10 Feb 2015 14:59:13 -0800 (PST) Received: from dehrenberg.mtv.corp.google.com ([172.22.65.87]) by mx.google.com with ESMTPSA id g11sm9498102iod.28.2015.02.10.14.59.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Feb 2015 14:59:12 -0800 (PST) From: Dan Ehrenberg To: linux-mtd@lists.infradead.org, richard.weinberger@gmail.com, ezequiel.garcia@imgtec.com Subject: [PATCH v2 3/3] mtdpart: Allow deleting a partition with another partition as master Date: Tue, 10 Feb 2015 14:58:58 -0800 Message-Id: <1423609138-19321-3-git-send-email-dehrenberg@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1423609138-19321-1-git-send-email-dehrenberg@chromium.org> References: <1423609138-19321-1-git-send-email-dehrenberg@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150210_152348_421397_5DE0808F X-CRM114-Status: GOOD ( 10.74 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.181 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.223.181 listed in wl.mailspike.net] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Cc: namnguyen@chromium.org, grundler@chromium.org, gwendal@chromium.org, Dan Ehrenberg X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch makes MTD dynamic partitioning more flexible by allowing partitions to be deleted by referencing any partition with the same master. For example, if you have /dev/mtd0 and /dev/mtd1 both partitions on the same underlying device, then you can call BLKPG_DEL_PARTITION with an fd of /dev/mtd0 and pno of 1, and /dev/mtd1 will be deleted (as opposed to returning EINVAL to signal a missing partition, which it did previously). Signed-off-by: Dan Ehrenberg --- drivers/mtd/mtdpart.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 7eb9083..7874bbd 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -600,6 +600,15 @@ int mtd_del_partition(struct mtd_info *master, int partno) struct mtd_part *slave, *next; int ret = -EINVAL; + /* If del_partition was called as a partition, just treat + * this as if it were called on its master. This is a harmless + * generalization and lets partitions be deleted in a system + * where they are sometimes already present on boot */ + if (mtd_is_partition(master)) { + struct mtd_part *master_partition = PART(master); + master = master_partition->master; + } + mutex_lock(&mtd_partitions_mutex); list_for_each_entry_safe(slave, next, &mtd_partitions, list) if ((slave->master == master) &&