Skip to content

Commit

Permalink
ALSA: sound: usbmidi: Use hweight16
Browse files Browse the repository at this point in the history
Use hweight16 instead of Brian Kernighan's/Peter Wegner's method

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
mita authored and tiwai committed Nov 20, 2009
1 parent d867bba commit fbc5439
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions sound/usb/usbmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,15 +1062,6 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi,
return 0;
}

static unsigned int snd_usbmidi_count_bits(unsigned int x)
{
unsigned int bits;

for (bits = 0; x; ++bits)
x &= x - 1;
return bits;
}

/*
* Frees an output endpoint.
* May be called when ep hasn't been initialized completely.
Expand Down Expand Up @@ -1914,8 +1905,8 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
out_ports = 0;
in_ports = 0;
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
out_ports += snd_usbmidi_count_bits(endpoints[i].out_cables);
in_ports += snd_usbmidi_count_bits(endpoints[i].in_cables);
out_ports += hweight16(endpoints[i].out_cables);
in_ports += hweight16(endpoints[i].in_cables);
}
err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports);
if (err < 0) {
Expand Down

0 comments on commit fbc5439

Please sign in to comment.