Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: Convert to new IDA API

Simpler and shorter code.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Acked-by: Vinod Koul <vkoul@kernel.org>

+7 -16
+7 -16
drivers/dma/dmaengine.c
··· 161 161 162 162 chan_dev = container_of(dev, typeof(*chan_dev), device); 163 163 if (atomic_dec_and_test(chan_dev->idr_ref)) { 164 - mutex_lock(&dma_list_mutex); 165 - ida_remove(&dma_ida, chan_dev->dev_id); 166 - mutex_unlock(&dma_list_mutex); 164 + ida_free(&dma_ida, chan_dev->dev_id); 167 165 kfree(chan_dev->idr_ref); 168 166 } 169 167 kfree(chan_dev); ··· 894 896 895 897 static int get_dma_id(struct dma_device *device) 896 898 { 897 - int rc; 899 + int rc = ida_alloc(&dma_ida, GFP_KERNEL); 898 900 899 - do { 900 - if (!ida_pre_get(&dma_ida, GFP_KERNEL)) 901 - return -ENOMEM; 902 - mutex_lock(&dma_list_mutex); 903 - rc = ida_get_new(&dma_ida, &device->dev_id); 904 - mutex_unlock(&dma_list_mutex); 905 - } while (rc == -EAGAIN); 906 - 907 - return rc; 901 + if (rc < 0) 902 + return rc; 903 + device->dev_id = rc; 904 + return 0; 908 905 } 909 906 910 907 /** ··· 1083 1090 err_out: 1084 1091 /* if we never registered a channel just release the idr */ 1085 1092 if (atomic_read(idr_ref) == 0) { 1086 - mutex_lock(&dma_list_mutex); 1087 - ida_remove(&dma_ida, device->dev_id); 1088 - mutex_unlock(&dma_list_mutex); 1093 + ida_free(&dma_ida, device->dev_id); 1089 1094 kfree(idr_ref); 1090 1095 return rc; 1091 1096 }