Commit 036e98b2 authored by Mike Lockwood's avatar Mike Lockwood Committed by Greg Kroah-Hartman

usb: gadget: Add variant of gether_setup to customize the device name

This is needed to avoid name collisions on SoCs that have both usb
gadget and usb host, where usb0 may be the rndis interface or a usb
ethernet adapter.
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
Signed-off-by: default avatarBenoit Goby <benoit@android.com>
	[make gether_setup a static inline function]
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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c3c04b29
...@@ -744,10 +744,11 @@ static struct device_type gadget_type = { ...@@ -744,10 +744,11 @@ static struct device_type gadget_type = {
}; };
/** /**
* gether_setup - initialize one ethernet-over-usb link * gether_setup_name - initialize one ethernet-over-usb link
* @g: gadget to associated with these links * @g: gadget to associated with these links
* @ethaddr: NULL, or a buffer in which the ethernet address of the * @ethaddr: NULL, or a buffer in which the ethernet address of the
* host side of the link is recorded * host side of the link is recorded
* @netname: name for network device (for example, "usb")
* Context: may sleep * Context: may sleep
* *
* This sets up the single network link that may be exported by a * This sets up the single network link that may be exported by a
...@@ -756,7 +757,8 @@ static struct device_type gadget_type = { ...@@ -756,7 +757,8 @@ static struct device_type gadget_type = {
* *
* Returns negative errno, or zero on success * Returns negative errno, or zero on success
*/ */
int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]) int gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
const char *netname)
{ {
struct eth_dev *dev; struct eth_dev *dev;
struct net_device *net; struct net_device *net;
...@@ -780,7 +782,7 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]) ...@@ -780,7 +782,7 @@ int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
/* network device setup */ /* network device setup */
dev->net = net; dev->net = net;
strcpy(net->name, "usb%d"); snprintf(net->name, sizeof(net->name), "%s%%d", netname);
if (get_ether_addr(dev_addr, net->dev_addr)) if (get_ether_addr(dev_addr, net->dev_addr))
dev_warn(&g->dev, dev_warn(&g->dev,
......
...@@ -69,9 +69,28 @@ struct gether { ...@@ -69,9 +69,28 @@ struct gether {
|USB_CDC_PACKET_TYPE_PROMISCUOUS \ |USB_CDC_PACKET_TYPE_PROMISCUOUS \
|USB_CDC_PACKET_TYPE_DIRECTED) |USB_CDC_PACKET_TYPE_DIRECTED)
/* variant of gether_setup that allows customizing network device name */
int gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
const char *netname);
/* netdev setup/teardown as directed by the gadget driver */ /* netdev setup/teardown as directed by the gadget driver */
int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN]); /* gether_setup - initialize one ethernet-over-usb link
* @g: gadget to associated with these links
* @ethaddr: NULL, or a buffer in which the ethernet address of the
* host side of the link is recorded
* Context: may sleep
*
* This sets up the single network link that may be exported by a
* gadget driver using this framework. The link layer addresses are
* set up using module parameters.
*
* Returns negative errno, or zero on success
*/
static inline int gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
{
return gether_setup_name(g, ethaddr, "usb");
}
void gether_cleanup(void); void gether_cleanup(void);
/* connect/disconnect is handled by individual functions */ /* connect/disconnect is handled by individual functions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment