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

Commit d6a01439 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi
Browse files

usb: gadget: move the global the_dev variable to their users



the u_ether.c file has a global variable named the_dev which keeps a
pointer to the network device after it has been created via
gether_setup_name(). It is only used internally by u_ether. This patches
moves the variable to its users and passes it via the port.ioport where
it is saved later anyway.

Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 15761826
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = {
};

static u8 hostaddr[ETH_ALEN];

static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/
static struct usb_function *f_acm;
static struct usb_function_instance *fi_serial;
@@ -122,7 +122,7 @@ static int __init cdc_do_config(struct usb_configuration *c)
		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
	}

	status = ecm_bind_config(c, hostaddr);
	status = ecm_bind_config(c, hostaddr, the_dev);
	if (status < 0)
		return status;

@@ -169,9 +169,9 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
	}

	/* set up network link layer */
	status = gether_setup(cdev->gadget, hostaddr);
	if (status < 0)
		return status;
	the_dev = gether_setup(cdev->gadget, hostaddr);
	if (IS_ERR(the_dev))
		return PTR_ERR(the_dev);

	/* set up serial link layer */
	status = gserial_alloc_line(&tty_line);
@@ -202,7 +202,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
fail1:
	gserial_free_line(tty_line);
fail0:
	gether_cleanup();
	gether_cleanup(the_dev);
	return status;
}

@@ -211,7 +211,7 @@ static int __exit cdc_unbind(struct usb_composite_dev *cdev)
	usb_put_function(f_acm);
	usb_put_function_instance(fi_serial);
	gserial_free_line(tty_line);
	gether_cleanup();
	gether_cleanup(the_dev);
	return 0;
}

+10 −10
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ static struct usb_gadget_strings *dev_strings[] = {
};

static u8 hostaddr[ETH_ALEN];

static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/

/*
@@ -224,7 +224,7 @@ static int __init rndis_do_config(struct usb_configuration *c)
		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
	}

	return rndis_bind_config(c, hostaddr);
	return rndis_bind_config(c, hostaddr, the_dev);
}

static struct usb_configuration rndis_config_driver = {
@@ -257,11 +257,11 @@ static int __init eth_do_config(struct usb_configuration *c)
	}

	if (use_eem)
		return eem_bind_config(c);
		return eem_bind_config(c, the_dev);
	else if (can_support_ecm(c->cdev->gadget))
		return ecm_bind_config(c, hostaddr);
		return ecm_bind_config(c, hostaddr, the_dev);
	else
		return geth_bind_config(c, hostaddr);
		return geth_bind_config(c, hostaddr, the_dev);
}

static struct usb_configuration eth_config_driver = {
@@ -279,9 +279,9 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
	int			status;

	/* set up network link layer */
	status = gether_setup(cdev->gadget, hostaddr);
	if (status < 0)
		return status;
	the_dev = gether_setup(cdev->gadget, hostaddr);
	if (IS_ERR(the_dev))
		return PTR_ERR(the_dev);

	/* set up main config label and device descriptor */
	if (use_eem) {
@@ -338,13 +338,13 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
	return 0;

fail:
	gether_cleanup();
	gether_cleanup(the_dev);
	return status;
}

static int __exit eth_unbind(struct usb_composite_dev *cdev)
{
	gether_cleanup();
	gether_cleanup(the_dev);
	return 0;
}

+3 −1
Original line number Diff line number Diff line
@@ -824,7 +824,8 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f)
 * for calling @gether_cleanup() before module unload.
 */
int
ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
		struct eth_dev *dev)
{
	struct f_ecm	*ecm;
	int		status;
@@ -852,6 +853,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
	snprintf(ecm->ethaddr, sizeof ecm->ethaddr, "%pm", ethaddr);
	ecm_string_defs[1].s = ecm->ethaddr;

	ecm->port.ioport = dev;
	ecm->port.cdc_filter = DEFAULT_FILTER;

	ecm->port.func.name = "cdc_ethernet";
+2 −1
Original line number Diff line number Diff line
@@ -528,7 +528,7 @@ static int eem_unwrap(struct gether *port,
 * Caller must have called @gether_setup().  Caller is also responsible
 * for calling @gether_cleanup() before module unload.
 */
int __init eem_bind_config(struct usb_configuration *c)
int __init eem_bind_config(struct usb_configuration *c, struct eth_dev *dev)
{
	struct f_eem	*eem;
	int		status;
@@ -549,6 +549,7 @@ int __init eem_bind_config(struct usb_configuration *c)
	if (!eem)
		return -ENOMEM;

	eem->port.ioport = dev;
	eem->port.cdc_filter = DEFAULT_FILTER;

	eem->port.func.name = "cdc_eem";
+3 −1
Original line number Diff line number Diff line
@@ -1287,7 +1287,8 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f)
 * Caller must have called @gether_setup().  Caller is also responsible
 * for calling @gether_cleanup() before module unload.
 */
int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
		struct eth_dev *dev)
{
	struct f_ncm	*ncm;
	int		status;
@@ -1321,6 +1322,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])

	spin_lock_init(&ncm->lock);
	ncm_reset_values(ncm);
	ncm->port.ioport = dev;
	ncm->port.is_fixed = true;

	ncm->port.func.name = "cdc_network";
Loading