mirror of
https://github.com/torvalds/linux.git
synced 2026-04-21 08:13:56 -04:00
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Acked-by: Tudor Ambarus <tudor.ambarus@linaro.org> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> # atmel Reviewed-by: Paul Cercueil <paul@crapouillou.net> # ingenic Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> # ingenic Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # intel Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # meson Acked-by: Roger Quadros <rogerq@kernel.org> # omap_elm Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas Reviewed-by: Heiko Stuebner <heiko@sntech.de> # rockchip Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> # sunxi Acked-by: Thierry Reding <treding@nvidia.com> # tegra Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230411113816.3472237-1-u.kleine-koenig@pengutronix.de
80 lines
1.8 KiB
C
80 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* BCM47XX NAND flash driver
|
|
*
|
|
* Copyright (C) 2012 Rafał Miłecki <zajec5@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 void bcm47xxnflash_remove(struct platform_device *pdev)
|
|
{
|
|
struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
|
|
struct nand_chip *chip = &nflash->nand_chip;
|
|
int ret;
|
|
|
|
ret = mtd_device_unregister(nand_to_mtd(chip));
|
|
WARN_ON(ret);
|
|
nand_cleanup(chip);
|
|
}
|
|
|
|
static struct platform_driver bcm47xxnflash_driver = {
|
|
.probe = bcm47xxnflash_probe,
|
|
.remove_new = bcm47xxnflash_remove,
|
|
.driver = {
|
|
.name = "bcma_nflash",
|
|
},
|
|
};
|
|
|
|
module_platform_driver(bcm47xxnflash_driver);
|