Instead of the explicit "1 << x", use BIT() macro for one bit values.
This will improve the readability and also avoids the possible bad
value for 31bit shift.
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
sound/usb/format.c | 17 +++++++----------
sound/usb/mixer.c | 38 +++++++++++++++++++-------------------
sound/usb/mixer_quirks.c | 20 ++++++++++----------
3 files changed, 36 insertions(+), 39 deletions(-)
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 3b45d0ee7693..1bb6a455a1b4 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -82,13 +82,13 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
fp->fmt_bits = sample_width;
if ((pcm_formats == 0) &&
- (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) {
+ (format == 0 || format == BIT(UAC_FORMAT_TYPE_I_UNDEFINED))) {
/* some devices don't define this correctly... */
usb_audio_info(chip, "%u:%d : format type 0 is detected, processed as PCM\n",
fp->iface, fp->altsetting);
- format = 1 << UAC_FORMAT_TYPE_I_PCM;
+ format = BIT(UAC_FORMAT_TYPE_I_PCM);
}
- if (format & (1 << UAC_FORMAT_TYPE_I_PCM)) {
+ if (format & BIT(UAC_FORMAT_TYPE_I_PCM)) {
if (((chip->usb_id == USB_ID(0x0582, 0x0016)) ||
/* Edirol SD-90 */
(chip->usb_id == USB_ID(0x0582, 0x000c))) &&
@@ -128,7 +128,7 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
break;
}
}
- if (format & (1 << UAC_FORMAT_TYPE_I_PCM8)) {
+ if (format & BIT(UAC_FORMAT_TYPE_I_PCM8)) {
/* Dallas DS4201 workaround: it advertises U8 format, but really
supports S8. */
if (chip->usb_id == USB_ID(0x04fa, 0x4201))
@@ -136,15 +136,12 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
else
pcm_formats |= SNDRV_PCM_FMTBIT_U8;
}
- if (format & (1 << UAC_FORMAT_TYPE_I_IEEE_FLOAT)) {
+ if (format & BIT(UAC_FORMAT_TYPE_I_IEEE_FLOAT))
pcm_formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
- }
- if (format & (1 << UAC_FORMAT_TYPE_I_ALAW)) {
+ if (format & BIT(UAC_FORMAT_TYPE_I_ALAW))
pcm_formats |= SNDRV_PCM_FMTBIT_A_LAW;
- }
- if (format & (1 << UAC_FORMAT_TYPE_I_MULAW)) {
+ if (format & BIT(UAC_FORMAT_TYPE_I_MULAW))
pcm_formats |= SNDRV_PCM_FMTBIT_MU_LAW;
- }
if (format & ~0x3f) {
usb_audio_info(chip,
"%u:%d : unsupported format bits %#llx\n",
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index fd6b94b3b638..c00009b545c0 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -433,7 +433,7 @@ int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
{
int err;
- if (cval->cached & (1 << channel)) {
+ if (cval->cached & BIT(channel)) {
*value = cval->cache_val[index];
return 0;
}
@@ -445,7 +445,7 @@ int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
cval->control, channel, err);
return err;
}
- cval->cached |= 1 << channel;
+ cval->cached |= BIT(channel);
cval->cache_val[index] = *value;
return 0;
}
@@ -522,7 +522,7 @@ int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
int err;
unsigned int read_only = (channel == 0) ?
cval->master_readonly :
- cval->ch_readonly & (1 << (channel - 1));
+ cval->ch_readonly & BIT(channel - 1);
if (read_only) {
usb_audio_dbg(cval->head.mixer->chip,
@@ -536,7 +536,7 @@ int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
value);
if (err < 0)
return err;
- cval->cached |= 1 << channel;
+ cval->cached |= BIT(channel);
cval->cache_val[index] = value;
return 0;
}
@@ -1253,7 +1253,7 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
int minchn = 0;
if (cval->cmask) {
for (i = 0; i < MAX_CHANNELS; i++)
- if (cval->cmask & (1 << i)) {
+ if (cval->cmask & BIT(i)) {
minchn = i + 1;
break;
}
@@ -1358,7 +1358,7 @@ static int get_min_max_with_quirks(struct usb_mixer_elem_info *cval,
} else {
idx = 0;
for (i = 0; i < MAX_CHANNELS; i++) {
- if (cval->cmask & (1 << i)) {
+ if (cval->cmask & BIT(i)) {
init_cur_mix_raw(cval, i + 1, idx);
idx++;
}
@@ -1416,7 +1416,7 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol,
if (cval->cmask) {
cnt = 0;
for (c = 0; c < MAX_CHANNELS; c++) {
- if (!(cval->cmask & (1 << c)))
+ if (!(cval->cmask & BIT(c)))
continue;
err = snd_usb_get_cur_mix_value(cval, c + 1, cnt, &val);
if (err < 0)
@@ -1448,7 +1448,7 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol,
if (cval->cmask) {
cnt = 0;
for (c = 0; c < MAX_CHANNELS; c++) {
- if (!(cval->cmask & (1 << c)))
+ if (!(cval->cmask & BIT(c)))
continue;
err = snd_usb_get_cur_mix_value(cval, c + 1, cnt, &oval);
if (err < 0)
@@ -1700,7 +1700,7 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
} else {
int i, c = 0;
for (i = 0; i < 16; i++)
- if (ctl_mask & (1 << i))
+ if (ctl_mask & BIT(i))
c++;
cval->channels = c;
cval->ch_readonly = readonly_mask;
@@ -2060,8 +2060,8 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
mask = snd_usb_combine_bytes(bmaControls +
csize * (j+1), csize);
- if (mask & (1 << i))
- ch_bits |= (1 << j);
+ if (mask & BIT(i))
+ ch_bits |= BIT(j);
}
/* audio class v1 controls are never read-only */
@@ -2072,7 +2072,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
if (ch_bits & 1)
build_feature_ctl(state, _ftr, ch_bits, control,
&iterm, unitid, 0);
- if (master_bits & (1 << i))
+ if (master_bits & BIT(i))
build_feature_ctl(state, _ftr, 0, control,
&iterm, unitid, 0);
}
@@ -2088,9 +2088,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
mask = snd_usb_combine_bytes(bmaControls +
csize * (j+1), csize);
if (uac_v2v3_control_is_readable(mask, control)) {
- ch_bits |= (1 << j);
+ ch_bits |= BIT(j);
if (!uac_v2v3_control_is_writeable(mask, control))
- ch_read_only |= (1 << j);
+ ch_read_only |= BIT(j);
}
}
@@ -2181,7 +2181,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
__u8 *c = uac_mixer_unit_bmControls(desc, state->mixer->protocol);
if (check_matrix_bitmap(c, in_ch, i, num_outs)) {
- cval->cmask |= (1 << i);
+ cval->cmask |= BIT(i);
cval->channels++;
}
}
@@ -2504,7 +2504,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
if (state->mixer->protocol == UAC_VERSION_1) {
if (!(controls[valinfo->control / 8] &
- (1 << ((valinfo->control % 8) - 1))))
+ BIT((valinfo->control % 8) - 1)))
continue;
} else { /* UAC_VERSION_2/3 */
if (!uac_v2v3_control_is_readable(controls[valinfo->control / 8],
@@ -3448,7 +3448,7 @@ static void snd_usb_mixer_interrupt_v2(struct usb_mixer_interface *mixer,
case UAC2_CS_CUR:
/* invalidate cache, so the value is read from the device */
if (channel)
- info->cached &= ~(1 << channel);
+ info->cached &= ~BIT(channel);
else /* master channel */
info->cached = 0;
@@ -3684,9 +3684,9 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list)
if (cval->cmask) {
idx = 0;
for (c = 0; c < MAX_CHANNELS; c++) {
- if (!(cval->cmask & (1 << c)))
+ if (!(cval->cmask & BIT(c)))
continue;
- if (cval->cached & (1 << (c + 1))) {
+ if (cval->cached & BIT(c + 1)) {
err = snd_usb_set_cur_mix_value(cval, c + 1, idx,
cval->cache_val[idx]);
if (err < 0)
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 212b5e6443d8..2bc344cf54a8 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -1139,7 +1139,7 @@ static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
for (out = 0; out < 8; out++) {
control = out + 1;
for (in = 0; in < 8; in++) {
- cmask = 1 << in;
+ cmask = BIT(in);
snprintf(name, sizeof(name),
"AIn%d - Out%d Capture Volume",
in + 1, out + 1);
@@ -1150,7 +1150,7 @@ static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer)
return err;
}
for (in = 8; in < 16; in++) {
- cmask = 1 << in;
+ cmask = BIT(in);
snprintf(name, sizeof(name),
"DIn%d - Out%d Playback Volume",
in - 7, out + 1);
@@ -1215,7 +1215,7 @@ static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer)
const unsigned int control = 7;
for (ch = 0; ch < 4; ++ch) {
- cmask = 1 << ch;
+ cmask = BIT(ch);
snprintf(name, sizeof(name),
"Effect Return %d Volume", ch + 1);
err = snd_create_std_mono_ctl(mixer, id, control,
@@ -1239,7 +1239,7 @@ static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
const unsigned int control = 9;
for (ch = 0; ch < 8; ++ch) {
- cmask = 1 << ch;
+ cmask = BIT(ch);
snprintf(name, sizeof(name),
"Effect Send AIn%d Volume", ch + 1);
err = snd_create_std_mono_ctl(mixer, id, control, cmask,
@@ -1249,7 +1249,7 @@ static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer)
return err;
}
for (ch = 8; ch < 16; ++ch) {
- cmask = 1 << ch;
+ cmask = BIT(ch);
snprintf(name, sizeof(name),
"Effect Send DIn%d Volume", ch - 7);
err = snd_create_std_mono_ctl(mixer, id, control, cmask,
@@ -1352,7 +1352,7 @@ static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer)
chan - num_outs + 1, out + 1);
}
- cmask = (out == 0) ? 0 : 1 << (out - 1);
+ cmask = (out == 0) ? 0 : BIT(out - 1);
offset = chan * num_outs;
err = snd_create_std_mono_ctl_offset(mixer, id, control,
cmask, val_type, offset, name,
@@ -1438,7 +1438,7 @@ static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer)
chan - num_outs + 1);
}
- cmask = (chan == 0) ? 0 : 1 << (chan - 1);
+ cmask = (chan == 0) ? 0 : BIT(chan - 1);
err = snd_create_std_mono_ctl(mixer, id, control,
cmask, val_type, name,
&snd_usb_mixer_vol_tlv);
@@ -1480,7 +1480,7 @@ static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer
chan + 1);
cmask = (chan == 0) ? 0 :
- 1 << (chan + (chan % 2) * num_outs - 1);
+ BIT(chan + (chan % 2) * num_outs - 1);
err = snd_create_std_mono_ctl_offset(mixer, id, control,
cmask, val_type, offset, name,
&snd_usb_mixer_vol_tlv);
@@ -2568,12 +2568,12 @@ static int snd_bbfpro_ctl_update(struct usb_mixer_interface *mixer, u8 reg,
usb_idx = 3;
usb_val = value ? 3 : 0;
} else {
- usb_idx = 1 << index;
+ usb_idx = BIT(index);
usb_val = value ? usb_idx : 0;
}
} else {
usb_req = SND_BBFPRO_USBREQ_CTL_REG2;
- usb_idx = 1 << index;
+ usb_idx = BIT(index);
usb_val = value ? usb_idx : 0;
}
--
2.43.0
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]