[OpenWrt-Devel] [PATCH 8/9] mtd: rawnand: bcm47xx: Merge all source files
Boris Brezillon
boris.brezillon at collabora.com
Sun Apr 19 08:51:39 EDT 2020
Given the number of lines it doesn't make them to split the code. Let's
merge everything in main.c and rename the file into bcm47xxnflash.c.
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
drivers/mtd/nand/raw/bcm47xxnflash/Makefile | 3 -
.../{ops_bcm4706.c => bcm47xxnflash.c} | 81 ++++++++++++++++++-
.../nand/raw/bcm47xxnflash/bcm47xxnflash.h | 21 -----
drivers/mtd/nand/raw/bcm47xxnflash/main.c | 77 ------------------
4 files changed, 78 insertions(+), 104 deletions(-)
rename drivers/mtd/nand/raw/bcm47xxnflash/{ops_bcm4706.c => bcm47xxnflash.c} (82%)
delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
delete mode 100644 drivers/mtd/nand/raw/bcm47xxnflash/main.c
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile b/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
index b531a630c9cf..71a953078799 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/Makefile
@@ -1,5 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-only
-bcm47xxnflash-y += main.o
-bcm47xxnflash-y += ops_bcm4706.o
-
obj-$(CONFIG_MTD_NAND_BCM47XXNFLASH) += bcm47xxnflash.o
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
similarity index 82%
rename from drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
rename to drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
index ab989de54cfc..ae0391c1ee28 100644
--- a/drivers/mtd/nand/raw/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.c
@@ -5,13 +5,14 @@
* Copyright (C) 2012 Rafał Miłecki <zajec5 at gmail.com>
*/
-#include "bcm47xxnflash.h"
-
+#include <linux/delay.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
-#include <linux/delay.h>
+#include <linux/platform_device.h>
#include <linux/bcma/bcma.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/rawnand.h>
/* Broadcom uses 1'000'000 but it seems to be too many. Tests on WNDR4500 has
* shown ~1000 retries as maxiumum. */
@@ -48,6 +49,17 @@
#define CONF_COL_BYTES(x) (((x) - 1) << 4)
#define CONF_ROW_BYTES(x) (((x) - 1) << 6)
+#ifndef pr_fmt
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#endif
+
+struct bcm47xxnflash {
+ struct nand_controller base;
+ struct bcma_drv_cc *cc;
+
+ struct nand_chip nand_chip;
+};
+
/**************************************************
* Various helpers
**************************************************/
@@ -276,3 +288,66 @@ int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n)
return err;
}
+
+static const char *probes[] = { "bcm47xxpart", NULL };
+
+static int bcm47xxnflash_probe(struct platform_device *pdev)
+{
+ struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
+ struct bcm47xxnflash *b47n;
+ struct mtd_info *mtd;
+ int err = 0;
+
+ b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
+ if (!b47n)
+ return -ENOMEM;
+
+ nand_set_controller_data(&b47n->nand_chip, b47n);
+ mtd = nand_to_mtd(&b47n->nand_chip);
+ mtd->dev.parent = &pdev->dev;
+ b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
+
+ if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
+ err = bcm47xxnflash_ops_bcm4706_init(b47n);
+ } else {
+ pr_err("Device not supported\n");
+ err = -ENOTSUPP;
+ }
+ if (err) {
+ pr_err("Initialization failed: %d\n", err);
+ return err;
+ }
+
+ platform_set_drvdata(pdev, b47n);
+
+ err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
+ if (err) {
+ pr_err("Failed to register MTD device: %d\n", err);
+ return err;
+ }
+
+ return 0;
+}
+
+static int bcm47xxnflash_remove(struct platform_device *pdev)
+{
+ struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
+
+ nand_release(&nflash->nand_chip);
+
+ return 0;
+}
+
+static struct platform_driver bcm47xxnflash_driver = {
+ .probe = bcm47xxnflash_probe,
+ .remove = bcm47xxnflash_remove,
+ .driver = {
+ .name = "bcma_nflash",
+ },
+};
+module_platform_driver(bcm47xxnflash_driver);
+
+MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Rafał Miłecki");
+
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h b/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
deleted file mode 100644
index 8de0e7e0a3a4..000000000000
--- a/drivers/mtd/nand/raw/bcm47xxnflash/bcm47xxnflash.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __BCM47XXNFLASH_H
-#define __BCM47XXNFLASH_H
-
-#ifndef pr_fmt
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#endif
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/rawnand.h>
-
-struct bcm47xxnflash {
- struct nand_controller base;
- struct bcma_drv_cc *cc;
-
- struct nand_chip nand_chip;
-};
-
-int bcm47xxnflash_ops_bcm4706_init(struct bcm47xxnflash *b47n);
-
-#endif /* BCM47XXNFLASH */
diff --git a/drivers/mtd/nand/raw/bcm47xxnflash/main.c b/drivers/mtd/nand/raw/bcm47xxnflash/main.c
deleted file mode 100644
index 8dae97c1dbe7..000000000000
--- a/drivers/mtd/nand/raw/bcm47xxnflash/main.c
+++ /dev/null
@@ -1,77 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * BCM47XX NAND flash driver
- *
- * Copyright (C) 2012 Rafał Miłecki <zajec5 at gmail.com>
- */
-
-#include "bcm47xxnflash.h"
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/platform_device.h>
-#include <linux/bcma/bcma.h>
-
-MODULE_DESCRIPTION("NAND flash driver for BCMA bus");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Rafał Miłecki");
-
-static const char *probes[] = { "bcm47xxpart", NULL };
-
-static int bcm47xxnflash_probe(struct platform_device *pdev)
-{
- struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
- struct bcm47xxnflash *b47n;
- struct mtd_info *mtd;
- int err = 0;
-
- b47n = devm_kzalloc(&pdev->dev, sizeof(*b47n), GFP_KERNEL);
- if (!b47n)
- return -ENOMEM;
-
- nand_set_controller_data(&b47n->nand_chip, b47n);
- mtd = nand_to_mtd(&b47n->nand_chip);
- mtd->dev.parent = &pdev->dev;
- b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
-
- if (b47n->cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
- err = bcm47xxnflash_ops_bcm4706_init(b47n);
- } else {
- pr_err("Device not supported\n");
- err = -ENOTSUPP;
- }
- if (err) {
- pr_err("Initialization failed: %d\n", err);
- return err;
- }
-
- platform_set_drvdata(pdev, b47n);
-
- err = mtd_device_parse_register(mtd, probes, NULL, NULL, 0);
- if (err) {
- pr_err("Failed to register MTD device: %d\n", err);
- return err;
- }
-
- return 0;
-}
-
-static int bcm47xxnflash_remove(struct platform_device *pdev)
-{
- struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
-
- nand_release(&nflash->nand_chip);
-
- return 0;
-}
-
-static struct platform_driver bcm47xxnflash_driver = {
- .probe = bcm47xxnflash_probe,
- .remove = bcm47xxnflash_remove,
- .driver = {
- .name = "bcma_nflash",
- },
-};
-
-module_platform_driver(bcm47xxnflash_driver);
--
2.25.2
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list