From patchwork Tue May 1 18:23:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 8333 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8668C23E23 for ; Tue, 1 May 2012 18:23:22 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 3BF3FA181B1 for ; Tue, 1 May 2012 18:23:22 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so2655363yhp.11 for ; Tue, 01 May 2012 11:23:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=lrqmd3efWo71dd4Xm94u8kKLkLUq4418AyI/N73twuY=; b=TH608Bvw7EkeDhEjAlAS7kANPsMWf+38zfHOB0n3B4fjk7tf2WCeelwLYesx47jU32 Y5QyK8xm1WuKwST1RkdX4v5ukyuFQANk9P3hPVZxsSnUe0THsECi4zpfbLbxLZaB5mDi +2rzprfNuTYA3Q4zKw5/jU23X42hRXqgRo2W3+UllPWxD1cUHR/acJpvQwM3teR22Vmc u1scHDVxdHfcZk+xwY33GLF5fXwpmZvifWxp7RYq866QGeNDSbScd9Nfcjmsm/NtTfdL NDqhr8bDGOxFvvhvGOV1QQJTp1e5PPtWftWyz5VnaK5amsJE15ZWDKt4A87LJadf3j/G +XTw== Received: by 10.50.160.225 with SMTP id xn1mr2784802igb.3.1335896601897; Tue, 01 May 2012 11:23:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp198007ibt; Tue, 1 May 2012 11:23:20 -0700 (PDT) Received: by 10.112.32.72 with SMTP id g8mr6062255lbi.43.1335896600271; Tue, 01 May 2012 11:23:20 -0700 (PDT) Received: from mail.df.lth.se (mail.df.lth.se. [194.47.250.12]) by mx.google.com with ESMTPS id nt8si11738459lab.19.2012.05.01.11.23.19 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 May 2012 11:23:20 -0700 (PDT) Received-SPF: neutral (google.com: 194.47.250.12 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=194.47.250.12; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.47.250.12 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) smtp.mail=linus.walleij@linaro.org Received: from fecusia (c83-249-217-212.bredband.comhem.se [83.249.217.212]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.df.lth.se (Postfix) with ESMTPSA id E63E265D55; Tue, 1 May 2012 20:23:17 +0200 (CEST) Received: by fecusia (sSMTP sendmail emulation); Tue, 1 May 2012 20:23:17 +0200 From: "Linus Walleij" To: netdev@vger.kernel.org, linux-usb@vger.kernel.org, Greg Kroah-Hartman , "David S. Miller" , Felipe Balbi Cc: Jussi Kivilinna , Haiyang Zhang , Wei Yongjun , Ben Hutchings , Linus Walleij Subject: [PATCH 08/13 v4] usb/net: rndis: merge media type definitions Date: Tue, 1 May 2012 20:23:16 +0200 Message-Id: <1335896596-13525-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.7.7.6 X-Gm-Message-State: ALoCoQlWSckIFmt6AvuQ0zGQTKMEWkZQyS7MSYc3CfvUHL4cfVn8ChJG3J7lZJ4WSH6jqgVCP5yY Let's have a unified table of RNDIS media. We used to have a similar table with NDIS_* prefix from the gadget driver, but since we're only using RNDIS in the kernel (IIRC NDIS, non-remote, is for the windows- internal network drivers so what do we care) let's prefix everything with RNDIS. Some of the definitions were conflicting, in one of the defines 0x0B is bearer "CO WAN" and in two others "BPC". Well I took the majority vote. Two definition of medium 0x09 calls it "wireless WAN" but one vote for "wireless LAN" but in this case I am sticking with the minority, "Wide Area Network" does not make much sense in this case as far as I can tell. NOTE: latin singular and plural is so screwed up in these defines that it makes my eyes bleed. But I will not attempt to submit a patch converting all use of _MEDIA_ to _MEDIUM_ while I can probably tell from the semantics of the code that RNDIS_MEDIA_STATE_CONNECTED is most probably (erroneously) referring to a singular, unless it can return an array of connected media. I suspect these erroneous plurals are used in documentation and such so I don't want to mess around with things for no functional change. Signed-off-by: Linus Walleij --- drivers/usb/gadget/f_rndis.c | 6 ++-- drivers/usb/gadget/rndis.c | 8 +++--- include/linux/rndis.h | 60 +++++++++++++++-------------------------- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 5234365..d4f823f 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c @@ -637,7 +637,7 @@ static void rndis_open(struct gether *geth) DBG(cdev, "%s\n", __func__); - rndis_set_param_medium(rndis->config, NDIS_MEDIUM_802_3, + rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3, bitrate(cdev->gadget) / 100); rndis_signal_connect(rndis->config); } @@ -648,7 +648,7 @@ static void rndis_close(struct gether *geth) DBG(geth->func.config->cdev, "%s\n", __func__); - rndis_set_param_medium(rndis->config, NDIS_MEDIUM_802_3, 0); + rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3, 0); rndis_signal_disconnect(rndis->config); } @@ -765,7 +765,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) goto fail; rndis->config = status; - rndis_set_param_medium(rndis->config, NDIS_MEDIUM_802_3, 0); + rndis_set_param_medium(rndis->config, RNDIS_MEDIUM_802_3, 0); rndis_set_host_mac(rndis->config, rndis->ethaddr); #if 0 diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 79ed261..d9086ca 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c @@ -252,7 +252,7 @@ static int gen_ndis_query_resp(int configNr, u32 OID, u8 *buf, if (rndis_debug > 1) pr_debug("%s: RNDIS_OID_GEN_LINK_SPEED\n", __func__); if (rndis_per_dev_params[configNr].media_state - == NDIS_MEDIA_STATE_DISCONNECTED) + == RNDIS_MEDIA_STATE_DISCONNECTED) *outbuf = cpu_to_le32(0); else *outbuf = cpu_to_le32( @@ -758,7 +758,7 @@ static int rndis_indicate_status_msg(int configNr, u32 status) int rndis_signal_connect(int configNr) { rndis_per_dev_params[configNr].media_state - = NDIS_MEDIA_STATE_CONNECTED; + = RNDIS_MEDIA_STATE_CONNECTED; return rndis_indicate_status_msg(configNr, RNDIS_STATUS_MEDIA_CONNECT); } @@ -766,7 +766,7 @@ int rndis_signal_connect(int configNr) int rndis_signal_disconnect(int configNr) { rndis_per_dev_params[configNr].media_state - = NDIS_MEDIA_STATE_DISCONNECTED; + = RNDIS_MEDIA_STATE_DISCONNECTED; return rndis_indicate_status_msg(configNr, RNDIS_STATUS_MEDIA_DISCONNECT); } @@ -1173,7 +1173,7 @@ int rndis_init(void) rndis_per_dev_params[i].used = 0; rndis_per_dev_params[i].state = RNDIS_UNINITIALIZED; rndis_per_dev_params[i].media_state - = NDIS_MEDIA_STATE_DISCONNECTED; + = RNDIS_MEDIA_STATE_DISCONNECTED; INIT_LIST_HEAD(&(rndis_per_dev_params[i].resp_queue)); } diff --git a/include/linux/rndis.h b/include/linux/rndis.h index 2e0b1bd..4857959 100644 --- a/include/linux/rndis.h +++ b/include/linux/rndis.h @@ -112,6 +112,28 @@ #define RNDIS_PHYSICAL_MEDIUM_WIRELESS_WAN 0x00000008 #define RNDIS_PHYSICAL_MEDIUM_MAX 0x00000009 +/* Remote NDIS medium types. */ +#define RNDIS_MEDIUM_UNSPECIFIED 0x00000000 +#define RNDIS_MEDIUM_802_3 0x00000000 +#define RNDIS_MEDIUM_802_5 0x00000001 +#define RNDIS_MEDIUM_FDDI 0x00000002 +#define RNDIS_MEDIUM_WAN 0x00000003 +#define RNDIS_MEDIUM_LOCAL_TALK 0x00000004 +#define RNDIS_MEDIUM_ARCNET_RAW 0x00000006 +#define RNDIS_MEDIUM_ARCNET_878_2 0x00000007 +#define RNDIS_MEDIUM_ATM 0x00000008 +#define RNDIS_MEDIUM_WIRELESS_LAN 0x00000009 +#define RNDIS_MEDIUM_IRDA 0x0000000A +#define RNDIS_MEDIUM_BPC 0x0000000B +#define RNDIS_MEDIUM_CO_WAN 0x0000000C +#define RNDIS_MEDIUM_1394 0x0000000D +/* Not a real medium, defined as an upper-bound */ +#define RNDIS_MEDIUM_MAX 0x0000000E + +/* Remote NDIS medium connection states. */ +#define RNDIS_MEDIA_STATE_CONNECTED 0x00000000 +#define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001 + /* packet filter bits used by RNDIS_OID_GEN_CURRENT_PACKET_FILTER */ #define RNDIS_PACKET_TYPE_DIRECTED 0x00000001 #define RNDIS_PACKET_TYPE_MULTICAST 0x00000002 @@ -163,21 +185,6 @@ #define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS 0x00800000 #define NDIS_MINIPORT_64BITS_DMA 0x01000000 -#define NDIS_MEDIUM_802_3 0x00000000 -#define NDIS_MEDIUM_802_5 0x00000001 -#define NDIS_MEDIUM_FDDI 0x00000002 -#define NDIS_MEDIUM_WAN 0x00000003 -#define NDIS_MEDIUM_LOCAL_TALK 0x00000004 -#define NDIS_MEDIUM_DIX 0x00000005 -#define NDIS_MEDIUM_ARCENT_RAW 0x00000006 -#define NDIS_MEDIUM_ARCENT_878_2 0x00000007 -#define NDIS_MEDIUM_ATM 0x00000008 -#define NDIS_MEDIUM_WIRELESS_LAN 0x00000009 -#define NDIS_MEDIUM_IRDA 0x0000000A -#define NDIS_MEDIUM_BPC 0x0000000B -#define NDIS_MEDIUM_CO_WAN 0x0000000C -#define NDIS_MEDIUM_1394 0x0000000D - #define NDIS_PACKET_TYPE_DIRECTED 0x00000001 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 @@ -191,9 +198,6 @@ #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 -#define NDIS_MEDIA_STATE_CONNECTED 0x00000000 -#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001 - #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002 #define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004 @@ -421,23 +425,3 @@ * driver and remote device, if necessary. */ #define REMOTE_NDIS_BUS_MSG 0xff000001 - -/* Remote NDIS medium types. */ -#define RNDIS_MEDIUM_802_3 0x00000000 -#define RNDIS_MEDIUM_802_5 0x00000001 -#define RNDIS_MEDIUM_FDDI 0x00000002 -#define RNDIS_MEDIUM_WAN 0x00000003 -#define RNDIS_MEDIUM_LOCAL_TALK 0x00000004 -#define RNDIS_MEDIUM_ARCNET_RAW 0x00000006 -#define RNDIS_MEDIUM_ARCNET_878_2 0x00000007 -#define RNDIS_MEDIUM_ATM 0x00000008 -#define RNDIS_MEDIUM_WIRELESS_WAN 0x00000009 -#define RNDIS_MEDIUM_IRDA 0x0000000a -#define RNDIS_MEDIUM_CO_WAN 0x0000000b -/* Not a real medium, defined as an upper-bound */ -#define RNDIS_MEDIUM_MAX 0x0000000d - - -/* Remote NDIS medium connection states. */ -#define RNDIS_MEDIA_STATE_CONNECTED 0x00000000 -#define RNDIS_MEDIA_STATE_DISCONNECTED 0x00000001