1 /*
2 * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 /**
19 * DOC: wlan_hdd_sysfs_dl_modes.c
20 *
21 * implementation for creating sysfs file dl_modes
22 */
23
24 #include <wlan_hdd_includes.h>
25 #include <wlan_hdd_main.h>
26 #include "osif_vdev_sync.h"
27 #include <wlan_hdd_sysfs.h>
28 #include <wlan_hdd_sysfs_dl_modes.h>
29 #include "wmi_unified_param.h"
30 #include "wma_api.h"
31
hdd_sysfs_set_dbg(struct hdd_adapter * adapter,int id,const char * id_string,int value)32 static int hdd_sysfs_set_dbg(struct hdd_adapter *adapter,
33 int id,
34 const char *id_string,
35 int value)
36 {
37 int errno;
38
39 hdd_debug("%s %d", id_string, value);
40 errno = wma_cli_set_command(adapter->deflink->vdev_id,
41 id, value, DBG_CMD);
42 if (errno)
43 hdd_err("Failed to set firmware, errno %d", errno);
44
45 return errno;
46 }
47
48 #define hdd_sysfs_set_dbg(adapter, id, value) \
49 hdd_sysfs_set_dbg(adapter, id, #id, value)
50
51 static ssize_t
__hdd_sysfs_dl_loglevel_store(struct net_device * net_dev,char const * buf,size_t count)52 __hdd_sysfs_dl_loglevel_store(struct net_device *net_dev,
53 char const *buf, size_t count)
54 {
55 struct hdd_adapter *adapter = netdev_priv(net_dev);
56 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
57 struct hdd_context *hdd_ctx;
58 char *sptr, *token;
59 uint32_t value;
60 int ret;
61
62 if (hdd_validate_adapter(adapter))
63 return -EINVAL;
64
65 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
66 ret = wlan_hdd_validate_context(hdd_ctx);
67 if (ret != 0)
68 return ret;
69
70 if (!wlan_hdd_validate_modules_state(hdd_ctx))
71 return -EINVAL;
72
73 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
74 buf, count);
75
76 if (ret) {
77 hdd_err_rl("invalid input");
78 return ret;
79 }
80
81 sptr = buf_local;
82 hdd_debug("dl_loglevel: count %zu buf_local:(%s) net_devname %s",
83 count, buf_local, net_dev->name);
84
85 /* Get value */
86 token = strsep(&sptr, " ");
87 if (!token)
88 return -EINVAL;
89 if (kstrtou32(token, 0, &value))
90 return -EINVAL;
91
92 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_LOG_LEVEL, value);
93
94 if (ret) {
95 hdd_err_rl("failed dl_loglevel: %d", ret);
96 return ret;
97 }
98
99 return count;
100 }
101
102 static ssize_t
hdd_sysfs_dl_loglevel_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)103 hdd_sysfs_dl_loglevel_store(struct device *dev,
104 struct device_attribute *attr,
105 char const *buf, size_t count)
106 {
107 struct net_device *net_dev = container_of(dev, struct net_device, dev);
108 struct osif_vdev_sync *vdev_sync;
109 ssize_t errno_size;
110
111 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
112 if (errno_size)
113 return errno_size;
114
115 errno_size = __hdd_sysfs_dl_loglevel_store(net_dev, buf, count);
116
117 osif_vdev_sync_op_stop(vdev_sync);
118
119 return errno_size;
120 }
121
122 static ssize_t
__hdd_sysfs_dl_mod_loglevel_store(struct net_device * net_dev,char const * buf,size_t count)123 __hdd_sysfs_dl_mod_loglevel_store(struct net_device *net_dev,
124 char const *buf, size_t count)
125 {
126 struct hdd_adapter *adapter = netdev_priv(net_dev);
127 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
128 struct hdd_context *hdd_ctx;
129 char *sptr, *token;
130 uint32_t value;
131 int ret;
132
133 if (hdd_validate_adapter(adapter))
134 return -EINVAL;
135
136 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
137 ret = wlan_hdd_validate_context(hdd_ctx);
138 if (ret != 0)
139 return ret;
140
141 if (!wlan_hdd_validate_modules_state(hdd_ctx))
142 return -EINVAL;
143
144 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
145 buf, count);
146
147 if (ret) {
148 hdd_err_rl("invalid input");
149 return ret;
150 }
151
152 sptr = buf_local;
153 hdd_debug("dl_mod_loglevel: count %zu buf_local:(%s) net_devname %s",
154 count, buf_local, net_dev->name);
155
156 /* Get value */
157 token = strsep(&sptr, " ");
158 if (!token)
159 return -EINVAL;
160 if (kstrtou32(token, 0, &value))
161 return -EINVAL;
162
163 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_MOD_LOG_LEVEL, value);
164
165 if (ret) {
166 hdd_err_rl("failed dl_mod_loglevel: %d", ret);
167 return ret;
168 }
169
170 return count;
171 }
172
173 static ssize_t
hdd_sysfs_dl_mod_loglevel_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)174 hdd_sysfs_dl_mod_loglevel_store(struct device *dev,
175 struct device_attribute *attr,
176 char const *buf, size_t count)
177 {
178 struct net_device *net_dev = container_of(dev, struct net_device, dev);
179 struct osif_vdev_sync *vdev_sync;
180 ssize_t errno_size;
181
182 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
183 if (errno_size)
184 return errno_size;
185
186 errno_size = __hdd_sysfs_dl_mod_loglevel_store(net_dev, buf, count);
187
188 osif_vdev_sync_op_stop(vdev_sync);
189
190 return errno_size;
191 }
192
193 static ssize_t
__hdd_sysfs_dl_modoff_store(struct net_device * net_dev,char const * buf,size_t count)194 __hdd_sysfs_dl_modoff_store(struct net_device *net_dev,
195 char const *buf, size_t count)
196 {
197 struct hdd_adapter *adapter = netdev_priv(net_dev);
198 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
199 struct hdd_context *hdd_ctx;
200 char *sptr, *token;
201 uint32_t value;
202 int ret;
203
204 if (hdd_validate_adapter(adapter))
205 return -EINVAL;
206
207 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
208 ret = wlan_hdd_validate_context(hdd_ctx);
209 if (ret != 0)
210 return ret;
211
212 if (!wlan_hdd_validate_modules_state(hdd_ctx))
213 return -EINVAL;
214
215 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
216 buf, count);
217
218 if (ret) {
219 hdd_err_rl("invalid input");
220 return ret;
221 }
222
223 sptr = buf_local;
224 hdd_debug("dl_modoff: count %zu buf_local:(%s) net_devname %s",
225 count, buf_local, net_dev->name);
226
227 /* Get value */
228 token = strsep(&sptr, " ");
229 if (!token)
230 return -EINVAL;
231 if (kstrtou32(token, 0, &value))
232 return -EINVAL;
233
234 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_MODULE_DISABLE, value);
235
236 if (ret) {
237 hdd_err_rl("failed dl_modoff: %d", ret);
238 return ret;
239 }
240
241 return count;
242 }
243
244 static ssize_t
hdd_sysfs_dl_modoff_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)245 hdd_sysfs_dl_modoff_store(struct device *dev,
246 struct device_attribute *attr,
247 char const *buf, size_t count)
248 {
249 struct net_device *net_dev = container_of(dev, struct net_device, dev);
250 struct osif_vdev_sync *vdev_sync;
251 ssize_t errno_size;
252
253 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
254 if (errno_size)
255 return errno_size;
256
257 errno_size = __hdd_sysfs_dl_modoff_store(net_dev, buf, count);
258
259 osif_vdev_sync_op_stop(vdev_sync);
260
261 return errno_size;
262 }
263
264 static ssize_t
__hdd_sysfs_dl_modon_store(struct net_device * net_dev,char const * buf,size_t count)265 __hdd_sysfs_dl_modon_store(struct net_device *net_dev,
266 char const *buf, size_t count)
267 {
268 struct hdd_adapter *adapter = netdev_priv(net_dev);
269 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
270 struct hdd_context *hdd_ctx;
271 char *sptr, *token;
272 uint32_t value;
273 int ret;
274
275 if (hdd_validate_adapter(adapter))
276 return -EINVAL;
277
278 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
279 ret = wlan_hdd_validate_context(hdd_ctx);
280 if (ret != 0)
281 return ret;
282
283 if (!wlan_hdd_validate_modules_state(hdd_ctx))
284 return -EINVAL;
285
286 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
287 buf, count);
288
289 if (ret) {
290 hdd_err_rl("invalid input");
291 return ret;
292 }
293
294 sptr = buf_local;
295 hdd_debug("dl_modon: count %zu buf_local:(%s) net_devname %s",
296 count, buf_local, net_dev->name);
297
298 /* Get value */
299 token = strsep(&sptr, " ");
300 if (!token)
301 return -EINVAL;
302 if (kstrtou32(token, 0, &value))
303 return -EINVAL;
304
305 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_MODULE_ENABLE, value);
306
307 if (ret) {
308 hdd_err_rl("failed dl_modon: %d", ret);
309 return ret;
310 }
311
312 return count;
313 }
314
315 static ssize_t
hdd_sysfs_dl_modon_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)316 hdd_sysfs_dl_modon_store(struct device *dev,
317 struct device_attribute *attr,
318 char const *buf, size_t count)
319 {
320 struct net_device *net_dev = container_of(dev, struct net_device, dev);
321 struct osif_vdev_sync *vdev_sync;
322 ssize_t errno_size;
323
324 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
325 if (errno_size)
326 return errno_size;
327
328 errno_size = __hdd_sysfs_dl_modon_store(net_dev, buf, count);
329
330 osif_vdev_sync_op_stop(vdev_sync);
331
332 return errno_size;
333 }
334
335 static ssize_t
__hdd_sysfs_dl_report_store(struct net_device * net_dev,char const * buf,size_t count)336 __hdd_sysfs_dl_report_store(struct net_device *net_dev,
337 char const *buf, size_t count)
338 {
339 struct hdd_adapter *adapter = netdev_priv(net_dev);
340 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
341 struct hdd_context *hdd_ctx;
342 char *sptr, *token;
343 uint32_t value;
344 int ret;
345
346 if (hdd_validate_adapter(adapter))
347 return -EINVAL;
348
349 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
350 ret = wlan_hdd_validate_context(hdd_ctx);
351 if (ret != 0)
352 return ret;
353
354 if (!wlan_hdd_validate_modules_state(hdd_ctx))
355 return -EINVAL;
356
357 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
358 buf, count);
359
360 if (ret) {
361 hdd_err_rl("invalid input");
362 return ret;
363 }
364
365 sptr = buf_local;
366 hdd_debug("dl_report: count %zu buf_local:(%s) net_devname %s",
367 count, buf_local, net_dev->name);
368
369 /* Get value */
370 token = strsep(&sptr, " ");
371 if (!token)
372 return -EINVAL;
373 if (kstrtou32(token, 0, &value))
374 return -EINVAL;
375
376 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_REPORT_ENABLE, value);
377
378 if (ret) {
379 hdd_err_rl("failed dl_report: %d", ret);
380 return ret;
381 }
382
383 return count;
384 }
385
386 static ssize_t
hdd_sysfs_dl_report_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)387 hdd_sysfs_dl_report_store(struct device *dev,
388 struct device_attribute *attr,
389 char const *buf, size_t count)
390 {
391 struct net_device *net_dev = container_of(dev, struct net_device, dev);
392 struct osif_vdev_sync *vdev_sync;
393 ssize_t errno_size;
394
395 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
396 if (errno_size)
397 return errno_size;
398
399 errno_size = __hdd_sysfs_dl_report_store(net_dev, buf, count);
400
401 osif_vdev_sync_op_stop(vdev_sync);
402
403 return errno_size;
404 }
405
406 static ssize_t
__hdd_sysfs_dl_type_store(struct net_device * net_dev,char const * buf,size_t count)407 __hdd_sysfs_dl_type_store(struct net_device *net_dev,
408 char const *buf, size_t count)
409 {
410 struct hdd_adapter *adapter = netdev_priv(net_dev);
411 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
412 struct hdd_context *hdd_ctx;
413 char *sptr, *token;
414 uint32_t value;
415 int ret;
416
417 if (hdd_validate_adapter(adapter))
418 return -EINVAL;
419
420 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
421 ret = wlan_hdd_validate_context(hdd_ctx);
422 if (ret != 0)
423 return ret;
424
425 if (!wlan_hdd_validate_modules_state(hdd_ctx))
426 return -EINVAL;
427
428 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
429 buf, count);
430
431 if (ret) {
432 hdd_err_rl("invalid input");
433 return ret;
434 }
435
436 sptr = buf_local;
437 hdd_debug("dl_type: count %zu buf_local:(%s) net_devname %s",
438 count, buf_local, net_dev->name);
439
440 /* Get value */
441 token = strsep(&sptr, " ");
442 if (!token)
443 return -EINVAL;
444 if (kstrtou32(token, 0, &value))
445 return -EINVAL;
446
447 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_TYPE, value);
448
449 if (ret) {
450 hdd_err_rl("failed dl_type: %d", ret);
451 return ret;
452 }
453
454 return count;
455 }
456
457 static ssize_t
hdd_sysfs_dl_type_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)458 hdd_sysfs_dl_type_store(struct device *dev,
459 struct device_attribute *attr,
460 char const *buf, size_t count)
461 {
462 struct net_device *net_dev = container_of(dev, struct net_device, dev);
463 struct osif_vdev_sync *vdev_sync;
464 ssize_t errno_size;
465
466 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
467 if (errno_size)
468 return errno_size;
469
470 errno_size = __hdd_sysfs_dl_type_store(net_dev, buf, count);
471
472 osif_vdev_sync_op_stop(vdev_sync);
473
474 return errno_size;
475 }
476
477 static ssize_t
__hdd_sysfs_dl_vapoff_store(struct net_device * net_dev,char const * buf,size_t count)478 __hdd_sysfs_dl_vapoff_store(struct net_device *net_dev,
479 char const *buf, size_t count)
480 {
481 struct hdd_adapter *adapter = netdev_priv(net_dev);
482 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
483 struct hdd_context *hdd_ctx;
484 char *sptr, *token;
485 uint32_t value;
486 int ret;
487
488 if (hdd_validate_adapter(adapter))
489 return -EINVAL;
490
491 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
492 ret = wlan_hdd_validate_context(hdd_ctx);
493 if (ret != 0)
494 return ret;
495
496 if (!wlan_hdd_validate_modules_state(hdd_ctx))
497 return -EINVAL;
498
499 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
500 buf, count);
501
502 if (ret) {
503 hdd_err_rl("invalid input");
504 return ret;
505 }
506
507 sptr = buf_local;
508 hdd_debug("dl_vapoff: count %zu buf_local:(%s) net_devname %s",
509 count, buf_local, net_dev->name);
510
511 /* Get value */
512 token = strsep(&sptr, " ");
513 if (!token)
514 return -EINVAL;
515 if (kstrtou32(token, 0, &value))
516 return -EINVAL;
517
518 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_VAP_DISABLE, value);
519
520 if (ret) {
521 hdd_err_rl("failed dl_vapoff: %d", ret);
522 return ret;
523 }
524
525 return count;
526 }
527
528 static ssize_t
hdd_sysfs_dl_vapoff_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)529 hdd_sysfs_dl_vapoff_store(struct device *dev,
530 struct device_attribute *attr,
531 char const *buf, size_t count)
532 {
533 struct net_device *net_dev = container_of(dev, struct net_device, dev);
534 struct osif_vdev_sync *vdev_sync;
535 ssize_t errno_size;
536
537 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
538 if (errno_size)
539 return errno_size;
540
541 errno_size = __hdd_sysfs_dl_vapoff_store(net_dev, buf, count);
542
543 osif_vdev_sync_op_stop(vdev_sync);
544
545 return errno_size;
546 }
547
548 static ssize_t
__hdd_sysfs_dl_vapon_store(struct net_device * net_dev,char const * buf,size_t count)549 __hdd_sysfs_dl_vapon_store(struct net_device *net_dev,
550 char const *buf, size_t count)
551 {
552 struct hdd_adapter *adapter = netdev_priv(net_dev);
553 char buf_local[MAX_SYSFS_USER_COMMAND_SIZE_LENGTH + 1];
554 struct hdd_context *hdd_ctx;
555 char *sptr, *token;
556 uint32_t value;
557 int ret;
558
559 if (hdd_validate_adapter(adapter))
560 return -EINVAL;
561
562 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
563 ret = wlan_hdd_validate_context(hdd_ctx);
564 if (ret != 0)
565 return ret;
566
567 if (!wlan_hdd_validate_modules_state(hdd_ctx))
568 return -EINVAL;
569
570 ret = hdd_sysfs_validate_and_copy_buf(buf_local, sizeof(buf_local),
571 buf, count);
572
573 if (ret) {
574 hdd_err_rl("invalid input");
575 return ret;
576 }
577
578 sptr = buf_local;
579 hdd_debug("dl_vapon: count %zu buf_local:(%s) net_devname %s",
580 count, buf_local, net_dev->name);
581
582 /* Get value */
583 token = strsep(&sptr, " ");
584 if (!token)
585 return -EINVAL;
586 if (kstrtou32(token, 0, &value))
587 return -EINVAL;
588
589 ret = hdd_sysfs_set_dbg(adapter, WMI_DBGLOG_VAP_ENABLE, value);
590
591 if (ret) {
592 hdd_err_rl("failed dl_vapon: %d", ret);
593 return ret;
594 }
595
596 return count;
597 }
598
599 static ssize_t
hdd_sysfs_dl_vapon_store(struct device * dev,struct device_attribute * attr,char const * buf,size_t count)600 hdd_sysfs_dl_vapon_store(struct device *dev,
601 struct device_attribute *attr,
602 char const *buf, size_t count)
603 {
604 struct net_device *net_dev = container_of(dev, struct net_device, dev);
605 struct osif_vdev_sync *vdev_sync;
606 ssize_t errno_size;
607
608 errno_size = osif_vdev_sync_op_start(net_dev, &vdev_sync);
609 if (errno_size)
610 return errno_size;
611
612 errno_size = __hdd_sysfs_dl_vapon_store(net_dev, buf, count);
613
614 osif_vdev_sync_op_stop(vdev_sync);
615
616 return errno_size;
617 }
618
619 static DEVICE_ATTR(dl_loglevel, 0220,
620 NULL, hdd_sysfs_dl_loglevel_store);
621
622 static DEVICE_ATTR(dl_mod_loglevel, 0220,
623 NULL, hdd_sysfs_dl_mod_loglevel_store);
624
625 static DEVICE_ATTR(dl_modoff, 0220,
626 NULL, hdd_sysfs_dl_modoff_store);
627
628 static DEVICE_ATTR(dl_modon, 0220,
629 NULL, hdd_sysfs_dl_modon_store);
630
631 static DEVICE_ATTR(dl_report, 0220,
632 NULL, hdd_sysfs_dl_report_store);
633
634 static DEVICE_ATTR(dl_type, 0220,
635 NULL, hdd_sysfs_dl_type_store);
636
637 static DEVICE_ATTR(dl_vapoff, 0220,
638 NULL, hdd_sysfs_dl_vapoff_store);
639
640 static DEVICE_ATTR(dl_vapon, 0220,
641 NULL, hdd_sysfs_dl_vapon_store);
642
hdd_sysfs_dl_loglevel_create(struct hdd_adapter * adapter)643 static int hdd_sysfs_dl_loglevel_create(struct hdd_adapter *adapter)
644 {
645 int error;
646
647 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_loglevel);
648 if (error)
649 hdd_err("could not create dl_loglevel sysfs file");
650
651 return error;
652 }
653
hdd_sysfs_dl_loglevel_destroy(struct hdd_adapter * adapter)654 static void hdd_sysfs_dl_loglevel_destroy(struct hdd_adapter *adapter)
655 {
656 device_remove_file(&adapter->dev->dev, &dev_attr_dl_loglevel);
657 }
658
hdd_sysfs_dl_mod_loglevel_create(struct hdd_adapter * adapter)659 static int hdd_sysfs_dl_mod_loglevel_create(struct hdd_adapter *adapter)
660 {
661 int error;
662
663 error = device_create_file(&adapter->dev->dev,
664 &dev_attr_dl_mod_loglevel);
665 if (error)
666 hdd_err("could not create dl_mod_loglevel sysfs file");
667
668 return error;
669 }
670
hdd_sysfs_dl_mod_loglevel_destroy(struct hdd_adapter * adapter)671 static void hdd_sysfs_dl_mod_loglevel_destroy(struct hdd_adapter *adapter)
672 {
673 device_remove_file(&adapter->dev->dev, &dev_attr_dl_mod_loglevel);
674 }
675
hdd_sysfs_dl_modoff_create(struct hdd_adapter * adapter)676 static int hdd_sysfs_dl_modoff_create(struct hdd_adapter *adapter)
677 {
678 int error;
679
680 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_modoff);
681 if (error)
682 hdd_err("could not create dl_modoff sysfs file");
683
684 return error;
685 }
686
hdd_sysfs_dl_modoff_destroy(struct hdd_adapter * adapter)687 static void hdd_sysfs_dl_modoff_destroy(struct hdd_adapter *adapter)
688 {
689 device_remove_file(&adapter->dev->dev, &dev_attr_dl_modoff);
690 }
691
hdd_sysfs_dl_modon_create(struct hdd_adapter * adapter)692 static int hdd_sysfs_dl_modon_create(struct hdd_adapter *adapter)
693 {
694 int error;
695
696 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_modon);
697 if (error)
698 hdd_err("could not create dl_modon sysfs file");
699
700 return error;
701 }
702
hdd_sysfs_dl_modon_destroy(struct hdd_adapter * adapter)703 static void hdd_sysfs_dl_modon_destroy(struct hdd_adapter *adapter)
704 {
705 device_remove_file(&adapter->dev->dev, &dev_attr_dl_modon);
706 }
707
hdd_sysfs_dl_report_create(struct hdd_adapter * adapter)708 static int hdd_sysfs_dl_report_create(struct hdd_adapter *adapter)
709 {
710 int error;
711
712 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_report);
713 if (error)
714 hdd_err("could not create dl_report sysfs file");
715
716 return error;
717 }
718
hdd_sysfs_dl_report_destroy(struct hdd_adapter * adapter)719 static void hdd_sysfs_dl_report_destroy(struct hdd_adapter *adapter)
720 {
721 device_remove_file(&adapter->dev->dev, &dev_attr_dl_report);
722 }
723
hdd_sysfs_dl_type_create(struct hdd_adapter * adapter)724 static int hdd_sysfs_dl_type_create(struct hdd_adapter *adapter)
725 {
726 int error;
727
728 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_type);
729 if (error)
730 hdd_err("could not create dl_type sysfs file");
731
732 return error;
733 }
734
hdd_sysfs_dl_type_destroy(struct hdd_adapter * adapter)735 static void hdd_sysfs_dl_type_destroy(struct hdd_adapter *adapter)
736 {
737 device_remove_file(&adapter->dev->dev, &dev_attr_dl_type);
738 }
739
hdd_sysfs_dl_vapoff_create(struct hdd_adapter * adapter)740 static int hdd_sysfs_dl_vapoff_create(struct hdd_adapter *adapter)
741 {
742 int error;
743
744 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_vapoff);
745 if (error)
746 hdd_err("could not create dl_vapoff sysfs file");
747
748 return error;
749 }
750
hdd_sysfs_dl_vapoff_destroy(struct hdd_adapter * adapter)751 static void hdd_sysfs_dl_vapoff_destroy(struct hdd_adapter *adapter)
752 {
753 device_remove_file(&adapter->dev->dev, &dev_attr_dl_vapoff);
754 }
755
hdd_sysfs_dl_vapon_create(struct hdd_adapter * adapter)756 static int hdd_sysfs_dl_vapon_create(struct hdd_adapter *adapter)
757 {
758 int error;
759
760 error = device_create_file(&adapter->dev->dev, &dev_attr_dl_vapon);
761 if (error)
762 hdd_err("could not create dl_vapon sysfs file");
763
764 return error;
765 }
766
hdd_sysfs_dl_vapon_destroy(struct hdd_adapter * adapter)767 static void hdd_sysfs_dl_vapon_destroy(struct hdd_adapter *adapter)
768 {
769 device_remove_file(&adapter->dev->dev, &dev_attr_dl_vapon);
770 }
771
hdd_sysfs_dl_modes_create(struct hdd_adapter * adapter)772 void hdd_sysfs_dl_modes_create(struct hdd_adapter *adapter)
773 {
774 hdd_sysfs_dl_loglevel_create(adapter);
775 hdd_sysfs_dl_mod_loglevel_create(adapter);
776 hdd_sysfs_dl_modoff_create(adapter);
777 hdd_sysfs_dl_modon_create(adapter);
778 hdd_sysfs_dl_report_create(adapter);
779 hdd_sysfs_dl_type_create(adapter);
780 hdd_sysfs_dl_vapoff_create(adapter);
781 hdd_sysfs_dl_vapon_create(adapter);
782 }
783
hdd_sysfs_dl_modes_destroy(struct hdd_adapter * adapter)784 void hdd_sysfs_dl_modes_destroy(struct hdd_adapter *adapter)
785 {
786 hdd_sysfs_dl_vapon_destroy(adapter);
787 hdd_sysfs_dl_vapoff_destroy(adapter);
788 hdd_sysfs_dl_type_destroy(adapter);
789 hdd_sysfs_dl_report_destroy(adapter);
790 hdd_sysfs_dl_modon_destroy(adapter);
791 hdd_sysfs_dl_modoff_destroy(adapter);
792 hdd_sysfs_dl_mod_loglevel_destroy(adapter);
793 hdd_sysfs_dl_loglevel_destroy(adapter);
794 }
795