Skip to content

Commit

Permalink
net: cdc_ncm: remove redundant "disconnected" flag
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bjørn Mork authored and David S. Miller committed May 17, 2014
1 parent 916f764 commit fa83dbe
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
19 changes: 2 additions & 17 deletions drivers/net/usb/cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 0 additions & 13 deletions drivers/net/usb/huawei_cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,11 @@ static int huawei_cdc_ncm_resume(struct usb_interface *intf)
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,
Expand Down
1 change: 0 additions & 1 deletion include/linux/usb/cdc_ncm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit fa83dbe

Please sign in to comment.