alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ALSA: rme9652: Adjustments for two function implementations
@ 2017-09-05 20:34 SF Markus Elfring
  2017-09-05 20:36 ` [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version() SF Markus Elfring
  2017-09-05 20:38 ` [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe() SF Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-05 20:34 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Bhumika Goyal, Jaroslav Kysela,
	Takashi Iwai, Takashi Sakamoto
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 5 Sep 2017 22:30:22 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use common code in hdsp_get_iobox_version()
  Use common error handling code in snd_hdspm_probe()

 sound/pci/rme9652/hdsp.c  | 26 +++++++++++---------------
 sound/pci/rme9652/hdspm.c | 16 ++++++++--------
 2 files changed, 19 insertions(+), 23 deletions(-)

-- 
2.14.1

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

* [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version()
  2017-09-05 20:34 [PATCH 0/2] ALSA: rme9652: Adjustments for two function implementations SF Markus Elfring
@ 2017-09-05 20:36 ` SF Markus Elfring
  2017-09-07  8:26   ` Takashi Iwai
  2017-09-05 20:38 ` [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe() SF Markus Elfring
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-05 20:36 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Bhumika Goyal, Jaroslav Kysela,
	Takashi Iwai, Takashi Sakamoto
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 5 Sep 2017 22:08:30 +0200

Add a jump target so that a bit of common code can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdsp.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 0ff41f9ab434..9f0f73875f01 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -793,11 +793,8 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
 
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200 | HDSP_PROGRAM);
 		hdsp_write (hdsp, HDSP_fifoData, 0);
-		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
-			hdsp->io_type = Multiface;
-			dev_info(hdsp->card->dev, "Multiface found\n");
-			return 0;
-		}
+		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0)
+			goto set_multi;
 
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD);
 		hdsp_write(hdsp, HDSP_fifoData, 0);
@@ -810,20 +807,14 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300);
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD);
 		hdsp_write(hdsp, HDSP_fifoData, 0);
-		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) {
-			hdsp->io_type = Multiface;
-			dev_info(hdsp->card->dev, "Multiface found\n");
-			return 0;
-		}
+		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0)
+			goto set_multi;
 
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300);
 		hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD);
 		hdsp_write(hdsp, HDSP_fifoData, 0);
-		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
-			hdsp->io_type = Multiface;
-			dev_info(hdsp->card->dev, "Multiface found\n");
-			return 0;
-		}
+		if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0)
+			goto set_multi;
 
 		hdsp->io_type = RPM;
 		dev_info(hdsp->card->dev, "RPM found\n");
@@ -838,6 +829,11 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
 			hdsp->io_type = Digiface;
 	}
 	return 0;
+
+set_multi:
+	hdsp->io_type = Multiface;
+	dev_info(hdsp->card->dev, "Multiface found\n");
+	return 0;
 }
 
 
-- 
2.14.1

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

* [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe()
  2017-09-05 20:34 [PATCH 0/2] ALSA: rme9652: Adjustments for two function implementations SF Markus Elfring
  2017-09-05 20:36 ` [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version() SF Markus Elfring
@ 2017-09-05 20:38 ` SF Markus Elfring
  2017-09-07  8:27   ` Takashi Iwai
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-05 20:38 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Bhumika Goyal, Jaroslav Kysela,
	Takashi Iwai, Takashi Sakamoto
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 5 Sep 2017 22:22:21 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/rme9652/hdspm.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 25284d8d9758..f20d42714e4d 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -6949,10 +6949,8 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 	hdspm->pci = pci;
 
 	err = snd_hdspm_create(card, hdspm);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	if (hdspm->io_type != MADIface) {
 		snprintf(card->shortname, sizeof(card->shortname), "%s_%x",
@@ -6970,15 +6968,17 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 	}
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	pci_set_drvdata(pci, card);
 
 	dev++;
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static void snd_hdspm_remove(struct pci_dev *pci)
-- 
2.14.1

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

* Re: [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version()
  2017-09-05 20:36 ` [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version() SF Markus Elfring
@ 2017-09-07  8:26   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-09-07  8:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Arnd Bergmann, Bhumika Goyal, Jaroslav Kysela,
	Takashi Sakamoto, kernel-janitors, LKML

On Tue, 05 Sep 2017 22:36:17 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 5 Sep 2017 22:08:30 +0200
> 
> Add a jump target so that a bit of common code can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

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

* Re: [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe()
  2017-09-05 20:38 ` [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe() SF Markus Elfring
@ 2017-09-07  8:27   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-09-07  8:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Arnd Bergmann, Bhumika Goyal, Jaroslav Kysela,
	Takashi Sakamoto, kernel-janitors, LKML

On Tue, 05 Sep 2017 22:38:16 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 5 Sep 2017 22:22:21 +0200
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

The subject prefix isn't right, it's about hdspm driver.
I applied the patch with that correction now.


thanks,

Takashi

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

end of thread, other threads:[~2017-09-07  8:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05 20:34 [PATCH 0/2] ALSA: rme9652: Adjustments for two function implementations SF Markus Elfring
2017-09-05 20:36 ` [PATCH 1/2] ALSA: rme9652: Use common code in hdsp_get_iobox_version() SF Markus Elfring
2017-09-07  8:26   ` Takashi Iwai
2017-09-05 20:38 ` [PATCH 2/2] ALSA: rme9652: Use common error handling code in snd_hdspm_probe() SF Markus Elfring
2017-09-07  8:27   ` Takashi Iwai

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).