smsdvb-debugfs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. // SPDX-License-Identifier: GPL-2.0+
  2. //
  3. // Copyright(c) 2013 Mauro Carvalho Chehab
  4. #include "smscoreapi.h"
  5. #include <linux/module.h>
  6. #include <linux/slab.h>
  7. #include <linux/init.h>
  8. #include <linux/debugfs.h>
  9. #include <linux/spinlock.h>
  10. #include <linux/usb.h>
  11. #include <media/dmxdev.h>
  12. #include <media/dvbdev.h>
  13. #include <media/dvb_demux.h>
  14. #include <media/dvb_frontend.h>
  15. #include "smsdvb.h"
  16. static struct dentry *smsdvb_debugfs_usb_root;
  17. struct smsdvb_debugfs {
  18. struct kref refcount;
  19. spinlock_t lock;
  20. char stats_data[PAGE_SIZE];
  21. unsigned stats_count;
  22. bool stats_was_read;
  23. wait_queue_head_t stats_queue;
  24. };
  25. static void smsdvb_print_dvb_stats(struct smsdvb_debugfs *debug_data,
  26. struct sms_stats *p)
  27. {
  28. int n = 0;
  29. char *buf;
  30. spin_lock(&debug_data->lock);
  31. if (debug_data->stats_count) {
  32. spin_unlock(&debug_data->lock);
  33. return;
  34. }
  35. buf = debug_data->stats_data;
  36. n += snprintf(&buf[n], PAGE_SIZE - n,
  37. "is_rf_locked = %d\n", p->is_rf_locked);
  38. n += snprintf(&buf[n], PAGE_SIZE - n,
  39. "is_demod_locked = %d\n", p->is_demod_locked);
  40. n += snprintf(&buf[n], PAGE_SIZE - n,
  41. "is_external_lna_on = %d\n", p->is_external_lna_on);
  42. n += snprintf(&buf[n], PAGE_SIZE - n,
  43. "SNR = %d\n", p->SNR);
  44. n += snprintf(&buf[n], PAGE_SIZE - n,
  45. "ber = %d\n", p->ber);
  46. n += snprintf(&buf[n], PAGE_SIZE - n,
  47. "FIB_CRC = %d\n", p->FIB_CRC);
  48. n += snprintf(&buf[n], PAGE_SIZE - n,
  49. "ts_per = %d\n", p->ts_per);
  50. n += snprintf(&buf[n], PAGE_SIZE - n,
  51. "MFER = %d\n", p->MFER);
  52. n += snprintf(&buf[n], PAGE_SIZE - n,
  53. "RSSI = %d\n", p->RSSI);
  54. n += snprintf(&buf[n], PAGE_SIZE - n,
  55. "in_band_pwr = %d\n", p->in_band_pwr);
  56. n += snprintf(&buf[n], PAGE_SIZE - n,
  57. "carrier_offset = %d\n", p->carrier_offset);
  58. n += snprintf(&buf[n], PAGE_SIZE - n,
  59. "modem_state = %d\n", p->modem_state);
  60. n += snprintf(&buf[n], PAGE_SIZE - n,
  61. "frequency = %d\n", p->frequency);
  62. n += snprintf(&buf[n], PAGE_SIZE - n,
  63. "bandwidth = %d\n", p->bandwidth);
  64. n += snprintf(&buf[n], PAGE_SIZE - n,
  65. "transmission_mode = %d\n", p->transmission_mode);
  66. n += snprintf(&buf[n], PAGE_SIZE - n,
  67. "modem_state = %d\n", p->modem_state);
  68. n += snprintf(&buf[n], PAGE_SIZE - n,
  69. "guard_interval = %d\n", p->guard_interval);
  70. n += snprintf(&buf[n], PAGE_SIZE - n,
  71. "code_rate = %d\n", p->code_rate);
  72. n += snprintf(&buf[n], PAGE_SIZE - n,
  73. "lp_code_rate = %d\n", p->lp_code_rate);
  74. n += snprintf(&buf[n], PAGE_SIZE - n,
  75. "hierarchy = %d\n", p->hierarchy);
  76. n += snprintf(&buf[n], PAGE_SIZE - n,
  77. "constellation = %d\n", p->constellation);
  78. n += snprintf(&buf[n], PAGE_SIZE - n,
  79. "burst_size = %d\n", p->burst_size);
  80. n += snprintf(&buf[n], PAGE_SIZE - n,
  81. "burst_duration = %d\n", p->burst_duration);
  82. n += snprintf(&buf[n], PAGE_SIZE - n,
  83. "burst_cycle_time = %d\n", p->burst_cycle_time);
  84. n += snprintf(&buf[n], PAGE_SIZE - n,
  85. "calc_burst_cycle_time = %d\n",
  86. p->calc_burst_cycle_time);
  87. n += snprintf(&buf[n], PAGE_SIZE - n,
  88. "num_of_rows = %d\n", p->num_of_rows);
  89. n += snprintf(&buf[n], PAGE_SIZE - n,
  90. "num_of_padd_cols = %d\n", p->num_of_padd_cols);
  91. n += snprintf(&buf[n], PAGE_SIZE - n,
  92. "num_of_punct_cols = %d\n", p->num_of_punct_cols);
  93. n += snprintf(&buf[n], PAGE_SIZE - n,
  94. "error_ts_packets = %d\n", p->error_ts_packets);
  95. n += snprintf(&buf[n], PAGE_SIZE - n,
  96. "total_ts_packets = %d\n", p->total_ts_packets);
  97. n += snprintf(&buf[n], PAGE_SIZE - n,
  98. "num_of_valid_mpe_tlbs = %d\n", p->num_of_valid_mpe_tlbs);
  99. n += snprintf(&buf[n], PAGE_SIZE - n,
  100. "num_of_invalid_mpe_tlbs = %d\n", p->num_of_invalid_mpe_tlbs);
  101. n += snprintf(&buf[n], PAGE_SIZE - n,
  102. "num_of_corrected_mpe_tlbs = %d\n", p->num_of_corrected_mpe_tlbs);
  103. n += snprintf(&buf[n], PAGE_SIZE - n,
  104. "ber_error_count = %d\n", p->ber_error_count);
  105. n += snprintf(&buf[n], PAGE_SIZE - n,
  106. "ber_bit_count = %d\n", p->ber_bit_count);
  107. n += snprintf(&buf[n], PAGE_SIZE - n,
  108. "sms_to_host_tx_errors = %d\n", p->sms_to_host_tx_errors);
  109. n += snprintf(&buf[n], PAGE_SIZE - n,
  110. "pre_ber = %d\n", p->pre_ber);
  111. n += snprintf(&buf[n], PAGE_SIZE - n,
  112. "cell_id = %d\n", p->cell_id);
  113. n += snprintf(&buf[n], PAGE_SIZE - n,
  114. "dvbh_srv_ind_hp = %d\n", p->dvbh_srv_ind_hp);
  115. n += snprintf(&buf[n], PAGE_SIZE - n,
  116. "dvbh_srv_ind_lp = %d\n", p->dvbh_srv_ind_lp);
  117. n += snprintf(&buf[n], PAGE_SIZE - n,
  118. "num_mpe_received = %d\n", p->num_mpe_received);
  119. debug_data->stats_count = n;
  120. spin_unlock(&debug_data->lock);
  121. wake_up(&debug_data->stats_queue);
  122. }
  123. static void smsdvb_print_isdb_stats(struct smsdvb_debugfs *debug_data,
  124. struct sms_isdbt_stats *p)
  125. {
  126. int i, n = 0;
  127. char *buf;
  128. spin_lock(&debug_data->lock);
  129. if (debug_data->stats_count) {
  130. spin_unlock(&debug_data->lock);
  131. return;
  132. }
  133. buf = debug_data->stats_data;
  134. n += snprintf(&buf[n], PAGE_SIZE - n,
  135. "statistics_type = %d\t", p->statistics_type);
  136. n += snprintf(&buf[n], PAGE_SIZE - n,
  137. "full_size = %d\n", p->full_size);
  138. n += snprintf(&buf[n], PAGE_SIZE - n,
  139. "is_rf_locked = %d\t\t", p->is_rf_locked);
  140. n += snprintf(&buf[n], PAGE_SIZE - n,
  141. "is_demod_locked = %d\t", p->is_demod_locked);
  142. n += snprintf(&buf[n], PAGE_SIZE - n,
  143. "is_external_lna_on = %d\n", p->is_external_lna_on);
  144. n += snprintf(&buf[n], PAGE_SIZE - n,
  145. "SNR = %d dB\t\t", p->SNR);
  146. n += snprintf(&buf[n], PAGE_SIZE - n,
  147. "RSSI = %d dBm\t\t", p->RSSI);
  148. n += snprintf(&buf[n], PAGE_SIZE - n,
  149. "in_band_pwr = %d dBm\n", p->in_band_pwr);
  150. n += snprintf(&buf[n], PAGE_SIZE - n,
  151. "carrier_offset = %d\t", p->carrier_offset);
  152. n += snprintf(&buf[n], PAGE_SIZE - n,
  153. "bandwidth = %d\t\t", p->bandwidth);
  154. n += snprintf(&buf[n], PAGE_SIZE - n,
  155. "frequency = %d Hz\n", p->frequency);
  156. n += snprintf(&buf[n], PAGE_SIZE - n,
  157. "transmission_mode = %d\t", p->transmission_mode);
  158. n += snprintf(&buf[n], PAGE_SIZE - n,
  159. "modem_state = %d\t\t", p->modem_state);
  160. n += snprintf(&buf[n], PAGE_SIZE - n,
  161. "guard_interval = %d\n", p->guard_interval);
  162. n += snprintf(&buf[n], PAGE_SIZE - n,
  163. "system_type = %d\t\t", p->system_type);
  164. n += snprintf(&buf[n], PAGE_SIZE - n,
  165. "partial_reception = %d\t", p->partial_reception);
  166. n += snprintf(&buf[n], PAGE_SIZE - n,
  167. "num_of_layers = %d\n", p->num_of_layers);
  168. n += snprintf(&buf[n], PAGE_SIZE - n,
  169. "sms_to_host_tx_errors = %d\n", p->sms_to_host_tx_errors);
  170. for (i = 0; i < 3; i++) {
  171. if (p->layer_info[i].number_of_segments < 1 ||
  172. p->layer_info[i].number_of_segments > 13)
  173. continue;
  174. n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
  175. n += snprintf(&buf[n], PAGE_SIZE - n, "\tcode_rate = %d\t",
  176. p->layer_info[i].code_rate);
  177. n += snprintf(&buf[n], PAGE_SIZE - n, "constellation = %d\n",
  178. p->layer_info[i].constellation);
  179. n += snprintf(&buf[n], PAGE_SIZE - n, "\tber = %-5d\t",
  180. p->layer_info[i].ber);
  181. n += snprintf(&buf[n], PAGE_SIZE - n, "\tber_error_count = %-5d\t",
  182. p->layer_info[i].ber_error_count);
  183. n += snprintf(&buf[n], PAGE_SIZE - n, "ber_bit_count = %-5d\n",
  184. p->layer_info[i].ber_bit_count);
  185. n += snprintf(&buf[n], PAGE_SIZE - n, "\tpre_ber = %-5d\t",
  186. p->layer_info[i].pre_ber);
  187. n += snprintf(&buf[n], PAGE_SIZE - n, "\tts_per = %-5d\n",
  188. p->layer_info[i].ts_per);
  189. n += snprintf(&buf[n], PAGE_SIZE - n, "\terror_ts_packets = %-5d\t",
  190. p->layer_info[i].error_ts_packets);
  191. n += snprintf(&buf[n], PAGE_SIZE - n, "total_ts_packets = %-5d\t",
  192. p->layer_info[i].total_ts_packets);
  193. n += snprintf(&buf[n], PAGE_SIZE - n, "ti_ldepth_i = %d\n",
  194. p->layer_info[i].ti_ldepth_i);
  195. n += snprintf(&buf[n], PAGE_SIZE - n,
  196. "\tnumber_of_segments = %d\t",
  197. p->layer_info[i].number_of_segments);
  198. n += snprintf(&buf[n], PAGE_SIZE - n, "tmcc_errors = %d\n",
  199. p->layer_info[i].tmcc_errors);
  200. }
  201. debug_data->stats_count = n;
  202. spin_unlock(&debug_data->lock);
  203. wake_up(&debug_data->stats_queue);
  204. }
  205. static void smsdvb_print_isdb_stats_ex(struct smsdvb_debugfs *debug_data,
  206. struct sms_isdbt_stats_ex *p)
  207. {
  208. int i, n = 0;
  209. char *buf;
  210. spin_lock(&debug_data->lock);
  211. if (debug_data->stats_count) {
  212. spin_unlock(&debug_data->lock);
  213. return;
  214. }
  215. buf = debug_data->stats_data;
  216. n += snprintf(&buf[n], PAGE_SIZE - n,
  217. "statistics_type = %d\t", p->statistics_type);
  218. n += snprintf(&buf[n], PAGE_SIZE - n,
  219. "full_size = %d\n", p->full_size);
  220. n += snprintf(&buf[n], PAGE_SIZE - n,
  221. "is_rf_locked = %d\t\t", p->is_rf_locked);
  222. n += snprintf(&buf[n], PAGE_SIZE - n,
  223. "is_demod_locked = %d\t", p->is_demod_locked);
  224. n += snprintf(&buf[n], PAGE_SIZE - n,
  225. "is_external_lna_on = %d\n", p->is_external_lna_on);
  226. n += snprintf(&buf[n], PAGE_SIZE - n,
  227. "SNR = %d dB\t\t", p->SNR);
  228. n += snprintf(&buf[n], PAGE_SIZE - n,
  229. "RSSI = %d dBm\t\t", p->RSSI);
  230. n += snprintf(&buf[n], PAGE_SIZE - n,
  231. "in_band_pwr = %d dBm\n", p->in_band_pwr);
  232. n += snprintf(&buf[n], PAGE_SIZE - n,
  233. "carrier_offset = %d\t", p->carrier_offset);
  234. n += snprintf(&buf[n], PAGE_SIZE - n,
  235. "bandwidth = %d\t\t", p->bandwidth);
  236. n += snprintf(&buf[n], PAGE_SIZE - n,
  237. "frequency = %d Hz\n", p->frequency);
  238. n += snprintf(&buf[n], PAGE_SIZE - n,
  239. "transmission_mode = %d\t", p->transmission_mode);
  240. n += snprintf(&buf[n], PAGE_SIZE - n,
  241. "modem_state = %d\t\t", p->modem_state);
  242. n += snprintf(&buf[n], PAGE_SIZE - n,
  243. "guard_interval = %d\n", p->guard_interval);
  244. n += snprintf(&buf[n], PAGE_SIZE - n,
  245. "system_type = %d\t\t", p->system_type);
  246. n += snprintf(&buf[n], PAGE_SIZE - n,
  247. "partial_reception = %d\t", p->partial_reception);
  248. n += snprintf(&buf[n], PAGE_SIZE - n,
  249. "num_of_layers = %d\n", p->num_of_layers);
  250. n += snprintf(&buf[n], PAGE_SIZE - n, "segment_number = %d\t",
  251. p->segment_number);
  252. n += snprintf(&buf[n], PAGE_SIZE - n, "tune_bw = %d\n",
  253. p->tune_bw);
  254. for (i = 0; i < 3; i++) {
  255. if (p->layer_info[i].number_of_segments < 1 ||
  256. p->layer_info[i].number_of_segments > 13)
  257. continue;
  258. n += snprintf(&buf[n], PAGE_SIZE - n, "\nLayer %d\n", i);
  259. n += snprintf(&buf[n], PAGE_SIZE - n, "\tcode_rate = %d\t",
  260. p->layer_info[i].code_rate);
  261. n += snprintf(&buf[n], PAGE_SIZE - n, "constellation = %d\n",
  262. p->layer_info[i].constellation);
  263. n += snprintf(&buf[n], PAGE_SIZE - n, "\tber = %-5d\t",
  264. p->layer_info[i].ber);
  265. n += snprintf(&buf[n], PAGE_SIZE - n, "\tber_error_count = %-5d\t",
  266. p->layer_info[i].ber_error_count);
  267. n += snprintf(&buf[n], PAGE_SIZE - n, "ber_bit_count = %-5d\n",
  268. p->layer_info[i].ber_bit_count);
  269. n += snprintf(&buf[n], PAGE_SIZE - n, "\tpre_ber = %-5d\t",
  270. p->layer_info[i].pre_ber);
  271. n += snprintf(&buf[n], PAGE_SIZE - n, "\tts_per = %-5d\n",
  272. p->layer_info[i].ts_per);
  273. n += snprintf(&buf[n], PAGE_SIZE - n, "\terror_ts_packets = %-5d\t",
  274. p->layer_info[i].error_ts_packets);
  275. n += snprintf(&buf[n], PAGE_SIZE - n, "total_ts_packets = %-5d\t",
  276. p->layer_info[i].total_ts_packets);
  277. n += snprintf(&buf[n], PAGE_SIZE - n, "ti_ldepth_i = %d\n",
  278. p->layer_info[i].ti_ldepth_i);
  279. n += snprintf(&buf[n], PAGE_SIZE - n,
  280. "\tnumber_of_segments = %d\t",
  281. p->layer_info[i].number_of_segments);
  282. n += snprintf(&buf[n], PAGE_SIZE - n, "tmcc_errors = %d\n",
  283. p->layer_info[i].tmcc_errors);
  284. }
  285. debug_data->stats_count = n;
  286. spin_unlock(&debug_data->lock);
  287. wake_up(&debug_data->stats_queue);
  288. }
  289. static int smsdvb_stats_open(struct inode *inode, struct file *file)
  290. {
  291. struct smsdvb_client_t *client = inode->i_private;
  292. struct smsdvb_debugfs *debug_data = client->debug_data;
  293. kref_get(&debug_data->refcount);
  294. spin_lock(&debug_data->lock);
  295. debug_data->stats_count = 0;
  296. debug_data->stats_was_read = false;
  297. spin_unlock(&debug_data->lock);
  298. file->private_data = debug_data;
  299. return 0;
  300. }
  301. static void smsdvb_debugfs_data_release(struct kref *ref)
  302. {
  303. struct smsdvb_debugfs *debug_data;
  304. debug_data = container_of(ref, struct smsdvb_debugfs, refcount);
  305. kfree(debug_data);
  306. }
  307. static int smsdvb_stats_wait_read(struct smsdvb_debugfs *debug_data)
  308. {
  309. int rc = 1;
  310. spin_lock(&debug_data->lock);
  311. if (debug_data->stats_was_read)
  312. goto exit;
  313. rc = debug_data->stats_count;
  314. exit:
  315. spin_unlock(&debug_data->lock);
  316. return rc;
  317. }
  318. static __poll_t smsdvb_stats_poll(struct file *file, poll_table *wait)
  319. {
  320. struct smsdvb_debugfs *debug_data = file->private_data;
  321. int rc;
  322. kref_get(&debug_data->refcount);
  323. poll_wait(file, &debug_data->stats_queue, wait);
  324. rc = smsdvb_stats_wait_read(debug_data);
  325. kref_put(&debug_data->refcount, smsdvb_debugfs_data_release);
  326. return rc > 0 ? EPOLLIN | EPOLLRDNORM : 0;
  327. }
  328. static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
  329. size_t nbytes, loff_t *ppos)
  330. {
  331. int rc = 0, len;
  332. struct smsdvb_debugfs *debug_data = file->private_data;
  333. kref_get(&debug_data->refcount);
  334. if (file->f_flags & O_NONBLOCK) {
  335. rc = smsdvb_stats_wait_read(debug_data);
  336. if (!rc) {
  337. rc = -EWOULDBLOCK;
  338. goto ret;
  339. }
  340. } else {
  341. rc = wait_event_interruptible(debug_data->stats_queue,
  342. smsdvb_stats_wait_read(debug_data));
  343. if (rc < 0)
  344. goto ret;
  345. }
  346. if (debug_data->stats_was_read) {
  347. rc = 0; /* EOF */
  348. goto ret;
  349. }
  350. len = debug_data->stats_count - *ppos;
  351. if (len >= 0)
  352. rc = simple_read_from_buffer(user_buf, nbytes, ppos,
  353. debug_data->stats_data, len);
  354. else
  355. rc = 0;
  356. if (*ppos >= debug_data->stats_count) {
  357. spin_lock(&debug_data->lock);
  358. debug_data->stats_was_read = true;
  359. spin_unlock(&debug_data->lock);
  360. }
  361. ret:
  362. kref_put(&debug_data->refcount, smsdvb_debugfs_data_release);
  363. return rc;
  364. }
  365. static int smsdvb_stats_release(struct inode *inode, struct file *file)
  366. {
  367. struct smsdvb_debugfs *debug_data = file->private_data;
  368. spin_lock(&debug_data->lock);
  369. debug_data->stats_was_read = true; /* return EOF to read() */
  370. spin_unlock(&debug_data->lock);
  371. wake_up_interruptible_sync(&debug_data->stats_queue);
  372. kref_put(&debug_data->refcount, smsdvb_debugfs_data_release);
  373. file->private_data = NULL;
  374. return 0;
  375. }
  376. static const struct file_operations debugfs_stats_ops = {
  377. .open = smsdvb_stats_open,
  378. .poll = smsdvb_stats_poll,
  379. .read = smsdvb_stats_read,
  380. .release = smsdvb_stats_release,
  381. .llseek = generic_file_llseek,
  382. };
  383. /*
  384. * Functions used by smsdvb, in order to create the interfaces
  385. */
  386. int smsdvb_debugfs_create(struct smsdvb_client_t *client)
  387. {
  388. struct smscore_device_t *coredev = client->coredev;
  389. struct dentry *d;
  390. struct smsdvb_debugfs *debug_data;
  391. if (!smsdvb_debugfs_usb_root || !coredev->is_usb_device)
  392. return -ENODEV;
  393. client->debugfs = debugfs_create_dir(coredev->devpath,
  394. smsdvb_debugfs_usb_root);
  395. if (IS_ERR_OR_NULL(client->debugfs)) {
  396. pr_info("Unable to create debugfs %s directory.\n",
  397. coredev->devpath);
  398. return -ENODEV;
  399. }
  400. d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
  401. client, &debugfs_stats_ops);
  402. if (!d) {
  403. debugfs_remove(client->debugfs);
  404. return -ENOMEM;
  405. }
  406. debug_data = kzalloc(sizeof(*client->debug_data), GFP_KERNEL);
  407. if (!debug_data)
  408. return -ENOMEM;
  409. client->debug_data = debug_data;
  410. client->prt_dvb_stats = smsdvb_print_dvb_stats;
  411. client->prt_isdb_stats = smsdvb_print_isdb_stats;
  412. client->prt_isdb_stats_ex = smsdvb_print_isdb_stats_ex;
  413. init_waitqueue_head(&debug_data->stats_queue);
  414. spin_lock_init(&debug_data->lock);
  415. kref_init(&debug_data->refcount);
  416. return 0;
  417. }
  418. void smsdvb_debugfs_release(struct smsdvb_client_t *client)
  419. {
  420. if (!client->debugfs)
  421. return;
  422. client->prt_dvb_stats = NULL;
  423. client->prt_isdb_stats = NULL;
  424. client->prt_isdb_stats_ex = NULL;
  425. debugfs_remove_recursive(client->debugfs);
  426. kref_put(&client->debug_data->refcount, smsdvb_debugfs_data_release);
  427. client->debug_data = NULL;
  428. client->debugfs = NULL;
  429. }
  430. void smsdvb_debugfs_register(void)
  431. {
  432. struct dentry *d;
  433. /*
  434. * FIXME: This was written to debug Siano USB devices. So, it creates
  435. * the debugfs node under <debugfs>/usb.
  436. * A similar logic would be needed for Siano sdio devices, but, in that
  437. * case, usb_debug_root is not a good choice.
  438. *
  439. * Perhaps the right fix here would be to create another sysfs root
  440. * node for sdio-based boards, but this may need some logic at sdio
  441. * subsystem.
  442. */
  443. d = debugfs_create_dir("smsdvb", usb_debug_root);
  444. if (IS_ERR_OR_NULL(d)) {
  445. pr_err("Couldn't create sysfs node for smsdvb\n");
  446. return;
  447. }
  448. smsdvb_debugfs_usb_root = d;
  449. }
  450. void smsdvb_debugfs_unregister(void)
  451. {
  452. if (!smsdvb_debugfs_usb_root)
  453. return;
  454. debugfs_remove_recursive(smsdvb_debugfs_usb_root);
  455. smsdvb_debugfs_usb_root = NULL;
  456. }