diff mbox series

[v2] spi: davinci: Use of_device_get_match_data() helper

Message ID 1617107474-46079-1-git-send-email-tiantao6@hisilicon.com
State Superseded
Headers show
Series [v2] spi: davinci: Use of_device_get_match_data() helper | expand

Commit Message

Tian Tao March 30, 2021, 12:31 p.m. UTC
Use the of_device_get_match_data() helper instead of open coding.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
v2: Removed forced type conversions
---
 drivers/spi/spi-davinci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Fabio Estevam March 30, 2021, 12:36 p.m. UTC | #1
On Tue, Mar 30, 2021 at 9:30 AM Tian Tao <tiantao6@hisilicon.com> wrote:

> -       match = of_match_device(davinci_spi_of_match, &pdev->dev);
> -       if (!match)
> +       spi_data = of_device_get_match_data(&pdev->dev);
> +       if (!spi_data)

No need to check against NULL here because all compatible strings
provide .data and DT is the only mechanism to probe.

Also, this could be device_get_match_data().
Fabio Estevam March 30, 2021, 12:49 p.m. UTC | #2
On Tue, Mar 30, 2021 at 9:48 AM tiantao (H) <tiantao6@huawei.com> wrote:

> What about doing it like this?

Yes, this is what I suggested before :-)
Fabio Estevam March 30, 2021, 12:55 p.m. UTC | #3
On Tue, Mar 30, 2021 at 9:53 AM tiantao (H) <tiantao6@huawei.com> wrote:

> thank you,I will send a new patch for this.
>
> can I add Signed-off-by: Fabio Estevam <festevam@gmail.com>

Please add:

Suggested-by: Fabio Estevam <festevam@gmail.com>

Also, in v3 don't forget to change the Subject from
of_device_get_match_data() to device_get_match_data().
diff mbox series

Patch

diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 7453a1d..9122235 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -817,19 +817,16 @@  static int spi_davinci_get_pdata(struct platform_device *pdev,
 			struct davinci_spi *dspi)
 {
 	struct device_node *node = pdev->dev.of_node;
-	struct davinci_spi_of_data *spi_data;
+	const struct davinci_spi_of_data *spi_data;
 	struct davinci_spi_platform_data *pdata;
 	unsigned int num_cs, intr_line = 0;
-	const struct of_device_id *match;
 
 	pdata = &dspi->pdata;
 
-	match = of_match_device(davinci_spi_of_match, &pdev->dev);
-	if (!match)
+	spi_data = of_device_get_match_data(&pdev->dev);
+	if (!spi_data)
 		return -ENODEV;
 
-	spi_data = (struct davinci_spi_of_data *)match->data;
-
 	pdata->version = spi_data->version;
 	pdata->prescaler_limit = spi_data->prescaler_limit;
 	/*