All of lore.kernel.org
 help / color / mirror / Atom feed
From: mkl@pengutronix.de (Marc Kleine-Budde)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH|RFC] of: let of_match_device() always return best match
Date: Sat, 05 Oct 2013 19:57:09 +0200	[thread overview]
Message-ID: <525052F5.5080204@pengutronix.de> (raw)
In-Reply-To: <CAOMZO5BekS_BvJzrt8vM1=7LjsiO=3hKL=mMfTjxkO3aZ4qwRQ@mail.gmail.com>

On 10/05/2013 07:46 PM, Fabio Estevam wrote:
> Hi Marc,
> 
> On Thu, Oct 3, 2013 at 3:51 PM, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> 
>> For example:
>>
>> The imx28.dtsi gives this compatible string for its CAN core:
>>
>>>       compatible = "fsl,imx28-flexcan", "fsl,p1010-flexcan";
>>
>> The flexcan driver defines:
>>
>>> static const struct of_device_id flexcan_of_match[] = {
>>>       { .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
>>>       { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
>>>       { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
>>>       { /* sentinel */ },
>>> };
>>
>> The "p1010" was the first Freescale SoC with the flexcan core. But this SoC has
>> a bug, so a workaround has to be enabled in the driver. The mx28 has this bug
>> fixed, so we don't need this quite costly workaround.
> 
> What about defining in imx28.dtsi:
> compatible = "fsl,imx28-flexcan".

It already works with changing only the driver.

> and the in the flexcan driver we could do the same as in the fec_main driver:
> 
> static struct platform_device_id fec_devtype[] = {

For DT based probing I need to modify the struct of_device_id, but I got
the idea :)

>     {
>         /* keep it for coldfire */
>         .name = DRIVER_NAME,
>         .driver_data = 0,
>     }, {
>         .name = "imx25-fec",
>         .driver_data = FEC_QUIRK_USE_GASKET,
>     }, {
>         .name = "imx27-fec",
>         .driver_data = 0,
>     }, {
>         .name = "imx28-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
>     }, {
>         .name = "imx6q-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
>                 FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>                 FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358,
>     }, {
>         .name = "mvf600-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC,
>     }, {
>         /* sentinel */
>     }
> };
> 
> So that we know which SoC needs to have the workaround applied or not.

I've already created a patch that rearranges the struct of_device_id in
the driver, works for me. I posted it (with another fix) for review on
linux-can[1].

Thanks,
Marc

[1] http://comments.gmane.org/gmane.linux.can/4050
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131005/12ed57bb/attachment.sig>

WARNING: multiple messages have this Message-ID (diff)
From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-arm-kernel
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org"
	<kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Subject: Re: [PATCH|RFC] of: let of_match_device() always return best match
Date: Sat, 05 Oct 2013 19:57:09 +0200	[thread overview]
Message-ID: <525052F5.5080204@pengutronix.de> (raw)
In-Reply-To: <CAOMZO5BekS_BvJzrt8vM1=7LjsiO=3hKL=mMfTjxkO3aZ4qwRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2667 bytes --]

On 10/05/2013 07:46 PM, Fabio Estevam wrote:
> Hi Marc,
> 
> On Thu, Oct 3, 2013 at 3:51 PM, Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> 
>> For example:
>>
>> The imx28.dtsi gives this compatible string for its CAN core:
>>
>>>       compatible = "fsl,imx28-flexcan", "fsl,p1010-flexcan";
>>
>> The flexcan driver defines:
>>
>>> static const struct of_device_id flexcan_of_match[] = {
>>>       { .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
>>>       { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
>>>       { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
>>>       { /* sentinel */ },
>>> };
>>
>> The "p1010" was the first Freescale SoC with the flexcan core. But this SoC has
>> a bug, so a workaround has to be enabled in the driver. The mx28 has this bug
>> fixed, so we don't need this quite costly workaround.
> 
> What about defining in imx28.dtsi:
> compatible = "fsl,imx28-flexcan".

It already works with changing only the driver.

> and the in the flexcan driver we could do the same as in the fec_main driver:
> 
> static struct platform_device_id fec_devtype[] = {

For DT based probing I need to modify the struct of_device_id, but I got
the idea :)

>     {
>         /* keep it for coldfire */
>         .name = DRIVER_NAME,
>         .driver_data = 0,
>     }, {
>         .name = "imx25-fec",
>         .driver_data = FEC_QUIRK_USE_GASKET,
>     }, {
>         .name = "imx27-fec",
>         .driver_data = 0,
>     }, {
>         .name = "imx28-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
>     }, {
>         .name = "imx6q-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
>                 FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>                 FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358,
>     }, {
>         .name = "mvf600-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC,
>     }, {
>         /* sentinel */
>     }
> };
> 
> So that we know which SoC needs to have the workaround applied or not.

I've already created a patch that rearranges the struct of_device_id in
the driver, works for me. I posted it (with another fix) for review on
linux-can[1].

Thanks,
Marc

[1] http://comments.gmane.org/gmane.linux.can/4050
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Fabio Estevam <festevam@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <rob.herring@calxeda.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [PATCH|RFC] of: let of_match_device() always return best match
Date: Sat, 05 Oct 2013 19:57:09 +0200	[thread overview]
Message-ID: <525052F5.5080204@pengutronix.de> (raw)
In-Reply-To: <CAOMZO5BekS_BvJzrt8vM1=7LjsiO=3hKL=mMfTjxkO3aZ4qwRQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2642 bytes --]

On 10/05/2013 07:46 PM, Fabio Estevam wrote:
> Hi Marc,
> 
> On Thu, Oct 3, 2013 at 3:51 PM, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> 
>> For example:
>>
>> The imx28.dtsi gives this compatible string for its CAN core:
>>
>>>       compatible = "fsl,imx28-flexcan", "fsl,p1010-flexcan";
>>
>> The flexcan driver defines:
>>
>>> static const struct of_device_id flexcan_of_match[] = {
>>>       { .compatible = "fsl,p1010-flexcan", .data = &fsl_p1010_devtype_data, },
>>>       { .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
>>>       { .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
>>>       { /* sentinel */ },
>>> };
>>
>> The "p1010" was the first Freescale SoC with the flexcan core. But this SoC has
>> a bug, so a workaround has to be enabled in the driver. The mx28 has this bug
>> fixed, so we don't need this quite costly workaround.
> 
> What about defining in imx28.dtsi:
> compatible = "fsl,imx28-flexcan".

It already works with changing only the driver.

> and the in the flexcan driver we could do the same as in the fec_main driver:
> 
> static struct platform_device_id fec_devtype[] = {

For DT based probing I need to modify the struct of_device_id, but I got
the idea :)

>     {
>         /* keep it for coldfire */
>         .name = DRIVER_NAME,
>         .driver_data = 0,
>     }, {
>         .name = "imx25-fec",
>         .driver_data = FEC_QUIRK_USE_GASKET,
>     }, {
>         .name = "imx27-fec",
>         .driver_data = 0,
>     }, {
>         .name = "imx28-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,
>     }, {
>         .name = "imx6q-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
>                 FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
>                 FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358,
>     }, {
>         .name = "mvf600-fec",
>         .driver_data = FEC_QUIRK_ENET_MAC,
>     }, {
>         /* sentinel */
>     }
> };
> 
> So that we know which SoC needs to have the workaround applied or not.

I've already created a patch that rearranges the struct of_device_id in
the driver, works for me. I posted it (with another fix) for review on
linux-can[1].

Thanks,
Marc

[1] http://comments.gmane.org/gmane.linux.can/4050
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2013-10-05 17:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03 18:51 [PATCH|RFC] of: let of_match_device() always return best match Marc Kleine-Budde
2013-10-03 18:51 ` Marc Kleine-Budde
2013-10-03 20:37 ` Rob Herring
2013-10-03 20:37   ` Rob Herring
2013-10-03 20:37   ` Rob Herring
2013-10-03 21:51   ` Marc Kleine-Budde
2013-10-03 21:51     ` Marc Kleine-Budde
2013-10-03 21:51     ` Marc Kleine-Budde
2013-10-03 22:23     ` Rob Herring
2013-10-03 22:23       ` Rob Herring
2013-10-03 22:23       ` Rob Herring
2013-10-05 17:46 ` Fabio Estevam
2013-10-05 17:46   ` Fabio Estevam
2013-10-05 17:46   ` Fabio Estevam
2013-10-05 17:57   ` Marc Kleine-Budde [this message]
2013-10-05 17:57     ` Marc Kleine-Budde
2013-10-05 17:57     ` Marc Kleine-Budde
2013-10-07  8:17     ` Lothar Waßmann
2013-10-07  8:17       ` Lothar Waßmann
2013-10-07  8:17       ` Lothar Waßmann
2013-10-07  8:18       ` Marc Kleine-Budde
2013-10-07  8:18         ` Marc Kleine-Budde
2013-10-07  8:18         ` Marc Kleine-Budde

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=525052F5.5080204@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.