From patchwork Mon Sep 27 15:04:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Wen X-Patchwork-Id: 65875 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 764A1B70D0 for ; Tue, 28 Sep 2010 01:00:27 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1P0FAI-0005K9-9r; Mon, 27 Sep 2010 14:58:50 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1P0FAE-0005Ho-Qu for linux-mtd@lists.infradead.org; Mon, 27 Sep 2010 14:58:47 +0000 X-ASG-Debug-ID: 1285599523-081b99250001-6YE7NY Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id dzRdt4wU4l9PPCUw; Mon, 27 Sep 2010 07:58:43 -0700 (PDT) X-Barracuda-Envelope-From: leiwen@marvell.com Received: from localhost (unknown [10.38.164.83]) by maili.marvell.com (Postfix) with ESMTP id BCB3A8A001; Mon, 27 Sep 2010 07:58:43 -0700 (PDT) From: Lei Wen To: roman.tereshonkov@nokia.com, dwmw2@infradead.org, dedekind1@gmail.com, linux-mtd@lists.infradead.org, adrian.wenl@gmail.com X-ASG-Orig-Subj: [PATCH] mtd: add get offset and size function for partition query Subject: [PATCH] mtd: add get offset and size function for partition query Date: Mon, 27 Sep 2010 23:04:44 +0800 X-ASG-Orig-Subj: [PATCH] mtd: add get offset and size function for partition query Message-Id: <1285599884-18312-1-git-send-email-leiwen@marvell.com> X-Mailer: git-send-email 1.7.0.4 X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1285599523 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100927_105847_080992_89CA3DD3 X-CRM114-Status: GOOD ( 14.97 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 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: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Since we add add_mtd_partitions and mtd_del_partition kenrel api to facilitate the mtd repartition job. It would be nice to add another two api to know the offset and size of each partition. Signed-off-by: Lei Wen --- drivers/mtd/mtdpart.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/mtd/partitions.h | 2 ++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 726c287..4548168 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -655,6 +655,42 @@ int add_mtd_partitions(struct mtd_info *master, } EXPORT_SYMBOL(add_mtd_partitions); +uint64_t get_mtd_offset(struct mtd_info *master, int partno) +{ + struct mtd_part *slave, *next; + uint64_t ret = ULLONG_MAX; + + mutex_lock(&mtd_partitions_mutex); + list_for_each_entry_safe(slave, next, &mtd_partitions, list) + if ((slave->master == master) && + (slave->mtd.index == partno)) { + ret = slave->offset; + break; + } + mutex_unlock(&mtd_partitions_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(get_mtd_offset); + +uint64_t get_mtd_size(struct mtd_info *master, int partno) +{ + struct mtd_part *slave, *next; + uint64_t ret = ULLONG_MAX; + + mutex_lock(&mtd_partitions_mutex); + list_for_each_entry_safe(slave, next, &mtd_partitions, list) + if ((slave->master == master) && + (slave->mtd.index == partno)) { + ret = slave->mtd.size; + break; + } + mutex_unlock(&mtd_partitions_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(get_mtd_size); + static DEFINE_SPINLOCK(part_parser_lock); static LIST_HEAD(part_parsers); diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index ffab9a6..03333ec 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h @@ -93,5 +93,7 @@ int mtd_is_master(struct mtd_info *mtd); int mtd_add_partition(struct mtd_info *master, char *name, long long offset, long long length); int mtd_del_partition(struct mtd_info *master, int partno); +uint64_t get_mtd_offset(struct mtd_info *master, int partno); +uint64_t get_mtd_size(struct mtd_info *master, int partno); #endif