Commit ae223cd4 authored by Bjørn Mork's avatar Bjørn Mork Committed by David S. Miller

net: cdc_ncm: use netif_* and dev_* instead of pr_*

Take advantage of standard device name prefixing and
netdevice msglvl control where possible.

Cc: Alexey Orishko <alexey.orishko@gmail.com>
Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a26fd05d
...@@ -87,7 +87,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -87,7 +87,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
0, iface_no, &ncm_parm, 0, iface_no, &ncm_parm,
sizeof(ncm_parm)); sizeof(ncm_parm));
if (err < 0) { if (err < 0) {
pr_debug("failed GET_NTB_PARAMETERS\n"); dev_dbg(&dev->intf->dev, "failed GET_NTB_PARAMETERS\n");
return 1; return 1;
} }
...@@ -115,9 +115,8 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -115,9 +115,8 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
flags = 0; flags = 0;
} }
pr_debug("dwNtbInMaxSize=%u dwNtbOutMaxSize=%u " dev_dbg(&dev->intf->dev,
"wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u " "dwNtbInMaxSize=%u dwNtbOutMaxSize=%u wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
"wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus, ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus,
ctx->tx_ndp_modulus, ctx->tx_max_datagrams, flags); ctx->tx_ndp_modulus, ctx->tx_max_datagrams, flags);
...@@ -128,13 +127,13 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -128,13 +127,13 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
/* verify maximum size of received NTB in bytes */ /* verify maximum size of received NTB in bytes */
if (ctx->rx_max < USB_CDC_NCM_NTB_MIN_IN_SIZE) { if (ctx->rx_max < USB_CDC_NCM_NTB_MIN_IN_SIZE) {
pr_debug("Using min receive length=%d\n", dev_dbg(&dev->intf->dev, "Using min receive length=%d\n",
USB_CDC_NCM_NTB_MIN_IN_SIZE); USB_CDC_NCM_NTB_MIN_IN_SIZE);
ctx->rx_max = USB_CDC_NCM_NTB_MIN_IN_SIZE; ctx->rx_max = USB_CDC_NCM_NTB_MIN_IN_SIZE;
} }
if (ctx->rx_max > CDC_NCM_NTB_MAX_SIZE_RX) { if (ctx->rx_max > CDC_NCM_NTB_MAX_SIZE_RX) {
pr_debug("Using default maximum receive length=%d\n", dev_dbg(&dev->intf->dev, "Using default maximum receive length=%d\n",
CDC_NCM_NTB_MAX_SIZE_RX); CDC_NCM_NTB_MAX_SIZE_RX);
ctx->rx_max = CDC_NCM_NTB_MAX_SIZE_RX; ctx->rx_max = CDC_NCM_NTB_MAX_SIZE_RX;
} }
...@@ -148,14 +147,14 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -148,14 +147,14 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
| USB_RECIP_INTERFACE, | USB_RECIP_INTERFACE,
0, iface_no, &dwNtbInMaxSize, 4); 0, iface_no, &dwNtbInMaxSize, 4);
if (err < 0) if (err < 0)
pr_debug("Setting NTB Input Size failed\n"); dev_dbg(&dev->intf->dev, "Setting NTB Input Size failed\n");
} }
/* verify maximum size of transmitted NTB in bytes */ /* verify maximum size of transmitted NTB in bytes */
if ((ctx->tx_max < if ((ctx->tx_max <
(min_hdr_size + min_dgram_size)) || (min_hdr_size + min_dgram_size)) ||
(ctx->tx_max > CDC_NCM_NTB_MAX_SIZE_TX)) { (ctx->tx_max > CDC_NCM_NTB_MAX_SIZE_TX)) {
pr_debug("Using default maximum transmit length=%d\n", dev_dbg(&dev->intf->dev, "Using default maximum transmit length=%d\n",
CDC_NCM_NTB_MAX_SIZE_TX); CDC_NCM_NTB_MAX_SIZE_TX);
ctx->tx_max = CDC_NCM_NTB_MAX_SIZE_TX; ctx->tx_max = CDC_NCM_NTB_MAX_SIZE_TX;
...@@ -178,7 +177,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -178,7 +177,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) || if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
(val != ((-val) & val)) || (val >= ctx->tx_max)) { (val != ((-val) & val)) || (val >= ctx->tx_max)) {
pr_debug("Using default alignment: 4 bytes\n"); dev_dbg(&dev->intf->dev, "Using default alignment: 4 bytes\n");
ctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE; ctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
} }
...@@ -192,13 +191,13 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -192,13 +191,13 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) || if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
(val != ((-val) & val)) || (val >= ctx->tx_max)) { (val != ((-val) & val)) || (val >= ctx->tx_max)) {
pr_debug("Using default transmit modulus: 4 bytes\n"); dev_dbg(&dev->intf->dev, "Using default transmit modulus: 4 bytes\n");
ctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE; ctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
} }
/* verify the payload remainder */ /* verify the payload remainder */
if (ctx->tx_remainder >= ctx->tx_modulus) { if (ctx->tx_remainder >= ctx->tx_modulus) {
pr_debug("Using default transmit remainder: 0 bytes\n"); dev_dbg(&dev->intf->dev, "Using default transmit remainder: 0 bytes\n");
ctx->tx_remainder = 0; ctx->tx_remainder = 0;
} }
...@@ -216,7 +215,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -216,7 +215,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
USB_CDC_NCM_CRC_NOT_APPENDED, USB_CDC_NCM_CRC_NOT_APPENDED,
iface_no, NULL, 0); iface_no, NULL, 0);
if (err < 0) if (err < 0)
pr_debug("Setting CRC mode off failed\n"); dev_dbg(&dev->intf->dev, "Setting CRC mode off failed\n");
} }
/* set NTB format, if both formats are supported */ /* set NTB format, if both formats are supported */
...@@ -227,7 +226,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -227,7 +226,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
USB_CDC_NCM_NTB16_FORMAT, USB_CDC_NCM_NTB16_FORMAT,
iface_no, NULL, 0); iface_no, NULL, 0);
if (err < 0) if (err < 0)
pr_debug("Setting NTB format to 16-bit failed\n"); dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit failed\n");
} }
ctx->max_datagram_size = min_dgram_size; ctx->max_datagram_size = min_dgram_size;
...@@ -248,7 +247,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -248,7 +247,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
| USB_RECIP_INTERFACE, | USB_RECIP_INTERFACE,
0, iface_no, &max_datagram_size, 2); 0, iface_no, &max_datagram_size, 2);
if (err < 0) { if (err < 0) {
pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n", dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
min_dgram_size); min_dgram_size);
} else { } else {
ctx->max_datagram_size = ctx->max_datagram_size =
...@@ -275,7 +274,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev) ...@@ -275,7 +274,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
iface_no, &max_datagram_size, iface_no, &max_datagram_size,
2); 2);
if (err < 0) if (err < 0)
pr_debug("SET_MAX_DGRAM_SIZE failed\n"); dev_dbg(&dev->intf->dev, "SET_MAX_DGRAM_SIZE failed\n");
} }
} }
} }
...@@ -867,6 +866,7 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ...@@ -867,6 +866,7 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
/* verify NTB header and return offset of first NDP, or negative error */ /* verify NTB header and return offset of first NDP, or negative error */
int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
{ {
struct usbnet *dev = netdev_priv(skb_in->dev);
struct usb_cdc_ncm_nth16 *nth16; struct usb_cdc_ncm_nth16 *nth16;
int len; int len;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -876,7 +876,7 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) ...@@ -876,7 +876,7 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) + if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) +
sizeof(struct usb_cdc_ncm_ndp16))) { sizeof(struct usb_cdc_ncm_ndp16))) {
pr_debug("frame too short\n"); netif_dbg(dev, rx_err, dev->net, "frame too short\n");
goto error; goto error;
} }
...@@ -890,7 +890,8 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) ...@@ -890,7 +890,8 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
len = le16_to_cpu(nth16->wBlockLength); len = le16_to_cpu(nth16->wBlockLength);
if (len > ctx->rx_max) { if (len > ctx->rx_max) {
pr_debug("unsupported NTB block length %u/%u\n", len, netif_dbg(dev, rx_err, dev->net,
"unsupported NTB block length %u/%u\n", len,
ctx->rx_max); ctx->rx_max);
goto error; goto error;
} }
...@@ -898,7 +899,8 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) ...@@ -898,7 +899,8 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) && if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) &&
(ctx->rx_seq || le16_to_cpu(nth16->wSequence)) && (ctx->rx_seq || le16_to_cpu(nth16->wSequence)) &&
!((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) { !((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) {
pr_debug("sequence number glitch prev=%d curr=%d\n", netif_dbg(dev, rx_err, dev->net,
"sequence number glitch prev=%d curr=%d\n",
ctx->rx_seq, le16_to_cpu(nth16->wSequence)); ctx->rx_seq, le16_to_cpu(nth16->wSequence));
} }
ctx->rx_seq = le16_to_cpu(nth16->wSequence); ctx->rx_seq = le16_to_cpu(nth16->wSequence);
...@@ -912,17 +914,19 @@ EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_nth16); ...@@ -912,17 +914,19 @@ EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_nth16);
/* verify NDP header and return number of datagrams, or negative error */ /* verify NDP header and return number of datagrams, or negative error */
int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
{ {
struct usbnet *dev = netdev_priv(skb_in->dev);
struct usb_cdc_ncm_ndp16 *ndp16; struct usb_cdc_ncm_ndp16 *ndp16;
int ret = -EINVAL; int ret = -EINVAL;
if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) { if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) {
pr_debug("invalid NDP offset <%u>\n", ndpoffset); netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n",
ndpoffset);
goto error; goto error;
} }
ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset);
if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) { if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) {
pr_debug("invalid DPT16 length <%u>\n", netif_dbg(dev, rx_err, dev->net, "invalid DPT16 length <%u>\n",
le16_to_cpu(ndp16->wLength)); le16_to_cpu(ndp16->wLength));
goto error; goto error;
} }
...@@ -932,9 +936,9 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) ...@@ -932,9 +936,9 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
sizeof(struct usb_cdc_ncm_dpe16)); sizeof(struct usb_cdc_ncm_dpe16));
ret--; /* we process NDP entries except for the last one */ ret--; /* we process NDP entries except for the last one */
if ((sizeof(struct usb_cdc_ncm_ndp16) + ret * (sizeof(struct usb_cdc_ncm_dpe16))) > if ((sizeof(struct usb_cdc_ncm_ndp16) +
skb_in->len) { ret * (sizeof(struct usb_cdc_ncm_dpe16))) > skb_in->len) {
pr_debug("Invalid nframes = %d\n", ret); netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -991,8 +995,8 @@ static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) ...@@ -991,8 +995,8 @@ static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
/* sanity checking */ /* sanity checking */
if (((offset + len) > skb_in->len) || if (((offset + len) > skb_in->len) ||
(len > ctx->rx_max) || (len < ETH_HLEN)) { (len > ctx->rx_max) || (len < ETH_HLEN)) {
pr_debug("invalid frame detected (ignored)" netif_dbg(dev, rx_err, dev->net,
"offset[%u]=%u, length=%u, skb=%p\n", "invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
x, offset, len, skb_in); x, offset, len, skb_in);
if (!x) if (!x)
goto err_ndp; goto err_ndp;
...@@ -1031,17 +1035,13 @@ cdc_ncm_speed_change(struct usbnet *dev, ...@@ -1031,17 +1035,13 @@ cdc_ncm_speed_change(struct usbnet *dev,
* device speed. Do print it instead. * device speed. Do print it instead.
*/ */
if ((tx_speed > 1000000) && (rx_speed > 1000000)) { if ((tx_speed > 1000000) && (rx_speed > 1000000)) {
printk(KERN_INFO KBUILD_MODNAME netif_info(dev, link, dev->net,
": %s: %u mbit/s downlink " "%u mbit/s downlink %u mbit/s uplink\n",
"%u mbit/s uplink\n",
dev->net->name,
(unsigned int)(rx_speed / 1000000U), (unsigned int)(rx_speed / 1000000U),
(unsigned int)(tx_speed / 1000000U)); (unsigned int)(tx_speed / 1000000U));
} else { } else {
printk(KERN_INFO KBUILD_MODNAME netif_info(dev, link, dev->net,
": %s: %u kbit/s downlink " "%u kbit/s downlink %u kbit/s uplink\n",
"%u kbit/s uplink\n",
dev->net->name,
(unsigned int)(rx_speed / 1000U), (unsigned int)(rx_speed / 1000U),
(unsigned int)(tx_speed / 1000U)); (unsigned int)(tx_speed / 1000U));
} }
...@@ -1074,11 +1074,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) ...@@ -1074,11 +1074,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
* sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
*/ */
ctx->connected = le16_to_cpu(event->wValue); ctx->connected = le16_to_cpu(event->wValue);
netif_info(dev, link, dev->net,
printk(KERN_INFO KBUILD_MODNAME ": %s: network connection:" "network connection: %sconnected\n",
" %sconnected\n", ctx->connected ? "" : "dis");
dev->net->name, ctx->connected ? "" : "dis");
usbnet_link_change(dev, ctx->connected, 0); usbnet_link_change(dev, ctx->connected, 0);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment