[alsa-devel] [PATCH 0/3] ALSA: hal2: Fine-tuning for four function implementations
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(-)
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)
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;
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
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));
participants (2)
-
SF Markus Elfring
-
Takashi Iwai