From: Fabio Estevam Date: Tue, 13 Jan 2015 22:14:15 +0000 (-0200) Subject: mtd: fsl-quadspi: Fix module unbound X-Git-Tag: omap-for-v4.1/prcm-dts-mfd-syscon-fix~51^2~20 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfe4af3aac3bd63e9caf548157805ca46ad7b073;p=pandora-kernel.git mtd: fsl-quadspi: Fix module unbound When removing the fsl-quadspi module and running 'cat /proc/mtd' afterwards, we see garbage data like: $ rmmod fsl-quadspi $ cat /proc/mtd dev: size erasesize name mtd0: 00000000 00000000 "(null)" mtd0: 00000000 00000000 "(null)" mtd0: 00000000 00000000 "(null)" ... mtd0: a22296c6c756e28 00000000 "(null)" mtd0: a22296c6c756e28 3064746d "(null)" If we continue doing multiple module load/unload operations, then it will also lead to a kernel crash. The reason for this is due to the wrong mtd index used in mtd_device_unregister() in the remove function. We need to keep the mtd unregister index aligned with the one used in the probe function, which means we need to take into account the 'has_second_chip' property. By doing so we can guarantee that the mtd index is the same in the registration and unregistration functions. With this patch applied we can load/unload the fsl-quadspi driver several times and it will result in no crash. Signed-off-by: Fabio Estevam Acked-by: Huang Shijie Tested-by: Frank Li Acked-by: Allen Xu Signed-off-by: Brian Norris --- Reading git-diff-tree failed