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: hisi_sas: 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-3-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
00c9d55f 9cba82bb

+9 -128
+9 -128
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 3990 3990 3991 3991 return count; 3992 3992 } 3993 - 3994 - static int debugfs_bist_linkrate_v3_hw_open(struct inode *inode, 3995 - struct file *filp) 3996 - { 3997 - return single_open(filp, debugfs_bist_linkrate_v3_hw_show, 3998 - inode->i_private); 3999 - } 4000 - 4001 - static const struct file_operations debugfs_bist_linkrate_v3_hw_fops = { 4002 - .open = debugfs_bist_linkrate_v3_hw_open, 4003 - .read = seq_read, 4004 - .write = debugfs_bist_linkrate_v3_hw_write, 4005 - .llseek = seq_lseek, 4006 - .release = single_release, 4007 - .owner = THIS_MODULE, 4008 - }; 3993 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_linkrate_v3_hw); 4009 3994 4010 3995 static const struct { 4011 3996 int value; ··· 4065 4080 4066 4081 return count; 4067 4082 } 4068 - 4069 - static int debugfs_bist_code_mode_v3_hw_open(struct inode *inode, 4070 - struct file *filp) 4071 - { 4072 - return single_open(filp, debugfs_bist_code_mode_v3_hw_show, 4073 - inode->i_private); 4074 - } 4075 - 4076 - static const struct file_operations debugfs_bist_code_mode_v3_hw_fops = { 4077 - .open = debugfs_bist_code_mode_v3_hw_open, 4078 - .read = seq_read, 4079 - .write = debugfs_bist_code_mode_v3_hw_write, 4080 - .llseek = seq_lseek, 4081 - .release = single_release, 4082 - .owner = THIS_MODULE, 4083 - }; 4083 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_code_mode_v3_hw); 4084 4084 4085 4085 static ssize_t debugfs_bist_phy_v3_hw_write(struct file *filp, 4086 4086 const char __user *buf, ··· 4099 4129 4100 4130 return 0; 4101 4131 } 4102 - 4103 - static int debugfs_bist_phy_v3_hw_open(struct inode *inode, 4104 - struct file *filp) 4105 - { 4106 - return single_open(filp, debugfs_bist_phy_v3_hw_show, 4107 - inode->i_private); 4108 - } 4109 - 4110 - static const struct file_operations debugfs_bist_phy_v3_hw_fops = { 4111 - .open = debugfs_bist_phy_v3_hw_open, 4112 - .read = seq_read, 4113 - .write = debugfs_bist_phy_v3_hw_write, 4114 - .llseek = seq_lseek, 4115 - .release = single_release, 4116 - .owner = THIS_MODULE, 4117 - }; 4132 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_phy_v3_hw); 4118 4133 4119 4134 static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp, 4120 4135 const char __user *buf, ··· 4132 4177 4133 4178 return 0; 4134 4179 } 4135 - 4136 - static int debugfs_bist_cnt_v3_hw_open(struct inode *inode, 4137 - struct file *filp) 4138 - { 4139 - return single_open(filp, debugfs_bist_cnt_v3_hw_show, 4140 - inode->i_private); 4141 - } 4142 - 4143 - static const struct file_operations debugfs_bist_cnt_v3_hw_ops = { 4144 - .open = debugfs_bist_cnt_v3_hw_open, 4145 - .read = seq_read, 4146 - .write = debugfs_bist_cnt_v3_hw_write, 4147 - .llseek = seq_lseek, 4148 - .release = single_release, 4149 - .owner = THIS_MODULE, 4150 - }; 4180 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_cnt_v3_hw); 4151 4181 4152 4182 static const struct { 4153 4183 int value; ··· 4196 4256 4197 4257 return count; 4198 4258 } 4199 - 4200 - static int debugfs_bist_mode_v3_hw_open(struct inode *inode, 4201 - struct file *filp) 4202 - { 4203 - return single_open(filp, debugfs_bist_mode_v3_hw_show, 4204 - inode->i_private); 4205 - } 4206 - 4207 - static const struct file_operations debugfs_bist_mode_v3_hw_fops = { 4208 - .open = debugfs_bist_mode_v3_hw_open, 4209 - .read = seq_read, 4210 - .write = debugfs_bist_mode_v3_hw_write, 4211 - .llseek = seq_lseek, 4212 - .release = single_release, 4213 - .owner = THIS_MODULE, 4214 - }; 4259 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_mode_v3_hw); 4215 4260 4216 4261 static ssize_t debugfs_bist_enable_v3_hw_write(struct file *filp, 4217 4262 const char __user *buf, ··· 4234 4309 4235 4310 return 0; 4236 4311 } 4237 - 4238 - static int debugfs_bist_enable_v3_hw_open(struct inode *inode, 4239 - struct file *filp) 4240 - { 4241 - return single_open(filp, debugfs_bist_enable_v3_hw_show, 4242 - inode->i_private); 4243 - } 4244 - 4245 - static const struct file_operations debugfs_bist_enable_v3_hw_fops = { 4246 - .open = debugfs_bist_enable_v3_hw_open, 4247 - .read = seq_read, 4248 - .write = debugfs_bist_enable_v3_hw_write, 4249 - .llseek = seq_lseek, 4250 - .release = single_release, 4251 - .owner = THIS_MODULE, 4252 - }; 4312 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_enable_v3_hw); 4253 4313 4254 4314 static const struct { 4255 4315 char *name; ··· 4272 4362 4273 4363 return 0; 4274 4364 } 4275 - 4276 - static int debugfs_v3_hw_open(struct inode *inode, struct file *filp) 4277 - { 4278 - return single_open(filp, debugfs_v3_hw_show, 4279 - inode->i_private); 4280 - } 4281 - 4282 - static const struct file_operations debugfs_v3_hw_fops = { 4283 - .open = debugfs_v3_hw_open, 4284 - .read = seq_read, 4285 - .write = debugfs_v3_hw_write, 4286 - .llseek = seq_lseek, 4287 - .release = single_release, 4288 - .owner = THIS_MODULE, 4289 - }; 4365 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_v3_hw); 4290 4366 4291 4367 static ssize_t debugfs_phy_down_cnt_v3_hw_write(struct file *filp, 4292 4368 const char __user *buf, ··· 4303 4407 4304 4408 return 0; 4305 4409 } 4306 - 4307 - static int debugfs_phy_down_cnt_v3_hw_open(struct inode *inode, 4308 - struct file *filp) 4309 - { 4310 - return single_open(filp, debugfs_phy_down_cnt_v3_hw_show, 4311 - inode->i_private); 4312 - } 4313 - 4314 - static const struct file_operations debugfs_phy_down_cnt_v3_hw_fops = { 4315 - .open = debugfs_phy_down_cnt_v3_hw_open, 4316 - .read = seq_read, 4317 - .write = debugfs_phy_down_cnt_v3_hw_write, 4318 - .llseek = seq_lseek, 4319 - .release = single_release, 4320 - .owner = THIS_MODULE, 4321 - }; 4410 + DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_phy_down_cnt_v3_hw); 4322 4411 4323 4412 enum fifo_dump_mode_v3_hw { 4324 4413 FIFO_DUMP_FORVER = (1U << 0), ··· 4713 4832 hisi_hba, &debugfs_bist_phy_v3_hw_fops); 4714 4833 4715 4834 debugfs_create_file("cnt", 0600, hisi_hba->debugfs_bist_dentry, 4716 - hisi_hba, &debugfs_bist_cnt_v3_hw_ops); 4835 + hisi_hba, &debugfs_bist_cnt_v3_hw_fops); 4717 4836 4718 4837 debugfs_create_file("loopback_mode", 0600, 4719 4838 hisi_hba->debugfs_bist_dentry,