From ohcanada, 2 Weeks ago, written in C.
  1. const struct rtw_proc_hdl drv_proc_hdls[] = {
  2.   RTW_PROC_HDL_SSEQ("ver_info", proc_get_drv_version, NULL),
  3.   RTW_PROC_HDL_SSEQ("log_level", proc_get_log_level, proc_set_log_level),
  4.   RTW_PROC_HDL_SSEQ("drv_cfg", proc_get_drv_cfg, NULL),
  5. #ifdef DBG_MEM_ALLOC
  6.   RTW_PROC_HDL_SSEQ("mstat", proc_get_mstat, NULL),
  7. #endif /* DBG_MEM_ALLOC */
  8.   RTW_PROC_HDL_SSEQ("country_chplan_map", proc_get_country_chplan_map, NULL),
  9.   RTW_PROC_HDL_SSEQ("chplan_id_list", proc_get_chplan_id_list, NULL),
  10.   RTW_PROC_HDL_SSEQ("chplan_test", proc_get_chplan_test, NULL),
  11.   RTW_PROC_HDL_SSEQ("chplan_ver", proc_get_chplan_ver, NULL),
  12. #ifdef RTW_HALMAC
  13.   RTW_PROC_HDL_SSEQ("halmac_info", proc_get_halmac_info, NULL),
  14. #endif /* RTW_HALMAC */
  15. };
  16.  
  17. static ssize_t proc_set_log_level(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data)
  18. {
  19.   char tmp[32];
  20.   int log_level;
  21.  
  22.   if (count < 1)
  23.     return -EINVAL;
  24.  
  25.   if (count > sizeof(tmp)) {
  26.     rtw_warn_on(1);
  27.     return -EFAULT;
  28.   }
  29.  
  30. #ifdef CONFIG_RTW_DEBUG
  31.   if (buffer && !copy_from_user(tmp, buffer, count)) {
  32.  
  33.     int num = sscanf(tmp, "%d ", &log_level);
  34.  
  35.     if (num == 1 &&
  36.         log_level >= _DRV_NONE_ && log_level <= _DRV_MAX_) {
  37.       rtw_drv_log_level = log_level;
  38.       printk("rtw_drv_log_level:%d\n", rtw_drv_log_level);
  39.     }
  40.   } else
  41.     return -EFAULT;
  42. #else
  43.   printk("CONFIG_RTW_DEBUG is disabled\n");
  44. #endif
  45.  
  46.   return count;
  47. }
captcha