Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ec8f00f authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi
Browse files

usb: gadget: g_ffs: remove a reduntant gfs_ether_setup variable



Since d6a01439
usb: gadget: move the global the_dev variable to their users
"the_dev" variable can be used as a "setup done" flag; non-NULL
meaning "setup done", NULL meaning "setup not done". Moreover,
gether_cleanup() can be safely called with a NULL argument.

Corrected a comment to be consistent with the code.

Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Acked-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 1933861d
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -182,7 +182,6 @@ static __refdata struct usb_composite_driver gfs_driver = {


static DEFINE_MUTEX(gfs_lock);
static DEFINE_MUTEX(gfs_lock);
static unsigned int missing_funcs;
static unsigned int missing_funcs;
static bool gfs_ether_setup;
static bool gfs_registered;
static bool gfs_registered;
static bool gfs_single_func;
static bool gfs_single_func;
static struct gfs_ffs_obj *ffs_tab;
static struct gfs_ffs_obj *ffs_tab;
@@ -364,7 +363,6 @@ static int gfs_bind(struct usb_composite_dev *cdev)
		ret = PTR_ERR(the_dev);
		ret = PTR_ERR(the_dev);
		goto error_quick;
		goto error_quick;
	}
	}
	gfs_ether_setup = true;


	ret = usb_string_ids_tab(cdev, gfs_strings);
	ret = usb_string_ids_tab(cdev, gfs_strings);
	if (unlikely(ret < 0))
	if (unlikely(ret < 0))
@@ -401,8 +399,8 @@ static int gfs_bind(struct usb_composite_dev *cdev)
		functionfs_unbind(ffs_tab[i].ffs_data);
		functionfs_unbind(ffs_tab[i].ffs_data);
error:
error:
	gether_cleanup(the_dev);
	gether_cleanup(the_dev);
	the_dev = NULL;
error_quick:
error_quick:
	gfs_ether_setup = false;
	return ret;
	return ret;
}
}


@@ -415,18 +413,17 @@ static int gfs_unbind(struct usb_composite_dev *cdev)


	ENTER();
	ENTER();


	gether_cleanup(the_dev);
	the_dev = NULL;

	/*
	/*
	 * We may have been called in an error recovery from
	 * We may have been called in an error recovery from
	 * composite_bind() after gfs_unbind() failure so we need to
	 * composite_bind() after gfs_unbind() failure so we need to
	 * check if gfs_ffs_data is not NULL since gfs_bind() handles
	 * check if instance's ffs_data is not NULL since gfs_bind() handles
	 * all error recovery itself.  I'd rather we werent called
	 * all error recovery itself.  I'd rather we werent called
	 * from composite on orror recovery, but what you're gonna
	 * from composite on orror recovery, but what you're gonna
	 * do...?
	 * do...?
	 */
	 */
	if (gfs_ether_setup)
		gether_cleanup(the_dev);
	gfs_ether_setup = false;

	for (i = func_num; i--; )
	for (i = func_num; i--; )
		if (ffs_tab[i].ffs_data)
		if (ffs_tab[i].ffs_data)
			functionfs_unbind(ffs_tab[i].ffs_data);
			functionfs_unbind(ffs_tab[i].ffs_data);