diff mbox series

ASoC: test-component: replace of_match_device() to of_device_get_match_data()

Message ID 20211208123659.15789-1-amhamza.mgc@gmail.com
State New
Headers show
Series ASoC: test-component: replace of_match_device() to of_device_get_match_data() | expand

Commit Message

Ameer Hamza Dec. 8, 2021, 12:36 p.m. UTC
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(-)

Comments

Ameer Hamza Dec. 8, 2021, 12:40 p.m. UTC | #1
On Wed, Dec 08, 2021 at 05:36:59PM +0500, Ameer Hamza wrote:
> 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;
> -- 
Hi Kuninori,
Would be really appreciated if you can review the patch please.

Best Regards,
Ameer Hamza.
Kuninori Morimoto Dec. 8, 2021, 10:40 p.m. UTC | #2
Hi

> Getting device data from of_device_get_match_data() for a cleaner
> implementation.
>
> Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
> ---

Reviewed-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

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;