Re: [PATCH] usb: gadget: mass_storage: Fix freeing luns sysfs implementation

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

 



On Fri, Jul 31 2015, Krzysztof Opasiak wrote:
> Use device_is_registered() instad of sysfs flag to determine if
> we should free sysfs representation of particular LUN.
[…]
>
> Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>

Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>

> ---
>  drivers/usb/gadget/function/f_mass_storage.c |   12 ++++++------
>  drivers/usb/gadget/function/f_mass_storage.h |    2 +-
>  2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
> index f94a8e2..9870913 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -2742,9 +2742,9 @@ error_release:
>  }
>  EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers);
>  
> -void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs)
> +void fsg_common_remove_lun(struct fsg_lun *lun)
>  {
> -	if (sysfs)
> +	if (device_is_registered(&lun->dev))
>  		device_unregister(&lun->dev);
>  	fsg_lun_close(lun);
>  	kfree(lun);
> @@ -2757,7 +2757,7 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n)
>  
>  	for (i = 0; i < n; ++i)
>  		if (common->luns[i]) {
> -			fsg_common_remove_lun(common->luns[i], common->sysfs);
> +			fsg_common_remove_lun(common->luns[i]);
>  			common->luns[i] = NULL;
>  		}
>  }
> @@ -2950,7 +2950,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
>  	return 0;
>  
>  error_lun:
> -	if (common->sysfs)
> +	if (device_is_registered(&lun->dev))
>  		device_unregister(&lun->dev);
>  	fsg_lun_close(lun);
>  	common->luns[id] = NULL;
> @@ -3038,7 +3038,7 @@ static void fsg_common_release(struct kref *ref)
>  			if (!lun)
>  				continue;
>  			fsg_lun_close(lun);
> -			if (common->sysfs)
> +		if (device_is_registered(&lun->dev))
>  				device_unregister(&lun->dev);
>  			kfree(lun);
>  		}
> @@ -3363,7 +3363,7 @@ static void fsg_lun_drop(struct config_group *group, struct config_item *item)
>  		unregister_gadget_item(gadget);
>  	}
>  
> -	fsg_common_remove_lun(lun_opts->lun, fsg_opts->common->sysfs);
> +	fsg_common_remove_lun(lun_opts->lun);
>  	fsg_opts->common->luns[lun_opts->lun_id] = NULL;
>  	lun_opts->lun_id = 0;
>  	mutex_unlock(&fsg_opts->lock);
> diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h
> index b4866fc..37bc94c 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.h
> +++ b/drivers/usb/gadget/function/f_mass_storage.h
> @@ -137,7 +137,7 @@ void fsg_common_free_buffers(struct fsg_common *common);
>  int fsg_common_set_cdev(struct fsg_common *common,
>  			struct usb_composite_dev *cdev, bool can_stall);
>  
> -void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs);
> +void fsg_common_remove_lun(struct fsg_lun *lun);
>  
>  void fsg_common_remove_luns(struct fsg_common *common);
>  
> -- 
> 1.7.9.5
>

-- 
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