netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Wei Fang <wei.fang@nxp.com>, Shenwei Wang <shenwei.wang@nxp.com>,
	Clark Wang <xiaoning.wang@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	netdev@vger.kernel.org
Subject: [PATCH 1/1] net: fec: Fix device_get_match_data usage
Date: Mon, 16 Oct 2023 14:24:46 +0200	[thread overview]
Message-ID: <20231016122446.807703-1-alexander.stein@ew.tq-group.com> (raw)

device_get_match_data() returns an entry of fec_devtype, an array of
struct platform_device_id. But the desired struct fec_devinfo information
is stored in platform_device_id.driver_data. Thus directly storing
device_get_match_data() result in dev_info is wrong.
Instead, similar to before the change, update the pdev->id_entry if
device_get_match_data() returned non-NULL.

Fixes: b0377116decd ("net: ethernet: Use device_get_match_data()")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Admittedly I am not a fan of adding a additional struct platform_device_id
pointer. But as long a this driver supports non-DT probes it can be non-NULL.

 drivers/net/ethernet/freescale/fec_main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 5eb756871a963..dc7c3ef5ba9de 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -4297,6 +4297,7 @@ fec_probe(struct platform_device *pdev)
 	char irq_name[8];
 	int irq_cnt;
 	const struct fec_devinfo *dev_info;
+	const struct platform_device_id *plat_dev_id;
 
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
@@ -4311,9 +4312,10 @@ fec_probe(struct platform_device *pdev)
 	/* setup board info structure */
 	fep = netdev_priv(ndev);
 
-	dev_info = device_get_match_data(&pdev->dev);
-	if (!dev_info)
-		dev_info = (const struct fec_devinfo *)pdev->id_entry->driver_data;
+	plat_dev_id = device_get_match_data(&pdev->dev);
+	if (plat_dev_id)
+		pdev->id_entry = plat_dev_id;
+	dev_info = (const struct fec_devinfo *)pdev->id_entry->driver_data;
 	if (dev_info)
 		fep->quirks = dev_info->quirks;
 
-- 
2.34.1


             reply	other threads:[~2023-10-16 12:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16 12:24 Alexander Stein [this message]
2023-10-16 13:33 ` [PATCH 1/1] net: fec: Fix device_get_match_data usage 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=20231016122446.807703-1-alexander.stein@ew.tq-group.com \
    --to=alexander.stein@ew.tq-group.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=shenwei.wang@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.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).