snd-powermac: style awacs.s and awacs.h
PATCH 1/1 snd-powermac: style awacs.s and awacs.h
From: Risto Suominen <[email protected]>
Coding style corrections for awacs.c and awacs.h.
---
Kernel version 2.6.25-rc8 (probably any 2.6)
ppc/awacs.c renamed from ppc/awacs.c.orig +3 -3
@@ -141,7 +141,7 @@ static int snd_pmac_awacs_info_volume(st uinfo->value.integer.max =15 ;return 0 ; } - +static int snd_pmac_awacs_get_volume (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -267,7 +267,8 @@ static int snd_pmac_awacs_put_switch(strstatic void awacs_set_cuda (int reg,int val) {struct adb_request req; -cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , reg, val); +cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , + reg, val);while (! req.complete)cuda_poll (); }
@@ -289,11 +290,11 @@ static void awacs_amp_set_tone(struct aw/* * vol = 0 - 31 (attenuation), 32 = mute bit, stereo */ -static int awacs_amp_set_vol(struct awacs_amp *amp, int index, int
lvol, int rvol,
- int do_check)
+static int awacs_amp_set_vol(struct awacs_amp *amp, int index,
+ int lvol, int rvol, int do_check)
{
if (do_check && amp->amp_vol[index][0] == lvol &&
- amp->amp_vol[index][1] == rvol)
+ amp->amp_vol[index][1] == rvol)
return 0;
awacs_set_cuda(3 + index, lvol);
awacs_set_cuda(5 + index, rvol);
@@ -337,7 +338,7 @@ static int snd_pmac_awacs_info_volume_am
uinfo->value.integer.max = 31;
return 0;
}
-
+
static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -361,8 +362,10 @@ static int snd_pmac_awacs_put_volume_amp
snd_assert(amp, return -EINVAL);
snd_assert(index >= 0 && index <= 1, return -EINVAL);
- vol[0] = (31 - (ucontrol->value.integer.value[0] & 31)) |
(amp->amp_vol[index][0] & 32);
- vol[1] = (31 - (ucontrol->value.integer.value[1] & 31)) |
(amp->amp_vol[index][1] & 32);
+ vol[0] = (31 - (ucontrol->value.integer.value[0] & 31))
+ | (amp->amp_vol[index][0] & 32);
+ vol[1] = (31 - (ucontrol->value.integer.value[1] & 31))
+ | (amp->amp_vol[index][1] & 32);
return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1);
}
@@ -374,8 +377,10 @@ static int snd_pmac_awacs_get_switch_amp
struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL);
- ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) ? 0 : 1;
- ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32) ? 0 : 1;
+ ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32)
+ ? 0 : 1;
+ ucontrol->value.integer.value[1] = (amp->amp_vol[index][1] & 32)
+ ? 0 : 1;
return 0;
}
@@ -389,8 +394,10 @@ static int snd_pmac_awacs_put_switch_amp
snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL);
- vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32) |
(amp->amp_vol[index][0] & 31);
- vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32) |
(amp->amp_vol[index][1] & 31);
+ vol[0] = (ucontrol->value.integer.value[0] ? 0 : 32)
+ | (amp->amp_vol[index][0] & 31);
+ vol[1] = (ucontrol->value.integer.value[1] ? 0 : 32)
+ | (amp->amp_vol[index][1] & 31);
return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1);
}
@@ -403,7 +410,7 @@ static int snd_pmac_awacs_info_tone_amp(
uinfo->value.integer.max = 14;
return 0;
}
-
+
static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -445,7 +452,7 @@ static int snd_pmac_awacs_info_master_am
uinfo->value.integer.max = 99;
return 0;
}
-
+
static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -688,12 +694,14 @@ static struct snd_kcontrol_new snd_pmac_
/*
* add new mixer elements to the card
*/
-static int build_mixers(struct snd_pmac *chip, int nums, struct snd_kcontrol_new *mixers)
+static int build_mixers(struct snd_pmac *chip, int nums,
+ struct snd_kcontrol_new *mixers)
{
int i, err;
for (i = 0; i < nums; i++) {
- if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip))) < 0)
+ if ((err = snd_ctl_add(chip->card,
+ snd_ctl_new1(&mixers[i], chip))) < 0)
return err;
}
return 0;
@@ -743,8 +752,10 @@ static void snd_pmac_awacs_resume(struct
#ifdef PMAC_AMP_AVAIL
if (chip->mixer_data) {
struct awacs_amp *amp = chip->mixer_data;
- awacs_amp_set_vol(amp, 0, amp->amp_vol[0][0], amp->amp_vol[0][1], 0);
- awacs_amp_set_vol(amp, 1, amp->amp_vol[1][0], amp->amp_vol[1][1], 0);
+ awacs_amp_set_vol(amp, 0,
+ amp->amp_vol[0][0], amp->amp_vol[0][1], 0);
+ awacs_amp_set_vol(amp, 1,
+ amp->amp_vol[1][0], amp->amp_vol[1][1], 0);
awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); awacs_amp_set_master(amp, amp->amp_master);
}
@@ -849,7 +860,7 @@ snd_pmac_awacs_init(struct snd_pmac *chi
chip->awacs_reg[1] = MASK_CMUTE | MASK_AMUTE;
/* FIXME: Only machines with external SRS module need MASK_PAROUT */ if (chip->has_iic || chip->device_id == 0x5 ||
- /*chip->_device_id == 0x8 || */ + /* chip->_device_id == 0x8 || */
chip->device_id == 0xb)
chip->awacs_reg[1] |= MASK_PAROUT;
/* get default volume from nvram */
@@ -860,8 +871,10 @@ snd_pmac_awacs_init(struct snd_pmac *chi
chip->awacs_reg[2] = vol; chip->awacs_reg[4] = vol;
if (chip->model == PMAC_SCREAMER) {
- chip->awacs_reg[5] = vol; /* FIXME: screamer has loopthru vol control */
- chip->awacs_reg[6] = MASK_MIC_BOOST; /* FIXME: maybe should be vol
<< 3 for PCMCIA speaker */
+ /* FIXME: screamer has loopthru vol control */
+ chip->awacs_reg[5] = vol;
+ /* FIXME: maybe should be vol << 3 for PCMCIA speaker */
+ chip->awacs_reg[6] = MASK_MIC_BOOST;
chip->awacs_reg[7] = 0;
}
@@ -877,7 +890,8 @@ snd_pmac_awacs_init(struct snd_pmac *chi
return -ENOMEM;
chip->mixer_data = amp;
chip->mixer_free = awacs_amp_free;
- awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */
+ /* mute and zero vol */
+ awacs_amp_set_vol(amp, 0, 63, 63, 0);
awacs_amp_set_vol(amp, 1, 63, 63, 0); awacs_amp_set_tone(amp, 7, 7); /* 0 dB */ awacs_amp_set_master(amp, 79); /* 0 dB */
@@ -965,21 +979,25 @@ snd_pmac_awacs_init(struct snd_pmac *chi
* screamer registers.
* in this case, it seems the route C is not used. */
- if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_amp_vol),
+ if ((err = build_mixers(chip,
+ ARRAY_SIZE(snd_pmac_awacs_amp_vol),
snd_pmac_awacs_amp_vol)) < 0)
return err;
/* overwrite */
- chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw, chip);
+ chip->master_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_hp_sw,
+ chip);
if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0)
return err;
- chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw, chip);
+ chip->speaker_sw_ctl = snd_ctl_new1(&snd_pmac_awacs_amp_spk_sw,
+ chip);
if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0)
return err;
} else
#endif /* PMAC_AMP_AVAIL */
{
/* route A = headphone, route C = speaker */
- if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_speaker_vol),
+ if ((err = build_mixers(chip,
+ ARRAY_SIZE(snd_pmac_awacs_speaker_vol),
snd_pmac_awacs_speaker_vol)) < 0)
return err;
chip->speaker_sw_ctl = snd_ctl_new1(imac
@@ -1010,8 +1028,9 @@ snd_pmac_awacs_init(struct snd_pmac *chi
snd_pmac_awacs_mic_boost_pmac7500)) < 0)
return err;
} else {
- if ((err = build_mixers(chip, ARRAY_SIZE(snd_pmac_awacs_mic_boost),
- snd_pmac_awacs_mic_boost)) < 0)
+ if ((err = build_mixers(chip,
+ ARRAY_SIZE(snd_pmac_awacs_mic_boost),
+ snd_pmac_awacs_mic_boost)) < 0)
return err;
}
ppc/awacs.h renamed from ppc/awacs.h.orig +2 -1
@@ -175,7 +175,8 @@ struct awacs_regs {/* DBDMA ChannelStatus Bit Masks */ /* ----- ------------- --- ----- */ #define MASK_CSERR (0x1 << 7)/* Error */ -#define MASK_EOI (0x1 << 6)/* End of Input -- only for Input Channel */ +#define MASK_EOI (0x1 << 6)/* End of Input -- +only for Input Channel */ #define MASK_CSUNUSED (0x1f << 1)/* bits 1-5 not used */ #define MASK_WAIT (0x1)/* Wait */
At Wed, 16 Apr 2008 10:02:38 +0300,
Quoted 6 lines · Risto Suominen
From: Risto Suominen <[email protected]>
Coding style corrections for
awacs.candawacs.h.Signed-off-by Risto Suominen <[email protected]>
Hmm.. I get patch errors in 002b, 003a and 003b due to line folds. Could you resend? Attachments would be fine to me, too.
thanks,
Takashi
2008/4/16, Takashi Iwai <[email protected]>:
Quoted 4 lines
Hmm.. I get patch errors in 002b, 003a and 003b due to line folds.
Could you resend? Attachments would be fine to me, too.
Ok, let's try...
Risto
From: Risto Suominen <[email protected]>
Coding style corrections for awacs.c and awacs.h.
---
Kernel version 2.6.25-rc8 (probably any 2.6)
ppc/awacs.c renamed from ppc/awacs.c.orig +47 -28
@@ -141,7 +141,7 @@ static int snd_pmac_awacs_info_volume(st uinfo->value.integer.max =15 ;return 0 ; } - +static int snd_pmac_awacs_get_volume (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -267,7 +267,8 @@ static int snd_pmac_awacs_put_switch(strstatic void awacs_set_cuda (int reg,int val) {struct adb_request req; -cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , reg, val); +cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , + reg, val);while (! req.complete)cuda_poll (); }
@@ -289,11 +290,11 @@ static void awacs_amp_set_tone(struct aw/* * vol = 0 - 31 (attenuation), 32 = mute bit, stereo */ -static int awacs_amp_set_vol (struct awacs_amp *amp,int index,int lvol,int rvol, -int do_check) +static int awacs_amp_set_vol (struct awacs_amp *amp,int index, +int lvol,int rvol,int do_check) {if (do_check && amp->amp_vol[index][0 ] == lvol && - amp->amp_vol[index][1 ] == rvol) + amp->amp_vol[index][1 ] == rvol)return 0 ;awacs_set_cuda (3 + index, lvol);awacs_set_cuda (5 + index, rvol);
@@ -337,7 +338,7 @@ static int snd_pmac_awacs_info_volume_am uinfo->value.integer.max =31 ;return 0 ; } - +static int snd_pmac_awacs_get_volume_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -361,8 +362,10 @@ static int snd_pmac_awacs_put_volume_ampsnd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - vol[0 ] = (31 - (ucontrol->value.integer.value[0 ] &31 )) | (amp->amp_vol[index][0 ] &32 ); - vol[1 ] = (31 - (ucontrol->value.integer.value[1 ] &31 )) | (amp->amp_vol[index][1 ] &32 ); + vol[0 ] = (31 - (ucontrol->value.integer.value[0 ] &31 )) + | (amp->amp_vol[index][0 ] &32 ); + vol[1 ] = (31 - (ucontrol->value.integer.value[1 ] &31 )) + | (amp->amp_vol[index][1 ] &32 );return awacs_amp_set_vol (amp, index, vol[0 ], vol[1 ],1 ); }
@@ -374,8 +377,10 @@ static int snd_pmac_awacs_get_switch_ampstruct awacs_amp *amp = chip->mixer_data;snd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - ucontrol->value.integer.value[0 ] = (amp->amp_vol[index][0 ] &32 ) ?0 :1 ; - ucontrol->value.integer.value[1 ] = (amp->amp_vol[index][1 ] &32 ) ?0 :1 ; + ucontrol->value.integer.value[0 ] = (amp->amp_vol[index][0 ] &32 ) + ?0 :1 ; + ucontrol->value.integer.value[1 ] = (amp->amp_vol[index][1 ] &32 ) + ?0 :1 ;return 0 ; }
@@ -389,8 +394,10 @@ static int snd_pmac_awacs_put_switch_ampsnd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - vol[0 ] = (ucontrol->value.integer.value[0 ] ?0 :32 ) | (amp->amp_vol[index][0 ] &31 ); - vol[1 ] = (ucontrol->value.integer.value[1 ] ?0 :32 ) | (amp->amp_vol[index][1 ] &31 ); + vol[0 ] = (ucontrol->value.integer.value[0 ] ?0 :32 ) + | (amp->amp_vol[index][0 ] &31 ); + vol[1 ] = (ucontrol->value.integer.value[1 ] ?0 :32 ) + | (amp->amp_vol[index][1 ] &31 );return awacs_amp_set_vol (amp, index, vol[0 ], vol[1 ],1 ); }
@@ -403,7 +410,7 @@ static int snd_pmac_awacs_info_tone_amp( uinfo->value.integer.max =14 ;return 0 ; } - +static int snd_pmac_awacs_get_tone_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -445,7 +452,7 @@ static int snd_pmac_awacs_info_master_am uinfo->value.integer.max =99 ;return 0 ; } - +static int snd_pmac_awacs_get_master_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -688,12 +694,14 @@ static struct snd_kcontrol_new snd_pmac_/* * add new mixer elements to the card */ -static int build_mixers (struct snd_pmac *chip,int nums,struct snd_kcontrol_new *mixers) +static int build_mixers (struct snd_pmac *chip,int nums, +struct snd_kcontrol_new *mixers) {int i, err;for (i =0 ; i < nums; i++) { -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixers[i], chip))) <0 ) +if ((err =snd_ctl_add (chip->card, +snd_ctl_new1 (&mixers[i], chip))) <0 )return err; }return 0 ;
@@ -743,8 +752,10 @@ static void snd_pmac_awacs_resume(struct#ifdef PMAC_AMP_AVAIL if (chip->mixer_data) {struct awacs_amp *amp = chip->mixer_data; -awacs_amp_set_vol (amp,0 , amp->amp_vol[0 ][0 ], amp->amp_vol[0 ][1 ],0 ); -awacs_amp_set_vol (amp,1 , amp->amp_vol[1 ][0 ], amp->amp_vol[1 ][1 ],0 ); +awacs_amp_set_vol (amp,0 , + amp->amp_vol[0 ][0 ], amp->amp_vol[0 ][1 ],0 ); +awacs_amp_set_vol (amp,1 , + amp->amp_vol[1 ][0 ], amp->amp_vol[1 ][1 ],0 );awacs_amp_set_tone (amp, amp->amp_tone[0 ], amp->amp_tone[1 ]);awacs_amp_set_master (amp, amp->amp_master); }
@@ -849,7 +860,7 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->awacs_reg[1 ] =MASK_CMUTE |MASK_AMUTE ;/* FIXME: Only machines with external SRS module need MASK_PAROUT */ if (chip->has_iic || chip->device_id ==0x5 || -/*chip->_device_id == 0x8 || */ +/* chip->_device_id == 0x8 || */ chip->device_id ==0xb ) chip->awacs_reg[1 ] |=MASK_PAROUT ;/* get default volume from nvram */
@@ -860,8 +871,10 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->awacs_reg[2 ] = vol; chip->awacs_reg[4 ] = vol;if (chip->model ==PMAC_SCREAMER ) { - chip->awacs_reg[5 ] = vol;/* FIXME: screamer has loopthru vol control */ - chip->awacs_reg[6 ] =MASK_MIC_BOOST ;/* FIXME: maybe should be vol << 3 for PCMCIA speaker */ +/* FIXME: screamer has loopthru vol control */ + chip->awacs_reg[5 ] = vol; +/* FIXME: maybe should be vol << 3 for PCMCIA speaker */ + chip->awacs_reg[6 ] =MASK_MIC_BOOST ; chip->awacs_reg[7 ] =0 ; }
@@ -877,7 +890,8 @@ snd_pmac_awacs_init(struct snd_pmac *chireturn -ENOMEM ; chip->mixer_data = amp; chip->mixer_free = awacs_amp_free; -awacs_amp_set_vol (amp,0 ,63 ,63 ,0 );/* mute and zero vol */ +/* mute and zero vol */ +awacs_amp_set_vol (amp,0 ,63 ,63 ,0 );awacs_amp_set_vol (amp,1 ,63 ,63 ,0 );awacs_amp_set_tone (amp,7 ,7 );/* 0 dB */ awacs_amp_set_master (amp,79 );/* 0 dB */
@@ -965,21 +979,25 @@ snd_pmac_awacs_init(struct snd_pmac *chi* screamer registers. * in this case, it seems the route C is not used. */ -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_amp_vol), +if ((err =build_mixers (chip, +ARRAY_SIZE (snd_pmac_awacs_amp_vol), snd_pmac_awacs_amp_vol)) <0 )return err;/* overwrite */ - chip->master_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_hp_sw, chip); + chip->master_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_hp_sw, + chip);if ((err =snd_ctl_add (chip->card, chip->master_sw_ctl)) <0 )return err; - chip->speaker_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_spk_sw, chip); + chip->speaker_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_spk_sw, + chip);if ((err =snd_ctl_add (chip->card, chip->speaker_sw_ctl)) <0 )return err; } else#endif /* PMAC_AMP_AVAIL */ {/* route A = headphone, route C = speaker */ -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_speaker_vol), +if ((err =build_mixers (chip, +ARRAY_SIZE (snd_pmac_awacs_speaker_vol), snd_pmac_awacs_speaker_vol)) <0 )return err; chip->speaker_sw_ctl = snd_ctl_new1(imac
@@ -1010,8 +1028,9 @@ snd_pmac_awacs_init(struct snd_pmac *chi snd_pmac_awacs_mic_boost_pmac7500)) < 0)return err; }else { -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_mic_boost), - snd_pmac_awacs_mic_boost)) <0 ) +if ((err =build_mixers (chip, +ARRAY_SIZE (snd_pmac_awacs_mic_boost), + snd_pmac_awacs_mic_boost)) <0 )return err; }
ppc/awacs.h renamed from ppc/awacs.h.orig +2 -1
@@ -175,7 +175,8 @@ struct awacs_regs {/* DBDMA ChannelStatus Bit Masks */ /* ----- ------------- --- ----- */ #define MASK_CSERR (0x1 << 7)/* Error */ -#define MASK_EOI (0x1 << 6)/* End of Input -- only for Input Channel */ +#define MASK_EOI (0x1 << 6)/* End of Input -- +only for Input Channel */ #define MASK_CSUNUSED (0x1f << 1)/* bits 1-5 not used */ #define MASK_WAIT (0x1)/* Wait */
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Wed, 16 Apr 2008 13:35:42 +0300,
Quoted 8 lines · Risto Suominen
2008/4/16, Takashi Iwai <[email protected]>:
Quoted 4 lines
Hmm.. I get patch errors in 002b, 003a and 003b due to line folds.
Could you resend? Attachments would be fine to me, too.Ok, let's try...
Thanks, that works. But, I get checkpatch errors:
ERROR: do not use assignment in if condition
#116: FILE: ppc/awacs.c:704:
+ if ((err = snd_ctl_add(chip->card,
ERROR: do not use assignment in if condition
#171: FILE: ppc/awacs.c:982:
+ if ((err = build_mixers(chip,
ERROR: do not use assignment in if condition
#191: FILE: ppc/awacs.c:999:
+ if ((err = build_mixers(chip,
Please fix?
Takashi
2008/4/16, Takashi Iwai <[email protected]>:
Quoted 15 lines
Thanks, that works. But, I get checkpatch errors:
ERROR: do not use assignment in if condition
#116: FILE:ppc/awacs.c:704:+ if ((err = snd_ctl_add(chip->card,
ERROR: do not use assignment in if condition
#171: FILE:ppc/awacs.c:982:+ if ((err = build_mixers(chip,
Quoted 9 lines
ERROR: do not use assignment in if condition
#191: FILE:ppc/awacs.c:999:+ if ((err = build_mixers(chip,
Please fix?
I can do that but it will make the code much clumsier. Actually, I think this is checkpatch misunderstanding something. There is a '< 0' at the end of those conditions. Is it really this kind of assingment they want to forbid? This is the style there has been all the time.
Risto
At Wed, 16 Apr 2008 13:53:31 +0300,
Quoted 24 lines · Risto Suominen
2008/4/16, Takashi Iwai <[email protected]>:
Quoted 22 lines
Thanks, that works. But, I get checkpatch errors:
ERROR: do not use assignment in if condition
#116: FILE:ppc/awacs.c:704:+ if ((err = snd_ctl_add(chip->card,
ERROR: do not use assignment in if condition
#171: FILE:ppc/awacs.c:982:+ if ((err = build_mixers(chip,
ERROR: do not use assignment in if condition
#191: FILE:ppc/awacs.c:999:+ if ((err = build_mixers(chip,
Quoted 7 lines
Quoted 2 lines
Please fix?
I can do that but it will make the code much clumsier. Actually, I think this is checkpatch misunderstanding something. There is a '< 0' at the end of those conditions. Is it really this kind of assingment they want to forbid? This is the style there has been all the time.
The style "if ((err = xxx) < 0) ..." has been disliked by many people, and now it became to a style to be avoided. This should be simply
err = xxx; if (err < 0) ...
Takashi
checkpatch-clean version.
Risto
From: Risto Suominen <[email protected]>
Coding style corrections for awacs.c and awacs.h.
---
Kernel version 2.6.25-rc8 (probably any 2.6)
ppc/awacs.c renamed from ppc/awacs.c.orig +59 -35
@@ -141,7 +141,7 @@ static int snd_pmac_awacs_info_volume(st uinfo->value.integer.max =15 ;return 0 ; } - +static int snd_pmac_awacs_get_volume (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -267,7 +267,8 @@ static int snd_pmac_awacs_put_switch(strstatic void awacs_set_cuda (int reg,int val) {struct adb_request req; -cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , reg, val); +cuda_request (&req,NULL ,5 ,CUDA_PACKET ,CUDA_GET_SET_IIC ,0x8a , + reg, val);while (! req.complete)cuda_poll (); }
@@ -289,11 +290,11 @@ static void awacs_amp_set_tone(struct aw/* * vol = 0 - 31 (attenuation), 32 = mute bit, stereo */ -static int awacs_amp_set_vol (struct awacs_amp *amp,int index,int lvol,int rvol, -int do_check) +static int awacs_amp_set_vol (struct awacs_amp *amp,int index, +int lvol,int rvol,int do_check) {if (do_check && amp->amp_vol[index][0 ] == lvol && - amp->amp_vol[index][1 ] == rvol) + amp->amp_vol[index][1 ] == rvol)return 0 ;awacs_set_cuda (3 + index, lvol);awacs_set_cuda (5 + index, rvol);
@@ -337,7 +338,7 @@ static int snd_pmac_awacs_info_volume_am uinfo->value.integer.max =31 ;return 0 ; } - +static int snd_pmac_awacs_get_volume_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -361,8 +362,10 @@ static int snd_pmac_awacs_put_volume_ampsnd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - vol[0 ] = (31 - (ucontrol->value.integer.value[0 ] &31 )) | (amp->amp_vol[index][0 ] &32 ); - vol[1 ] = (31 - (ucontrol->value.integer.value[1 ] &31 )) | (amp->amp_vol[index][1 ] &32 ); + vol[0 ] = (31 - (ucontrol->value.integer.value[0 ] &31 )) + | (amp->amp_vol[index][0 ] &32 ); + vol[1 ] = (31 - (ucontrol->value.integer.value[1 ] &31 )) + | (amp->amp_vol[index][1 ] &32 );return awacs_amp_set_vol (amp, index, vol[0 ], vol[1 ],1 ); }
@@ -374,8 +377,10 @@ static int snd_pmac_awacs_get_switch_ampstruct awacs_amp *amp = chip->mixer_data;snd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - ucontrol->value.integer.value[0 ] = (amp->amp_vol[index][0 ] &32 ) ?0 :1 ; - ucontrol->value.integer.value[1 ] = (amp->amp_vol[index][1 ] &32 ) ?0 :1 ; + ucontrol->value.integer.value[0 ] = (amp->amp_vol[index][0 ] &32 ) + ?0 :1 ; + ucontrol->value.integer.value[1 ] = (amp->amp_vol[index][1 ] &32 ) + ?0 :1 ;return 0 ; }
@@ -389,8 +394,10 @@ static int snd_pmac_awacs_put_switch_ampsnd_assert (amp, return -EINVAL );snd_assert (index >=0 && index <=1 , return -EINVAL ); - vol[0 ] = (ucontrol->value.integer.value[0 ] ?0 :32 ) | (amp->amp_vol[index][0 ] &31 ); - vol[1 ] = (ucontrol->value.integer.value[1 ] ?0 :32 ) | (amp->amp_vol[index][1 ] &31 ); + vol[0 ] = (ucontrol->value.integer.value[0 ] ?0 :32 ) + | (amp->amp_vol[index][0 ] &31 ); + vol[1 ] = (ucontrol->value.integer.value[1 ] ?0 :32 ) + | (amp->amp_vol[index][1 ] &31 );return awacs_amp_set_vol (amp, index, vol[0 ], vol[1 ],1 ); }
@@ -403,7 +410,7 @@ static int snd_pmac_awacs_info_tone_amp( uinfo->value.integer.max =14 ;return 0 ; } - +static int snd_pmac_awacs_get_tone_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -445,7 +452,7 @@ static int snd_pmac_awacs_info_master_am uinfo->value.integer.max =99 ;return 0 ; } - +static int snd_pmac_awacs_get_master_amp (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -688,12 +695,14 @@ AWACS_SWITCH("PC Speaker Playback Switch/* * add new mixer elements to the card */ -static int build_mixers (struct snd_pmac *chip,int nums,struct snd_kcontrol_new *mixers) +static int build_mixers (struct snd_pmac *chip,int nums, +struct snd_kcontrol_new *mixers) {int i, err;for (i =0 ; i < nums; i++) { -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixers[i], chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixers[i], chip)); +if (err <0 )return err; }return 0 ;
@@ -743,8 +752,10 @@ static void snd_pmac_awacs_resume(struct#ifdef PMAC_AMP_AVAIL if (chip->mixer_data) {struct awacs_amp *amp = chip->mixer_data; -awacs_amp_set_vol (amp,0 , amp->amp_vol[0 ][0 ], amp->amp_vol[0 ][1 ],0 ); -awacs_amp_set_vol (amp,1 , amp->amp_vol[1 ][0 ], amp->amp_vol[1 ][1 ],0 ); +awacs_amp_set_vol (amp,0 , + amp->amp_vol[0 ][0 ], amp->amp_vol[0 ][1 ],0 ); +awacs_amp_set_vol (amp,1 , + amp->amp_vol[1 ][0 ], amp->amp_vol[1 ][1 ],0 );awacs_amp_set_tone (amp, amp->amp_tone[0 ], amp->amp_tone[1 ]);awacs_amp_set_master (amp, amp->amp_master); }
@@ -849,7 +860,7 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->awacs_reg[1 ] =MASK_CMUTE |MASK_AMUTE ;/* FIXME: Only machines with external SRS module need MASK_PAROUT */ if (chip->has_iic || chip->device_id ==0x5 || -/*chip->_device_id == 0x8 || */ +/* chip->_device_id == 0x8 || */ chip->device_id ==0xb ) chip->awacs_reg[1 ] |=MASK_PAROUT ;/* get default volume from nvram */
@@ -860,8 +871,10 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->awacs_reg[2 ] = vol; chip->awacs_reg[4 ] = vol;if (chip->model ==PMAC_SCREAMER ) { - chip->awacs_reg[5 ] = vol;/* FIXME: screamer has loopthru vol control */ - chip->awacs_reg[6 ] =MASK_MIC_BOOST ;/* FIXME: maybe should be vol << 3 for PCMCIA speaker */ +/* FIXME: screamer has loopthru vol control */ + chip->awacs_reg[5 ] = vol; +/* FIXME: maybe should be vol << 3 for PCMCIA speaker */ + chip->awacs_reg[6 ] =MASK_MIC_BOOST ; chip->awacs_reg[7 ] =0 ; }
@@ -877,7 +890,8 @@ snd_pmac_awacs_init(struct snd_pmac *chireturn -ENOMEM ; chip->mixer_data = amp; chip->mixer_free = awacs_amp_free; -awacs_amp_set_vol (amp,0 ,63 ,63 ,0 );/* mute and zero vol */ +/* mute and zero vol */ +awacs_amp_set_vol (amp,0 ,63 ,63 ,0 );awacs_amp_set_vol (amp,1 ,63 ,63 ,0 );awacs_amp_set_tone (amp,7 ,7 );/* 0 dB */ awacs_amp_set_master (amp,79 );/* 0 dB */
@@ -921,8 +935,9 @@ snd_pmac_awacs_init(struct snd_pmac *chi*/ strcpy (chip->card->mixername,"PowerMac AWACS" ); -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_mixers), - snd_pmac_awacs_mixers)) <0 ) + err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_mixers), + snd_pmac_awacs_mixers); +if (err <0 )return err;if (beige) ;
@@ -955,7 +970,8 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->master_sw_ctl =snd_ctl_new1 ((pm7500 || imac) ? &snd_pmac_awacs_master_sw_imac : &snd_pmac_awacs_master_sw, chip); -if ((err =snd_ctl_add (chip->card, chip->master_sw_ctl)) <0 ) + err =snd_ctl_add (chip->card, chip->master_sw_ctl); +if (err <0 )return err;#ifdef PMAC_AMP_AVAIL if (chip->mixer_data) {
@@ -965,27 +981,34 @@ snd_pmac_awacs_init(struct snd_pmac *chi* screamer registers. * in this case, it seems the route C is not used. */ -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_amp_vol), - snd_pmac_awacs_amp_vol)) <0 ) + err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_amp_vol), + snd_pmac_awacs_amp_vol); +if (err <0 )return err;/* overwrite */ - chip->master_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_hp_sw, chip); -if ((err =snd_ctl_add (chip->card, chip->master_sw_ctl)) <0 ) + chip->master_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_hp_sw, + chip); + err =snd_ctl_add (chip->card, chip->master_sw_ctl); +if (err <0 )return err; - chip->speaker_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_spk_sw, chip); -if ((err =snd_ctl_add (chip->card, chip->speaker_sw_ctl)) <0 ) + chip->speaker_sw_ctl =snd_ctl_new1 (&snd_pmac_awacs_amp_spk_sw, + chip); + err =snd_ctl_add (chip->card, chip->speaker_sw_ctl); +if (err <0 )return err; } else#endif /* PMAC_AMP_AVAIL */ {/* route A = headphone, route C = speaker */ -if ((err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_speaker_vol), - snd_pmac_awacs_speaker_vol)) <0 ) + err =build_mixers (chip,ARRAY_SIZE (snd_pmac_awacs_speaker_vol), + snd_pmac_awacs_speaker_vol); +if (err <0 )return err; chip->speaker_sw_ctl =snd_ctl_new1 (imac ? &snd_pmac_awacs_speaker_sw_imac : &snd_pmac_awacs_speaker_sw, chip); -if ((err =snd_ctl_add (chip->card, chip->speaker_sw_ctl)) <0 ) + err =snd_ctl_add (chip->card, chip->speaker_sw_ctl); +if (err <0 )return err; }
@@ -1020,7 +1043,8 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->resume = snd_pmac_awacs_resume;#endif #ifdef PMAC_SUPPORT_AUTOMUTE -if ((err =snd_pmac_add_automute (chip)) <0 ) + err =snd_pmac_add_automute (chip); +if (err <0 )return err; chip->detect_headphone = snd_pmac_awacs_detect_headphone; chip->update_automute = snd_pmac_awacs_update_automute;
ppc/awacs.h renamed from ppc/awacs.h.orig +3 -2
@@ -144,7 +144,7 @@ struct awacs_regs {#define VOLLEFT (x) (((~(x)) << 6) & MASK_OUTVOLLEFT)/* address 6 */ -#define MASK_MIC_BOOST (0x4)/* screamer mic boost */ +#define MASK_MIC_BOOST (0x4)/* screamer mic boost */ #define SHIFT_MIC_BOOST 2/* Audio Codec Status Reg Bit Masks */
@@ -175,7 +175,8 @@ struct awacs_regs {/* DBDMA ChannelStatus Bit Masks */ /* ----- ------------- --- ----- */ #define MASK_CSERR (0x1 << 7)/* Error */ -#define MASK_EOI (0x1 << 6)/* End of Input -- only for Input Channel */ +#define MASK_EOI (0x1 << 6)/* End of Input -- +only for Input Channel */ #define MASK_CSUNUSED (0x1f << 1)/* bits 1-5 not used */ #define MASK_WAIT (0x1)/* Wait */
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel