From patchwork Sat Jun 11 23:11:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 100055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 64B82B705D for ; Sun, 12 Jun 2011 09:14:36 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QVXNa-00039x-QF; Sat, 11 Jun 2011 23:14:11 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QVXNa-0001Qo-85; Sat, 11 Jun 2011 23:14:10 +0000 Received: from mail-ew0-f49.google.com ([209.85.215.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QVXLs-00010O-NS for linux-mtd@lists.infradead.org; Sat, 11 Jun 2011 23:12:26 +0000 Received: by mail-ew0-f49.google.com with SMTP id 3so1527779ewy.36 for ; Sat, 11 Jun 2011 16:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=9TzjlsiMaVxoOP6WlgLOAMBE5IsW0nK+8h+wS5qeVV8=; b=qMoQ/Vs6TGaq7+lq4oTu1Y22ghM3Sj7m9ZT+vc3QjuM1KR+n4Cyr1qMf4sQn98vqh5 D7Ec4bjuYkD7XcWNP851IjtdDyJxHepMyaispTT7L8iCNg0dt0pHYJ+7iqAA5gXi4CXb lnqfa1Ris9fsxsJZNk0QjTm3llL1ubEOcFqlI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=w74cEAvhR2praSO0PpoUuBCJldKJutBS0lhQdsm5imAJlabzYRrRAQcoQuiysydlfF YPRtiwjoHn65oEG61AfsK+mQNMknZem/0nIfP90PIiE/pQ2x0RhOTp1uiOq5JbftJ6OW TTmXWLqMSz4gRHT8XkGx2ByZ0oNetVXsz4SF0= Received: by 10.213.2.73 with SMTP id 9mr500198ebi.62.1307833944293; Sat, 11 Jun 2011 16:12:24 -0700 (PDT) Received: from doriath.lumag.dynalias.net (ppp89-110-7-240.pppoe.avangarddsl.ru [89.110.7.240]) by mx.google.com with ESMTPS id y6sm3745991eem.4.2011.06.11.16.12.22 (version=SSLv3 cipher=OTHER); Sat, 11 Jun 2011 16:12:23 -0700 (PDT) From: Dmitry Eremin-Solenikov To: linux-mtd@lists.infradead.org Subject: [PATCH 13/18] mtd: m25p80.c: use mtd_device_parse_register Date: Sun, 12 Jun 2011 03:11:57 +0400 Message-Id: <1307833922-21602-14-git-send-email-dbaryshkov@gmail.com> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1307833922-21602-1-git-send-email-dbaryshkov@gmail.com> References: <1307833922-21602-1-git-send-email-dbaryshkov@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110611_191225_094530_63604DA3 X-CRM114-Status: GOOD ( 13.70 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dbaryshkov[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: David Woodhouse , dedekind1@gmail.com 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 Replace custom invocations of parse_mtd_partitions and mtd_device_register with common mtd_device_parse_register call. This would bring: standard handling of all errors, fallback to default partitions, etc. Signed-off-by: Dmitry Eremin-Solenikov --- drivers/mtd/devices/m25p80.c | 28 +++------------------------- 1 files changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 399c234..66a3555 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -88,7 +88,6 @@ struct m25p { struct spi_device *spi; struct mutex lock; struct mtd_info mtd; - unsigned partitioned:1; u16 page_size; u16 addr_width; u8 erase_opcode; @@ -825,8 +824,6 @@ static int __devinit m25p_probe(struct spi_device *spi) struct m25p *flash; struct flash_info *info; unsigned i; - struct mtd_partition *parts = NULL; - int nr_parts = 0; struct mtd_part_parser_data ppdata; /* Platform data helps sort out which chip type we have, as @@ -970,28 +967,9 @@ static int __devinit m25p_probe(struct spi_device *spi) /* partitions should match sector boundaries; and it may be good to * use readonly partitions for writeprotected sectors (BP2..BP0). */ - nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, &ppdata); - - if (nr_parts <= 0 && data && data->parts) { - parts = data->parts; - nr_parts = data->nr_parts; - } - - if (nr_parts > 0) { - for (i = 0; i < nr_parts; i++) { - DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " - "{.name = %s, .offset = 0x%llx, " - ".size = 0x%llx (%lldKiB) }\n", - i, parts[i].name, - (long long)parts[i].offset, - (long long)parts[i].size, - (long long)(parts[i].size >> 10)); - } - flash->partitioned = 1; - } - - return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ? - -ENODEV : 0; + return mtd_device_parse_register(&flash->mtd, NULL, &ppdata, + data ? data->parts : NULL, + data ? data->nr_parts : 0); }