mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Green <andy@warmcat.com>
To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Cc: patches@linaro.org, Andy Green <andy.green@linaro.org>
Subject: [RFC PATCH 3/3] USBNET: Use usbnet platform data if it is present
Date: Sat, 12 Mar 2011 22:40:11 +0000	[thread overview]
Message-ID: <20110312224011.27344.71472.stgit@otae.warmcat.com> (raw)
In-Reply-To: <20110312223643.27344.72406.stgit@otae.warmcat.com>

This enables usbnet to actually use the two features it now
supports via platform_data, if that has been set up by the board
definition file.

Signed-off-by: Andy Green <andy.green@linaro.org>
---

 drivers/net/usb/usbnet.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 95c41d5..5a5da74 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1293,6 +1293,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	int				status;
 	const char			*name;
 	struct usb_driver 	*driver = to_usb_driver(udev->dev.driver);
+	struct usbnet_platform_data	*pdata;
 
 	/* usbnet already took usb runtime pm, so have to enable the feature
 	 * for usb interface, otherwise usb_autopm_get_interface may return
@@ -1313,6 +1314,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	interface = udev->cur_altsetting;
 
 	usb_get_dev (xdev);
+	pdata = xdev->dev.platform_data;
 
 	status = -ENOMEM;
 
@@ -1348,7 +1350,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 
 	dev->net = net;
 	strcpy (net->name, "usb%d");
-	memcpy (net->dev_addr, node_id, sizeof node_id);
+	if (pdata && pdata->flags & USBNET_PLATDATA_FLAG__USE_MAC)
+		memcpy(net->dev_addr, pdata->mac, sizeof pdata->mac);
+	else
+		memcpy(net->dev_addr, node_id, sizeof node_id);
 
 	/* rx and tx sides can use different message sizes;
 	 * bind() should set rx_urb_size in that case.
@@ -1372,11 +1377,17 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 		if (status < 0)
 			goto out1;
 
-		// heuristic:  "usb%d" for links we know are two-host,
-		// else "eth%d" when there's reasonable doubt.  userspace
-		// can rename the link if it knows better.
-		if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
-		    (net->dev_addr [0] & 0x02) == 0)
+		/*
+		 * heuristic:  "usb%d" for links we know are two-host,
+		 * else "eth%d" when there's reasonable doubt.  userspace
+		 * can rename the link if it knows better.  Async
+		 * platform_data can also override this if it knows better
+		 * based on knowledge of what this link is wired up to.
+		 */
+		if ((((dev->driver_info->flags & FLAG_ETHER) != 0 &&
+		    (net->dev_addr[0] & 0x02) == 0)) ||
+		    (pdata && pdata->flags &
+					USBNET_PLATDATA_FLAG__FORCE_ETH_IFNAME))
 			strcpy (net->name, "eth%d");
 		/* WLAN devices should always be named "wlan%d" */
 		if ((dev->driver_info->flags & FLAG_WLAN) != 0)


      parent reply	other threads:[~2011-03-12 22:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-12 22:39 [RFC PATCH 0/3] USB: async platform_data support for usb and usbnet Andy Green
2011-03-12 22:39 ` [RFC PATCH 1/3] USB HOST CORE:probed devices collect any platform_data waiting for them Andy Green
2011-03-12 22:40 ` [RFC PATCH 2/3] USBNET: Introduce usbnet platform data Andy Green
2011-03-12 22:40 ` Andy Green [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110312224011.27344.71472.stgit@otae.warmcat.com \
    --to=andy@warmcat.com \
    --cc=andy.green@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=patches@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome