diff options
-rw-r--r-- | drivers/staging/rtl8188eu/include/osdep_service.h | 5 | ||||
-rw-r--r-- | drivers/staging/rtl8188eu/os_dep/osdep_service.c | 208 |
2 files changed, 0 insertions, 213 deletions
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 44f24fa31a34..36523edf6a71 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h | |||
@@ -430,11 +430,6 @@ int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); | |||
430 | int ATOMIC_INC_RETURN(ATOMIC_T *v); | 430 | int ATOMIC_INC_RETURN(ATOMIC_T *v); |
431 | int ATOMIC_DEC_RETURN(ATOMIC_T *v); | 431 | int ATOMIC_DEC_RETURN(ATOMIC_T *v); |
432 | 432 | ||
433 | /* File operation APIs, just for linux now */ | ||
434 | int rtw_is_file_readable(char *path); | ||
435 | int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz); | ||
436 | int rtw_store_to_file(char *path, u8 __user *buf, u32 sz); | ||
437 | |||
438 | struct rtw_netdev_priv_indicator { | 433 | struct rtw_netdev_priv_indicator { |
439 | void *priv; | 434 | void *priv; |
440 | u32 sizeof_priv; | 435 | u32 sizeof_priv; |
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c index 4e0bfb7e153b..4aedb85a3527 100644 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c | |||
@@ -356,214 +356,6 @@ inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) | |||
356 | return atomic_dec_return(v); | 356 | return atomic_dec_return(v); |
357 | } | 357 | } |
358 | 358 | ||
359 | /* Open a file with the specific @param path, @param flag, @param mode | ||
360 | * @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success | ||
361 | * @param path the path of the file to open | ||
362 | * @param flag file operation flags, please refer to linux document | ||
363 | * @param mode please refer to linux document | ||
364 | * @return Linux specific error code | ||
365 | */ | ||
366 | static int openfile(struct file **fpp, char *path, int flag, int mode) | ||
367 | { | ||
368 | struct file *fp; | ||
369 | |||
370 | fp = filp_open(path, flag, mode); | ||
371 | if (IS_ERR(fp)) { | ||
372 | *fpp = NULL; | ||
373 | return PTR_ERR(fp); | ||
374 | } else { | ||
375 | *fpp = fp; | ||
376 | return 0; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | /* Close the file with the specific @param fp | ||
381 | * @param fp the pointer of struct file to close | ||
382 | * @return always 0 | ||
383 | */ | ||
384 | static int closefile(struct file *fp) | ||
385 | { | ||
386 | filp_close(fp, NULL); | ||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | static int readfile(struct file *fp, char __user *buf, int len) | ||
391 | { | ||
392 | int rlen = 0, sum = 0; | ||
393 | |||
394 | if (!fp->f_op || !fp->f_op->read) | ||
395 | return -EPERM; | ||
396 | |||
397 | while (sum < len) { | ||
398 | rlen = fp->f_op->read(fp, buf+sum, len-sum, &fp->f_pos); | ||
399 | if (rlen > 0) | ||
400 | sum += rlen; | ||
401 | else if (0 != rlen) | ||
402 | return rlen; | ||
403 | else | ||
404 | break; | ||
405 | } | ||
406 | return sum; | ||
407 | } | ||
408 | |||
409 | static int writefile(struct file *fp, char __user *buf, int len) | ||
410 | { | ||
411 | int wlen = 0, sum = 0; | ||
412 | |||
413 | if (!fp->f_op || !fp->f_op->write) | ||
414 | return -EPERM; | ||
415 | |||
416 | while (sum < len) { | ||
417 | wlen = fp->f_op->write(fp, buf+sum, len-sum, &fp->f_pos); | ||
418 | if (wlen > 0) | ||
419 | sum += wlen; | ||
420 | else if (0 != wlen) | ||
421 | return wlen; | ||
422 | else | ||
423 | break; | ||
424 | } | ||
425 | return sum; | ||
426 | } | ||
427 | |||
428 | /* Test if the specifi @param path is a file and readable | ||
429 | * @param path the path of the file to test | ||
430 | * @return Linux specific error code | ||
431 | */ | ||
432 | static int isfilereadable(char *path) | ||
433 | { | ||
434 | struct file *fp; | ||
435 | int ret = 0; | ||
436 | mm_segment_t oldfs; | ||
437 | char __user buf; | ||
438 | |||
439 | fp = filp_open(path, O_RDONLY, 0); | ||
440 | if (IS_ERR(fp)) { | ||
441 | ret = PTR_ERR(fp); | ||
442 | } else { | ||
443 | oldfs = get_fs(); set_fs(get_ds()); | ||
444 | |||
445 | if (1 != readfile(fp, &buf, 1)) | ||
446 | ret = PTR_ERR(fp); | ||
447 | |||
448 | set_fs(oldfs); | ||
449 | filp_close(fp, NULL); | ||
450 | } | ||
451 | return ret; | ||
452 | } | ||
453 | |||
454 | /* Open the file with @param path and retrive the file content into | ||
455 | * memory starting from @param buf for @param sz at most | ||
456 | * @param path the path of the file to open and read | ||
457 | * @param buf the starting address of the buffer to store file content | ||
458 | * @param sz how many bytes to read at most | ||
459 | * @return the byte we've read, or Linux specific error code | ||
460 | */ | ||
461 | static int retrievefromfile(char *path, u8 __user *buf, u32 sz) | ||
462 | { | ||
463 | int ret = -1; | ||
464 | mm_segment_t oldfs; | ||
465 | struct file *fp; | ||
466 | |||
467 | if (path && buf) { | ||
468 | ret = openfile(&fp, path, O_RDONLY, 0); | ||
469 | if (0 == ret) { | ||
470 | DBG_88E("%s openfile path:%s fp =%p\n", __func__, | ||
471 | path, fp); | ||
472 | |||
473 | oldfs = get_fs(); set_fs(get_ds()); | ||
474 | ret = readfile(fp, buf, sz); | ||
475 | set_fs(oldfs); | ||
476 | closefile(fp); | ||
477 | |||
478 | DBG_88E("%s readfile, ret:%d\n", __func__, ret); | ||
479 | |||
480 | } else { | ||
481 | DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, | ||
482 | path, ret); | ||
483 | } | ||
484 | } else { | ||
485 | DBG_88E("%s NULL pointer\n", __func__); | ||
486 | ret = -EINVAL; | ||
487 | } | ||
488 | return ret; | ||
489 | } | ||
490 | |||
491 | /* | ||
492 | * Open the file with @param path and wirte @param sz byte of data starting from @param buf into the file | ||
493 | * @param path the path of the file to open and write | ||
494 | * @param buf the starting address of the data to write into file | ||
495 | * @param sz how many bytes to write at most | ||
496 | * @return the byte we've written, or Linux specific error code | ||
497 | */ | ||
498 | static int storetofile(char *path, u8 __user *buf, u32 sz) | ||
499 | { | ||
500 | int ret = 0; | ||
501 | mm_segment_t oldfs; | ||
502 | struct file *fp; | ||
503 | |||
504 | if (path && buf) { | ||
505 | ret = openfile(&fp, path, O_CREAT|O_WRONLY, 0666); | ||
506 | if (0 == ret) { | ||
507 | DBG_88E("%s openfile path:%s fp =%p\n", __func__, path, fp); | ||
508 | |||
509 | oldfs = get_fs(); set_fs(get_ds()); | ||
510 | ret = writefile(fp, buf, sz); | ||
511 | set_fs(oldfs); | ||
512 | closefile(fp); | ||
513 | |||
514 | DBG_88E("%s writefile, ret:%d\n", __func__, ret); | ||
515 | |||
516 | } else { | ||
517 | DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, path, ret); | ||
518 | } | ||
519 | } else { | ||
520 | DBG_88E("%s NULL pointer\n", __func__); | ||
521 | ret = -EINVAL; | ||
522 | } | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | /* | ||
527 | * Test if the specifi @param path is a file and readable | ||
528 | * @param path the path of the file to test | ||
529 | * @return true or false | ||
530 | */ | ||
531 | int rtw_is_file_readable(char *path) | ||
532 | { | ||
533 | if (isfilereadable(path) == 0) | ||
534 | return true; | ||
535 | else | ||
536 | return false; | ||
537 | } | ||
538 | |||
539 | /* | ||
540 | * Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most | ||
541 | * @param path the path of the file to open and read | ||
542 | * @param buf the starting address of the buffer to store file content | ||
543 | * @param sz how many bytes to read at most | ||
544 | * @return the byte we've read | ||
545 | */ | ||
546 | int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz) | ||
547 | { | ||
548 | int ret = retrievefromfile(path, buf, sz); | ||
549 | |||
550 | return ret >= 0 ? ret : 0; | ||
551 | } | ||
552 | |||
553 | /* | ||
554 | * Open the file with @param path and wirte @param sz byte of data | ||
555 | * starting from @param buf into the file | ||
556 | * @param path the path of the file to open and write | ||
557 | * @param buf the starting address of the data to write into file | ||
558 | * @param sz how many bytes to write at most | ||
559 | * @return the byte we've written | ||
560 | */ | ||
561 | int rtw_store_to_file(char *path, u8 __user *buf, u32 sz) | ||
562 | { | ||
563 | int ret = storetofile(path, buf, sz); | ||
564 | return ret >= 0 ? ret : 0; | ||
565 | } | ||
566 | |||
567 | struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, | 359 | struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, |
568 | void *old_priv) | 360 | void *old_priv) |
569 | { | 361 | { |