diff options
Diffstat (limited to 'drivers/dma/dmaengine.c')
-rw-r--r-- | drivers/dma/dmaengine.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 6b535262ac5d..24e0221fd66d 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -65,7 +65,7 @@ | |||
65 | #include <linux/mempool.h> | 65 | #include <linux/mempool.h> |
66 | 66 | ||
67 | static DEFINE_MUTEX(dma_list_mutex); | 67 | static DEFINE_MUTEX(dma_list_mutex); |
68 | static DEFINE_IDR(dma_idr); | 68 | static DEFINE_IDA(dma_ida); |
69 | static LIST_HEAD(dma_device_list); | 69 | static LIST_HEAD(dma_device_list); |
70 | static long dmaengine_ref_count; | 70 | static long dmaengine_ref_count; |
71 | 71 | ||
@@ -162,7 +162,7 @@ static void chan_dev_release(struct device *dev) | |||
162 | chan_dev = container_of(dev, typeof(*chan_dev), device); | 162 | chan_dev = container_of(dev, typeof(*chan_dev), device); |
163 | if (atomic_dec_and_test(chan_dev->idr_ref)) { | 163 | if (atomic_dec_and_test(chan_dev->idr_ref)) { |
164 | mutex_lock(&dma_list_mutex); | 164 | mutex_lock(&dma_list_mutex); |
165 | idr_remove(&dma_idr, chan_dev->dev_id); | 165 | ida_remove(&dma_ida, chan_dev->dev_id); |
166 | mutex_unlock(&dma_list_mutex); | 166 | mutex_unlock(&dma_list_mutex); |
167 | kfree(chan_dev->idr_ref); | 167 | kfree(chan_dev->idr_ref); |
168 | } | 168 | } |
@@ -898,14 +898,15 @@ static int get_dma_id(struct dma_device *device) | |||
898 | { | 898 | { |
899 | int rc; | 899 | int rc; |
900 | 900 | ||
901 | mutex_lock(&dma_list_mutex); | 901 | do { |
902 | 902 | if (!ida_pre_get(&dma_ida, GFP_KERNEL)) | |
903 | rc = idr_alloc(&dma_idr, NULL, 0, 0, GFP_KERNEL); | 903 | return -ENOMEM; |
904 | if (rc >= 0) | 904 | mutex_lock(&dma_list_mutex); |
905 | device->dev_id = rc; | 905 | rc = ida_get_new(&dma_ida, &device->dev_id); |
906 | mutex_unlock(&dma_list_mutex); | ||
907 | } while (rc == -EAGAIN); | ||
906 | 908 | ||
907 | mutex_unlock(&dma_list_mutex); | 909 | return rc; |
908 | return rc < 0 ? rc : 0; | ||
909 | } | 910 | } |
910 | 911 | ||
911 | /** | 912 | /** |
@@ -1035,7 +1036,7 @@ err_out: | |||
1035 | /* if we never registered a channel just release the idr */ | 1036 | /* if we never registered a channel just release the idr */ |
1036 | if (atomic_read(idr_ref) == 0) { | 1037 | if (atomic_read(idr_ref) == 0) { |
1037 | mutex_lock(&dma_list_mutex); | 1038 | mutex_lock(&dma_list_mutex); |
1038 | idr_remove(&dma_idr, device->dev_id); | 1039 | ida_remove(&dma_ida, device->dev_id); |
1039 | mutex_unlock(&dma_list_mutex); | 1040 | mutex_unlock(&dma_list_mutex); |
1040 | kfree(idr_ref); | 1041 | kfree(idr_ref); |
1041 | return rc; | 1042 | return rc; |