diff options
author | Mihai Donțu <mihai.dontu@gmail.com> | 2010-09-07 19:54:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:21:30 -0400 |
commit | a1df4e45c81ec9ae6b537f845db48b82ab40ac4f (patch) | |
tree | c4bdfe73586fbaa8e7a330019bdd18f790c2eee2 /drivers/usb/gadget/rndis.c | |
parent | 65fd42724aee31018b0bb53f4cb04971423be664 (diff) |
USB: gadget: rndis: fix up coding style issues in the file
Corrected the coding style.
Signed-off-by: Mihai Dontu <mihai.dontu@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/rndis.c')
-rw-r--r-- | drivers/usb/gadget/rndis.c | 492 |
1 files changed, 244 insertions, 248 deletions
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c index 972d5ddd1e18..5b314041dfa9 100644 --- a/drivers/usb/gadget/rndis.c +++ b/drivers/usb/gadget/rndis.c | |||
@@ -61,17 +61,17 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging"); | |||
61 | #define RNDIS_MAX_CONFIGS 1 | 61 | #define RNDIS_MAX_CONFIGS 1 |
62 | 62 | ||
63 | 63 | ||
64 | static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS]; | 64 | static rndis_params rndis_per_dev_params[RNDIS_MAX_CONFIGS]; |
65 | 65 | ||
66 | /* Driver Version */ | 66 | /* Driver Version */ |
67 | static const __le32 rndis_driver_version = cpu_to_le32 (1); | 67 | static const __le32 rndis_driver_version = cpu_to_le32(1); |
68 | 68 | ||
69 | /* Function Prototypes */ | 69 | /* Function Prototypes */ |
70 | static rndis_resp_t *rndis_add_response (int configNr, u32 length); | 70 | static rndis_resp_t *rndis_add_response(int configNr, u32 length); |
71 | 71 | ||
72 | 72 | ||
73 | /* supported OIDs */ | 73 | /* supported OIDs */ |
74 | static const u32 oid_supported_list [] = | 74 | static const u32 oid_supported_list[] = |
75 | { | 75 | { |
76 | /* the general stuff */ | 76 | /* the general stuff */ |
77 | OID_GEN_SUPPORTED_LIST, | 77 | OID_GEN_SUPPORTED_LIST, |
@@ -161,21 +161,20 @@ static const u32 oid_supported_list [] = | |||
161 | 161 | ||
162 | 162 | ||
163 | /* NDIS Functions */ | 163 | /* NDIS Functions */ |
164 | static int | 164 | static int gen_ndis_query_resp(int configNr, u32 OID, u8 *buf, |
165 | gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | 165 | unsigned buf_len, rndis_resp_t *r) |
166 | rndis_resp_t *r) | ||
167 | { | 166 | { |
168 | int retval = -ENOTSUPP; | 167 | int retval = -ENOTSUPP; |
169 | u32 length = 4; /* usually */ | 168 | u32 length = 4; /* usually */ |
170 | __le32 *outbuf; | 169 | __le32 *outbuf; |
171 | int i, count; | 170 | int i, count; |
172 | rndis_query_cmplt_type *resp; | 171 | rndis_query_cmplt_type *resp; |
173 | struct net_device *net; | 172 | struct net_device *net; |
174 | struct rtnl_link_stats64 temp; | 173 | struct rtnl_link_stats64 temp; |
175 | const struct rtnl_link_stats64 *stats; | 174 | const struct rtnl_link_stats64 *stats; |
176 | 175 | ||
177 | if (!r) return -ENOMEM; | 176 | if (!r) return -ENOMEM; |
178 | resp = (rndis_query_cmplt_type *) r->buf; | 177 | resp = (rndis_query_cmplt_type *)r->buf; |
179 | 178 | ||
180 | if (!resp) return -ENOMEM; | 179 | if (!resp) return -ENOMEM; |
181 | 180 | ||
@@ -191,8 +190,8 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
191 | } | 190 | } |
192 | 191 | ||
193 | /* response goes here, right after the header */ | 192 | /* response goes here, right after the header */ |
194 | outbuf = (__le32 *) &resp[1]; | 193 | outbuf = (__le32 *)&resp[1]; |
195 | resp->InformationBufferOffset = cpu_to_le32 (16); | 194 | resp->InformationBufferOffset = cpu_to_le32(16); |
196 | 195 | ||
197 | net = rndis_per_dev_params[configNr].dev; | 196 | net = rndis_per_dev_params[configNr].dev; |
198 | stats = dev_get_stats(net, &temp); | 197 | stats = dev_get_stats(net, &temp); |
@@ -204,10 +203,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
204 | /* mandatory */ | 203 | /* mandatory */ |
205 | case OID_GEN_SUPPORTED_LIST: | 204 | case OID_GEN_SUPPORTED_LIST: |
206 | pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); | 205 | pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); |
207 | length = sizeof (oid_supported_list); | 206 | length = sizeof(oid_supported_list); |
208 | count = length / sizeof (u32); | 207 | count = length / sizeof(u32); |
209 | for (i = 0; i < count; i++) | 208 | for (i = 0; i < count; i++) |
210 | outbuf[i] = cpu_to_le32 (oid_supported_list[i]); | 209 | outbuf[i] = cpu_to_le32(oid_supported_list[i]); |
211 | retval = 0; | 210 | retval = 0; |
212 | break; | 211 | break; |
213 | 212 | ||
@@ -220,14 +219,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
220 | * reddite ergo quae sunt Caesaris Caesari | 219 | * reddite ergo quae sunt Caesaris Caesari |
221 | * et quae sunt Dei Deo! | 220 | * et quae sunt Dei Deo! |
222 | */ | 221 | */ |
223 | *outbuf = cpu_to_le32 (0); | 222 | *outbuf = cpu_to_le32(0); |
224 | retval = 0; | 223 | retval = 0; |
225 | break; | 224 | break; |
226 | 225 | ||
227 | /* mandatory */ | 226 | /* mandatory */ |
228 | case OID_GEN_MEDIA_SUPPORTED: | 227 | case OID_GEN_MEDIA_SUPPORTED: |
229 | pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); | 228 | pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); |
230 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); | 229 | *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium); |
231 | retval = 0; | 230 | retval = 0; |
232 | break; | 231 | break; |
233 | 232 | ||
@@ -235,16 +234,16 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
235 | case OID_GEN_MEDIA_IN_USE: | 234 | case OID_GEN_MEDIA_IN_USE: |
236 | pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); | 235 | pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); |
237 | /* one medium, one transport... (maybe you do it better) */ | 236 | /* one medium, one transport... (maybe you do it better) */ |
238 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); | 237 | *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium); |
239 | retval = 0; | 238 | retval = 0; |
240 | break; | 239 | break; |
241 | 240 | ||
242 | /* mandatory */ | 241 | /* mandatory */ |
243 | case OID_GEN_MAXIMUM_FRAME_SIZE: | 242 | case OID_GEN_MAXIMUM_FRAME_SIZE: |
244 | pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); | 243 | pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); |
245 | if (rndis_per_dev_params [configNr].dev) { | 244 | if (rndis_per_dev_params[configNr].dev) { |
246 | *outbuf = cpu_to_le32 ( | 245 | *outbuf = cpu_to_le32( |
247 | rndis_per_dev_params [configNr].dev->mtu); | 246 | rndis_per_dev_params[configNr].dev->mtu); |
248 | retval = 0; | 247 | retval = 0; |
249 | } | 248 | } |
250 | break; | 249 | break; |
@@ -253,21 +252,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
253 | case OID_GEN_LINK_SPEED: | 252 | case OID_GEN_LINK_SPEED: |
254 | if (rndis_debug > 1) | 253 | if (rndis_debug > 1) |
255 | pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); | 254 | pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); |
256 | if (rndis_per_dev_params [configNr].media_state | 255 | if (rndis_per_dev_params[configNr].media_state |
257 | == NDIS_MEDIA_STATE_DISCONNECTED) | 256 | == NDIS_MEDIA_STATE_DISCONNECTED) |
258 | *outbuf = cpu_to_le32 (0); | 257 | *outbuf = cpu_to_le32(0); |
259 | else | 258 | else |
260 | *outbuf = cpu_to_le32 ( | 259 | *outbuf = cpu_to_le32( |
261 | rndis_per_dev_params [configNr].speed); | 260 | rndis_per_dev_params[configNr].speed); |
262 | retval = 0; | 261 | retval = 0; |
263 | break; | 262 | break; |
264 | 263 | ||
265 | /* mandatory */ | 264 | /* mandatory */ |
266 | case OID_GEN_TRANSMIT_BLOCK_SIZE: | 265 | case OID_GEN_TRANSMIT_BLOCK_SIZE: |
267 | pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); | 266 | pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); |
268 | if (rndis_per_dev_params [configNr].dev) { | 267 | if (rndis_per_dev_params[configNr].dev) { |
269 | *outbuf = cpu_to_le32 ( | 268 | *outbuf = cpu_to_le32( |
270 | rndis_per_dev_params [configNr].dev->mtu); | 269 | rndis_per_dev_params[configNr].dev->mtu); |
271 | retval = 0; | 270 | retval = 0; |
272 | } | 271 | } |
273 | break; | 272 | break; |
@@ -275,9 +274,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
275 | /* mandatory */ | 274 | /* mandatory */ |
276 | case OID_GEN_RECEIVE_BLOCK_SIZE: | 275 | case OID_GEN_RECEIVE_BLOCK_SIZE: |
277 | pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); | 276 | pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); |
278 | if (rndis_per_dev_params [configNr].dev) { | 277 | if (rndis_per_dev_params[configNr].dev) { |
279 | *outbuf = cpu_to_le32 ( | 278 | *outbuf = cpu_to_le32( |
280 | rndis_per_dev_params [configNr].dev->mtu); | 279 | rndis_per_dev_params[configNr].dev->mtu); |
281 | retval = 0; | 280 | retval = 0; |
282 | } | 281 | } |
283 | break; | 282 | break; |
@@ -285,18 +284,20 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
285 | /* mandatory */ | 284 | /* mandatory */ |
286 | case OID_GEN_VENDOR_ID: | 285 | case OID_GEN_VENDOR_ID: |
287 | pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); | 286 | pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); |
288 | *outbuf = cpu_to_le32 ( | 287 | *outbuf = cpu_to_le32( |
289 | rndis_per_dev_params [configNr].vendorID); | 288 | rndis_per_dev_params[configNr].vendorID); |
290 | retval = 0; | 289 | retval = 0; |
291 | break; | 290 | break; |
292 | 291 | ||
293 | /* mandatory */ | 292 | /* mandatory */ |
294 | case OID_GEN_VENDOR_DESCRIPTION: | 293 | case OID_GEN_VENDOR_DESCRIPTION: |
295 | pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); | 294 | pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); |
296 | if ( rndis_per_dev_params [configNr].vendorDescr ) { | 295 | if (rndis_per_dev_params[configNr].vendorDescr) { |
297 | length = strlen (rndis_per_dev_params [configNr].vendorDescr); | 296 | length = strlen(rndis_per_dev_params[configNr]. |
298 | memcpy (outbuf, | 297 | vendorDescr); |
299 | rndis_per_dev_params [configNr].vendorDescr, length); | 298 | memcpy(outbuf, |
299 | rndis_per_dev_params[configNr].vendorDescr, | ||
300 | length); | ||
300 | } else { | 301 | } else { |
301 | outbuf[0] = 0; | 302 | outbuf[0] = 0; |
302 | } | 303 | } |
@@ -313,7 +314,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
313 | /* mandatory */ | 314 | /* mandatory */ |
314 | case OID_GEN_CURRENT_PACKET_FILTER: | 315 | case OID_GEN_CURRENT_PACKET_FILTER: |
315 | pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); | 316 | pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); |
316 | *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); | 317 | *outbuf = cpu_to_le32(*rndis_per_dev_params[configNr].filter); |
317 | retval = 0; | 318 | retval = 0; |
318 | break; | 319 | break; |
319 | 320 | ||
@@ -328,14 +329,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
328 | case OID_GEN_MEDIA_CONNECT_STATUS: | 329 | case OID_GEN_MEDIA_CONNECT_STATUS: |
329 | if (rndis_debug > 1) | 330 | if (rndis_debug > 1) |
330 | pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); | 331 | pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); |
331 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] | 332 | *outbuf = cpu_to_le32(rndis_per_dev_params[configNr] |
332 | .media_state); | 333 | .media_state); |
333 | retval = 0; | 334 | retval = 0; |
334 | break; | 335 | break; |
335 | 336 | ||
336 | case OID_GEN_PHYSICAL_MEDIUM: | 337 | case OID_GEN_PHYSICAL_MEDIUM: |
337 | pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); | 338 | pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); |
338 | *outbuf = cpu_to_le32 (0); | 339 | *outbuf = cpu_to_le32(0); |
339 | retval = 0; | 340 | retval = 0; |
340 | break; | 341 | break; |
341 | 342 | ||
@@ -409,10 +410,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
409 | /* mandatory */ | 410 | /* mandatory */ |
410 | case OID_802_3_PERMANENT_ADDRESS: | 411 | case OID_802_3_PERMANENT_ADDRESS: |
411 | pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); | 412 | pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); |
412 | if (rndis_per_dev_params [configNr].dev) { | 413 | if (rndis_per_dev_params[configNr].dev) { |
413 | length = ETH_ALEN; | 414 | length = ETH_ALEN; |
414 | memcpy (outbuf, | 415 | memcpy(outbuf, |
415 | rndis_per_dev_params [configNr].host_mac, | 416 | rndis_per_dev_params[configNr].host_mac, |
416 | length); | 417 | length); |
417 | retval = 0; | 418 | retval = 0; |
418 | } | 419 | } |
@@ -421,9 +422,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
421 | /* mandatory */ | 422 | /* mandatory */ |
422 | case OID_802_3_CURRENT_ADDRESS: | 423 | case OID_802_3_CURRENT_ADDRESS: |
423 | pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); | 424 | pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); |
424 | if (rndis_per_dev_params [configNr].dev) { | 425 | if (rndis_per_dev_params[configNr].dev) { |
425 | length = ETH_ALEN; | 426 | length = ETH_ALEN; |
426 | memcpy (outbuf, | 427 | memcpy(outbuf, |
427 | rndis_per_dev_params [configNr].host_mac, | 428 | rndis_per_dev_params [configNr].host_mac, |
428 | length); | 429 | length); |
429 | retval = 0; | 430 | retval = 0; |
@@ -434,7 +435,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
434 | case OID_802_3_MULTICAST_LIST: | 435 | case OID_802_3_MULTICAST_LIST: |
435 | pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); | 436 | pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); |
436 | /* Multicast base address only */ | 437 | /* Multicast base address only */ |
437 | *outbuf = cpu_to_le32 (0xE0000000); | 438 | *outbuf = cpu_to_le32(0xE0000000); |
438 | retval = 0; | 439 | retval = 0; |
439 | break; | 440 | break; |
440 | 441 | ||
@@ -442,7 +443,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
442 | case OID_802_3_MAXIMUM_LIST_SIZE: | 443 | case OID_802_3_MAXIMUM_LIST_SIZE: |
443 | pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); | 444 | pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); |
444 | /* Multicast base address only */ | 445 | /* Multicast base address only */ |
445 | *outbuf = cpu_to_le32 (1); | 446 | *outbuf = cpu_to_le32(1); |
446 | retval = 0; | 447 | retval = 0; |
447 | break; | 448 | break; |
448 | 449 | ||
@@ -466,14 +467,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
466 | /* mandatory */ | 467 | /* mandatory */ |
467 | case OID_802_3_XMIT_ONE_COLLISION: | 468 | case OID_802_3_XMIT_ONE_COLLISION: |
468 | pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); | 469 | pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); |
469 | *outbuf = cpu_to_le32 (0); | 470 | *outbuf = cpu_to_le32(0); |
470 | retval = 0; | 471 | retval = 0; |
471 | break; | 472 | break; |
472 | 473 | ||
473 | /* mandatory */ | 474 | /* mandatory */ |
474 | case OID_802_3_XMIT_MORE_COLLISIONS: | 475 | case OID_802_3_XMIT_MORE_COLLISIONS: |
475 | pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); | 476 | pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); |
476 | *outbuf = cpu_to_le32 (0); | 477 | *outbuf = cpu_to_le32(0); |
477 | retval = 0; | 478 | retval = 0; |
478 | break; | 479 | break; |
479 | 480 | ||
@@ -484,22 +485,22 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, | |||
484 | if (retval < 0) | 485 | if (retval < 0) |
485 | length = 0; | 486 | length = 0; |
486 | 487 | ||
487 | resp->InformationBufferLength = cpu_to_le32 (length); | 488 | resp->InformationBufferLength = cpu_to_le32(length); |
488 | r->length = length + sizeof *resp; | 489 | r->length = length + sizeof(*resp); |
489 | resp->MessageLength = cpu_to_le32 (r->length); | 490 | resp->MessageLength = cpu_to_le32(r->length); |
490 | return retval; | 491 | return retval; |
491 | } | 492 | } |
492 | 493 | ||
493 | static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | 494 | static int gen_ndis_set_resp(u8 configNr, u32 OID, u8 *buf, u32 buf_len, |
494 | rndis_resp_t *r) | 495 | rndis_resp_t *r) |
495 | { | 496 | { |
496 | rndis_set_cmplt_type *resp; | 497 | rndis_set_cmplt_type *resp; |
497 | int i, retval = -ENOTSUPP; | 498 | int i, retval = -ENOTSUPP; |
498 | struct rndis_params *params; | 499 | struct rndis_params *params; |
499 | 500 | ||
500 | if (!r) | 501 | if (!r) |
501 | return -ENOMEM; | 502 | return -ENOMEM; |
502 | resp = (rndis_set_cmplt_type *) r->buf; | 503 | resp = (rndis_set_cmplt_type *)r->buf; |
503 | if (!resp) | 504 | if (!resp) |
504 | return -ENOMEM; | 505 | return -ENOMEM; |
505 | 506 | ||
@@ -514,7 +515,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
514 | } | 515 | } |
515 | } | 516 | } |
516 | 517 | ||
517 | params = &rndis_per_dev_params [configNr]; | 518 | params = &rndis_per_dev_params[configNr]; |
518 | switch (OID) { | 519 | switch (OID) { |
519 | case OID_GEN_CURRENT_PACKET_FILTER: | 520 | case OID_GEN_CURRENT_PACKET_FILTER: |
520 | 521 | ||
@@ -537,11 +538,11 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
537 | params->state = RNDIS_DATA_INITIALIZED; | 538 | params->state = RNDIS_DATA_INITIALIZED; |
538 | netif_carrier_on(params->dev); | 539 | netif_carrier_on(params->dev); |
539 | if (netif_running(params->dev)) | 540 | if (netif_running(params->dev)) |
540 | netif_wake_queue (params->dev); | 541 | netif_wake_queue(params->dev); |
541 | } else { | 542 | } else { |
542 | params->state = RNDIS_INITIALIZED; | 543 | params->state = RNDIS_INITIALIZED; |
543 | netif_carrier_off (params->dev); | 544 | netif_carrier_off(params->dev); |
544 | netif_stop_queue (params->dev); | 545 | netif_stop_queue(params->dev); |
545 | } | 546 | } |
546 | break; | 547 | break; |
547 | 548 | ||
@@ -563,48 +564,47 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, | |||
563 | * Response Functions | 564 | * Response Functions |
564 | */ | 565 | */ |
565 | 566 | ||
566 | static int rndis_init_response (int configNr, rndis_init_msg_type *buf) | 567 | static int rndis_init_response(int configNr, rndis_init_msg_type *buf) |
567 | { | 568 | { |
568 | rndis_init_cmplt_type *resp; | 569 | rndis_init_cmplt_type *resp; |
569 | rndis_resp_t *r; | 570 | rndis_resp_t *r; |
570 | struct rndis_params *params = rndis_per_dev_params + configNr; | 571 | struct rndis_params *params = rndis_per_dev_params + configNr; |
571 | 572 | ||
572 | if (!params->dev) | 573 | if (!params->dev) |
573 | return -ENOTSUPP; | 574 | return -ENOTSUPP; |
574 | 575 | ||
575 | r = rndis_add_response (configNr, sizeof (rndis_init_cmplt_type)); | 576 | r = rndis_add_response(configNr, sizeof(rndis_init_cmplt_type)); |
576 | if (!r) | 577 | if (!r) |
577 | return -ENOMEM; | 578 | return -ENOMEM; |
578 | resp = (rndis_init_cmplt_type *) r->buf; | 579 | resp = (rndis_init_cmplt_type *)r->buf; |
579 | 580 | ||
580 | resp->MessageType = cpu_to_le32 ( | 581 | resp->MessageType = cpu_to_le32(REMOTE_NDIS_INITIALIZE_CMPLT); |
581 | REMOTE_NDIS_INITIALIZE_CMPLT); | 582 | resp->MessageLength = cpu_to_le32(52); |
582 | resp->MessageLength = cpu_to_le32 (52); | ||
583 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ | 583 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
584 | resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); | 584 | resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); |
585 | resp->MajorVersion = cpu_to_le32 (RNDIS_MAJOR_VERSION); | 585 | resp->MajorVersion = cpu_to_le32(RNDIS_MAJOR_VERSION); |
586 | resp->MinorVersion = cpu_to_le32 (RNDIS_MINOR_VERSION); | 586 | resp->MinorVersion = cpu_to_le32(RNDIS_MINOR_VERSION); |
587 | resp->DeviceFlags = cpu_to_le32 (RNDIS_DF_CONNECTIONLESS); | 587 | resp->DeviceFlags = cpu_to_le32(RNDIS_DF_CONNECTIONLESS); |
588 | resp->Medium = cpu_to_le32 (RNDIS_MEDIUM_802_3); | 588 | resp->Medium = cpu_to_le32(RNDIS_MEDIUM_802_3); |
589 | resp->MaxPacketsPerTransfer = cpu_to_le32 (1); | 589 | resp->MaxPacketsPerTransfer = cpu_to_le32(1); |
590 | resp->MaxTransferSize = cpu_to_le32 ( | 590 | resp->MaxTransferSize = cpu_to_le32( |
591 | params->dev->mtu | 591 | params->dev->mtu |
592 | + sizeof (struct ethhdr) | 592 | + sizeof(struct ethhdr) |
593 | + sizeof (struct rndis_packet_msg_type) | 593 | + sizeof(struct rndis_packet_msg_type) |
594 | + 22); | 594 | + 22); |
595 | resp->PacketAlignmentFactor = cpu_to_le32 (0); | 595 | resp->PacketAlignmentFactor = cpu_to_le32(0); |
596 | resp->AFListOffset = cpu_to_le32 (0); | 596 | resp->AFListOffset = cpu_to_le32(0); |
597 | resp->AFListSize = cpu_to_le32 (0); | 597 | resp->AFListSize = cpu_to_le32(0); |
598 | 598 | ||
599 | params->resp_avail(params->v); | 599 | params->resp_avail(params->v); |
600 | return 0; | 600 | return 0; |
601 | } | 601 | } |
602 | 602 | ||
603 | static int rndis_query_response (int configNr, rndis_query_msg_type *buf) | 603 | static int rndis_query_response(int configNr, rndis_query_msg_type *buf) |
604 | { | 604 | { |
605 | rndis_query_cmplt_type *resp; | 605 | rndis_query_cmplt_type *resp; |
606 | rndis_resp_t *r; | 606 | rndis_resp_t *r; |
607 | struct rndis_params *params = rndis_per_dev_params + configNr; | 607 | struct rndis_params *params = rndis_per_dev_params + configNr; |
608 | 608 | ||
609 | /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ | 609 | /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ |
610 | if (!params->dev) | 610 | if (!params->dev) |
@@ -616,47 +616,46 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) | |||
616 | * rndis_query_cmplt_type followed by data. | 616 | * rndis_query_cmplt_type followed by data. |
617 | * oid_supported_list is the largest data reply | 617 | * oid_supported_list is the largest data reply |
618 | */ | 618 | */ |
619 | r = rndis_add_response (configNr, | 619 | r = rndis_add_response(configNr, |
620 | sizeof (oid_supported_list) + sizeof(rndis_query_cmplt_type)); | 620 | sizeof(oid_supported_list) + sizeof(rndis_query_cmplt_type)); |
621 | if (!r) | 621 | if (!r) |
622 | return -ENOMEM; | 622 | return -ENOMEM; |
623 | resp = (rndis_query_cmplt_type *) r->buf; | 623 | resp = (rndis_query_cmplt_type *)r->buf; |
624 | 624 | ||
625 | resp->MessageType = cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT); | 625 | resp->MessageType = cpu_to_le32(REMOTE_NDIS_QUERY_CMPLT); |
626 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ | 626 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
627 | 627 | ||
628 | if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID), | 628 | if (gen_ndis_query_resp(configNr, le32_to_cpu(buf->OID), |
629 | le32_to_cpu(buf->InformationBufferOffset) | 629 | le32_to_cpu(buf->InformationBufferOffset) |
630 | + 8 + (u8 *) buf, | 630 | + 8 + (u8 *)buf, |
631 | le32_to_cpu(buf->InformationBufferLength), | 631 | le32_to_cpu(buf->InformationBufferLength), |
632 | r)) { | 632 | r)) { |
633 | /* OID not supported */ | 633 | /* OID not supported */ |
634 | resp->Status = cpu_to_le32 ( | 634 | resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); |
635 | RNDIS_STATUS_NOT_SUPPORTED); | 635 | resp->MessageLength = cpu_to_le32(sizeof *resp); |
636 | resp->MessageLength = cpu_to_le32 (sizeof *resp); | 636 | resp->InformationBufferLength = cpu_to_le32(0); |
637 | resp->InformationBufferLength = cpu_to_le32 (0); | 637 | resp->InformationBufferOffset = cpu_to_le32(0); |
638 | resp->InformationBufferOffset = cpu_to_le32 (0); | ||
639 | } else | 638 | } else |
640 | resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); | 639 | resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); |
641 | 640 | ||
642 | params->resp_avail(params->v); | 641 | params->resp_avail(params->v); |
643 | return 0; | 642 | return 0; |
644 | } | 643 | } |
645 | 644 | ||
646 | static int rndis_set_response (int configNr, rndis_set_msg_type *buf) | 645 | static int rndis_set_response(int configNr, rndis_set_msg_type *buf) |
647 | { | 646 | { |
648 | u32 BufLength, BufOffset; | 647 | u32 BufLength, BufOffset; |
649 | rndis_set_cmplt_type *resp; | 648 | rndis_set_cmplt_type *resp; |
650 | rndis_resp_t *r; | 649 | rndis_resp_t *r; |
651 | struct rndis_params *params = rndis_per_dev_params + configNr; | 650 | struct rndis_params *params = rndis_per_dev_params + configNr; |
652 | 651 | ||
653 | r = rndis_add_response (configNr, sizeof (rndis_set_cmplt_type)); | 652 | r = rndis_add_response(configNr, sizeof(rndis_set_cmplt_type)); |
654 | if (!r) | 653 | if (!r) |
655 | return -ENOMEM; | 654 | return -ENOMEM; |
656 | resp = (rndis_set_cmplt_type *) r->buf; | 655 | resp = (rndis_set_cmplt_type *)r->buf; |
657 | 656 | ||
658 | BufLength = le32_to_cpu (buf->InformationBufferLength); | 657 | BufLength = le32_to_cpu(buf->InformationBufferLength); |
659 | BufOffset = le32_to_cpu (buf->InformationBufferOffset); | 658 | BufOffset = le32_to_cpu(buf->InformationBufferOffset); |
660 | 659 | ||
661 | #ifdef VERBOSE_DEBUG | 660 | #ifdef VERBOSE_DEBUG |
662 | pr_debug("%s: Length: %d\n", __func__, BufLength); | 661 | pr_debug("%s: Length: %d\n", __func__, BufLength); |
@@ -670,59 +669,59 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) | |||
670 | pr_debug("\n"); | 669 | pr_debug("\n"); |
671 | #endif | 670 | #endif |
672 | 671 | ||
673 | resp->MessageType = cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); | 672 | resp->MessageType = cpu_to_le32(REMOTE_NDIS_SET_CMPLT); |
674 | resp->MessageLength = cpu_to_le32 (16); | 673 | resp->MessageLength = cpu_to_le32(16); |
675 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ | 674 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
676 | if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID), | 675 | if (gen_ndis_set_resp(configNr, le32_to_cpu(buf->OID), |
677 | ((u8 *) buf) + 8 + BufOffset, BufLength, r)) | 676 | ((u8 *)buf) + 8 + BufOffset, BufLength, r)) |
678 | resp->Status = cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED); | 677 | resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED); |
679 | else | 678 | else |
680 | resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); | 679 | resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); |
681 | 680 | ||
682 | params->resp_avail(params->v); | 681 | params->resp_avail(params->v); |
683 | return 0; | 682 | return 0; |
684 | } | 683 | } |
685 | 684 | ||
686 | static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf) | 685 | static int rndis_reset_response(int configNr, rndis_reset_msg_type *buf) |
687 | { | 686 | { |
688 | rndis_reset_cmplt_type *resp; | 687 | rndis_reset_cmplt_type *resp; |
689 | rndis_resp_t *r; | 688 | rndis_resp_t *r; |
690 | struct rndis_params *params = rndis_per_dev_params + configNr; | 689 | struct rndis_params *params = rndis_per_dev_params + configNr; |
691 | 690 | ||
692 | r = rndis_add_response (configNr, sizeof (rndis_reset_cmplt_type)); | 691 | r = rndis_add_response(configNr, sizeof(rndis_reset_cmplt_type)); |
693 | if (!r) | 692 | if (!r) |
694 | return -ENOMEM; | 693 | return -ENOMEM; |
695 | resp = (rndis_reset_cmplt_type *) r->buf; | 694 | resp = (rndis_reset_cmplt_type *)r->buf; |
696 | 695 | ||
697 | resp->MessageType = cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT); | 696 | resp->MessageType = cpu_to_le32(REMOTE_NDIS_RESET_CMPLT); |
698 | resp->MessageLength = cpu_to_le32 (16); | 697 | resp->MessageLength = cpu_to_le32(16); |
699 | resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); | 698 | resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); |
700 | /* resent information */ | 699 | /* resent information */ |
701 | resp->AddressingReset = cpu_to_le32 (1); | 700 | resp->AddressingReset = cpu_to_le32(1); |
702 | 701 | ||
703 | params->resp_avail(params->v); | 702 | params->resp_avail(params->v); |
704 | return 0; | 703 | return 0; |
705 | } | 704 | } |
706 | 705 | ||
707 | static int rndis_keepalive_response (int configNr, | 706 | static int rndis_keepalive_response(int configNr, |
708 | rndis_keepalive_msg_type *buf) | 707 | rndis_keepalive_msg_type *buf) |
709 | { | 708 | { |
710 | rndis_keepalive_cmplt_type *resp; | 709 | rndis_keepalive_cmplt_type *resp; |
711 | rndis_resp_t *r; | 710 | rndis_resp_t *r; |
712 | struct rndis_params *params = rndis_per_dev_params + configNr; | 711 | struct rndis_params *params = rndis_per_dev_params + configNr; |
713 | 712 | ||
714 | /* host "should" check only in RNDIS_DATA_INITIALIZED state */ | 713 | /* host "should" check only in RNDIS_DATA_INITIALIZED state */ |
715 | 714 | ||
716 | r = rndis_add_response (configNr, sizeof (rndis_keepalive_cmplt_type)); | 715 | r = rndis_add_response(configNr, sizeof(rndis_keepalive_cmplt_type)); |
717 | if (!r) | 716 | if (!r) |
718 | return -ENOMEM; | 717 | return -ENOMEM; |
719 | resp = (rndis_keepalive_cmplt_type *) r->buf; | 718 | resp = (rndis_keepalive_cmplt_type *)r->buf; |
720 | 719 | ||
721 | resp->MessageType = cpu_to_le32 ( | 720 | resp->MessageType = cpu_to_le32( |
722 | REMOTE_NDIS_KEEPALIVE_CMPLT); | 721 | REMOTE_NDIS_KEEPALIVE_CMPLT); |
723 | resp->MessageLength = cpu_to_le32 (16); | 722 | resp->MessageLength = cpu_to_le32(16); |
724 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ | 723 | resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ |
725 | resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS); | 724 | resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); |
726 | 725 | ||
727 | params->resp_avail(params->v); | 726 | params->resp_avail(params->v); |
728 | return 0; | 727 | return 0; |
@@ -732,86 +731,85 @@ static int rndis_keepalive_response (int configNr, | |||
732 | /* | 731 | /* |
733 | * Device to Host Comunication | 732 | * Device to Host Comunication |
734 | */ | 733 | */ |
735 | static int rndis_indicate_status_msg (int configNr, u32 status) | 734 | static int rndis_indicate_status_msg(int configNr, u32 status) |
736 | { | 735 | { |
737 | rndis_indicate_status_msg_type *resp; | 736 | rndis_indicate_status_msg_type *resp; |
738 | rndis_resp_t *r; | 737 | rndis_resp_t *r; |
739 | struct rndis_params *params = rndis_per_dev_params + configNr; | 738 | struct rndis_params *params = rndis_per_dev_params + configNr; |
740 | 739 | ||
741 | if (params->state == RNDIS_UNINITIALIZED) | 740 | if (params->state == RNDIS_UNINITIALIZED) |
742 | return -ENOTSUPP; | 741 | return -ENOTSUPP; |
743 | 742 | ||
744 | r = rndis_add_response (configNr, | 743 | r = rndis_add_response(configNr, |
745 | sizeof (rndis_indicate_status_msg_type)); | 744 | sizeof(rndis_indicate_status_msg_type)); |
746 | if (!r) | 745 | if (!r) |
747 | return -ENOMEM; | 746 | return -ENOMEM; |
748 | resp = (rndis_indicate_status_msg_type *) r->buf; | 747 | resp = (rndis_indicate_status_msg_type *)r->buf; |
749 | 748 | ||
750 | resp->MessageType = cpu_to_le32 ( | 749 | resp->MessageType = cpu_to_le32(REMOTE_NDIS_INDICATE_STATUS_MSG); |
751 | REMOTE_NDIS_INDICATE_STATUS_MSG); | 750 | resp->MessageLength = cpu_to_le32(20); |
752 | resp->MessageLength = cpu_to_le32 (20); | 751 | resp->Status = cpu_to_le32(status); |
753 | resp->Status = cpu_to_le32 (status); | 752 | resp->StatusBufferLength = cpu_to_le32(0); |
754 | resp->StatusBufferLength = cpu_to_le32 (0); | 753 | resp->StatusBufferOffset = cpu_to_le32(0); |
755 | resp->StatusBufferOffset = cpu_to_le32 (0); | ||
756 | 754 | ||
757 | params->resp_avail(params->v); | 755 | params->resp_avail(params->v); |
758 | return 0; | 756 | return 0; |
759 | } | 757 | } |
760 | 758 | ||
761 | int rndis_signal_connect (int configNr) | 759 | int rndis_signal_connect(int configNr) |
762 | { | 760 | { |
763 | rndis_per_dev_params [configNr].media_state | 761 | rndis_per_dev_params[configNr].media_state |
764 | = NDIS_MEDIA_STATE_CONNECTED; | 762 | = NDIS_MEDIA_STATE_CONNECTED; |
765 | return rndis_indicate_status_msg (configNr, | 763 | return rndis_indicate_status_msg(configNr, |
766 | RNDIS_STATUS_MEDIA_CONNECT); | 764 | RNDIS_STATUS_MEDIA_CONNECT); |
767 | } | 765 | } |
768 | 766 | ||
769 | int rndis_signal_disconnect (int configNr) | 767 | int rndis_signal_disconnect(int configNr) |
770 | { | 768 | { |
771 | rndis_per_dev_params [configNr].media_state | 769 | rndis_per_dev_params[configNr].media_state |
772 | = NDIS_MEDIA_STATE_DISCONNECTED; | 770 | = NDIS_MEDIA_STATE_DISCONNECTED; |
773 | return rndis_indicate_status_msg (configNr, | 771 | return rndis_indicate_status_msg(configNr, |
774 | RNDIS_STATUS_MEDIA_DISCONNECT); | 772 | RNDIS_STATUS_MEDIA_DISCONNECT); |
775 | } | 773 | } |
776 | 774 | ||
777 | void rndis_uninit (int configNr) | 775 | void rndis_uninit(int configNr) |
778 | { | 776 | { |
779 | u8 *buf; | 777 | u8 *buf; |
780 | u32 length; | 778 | u32 length; |
781 | 779 | ||
782 | if (configNr >= RNDIS_MAX_CONFIGS) | 780 | if (configNr >= RNDIS_MAX_CONFIGS) |
783 | return; | 781 | return; |
784 | rndis_per_dev_params [configNr].state = RNDIS_UNINITIALIZED; | 782 | rndis_per_dev_params[configNr].state = RNDIS_UNINITIALIZED; |
785 | 783 | ||
786 | /* drain the response queue */ | 784 | /* drain the response queue */ |
787 | while ((buf = rndis_get_next_response(configNr, &length))) | 785 | while ((buf = rndis_get_next_response(configNr, &length))) |
788 | rndis_free_response(configNr, buf); | 786 | rndis_free_response(configNr, buf); |
789 | } | 787 | } |
790 | 788 | ||
791 | void rndis_set_host_mac (int configNr, const u8 *addr) | 789 | void rndis_set_host_mac(int configNr, const u8 *addr) |
792 | { | 790 | { |
793 | rndis_per_dev_params [configNr].host_mac = addr; | 791 | rndis_per_dev_params[configNr].host_mac = addr; |
794 | } | 792 | } |
795 | 793 | ||
796 | /* | 794 | /* |
797 | * Message Parser | 795 | * Message Parser |
798 | */ | 796 | */ |
799 | int rndis_msg_parser (u8 configNr, u8 *buf) | 797 | int rndis_msg_parser(u8 configNr, u8 *buf) |
800 | { | 798 | { |
801 | u32 MsgType, MsgLength; | 799 | u32 MsgType, MsgLength; |
802 | __le32 *tmp; | 800 | __le32 *tmp; |
803 | struct rndis_params *params; | 801 | struct rndis_params *params; |
804 | 802 | ||
805 | if (!buf) | 803 | if (!buf) |
806 | return -ENOMEM; | 804 | return -ENOMEM; |
807 | 805 | ||
808 | tmp = (__le32 *) buf; | 806 | tmp = (__le32 *)buf; |
809 | MsgType = get_unaligned_le32(tmp++); | 807 | MsgType = get_unaligned_le32(tmp++); |
810 | MsgLength = get_unaligned_le32(tmp++); | 808 | MsgLength = get_unaligned_le32(tmp++); |
811 | 809 | ||
812 | if (configNr >= RNDIS_MAX_CONFIGS) | 810 | if (configNr >= RNDIS_MAX_CONFIGS) |
813 | return -ENOTSUPP; | 811 | return -ENOTSUPP; |
814 | params = &rndis_per_dev_params [configNr]; | 812 | params = &rndis_per_dev_params[configNr]; |
815 | 813 | ||
816 | /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for | 814 | /* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for |
817 | * rx/tx statistics and link status, in addition to KEEPALIVE traffic | 815 | * rx/tx statistics and link status, in addition to KEEPALIVE traffic |
@@ -822,41 +820,41 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
822 | switch (MsgType) { | 820 | switch (MsgType) { |
823 | case REMOTE_NDIS_INITIALIZE_MSG: | 821 | case REMOTE_NDIS_INITIALIZE_MSG: |
824 | pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", | 822 | pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", |
825 | __func__ ); | 823 | __func__); |
826 | params->state = RNDIS_INITIALIZED; | 824 | params->state = RNDIS_INITIALIZED; |
827 | return rndis_init_response (configNr, | 825 | return rndis_init_response(configNr, |
828 | (rndis_init_msg_type *) buf); | 826 | (rndis_init_msg_type *)buf); |
829 | 827 | ||
830 | case REMOTE_NDIS_HALT_MSG: | 828 | case REMOTE_NDIS_HALT_MSG: |
831 | pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", | 829 | pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", |
832 | __func__ ); | 830 | __func__); |
833 | params->state = RNDIS_UNINITIALIZED; | 831 | params->state = RNDIS_UNINITIALIZED; |
834 | if (params->dev) { | 832 | if (params->dev) { |
835 | netif_carrier_off (params->dev); | 833 | netif_carrier_off(params->dev); |
836 | netif_stop_queue (params->dev); | 834 | netif_stop_queue(params->dev); |
837 | } | 835 | } |
838 | return 0; | 836 | return 0; |
839 | 837 | ||
840 | case REMOTE_NDIS_QUERY_MSG: | 838 | case REMOTE_NDIS_QUERY_MSG: |
841 | return rndis_query_response (configNr, | 839 | return rndis_query_response(configNr, |
842 | (rndis_query_msg_type *) buf); | 840 | (rndis_query_msg_type *)buf); |
843 | 841 | ||
844 | case REMOTE_NDIS_SET_MSG: | 842 | case REMOTE_NDIS_SET_MSG: |
845 | return rndis_set_response (configNr, | 843 | return rndis_set_response(configNr, |
846 | (rndis_set_msg_type *) buf); | 844 | (rndis_set_msg_type *)buf); |
847 | 845 | ||
848 | case REMOTE_NDIS_RESET_MSG: | 846 | case REMOTE_NDIS_RESET_MSG: |
849 | pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", | 847 | pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", |
850 | __func__ ); | 848 | __func__); |
851 | return rndis_reset_response (configNr, | 849 | return rndis_reset_response(configNr, |
852 | (rndis_reset_msg_type *) buf); | 850 | (rndis_reset_msg_type *)buf); |
853 | 851 | ||
854 | case REMOTE_NDIS_KEEPALIVE_MSG: | 852 | case REMOTE_NDIS_KEEPALIVE_MSG: |
855 | /* For USB: host does this every 5 seconds */ | 853 | /* For USB: host does this every 5 seconds */ |
856 | if (rndis_debug > 1) | 854 | if (rndis_debug > 1) |
857 | pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", | 855 | pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", |
858 | __func__ ); | 856 | __func__); |
859 | return rndis_keepalive_response (configNr, | 857 | return rndis_keepalive_response(configNr, |
860 | (rndis_keepalive_msg_type *) | 858 | (rndis_keepalive_msg_type *) |
861 | buf); | 859 | buf); |
862 | 860 | ||
@@ -866,7 +864,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) | |||
866 | * suspending itself. | 864 | * suspending itself. |
867 | */ | 865 | */ |
868 | pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", | 866 | pr_warning("%s: unknown RNDIS message 0x%08X len %d\n", |
869 | __func__ , MsgType, MsgLength); | 867 | __func__, MsgType, MsgLength); |
870 | { | 868 | { |
871 | unsigned i; | 869 | unsigned i; |
872 | for (i = 0; i < MsgLength; i += 16) { | 870 | for (i = 0; i < MsgLength; i += 16) { |
@@ -901,10 +899,10 @@ int rndis_register(void (*resp_avail)(void *v), void *v) | |||
901 | return -EINVAL; | 899 | return -EINVAL; |
902 | 900 | ||
903 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { | 901 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { |
904 | if (!rndis_per_dev_params [i].used) { | 902 | if (!rndis_per_dev_params[i].used) { |
905 | rndis_per_dev_params [i].used = 1; | 903 | rndis_per_dev_params[i].used = 1; |
906 | rndis_per_dev_params [i].resp_avail = resp_avail; | 904 | rndis_per_dev_params[i].resp_avail = resp_avail; |
907 | rndis_per_dev_params [i].v = v; | 905 | rndis_per_dev_params[i].v = v; |
908 | pr_debug("%s: configNr = %d\n", __func__, i); | 906 | pr_debug("%s: configNr = %d\n", __func__, i); |
909 | return i; | 907 | return i; |
910 | } | 908 | } |
@@ -914,12 +912,12 @@ int rndis_register(void (*resp_avail)(void *v), void *v) | |||
914 | return -ENODEV; | 912 | return -ENODEV; |
915 | } | 913 | } |
916 | 914 | ||
917 | void rndis_deregister (int configNr) | 915 | void rndis_deregister(int configNr) |
918 | { | 916 | { |
919 | pr_debug("%s: \n", __func__); | 917 | pr_debug("%s:\n", __func__); |
920 | 918 | ||
921 | if (configNr >= RNDIS_MAX_CONFIGS) return; | 919 | if (configNr >= RNDIS_MAX_CONFIGS) return; |
922 | rndis_per_dev_params [configNr].used = 0; | 920 | rndis_per_dev_params[configNr].used = 0; |
923 | 921 | ||
924 | return; | 922 | return; |
925 | } | 923 | } |
@@ -931,76 +929,76 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) | |||
931 | return -EINVAL; | 929 | return -EINVAL; |
932 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 930 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
933 | 931 | ||
934 | rndis_per_dev_params [configNr].dev = dev; | 932 | rndis_per_dev_params[configNr].dev = dev; |
935 | rndis_per_dev_params [configNr].filter = cdc_filter; | 933 | rndis_per_dev_params[configNr].filter = cdc_filter; |
936 | 934 | ||
937 | return 0; | 935 | return 0; |
938 | } | 936 | } |
939 | 937 | ||
940 | int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) | 938 | int rndis_set_param_vendor(u8 configNr, u32 vendorID, const char *vendorDescr) |
941 | { | 939 | { |
942 | pr_debug("%s:\n", __func__); | 940 | pr_debug("%s:\n", __func__); |
943 | if (!vendorDescr) return -1; | 941 | if (!vendorDescr) return -1; |
944 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 942 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
945 | 943 | ||
946 | rndis_per_dev_params [configNr].vendorID = vendorID; | 944 | rndis_per_dev_params[configNr].vendorID = vendorID; |
947 | rndis_per_dev_params [configNr].vendorDescr = vendorDescr; | 945 | rndis_per_dev_params[configNr].vendorDescr = vendorDescr; |
948 | 946 | ||
949 | return 0; | 947 | return 0; |
950 | } | 948 | } |
951 | 949 | ||
952 | int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) | 950 | int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed) |
953 | { | 951 | { |
954 | pr_debug("%s: %u %u\n", __func__, medium, speed); | 952 | pr_debug("%s: %u %u\n", __func__, medium, speed); |
955 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; | 953 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
956 | 954 | ||
957 | rndis_per_dev_params [configNr].medium = medium; | 955 | rndis_per_dev_params[configNr].medium = medium; |
958 | rndis_per_dev_params [configNr].speed = speed; | 956 | rndis_per_dev_params[configNr].speed = speed; |
959 | 957 | ||
960 | return 0; | 958 | return 0; |
961 | } | 959 | } |
962 | 960 | ||
963 | void rndis_add_hdr (struct sk_buff *skb) | 961 | void rndis_add_hdr(struct sk_buff *skb) |
964 | { | 962 | { |
965 | struct rndis_packet_msg_type *header; | 963 | struct rndis_packet_msg_type *header; |
966 | 964 | ||
967 | if (!skb) | 965 | if (!skb) |
968 | return; | 966 | return; |
969 | header = (void *) skb_push (skb, sizeof *header); | 967 | header = (void *)skb_push(skb, sizeof(*header)); |
970 | memset (header, 0, sizeof *header); | 968 | memset(header, 0, sizeof *header); |
971 | header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG); | 969 | header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG); |
972 | header->MessageLength = cpu_to_le32(skb->len); | 970 | header->MessageLength = cpu_to_le32(skb->len); |
973 | header->DataOffset = cpu_to_le32 (36); | 971 | header->DataOffset = cpu_to_le32(36); |
974 | header->DataLength = cpu_to_le32(skb->len - sizeof *header); | 972 | header->DataLength = cpu_to_le32(skb->len - sizeof(*header)); |
975 | } | 973 | } |
976 | 974 | ||
977 | void rndis_free_response (int configNr, u8 *buf) | 975 | void rndis_free_response(int configNr, u8 *buf) |
978 | { | 976 | { |
979 | rndis_resp_t *r; | 977 | rndis_resp_t *r; |
980 | struct list_head *act, *tmp; | 978 | struct list_head *act, *tmp; |
981 | 979 | ||
982 | list_for_each_safe (act, tmp, | 980 | list_for_each_safe(act, tmp, |
983 | &(rndis_per_dev_params [configNr].resp_queue)) | 981 | &(rndis_per_dev_params[configNr].resp_queue)) |
984 | { | 982 | { |
985 | r = list_entry (act, rndis_resp_t, list); | 983 | r = list_entry(act, rndis_resp_t, list); |
986 | if (r && r->buf == buf) { | 984 | if (r && r->buf == buf) { |
987 | list_del (&r->list); | 985 | list_del(&r->list); |
988 | kfree (r); | 986 | kfree(r); |
989 | } | 987 | } |
990 | } | 988 | } |
991 | } | 989 | } |
992 | 990 | ||
993 | u8 *rndis_get_next_response (int configNr, u32 *length) | 991 | u8 *rndis_get_next_response(int configNr, u32 *length) |
994 | { | 992 | { |
995 | rndis_resp_t *r; | 993 | rndis_resp_t *r; |
996 | struct list_head *act, *tmp; | 994 | struct list_head *act, *tmp; |
997 | 995 | ||
998 | if (!length) return NULL; | 996 | if (!length) return NULL; |
999 | 997 | ||
1000 | list_for_each_safe (act, tmp, | 998 | list_for_each_safe(act, tmp, |
1001 | &(rndis_per_dev_params [configNr].resp_queue)) | 999 | &(rndis_per_dev_params[configNr].resp_queue)) |
1002 | { | 1000 | { |
1003 | r = list_entry (act, rndis_resp_t, list); | 1001 | r = list_entry(act, rndis_resp_t, list); |
1004 | if (!r->send) { | 1002 | if (!r->send) { |
1005 | r->send = 1; | 1003 | r->send = 1; |
1006 | *length = r->length; | 1004 | *length = r->length; |
@@ -1011,20 +1009,20 @@ u8 *rndis_get_next_response (int configNr, u32 *length) | |||
1011 | return NULL; | 1009 | return NULL; |
1012 | } | 1010 | } |
1013 | 1011 | ||
1014 | static rndis_resp_t *rndis_add_response (int configNr, u32 length) | 1012 | static rndis_resp_t *rndis_add_response(int configNr, u32 length) |
1015 | { | 1013 | { |
1016 | rndis_resp_t *r; | 1014 | rndis_resp_t *r; |
1017 | 1015 | ||
1018 | /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */ | 1016 | /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */ |
1019 | r = kmalloc (sizeof (rndis_resp_t) + length, GFP_ATOMIC); | 1017 | r = kmalloc(sizeof(rndis_resp_t) + length, GFP_ATOMIC); |
1020 | if (!r) return NULL; | 1018 | if (!r) return NULL; |
1021 | 1019 | ||
1022 | r->buf = (u8 *) (r + 1); | 1020 | r->buf = (u8 *)(r + 1); |
1023 | r->length = length; | 1021 | r->length = length; |
1024 | r->send = 0; | 1022 | r->send = 0; |
1025 | 1023 | ||
1026 | list_add_tail (&r->list, | 1024 | list_add_tail(&r->list, |
1027 | &(rndis_per_dev_params [configNr].resp_queue)); | 1025 | &(rndis_per_dev_params[configNr].resp_queue)); |
1028 | return r; | 1026 | return r; |
1029 | } | 1027 | } |
1030 | 1028 | ||
@@ -1033,7 +1031,7 @@ int rndis_rm_hdr(struct gether *port, | |||
1033 | struct sk_buff_head *list) | 1031 | struct sk_buff_head *list) |
1034 | { | 1032 | { |
1035 | /* tmp points to a struct rndis_packet_msg_type */ | 1033 | /* tmp points to a struct rndis_packet_msg_type */ |
1036 | __le32 *tmp = (void *) skb->data; | 1034 | __le32 *tmp = (void *)skb->data; |
1037 | 1035 | ||
1038 | /* MessageType, MessageLength */ | 1036 | /* MessageType, MessageLength */ |
1039 | if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG) | 1037 | if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG) |
@@ -1054,7 +1052,7 @@ int rndis_rm_hdr(struct gether *port, | |||
1054 | return 0; | 1052 | return 0; |
1055 | } | 1053 | } |
1056 | 1054 | ||
1057 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1055 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1058 | 1056 | ||
1059 | static int rndis_proc_show(struct seq_file *m, void *v) | 1057 | static int rndis_proc_show(struct seq_file *m, void *v) |
1060 | { | 1058 | { |
@@ -1087,7 +1085,7 @@ static int rndis_proc_show(struct seq_file *m, void *v) | |||
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, | 1087 | static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, |
1090 | size_t count, loff_t *ppos) | 1088 | size_t count, loff_t *ppos) |
1091 | { | 1089 | { |
1092 | rndis_params *p = PDE(file->f_path.dentry->d_inode)->data; | 1090 | rndis_params *p = PDE(file->f_path.dentry->d_inode)->data; |
1093 | u32 speed = 0; | 1091 | u32 speed = 0; |
@@ -1109,11 +1107,11 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, | |||
1109 | case '8': | 1107 | case '8': |
1110 | case '9': | 1108 | case '9': |
1111 | fl_speed = 1; | 1109 | fl_speed = 1; |
1112 | speed = speed*10 + c - '0'; | 1110 | speed = speed * 10 + c - '0'; |
1113 | break; | 1111 | break; |
1114 | case 'C': | 1112 | case 'C': |
1115 | case 'c': | 1113 | case 'c': |
1116 | rndis_signal_connect (p->confignr); | 1114 | rndis_signal_connect(p->confignr); |
1117 | break; | 1115 | break; |
1118 | case 'D': | 1116 | case 'D': |
1119 | case 'd': | 1117 | case 'd': |
@@ -1145,11 +1143,11 @@ static const struct file_operations rndis_proc_fops = { | |||
1145 | .write = rndis_proc_write, | 1143 | .write = rndis_proc_write, |
1146 | }; | 1144 | }; |
1147 | 1145 | ||
1148 | #define NAME_TEMPLATE "driver/rndis-%03d" | 1146 | #define NAME_TEMPLATE "driver/rndis-%03d" |
1149 | 1147 | ||
1150 | static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; | 1148 | static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS]; |
1151 | 1149 | ||
1152 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ | 1150 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ |
1153 | 1151 | ||
1154 | 1152 | ||
1155 | int rndis_init(void) | 1153 | int rndis_init(void) |
@@ -1160,42 +1158,40 @@ int rndis_init(void) | |||
1160 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1158 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1161 | char name [20]; | 1159 | char name [20]; |
1162 | 1160 | ||
1163 | sprintf (name, NAME_TEMPLATE, i); | 1161 | sprintf(name, NAME_TEMPLATE, i); |
1164 | if (!(rndis_connect_state [i] | 1162 | rndis_connect_state[i] = proc_create_data(name, 0660, NULL, |
1165 | = proc_create_data(name, 0660, NULL, | ||
1166 | &rndis_proc_fops, | 1163 | &rndis_proc_fops, |
1167 | (void *)(rndis_per_dev_params + i)))) | 1164 | (void *)(rndis_per_dev_params + i)); |
1168 | { | 1165 | if (!rndis_connect_state[i]) { |
1169 | pr_debug("%s :remove entries", __func__); | 1166 | pr_debug("%s: remove entries", __func__); |
1170 | while (i) { | 1167 | while (i) { |
1171 | sprintf (name, NAME_TEMPLATE, --i); | 1168 | sprintf(name, NAME_TEMPLATE, --i); |
1172 | remove_proc_entry (name, NULL); | 1169 | remove_proc_entry(name, NULL); |
1173 | } | 1170 | } |
1174 | pr_debug("\n"); | 1171 | pr_debug("\n"); |
1175 | return -EIO; | 1172 | return -EIO; |
1176 | } | 1173 | } |
1177 | #endif | 1174 | #endif |
1178 | rndis_per_dev_params [i].confignr = i; | 1175 | rndis_per_dev_params[i].confignr = i; |
1179 | rndis_per_dev_params [i].used = 0; | 1176 | rndis_per_dev_params[i].used = 0; |
1180 | rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED; | 1177 | rndis_per_dev_params[i].state = RNDIS_UNINITIALIZED; |
1181 | rndis_per_dev_params [i].media_state | 1178 | rndis_per_dev_params[i].media_state |
1182 | = NDIS_MEDIA_STATE_DISCONNECTED; | 1179 | = NDIS_MEDIA_STATE_DISCONNECTED; |
1183 | INIT_LIST_HEAD (&(rndis_per_dev_params [i].resp_queue)); | 1180 | INIT_LIST_HEAD(&(rndis_per_dev_params[i].resp_queue)); |
1184 | } | 1181 | } |
1185 | 1182 | ||
1186 | return 0; | 1183 | return 0; |
1187 | } | 1184 | } |
1188 | 1185 | ||
1189 | void rndis_exit (void) | 1186 | void rndis_exit(void) |
1190 | { | 1187 | { |
1191 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1188 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1192 | u8 i; | 1189 | u8 i; |
1193 | char name [20]; | 1190 | char name[20]; |
1194 | 1191 | ||
1195 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { | 1192 | for (i = 0; i < RNDIS_MAX_CONFIGS; i++) { |
1196 | sprintf (name, NAME_TEMPLATE, i); | 1193 | sprintf(name, NAME_TEMPLATE, i); |
1197 | remove_proc_entry (name, NULL); | 1194 | remove_proc_entry(name, NULL); |
1198 | } | 1195 | } |
1199 | #endif | 1196 | #endif |
1200 | } | 1197 | } |
1201 | |||