All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] ASoC: mxs-saif: Add variable dev to simplify code
@ 2020-04-30  6:36 ` Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2020-04-30  6:36 UTC (permalink / raw)
  To: Tang Bin, Zhang Shengju, alsa-devel, linux-arm-kernel
  Cc: linux-kernel, kernel-janitors, Jaroslav Kysela, Liam Girdwood,
	Mark Brown, Sascha Hauer, Shawn Guo, Takashi Iwai

> Add variable 'dev' to make the code cleaner in the function
> mxs_saif_probe(). And now that the function mxs_saif_mclk_init()
> have defined the variables 'ret' as the error returned value,
> then it should be used instead in this place.

I find it clearer to integrate such source code adjustments by separate patches
together with improved commit messages.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=1d2cc5ac6f6668cc15216d51051103c61467d7e8#n138


Would you become interested to search for similar update candidates
by the means of the semantic patch language (Coccinelle software)?

Regards,
Markus

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH] ASoC: mxs-saif: Add variable dev to simplify code
@ 2020-04-29  9:40 ` Tang Bin
  0 siblings, 0 replies; 9+ messages in thread
From: Tang Bin @ 2020-04-29  9:40 UTC (permalink / raw)
  To: broonie, lgirdwood, perex, tiwai, shawnguo, s.hauer
  Cc: alsa-devel, linux-arm-kernel, linux-kernel, Tang Bin, Zhang Shengju

Add variable 'dev' to make the code cleaner in the function
mxs_saif_probe(). And now that the function mxs_saif_mclk_init()
have defined the variables 'ret' as the error returned value,
then it should be used instead in this place.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 sound/soc/mxs/mxs-saif.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index dc197883e..f4e441183 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -719,7 +719,7 @@ static int mxs_saif_mclk_init(struct platform_device *pdev)
 		if (ret == -EEXIST)
 			return 0;
 		dev_err(&pdev->dev, "failed to register mclk: %d\n", ret);
-		return PTR_ERR(clk);
+		return ret;
 	}
 
 	ret = of_clk_add_provider(np, of_clk_src_simple_get, clk);
@@ -732,6 +732,7 @@ static int mxs_saif_mclk_init(struct platform_device *pdev)
 static int mxs_saif_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
+	struct device *dev = &pdev->dev;
 	struct mxs_saif *saif;
 	int irq, ret;
 	struct device_node *master;
@@ -739,7 +740,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	if (!np)
 		return -EINVAL;
 
-	saif = devm_kzalloc(&pdev->dev, sizeof(*saif), GFP_KERNEL);
+	saif = devm_kzalloc(dev, sizeof(*saif), GFP_KERNEL);
 	if (!saif)
 		return -ENOMEM;
 
@@ -750,7 +751,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 		saif->id = ret;
 
 	if (saif->id >= ARRAY_SIZE(mxs_saif)) {
-		dev_err(&pdev->dev, "get wrong saif id\n");
+		dev_err(dev, "get wrong saif id\n");
 		return -EINVAL;
 	}
 
@@ -770,18 +771,17 @@ static int mxs_saif_probe(struct platform_device *pdev)
 			saif->master_id = ret;
 
 		if (saif->master_id >= ARRAY_SIZE(mxs_saif)) {
-			dev_err(&pdev->dev, "get wrong master id\n");
+			dev_err(dev, "get wrong master id\n");
 			return -EINVAL;
 		}
 	}
 
 	mxs_saif[saif->id] = saif;
 
-	saif->clk = devm_clk_get(&pdev->dev, NULL);
+	saif->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(saif->clk)) {
 		ret = PTR_ERR(saif->clk);
-		dev_err(&pdev->dev, "Cannot get the clock: %d\n",
-			ret);
+		dev_err(dev, "Cannot get the clock: %d\n", ret);
 		return ret;
 	}
 
@@ -793,11 +793,11 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	saif->dev = &pdev->dev;
-	ret = devm_request_irq(&pdev->dev, irq, mxs_saif_irq, 0,
-			       dev_name(&pdev->dev), saif);
+	saif->dev = dev;
+	ret = devm_request_irq(dev, irq, mxs_saif_irq, 0,
+			       dev_name(dev), saif);
 	if (ret) {
-		dev_err(&pdev->dev, "failed to request irq\n");
+		dev_err(dev, "failed to request irq\n");
 		return ret;
 	}
 
@@ -807,19 +807,19 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	if (saif->id == 0) {
 		ret = mxs_saif_mclk_init(pdev);
 		if (ret)
-			dev_warn(&pdev->dev, "failed to init clocks\n");
+			dev_warn(dev, "failed to init clocks\n");
 	}
 
-	ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component,
+	ret = devm_snd_soc_register_component(dev, &mxs_saif_component,
 					      &mxs_saif_dai, 1);
 	if (ret) {
-		dev_err(&pdev->dev, "register DAI failed\n");
+		dev_err(dev, "register DAI failed\n");
 		return ret;
 	}
 
-	ret = mxs_pcm_platform_register(&pdev->dev);
+	ret = mxs_pcm_platform_register(dev);
 	if (ret) {
-		dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
+		dev_err(dev, "register PCM failed: %d\n", ret);
 		return ret;
 	}
 
-- 
2.20.1.windows.1




^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-08 17:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30  6:36 [PATCH] ASoC: mxs-saif: Add variable dev to simplify code Markus Elfring
2020-04-30  6:36 ` Markus Elfring
2020-04-30  6:36 ` Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-04-29  9:40 Tang Bin
2020-04-29  9:40 ` Tang Bin
2020-04-29  9:40 ` Tang Bin
2020-05-08 17:13 ` Mark Brown
2020-05-08 17:13   ` Mark Brown
2020-05-08 17:13   ` Mark Brown

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.