On 06/21/2018 11:28 PM, Matthew Wilcox wrote:
> Simpler and shorter code.
> 
> Signed-off-by: Matthew Wilcox <[email protected]>
> ---
[...]>  {
> -     int rc;
> -
> -     do {
> -             if (!ida_pre_get(&dma_ida, GFP_KERNEL))
> -                     return -ENOMEM;
> -             mutex_lock(&dma_list_mutex);
> -             rc = ida_get_new(&dma_ida, &device->dev_id);
> -             mutex_unlock(&dma_list_mutex);
> -     } while (rc == -EAGAIN);
> +     int rc = ida_alloc(&dma_ida, GFP_KERNEL);
>  
> +     if (rc >= 0)
> +             device->dev_id = rc;
>       return rc;

This used to return 0 on success, now it returns the ID. That wont work
considering that it is used like this

    rc = get_dma_id(device);
    if (rc != 0) ...


>  }
>  
> @@ -1090,9 +1082,7 @@ int dma_async_device_register(struct dma_device *device)
>  err_out:
>       /* if we never registered a channel just release the idr */
>       if (atomic_read(idr_ref) == 0) {
> -             mutex_lock(&dma_list_mutex);
> -             ida_remove(&dma_ida, device->dev_id);
> -             mutex_unlock(&dma_list_mutex);
> +             ida_free(&dma_ida, device->dev_id);
>               kfree(idr_ref);
>               return rc;
>       }
> 

Reply via email to