-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafhba_sysfs.c
642 lines (540 loc) · 16.9 KB
/
afhba_sysfs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/* ------------------------------------------------------------------------- */
/* acq400_drv.c D-TACQ ACQ400 FMC DRIVER
* afhba_sysfs.c
*
* Created on: 20 Jan 2015
* Author: pgm
*/
/* ------------------------------------------------------------------------- */
/* Copyright (C) 2015 Peter Milne, D-TACQ Solutions Ltd *
* <peter dot milne at D hyphen TACQ dot com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of Version 2 of the GNU General Public License *
* as published by the Free Software Foundation; *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* ------------------------------------------------------------------------- */
#include "acq-fiber-hba.h"
#include "afhba_stream_drv.h"
static char* getDataFifoStat(u32 stat, char buf[], int maxbuf)
{
int cursor = 0;
cursor += sprintf(buf+cursor, "%4d ",
(stat&DMA_DATA_FIFO_COUNT)>>DMA_DATA_FIFO_COUNT_SHL);
if ((stat & DMA_DATA_FIFO_EMPTY) != 0){
cursor += sprintf(buf+cursor, "EMPTY ");
}
if ((stat & DMA_DATA_FIFO_FULL) != 0){
cursor += sprintf(buf+cursor, "FULL ");
}
if ((stat & DMA_DATA_FIFO_UNDER) != 0){
cursor += sprintf(buf+cursor, "UNDER ");
}
if ((stat & DMA_DATA_FIFO_OVER) != 0){
cursor += sprintf(buf+cursor, "EMPTY ");
}
strcat(buf, "\n");
assert(cursor < maxbuf);
return buf;
}
#define DATA_FIFO_STAT(DIR, SHL) \
static ssize_t show_data_fifo_stat_##DIR( \
struct device * dev, \
struct device_attribute *attr, \
char * buf) \
{ \
char flags[80]; \
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
u32 stat = (DMA_DATA_FIFSTA_RD(adev) >> SHL)&0xffff; \
getDataFifoStat(stat, flags, 80); \
return sprintf(buf, "0x%04x %s\n", stat, flags); \
} \
\
static DEVICE_ATTR(data_fifo_stat_##DIR, (S_IRUSR|S_IRGRP), show_data_fifo_stat_##DIR, 0)
DATA_FIFO_STAT(pull, DMA_CTRL_PULL_SHL);
DATA_FIFO_STAT(push, DMA_CTRL_PUSH_SHL);
#define DESC_FIFO_STAT(DIR, SHL) \
static ssize_t show_desc_fifo_stat_##DIR( \
struct device * dev, \
struct device_attribute *attr, \
char * buf) \
{ \
char flags[80]; \
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
u32 stat = (DMA_DESC_FIFSTA_RD(adev) >> SHL)&0xffff; \
getDataFifoStat(stat, flags, 80); \
return sprintf(buf, "0x%04x %s\n", stat, flags); \
} \
\
static DEVICE_ATTR(desc_fifo_stat_##DIR, (S_IRUSR|S_IRGRP), show_desc_fifo_stat_##DIR, 0)
DESC_FIFO_STAT(pull, DMA_CTRL_PULL_SHL);
DESC_FIFO_STAT(push, DMA_CTRL_PUSH_SHL);
static char* getDmaCtrl(u32 stat, char buf[], int maxbuf)
{
int cursor = 0;
buf[0] = '\0';
if ((stat & DMA_CTRL_EN) != 0){
cursor += sprintf(buf+cursor, "ENABLE ");
}
if ((stat & DMA_CTRL_FIFO_RST) != 0){
cursor += sprintf(buf+cursor, "RESET ");
}
if ((stat & DMA_CTRL_LOW_LAT) != 0){
cursor += sprintf(buf+cursor, "LOWLAT ");
}
if ((stat & DMA_CTRL_RECYCLE) != 0){
cursor += sprintf(buf+cursor, "RECYCLE ");
}
strcat(buf, "\n");
assert(cursor < maxbuf);
return buf;
}
#define DMA_CTRL(DIR, SHL) \
static ssize_t show_dma_ctrl_##DIR( \
struct device * dev, \
struct device_attribute *attr, \
char * buf) \
{ \
char flags[80]; \
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
u32 stat = (DMA_CTRL_RD(adev) >> SHL)&0xffff; \
getDmaCtrl(stat, flags, 80); \
return sprintf(buf, "0x%04x %s\n", stat, flags); \
} \
\
static DEVICE_ATTR(dma_ctrl_##DIR, (S_IRUSR|S_IRGRP), show_dma_ctrl_##DIR, 0)
DMA_CTRL(pull, DMA_CTRL_PULL_SHL);
DMA_CTRL(push, DMA_CTRL_PUSH_SHL);
static char* getDesc(u32 descr, char buf[], int maxbuf)
{
int cursor = 0;
cursor += sprintf(buf+cursor, "pa=%08x ", descr&DMA_DESCR_ADDR);
if ((descr & DMA_DESCR_INTEN) != 0){
cursor += sprintf(buf+cursor, "INTEN ");
}
cursor += sprintf(buf+cursor, "lenb=%08x ", DMA_DESCR_LEN_BYTES(descr));
cursor += sprintf(buf+cursor, "id=%x\n", descr&DMA_DESCR_ID);
assert(cursor < maxbuf);
return buf;
}
#define DMA_LATEST(DIR, RD) \
static ssize_t show_dma_latest_##DIR( \
struct device * dev, \
struct device_attribute *attr, \
char * buf) \
{ \
char flags[80]; \
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
u32 descr = RD(adev); \
getDesc(descr, flags, 80); \
return sprintf(buf, "0x%08x %s\n", descr, flags); \
} \
\
static DEVICE_ATTR(dma_latest_##DIR##_desc, (S_IRUSR|S_IRGRP), show_dma_latest_##DIR, 0)
DMA_LATEST(pull, DMA_PULL_DESC_STA_RD);
DMA_LATEST(push, DMA_PUSH_DESC_STA_RD);
static ssize_t store_reset_buffers(
struct device * dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned mode;
if (sscanf(buf, "%u", &mode) > 0){
if (mode == 1){
afs_reset_buffers(afhba_lookupDeviceFromClass(dev));
}
return count;
}else{
return -EPERM;
}
}
static DEVICE_ATTR(reset_buffers, (S_IWUSR|S_IWGRP), 0, store_reset_buffers);
extern int buffer_len;
static ssize_t store_buffer_len(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
int ll_length;
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
if (sscanf(buf, "%d", &ll_length) == 1 && ll_length > 0){
sdev->buffer_len = min(ll_length, buffer_len);
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_buffer_len(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
sprintf(buf, "%d\n", sdev->buffer_len);
return strlen(buf);
}
static DEVICE_ATTR(buffer_len, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_buffer_len, store_buffer_len);
char* getFlags(u32 stat, char buf[], int maxbuf)
{
int cursor = 0;
cursor += sprintf(buf+cursor, "%c%s ",
(stat & AFHBA_AURORA_STAT_SFP_PRESENTn)? '-': '+',
"PRESENT");
if ((stat & AFHBA_AURORA_STAT_SFP_LOS) != 0){
cursor += sprintf(buf+cursor, "LOS ");
}
if ((stat & AFHBA_AURORA_STAT_SFP_TX_FAULT) != 0){
cursor += sprintf(buf+cursor, "TX_FAULT ");
}
if ((stat & AFHBA_AURORA_STAT_HARD_ERR) != 0){
cursor += sprintf(buf+cursor, "HARD_ERR ");
}
if ((stat & AFHBA_AURORA_STAT_SOFT_ERR) != 0){
cursor += sprintf(buf+cursor, "SOFT_ERR ");
}
if ((stat & AFHBA_AURORA_STAT_FRAME_ERR) != 0){
cursor += sprintf(buf+cursor, "FRAME_ERR ");
}
if ((stat & AFHBA_AURORA_STAT_CHANNEL_UP) != 0){
cursor += sprintf(buf+cursor, "+CHANNEL_UP ");
}
if ((stat & AFHBA_AURORA_STAT_LANE_UP) != 0){
cursor += sprintf(buf+cursor, "+LANE_UP ");
}
strcat(buf, "\n");
assert(cursor < maxbuf);
return buf;
}
#define AURORA(SFPN) \
static ssize_t store_aurora##SFPN( \
struct device * dev, \
struct device_attribute *attr, \
const char * buf, \
size_t count) \
{ \
u32 ctrl = simple_strtoul(buf, 0, 16); \
afhba_write_reg(afhba_lookupDeviceFromClass(dev), AURORA_CONTROL_REG##SFPN, ctrl); \
return count; \
} \
\
\
static ssize_t show_aurora##SFPN( \
struct device * dev, \
struct device_attribute *attr, \
char * buf) \
{ \
char flags[80]; \
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
u32 stat = afhba_read_reg(adev, AURORA_STATUS_REG##SFPN); \
if ((stat&AFHBA_AURORA_STAT_ERR) != 0){ \
u32 ctrl = afhba_read_reg(adev, AURORA_CONTROL_REG##SFPN); \
afhba_write_reg(adev, AURORA_CONTROL_REG##SFPN, ctrl|AFHBA_AURORA_CTRL_CLR); \
afhba_write_reg(adev, AURORA_CONTROL_REG##SFPN, ctrl); \
} \
return sprintf(buf, "0x%08x %s\n", stat, getFlags(stat, flags, 80)); \
} \
\
static DEVICE_ATTR(aurora##SFPN, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_aurora##SFPN, store_aurora##SFPN);
AURORA(A);
AURORA(B);
static ssize_t store_aurora(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
if (adev->peer){
return store_auroraB(dev, attr, buf, count);
}else{
return store_auroraA(dev, attr, buf, count);
}
}
static ssize_t show_aurora(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
if (adev->peer){
return show_auroraB(dev, attr, buf);
}else{
return show_auroraA(dev, attr, buf);
}
}
static DEVICE_ATTR(aurora, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_aurora, store_aurora);
static ssize_t show_aurora_ext(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
return sprintf(buf, "0x%08x\n", read_astatus2(adev));
}
static DEVICE_ATTR(aurora_ext, (S_IRUSR|S_IRGRP), show_aurora_ext, 0);
static ssize_t store_comms_init(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
int init;
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
struct AFHBA_STREAM_DEV *sdev = adev->stream_dev;
if (sscanf(buf, "%d", &init) == 1 && init==1){
sdev->comms_init_done = false;
afs_comms_init(adev);
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_comms_init(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
return sprintf(buf, "%d\n", sdev->comms_init_done);
}
static DEVICE_ATTR(comms_init, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_comms_init, store_comms_init);
static ssize_t show_inflight(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
struct JOB *job = &sdev->job;
return sprintf(buf, "%d\n", job->buffers_queued-job->buffers_received);
}
static DEVICE_ATTR(inflight, (S_IRUSR|S_IRGRP), show_inflight, 0);
static ssize_t show_shot(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
return sprintf(buf, "%d\n", sdev->shot);
}
static DEVICE_ATTR(shot, (S_IRUSR|S_IRGRP), show_shot, 0);
#define _ERRLAT(yymask) ((yymask) == 0x0ffff || (yymask) == 0)
#define ERRLAT(yy) (_ERRLAT((yy)&0x0ffff))
static ssize_t show_latstat(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
unsigned ls1 = afhba_read_reg(adev, HOST_PCIE_LATSTATS_1);
unsigned ls2 = afhba_read_reg(adev, HOST_PCIE_LATSTATS_2);
int maxtry = 1;
unsigned over5 = ls1 & 0x0ffff;
while (over5 && (ERRLAT(ls2>>16) || ERRLAT(ls2))){
yield();
ls2 = afhba_read_reg(adev, HOST_PCIE_LATSTATS_2);
if (++maxtry > 100){
dev_warn(dev, "show_latstat maxtry exceeded");
break;
}
}
return sprintf(buf, "%5d %5d %5d %5d\n",
ls1>>16, ls1&0x0ffff, ls2>>16, ls2&0x0ffff);
}
static DEVICE_ATTR(latstat, (S_IRUSR|S_IRGRP), show_latstat, 0);
static ssize_t show_fpga_rev(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
return sprintf(buf, "0x%08x\n", afhba_read_reg(adev, FPGA_REVISION_REG));
}
static DEVICE_ATTR(fpga_rev, (S_IRUSR|S_IRGRP), show_fpga_rev, 0);
static ssize_t store_dma_test(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
unsigned test;
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
if (sscanf(buf, "0x%x", &test) == 1 || sscanf(buf, "%d", &test) == 1){
DMA_TEST_WR(adev, test);
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_dma_test(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
sprintf(buf, "0x%08x\n", DMA_TEST_RD(adev));
return strlen(buf);
}
static DEVICE_ATTR(dma_test, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_dma_test, store_dma_test);
static ssize_t show_heartbeat(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
return sprintf(buf, "0x%08x\n", afhba_read_reg(adev, HOST_COUNTER_REG));
}
static DEVICE_ATTR(heartbeat, (S_IRUSR|S_IRGRP), show_heartbeat, 0);
static ssize_t store_push_dma_timeouts(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
int clear;
if (sscanf(buf, "%d", &clear) == 1 && clear == 1){
sdev->push_dma_timeouts = 0;
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_push_dma_timeouts(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
sprintf(buf, "%d\n", sdev->push_dma_timeouts);
return strlen(buf);
}
static DEVICE_ATTR(push_dma_timeouts, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_push_dma_timeouts, store_push_dma_timeouts);
static ssize_t store_pull_dma_timeouts(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
int clear;
if (sscanf(buf, "%d", &clear) == 1 && clear == 1){
sdev->pull_dma_timeouts = 0;
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_pull_dma_timeouts(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_STREAM_DEV *sdev = afhba_lookupDeviceFromClass(dev)->stream_dev;
sprintf(buf, "%d\n", sdev->pull_dma_timeouts);
return strlen(buf);
}
static DEVICE_ATTR(pull_dma_timeouts, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_pull_dma_timeouts, store_pull_dma_timeouts);
static ssize_t store_host_test(
struct device * dev,
struct device_attribute *attr,
const char * buf, size_t count)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
unsigned tv;
if (sscanf(buf, "%x", &tv) == 1){
afhba_write_reg(adev, HOST_TEST_REG, tv);
return strlen(buf);
}else{
return -1;
}
}
static ssize_t show_host_test(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
sprintf(buf, "%08x\n", afhba_read_reg(adev, HOST_TEST_REG));
return strlen(buf);
}
static DEVICE_ATTR(host_test, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_host_test, store_host_test);
static const struct attribute *dev_attrs[] = {
&dev_attr_buffer_len.attr,
&dev_attr_dma_test.attr,
&dev_attr_inflight.attr,
&dev_attr_reset_buffers.attr,
&dev_attr_auroraA.attr,
&dev_attr_auroraB.attr,
&dev_attr_aurora.attr,
&dev_attr_aurora_ext.attr,
&dev_attr_data_fifo_stat_push.attr,
&dev_attr_data_fifo_stat_pull.attr,
&dev_attr_desc_fifo_stat_push.attr,
&dev_attr_desc_fifo_stat_pull.attr,
&dev_attr_dma_ctrl_push.attr,
&dev_attr_dma_ctrl_pull.attr,
&dev_attr_dma_latest_push_desc.attr,
&dev_attr_dma_latest_pull_desc.attr,
&dev_attr_comms_init.attr,
&dev_attr_shot.attr,
&dev_attr_latstat.attr,
&dev_attr_fpga_rev.attr,
&dev_attr_heartbeat.attr,
&dev_attr_host_test.attr,
&dev_attr_pull_dma_timeouts.attr,
&dev_attr_push_dma_timeouts.attr,
NULL
};
void afhba_create_sysfs(struct AFHBA_DEV *adev)
{
int rc;
rc = sysfs_create_files(&adev->class_dev->kobj, dev_attrs);
if (rc){
dev_err(pdev(adev), "failed to create files");
return;
}
}
void afhba_remove_sysfs(struct AFHBA_DEV *adev)
{
sysfs_remove_files(&adev->class_dev->kobj, dev_attrs);
}
static ssize_t show_dev(
struct device * dev,
struct device_attribute *attr,
char * buf)
{
struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev);
if (adev){
return sprintf(buf, "%d:0\n", adev->major);
}else{
return -ENODEV;
}
}
static DEVICE_ATTR(dev, (S_IRUSR|S_IRGRP), show_dev, 0);
static const struct attribute *class_attrs[] = {
&dev_attr_dev.attr,
NULL
};
void afhba_create_sysfs_class(struct AFHBA_DEV *adev)
{
int rc;
dev_dbg(pdev(adev), "01");
rc = sysfs_create_files(&adev->class_dev->kobj, class_attrs);
if (rc){
dev_err(pdev(adev), "failed to create files");
return;
}
rc = sysfs_create_link(
&adev->class_dev->kobj, &adev->pci_dev->dev.kobj, "device");
if (rc) {
dev_err(pdev(adev), "failed to create symlink %s\n", "device");
}
dev_dbg(pdev(adev), "9");
}
void afhba_remove_sysfs_class(struct AFHBA_DEV *adev)
{
sysfs_remove_files(&adev->pci_dev->dev.kobj, class_attrs);
}