public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Rob Herring <robh@kernel.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>,
	Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>,
	Michal Simek <michal.simek@amd.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RESEND PATCH] net: can: Use device_get_match_data()
Date: Thu, 16 Nov 2023 18:29:23 +0000	[thread overview]
Message-ID: <20231116182923.GH109951@vergenet.net> (raw)
In-Reply-To: <20231115210129.3739377-1-robh@kernel.org>

On Wed, Nov 15, 2023 at 03:01:28PM -0600, Rob Herring wrote:
> Use preferred device_get_match_data() instead of of_match_device() to
> get the driver match data. With this, adjust the includes to explicitly
> include the correct headers.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

...

> diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
> index abe58f103043..f17fd43d03c0 100644
> --- a/drivers/net/can/xilinx_can.c
> +++ b/drivers/net/can/xilinx_can.c
> @@ -20,8 +20,8 @@
>  #include <linux/module.h>
>  #include <linux/netdevice.h>
>  #include <linux/of.h>
> -#include <linux/of_device.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/skbuff.h>
>  #include <linux/spinlock.h>
>  #include <linux/string.h>
> @@ -1726,7 +1726,6 @@ static int xcan_probe(struct platform_device *pdev)
>  	struct net_device *ndev;
>  	struct xcan_priv *priv;
>  	struct phy *transceiver;
> -	const struct of_device_id *of_id;
>  	const struct xcan_devtype_data *devtype = &xcan_axi_data;

Hi Rob,

Here devtype is initialised.

>  	void __iomem *addr;
>  	int ret;
> @@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev)
>  		goto err;
>  	}
>  
> -	of_id = of_match_device(xcan_of_match, &pdev->dev);
> -	if (of_id && of_id->data)
> -		devtype = of_id->data;

And in the old code devtype was conditionally re-initialised here,
if a match with data was found.

But in the new code devtype is re-initialised unconditionally.

Possibly I am missing something obvious, but it seems that either this
should somehow be made conditional, or the initialisation to &xcan_axi_data
should be dropped.

> +	devtype = device_get_match_data(&pdev->dev);
>  
>  	hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
>  			     "tx-mailbox-count" : "tx-fifo-depth";
> -- 
> 2.42.0
> 

  reply	other threads:[~2023-11-16 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 21:01 [RESEND PATCH] net: can: Use device_get_match_data() Rob Herring
2023-11-16 18:29 ` Simon Horman [this message]
2023-11-21 14:50   ` Rob Herring

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=20231116182923.GH109951@vergenet.net \
    --to=horms@kernel.org \
    --cc=appana.durga.rao@xilinx.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=mkl@pengutronix.de \
    --cc=naga.sureshkumar.relli@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=wg@grandegger.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