linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tiantao (H)" <tiantao6@huawei.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Mark Brown <broonie@kernel.org>,
	Tian Tao <tiantao6@hisilicon.com>,
	linux-spi <linux-spi@vger.kernel.org>
Subject: Re: [PATCH] spi: davinci: Use of_device_get_match_data() helper
Date: Tue, 30 Mar 2021 20:11:39 +0800	[thread overview]
Message-ID: <bc792674-dca3-8fd7-dc55-3fceb1de4524@huawei.com> (raw)
In-Reply-To: <CAOMZO5ArUtHLREuWqKxSrh-SzYtaduWg9gQZqTFjXj9uEkzn9g@mail.gmail.com>


在 2021/3/30 19:56, Fabio Estevam 写道:
> On Mon, Mar 29, 2021 at 9:54 PM tiantao (H) <tiantao6@huawei.com> 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?
thanks.

 From what I have tested, the results are ok. I will send v2 to fix.

make modules M=drivers/spi/
   CC [M]  drivers/spi//spi-davinci.o
drivers/spi//spi-davinci.c: In function ‘spi_davinci_get_pdata’:
drivers/spi//spi-davinci.c:826:11: warning: assignment discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
   826 |  spi_data = of_device_get_match_data(&pdev->dev);
       |           ^
   MODPOST drivers/spi//Module.symvers

   LD [M]  drivers/spi//spi-davinci.ko

  vim drivers/spi//spi-davinci.c
make modules M=drivers/spi/
   CC [M]  drivers/spi//spi-davinci.o
   MODPOST drivers/spi//Module.symvers
   LD [M]  drivers/spi//spi-davinci.ko
>
> --- 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;
> .
>


  reply	other threads:[~2021-03-30 12:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  8:58 [PATCH] spi: davinci: Use of_device_get_match_data() helper Tian Tao
2021-03-29 15:21 ` Mark Brown
2021-03-30  0:53   ` tiantao (H)
2021-03-30 10:47     ` Mark Brown
2021-03-30 11:56     ` Fabio Estevam
2021-03-30 12:11       ` tiantao (H) [this message]
2021-03-30 12:15         ` Fabio Estevam
2021-03-30 12:17           ` tiantao (H)
2021-03-30 12:12       ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc792674-dca3-8fd7-dc55-3fceb1de4524@huawei.com \
    --to=tiantao6@huawei.com \
    --cc=broonie@kernel.org \
    --cc=festevam@gmail.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=tiantao6@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).