Skip to contentSkip to conversation

ALSA: hal2: Fine-tuning for four function implementations

PATCH Applied SF Markus Elfring 2 participants 5 messages Nov 11, 2017 – Nov 28, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ALSA: hal2: Fine-tuning for four function implementations

From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 19:06:54 +0100

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

Markus Elfring (3):
Use common error handling code in hal2_probe()
Improve a size determination in hal2_create()
Fix a typo in two comment lines

 sound/mips/hal2.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/3 ALSA: hal2: Use common error handling code in hal2_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 18:26:06 +0100

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.

---
 sound/mips/hal2.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
sound/mips/hal2.c +14 -16
index 37d378a26a50..30563d9aa5c8 100644
@@ -887,21 +887,16 @@ static int hal2_probe(struct platform_device *pdev)
 		return err;
 
 	err = hal2_create(card, &chip);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	err = hal2_pcm_create(chip);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
+
 	err = hal2_mixer_create(chip);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	strcpy(card->driver, "SGI HAL2 Audio");
 	strcpy(card->shortname, "SGI HAL2 Audio");
@@ -910,12 +905,15 @@ static int hal2_probe(struct platform_device *pdev)
 		SGI_HPCDMA_IRQ);
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
+
 	platform_set_drvdata(pdev, card);
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static int hal2_remove(struct platform_device *pdev)
Signature · 1 line
2.15.0
#2 lore raw

PATCH 2/3 ALSA: hal2: Improve a size determination in hal2_create()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 18:34:04 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 sound/mips/hal2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/mips/hal2.c +1 -1
index 30563d9aa5c8..675c3aba794e 100644
@@ -814,7 +814,7 @@ static int hal2_create(struct snd_card *card, struct snd_hal2 **rchip)
 	struct hpc3_regs *hpc3 = hpc3c0;
 	int err;
 
-	hal2 = kzalloc(sizeof(struct snd_hal2), GFP_KERNEL);
+	hal2 = kzalloc(sizeof(*hal2), GFP_KERNEL);
 	if (!hal2)
 		return -ENOMEM;
 
Signature · 1 line
2.15.0
#4 lore raw

PATCH 3/3 ALSA: hal2: Fix a typo in two comment lines

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 18:48:41 +0100

Add a missing character in these descriptions.

---
 sound/mips/hal2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/mips/hal2.c +2 -2
index 675c3aba794e..4fa5f161ef2d 100644
@@ -388,7 +388,7 @@ static void hal2_setup_dac(struct snd_hal2 *hal2)
 	hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECTX);
 	/* Setup the HAL2 for playback */
 	hal2_set_dac_rate(hal2);
-	/* Set endianess */
+	/* Set endianness */
 	hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECTX);
 	/* Set DMA bus */
 	hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr));
@@ -413,7 +413,7 @@ static void hal2_setup_adc(struct snd_hal2 *hal2)
 	hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECR);
 	/* Setup the HAL2 for record */
 	hal2_set_adc_rate(hal2);
-	/* Set endianess */
+	/* Set endianness */
 	hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECR);
 	/* Set DMA bus */
 	hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr));
Signature · 1 line
2.15.0
Applied
#3 lore raw

Re: [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create()

In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 18:34:04 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi