aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2013-11-01 06:16:54 -0400
committerDavid S. Miller <davem@davemloft.net>2013-11-02 02:02:04 -0400
commitae223cd406dd63487ad96593248a669da8e551cd (patch)
treed7b2464db960e16143a01fb95b886f415872570a
parenta26fd05debd00b6f4e776d9dca4a39f0b76b01c7 (diff)
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: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/cdc_ncm.c98
1 files changed, 48 insertions, 50 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index b5fdf8f16f5d..73faf05209b3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -87,7 +87,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
87 0, iface_no, &ncm_parm, 87 0, iface_no, &ncm_parm,
88 sizeof(ncm_parm)); 88 sizeof(ncm_parm));
89 if (err < 0) { 89 if (err < 0) {
90 pr_debug("failed GET_NTB_PARAMETERS\n"); 90 dev_dbg(&dev->intf->dev, "failed GET_NTB_PARAMETERS\n");
91 return 1; 91 return 1;
92 } 92 }
93 93
@@ -115,11 +115,10 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
115 flags = 0; 115 flags = 0;
116 } 116 }
117 117
118 pr_debug("dwNtbInMaxSize=%u dwNtbOutMaxSize=%u " 118 dev_dbg(&dev->intf->dev,
119 "wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u " 119 "dwNtbInMaxSize=%u dwNtbOutMaxSize=%u wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
120 "wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n", 120 ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus,
121 ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus, 121 ctx->tx_ndp_modulus, ctx->tx_max_datagrams, flags);
122 ctx->tx_ndp_modulus, ctx->tx_max_datagrams, flags);
123 122
124 /* max count of tx datagrams */ 123 /* max count of tx datagrams */
125 if ((ctx->tx_max_datagrams == 0) || 124 if ((ctx->tx_max_datagrams == 0) ||
@@ -128,14 +127,14 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
128 127
129 /* verify maximum size of received NTB in bytes */ 128 /* verify maximum size of received NTB in bytes */
130 if (ctx->rx_max < USB_CDC_NCM_NTB_MIN_IN_SIZE) { 129 if (ctx->rx_max < USB_CDC_NCM_NTB_MIN_IN_SIZE) {
131 pr_debug("Using min receive length=%d\n", 130 dev_dbg(&dev->intf->dev, "Using min receive length=%d\n",
132 USB_CDC_NCM_NTB_MIN_IN_SIZE); 131 USB_CDC_NCM_NTB_MIN_IN_SIZE);
133 ctx->rx_max = USB_CDC_NCM_NTB_MIN_IN_SIZE; 132 ctx->rx_max = USB_CDC_NCM_NTB_MIN_IN_SIZE;
134 } 133 }
135 134
136 if (ctx->rx_max > CDC_NCM_NTB_MAX_SIZE_RX) { 135 if (ctx->rx_max > CDC_NCM_NTB_MAX_SIZE_RX) {
137 pr_debug("Using default maximum receive length=%d\n", 136 dev_dbg(&dev->intf->dev, "Using default maximum receive length=%d\n",
138 CDC_NCM_NTB_MAX_SIZE_RX); 137 CDC_NCM_NTB_MAX_SIZE_RX);
139 ctx->rx_max = CDC_NCM_NTB_MAX_SIZE_RX; 138 ctx->rx_max = CDC_NCM_NTB_MAX_SIZE_RX;
140 } 139 }
141 140
@@ -148,15 +147,15 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
148 | USB_RECIP_INTERFACE, 147 | USB_RECIP_INTERFACE,
149 0, iface_no, &dwNtbInMaxSize, 4); 148 0, iface_no, &dwNtbInMaxSize, 4);
150 if (err < 0) 149 if (err < 0)
151 pr_debug("Setting NTB Input Size failed\n"); 150 dev_dbg(&dev->intf->dev, "Setting NTB Input Size failed\n");
152 } 151 }
153 152
154 /* verify maximum size of transmitted NTB in bytes */ 153 /* verify maximum size of transmitted NTB in bytes */
155 if ((ctx->tx_max < 154 if ((ctx->tx_max <
156 (min_hdr_size + min_dgram_size)) || 155 (min_hdr_size + min_dgram_size)) ||
157 (ctx->tx_max > CDC_NCM_NTB_MAX_SIZE_TX)) { 156 (ctx->tx_max > CDC_NCM_NTB_MAX_SIZE_TX)) {
158 pr_debug("Using default maximum transmit length=%d\n", 157 dev_dbg(&dev->intf->dev, "Using default maximum transmit length=%d\n",
159 CDC_NCM_NTB_MAX_SIZE_TX); 158 CDC_NCM_NTB_MAX_SIZE_TX);
160 ctx->tx_max = CDC_NCM_NTB_MAX_SIZE_TX; 159 ctx->tx_max = CDC_NCM_NTB_MAX_SIZE_TX;
161 160
162 /* Adding a pad byte here simplifies the handling in 161 /* Adding a pad byte here simplifies the handling in
@@ -178,7 +177,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
178 177
179 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) || 178 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
180 (val != ((-val) & val)) || (val >= ctx->tx_max)) { 179 (val != ((-val) & val)) || (val >= ctx->tx_max)) {
181 pr_debug("Using default alignment: 4 bytes\n"); 180 dev_dbg(&dev->intf->dev, "Using default alignment: 4 bytes\n");
182 ctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE; 181 ctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
183 } 182 }
184 183
@@ -192,13 +191,13 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
192 191
193 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) || 192 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
194 (val != ((-val) & val)) || (val >= ctx->tx_max)) { 193 (val != ((-val) & val)) || (val >= ctx->tx_max)) {
195 pr_debug("Using default transmit modulus: 4 bytes\n"); 194 dev_dbg(&dev->intf->dev, "Using default transmit modulus: 4 bytes\n");
196 ctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE; 195 ctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
197 } 196 }
198 197
199 /* verify the payload remainder */ 198 /* verify the payload remainder */
200 if (ctx->tx_remainder >= ctx->tx_modulus) { 199 if (ctx->tx_remainder >= ctx->tx_modulus) {
201 pr_debug("Using default transmit remainder: 0 bytes\n"); 200 dev_dbg(&dev->intf->dev, "Using default transmit remainder: 0 bytes\n");
202 ctx->tx_remainder = 0; 201 ctx->tx_remainder = 0;
203 } 202 }
204 203
@@ -216,7 +215,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
216 USB_CDC_NCM_CRC_NOT_APPENDED, 215 USB_CDC_NCM_CRC_NOT_APPENDED,
217 iface_no, NULL, 0); 216 iface_no, NULL, 0);
218 if (err < 0) 217 if (err < 0)
219 pr_debug("Setting CRC mode off failed\n"); 218 dev_dbg(&dev->intf->dev, "Setting CRC mode off failed\n");
220 } 219 }
221 220
222 /* set NTB format, if both formats are supported */ 221 /* set NTB format, if both formats are supported */
@@ -227,7 +226,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
227 USB_CDC_NCM_NTB16_FORMAT, 226 USB_CDC_NCM_NTB16_FORMAT,
228 iface_no, NULL, 0); 227 iface_no, NULL, 0);
229 if (err < 0) 228 if (err < 0)
230 pr_debug("Setting NTB format to 16-bit failed\n"); 229 dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit failed\n");
231 } 230 }
232 231
233 ctx->max_datagram_size = min_dgram_size; 232 ctx->max_datagram_size = min_dgram_size;
@@ -248,8 +247,8 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
248 | USB_RECIP_INTERFACE, 247 | USB_RECIP_INTERFACE,
249 0, iface_no, &max_datagram_size, 2); 248 0, iface_no, &max_datagram_size, 2);
250 if (err < 0) { 249 if (err < 0) {
251 pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n", 250 dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
252 min_dgram_size); 251 min_dgram_size);
253 } else { 252 } else {
254 ctx->max_datagram_size = 253 ctx->max_datagram_size =
255 le16_to_cpu(max_datagram_size); 254 le16_to_cpu(max_datagram_size);
@@ -275,7 +274,7 @@ static u8 cdc_ncm_setup(struct usbnet *dev)
275 iface_no, &max_datagram_size, 274 iface_no, &max_datagram_size,
276 2); 275 2);
277 if (err < 0) 276 if (err < 0)
278 pr_debug("SET_MAX_DGRAM_SIZE failed\n"); 277 dev_dbg(&dev->intf->dev, "SET_MAX_DGRAM_SIZE failed\n");
279 } 278 }
280 } 279 }
281 } 280 }
@@ -867,6 +866,7 @@ error:
867/* verify NTB header and return offset of first NDP, or negative error */ 866/* verify NTB header and return offset of first NDP, or negative error */
868int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in) 867int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
869{ 868{
869 struct usbnet *dev = netdev_priv(skb_in->dev);
870 struct usb_cdc_ncm_nth16 *nth16; 870 struct usb_cdc_ncm_nth16 *nth16;
871 int len; 871 int len;
872 int ret = -EINVAL; 872 int ret = -EINVAL;
@@ -876,7 +876,7 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
876 876
877 if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) + 877 if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) +
878 sizeof(struct usb_cdc_ncm_ndp16))) { 878 sizeof(struct usb_cdc_ncm_ndp16))) {
879 pr_debug("frame too short\n"); 879 netif_dbg(dev, rx_err, dev->net, "frame too short\n");
880 goto error; 880 goto error;
881 } 881 }
882 882
@@ -890,16 +890,18 @@ int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
890 890
891 len = le16_to_cpu(nth16->wBlockLength); 891 len = le16_to_cpu(nth16->wBlockLength);
892 if (len > ctx->rx_max) { 892 if (len > ctx->rx_max) {
893 pr_debug("unsupported NTB block length %u/%u\n", len, 893 netif_dbg(dev, rx_err, dev->net,
894 ctx->rx_max); 894 "unsupported NTB block length %u/%u\n", len,
895 ctx->rx_max);
895 goto error; 896 goto error;
896 } 897 }
897 898
898 if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) && 899 if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) &&
899 (ctx->rx_seq || le16_to_cpu(nth16->wSequence)) && 900 (ctx->rx_seq || le16_to_cpu(nth16->wSequence)) &&
900 !((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) { 901 !((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) {
901 pr_debug("sequence number glitch prev=%d curr=%d\n", 902 netif_dbg(dev, rx_err, dev->net,
902 ctx->rx_seq, le16_to_cpu(nth16->wSequence)); 903 "sequence number glitch prev=%d curr=%d\n",
904 ctx->rx_seq, le16_to_cpu(nth16->wSequence));
903 } 905 }
904 ctx->rx_seq = le16_to_cpu(nth16->wSequence); 906 ctx->rx_seq = le16_to_cpu(nth16->wSequence);
905 907
@@ -912,18 +914,20 @@ EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_nth16);
912/* verify NDP header and return number of datagrams, or negative error */ 914/* verify NDP header and return number of datagrams, or negative error */
913int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) 915int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
914{ 916{
917 struct usbnet *dev = netdev_priv(skb_in->dev);
915 struct usb_cdc_ncm_ndp16 *ndp16; 918 struct usb_cdc_ncm_ndp16 *ndp16;
916 int ret = -EINVAL; 919 int ret = -EINVAL;
917 920
918 if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) { 921 if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) {
919 pr_debug("invalid NDP offset <%u>\n", ndpoffset); 922 netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n",
923 ndpoffset);
920 goto error; 924 goto error;
921 } 925 }
922 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); 926 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset);
923 927
924 if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) { 928 if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) {
925 pr_debug("invalid DPT16 length <%u>\n", 929 netif_dbg(dev, rx_err, dev->net, "invalid DPT16 length <%u>\n",
926 le16_to_cpu(ndp16->wLength)); 930 le16_to_cpu(ndp16->wLength));
927 goto error; 931 goto error;
928 } 932 }
929 933
@@ -932,9 +936,9 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
932 sizeof(struct usb_cdc_ncm_dpe16)); 936 sizeof(struct usb_cdc_ncm_dpe16));
933 ret--; /* we process NDP entries except for the last one */ 937 ret--; /* we process NDP entries except for the last one */
934 938
935 if ((sizeof(struct usb_cdc_ncm_ndp16) + ret * (sizeof(struct usb_cdc_ncm_dpe16))) > 939 if ((sizeof(struct usb_cdc_ncm_ndp16) +
936 skb_in->len) { 940 ret * (sizeof(struct usb_cdc_ncm_dpe16))) > skb_in->len) {
937 pr_debug("Invalid nframes = %d\n", ret); 941 netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
938 ret = -EINVAL; 942 ret = -EINVAL;
939 } 943 }
940 944
@@ -991,9 +995,9 @@ next_ndp:
991 /* sanity checking */ 995 /* sanity checking */
992 if (((offset + len) > skb_in->len) || 996 if (((offset + len) > skb_in->len) ||
993 (len > ctx->rx_max) || (len < ETH_HLEN)) { 997 (len > ctx->rx_max) || (len < ETH_HLEN)) {
994 pr_debug("invalid frame detected (ignored)" 998 netif_dbg(dev, rx_err, dev->net,
995 "offset[%u]=%u, length=%u, skb=%p\n", 999 "invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
996 x, offset, len, skb_in); 1000 x, offset, len, skb_in);
997 if (!x) 1001 if (!x)
998 goto err_ndp; 1002 goto err_ndp;
999 break; 1003 break;
@@ -1031,17 +1035,13 @@ cdc_ncm_speed_change(struct usbnet *dev,
1031 * device speed. Do print it instead. 1035 * device speed. Do print it instead.
1032 */ 1036 */
1033 if ((tx_speed > 1000000) && (rx_speed > 1000000)) { 1037 if ((tx_speed > 1000000) && (rx_speed > 1000000)) {
1034 printk(KERN_INFO KBUILD_MODNAME 1038 netif_info(dev, link, dev->net,
1035 ": %s: %u mbit/s downlink " 1039 "%u mbit/s downlink %u mbit/s uplink\n",
1036 "%u mbit/s uplink\n",
1037 dev->net->name,
1038 (unsigned int)(rx_speed / 1000000U), 1040 (unsigned int)(rx_speed / 1000000U),
1039 (unsigned int)(tx_speed / 1000000U)); 1041 (unsigned int)(tx_speed / 1000000U));
1040 } else { 1042 } else {
1041 printk(KERN_INFO KBUILD_MODNAME 1043 netif_info(dev, link, dev->net,
1042 ": %s: %u kbit/s downlink " 1044 "%u kbit/s downlink %u kbit/s uplink\n",
1043 "%u kbit/s uplink\n",
1044 dev->net->name,
1045 (unsigned int)(rx_speed / 1000U), 1045 (unsigned int)(rx_speed / 1000U),
1046 (unsigned int)(tx_speed / 1000U)); 1046 (unsigned int)(tx_speed / 1000U));
1047 } 1047 }
@@ -1074,11 +1074,9 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
1074 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE. 1074 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
1075 */ 1075 */
1076 ctx->connected = le16_to_cpu(event->wValue); 1076 ctx->connected = le16_to_cpu(event->wValue);
1077 1077 netif_info(dev, link, dev->net,
1078 printk(KERN_INFO KBUILD_MODNAME ": %s: network connection:" 1078 "network connection: %sconnected\n",
1079 " %sconnected\n", 1079 ctx->connected ? "" : "dis");
1080 dev->net->name, ctx->connected ? "" : "dis");
1081
1082 usbnet_link_change(dev, ctx->connected, 0); 1080 usbnet_link_change(dev, ctx->connected, 0);
1083 break; 1081 break;
1084 1082