1 #include <linux/module.h>
2 #include <linux/dcache.h>
3 #include <linux/debugfs.h>
4 #include <linux/delay.h>
6 #include <linux/string.h>
7 #include <linux/slab.h>
8 #include <net/iw_handler.h>
9 #include <net/lib80211.h>
17 static struct dentry *lbs_dir;
18 static char *szStates[] = {
24 static void lbs_debug_init(struct lbs_private *priv);
27 static int open_file_generic(struct inode *inode, struct file *file)
29 file->private_data = inode->i_private;
33 static ssize_t write_file_dummy(struct file *file, const char __user *buf,
34 size_t count, loff_t *ppos)
39 static const size_t len = PAGE_SIZE;
41 static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
42 size_t count, loff_t *ppos)
44 struct lbs_private *priv = file->private_data;
46 unsigned long addr = get_zeroed_page(GFP_KERNEL);
47 char *buf = (char *)addr;
52 pos += snprintf(buf+pos, len-pos, "state = %s\n",
53 szStates[priv->connect_status]);
54 pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
55 (u32) priv->regioncode);
57 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
64 static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
65 size_t count, loff_t *ppos)
67 struct lbs_private *priv = file->private_data;
69 int numscansdone = 0, res;
70 unsigned long addr = get_zeroed_page(GFP_KERNEL);
71 char *buf = (char *)addr;
72 DECLARE_SSID_BUF(ssid);
73 struct bss_descriptor * iter_bss;
77 pos += snprintf(buf+pos, len-pos,
78 "# | ch | rssi | bssid | cap | Qual | SSID \n");
80 mutex_lock(&priv->lock);
81 list_for_each_entry (iter_bss, &priv->network_list, list) {
82 u16 ibss = (iter_bss->capability & WLAN_CAPABILITY_IBSS);
83 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY);
84 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
86 pos += snprintf(buf+pos, len-pos, "%02u| %03d | %04d | %pM |",
87 numscansdone, iter_bss->channel, iter_bss->rssi,
89 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability);
90 pos += snprintf(buf+pos, len-pos, "%c%c%c |",
91 ibss ? 'A' : 'I', privacy ? 'P' : ' ',
92 spectrum_mgmt ? 'S' : ' ');
93 pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
94 pos += snprintf(buf+pos, len-pos, " %s\n",
95 print_ssid(ssid, iter_bss->ssid,
100 mutex_unlock(&priv->lock);
102 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
108 static ssize_t lbs_sleepparams_write(struct file *file,
109 const char __user *user_buf, size_t count,
112 struct lbs_private *priv = file->private_data;
113 ssize_t buf_size, ret;
114 struct sleep_params sp;
115 int p1, p2, p3, p4, p5, p6;
116 unsigned long addr = get_zeroed_page(GFP_KERNEL);
117 char *buf = (char *)addr;
121 buf_size = min(count, len - 1);
122 if (copy_from_user(buf, user_buf, buf_size)) {
126 ret = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6);
133 sp.sp_stabletime = p3;
134 sp.sp_calcontrol = p4;
135 sp.sp_extsleepclk = p5;
138 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_SET, &sp);
149 static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
150 size_t count, loff_t *ppos)
152 struct lbs_private *priv = file->private_data;
155 struct sleep_params sp;
156 unsigned long addr = get_zeroed_page(GFP_KERNEL);
157 char *buf = (char *)addr;
161 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
165 pos += snprintf(buf, len, "%d %d %d %d %d %d\n", sp.sp_error,
166 sp.sp_offset, sp.sp_stabletime,
167 sp.sp_calcontrol, sp.sp_extsleepclk,
170 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
178 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might
179 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the
180 * firmware. Here's an example:
181 * 04 01 02 00 00 00 05 01 02 00 00 00 06 01 02 00
182 * 00 00 07 01 02 00 3c 00 00 00 00 00 00 00 03 03
183 * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
185 * The 04 01 is the TLV type (here TLV_TYPE_RSSI_LOW), 02 00 is the length,
186 * 00 00 are the data bytes of this TLV. For this TLV, their meaning is
187 * defined in mrvlietypes_thresholds
189 * This function searches in this TLV data chunk for a given TLV type
190 * and returns a pointer to the first data byte of the TLV, or to NULL
191 * if the TLV hasn't been found.
193 static void *lbs_tlv_find(uint16_t tlv_type, const uint8_t *tlv, uint16_t size)
195 struct mrvl_ie_header *tlv_h;
200 tlv_h = (struct mrvl_ie_header *) tlv;
203 if (tlv_h->type == cpu_to_le16(tlv_type))
205 length = le16_to_cpu(tlv_h->len) + sizeof(*tlv_h);
213 static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
214 struct file *file, char __user *userbuf,
215 size_t count, loff_t *ppos)
217 struct cmd_ds_802_11_subscribe_event *subscribed;
218 struct mrvl_ie_thresholds *got;
219 struct lbs_private *priv = file->private_data;
227 buf = (char *)get_zeroed_page(GFP_KERNEL);
231 subscribed = kzalloc(sizeof(*subscribed), GFP_KERNEL);
237 subscribed->hdr.size = cpu_to_le16(sizeof(*subscribed));
238 subscribed->action = cpu_to_le16(CMD_ACT_GET);
240 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, subscribed);
244 got = lbs_tlv_find(tlv_type, subscribed->tlv, sizeof(subscribed->tlv));
248 events = le16_to_cpu(subscribed->events);
250 pos += snprintf(buf, len, "%d %d %d\n", value, freq,
251 !!(events & event_mask));
254 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
260 free_page((unsigned long)buf);
265 static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
267 const char __user *userbuf, size_t count,
270 struct cmd_ds_802_11_subscribe_event *events;
271 struct mrvl_ie_thresholds *tlv;
272 struct lbs_private *priv = file->private_data;
274 int value, freq, new_mask;
279 buf = (char *)get_zeroed_page(GFP_KERNEL);
283 buf_size = min(count, len - 1);
284 if (copy_from_user(buf, userbuf, buf_size)) {
288 ret = sscanf(buf, "%d %d %d", &value, &freq, &new_mask);
293 events = kzalloc(sizeof(*events), GFP_KERNEL);
299 events->hdr.size = cpu_to_le16(sizeof(*events));
300 events->action = cpu_to_le16(CMD_ACT_GET);
302 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
306 curr_mask = le16_to_cpu(events->events);
309 new_mask = curr_mask | event_mask;
311 new_mask = curr_mask & ~event_mask;
313 /* Now everything is set and we can send stuff down to the firmware */
315 tlv = (void *)events->tlv;
317 events->action = cpu_to_le16(CMD_ACT_SET);
318 events->events = cpu_to_le16(new_mask);
319 tlv->header.type = cpu_to_le16(tlv_type);
320 tlv->header.len = cpu_to_le16(sizeof(*tlv) - sizeof(tlv->header));
322 if (tlv_type != TLV_TYPE_BCNMISS)
325 /* The command header, the action, the event mask, and one TLV */
326 events->hdr.size = cpu_to_le16(sizeof(events->hdr) + 4 + sizeof(*tlv));
328 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
335 free_page((unsigned long)buf);
340 static ssize_t lbs_lowrssi_read(struct file *file, char __user *userbuf,
341 size_t count, loff_t *ppos)
343 return lbs_threshold_read(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
344 file, userbuf, count, ppos);
348 static ssize_t lbs_lowrssi_write(struct file *file, const char __user *userbuf,
349 size_t count, loff_t *ppos)
351 return lbs_threshold_write(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
352 file, userbuf, count, ppos);
356 static ssize_t lbs_lowsnr_read(struct file *file, char __user *userbuf,
357 size_t count, loff_t *ppos)
359 return lbs_threshold_read(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
360 file, userbuf, count, ppos);
364 static ssize_t lbs_lowsnr_write(struct file *file, const char __user *userbuf,
365 size_t count, loff_t *ppos)
367 return lbs_threshold_write(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
368 file, userbuf, count, ppos);
372 static ssize_t lbs_failcount_read(struct file *file, char __user *userbuf,
373 size_t count, loff_t *ppos)
375 return lbs_threshold_read(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
376 file, userbuf, count, ppos);
380 static ssize_t lbs_failcount_write(struct file *file, const char __user *userbuf,
381 size_t count, loff_t *ppos)
383 return lbs_threshold_write(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
384 file, userbuf, count, ppos);
388 static ssize_t lbs_highrssi_read(struct file *file, char __user *userbuf,
389 size_t count, loff_t *ppos)
391 return lbs_threshold_read(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
392 file, userbuf, count, ppos);
396 static ssize_t lbs_highrssi_write(struct file *file, const char __user *userbuf,
397 size_t count, loff_t *ppos)
399 return lbs_threshold_write(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
400 file, userbuf, count, ppos);
404 static ssize_t lbs_highsnr_read(struct file *file, char __user *userbuf,
405 size_t count, loff_t *ppos)
407 return lbs_threshold_read(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
408 file, userbuf, count, ppos);
412 static ssize_t lbs_highsnr_write(struct file *file, const char __user *userbuf,
413 size_t count, loff_t *ppos)
415 return lbs_threshold_write(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
416 file, userbuf, count, ppos);
419 static ssize_t lbs_bcnmiss_read(struct file *file, char __user *userbuf,
420 size_t count, loff_t *ppos)
422 return lbs_threshold_read(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
423 file, userbuf, count, ppos);
427 static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
428 size_t count, loff_t *ppos)
430 return lbs_threshold_write(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
431 file, userbuf, count, ppos);
436 static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
437 size_t count, loff_t *ppos)
439 struct lbs_private *priv = file->private_data;
440 struct lbs_offset_value offval;
443 unsigned long addr = get_zeroed_page(GFP_KERNEL);
444 char *buf = (char *)addr;
448 offval.offset = priv->mac_offset;
451 ret = lbs_prepare_and_send_command(priv,
452 CMD_MAC_REG_ACCESS, 0,
453 CMD_OPTION_WAITFORRSP, 0, &offval);
456 pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n",
457 priv->mac_offset, priv->offsetvalue.value);
459 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
465 static ssize_t lbs_rdmac_write(struct file *file,
466 const char __user *userbuf,
467 size_t count, loff_t *ppos)
469 struct lbs_private *priv = file->private_data;
470 ssize_t res, buf_size;
471 unsigned long addr = get_zeroed_page(GFP_KERNEL);
472 char *buf = (char *)addr;
476 buf_size = min(count, len - 1);
477 if (copy_from_user(buf, userbuf, buf_size)) {
481 priv->mac_offset = simple_strtoul((char *)buf, NULL, 16);
488 static ssize_t lbs_wrmac_write(struct file *file,
489 const char __user *userbuf,
490 size_t count, loff_t *ppos)
493 struct lbs_private *priv = file->private_data;
494 ssize_t res, buf_size;
496 struct lbs_offset_value offval;
497 unsigned long addr = get_zeroed_page(GFP_KERNEL);
498 char *buf = (char *)addr;
502 buf_size = min(count, len - 1);
503 if (copy_from_user(buf, userbuf, buf_size)) {
507 res = sscanf(buf, "%x %x", &offset, &value);
513 offval.offset = offset;
514 offval.value = value;
515 res = lbs_prepare_and_send_command(priv,
516 CMD_MAC_REG_ACCESS, 1,
517 CMD_OPTION_WAITFORRSP, 0, &offval);
527 static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
528 size_t count, loff_t *ppos)
530 struct lbs_private *priv = file->private_data;
531 struct lbs_offset_value offval;
534 unsigned long addr = get_zeroed_page(GFP_KERNEL);
535 char *buf = (char *)addr;
539 offval.offset = priv->bbp_offset;
542 ret = lbs_prepare_and_send_command(priv,
543 CMD_BBP_REG_ACCESS, 0,
544 CMD_OPTION_WAITFORRSP, 0, &offval);
547 pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n",
548 priv->bbp_offset, priv->offsetvalue.value);
550 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
557 static ssize_t lbs_rdbbp_write(struct file *file,
558 const char __user *userbuf,
559 size_t count, loff_t *ppos)
561 struct lbs_private *priv = file->private_data;
562 ssize_t res, buf_size;
563 unsigned long addr = get_zeroed_page(GFP_KERNEL);
564 char *buf = (char *)addr;
568 buf_size = min(count, len - 1);
569 if (copy_from_user(buf, userbuf, buf_size)) {
573 priv->bbp_offset = simple_strtoul((char *)buf, NULL, 16);
580 static ssize_t lbs_wrbbp_write(struct file *file,
581 const char __user *userbuf,
582 size_t count, loff_t *ppos)
585 struct lbs_private *priv = file->private_data;
586 ssize_t res, buf_size;
588 struct lbs_offset_value offval;
589 unsigned long addr = get_zeroed_page(GFP_KERNEL);
590 char *buf = (char *)addr;
594 buf_size = min(count, len - 1);
595 if (copy_from_user(buf, userbuf, buf_size)) {
599 res = sscanf(buf, "%x %x", &offset, &value);
605 offval.offset = offset;
606 offval.value = value;
607 res = lbs_prepare_and_send_command(priv,
608 CMD_BBP_REG_ACCESS, 1,
609 CMD_OPTION_WAITFORRSP, 0, &offval);
619 static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
620 size_t count, loff_t *ppos)
622 struct lbs_private *priv = file->private_data;
623 struct lbs_offset_value offval;
626 unsigned long addr = get_zeroed_page(GFP_KERNEL);
627 char *buf = (char *)addr;
631 offval.offset = priv->rf_offset;
634 ret = lbs_prepare_and_send_command(priv,
635 CMD_RF_REG_ACCESS, 0,
636 CMD_OPTION_WAITFORRSP, 0, &offval);
639 pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n",
640 priv->rf_offset, priv->offsetvalue.value);
642 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
649 static ssize_t lbs_rdrf_write(struct file *file,
650 const char __user *userbuf,
651 size_t count, loff_t *ppos)
653 struct lbs_private *priv = file->private_data;
654 ssize_t res, buf_size;
655 unsigned long addr = get_zeroed_page(GFP_KERNEL);
656 char *buf = (char *)addr;
660 buf_size = min(count, len - 1);
661 if (copy_from_user(buf, userbuf, buf_size)) {
665 priv->rf_offset = simple_strtoul(buf, NULL, 16);
672 static ssize_t lbs_wrrf_write(struct file *file,
673 const char __user *userbuf,
674 size_t count, loff_t *ppos)
677 struct lbs_private *priv = file->private_data;
678 ssize_t res, buf_size;
680 struct lbs_offset_value offval;
681 unsigned long addr = get_zeroed_page(GFP_KERNEL);
682 char *buf = (char *)addr;
686 buf_size = min(count, len - 1);
687 if (copy_from_user(buf, userbuf, buf_size)) {
691 res = sscanf(buf, "%x %x", &offset, &value);
697 offval.offset = offset;
698 offval.value = value;
699 res = lbs_prepare_and_send_command(priv,
700 CMD_RF_REG_ACCESS, 1,
701 CMD_OPTION_WAITFORRSP, 0, &offval);
711 #define FOPS(fread, fwrite) { \
712 .owner = THIS_MODULE, \
713 .open = open_file_generic, \
718 struct lbs_debugfs_files {
721 struct file_operations fops;
724 static const struct lbs_debugfs_files debugfs_files[] = {
725 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), },
726 { "getscantable", 0444, FOPS(lbs_getscantable,
727 write_file_dummy), },
728 { "sleepparams", 0644, FOPS(lbs_sleepparams_read,
729 lbs_sleepparams_write), },
732 static const struct lbs_debugfs_files debugfs_events_files[] = {
733 {"low_rssi", 0644, FOPS(lbs_lowrssi_read,
734 lbs_lowrssi_write), },
735 {"low_snr", 0644, FOPS(lbs_lowsnr_read,
736 lbs_lowsnr_write), },
737 {"failure_count", 0644, FOPS(lbs_failcount_read,
738 lbs_failcount_write), },
739 {"beacon_missed", 0644, FOPS(lbs_bcnmiss_read,
740 lbs_bcnmiss_write), },
741 {"high_rssi", 0644, FOPS(lbs_highrssi_read,
742 lbs_highrssi_write), },
743 {"high_snr", 0644, FOPS(lbs_highsnr_read,
744 lbs_highsnr_write), },
747 static const struct lbs_debugfs_files debugfs_regs_files[] = {
748 {"rdmac", 0644, FOPS(lbs_rdmac_read, lbs_rdmac_write), },
749 {"wrmac", 0600, FOPS(NULL, lbs_wrmac_write), },
750 {"rdbbp", 0644, FOPS(lbs_rdbbp_read, lbs_rdbbp_write), },
751 {"wrbbp", 0600, FOPS(NULL, lbs_wrbbp_write), },
752 {"rdrf", 0644, FOPS(lbs_rdrf_read, lbs_rdrf_write), },
753 {"wrrf", 0600, FOPS(NULL, lbs_wrrf_write), },
756 void lbs_debugfs_init(void)
759 lbs_dir = debugfs_create_dir("lbs_wireless", NULL);
764 void lbs_debugfs_remove(void)
767 debugfs_remove(lbs_dir);
771 void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
774 const struct lbs_debugfs_files *files;
778 priv->debugfs_dir = debugfs_create_dir(dev->name, lbs_dir);
779 if (!priv->debugfs_dir)
782 for (i=0; i<ARRAY_SIZE(debugfs_files); i++) {
783 files = &debugfs_files[i];
784 priv->debugfs_files[i] = debugfs_create_file(files->name,
791 priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir);
792 if (!priv->events_dir)
795 for (i=0; i<ARRAY_SIZE(debugfs_events_files); i++) {
796 files = &debugfs_events_files[i];
797 priv->debugfs_events_files[i] = debugfs_create_file(files->name,
804 priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir);
808 for (i=0; i<ARRAY_SIZE(debugfs_regs_files); i++) {
809 files = &debugfs_regs_files[i];
810 priv->debugfs_regs_files[i] = debugfs_create_file(files->name,
818 lbs_debug_init(priv);
824 void lbs_debugfs_remove_one(struct lbs_private *priv)
828 for(i=0; i<ARRAY_SIZE(debugfs_regs_files); i++)
829 debugfs_remove(priv->debugfs_regs_files[i]);
831 debugfs_remove(priv->regs_dir);
833 for(i=0; i<ARRAY_SIZE(debugfs_events_files); i++)
834 debugfs_remove(priv->debugfs_events_files[i]);
836 debugfs_remove(priv->events_dir);
838 debugfs_remove(priv->debugfs_debug);
840 for(i=0; i<ARRAY_SIZE(debugfs_files); i++)
841 debugfs_remove(priv->debugfs_files[i]);
842 debugfs_remove(priv->debugfs_dir);
851 #define item_size(n) (FIELD_SIZEOF(struct lbs_private, n))
852 #define item_addr(n) (offsetof(struct lbs_private, n))
861 /* To debug any member of struct lbs_private, simply add one line here.
863 static struct debug_data items[] = {
864 {"psmode", item_size(psmode), item_addr(psmode)},
865 {"psstate", item_size(psstate), item_addr(psstate)},
868 static int num_of_items = ARRAY_SIZE(items);
871 * @brief proc read function
873 * @param page pointer to buffer
874 * @param s read data starting position
877 * @param eof end of file flag
878 * @param data data to output
879 * @return number of output data
881 static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
882 size_t count, loff_t *ppos)
889 struct debug_data *d;
890 unsigned long addr = get_zeroed_page(GFP_KERNEL);
891 char *buf = (char *)addr;
897 d = (struct debug_data *)file->private_data;
899 for (i = 0; i < num_of_items; i++) {
901 val = *((u8 *) d[i].addr);
902 else if (d[i].size == 2)
903 val = *((u16 *) d[i].addr);
904 else if (d[i].size == 4)
905 val = *((u32 *) d[i].addr);
906 else if (d[i].size == 8)
907 val = *((u64 *) d[i].addr);
909 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
912 res = simple_read_from_buffer(userbuf, count, ppos, p, pos);
919 * @brief proc write function
921 * @param f file pointer
922 * @param buf pointer to data buffer
923 * @param cnt data number to write
924 * @param data data to write
925 * @return number of data
927 static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
928 size_t cnt, loff_t *ppos)
936 struct debug_data *d = (struct debug_data *)f->private_data;
938 pdata = kmalloc(cnt, GFP_KERNEL);
942 if (copy_from_user(pdata, buf, cnt)) {
943 lbs_deb_debugfs("Copy from user failed\n");
949 for (i = 0; i < num_of_items; i++) {
951 p = strstr(p0, d[i].name);
954 p1 = strchr(p, '\n');
962 r = simple_strtoul(p2, NULL, 0);
964 *((u8 *) d[i].addr) = (u8) r;
965 else if (d[i].size == 2)
966 *((u16 *) d[i].addr) = (u16) r;
967 else if (d[i].size == 4)
968 *((u32 *) d[i].addr) = (u32) r;
969 else if (d[i].size == 8)
970 *((u64 *) d[i].addr) = (u64) r;
979 static const struct file_operations lbs_debug_fops = {
980 .owner = THIS_MODULE,
981 .open = open_file_generic,
982 .write = lbs_debugfs_write,
983 .read = lbs_debugfs_read,
987 * @brief create debug proc file
989 * @param priv pointer struct lbs_private
990 * @param dev pointer net_device
993 static void lbs_debug_init(struct lbs_private *priv)
997 if (!priv->debugfs_dir)
1000 for (i = 0; i < num_of_items; i++)
1001 items[i].addr += (size_t) priv;
1003 priv->debugfs_debug = debugfs_create_file("debug", 0644,
1004 priv->debugfs_dir, &items[0],