net: cdc_ncm: remove redundant "disconnected" flag
authorBjørn Mork <bjorn@mork.no>
Fri, 16 May 2014 19:48:28 +0000 (21:48 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 17 May 2014 02:39:02 +0000 (22:39 -0400)
Calling netif_carrier_{on,off} is sufficient.  There is no need
to duplicate the carrier state in a driver specific flag.

Acked-by: Enrico Mioso <mrkiko.rs@gmail.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ncm.c
drivers/net/usb/huawei_cdc_ncm.c
include/linux/usb/cdc_ncm.h

index 1d1ff2fa8ae19b98c0e358f66bc074497005e762..783c4ed963958ff12646c38622dfe818647fce4f 100644 (file)
@@ -1364,11 +1364,10 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
                 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
                 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
                 */
-               ctx->connected = le16_to_cpu(event->wValue);
                netif_info(dev, link, dev->net,
                           "network connection: %sconnected\n",
-                          ctx->connected ? "" : "dis");
-               usbnet_link_change(dev, ctx->connected, 0);
+                          !!event->wValue ? "" : "dis");
+               usbnet_link_change(dev, !!event->wValue, 0);
                break;
 
        case USB_CDC_NOTIFY_SPEED_CHANGE:
@@ -1388,23 +1387,11 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
        }
 }
 
-static int cdc_ncm_check_connect(struct usbnet *dev)
-{
-       struct cdc_ncm_ctx *ctx;
-
-       ctx = (struct cdc_ncm_ctx *)dev->data[0];
-       if (ctx == NULL)
-               return 1;       /* disconnected */
-
-       return !ctx->connected;
-}
-
 static const struct driver_info cdc_ncm_info = {
        .description = "CDC NCM",
        .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
-       .check_connect = cdc_ncm_check_connect,
        .manage_power = usbnet_manage_power,
        .status = cdc_ncm_status,
        .rx_fixup = cdc_ncm_rx_fixup,
@@ -1418,7 +1405,6 @@ static const struct driver_info wwan_info = {
                        | FLAG_WWAN,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
-       .check_connect = cdc_ncm_check_connect,
        .manage_power = usbnet_manage_power,
        .status = cdc_ncm_status,
        .rx_fixup = cdc_ncm_rx_fixup,
@@ -1432,7 +1418,6 @@ static const struct driver_info wwan_noarp_info = {
                        | FLAG_WWAN | FLAG_NOARP,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
-       .check_connect = cdc_ncm_check_connect,
        .manage_power = usbnet_manage_power,
        .status = cdc_ncm_status,
        .rx_fixup = cdc_ncm_rx_fixup,
index 312178d7b698e06a6bc97ede9c7c1eb49510c322..f9822bc75425a9bacc2dcd8915344c6373778a2c 100644 (file)
@@ -172,24 +172,11 @@ err:
        return ret;
 }
 
-static int huawei_cdc_ncm_check_connect(struct usbnet *usbnet_dev)
-{
-       struct cdc_ncm_ctx *ctx;
-
-       ctx = (struct cdc_ncm_ctx *)usbnet_dev->data[0];
-
-       if (ctx == NULL)
-               return 1; /* disconnected */
-
-       return !ctx->connected;
-}
-
 static const struct driver_info huawei_cdc_ncm_info = {
        .description = "Huawei CDC NCM device",
        .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN,
        .bind = huawei_cdc_ncm_bind,
        .unbind = huawei_cdc_ncm_unbind,
-       .check_connect = huawei_cdc_ncm_check_connect,
        .manage_power = huawei_cdc_ncm_manage_power,
        .rx_fixup = cdc_ncm_rx_fixup,
        .tx_fixup = cdc_ncm_tx_fixup,
index cde506731c48786ac9c339dcefce30f8d84f6b29..8c5e38819828b0c525f94e9558e9f4e232d978ec 100644 (file)
@@ -118,7 +118,6 @@ struct cdc_ncm_ctx {
        u16 tx_ndp_modulus;
        u16 tx_seq;
        u16 rx_seq;
-       u16 connected;
        u16 min_tx_pkt;
 
        /* statistics */