@@ -666,7 +666,7 @@ static int deliver_to_subscribers(struct snd_seq_client *client,
down_read(&grp->list_mutex);
list_for_each_entry(subs, &grp->list_head, src_list) {
/* both ports ready? */
- if (atomic_read(&subs->ref_count) != 2)
+ if (refcount_read(&subs->ref_count) != 2)
continue;
event->dest = subs->info.dest;
if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP)
@@ -241,7 +241,7 @@ static void clear_subscriber_list(struct snd_seq_client *client,
* we decrease the counter, and when both ports are deleted
* remove the subscriber info
*/
- if (atomic_dec_and_test(&subs->ref_count))
+ if (refcount_dec_and_test(&subs->ref_count))
kfree(subs);
continue;
}
@@ -520,7 +520,7 @@ static int check_and_subscribe_port(struct snd_seq_client *client,
else
list_add_tail(&subs->dest_list, &grp->list_head);
grp->exclusive = exclusive;
- atomic_inc(&subs->ref_count);
+ refcount_inc(&subs->ref_count);
write_unlock_irq(&grp->list_lock);
err = 0;
@@ -570,7 +570,7 @@ int snd_seq_port_connect(struct snd_seq_client *connector,
return -ENOMEM;
subs->info = *info;
- atomic_set(&subs->ref_count, 0);
+ refcount_set(&subs->ref_count, 0);
INIT_LIST_HEAD(&subs->src_list);
INIT_LIST_HEAD(&subs->dest_list);
@@ -613,7 +613,7 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector,
/* look for the connection */
list_for_each_entry(subs, &src->list_head, src_list) {
if (match_subs_info(info, &subs->info)) {
- atomic_dec(&subs->ref_count); /* mark as not ready */
+ refcount_dec(&subs->ref_count); /* mark as not ready */
err = 0;
break;
}
@@ -21,6 +21,7 @@
#ifndef __SND_SEQ_PORTS_H
#define __SND_SEQ_PORTS_H
+#include <linux/refcount.h>
#include <sound/seq_kernel.h>
#include "seq_lock.h"
@@ -44,7 +45,7 @@ struct snd_seq_subscribers {
struct snd_seq_port_subscribe info; /* additional info */
struct list_head src_list; /* link of sources */
struct list_head dest_list; /* link of destinations */
- atomic_t ref_count;
+ refcount_t ref_count;
};
struct snd_seq_port_subs_info {
@@ -378,7 +378,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
chip->setup = device_setup[idx];
chip->autoclock = autoclock;
atomic_set(&chip->active, 1); /* avoid autopm during probing */
- atomic_set(&chip->usage_count, 0);
+ refcount_set(&chip->usage_count, 0);
atomic_set(&chip->shutdown, 0);
chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
@@ -657,7 +657,7 @@ static void usb_audio_disconnect(struct usb_interface *intf)
* they are protected by snd_usb_lock_shutdown()
*/
wait_event(chip->shutdown_wait,
- !atomic_read(&chip->usage_count));
+ !refcount_read(&chip->usage_count));
snd_card_disconnect(card);
/* release the pcm resources */
list_for_each_entry(as, &chip->pcm_list, list) {
@@ -692,7 +692,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
{
int err;
- atomic_inc(&chip->usage_count);
+ refcount_inc(&chip->usage_count);
if (atomic_read(&chip->shutdown)) {
err = -EIO;
goto error;
@@ -703,7 +703,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
return 0;
error:
- if (atomic_dec_and_test(&chip->usage_count))
+ if (refcount_dec_and_test(&chip->usage_count))
wake_up(&chip->shutdown_wait);
return err;
}
@@ -712,7 +712,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
{
snd_usb_autosuspend(chip);
- if (atomic_dec_and_test(&chip->usage_count))
+ if (refcount_dec_and_test(&chip->usage_count))
wake_up(&chip->shutdown_wait);
}
@@ -26,6 +26,8 @@
#define USB_ID_VENDOR(id) ((id) >> 16)
#define USB_ID_PRODUCT(id) ((u16)(id))
+#include <linux/refcount.h>
+
/*
*
*/
@@ -40,7 +42,7 @@ struct snd_usb_audio {
unsigned int autosuspended:1;
atomic_t active;
atomic_t shutdown;
- atomic_t usage_count;
+ refcount_t usage_count;
wait_queue_head_t shutdown_wait;
unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */
unsigned int tx_length_quirk:1; /* Put length specifier in transfers */