From patchwork Sat Mar 12 22:40:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Green X-Patchwork-Id: 532 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:43:23 -0000 Delivered-To: patches@linaro.org Received: by 10.224.45.75 with SMTP id d11cs13584qaf; Sat, 12 Mar 2011 14:40:15 -0800 (PST) Received: by 10.216.82.77 with SMTP id n55mr417658wee.52.1299969614749; Sat, 12 Mar 2011 14:40:14 -0800 (PST) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id o2si10961890wer.68.2011.03.12.14.40.14 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 Mar 2011 14:40:14 -0800 (PST) Received-SPF: pass (google.com: domain of andy.warmcat.com@googlemail.com designates 74.125.82.178 as permitted sender) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of andy.warmcat.com@googlemail.com designates 74.125.82.178 as permitted sender) smtp.mail=andy.warmcat.com@googlemail.com; dkim=pass (test mode) header.i=@googlemail.com Received: by mail-wy0-f178.google.com with SMTP id 26so4059118wyj.37 for ; Sat, 12 Mar 2011 14:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:sender:from:subject:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version:content-type :content-transfer-encoding; bh=tbnefiMjncQfc1aG2ZmqpwfDhqaRKhXUdrzd3Q+l6q8=; b=iUop3ore5f5alaTwWXlJHzjvmlzFNv/tiGAQpsDm5s5FPAvN/bHpOGdz3Z4/MERuWU S7BOKzXrTV4rPtbqAegzeZB/yZ0SYyejUWFEnR8leqBFK1ehSLSuIflZcs5PsHuAICp3 AhLZP3lA03kkt7j/8lAUwYyowHZ5brPhlqTEI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=SnvNfFtKv50zPJc7qoVPJbdj5ybiso6MUwgyH/AAzih64KoYKc2IF4iYA6AGQ3SqKG 730fTbEVhOG/CcqsHfyehy6raWpbudthUd4tbvV1ZL9mlJ+ztCNTxZJkoOqCUPkMdX2+ GpCiKQ9dRC9NNHCQRmTbjlukb14S+mQKp98jA= Received: by 10.216.145.145 with SMTP id p17mr985784wej.37.1299969613691; Sat, 12 Mar 2011 14:40:13 -0800 (PST) Received: from otae.warmcat.com (s15404224.onlinehome-server.info [87.106.134.80]) by mx.google.com with ESMTPS id t72sm1902681wei.44.2011.03.12.14.40.12 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 Mar 2011 14:40:13 -0800 (PST) Sender: Andy Green From: Andy Green Subject: [RFC PATCH 3/3] USBNET: Use usbnet platform data if it is present To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: patches@linaro.org, Andy Green Date: Sat, 12 Mar 2011 22:40:11 +0000 Message-ID: <20110312224011.27344.71472.stgit@otae.warmcat.com> In-Reply-To: <20110312223643.27344.72406.stgit@otae.warmcat.com> References: <20110312223643.27344.72406.stgit@otae.warmcat.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 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 --- 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)