ALSA: hal2: Fine-tuning for four function implementations
Subsystems (2)
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
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
@@ -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
PATCH 2/3 ALSA: hal2: Improve a size determination in hal2_create()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 ALSA: hal2: Fix a typo in two comment lines
In reply to SF Markus ElfringFrom: 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
@@ -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
Takashi Iwai
AppliedRe: [PATCH 2/3] ALSA: hal2: Improve a size determination in hal2_create()
In reply to SF Markus ElfringQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 11 Nov 2017 18:34:04 +0100Replace 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 <[email protected]>
Applied, thanks.
Takashi