diff options
author | David Brownell <david-b@pacbell.net> | 2005-05-16 11:26:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-27 17:43:59 -0400 |
commit | 45e45ab45c266642276d01e56d9fb5dccbfad960 (patch) | |
tree | 146b07b7ffde3ab3b38b3159aca5db7b5e3467ae /drivers | |
parent | 391eca9d8892a940ff8dbfee2ca78942e05c2d37 (diff) |
[PATCH] USB: fix drivers/usb/gadget/ether.c compile error
This fixes a compile glitch with CONFIG_USB_ETH_RNDIS disabled, and
replaces some inline #ifdeffery (and other code) with inline functions
which can evaluate to constants.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/ether.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 9f8413e3c10..86affef226e 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -91,12 +91,12 @@ static const char driver_desc [] = DRIVER_DESC; | |||
91 | 91 | ||
92 | #define RX_EXTRA 20 /* guard against rx overflows */ | 92 | #define RX_EXTRA 20 /* guard against rx overflows */ |
93 | 93 | ||
94 | #ifdef CONFIG_USB_ETH_RNDIS | ||
95 | #include "rndis.h" | 94 | #include "rndis.h" |
96 | #else | 95 | |
97 | #define rndis_init() 0 | 96 | #ifndef CONFIG_USB_ETH_RNDIS |
98 | #define rndis_uninit(x) do{}while(0) | 97 | #define rndis_uninit(x) do{}while(0) |
99 | #define rndis_exit() do{}while(0) | 98 | #define rndis_deregister(c) do{}while(0) |
99 | #define rndis_exit() do{}while(0) | ||
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ | 102 | /* CDC and RNDIS support the same host-chosen outgoing packet filters. */ |
@@ -1133,9 +1133,9 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags) | |||
1133 | dev->config = number; | 1133 | dev->config = number; |
1134 | INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n", | 1134 | INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n", |
1135 | speed, number, power, driver_desc, | 1135 | speed, number, power, driver_desc, |
1136 | dev->rndis | 1136 | rndis_active(dev) |
1137 | ? "RNDIS" | 1137 | ? "RNDIS" |
1138 | : (dev->cdc | 1138 | : (cdc_active(dev) |
1139 | ? "CDC Ethernet" | 1139 | ? "CDC Ethernet" |
1140 | : "CDC Ethernet Subset")); | 1140 | : "CDC Ethernet Subset")); |
1141 | } | 1141 | } |
@@ -1350,7 +1350,7 @@ eth_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1350 | || !dev->config | 1350 | || !dev->config |
1351 | || wIndex > 1) | 1351 | || wIndex > 1) |
1352 | break; | 1352 | break; |
1353 | if (!dev->cdc && wIndex != 0) | 1353 | if (!cdc_active(dev) && wIndex != 0) |
1354 | break; | 1354 | break; |
1355 | spin_lock (&dev->lock); | 1355 | spin_lock (&dev->lock); |
1356 | 1356 | ||
@@ -1420,11 +1420,11 @@ done_set_intf: | |||
1420 | || !dev->config | 1420 | || !dev->config |
1421 | || wIndex > 1) | 1421 | || wIndex > 1) |
1422 | break; | 1422 | break; |
1423 | if (!(dev->cdc || dev->rndis) && wIndex != 0) | 1423 | if (!(cdc_active(dev) || rndis_active(dev)) && wIndex != 0) |
1424 | break; | 1424 | break; |
1425 | 1425 | ||
1426 | /* for CDC, iff carrier is on, data interface is active. */ | 1426 | /* for CDC, iff carrier is on, data interface is active. */ |
1427 | if (dev->rndis || wIndex != 1) | 1427 | if (rndis_active(dev) || wIndex != 1) |
1428 | *(u8 *)req->buf = 0; | 1428 | *(u8 *)req->buf = 0; |
1429 | else | 1429 | else |
1430 | *(u8 *)req->buf = netif_carrier_ok (dev->net) ? 1 : 0; | 1430 | *(u8 *)req->buf = netif_carrier_ok (dev->net) ? 1 : 0; |
@@ -1437,8 +1437,7 @@ done_set_intf: | |||
1437 | * wValue = packet filter bitmap | 1437 | * wValue = packet filter bitmap |
1438 | */ | 1438 | */ |
1439 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1439 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1440 | || !dev->cdc | 1440 | || !cdc_active(dev) |
1441 | || dev->rndis | ||
1442 | || wLength != 0 | 1441 | || wLength != 0 |
1443 | || wIndex > 1) | 1442 | || wIndex > 1) |
1444 | break; | 1443 | break; |
@@ -1462,7 +1461,7 @@ done_set_intf: | |||
1462 | */ | 1461 | */ |
1463 | case USB_CDC_SEND_ENCAPSULATED_COMMAND: | 1462 | case USB_CDC_SEND_ENCAPSULATED_COMMAND: |
1464 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1463 | if (ctrl->bRequestType != (USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1465 | || !dev->rndis | 1464 | || !rndis_active(dev) |
1466 | || wLength > USB_BUFSIZ | 1465 | || wLength > USB_BUFSIZ |
1467 | || wValue | 1466 | || wValue |
1468 | || rndis_control_intf.bInterfaceNumber | 1467 | || rndis_control_intf.bInterfaceNumber |
@@ -1477,7 +1476,7 @@ done_set_intf: | |||
1477 | case USB_CDC_GET_ENCAPSULATED_RESPONSE: | 1476 | case USB_CDC_GET_ENCAPSULATED_RESPONSE: |
1478 | if ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE) | 1477 | if ((USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE) |
1479 | == ctrl->bRequestType | 1478 | == ctrl->bRequestType |
1480 | && dev->rndis | 1479 | && rndis_active(dev) |
1481 | // && wLength >= 0x0400 | 1480 | // && wLength >= 0x0400 |
1482 | && !wValue | 1481 | && !wValue |
1483 | && rndis_control_intf.bInterfaceNumber | 1482 | && rndis_control_intf.bInterfaceNumber |
@@ -1661,11 +1660,9 @@ static void rx_complete (struct usb_ep *ep, struct usb_request *req) | |||
1661 | /* normal completion */ | 1660 | /* normal completion */ |
1662 | case 0: | 1661 | case 0: |
1663 | skb_put (skb, req->actual); | 1662 | skb_put (skb, req->actual); |
1664 | #ifdef CONFIG_USB_ETH_RNDIS | ||
1665 | /* we know MaxPacketsPerTransfer == 1 here */ | 1663 | /* we know MaxPacketsPerTransfer == 1 here */ |
1666 | if (dev->rndis) | 1664 | if (rndis_active(dev)) |
1667 | status = rndis_rm_hdr (skb); | 1665 | status = rndis_rm_hdr (skb); |
1668 | #endif | ||
1669 | if (status < 0 | 1666 | if (status < 0 |
1670 | || ETH_HLEN > skb->len | 1667 | || ETH_HLEN > skb->len |
1671 | || skb->len > ETH_FRAME_LEN) { | 1668 | || skb->len > ETH_FRAME_LEN) { |
@@ -1893,8 +1890,7 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
1893 | * or the hardware can't use skb buffers. | 1890 | * or the hardware can't use skb buffers. |
1894 | * or there's not enough space for any RNDIS headers we need | 1891 | * or there's not enough space for any RNDIS headers we need |
1895 | */ | 1892 | */ |
1896 | #ifdef CONFIG_USB_ETH_RNDIS | 1893 | if (rndis_active(dev)) { |
1897 | if (dev->rndis) { | ||
1898 | struct sk_buff *skb_rndis; | 1894 | struct sk_buff *skb_rndis; |
1899 | 1895 | ||
1900 | skb_rndis = skb_realloc_headroom (skb, | 1896 | skb_rndis = skb_realloc_headroom (skb, |
@@ -1907,7 +1903,6 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
1907 | rndis_add_hdr (skb); | 1903 | rndis_add_hdr (skb); |
1908 | length = skb->len; | 1904 | length = skb->len; |
1909 | } | 1905 | } |
1910 | #endif | ||
1911 | req->buf = skb->data; | 1906 | req->buf = skb->data; |
1912 | req->context = skb; | 1907 | req->context = skb; |
1913 | req->complete = tx_complete; | 1908 | req->complete = tx_complete; |
@@ -1940,9 +1935,7 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net) | |||
1940 | } | 1935 | } |
1941 | 1936 | ||
1942 | if (retval) { | 1937 | if (retval) { |
1943 | #ifdef CONFIG_USB_ETH_RNDIS | ||
1944 | drop: | 1938 | drop: |
1945 | #endif | ||
1946 | dev->stats.tx_dropped++; | 1939 | dev->stats.tx_dropped++; |
1947 | dev_kfree_skb_any (skb); | 1940 | dev_kfree_skb_any (skb); |
1948 | spin_lock_irqsave (&dev->lock, flags); | 1941 | spin_lock_irqsave (&dev->lock, flags); |
@@ -2023,6 +2016,10 @@ static int rndis_control_ack (struct net_device *net) | |||
2023 | return 0; | 2016 | return 0; |
2024 | } | 2017 | } |
2025 | 2018 | ||
2019 | #else | ||
2020 | |||
2021 | #define rndis_control_ack NULL | ||
2022 | |||
2026 | #endif /* RNDIS */ | 2023 | #endif /* RNDIS */ |
2027 | 2024 | ||
2028 | static void eth_start (struct eth_dev *dev, int gfp_flags) | 2025 | static void eth_start (struct eth_dev *dev, int gfp_flags) |
@@ -2035,14 +2032,12 @@ static void eth_start (struct eth_dev *dev, int gfp_flags) | |||
2035 | /* and open the tx floodgates */ | 2032 | /* and open the tx floodgates */ |
2036 | atomic_set (&dev->tx_qlen, 0); | 2033 | atomic_set (&dev->tx_qlen, 0); |
2037 | netif_wake_queue (dev->net); | 2034 | netif_wake_queue (dev->net); |
2038 | #ifdef CONFIG_USB_ETH_RNDIS | 2035 | if (rndis_active(dev)) { |
2039 | if (dev->rndis) { | ||
2040 | rndis_set_param_medium (dev->rndis_config, | 2036 | rndis_set_param_medium (dev->rndis_config, |
2041 | NDIS_MEDIUM_802_3, | 2037 | NDIS_MEDIUM_802_3, |
2042 | BITRATE(dev->gadget)/100); | 2038 | BITRATE(dev->gadget)/100); |
2043 | (void) rndis_signal_connect (dev->rndis_config); | 2039 | (void) rndis_signal_connect (dev->rndis_config); |
2044 | } | 2040 | } |
2045 | #endif | ||
2046 | } | 2041 | } |
2047 | 2042 | ||
2048 | static int eth_open (struct net_device *net) | 2043 | static int eth_open (struct net_device *net) |
@@ -2083,13 +2078,11 @@ static int eth_stop (struct net_device *net) | |||
2083 | } | 2078 | } |
2084 | } | 2079 | } |
2085 | 2080 | ||
2086 | #ifdef CONFIG_USB_ETH_RNDIS | 2081 | if (rndis_active(dev)) { |
2087 | if (dev->rndis) { | ||
2088 | rndis_set_param_medium (dev->rndis_config, | 2082 | rndis_set_param_medium (dev->rndis_config, |
2089 | NDIS_MEDIUM_802_3, 0); | 2083 | NDIS_MEDIUM_802_3, 0); |
2090 | (void) rndis_signal_disconnect (dev->rndis_config); | 2084 | (void) rndis_signal_disconnect (dev->rndis_config); |
2091 | } | 2085 | } |
2092 | #endif | ||
2093 | 2086 | ||
2094 | return 0; | 2087 | return 0; |
2095 | } | 2088 | } |
@@ -2127,10 +2120,8 @@ eth_unbind (struct usb_gadget *gadget) | |||
2127 | struct eth_dev *dev = get_gadget_data (gadget); | 2120 | struct eth_dev *dev = get_gadget_data (gadget); |
2128 | 2121 | ||
2129 | DEBUG (dev, "unbind\n"); | 2122 | DEBUG (dev, "unbind\n"); |
2130 | #ifdef CONFIG_USB_ETH_RNDIS | ||
2131 | rndis_deregister (dev->rndis_config); | 2123 | rndis_deregister (dev->rndis_config); |
2132 | rndis_exit (); | 2124 | rndis_exit (); |
2133 | #endif | ||
2134 | 2125 | ||
2135 | /* we've already been disconnected ... no i/o is active */ | 2126 | /* we've already been disconnected ... no i/o is active */ |
2136 | if (dev->req) { | 2127 | if (dev->req) { |
@@ -2481,7 +2472,6 @@ autoconf_fail: | |||
2481 | dev->host_mac [2], dev->host_mac [3], | 2472 | dev->host_mac [2], dev->host_mac [3], |
2482 | dev->host_mac [4], dev->host_mac [5]); | 2473 | dev->host_mac [4], dev->host_mac [5]); |
2483 | 2474 | ||
2484 | #ifdef CONFIG_USB_ETH_RNDIS | ||
2485 | if (rndis) { | 2475 | if (rndis) { |
2486 | u32 vendorID = 0; | 2476 | u32 vendorID = 0; |
2487 | 2477 | ||
@@ -2509,7 +2499,6 @@ fail0: | |||
2509 | goto fail0; | 2499 | goto fail0; |
2510 | INFO (dev, "RNDIS ready\n"); | 2500 | INFO (dev, "RNDIS ready\n"); |
2511 | } | 2501 | } |
2512 | #endif | ||
2513 | 2502 | ||
2514 | return status; | 2503 | return status; |
2515 | 2504 | ||