smsdvb-debugfs.c 17 KB

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