linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations
@ 2017-11-11 18:10 SF Markus Elfring
  2017-11-11 18:11 ` [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-11-11 18:10 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Arvind Yadav, Bhumika Goyal,
	Jaroslav Kysela, Mark Brown, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.15.0

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

* [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe()
  2017-11-11 18:10 [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations SF Markus Elfring
@ 2017-11-11 18:11 ` SF Markus Elfring
  2017-11-11 18:13 ` [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create() SF Markus Elfring
  2017-11-11 18:15 ` [PATCH 3/3] ALSA: hal2: Fix a typo in two comment lines SF Markus Elfring
  2 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-11-11 18:11 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Arvind Yadav, Bhumika Goyal,
	Jaroslav Kysela, Mark Brown, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/mips/hal2.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 37d378a26a50..30563d9aa5c8 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -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)
-- 
2.15.0

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

* [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create()
  2017-11-11 18:10 [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations SF Markus Elfring
  2017-11-11 18:11 ` [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe() SF Markus Elfring
@ 2017-11-11 18:13 ` SF Markus Elfring
  2017-11-28  6:49   ` Takashi Iwai
  2017-11-11 18:15 ` [PATCH 3/3] ALSA: hal2: Fix a typo in two comment lines SF Markus Elfring
  2 siblings, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-11-11 18:13 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Arvind Yadav, Bhumika Goyal,
	Jaroslav Kysela, Mark Brown, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/mips/hal2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 30563d9aa5c8..675c3aba794e 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -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;
 
-- 
2.15.0

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

* [PATCH 3/3] ALSA: hal2: Fix a typo in two comment lines
  2017-11-11 18:10 [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations SF Markus Elfring
  2017-11-11 18:11 ` [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe() SF Markus Elfring
  2017-11-11 18:13 ` [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create() SF Markus Elfring
@ 2017-11-11 18:15 ` SF Markus Elfring
  2 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-11-11 18:15 UTC (permalink / raw)
  To: alsa-devel, Arnd Bergmann, Arvind Yadav, Bhumika Goyal,
	Jaroslav Kysela, Mark Brown, Takashi Iwai
  Cc: LKML, kernel-janitors, trivial

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 11 Nov 2017 18:48:41 +0100

Add a missing character in these descriptions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/mips/hal2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 675c3aba794e..4fa5f161ef2d 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -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));
-- 
2.15.0

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

* Re: [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create()
  2017-11-11 18:13 ` [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create() SF Markus Elfring
@ 2017-11-28  6:49   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-11-28  6:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Arnd Bergmann, Arvind Yadav, Bhumika Goyal,
	Mark Brown, Jaroslav Kysela, kernel-janitors, LKML

On Sat, 11 Nov 2017 19:13:15 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

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

end of thread, other threads:[~2017-11-28  6:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-11 18:10 [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations SF Markus Elfring
2017-11-11 18:11 ` [PATCH 1/3] ALSA: hal2: Use common error handling code in hal2_probe() SF Markus Elfring
2017-11-11 18:13 ` [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create() SF Markus Elfring
2017-11-28  6:49   ` Takashi Iwai
2017-11-11 18:15 ` [PATCH 3/3] ALSA: hal2: Fix a typo in two comment lines SF Markus Elfring

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