Browse Source

ath79: patch upstream Mikrotik rb4xx-spi driver to be device tree aware

Backport upstream patches that make drivers/spi/spi-rb4xx.c device tree
aware, plus a null pointer fix.

Signed-off-by: Christopher Hill <[email protected]>
Christopher Hill 5 years ago
parent
commit
344e75eb2b

+ 50 - 0
target/linux/generic/backport-4.19/825-v5.8-spi-rb4xx-null-pointer-bug-fix.patch

@@ -0,0 +1,50 @@
+From: Christopher Hill <[email protected]>
+To: Mark Brown <[email protected]>
+Cc: Christopher Hill <[email protected]>, [email protected],
+        [email protected]
+Subject: [PATCH 1/3] spi: rb4xx: null pointer bug fix
+Date: Thu, 21 May 2020 14:36:29 -0400
+Message-Id: <[email protected]>
+X-Mailer: git-send-email 2.25.1
+MIME-Version: 1.0
+Sender: [email protected]
+Precedence: bulk
+List-ID: <linux-spi.vger.kernel.org>
+X-Mailing-List: [email protected]
+
+This patch fixes a null pointer bug in the spi driver spi-rb4xx.c by
+moving the private data initialization to earlier in probe
+
+Signed-off-by: Christopher Hill <[email protected]>
+---
+ drivers/spi/spi-rb4xx.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c
+index 4c9620e0d18c..17e1a77dc132 100644
+--- a/drivers/spi/spi-rb4xx.c
++++ b/drivers/spi/spi-rb4xx.c
+@@ -158,6 +158,11 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	master->transfer_one = rb4xx_transfer_one;
+ 	master->set_cs = rb4xx_set_cs;
+ 
++	rbspi = spi_master_get_devdata(master);
++	rbspi->base = spi_base;
++	rbspi->clk = ahb_clk;
++	platform_set_drvdata(pdev, rbspi);
++
+ 	err = devm_spi_register_master(&pdev->dev, master);
+ 	if (err) {
+ 		dev_err(&pdev->dev, "failed to register SPI master\n");
+@@ -168,11 +173,6 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	if (err)
+ 		return err;
+ 
+-	rbspi = spi_master_get_devdata(master);
+-	rbspi->base = spi_base;
+-	rbspi->clk = ahb_clk;
+-	platform_set_drvdata(pdev, rbspi);
+-
+ 	/* Enable SPI */
+ 	rb4xx_write(rbspi, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
+ 

+ 62 - 0
target/linux/generic/backport-4.19/826-v5.8-spi-rb4xx-update-driver-to-be-device-tree-aware.patch

@@ -0,0 +1,62 @@
+From: Christopher Hill <[email protected]>
+To: Mark Brown <[email protected]>
+Cc: Christopher Hill <[email protected]>, [email protected],
+        [email protected]
+Subject: [PATCH 2/3] spi: rb4xx: update driver to be device tree aware
+Date: Thu, 21 May 2020 14:36:30 -0400
+Message-Id: <[email protected]>
+X-Mailer: git-send-email 2.25.1
+In-Reply-To: <[email protected]>
+References: <[email protected]>
+MIME-Version: 1.0
+Sender: [email protected]
+Precedence: bulk
+List-ID: <linux-spi.vger.kernel.org>
+X-Mailing-List: [email protected]
+
+This patch updates the spi driver spi-rb4xx.c to be device tree aware
+
+Signed-off-by: Christopher Hill <[email protected]>
+---
+ drivers/spi/spi-rb4xx.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c
+index 17e1a77dc132..8aa51beb4ff3 100644
+--- a/drivers/spi/spi-rb4xx.c
++++ b/drivers/spi/spi-rb4xx.c
+@@ -14,6 +14,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/clk.h>
+ #include <linux/spi/spi.h>
++#include <linux/of.h>
+ 
+ #include <asm/mach-ath79/ar71xx_regs.h>
+ 
+@@ -150,6 +151,7 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	if (IS_ERR(ahb_clk))
+ 		return PTR_ERR(ahb_clk);
+ 
++	master->dev.of_node = pdev->dev.of_node;
+ 	master->bus_num = 0;
+ 	master->num_chipselect = 3;
+ 	master->mode_bits = SPI_TX_DUAL;
+@@ -188,11 +190,18 @@ static int rb4xx_spi_remove(struct platform_device *pdev)
+ 	return 0;
+ }
+ 
++static const struct of_device_id rb4xx_spi_dt_match[] = {
++	{ .compatible = "mikrotik,rb4xx-spi" },
++	{ },
++};
++MODULE_DEVICE_TABLE(of, rb4xx_spi_dt_match);
++
+ static struct platform_driver rb4xx_spi_drv = {
+ 	.probe = rb4xx_spi_probe,
+ 	.remove = rb4xx_spi_remove,
+ 	.driver = {
+ 		.name = "rb4xx-spi",
++		.of_match_table = of_match_ptr(rb4xx_spi_dt_match),
+ 	},
+ };
+ 

+ 50 - 0
target/linux/generic/backport-5.4/825-v5.8-spi-rb4xx-null-pointer-bug-fix.patch

@@ -0,0 +1,50 @@
+From: Christopher Hill <[email protected]>
+To: Mark Brown <[email protected]>
+Cc: Christopher Hill <[email protected]>, [email protected],
+        [email protected]
+Subject: [PATCH 1/3] spi: rb4xx: null pointer bug fix
+Date: Thu, 21 May 2020 14:36:29 -0400
+Message-Id: <[email protected]>
+X-Mailer: git-send-email 2.25.1
+MIME-Version: 1.0
+Sender: [email protected]
+Precedence: bulk
+List-ID: <linux-spi.vger.kernel.org>
+X-Mailing-List: [email protected]
+
+This patch fixes a null pointer bug in the spi driver spi-rb4xx.c by
+moving the private data initialization to earlier in probe
+
+Signed-off-by: Christopher Hill <[email protected]>
+---
+ drivers/spi/spi-rb4xx.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c
+index 4c9620e0d18c..17e1a77dc132 100644
+--- a/drivers/spi/spi-rb4xx.c
++++ b/drivers/spi/spi-rb4xx.c
+@@ -158,6 +158,11 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	master->transfer_one = rb4xx_transfer_one;
+ 	master->set_cs = rb4xx_set_cs;
+ 
++	rbspi = spi_master_get_devdata(master);
++	rbspi->base = spi_base;
++	rbspi->clk = ahb_clk;
++	platform_set_drvdata(pdev, rbspi);
++
+ 	err = devm_spi_register_master(&pdev->dev, master);
+ 	if (err) {
+ 		dev_err(&pdev->dev, "failed to register SPI master\n");
+@@ -168,11 +173,6 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	if (err)
+ 		return err;
+ 
+-	rbspi = spi_master_get_devdata(master);
+-	rbspi->base = spi_base;
+-	rbspi->clk = ahb_clk;
+-	platform_set_drvdata(pdev, rbspi);
+-
+ 	/* Enable SPI */
+ 	rb4xx_write(rbspi, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
+ 

+ 62 - 0
target/linux/generic/backport-5.4/826-v5.8-spi-rb4xx-update-driver-to-be-device-tree-aware.patch

@@ -0,0 +1,62 @@
+From: Christopher Hill <[email protected]>
+To: Mark Brown <[email protected]>
+Cc: Christopher Hill <[email protected]>, [email protected],
+        [email protected]
+Subject: [PATCH 2/3] spi: rb4xx: update driver to be device tree aware
+Date: Thu, 21 May 2020 14:36:30 -0400
+Message-Id: <[email protected]>
+X-Mailer: git-send-email 2.25.1
+In-Reply-To: <[email protected]>
+References: <[email protected]>
+MIME-Version: 1.0
+Sender: [email protected]
+Precedence: bulk
+List-ID: <linux-spi.vger.kernel.org>
+X-Mailing-List: [email protected]
+
+This patch updates the spi driver spi-rb4xx.c to be device tree aware
+
+Signed-off-by: Christopher Hill <[email protected]>
+---
+ drivers/spi/spi-rb4xx.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c
+index 17e1a77dc132..8aa51beb4ff3 100644
+--- a/drivers/spi/spi-rb4xx.c
++++ b/drivers/spi/spi-rb4xx.c
+@@ -14,6 +14,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/clk.h>
+ #include <linux/spi/spi.h>
++#include <linux/of.h>
+ 
+ #include <asm/mach-ath79/ar71xx_regs.h>
+ 
+@@ -150,6 +151,7 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
+ 	if (IS_ERR(ahb_clk))
+ 		return PTR_ERR(ahb_clk);
+ 
++	master->dev.of_node = pdev->dev.of_node;
+ 	master->bus_num = 0;
+ 	master->num_chipselect = 3;
+ 	master->mode_bits = SPI_TX_DUAL;
+@@ -188,11 +190,18 @@ static int rb4xx_spi_remove(struct platform_device *pdev)
+ 	return 0;
+ }
+ 
++static const struct of_device_id rb4xx_spi_dt_match[] = {
++	{ .compatible = "mikrotik,rb4xx-spi" },
++	{ },
++};
++MODULE_DEVICE_TABLE(of, rb4xx_spi_dt_match);
++
+ static struct platform_driver rb4xx_spi_drv = {
+ 	.probe = rb4xx_spi_probe,
+ 	.remove = rb4xx_spi_remove,
+ 	.driver = {
+ 		.name = "rb4xx-spi",
++		.of_match_table = of_match_ptr(rb4xx_spi_dt_match),
+ 	},
+ };
+