Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: qla2xxx: use DEFINE_SHOW_STORE_ATTRIBUTE() helper for debugfs

Use DEFINE_SHOW_STORE_ATTRIBUTE() helper for read-write file to reduce some
duplicated code.

Link: https://lkml.kernel.org/r/20230905024835.43219-4-yangxingui@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Co-developed-by: Xingui Yang <yangxingui@huawei.com>
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Animesh Manna <animesh.manna@intel.com>
Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Himanshu Madhani <himanshu.madhani@cavium.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Xiang Chen <chenxiang66@hisilicon.com>
Cc: Zeng Tao <prime.zeng@hisilicon.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Xingui Yang and committed by
Andrew Morton
a9d56ce0 00c9d55f

+7 -52
+7 -52
drivers/scsi/qla2xxx/qla_dfs.c
··· 528 528 * 529 529 * Example for creating "TEST" sysfs file: 530 530 * 1. struct qla_hw_data { ... struct dentry *dfs_TEST; } 531 - * 2. QLA_DFS_SETUP_RD(TEST, scsi_qla_host_t); 531 + * 2. QLA_DFS_SETUP_RD(TEST); 532 532 * 3. In qla2x00_dfs_setup(): 533 533 * QLA_DFS_CREATE_FILE(ha, TEST, 0600, ha->dfs_dir, vha); 534 534 * 4. In qla2x00_dfs_remove(): 535 535 * QLA_DFS_REMOVE_FILE(ha, TEST); 536 536 */ 537 - #define QLA_DFS_SETUP_RD(_name, _ctx_struct) \ 538 - static int \ 539 - qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ 540 - { \ 541 - _ctx_struct *__ctx = inode->i_private; \ 542 - \ 543 - return single_open(file, qla_dfs_##_name##_show, __ctx); \ 544 - } \ 545 - \ 546 - static const struct file_operations qla_dfs_##_name##_ops = { \ 547 - .open = qla_dfs_##_name##_open, \ 548 - .read = seq_read, \ 549 - .llseek = seq_lseek, \ 550 - .release = single_release, \ 551 - }; 537 + #define QLA_DFS_SETUP_RD(_name) DEFINE_SHOW_ATTRIBUTE(qla_dfs_##_name) 552 538 553 - #define QLA_DFS_SETUP_RW(_name, _ctx_struct) \ 554 - static int \ 555 - qla_dfs_##_name##_open(struct inode *inode, struct file *file) \ 556 - { \ 557 - _ctx_struct *__ctx = inode->i_private; \ 558 - \ 559 - return single_open(file, qla_dfs_##_name##_show, __ctx); \ 560 - } \ 561 - \ 562 - static const struct file_operations qla_dfs_##_name##_ops = { \ 563 - .open = qla_dfs_##_name##_open, \ 564 - .read = seq_read, \ 565 - .llseek = seq_lseek, \ 566 - .release = single_release, \ 567 - .write = qla_dfs_##_name##_write, \ 568 - }; 539 + #define QLA_DFS_SETUP_RW(_name) DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_##_name) 569 540 570 541 #define QLA_DFS_ROOT_CREATE_FILE(_name, _perm, _ctx) \ 571 542 do { \ 572 543 if (!qla_dfs_##_name) \ 573 544 qla_dfs_##_name = debugfs_create_file(#_name, \ 574 545 _perm, qla2x00_dfs_root, _ctx, \ 575 - &qla_dfs_##_name##_ops); \ 546 + &qla_dfs_##_name##_fops); \ 576 547 } while (0) 577 548 578 549 #define QLA_DFS_ROOT_REMOVE_FILE(_name) \ ··· 558 587 do { \ 559 588 (_struct)->dfs_##_name = debugfs_create_file(#_name, \ 560 589 _perm, _parent, _ctx, \ 561 - &qla_dfs_##_name##_ops) \ 590 + &qla_dfs_##_name##_fops) \ 562 591 } while (0) 563 592 564 593 #define QLA_DFS_REMOVE_FILE(_struct, _name) \ ··· 568 597 (_struct)->dfs_##_name = NULL; \ 569 598 } \ 570 599 } while (0) 571 - 572 - static int 573 - qla_dfs_naqp_open(struct inode *inode, struct file *file) 574 - { 575 - struct scsi_qla_host *vha = inode->i_private; 576 - 577 - return single_open(file, qla_dfs_naqp_show, vha); 578 - } 579 600 580 601 static ssize_t 581 602 qla_dfs_naqp_write(struct file *file, const char __user *buffer, ··· 616 653 kfree(buf); 617 654 return rc; 618 655 } 619 - 620 - static const struct file_operations dfs_naqp_ops = { 621 - .open = qla_dfs_naqp_open, 622 - .read = seq_read, 623 - .llseek = seq_lseek, 624 - .release = single_release, 625 - .write = qla_dfs_naqp_write, 626 - }; 627 - 656 + QLA_DFS_SETUP_RW(naqp); 628 657 629 658 int 630 659 qla2x00_dfs_setup(scsi_qla_host_t *vha) ··· 662 707 663 708 if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) { 664 709 ha->tgt.dfs_naqp = debugfs_create_file("naqp", 665 - 0400, ha->dfs_dir, vha, &dfs_naqp_ops); 710 + 0400, ha->dfs_dir, vha, &qla_dfs_naqp_fops); 666 711 if (IS_ERR(ha->tgt.dfs_naqp)) { 667 712 ql_log(ql_log_warn, vha, 0xd011, 668 713 "Unable to create debugFS naqp node.\n");