Re: [PATCH] spi: davinci: Use of_device_get_match_data() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 29, 2021 at 9:54 PM tiantao (H) <tiantao6@xxxxxxxxxx> wrote:

> Even with of_match_device, there is still a type conversion,as follows
>
> spi_data = (struct davinci_spi_of_data *)match->data;
>
> Using of_device_get_match_data instead of of_match_device doesn't look
> like a problem from the code, other spi drivers do the same thing

What about doing it like this?

--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -817,18 +817,13 @@ 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)
-               return -ENODEV;
-
-       spi_data = (struct davinci_spi_of_data *)match->data;
+       spi_data = device_get_match_data(&pdev->dev);

        pdata->version = spi_data->version;
        pdata->prescaler_limit = spi_data->prescaler_limit;




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux