alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Ameer Hamza <amhamza.mgc@gmail.com>
To: kuninori.morimoto.gx@renesas.com
Cc: alsa-devel@alsa-project.org, Ameer Hamza <amhamza.mgc@gmail.com>,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
	tiwai@suse.com, broonie@kernel.org
Subject: [PATCH] ASoC: test-component: replace of_match_device() to of_device_get_match_data()
Date: Wed,  8 Dec 2021 17:36:59 +0500	[thread overview]
Message-ID: <20211208123659.15789-1-amhamza.mgc@gmail.com> (raw)
In-Reply-To: <20211208120526.GA12550@hamza-OptiPlex-7040>

Getting device data from of_device_get_match_data() for a cleaner
implementation.

Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
 sound/soc/generic/test-component.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/generic/test-component.c b/sound/soc/generic/test-component.c
index 8fc97d3ff011..5da4725d9e16 100644
--- a/sound/soc/generic/test-component.c
+++ b/sound/soc/generic/test-component.c
@@ -531,17 +531,13 @@ static int test_driver_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *node = dev->of_node;
 	struct device_node *ep;
-	const struct of_device_id *of_id = of_match_device(test_of_match, &pdev->dev);
-	const struct test_adata *adata;
+	const struct test_adata *adata = of_device_get_match_data(&pdev->dev);
 	struct snd_soc_component_driver *cdriv;
 	struct snd_soc_dai_driver *ddriv;
 	struct test_dai_name *dname;
 	struct test_priv *priv;
 	int num, ret, i;
 
-	if (!of_id)
-		return -EINVAL;
-	adata = of_id->data;
 	num = of_graph_get_endpoint_count(node);
 	if (!num) {
 		dev_err(dev, "no port exits\n");
@@ -552,7 +548,7 @@ static int test_driver_probe(struct platform_device *pdev)
 	cdriv	= devm_kzalloc(dev, sizeof(*cdriv),		GFP_KERNEL);
 	ddriv	= devm_kzalloc(dev, sizeof(*ddriv) * num,	GFP_KERNEL);
 	dname	= devm_kzalloc(dev, sizeof(*dname) * num,	GFP_KERNEL);
-	if (!priv || !cdriv || !ddriv || !dname)
+	if (!priv || !cdriv || !ddriv || !dname || !adata)
 		return -EINVAL;
 
 	priv->dev		= dev;
-- 
2.25.1


  reply	other threads:[~2021-12-08 12:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-05 20:42 [PATCH] ASoC: test-component: fix null pointer dereference Ameer Hamza
2021-12-05 22:40 ` Kuninori Morimoto
2021-12-06  9:29   ` Ameer Hamza
2021-12-06 23:19     ` Kuninori Morimoto
2021-12-07  8:15       ` Ameer Hamza
2021-12-07 12:51         ` Mark Brown
2021-12-07 14:23           ` [PATCH v2] " Ameer Hamza
2021-12-08  0:05             ` Kuninori Morimoto
2021-12-08 12:05               ` Ameer Hamza
2021-12-08 12:36                 ` Ameer Hamza [this message]
2021-12-08 12:40                   ` [PATCH] ASoC: test-component: replace of_match_device() to of_device_get_match_data() Ameer Hamza
2021-12-08 22:40                   ` Kuninori Morimoto
2021-12-09 13:45             ` [PATCH v2] ASoC: test-component: fix null pointer dereference Mark Brown
2021-12-07 23:53           ` [PATCH] " Kuninori Morimoto
2021-12-06 18:00 ` 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=20211208123659.15789-1-amhamza.mgc@gmail.com \
    --to=amhamza.mgc@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.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).