Re: [PATCH 12/16] usb/gadget: FunctionFS: add devices management code

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

 



On Wed, Oct 23 2013, Andrzej Pietrasiewicz wrote:
> This will be required in order to use the new function interface
> (usb_get_function_instance/usb_put_function_instance)
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
> Signed-off-by: Kyunmgin Park <kyungmin.park@xxxxxxxxxxx>
> ---
>  drivers/usb/gadget/f_fs.c  |   41 ++++++++++++++++++++++++++++++++++++
>  drivers/usb/gadget/g_ffs.c |   50 ++++++++++++++++++++++++++-----------------
>  drivers/usb/gadget/u_fs.h  |    2 +
>  3 files changed, 73 insertions(+), 20 deletions(-)

> @@ -175,35 +175,49 @@ static DEFINE_MUTEX(gfs_lock);
>  static unsigned int missing_funcs;
>  static bool gfs_registered;
>  static bool gfs_single_func;
> -static struct ffs_dev *ffs_tab;
> +static struct ffs_dev **ffs_tab;
>  
>  static int __init gfs_init(void)
>  {
>  	int i;
> +	int ret = 0;
>  
>  	ENTER();
>  
> -	if (!func_num) {
> +	if (func_num < 2) {
>  		gfs_single_func = true;
>  		func_num = 1;
>  	}
>  
> -	ffs_tab = kcalloc(func_num, sizeof *ffs_tab, GFP_KERNEL);
> +	ffs_tab = kcalloc(func_num, sizeof(ffs_tab), GFP_KERNEL);

What just happened here? I'm pretty sure the star is required.

>  	if (!ffs_tab)
>  		return -ENOMEM;
>  
> -	if (!gfs_single_func)
> -		for (i = 0; i < func_num; i++)
> -			ffs_tab[i].name = func_names[i];
> +	for (i = 0; i < func_num; i++) {
> +		ffs_tab[i] = ffs_alloc_dev();
> +		if (IS_ERR(ffs_tab[i])) {
> +			ret = PTR_ERR(ffs_tab[i]);
> +			goto no_dev;
> +		}
> +		if (!gfs_single_func)
> +			ffs_tab[i]->name = func_names[i];
> +	}
>  
>  	missing_funcs = func_num;
>  
>  	return functionfs_init();
> +no_dev:
> +	while (--i >= 0)
> +		ffs_free_dev(ffs_tab[i]);
> +	kfree(ffs_tab);
> +	return ret;
>  }
>  module_init(gfs_init);
>  
>  static void __exit gfs_exit(void)
>  {
> +	int i;
> +
>  	ENTER();
>  	mutex_lock(&gfs_lock);
>  

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux