spi: mediatek: Use of_device_get_match_data()
diff mbox

Message ID 94cba80f703be048666afde1ed53c15c3704c533.1523347340.git.ryder.lee@mediatek.com
State New
Headers show

Commit Message

Ryder Lee April 16, 2018, 2:33 a.m. UTC
The usage of of_device_get_match_data() reduce the code size a bit.

Also, the only way to call mtk_spi_probe() is to match an entry in
mtk_spi_of_match[], so of_id cannot be NULL.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
---
 drivers/spi/spi-mt65xx.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Ryder Lee April 30, 2018, 7:26 a.m. UTC | #1
Hi Mark,

Is it okay with you?

On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee (李庚?V) wrote:
> The usage of of_device_get_match_data() reduce the code size a bit.
> 
> Also, the only way to call mtk_spi_probe() is to match an entry in
> mtk_spi_of_match[], so of_id cannot be NULL.
> 
> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
> ---
>  drivers/spi/spi-mt65xx.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
Mark Brown May 1, 2018, 8:35 p.m. UTC | #2
On Mon, Apr 30, 2018 at 03:26:36PM +0800, Ryder Lee wrote:
> Hi Mark,
> 
> Is it okay with you?
> 
> On Mon, 2018-04-16 at 10:33 +0800, Ryder Lee (李庚?V) wrote:
> > The usage of of_device_get_match_data() reduce the code size a bit.

Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so 
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review.  If there have been
review comments then people may be waiting for those to be addressed.
Sending content free pings just adds to the mail volume (if they are
seen at all) and if something has gone wrong you'll have to resend the
patches anyway.

Patch
diff mbox

diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 86bf456..3edc183 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -20,6 +20,7 @@ 
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/spi-mt65xx.h>
@@ -578,7 +579,6 @@  static int mtk_spi_probe(struct platform_device *pdev)
 {
 	struct spi_master *master;
 	struct mtk_spi *mdata;
-	const struct of_device_id *of_id;
 	struct resource *res;
 	int i, irq, ret;
 
@@ -598,15 +598,9 @@  static int mtk_spi_probe(struct platform_device *pdev)
 	master->can_dma = mtk_spi_can_dma;
 	master->setup = mtk_spi_setup;
 
-	of_id = of_match_node(mtk_spi_of_match, pdev->dev.of_node);
-	if (!of_id) {
-		dev_err(&pdev->dev, "failed to probe of_node\n");
-		ret = -EINVAL;
-		goto err_put_master;
-	}
-
 	mdata = spi_master_get_devdata(master);
-	mdata->dev_comp = of_id->data;
+	mdata->dev_comp = of_device_get_match_data(&pdev->dev);
+
 	if (mdata->dev_comp->must_tx)
 		master->flags = SPI_MASTER_MUST_TX;