Re: [PATCH v4] usb: gadget: f_mass_storage: stop thread in bind failure case

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

 



On Wed, Jul 22 2015, Sanjay Singh Rawat wrote:
> After the worker thread is launched, bind function is doing further
> configuration. In case of failure stop the thread.
>
> Signed-off-by: Sanjay Singh Rawat <snjsrwt@xxxxxxxxx>

Sorry for the delay.

Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>

> ---
>
> history:
>
> v3: - handled Michal's comment; used existing function to change state and
>       exit thread.
>     - tested for f_mass_storage.c only; dropped patches for legacy.
>
> v2: - Handled review comment from Michal.
>       - Merged v2 patch-2/3/4 to make patch-2.
>     - Added acked-by from Michal to patch-1.
>
> v1: - Handled review comments from Michal.
>       - updated patch-2 : added thread wake in legacy client of function (patch-2).
>       - added patch-4 : freeing file-storage thread in configuration error case.
>         - added patch-3 (needed by patch-4) : moved fsg_common structure to header
>           file, as code is dereferencing common->thread_task.
> ---
>  drivers/usb/gadget/function/f_mass_storage.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
> index f936268..c5b3db5 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -3080,7 +3080,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
>  	/* New interface */
>  	i = usb_interface_id(c, f);
>  	if (i < 0)
> -		return i;
> +		goto fail;
>  	fsg_intf_desc.bInterfaceNumber = i;
>  	fsg->interface_number = i;
>  
> @@ -3123,7 +3123,14 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
>  
>  autoconf_fail:
>  	ERROR(fsg, "unable to autoconfigure all endpoints\n");
> -	return -ENOTSUPP;
> +	i = -ENOTSUPP;
> +fail:
> +	/* terminate the thread */
> +	if (fsg->common->state != FSG_STATE_TERMINATED) {
> +		raise_exception(fsg->common, FSG_STATE_EXIT);
> +		wait_for_completion(&fsg->common->thread_notifier);
> +	}
> +	return i;
>  }
>  
>  /****************************** ALLOCATE FUNCTION *************************/
> -- 
> 1.9.1
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux