Seq introduce a new helper macro DEFINE_SHOW_STORE_ATTRIBUTE for
Read-Write file, so we apply it at qla2xxx to reduce some duplicated code.
Signed-off-by: Luo Jiaxing <[email protected]>
---
drivers/scsi/qla2xxx/qla_dfs.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index f89ad32..a5de808 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -513,14 +513,6 @@ qla_dfs_naqp_show(struct seq_file *s, void *unused)
return 0;
}
-static int
-qla_dfs_naqp_open(struct inode *inode, struct file *file)
-{
- struct scsi_qla_host *vha = inode->i_private;
-
- return single_open(file, qla_dfs_naqp_show, vha);
-}
-
static ssize_t
qla_dfs_naqp_write(struct file *file, const char __user *buffer,
size_t count, loff_t *pos)
@@ -569,14 +561,7 @@ qla_dfs_naqp_write(struct file *file, const char __user *buffer,
return rc;
}
-static const struct file_operations dfs_naqp_ops = {
- .open = qla_dfs_naqp_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
- .write = qla_dfs_naqp_write,
-};
-
+DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_naqp);
int
qla2x00_dfs_setup(scsi_qla_host_t *vha)
@@ -622,7 +607,7 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)
if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) {
ha->tgt.dfs_naqp = debugfs_create_file("naqp",
- 0400, ha->dfs_dir, vha, &dfs_naqp_ops);
+ 0400, ha->dfs_dir, vha, &qla_dfs_naqp_ops);
if (!ha->tgt.dfs_naqp) {
ql_log(ql_log_warn, vha, 0xd011,
"Unable to create debugFS naqp node.\n");
--
2.7.4
Hi Luo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on scsi/for-next linus/master v5.10-rc3 next-20201113]
[cannot apply to hnaz-linux-mm/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Luo-Jiaxing/Introduce-a-new-helper-macro-DEFINE_SHOW_STORE_ATTRIBUTE-at-seq_file-c/20201112-150927
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: x86_64-rhel (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/cdd2edc795fcbb643f104476d99a52d0e95bb229
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luo-Jiaxing/Introduce-a-new-helper-macro-DEFINE_SHOW_STORE_ATTRIBUTE-at-seq_file-c/20201112-150927
git checkout cdd2edc795fcbb643f104476d99a52d0e95bb229
# save the attached .config to linux build tree
make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
drivers/scsi/qla2xxx/qla_dfs.c: In function 'qla2x00_dfs_setup':
>> drivers/scsi/qla2xxx/qla_dfs.c:558:32: error: 'qla_dfs_naqp_ops' undeclared (first use in this function); did you mean 'qla_dfs_naqp_fops'?
558 | 0400, ha->dfs_dir, vha, &qla_dfs_naqp_ops);
| ^~~~~~~~~~~~~~~~
| qla_dfs_naqp_fops
drivers/scsi/qla2xxx/qla_dfs.c:558:32: note: each undeclared identifier is reported only once for each function it appears in
In file included from include/scsi/scsi_host.h:10,
from drivers/scsi/qla2xxx/qla_def.h:30,
from drivers/scsi/qla2xxx/qla_dfs.c:6:
At top level:
drivers/scsi/qla2xxx/qla_dfs.c:512:29: warning: 'qla_dfs_naqp_fops' defined but not used [-Wunused-const-variable=]
512 | DEFINE_SHOW_STORE_ATTRIBUTE(qla_dfs_naqp);
| ^~~~~~~~~~~~
include/linux/seq_file.h:200:37: note: in definition of macro 'DEFINE_SHOW_STORE_ATTRIBUTE'
200 | static const struct file_operations __name ## _fops = { \
| ^~~~~~
vim +558 drivers/scsi/qla2xxx/qla_dfs.c
513
514 int
515 qla2x00_dfs_setup(scsi_qla_host_t *vha)
516 {
517 struct qla_hw_data *ha = vha->hw;
518
519 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) &&
520 !IS_QLA27XX(ha) && !IS_QLA28XX(ha))
521 goto out;
522 if (!ha->fce)
523 goto out;
524
525 if (qla2x00_dfs_root)
526 goto create_dir;
527
528 atomic_set(&qla2x00_dfs_root_count, 0);
529 qla2x00_dfs_root = debugfs_create_dir(QLA2XXX_DRIVER_NAME, NULL);
530
531 create_dir:
532 if (ha->dfs_dir)
533 goto create_nodes;
534
535 mutex_init(&ha->fce_mutex);
536 ha->dfs_dir = debugfs_create_dir(vha->host_str, qla2x00_dfs_root);
537
538 atomic_inc(&qla2x00_dfs_root_count);
539
540 create_nodes:
541 ha->dfs_fw_resource_cnt = debugfs_create_file("fw_resource_count",
542 S_IRUSR, ha->dfs_dir, vha, &qla_dfs_fw_resource_cnt_fops);
543
544 ha->dfs_tgt_counters = debugfs_create_file("tgt_counters", S_IRUSR,
545 ha->dfs_dir, vha, &qla_dfs_tgt_counters_fops);
546
547 ha->tgt.dfs_tgt_port_database = debugfs_create_file("tgt_port_database",
548 S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_port_database_fops);
549
550 ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha,
551 &dfs_fce_ops);
552
553 ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
554 S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_sess_fops);
555
556 if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) {
557 ha->tgt.dfs_naqp = debugfs_create_file("naqp",
> 558 0400, ha->dfs_dir, vha, &qla_dfs_naqp_ops);
559 if (!ha->tgt.dfs_naqp) {
560 ql_log(ql_log_warn, vha, 0xd011,
561 "Unable to create debugFS naqp node.\n");
562 goto out;
563 }
564 }
565 vha->dfs_rport_root = debugfs_create_dir("rports", ha->dfs_dir);
566 if (!vha->dfs_rport_root) {
567 ql_log(ql_log_warn, vha, 0xd012,
568 "Unable to create debugFS rports node.\n");
569 goto out;
570 }
571 out:
572 return 0;
573 }
574
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]