Patchwork mtd: cafe_nand: register master MTD at most once

login
register
mail settings
Submitter Brian Norris
Date Aug. 2, 2011, 11:38 p.m.
Message ID <1312328310-18003-1-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/108008/
State New
Headers show

Comments

Brian Norris - Aug. 2, 2011, 11:38 p.m.
This patch addresses a regression where a master MTD object might be
registered twice if no partitions are found. The initial bug report can
be seen here:
    http://lists.infradead.org/pipermail/linux-mtd/2011-July/037086.html

The regression is caused by:
    commit 0f7451bea72c64d3f0a47850328d52f0315e2ea6
    "mtd: cafe_nand.c: use mtd_device_parse_register"

The aforementioned commit was intended to basically just refactor the
codebase; however, it had unintentional side effects. The cafe_nand probe
behavior over time is as follows.

Previous functionality (before commit 0f7451be):
 A) register the master device with add_mtd_device()
 B) if partitions are found, register them as well

New functionality (at commit 0f7451be):
 A) register the master device with add_mtd_device()
 B) if partitions are found, register them as well
 C) if partitions are not found, register the master device (again)

Correct functionality (this patch):
 (remove step A)
 B) if partitions are found, register them
 C) if partitions are not found, register the master device

Thus, this fix means that we will never register both the master MTD and
its partitions, as we did before commit 0f7451be. This is probably the
expected behavior and should be a welcome change.

Reported-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/cafe_nand.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
Artem Bityutskiy - Aug. 15, 2011, 3:31 p.m.
On Tue, 2011-08-02 at 16:38 -0700, Brian Norris wrote:
> This patch addresses a regression where a master MTD object might be
> registered twice if no partitions are found. The initial bug report can
> be seen here:
>     http://lists.infradead.org/pipermail/linux-mtd/2011-July/037086.html
> 
> The regression is caused by:
>     commit 0f7451bea72c64d3f0a47850328d52f0315e2ea6
>     "mtd: cafe_nand.c: use mtd_device_parse_register"

Thanks for the fix! For some reason David missed the last merge window
and did not merge the MTD stuff. So we still have a possibility to fix
the original commit, so I folded this into commit 0f7451bea.
Brian Norris - Aug. 15, 2011, 5:41 p.m.
On Mon, Aug 15, 2011 at 8:31 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> Thanks for the fix! For some reason David missed the last merge window
> and did not merge the MTD stuff. So we still have a possibility to fix
> the original commit, so I folded this into commit 0f7451bea.

OK, good.

Speaking of the folding, missing merge window, rebasing, etc., I think
you now have a commit in l2-mtd-2.6.git that refers to a hash that
doesn't exist in your tree anymore. For fear of continuing the trend
of having archived messages referring to holes in history, I will
simply list the name (not hash) of the commit whose description
probably should be edited:

"mtd: plat-nand: Fixup kerneldoc for struct platform_nand_chip"

Brian

Patch

diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 661e5dc..11a56df 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -797,9 +797,6 @@  static int __devinit cafe_nand_probe(struct pci_dev *pdev,
 
 	pci_set_drvdata(pdev, mtd);
 
-	/* We register the whole device first, separate from the partitions */
-	mtd_device_register(mtd, NULL, 0);
-
 	mtd->name = "cafe_nand";
 	mtd_device_parse_register(mtd, part_probes, 0, NULL, 0);