diff mbox

mtd: unable to unregister device

Message ID CAOMZO5Cm=-kNAccOgHAV=+yZW3cbE8oKeVbA1xN=vap+Bvi0Rw@mail.gmail.com
State RFC
Headers show

Commit Message

Fabio Estevam Dec. 5, 2014, 8:36 p.m. UTC
On Fri, Dec 5, 2014 at 1:55 PM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi,
>
> Running top of head linus tree or linux-next I observe the following issue:
>
> fsl-quadspi is autloaded as a kernel module:
>
> [    9.670508] fsl-quadspi 21e4000.qspi: s25fl128s (16384 Kbytes)
> [    9.763432] fsl-quadspi 21e4000.qspi: s25fl128s (16384 Kbytes)
> [    9.847063] fsl-quadspi 21e4000.qspi: QuadSPI SPI NOR flash driver
>
> root@freescale /$ cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 01000000 00010000 "21e4000.qspi"
> mtd1: 01000000 00010000 "21e4000.qspi"
>
> root@freescale /$ rmmod  fsl-quadspi
> root@freescale /$ cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 00000000 00000000 "(null)"
> mtd0: 00000000 00000000 "(null)"
> mtd0: 00000000 00000000 "(null)"

If I change it like this:


Then rmmod works as expected:

root@freescale /$ rmmod fsl-quadspi
root@freescale /$ cat /proc/mtd
dev:    size   erasesize  name
diff mbox

Patch

--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -960,7 +960,7 @@  static int fsl_qspi_remove(struct platform_device *pdev)
        struct fsl_qspi *q = platform_get_drvdata(pdev);
        int i;

-       for (i = 0; i < q->nor_num; i++)
+       for (i = 0; i < FSL_QSPI_MAX_CHIP; i++)
                mtd_device_unregister(&q->mtd[i]);

        /* disable the hardware */