Skip to contentSkip to conversation

is_power_of_2-sound/pcm_params.h

PATCH New vignesh babu 1 participant 1 message Jun 14, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 is_power_of_2-sound/pcm_params.h

Replacing (n & (n-1)) in the context of power of 2 checks with is_power_of_2

---

include/sound/pcm_params.h +2 -1
index 85cf1cf..dee298e 100644
@@ -21,6 +21,7 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
  */
+#include <linux/log2.h>
 
 int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, 
 			   struct snd_pcm_hw_params *params,
@@ -170,7 +171,7 @@ static inline int snd_mask_single(const struct snd_mask *mask)
 	for (i = 0; i < SNDRV_MASK_SIZE; i++) {
 		if (! mask->bits[i])
 			continue;
-		if (mask->bits[i] & (mask->bits[i] - 1))
+		if (!is_power_of_2(mask->bits[i]))
 			return 0;
 		if (c)
 			return 0;
Signature · 3 lines
Vignesh Babu BM 
_____________________________________________________________ 
"Why is it that every time I'm with you, makes me believe in magic?"