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 <net/iw_handler.h>
15 static struct dentry *lbs_dir;
16 static char *szStates[] = {
22 static void lbs_debug_init(struct lbs_private *priv);
25 static int open_file_generic(struct inode *inode, struct file *file)
27 file->private_data = inode->i_private;
31 static ssize_t write_file_dummy(struct file *file, const char __user *buf,
32 size_t count, loff_t *ppos)
37 static const size_t len = PAGE_SIZE;
39 static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
40 size_t count, loff_t *ppos)
42 struct lbs_private *priv = file->private_data;
44 unsigned long addr = get_zeroed_page(GFP_KERNEL);
45 char *buf = (char *)addr;
48 pos += snprintf(buf+pos, len-pos, "state = %s\n",
49 szStates[priv->connect_status]);
50 pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
51 (u32) priv->regioncode);
53 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
60 static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
61 size_t count, loff_t *ppos)
63 struct lbs_private *priv = file->private_data;
65 int numscansdone = 0, res;
66 unsigned long addr = get_zeroed_page(GFP_KERNEL);
67 char *buf = (char *)addr;
68 struct bss_descriptor * iter_bss;
70 pos += snprintf(buf+pos, len-pos,
71 "# | ch | rssi | bssid | cap | Qual | SSID \n");
73 mutex_lock(&priv->lock);
74 list_for_each_entry (iter_bss, &priv->network_list, list) {
75 u16 ibss = (iter_bss->capability & WLAN_CAPABILITY_IBSS);
76 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY);
77 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
79 pos += snprintf(buf+pos, len-pos, "%02u| %03d | %04d | %pM |",
80 numscansdone, iter_bss->channel, iter_bss->rssi,
82 pos += snprintf(buf+pos, len-pos, " %04x-", iter_bss->capability);
83 pos += snprintf(buf+pos, len-pos, "%c%c%c |",
84 ibss ? 'A' : 'I', privacy ? 'P' : ' ',
85 spectrum_mgmt ? 'S' : ' ');
86 pos += snprintf(buf+pos, len-pos, " %04d |", SCAN_RSSI(iter_bss->rssi));
87 pos += snprintf(buf+pos, len-pos, " %s\n",
88 escape_essid(iter_bss->ssid, iter_bss->ssid_len));
92 mutex_unlock(&priv->lock);
94 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
100 static ssize_t lbs_sleepparams_write(struct file *file,
101 const char __user *user_buf, size_t count,
104 struct lbs_private *priv = file->private_data;
105 ssize_t buf_size, ret;
106 struct sleep_params sp;
107 int p1, p2, p3, p4, p5, p6;
108 unsigned long addr = get_zeroed_page(GFP_KERNEL);
109 char *buf = (char *)addr;
111 buf_size = min(count, len - 1);
112 if (copy_from_user(buf, user_buf, buf_size)) {
116 ret = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6);
123 sp.sp_stabletime = p3;
124 sp.sp_calcontrol = p4;
125 sp.sp_extsleepclk = p5;
128 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_SET, &sp);
139 static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
140 size_t count, loff_t *ppos)
142 struct lbs_private *priv = file->private_data;
145 struct sleep_params sp;
146 unsigned long addr = get_zeroed_page(GFP_KERNEL);
147 char *buf = (char *)addr;
149 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
153 pos += snprintf(buf, len, "%d %d %d %d %d %d\n", sp.sp_error,
154 sp.sp_offset, sp.sp_stabletime,
155 sp.sp_calcontrol, sp.sp_extsleepclk,
158 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
166 * When calling CMD_802_11_SUBSCRIBE_EVENT with CMD_ACT_GET, me might
167 * get a bunch of vendor-specific TLVs (a.k.a. IEs) back from the
168 * firmware. Here's an example:
169 * 04 01 02 00 00 00 05 01 02 00 00 00 06 01 02 00
170 * 00 00 07 01 02 00 3c 00 00 00 00 00 00 00 03 03
171 * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
173 * The 04 01 is the TLV type (here TLV_TYPE_RSSI_LOW), 02 00 is the length,
174 * 00 00 are the data bytes of this TLV. For this TLV, their meaning is
175 * defined in mrvlietypes_thresholds
177 * This function searches in this TLV data chunk for a given TLV type
178 * and returns a pointer to the first data byte of the TLV, or to NULL
179 * if the TLV hasn't been found.
181 static void *lbs_tlv_find(uint16_t tlv_type, const uint8_t *tlv, uint16_t size)
183 struct mrvlietypesheader *tlv_h;
188 tlv_h = (struct mrvlietypesheader *) tlv;
191 if (tlv_h->type == cpu_to_le16(tlv_type))
193 length = le16_to_cpu(tlv_h->len) + sizeof(*tlv_h);
201 static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
202 struct file *file, char __user *userbuf,
203 size_t count, loff_t *ppos)
205 struct cmd_ds_802_11_subscribe_event *subscribed;
206 struct mrvlietypes_thresholds *got;
207 struct lbs_private *priv = file->private_data;
215 buf = (char *)get_zeroed_page(GFP_KERNEL);
219 subscribed = kzalloc(sizeof(*subscribed), GFP_KERNEL);
225 subscribed->hdr.size = cpu_to_le16(sizeof(*subscribed));
226 subscribed->action = cpu_to_le16(CMD_ACT_GET);
228 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, subscribed);
232 got = lbs_tlv_find(tlv_type, subscribed->tlv, sizeof(subscribed->tlv));
236 events = le16_to_cpu(subscribed->events);
238 pos += snprintf(buf, len, "%d %d %d\n", value, freq,
239 !!(events & event_mask));
242 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
248 free_page((unsigned long)buf);
253 static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
255 const char __user *userbuf, size_t count,
258 struct cmd_ds_802_11_subscribe_event *events;
259 struct mrvlietypes_thresholds *tlv;
260 struct lbs_private *priv = file->private_data;
262 int value, freq, new_mask;
267 buf = (char *)get_zeroed_page(GFP_KERNEL);
271 buf_size = min(count, len - 1);
272 if (copy_from_user(buf, userbuf, buf_size)) {
276 ret = sscanf(buf, "%d %d %d", &value, &freq, &new_mask);
281 events = kzalloc(sizeof(*events), GFP_KERNEL);
287 events->hdr.size = cpu_to_le16(sizeof(*events));
288 events->action = cpu_to_le16(CMD_ACT_GET);
290 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
294 curr_mask = le16_to_cpu(events->events);
297 new_mask = curr_mask | event_mask;
299 new_mask = curr_mask & ~event_mask;
301 /* Now everything is set and we can send stuff down to the firmware */
303 tlv = (void *)events->tlv;
305 events->action = cpu_to_le16(CMD_ACT_SET);
306 events->events = cpu_to_le16(new_mask);
307 tlv->header.type = cpu_to_le16(tlv_type);
308 tlv->header.len = cpu_to_le16(sizeof(*tlv) - sizeof(tlv->header));
310 if (tlv_type != TLV_TYPE_BCNMISS)
313 /* The command header, the action, the event mask, and one TLV */
314 events->hdr.size = cpu_to_le16(sizeof(events->hdr) + 4 + sizeof(*tlv));
316 ret = lbs_cmd_with_response(priv, CMD_802_11_SUBSCRIBE_EVENT, events);
323 free_page((unsigned long)buf);
328 static ssize_t lbs_lowrssi_read(struct file *file, char __user *userbuf,
329 size_t count, loff_t *ppos)
331 return lbs_threshold_read(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
332 file, userbuf, count, ppos);
336 static ssize_t lbs_lowrssi_write(struct file *file, const char __user *userbuf,
337 size_t count, loff_t *ppos)
339 return lbs_threshold_write(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
340 file, userbuf, count, ppos);
344 static ssize_t lbs_lowsnr_read(struct file *file, char __user *userbuf,
345 size_t count, loff_t *ppos)
347 return lbs_threshold_read(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
348 file, userbuf, count, ppos);
352 static ssize_t lbs_lowsnr_write(struct file *file, const char __user *userbuf,
353 size_t count, loff_t *ppos)
355 return lbs_threshold_write(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
356 file, userbuf, count, ppos);
360 static ssize_t lbs_failcount_read(struct file *file, char __user *userbuf,
361 size_t count, loff_t *ppos)
363 return lbs_threshold_read(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
364 file, userbuf, count, ppos);
368 static ssize_t lbs_failcount_write(struct file *file, const char __user *userbuf,
369 size_t count, loff_t *ppos)
371 return lbs_threshold_write(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
372 file, userbuf, count, ppos);
376 static ssize_t lbs_highrssi_read(struct file *file, char __user *userbuf,
377 size_t count, loff_t *ppos)
379 return lbs_threshold_read(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
380 file, userbuf, count, ppos);
384 static ssize_t lbs_highrssi_write(struct file *file, const char __user *userbuf,
385 size_t count, loff_t *ppos)
387 return lbs_threshold_write(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
388 file, userbuf, count, ppos);
392 static ssize_t lbs_highsnr_read(struct file *file, char __user *userbuf,
393 size_t count, loff_t *ppos)
395 return lbs_threshold_read(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
396 file, userbuf, count, ppos);
400 static ssize_t lbs_highsnr_write(struct file *file, const char __user *userbuf,
401 size_t count, loff_t *ppos)
403 return lbs_threshold_write(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
404 file, userbuf, count, ppos);
407 static ssize_t lbs_bcnmiss_read(struct file *file, char __user *userbuf,
408 size_t count, loff_t *ppos)
410 return lbs_threshold_read(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
411 file, userbuf, count, ppos);
415 static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
416 size_t count, loff_t *ppos)
418 return lbs_threshold_write(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
419 file, userbuf, count, ppos);
424 static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
425 size_t count, loff_t *ppos)
427 struct lbs_private *priv = file->private_data;
428 struct lbs_offset_value offval;
431 unsigned long addr = get_zeroed_page(GFP_KERNEL);
432 char *buf = (char *)addr;
434 offval.offset = priv->mac_offset;
437 ret = lbs_prepare_and_send_command(priv,
438 CMD_MAC_REG_ACCESS, 0,
439 CMD_OPTION_WAITFORRSP, 0, &offval);
441 pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n",
442 priv->mac_offset, priv->offsetvalue.value);
444 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
449 static ssize_t lbs_rdmac_write(struct file *file,
450 const char __user *userbuf,
451 size_t count, loff_t *ppos)
453 struct lbs_private *priv = file->private_data;
454 ssize_t res, buf_size;
455 unsigned long addr = get_zeroed_page(GFP_KERNEL);
456 char *buf = (char *)addr;
458 buf_size = min(count, len - 1);
459 if (copy_from_user(buf, userbuf, buf_size)) {
463 priv->mac_offset = simple_strtoul((char *)buf, NULL, 16);
470 static ssize_t lbs_wrmac_write(struct file *file,
471 const char __user *userbuf,
472 size_t count, loff_t *ppos)
475 struct lbs_private *priv = file->private_data;
476 ssize_t res, buf_size;
478 struct lbs_offset_value offval;
479 unsigned long addr = get_zeroed_page(GFP_KERNEL);
480 char *buf = (char *)addr;
482 buf_size = min(count, len - 1);
483 if (copy_from_user(buf, userbuf, buf_size)) {
487 res = sscanf(buf, "%x %x", &offset, &value);
493 offval.offset = offset;
494 offval.value = value;
495 res = lbs_prepare_and_send_command(priv,
496 CMD_MAC_REG_ACCESS, 1,
497 CMD_OPTION_WAITFORRSP, 0, &offval);
506 static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
507 size_t count, loff_t *ppos)
509 struct lbs_private *priv = file->private_data;
510 struct lbs_offset_value offval;
513 unsigned long addr = get_zeroed_page(GFP_KERNEL);
514 char *buf = (char *)addr;
516 offval.offset = priv->bbp_offset;
519 ret = lbs_prepare_and_send_command(priv,
520 CMD_BBP_REG_ACCESS, 0,
521 CMD_OPTION_WAITFORRSP, 0, &offval);
523 pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n",
524 priv->bbp_offset, priv->offsetvalue.value);
526 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
532 static ssize_t lbs_rdbbp_write(struct file *file,
533 const char __user *userbuf,
534 size_t count, loff_t *ppos)
536 struct lbs_private *priv = file->private_data;
537 ssize_t res, buf_size;
538 unsigned long addr = get_zeroed_page(GFP_KERNEL);
539 char *buf = (char *)addr;
541 buf_size = min(count, len - 1);
542 if (copy_from_user(buf, userbuf, buf_size)) {
546 priv->bbp_offset = simple_strtoul((char *)buf, NULL, 16);
553 static ssize_t lbs_wrbbp_write(struct file *file,
554 const char __user *userbuf,
555 size_t count, loff_t *ppos)
558 struct lbs_private *priv = file->private_data;
559 ssize_t res, buf_size;
561 struct lbs_offset_value offval;
562 unsigned long addr = get_zeroed_page(GFP_KERNEL);
563 char *buf = (char *)addr;
565 buf_size = min(count, len - 1);
566 if (copy_from_user(buf, userbuf, buf_size)) {
570 res = sscanf(buf, "%x %x", &offset, &value);
576 offval.offset = offset;
577 offval.value = value;
578 res = lbs_prepare_and_send_command(priv,
579 CMD_BBP_REG_ACCESS, 1,
580 CMD_OPTION_WAITFORRSP, 0, &offval);
589 static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
590 size_t count, loff_t *ppos)
592 struct lbs_private *priv = file->private_data;
593 struct lbs_offset_value offval;
596 unsigned long addr = get_zeroed_page(GFP_KERNEL);
597 char *buf = (char *)addr;
599 offval.offset = priv->rf_offset;
602 ret = lbs_prepare_and_send_command(priv,
603 CMD_RF_REG_ACCESS, 0,
604 CMD_OPTION_WAITFORRSP, 0, &offval);
606 pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n",
607 priv->rf_offset, priv->offsetvalue.value);
609 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
615 static ssize_t lbs_rdrf_write(struct file *file,
616 const char __user *userbuf,
617 size_t count, loff_t *ppos)
619 struct lbs_private *priv = file->private_data;
620 ssize_t res, buf_size;
621 unsigned long addr = get_zeroed_page(GFP_KERNEL);
622 char *buf = (char *)addr;
624 buf_size = min(count, len - 1);
625 if (copy_from_user(buf, userbuf, buf_size)) {
629 priv->rf_offset = simple_strtoul((char *)buf, NULL, 16);
636 static ssize_t lbs_wrrf_write(struct file *file,
637 const char __user *userbuf,
638 size_t count, loff_t *ppos)
641 struct lbs_private *priv = file->private_data;
642 ssize_t res, buf_size;
644 struct lbs_offset_value offval;
645 unsigned long addr = get_zeroed_page(GFP_KERNEL);
646 char *buf = (char *)addr;
648 buf_size = min(count, len - 1);
649 if (copy_from_user(buf, userbuf, buf_size)) {
653 res = sscanf(buf, "%x %x", &offset, &value);
659 offval.offset = offset;
660 offval.value = value;
661 res = lbs_prepare_and_send_command(priv,
662 CMD_RF_REG_ACCESS, 1,
663 CMD_OPTION_WAITFORRSP, 0, &offval);
672 #define FOPS(fread, fwrite) { \
673 .owner = THIS_MODULE, \
674 .open = open_file_generic, \
679 struct lbs_debugfs_files {
682 struct file_operations fops;
685 static struct lbs_debugfs_files debugfs_files[] = {
686 { "info", 0444, FOPS(lbs_dev_info, write_file_dummy), },
687 { "getscantable", 0444, FOPS(lbs_getscantable,
688 write_file_dummy), },
689 { "sleepparams", 0644, FOPS(lbs_sleepparams_read,
690 lbs_sleepparams_write), },
693 static struct lbs_debugfs_files debugfs_events_files[] = {
694 {"low_rssi", 0644, FOPS(lbs_lowrssi_read,
695 lbs_lowrssi_write), },
696 {"low_snr", 0644, FOPS(lbs_lowsnr_read,
697 lbs_lowsnr_write), },
698 {"failure_count", 0644, FOPS(lbs_failcount_read,
699 lbs_failcount_write), },
700 {"beacon_missed", 0644, FOPS(lbs_bcnmiss_read,
701 lbs_bcnmiss_write), },
702 {"high_rssi", 0644, FOPS(lbs_highrssi_read,
703 lbs_highrssi_write), },
704 {"high_snr", 0644, FOPS(lbs_highsnr_read,
705 lbs_highsnr_write), },
708 static struct lbs_debugfs_files debugfs_regs_files[] = {
709 {"rdmac", 0644, FOPS(lbs_rdmac_read, lbs_rdmac_write), },
710 {"wrmac", 0600, FOPS(NULL, lbs_wrmac_write), },
711 {"rdbbp", 0644, FOPS(lbs_rdbbp_read, lbs_rdbbp_write), },
712 {"wrbbp", 0600, FOPS(NULL, lbs_wrbbp_write), },
713 {"rdrf", 0644, FOPS(lbs_rdrf_read, lbs_rdrf_write), },
714 {"wrrf", 0600, FOPS(NULL, lbs_wrrf_write), },
717 void lbs_debugfs_init(void)
720 lbs_dir = debugfs_create_dir("lbs_wireless", NULL);
725 void lbs_debugfs_remove(void)
728 debugfs_remove(lbs_dir);
732 void lbs_debugfs_init_one(struct lbs_private *priv, struct net_device *dev)
735 struct lbs_debugfs_files *files;
739 priv->debugfs_dir = debugfs_create_dir(dev->name, lbs_dir);
740 if (!priv->debugfs_dir)
743 for (i=0; i<ARRAY_SIZE(debugfs_files); i++) {
744 files = &debugfs_files[i];
745 priv->debugfs_files[i] = debugfs_create_file(files->name,
752 priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir);
753 if (!priv->events_dir)
756 for (i=0; i<ARRAY_SIZE(debugfs_events_files); i++) {
757 files = &debugfs_events_files[i];
758 priv->debugfs_events_files[i] = debugfs_create_file(files->name,
765 priv->regs_dir = debugfs_create_dir("registers", priv->debugfs_dir);
769 for (i=0; i<ARRAY_SIZE(debugfs_regs_files); i++) {
770 files = &debugfs_regs_files[i];
771 priv->debugfs_regs_files[i] = debugfs_create_file(files->name,
779 lbs_debug_init(priv);
785 void lbs_debugfs_remove_one(struct lbs_private *priv)
789 for(i=0; i<ARRAY_SIZE(debugfs_regs_files); i++)
790 debugfs_remove(priv->debugfs_regs_files[i]);
792 debugfs_remove(priv->regs_dir);
794 for(i=0; i<ARRAY_SIZE(debugfs_events_files); i++)
795 debugfs_remove(priv->debugfs_events_files[i]);
797 debugfs_remove(priv->events_dir);
799 debugfs_remove(priv->debugfs_debug);
801 for(i=0; i<ARRAY_SIZE(debugfs_files); i++)
802 debugfs_remove(priv->debugfs_files[i]);
803 debugfs_remove(priv->debugfs_dir);
812 #define item_size(n) (FIELD_SIZEOF(struct lbs_private, n))
813 #define item_addr(n) (offsetof(struct lbs_private, n))
822 /* To debug any member of struct lbs_private, simply add one line here.
824 static struct debug_data items[] = {
825 {"psmode", item_size(psmode), item_addr(psmode)},
826 {"psstate", item_size(psstate), item_addr(psstate)},
829 static int num_of_items = ARRAY_SIZE(items);
832 * @brief proc read function
834 * @param page pointer to buffer
835 * @param s read data starting position
838 * @param eof end of file flag
839 * @param data data to output
840 * @return number of output data
842 static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
843 size_t count, loff_t *ppos)
850 struct debug_data *d;
851 unsigned long addr = get_zeroed_page(GFP_KERNEL);
852 char *buf = (char *)addr;
856 d = (struct debug_data *)file->private_data;
858 for (i = 0; i < num_of_items; i++) {
860 val = *((u8 *) d[i].addr);
861 else if (d[i].size == 2)
862 val = *((u16 *) d[i].addr);
863 else if (d[i].size == 4)
864 val = *((u32 *) d[i].addr);
865 else if (d[i].size == 8)
866 val = *((u64 *) d[i].addr);
868 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
871 res = simple_read_from_buffer(userbuf, count, ppos, p, pos);
878 * @brief proc write function
880 * @param f file pointer
881 * @param buf pointer to data buffer
882 * @param cnt data number to write
883 * @param data data to write
884 * @return number of data
886 static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
887 size_t cnt, loff_t *ppos)
895 struct debug_data *d = (struct debug_data *)f->private_data;
897 pdata = kmalloc(cnt, GFP_KERNEL);
901 if (copy_from_user(pdata, buf, cnt)) {
902 lbs_deb_debugfs("Copy from user failed\n");
908 for (i = 0; i < num_of_items; i++) {
910 p = strstr(p0, d[i].name);
913 p1 = strchr(p, '\n');
921 r = simple_strtoul(p2, NULL, 0);
923 *((u8 *) d[i].addr) = (u8) r;
924 else if (d[i].size == 2)
925 *((u16 *) d[i].addr) = (u16) r;
926 else if (d[i].size == 4)
927 *((u32 *) d[i].addr) = (u32) r;
928 else if (d[i].size == 8)
929 *((u64 *) d[i].addr) = (u64) r;
938 static struct file_operations lbs_debug_fops = {
939 .owner = THIS_MODULE,
940 .open = open_file_generic,
941 .write = lbs_debugfs_write,
942 .read = lbs_debugfs_read,
946 * @brief create debug proc file
948 * @param priv pointer struct lbs_private
949 * @param dev pointer net_device
952 static void lbs_debug_init(struct lbs_private *priv)
956 if (!priv->debugfs_dir)
959 for (i = 0; i < num_of_items; i++)
960 items[i].addr += (size_t) priv;
962 priv->debugfs_debug = debugfs_create_file("debug", 0644,
963 priv->debugfs_dir, &items[0],