Re: [PATCH] staging: bcm2835-camera: Replace open-coded idr with a struct idr.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 10, 2018 at 04:31:07PM -0700, Eric Anholt wrote:
> @@ -258,32 +181,40 @@ get_msg_context(struct vchiq_mmal_instance *instance)
>  	if (!msg_context)
>  		return ERR_PTR(-ENOMEM);
>  
> -	msg_context->instance = instance;
> -	msg_context->handle =
> -		mmal_context_map_create_handle(&instance->context_map,
> -					       msg_context,
> -					       GFP_KERNEL);
> +	/* Create an ID that will be passed along with our message so
> +	 * that when we service the VCHI reply, we can look up what
> +	 * message is being replied to.
> +	 */
> +	spin_lock(&instance->context_map_lock);
> +	handle = idr_alloc(&instance->context_map, msg_context,
> +			   0, 0, GFP_KERNEL);
> +	spin_unlock(&instance->context_map_lock);
>  
> -	if (!msg_context->handle) {
> +	if (msg_context->handle < 0) {

This should probably be testing:

	if (handle < 0) {

>  		kfree(msg_context);
> -		return ERR_PTR(-ENOMEM);
> +		return ERR_PTR(handle);
>  	}
>  
> +	msg_context->instance = instance;
> +	msg_context->handle = handle;
> +
>  	return msg_context;
>  }
>  

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux