@@ -7,6 +7,7 @@
#include <linux/init.h>
#include <linux/delay.h>
+#include <linux/find_atomic.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/module.h>
@@ -3263,10 +3264,9 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
#ifdef CONFIG_SND_DYNAMIC_MINORS
/* non-fixed slots starting from 10 */
- for (i = 10; i < 32; i++) {
- if (!test_and_set_bit(i, bus->pcm_dev_bits))
- return i;
- }
+ i = find_and_set_next_bit(bus->pcm_dev_bits, 32, 10);
+ if (i < 32)
+ return i;
#endif
dev_warn(bus->card->dev, "Too many %s devices\n",
@@ -4,6 +4,7 @@
*/
#include <linux/device.h>
+#include <linux/find_atomic.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/init.h>
@@ -610,7 +611,7 @@ static void read_completed(struct urb *urb)
struct snd_usb_caiaq_cb_info *info = urb->context;
struct snd_usb_caiaqdev *cdev;
struct device *dev;
- struct urb *out = NULL;
+ struct urb *out;
int i, frame, len, send_it = 0, outframe = 0;
unsigned long flags;
size_t offset = 0;
@@ -625,17 +626,14 @@ static void read_completed(struct urb *urb)
return;
/* find an unused output urb that is unused */
- for (i = 0; i < N_URBS; i++)
- if (test_and_set_bit(i, &cdev->outurb_active_mask) == 0) {
- out = cdev->data_urbs_out[i];
- break;
- }
-
- if (!out) {
+ i = find_and_set_bit(&cdev->outurb_active_mask, N_URBS);
+ if (i >= N_URBS) {
dev_err(dev, "Unable to find an output urb to use\n");
goto requeue;
}
+ out = cdev->data_urbs_out[i];
+
/* read the recently received packet and send back one which has
* the same layout */
for (frame = 0; frame < FRAMES_PER_URB; frame++) {