qdf_vfs.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qdf_vfs
  20. * This file provides OS dependent virtual fiesystem APIs
  21. */
  22. #include "qdf_vfs.h"
  23. #include "qdf_util.h"
  24. #include "qdf_module.h"
  25. #include <linux/string.h>
  26. #include <linux/kobject.h>
  27. QDF_STATUS
  28. qdf_vfs_set_file_attributes(struct qdf_dev_obj *devobj,
  29. struct qdf_vfs_attr *attr)
  30. {
  31. int ret;
  32. if (!devobj || !attr)
  33. return QDF_STATUS_E_INVAL;
  34. ret = sysfs_create_group((struct kobject *)devobj,
  35. (struct attribute_group *)attr);
  36. return qdf_status_from_os_return(ret);
  37. }
  38. qdf_export_symbol(qdf_vfs_set_file_attributes);
  39. QDF_STATUS
  40. qdf_vfs_clear_file_attributes(struct qdf_dev_obj *devobj,
  41. struct qdf_vfs_attr *attr)
  42. {
  43. if (!devobj || !attr)
  44. return QDF_STATUS_E_INVAL;
  45. sysfs_remove_group((struct kobject *)devobj,
  46. (struct attribute_group *)attr);
  47. return QDF_STATUS_SUCCESS;
  48. }
  49. qdf_export_symbol(qdf_vfs_clear_file_attributes);
  50. QDF_STATUS
  51. qdf_vfs_create_binfile(struct qdf_dev_obj *devobj, struct qdf_vf_bin_attr *attr)
  52. {
  53. int ret;
  54. if (!devobj || !attr)
  55. return QDF_STATUS_E_INVAL;
  56. ret = sysfs_create_bin_file((struct kobject *)devobj,
  57. (struct bin_attribute *)attr);
  58. return qdf_status_from_os_return(ret);
  59. }
  60. qdf_export_symbol(qdf_vfs_create_binfile);
  61. QDF_STATUS
  62. qdf_vfs_delete_binfile(struct qdf_dev_obj *devobj, struct qdf_vf_bin_attr *attr)
  63. {
  64. if (!devobj || !attr)
  65. return QDF_STATUS_E_INVAL;
  66. sysfs_remove_bin_file((struct kobject *)devobj,
  67. (struct bin_attribute *)attr);
  68. return QDF_STATUS_SUCCESS;
  69. }
  70. qdf_export_symbol(qdf_vfs_delete_binfile);