Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: fsl-lpspi: Fix problematic dev_set_drvdata call

The original code already set controller as drvdata:
platform_set_drvdata(pdev, controller);

But commit 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi")
added dev_set_drvdata(&pdev->dev, fsl_lpspi);
so fsl_lpspi_remove() will get wrong pointer by platform_get_drvdata().

Fixes: 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Axel Lin and committed by
Mark Brown
6599be34 9d8371e2

+8 -3
+8 -3
drivers/spi/spi-fsl-lpspi.c
··· 788 788 789 789 static int fsl_lpspi_runtime_resume(struct device *dev) 790 790 { 791 - struct fsl_lpspi_data *fsl_lpspi = dev_get_drvdata(dev); 791 + struct spi_controller *controller = dev_get_drvdata(dev); 792 + struct fsl_lpspi_data *fsl_lpspi; 792 793 int ret; 794 + 795 + fsl_lpspi = spi_controller_get_devdata(controller); 793 796 794 797 ret = clk_prepare_enable(fsl_lpspi->clk_per); 795 798 if (ret) ··· 809 806 810 807 static int fsl_lpspi_runtime_suspend(struct device *dev) 811 808 { 812 - struct fsl_lpspi_data *fsl_lpspi = dev_get_drvdata(dev); 809 + struct spi_controller *controller = dev_get_drvdata(dev); 810 + struct fsl_lpspi_data *fsl_lpspi; 811 + 812 + fsl_lpspi = spi_controller_get_devdata(controller); 813 813 814 814 clk_disable_unprepare(fsl_lpspi->clk_per); 815 815 clk_disable_unprepare(fsl_lpspi->clk_ipg); ··· 859 853 860 854 fsl_lpspi = spi_controller_get_devdata(controller); 861 855 fsl_lpspi->dev = &pdev->dev; 862 - dev_set_drvdata(&pdev->dev, fsl_lpspi); 863 856 fsl_lpspi->is_slave = of_property_read_bool((&pdev->dev)->of_node, 864 857 "spi-slave"); 865 858