make coccicheck COCCI=$PWD/scripts/coccinelle/api/device_attr_show.cocci`
complians some warnnings as following[1]:
Not sure if someone had tried these fixes, feel free to ignore this
patch set if we have come to a *NOT-FIX* conclusion before :)
This patch set also fix a few snprintf() beside coccicheck reported.
For example, some thing like
xxx_show() {
rc = snprintf();
..
return rc;
}
TODOs:
1. Fix other abused cases that coccicheck has not detected. For
example, ./drivers/scsi/scsi_transport_fc.c has other places using
snprint inside the macro.
2. Improve device_attr_show.cocci to detect sprintf() and fix them
[1]
$ make coccicheck COCCI=$PWD/scripts/coccinelle/api/device_attr_show.cocci
..
/arch/arm/mm/cache-l2x0-pmu.c:346:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/amd/core.c:1282:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/core.c:1895:11-19: WARNING: use scnprintf or sprintf
/arch/x86/events/core.c:2542:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/core.c:2600:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/intel/core.c:5496:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/intel/core.c:5530:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/intel/core.c:5546:8-16: WARNING: use scnprintf or sprintf
/arch/x86/events/intel/pt.c:99:8-16: WARNING: use scnprintf or sprintf
/drivers/bus/fsl-mc/fsl-mc-bus.c:205:8-16: WARNING: use scnprintf or sprintf
/drivers/edac/edac_mc_sysfs.c:210:8-16: WARNING: use scnprintf or sprintf
/drivers/edac/edac_mc_sysfs.c:518:8-16: WARNING: use scnprintf or sprintf
/drivers/fsi/fsi-master-ast-cf.c:1086:8-16: WARNING: use scnprintf or sprintf
/drivers/fsi/fsi-master-gpio.c:721:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:558:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:602:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:792:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:822:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:852:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:882:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:912:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-lenovo.c:941:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-picolcd_core.c:259:9-17: WARNING: use scnprintf or sprintf
/drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-isku.c:64:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:403:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:412:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:435:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:444:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:454:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kone.c:556:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-koneplus.c:245:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-koneplus.c:312:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kovaplus.c:275:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kovaplus.c:328:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kovaplus.c:337:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kovaplus.c:347:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-kovaplus.c:368:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-pyra.c:286:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-pyra.c:303:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-roccat-pyra.c:324:8-16: WARNING: use scnprintf or sprintf
/drivers/hid/hid-sensor-custom.c:375:10-18: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3100:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3116:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3132:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3145:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3159:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3173:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3186:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3198:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3211:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3224:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3237:8-16: WARNING: use scnprintf or sprintf
/drivers/message/fusion/mptscsih.c:3250:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:211:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:222:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:233:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:244:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:254:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:263:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:272:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:282:9-17: WARNING: use scnprintf or sprintf
/drivers/most/core.c:297:10-18: WARNING: use scnprintf or sprintf
/drivers/most/core.c:309:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:318:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:326:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:398:8-16: WARNING: use scnprintf or sprintf
/drivers/most/core.c:409:9-17: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:466:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:584:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:635:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:686:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:737:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:788:8-16: WARNING: use scnprintf or sprintf
/drivers/platform/mellanox/mlxbf-bootctl.c:839:8-16: WARNING: use scnprintf or sprintf
/drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/53c700.c:2074:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aacraid/linit.c:1299:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aacraid/linit.c:1325:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aacraid/linit.c:1332:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aacraid/linit.c:561:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/aacraid/linit.c:588:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aic94xx/aic94xx_init.c:267:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aic94xx/aic94xx_init.c:276:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aic94xx/aic94xx_init.c:284:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/aic94xx/aic94xx_init.c:455:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:261:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:273:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:285:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:297:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:309:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:322:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:335:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:348:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:361:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/arcmsr/arcmsr_attr.c:374:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/be2iscsi/be_mgmt.c:1145:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/be2iscsi/be_mgmt.c:1164:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/be2iscsi/be_mgmt.c:1251:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/be2iscsi/be_mgmt.c:1280:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fcoe/fcoe_sysfs.c:253:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fcoe/fcoe_sysfs.c:268:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fcoe/fcoe_sysfs.c:376:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:528:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:538:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:549:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:561:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:645:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:724:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:746:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:775:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:799:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:898:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hpsa.c:908:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hptiop.c:1114:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/hptiop.c:1123:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3483:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3493:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3503:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3513:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3522:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi/ibmvfc.c:3530:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3619:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3625:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3633:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/isci/init.c:140:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3336:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3382:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3389:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3399:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3409:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3419:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/megaraid/megaraid_sas_base.c:3473:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2825:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2850:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2873:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2893:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2912:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2932:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2952:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2971:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:2990:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3012:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3034:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3055:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3077:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3097:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3133:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3170:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3198:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3320:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3407:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3828:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3848:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:3996:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:4018:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/mpt3sas/mpt3sas_ctl.c:4056:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:1770:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:1889:10-18: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:1906:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:2143:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:2153:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrb.c:2163:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1061:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1089:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1193:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1306:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1316:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1391:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1401:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1411:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1421:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:1491:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/myrs.c:942:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/ncr53c8xx.c:8034:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/pcmcia/sym53c500_cs.c:627:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/pm8001/pm8001_ctl.c:883:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/pmcraid.c:3541:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/pmcraid.c:3602:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/pmcraid.c:3635:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:159:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:173:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:181:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:190:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:200:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:210:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:223:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:235:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:247:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:256:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:264:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:273:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:281:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:303:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/qla4xxx/ql4_attr.c:312:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:1112:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:1202:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:231:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:277:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:327:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:385:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:402:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:680:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:689:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:701:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:722:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:858:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:873:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:953:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_sysfs.c:979:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1123:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1218:10-18: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1286:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1304:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1665:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1891:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1915:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:1967:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_fc.c:2000:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_sas.c:1180:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_sas.c:525:9-17: WARNING: use scnprintf or sprintf
/drivers/scsi/scsi_transport_sas.c:572:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/snic/snic_attrs.c:16:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/snic/snic_attrs.c:26:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/snic/snic_attrs.c:35:8-16: WARNING: use scnprintf or sprintf
/drivers/scsi/snic/snic_attrs.c:48:8-16: WARNING: use scnprintf or sprintf
/drivers/video/fbdev/uvesafb.c:1549:8-16: WARNING: use scnprintf or sprintf
/kernel/cpu.c:3013:8-16: WARNING: use scnprintf or sprintf
/kernel/cpu.c:3026:8-16: WARNING: use scnprintf or sprintf
CC: Adaptec OEM Raid Solutions <[email protected]>
CC: Adrian Hunter <[email protected]>
CC: Alexander Shishkin <[email protected]>
CC: Alistar Popple <[email protected]>
CC: "Aneesh Kumar K.V" <[email protected]>
CC: Arnaldo Carvalho de Melo <[email protected]>
CC: Artur Paszkiewicz <[email protected]>
CC: Benjamin Tissoires <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: "Bruno Prémont" <[email protected]>
CC: Chandrakanth patil <[email protected]>
CC: Christian Gromm <[email protected]>
CC: Christophe Leroy <[email protected]>
CC: [email protected]
CC: Dave Hansen <[email protected]>
CC: Don Brace <[email protected]>
CC: [email protected]
CC: Eddie James <[email protected]>
CC: [email protected]
CC: Hannes Reinecke <[email protected]>
CC: Hannes Reinecke <[email protected]>
CC: Hans de Goede <[email protected]>
CC: Helge Deller <[email protected]>
CC: HighPoint Linux Team <[email protected]>
CC: "H. Peter Anvin" <[email protected]>
CC: Ian Rogers <[email protected]>
CC: "Ilpo Järvinen" <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Jack Wang <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: James Morse <[email protected]>
CC: Jeremy Kerr <[email protected]>
CC: Jiri Kosina <[email protected]>
CC: Jiri Olsa <[email protected]>
CC: Joel Stanley <[email protected]>
CC: Jonathan Cameron <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Karan Tilak Kumar <[email protected]>
CC: Kashyap Desai <[email protected]>
CC: Ketan Mukadam <[email protected]>
CC: Laurentiu Tudor <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: Manish Rangankar <[email protected]>
CC: Mark Rutland <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: Mauro Carvalho Chehab <[email protected]>
CC: [email protected]
CC: Michael Cyr <[email protected]>
CC: Michael Ellerman <[email protected]>
CC: Michal Januszewski <[email protected]>
CC: [email protected]
CC: Namhyung Kim <[email protected]>
CC: "Naveen N. Rao" <[email protected]>
CC: [email protected]
CC: Nicholas Piggin <[email protected]>
CC: Nicolas Palix <[email protected]>
CC: Nilesh Javali <[email protected]>
CC: Parthiban Veerasooran <[email protected]>
CC: Peter Zijlstra <[email protected]>
CC: [email protected]
CC: Richard Cochran <[email protected]>
CC: Robert Richter <[email protected]>
CC: Russell King <[email protected]>
CC: Sathya Prakash <[email protected]>
CC: Satish Kharat <[email protected]>
CC: Sesidhar Baddela <[email protected]>
CC: Shivasharan S <[email protected]>
CC: Sreekanth Reddy <[email protected]>
CC: Srinivas Pandruvada <[email protected]>
CC: Stefan Achatz <[email protected]>
CC: [email protected]
CC: Stuart Yoder <[email protected]>
CC: Suganath Prabu Subramani <[email protected]>
CC: Sumit Saxena <[email protected]>
CC: [email protected]
CC: Thomas Gleixner <[email protected]>
CC: Tony Luck <[email protected]>
CC: Tyrel Datwyler <[email protected]>
CC: Vadim Pasternak <[email protected]>
CC: [email protected]
Li Zhijian (42):
coccinelle: device_attr_show.cocci: update description and warning
message
arch/arm/mm: Convert snprintf to sysfs_emit
arch/x86/events/amd: Convert snprintf to sysfs_emit
arch/x86/events/core: Convert snprintf to sysfs_emit
arch/x86/events/intel: Convert snprintf to sysfs_emit
drivers/bus/fsl-mc: Convert snprintf to sysfs_emit
drivers/edac: Convert snprintf to sysfs_emit
drivers/fsi: Convert snprintf to sysfs_emit
drivers/hid/hid-lenovo: Convert snprintf to sysfs_emit
drivers/hid/hid-roccat-*: Convert snprintf to sysfs_emit
drivers/hid: Convert snprintf to sysfs_emit
drivers/message/fusion: Convert snprintf to sysfs_emit
drivers/most: Convert snprintf to sysfs_emit
drivers/platform/mellanox: Convert snprintf to sysfs_emit
drivers/ptp: Convert snprintf to sysfs_emit
drivers/scsi/53c700: Convert snprintf to sysfs_emit
drivers/scsi/aacraid: Convert snprintf to sysfs_emit
drivers/scsi/aic94xx: Convert snprintf to sysfs_emit
drivers/scsi/arcmsr: Convert snprintf to sysfs_emit
drivers/scsi/be2iscsi: Convert snprintf to sysfs_emit
drivers/scsi/fcoe: Convert snprintf to sysfs_emit
drivers/scsi/fnic: Convert snprintf to sysfs_emit
drivers/scsi/hpsa: Convert snprintf to sysfs_emit
drivers/scsi/hptiop: Convert snprintf to sysfs_emit
drivers/scsi/ibmvscsi: Convert snprintf to sysfs_emit
drivers/scsi/ibmvscsi_tgt: Convert snprintf to sysfs_emit
drivers/scsi/isci: Convert snprintf to sysfs_emit
drivers/scsi/megaraid: Convert snprintf to sysfs_emit
drivers/scsi/mpt3sas: Convert snprintf to sysfs_emit
drivers/scsi/myrb: Convert snprintf to sysfs_emit
drivers/scsi/myrs: Convert snprintf to sysfs_emit
drivers/scsi/ncr53c8xx: Convert snprintf to sysfs_emit
drivers/scsi/pcmcia/sym53c500_cs: Convert snprintf to sysfs_emit
drivers/scsi/pm8001: Convert snprintf to sysfs_emit
drivers/scsi/pmcraid: Convert snprintf to sysfs_emit
drivers/scsi/qla4xxx/ql4_attr: Convert snprintf to sysfs_emit
drivers/scsi/scsi_sysfs: Convert snprintf to sysfs_emit
drivers/scsi/scsi_transport_fc: Convert snprintf to sysfs_emit
drivers/scsi/scsi_transport_sas: Convert snprintf to sysfs_emit
drivers/scsi/snic/snic_attrs: Convert snprintf to sysfs_emit
drivers/video/fbdev/uvesafb: Convert snprintf to sysfs_emit
kernel/cpu: Convert snprintf to sysfs_emit
arch/arm/mm/cache-l2x0-pmu.c | 2 +-
arch/x86/events/amd/core.c | 2 +-
arch/x86/events/core.c | 6 +-
arch/x86/events/intel/core.c | 6 +-
arch/x86/events/intel/pt.c | 2 +-
drivers/bus/fsl-mc/fsl-mc-bus.c | 2 +-
drivers/edac/edac_mc_sysfs.c | 5 +-
drivers/fsi/fsi-master-ast-cf.c | 3 +-
drivers/fsi/fsi-master-gpio.c | 3 +-
drivers/hid/hid-lenovo.c | 19 +++---
drivers/hid/hid-picolcd_core.c | 6 +-
drivers/hid/hid-roccat-isku.c | 2 +-
drivers/hid/hid-roccat-kone.c | 12 ++--
drivers/hid/hid-roccat-koneplus.c | 4 +-
drivers/hid/hid-roccat-kovaplus.c | 10 +--
drivers/hid/hid-roccat-pyra.c | 6 +-
drivers/hid/hid-sensor-custom.c | 3 +-
drivers/message/fusion/mptscsih.c | 25 ++++----
drivers/most/core.c | 61 +++++++++----------
drivers/platform/mellanox/mlxbf-bootctl.c | 14 ++---
drivers/ptp/ptp_sysfs.c | 3 +-
drivers/scsi/53c700.c | 2 +-
drivers/scsi/aacraid/linit.c | 17 +++---
drivers/scsi/aic94xx/aic94xx_init.c | 15 +++--
drivers/scsi/arcmsr/arcmsr_attr.c | 40 +++---------
drivers/scsi/be2iscsi/be_mgmt.c | 20 +++---
drivers/scsi/fcoe/fcoe_sysfs.c | 8 +--
drivers/scsi/fnic/fnic_attrs.c | 7 +--
drivers/scsi/hpsa.c | 36 +++++------
drivers/scsi/hptiop.c | 4 +-
drivers/scsi/ibmvscsi/ibmvfc.c | 22 +++----
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 6 +-
drivers/scsi/isci/init.c | 2 +-
drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++--
drivers/scsi/mpt3sas/mpt3sas_ctl.c | 60 +++++++++---------
drivers/scsi/myrb.c | 38 ++++++------
drivers/scsi/myrs.c | 56 ++++++++---------
drivers/scsi/ncr53c8xx.c | 2 +-
drivers/scsi/pcmcia/sym53c500_cs.c | 2 +-
drivers/scsi/pm8001/pm8001_ctl.c | 6 +-
drivers/scsi/pmcraid.c | 11 ++--
drivers/scsi/qla4xxx/ql4_attr.c | 48 +++++++--------
drivers/scsi/scsi_sysfs.c | 34 +++++------
drivers/scsi/scsi_transport_fc.c | 34 +++++------
drivers/scsi/scsi_transport_sas.c | 22 +++----
drivers/scsi/snic/snic_attrs.c | 10 +--
drivers/video/fbdev/uvesafb.c | 2 +-
kernel/cpu.c | 4 +-
scripts/coccinelle/api/device_attr_show.cocci | 10 ++-
49 files changed, 343 insertions(+), 386 deletions(-)
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./arch/x86/events/amd/core.c:1282:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Peter Zijlstra <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Arnaldo Carvalho de Melo <[email protected]>
CC: Mark Rutland <[email protected]>
CC: Alexander Shishkin <[email protected]>
CC: Jiri Olsa <[email protected]>
CC: Namhyung Kim <[email protected]>
CC: Ian Rogers <[email protected]>
CC: Adrian Hunter <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: [email protected]
CC: "H. Peter Anvin" <[email protected]>
Signed-off-by: Li Zhijian <[email protected]>
---
arch/x86/events/amd/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index e24976593a29..f2fef75d464c 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -1279,7 +1279,7 @@ static ssize_t branches_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
+ return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
}
static DEVICE_ATTR_RO(branches);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./arch/x86/events/intel/core.c:5496:8-16: WARNING: please use sysfs_emit
> ./arch/x86/events/intel/core.c:5530:8-16: WARNING: please use sysfs_emit
> ./arch/x86/events/intel/core.c:5546:8-16: WARNING: please use sysfs_emit
> ./arch/x86/events/intel/pt.c:99:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Peter Zijlstra <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Arnaldo Carvalho de Melo <[email protected]>
CC: Mark Rutland <[email protected]>
CC: Alexander Shishkin <[email protected]>
CC: Jiri Olsa <[email protected]>
CC: Namhyung Kim <[email protected]>
CC: Ian Rogers <[email protected]>
CC: Adrian Hunter <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: [email protected]
CC: "H. Peter Anvin" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
arch/x86/events/intel/core.c | 6 +++---
arch/x86/events/intel/pt.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 0f2786d4e405..aa5fa64a923b 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -5493,7 +5493,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
+ return sysfs_emit(buf, "%d\n", allow_tsx_force_abort);
}
static ssize_t set_sysctl_tfa(struct device *cdev,
@@ -5527,7 +5527,7 @@ static ssize_t branches_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
+ return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
}
static DEVICE_ATTR_RO(branches);
@@ -5543,7 +5543,7 @@ static ssize_t pmu_name_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str);
+ return sysfs_emit(buf, "%s\n", pmu_name_str);
}
static DEVICE_ATTR_RO(pmu_name);
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 8e2a12235e62..30bba5f3a840 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -96,7 +96,7 @@ static ssize_t pt_cap_show(struct device *cdev,
container_of(attr, struct dev_ext_attribute, attr);
enum pt_capabilities cap = (long)ea->var;
- return snprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap));
+ return sysfs_emit(buf, "%x\n", intel_pt_validate_hw_cap(cap));
}
static struct attribute_group pt_cap_group __ro_after_init = {
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./arch/x86/events/core.c:1895:11-19: WARNING: please use sysfs_emit
> ./arch/x86/events/core.c:2542:8-16: WARNING: please use sysfs_emit
> ./arch/x86/events/core.c:2600:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Peter Zijlstra <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Arnaldo Carvalho de Melo <[email protected]>
CC: Mark Rutland <[email protected]>
CC: Alexander Shishkin <[email protected]>
CC: Jiri Olsa <[email protected]>
CC: Namhyung Kim <[email protected]>
CC: Ian Rogers <[email protected]>
CC: Adrian Hunter <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: Dave Hansen <[email protected]>
CC: [email protected]
CC: "H. Peter Anvin" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
arch/x86/events/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 40ad1425ffa2..52e5707be03b 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1892,7 +1892,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) {
next_str = strchr(str, ';');
if (next_str)
- return snprintf(page, next_str - str + 1, "%s", str);
+ return sysfs_emit(page, "%s", str);
else
return sprintf(page, "%s", str);
}
@@ -2539,7 +2539,7 @@ static ssize_t get_attr_rdpmc(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
+ return sysfs_emit(buf, "%d\n", x86_pmu.attr_rdpmc);
}
static ssize_t set_attr_rdpmc(struct device *cdev,
@@ -2597,7 +2597,7 @@ static ssize_t max_precise_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
+ return sysfs_emit(buf, "%d\n", x86_pmu_max_precise());
}
static DEVICE_ATTR_RO(max_precise);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/hptiop.c:1114:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hptiop.c:1123:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: HighPoint Linux Team <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/hptiop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index f5334ccbf2ca..65426df93270 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1111,7 +1111,7 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
static ssize_t hptiop_show_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver);
+ return sysfs_emit(buf, "%s\n", driver_ver);
}
static ssize_t hptiop_show_fw_version(struct device *dev,
@@ -1120,7 +1120,7 @@ static ssize_t hptiop_show_fw_version(struct device *dev,
struct Scsi_Host *host = class_to_shost(dev);
struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n",
+ return sysfs_emit(buf, "%d.%d.%d.%d\n",
hba->firmware_version >> 24,
(hba->firmware_version >> 16) & 0xff,
(hba->firmware_version >> 8) & 0xff,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/fsi/fsi-master-ast-cf.c:1086:8-16: WARNING: please use sysfs_emit
> ./drivers/fsi/fsi-master-gpio.c:721:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Jeremy Kerr <[email protected]>
CC: Joel Stanley <[email protected]>
CC: Alistar Popple <[email protected]>
CC: Eddie James <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/fsi/fsi-master-ast-cf.c | 3 +--
drivers/fsi/fsi-master-gpio.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
index 812dfa9a9140..5740b2d9dace 100644
--- a/drivers/fsi/fsi-master-ast-cf.c
+++ b/drivers/fsi/fsi-master-ast-cf.c
@@ -1083,8 +1083,7 @@ static ssize_t external_mode_show(struct device *dev,
{
struct fsi_master_acf *master = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE - 1, "%u\n",
- master->external_mode ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
}
static ssize_t external_mode_store(struct device *dev,
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index ed03da4f2447..286fe1cddf99 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -718,8 +718,7 @@ static ssize_t external_mode_show(struct device *dev,
{
struct fsi_master_gpio *master = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE - 1, "%u\n",
- master->external_mode ? 1 : 0);
+ return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
}
static ssize_t external_mode_store(struct device *dev,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/hpsa.c:528:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:538:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:549:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:561:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:645:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:724:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:746:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:775:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:799:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:898:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/hpsa.c:908:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Don Brace <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/hpsa.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index af18d20f3079..5736c0f7a1be 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -525,8 +525,8 @@ static ssize_t host_show_firmware_revision(struct device *dev,
if (!h->hba_inquiry_data)
return 0;
fwrev = &h->hba_inquiry_data[32];
- return snprintf(buf, 20, "%c%c%c%c\n",
- fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
+ return sysfs_emit(buf, "%c%c%c%c\n",
+ fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
}
static ssize_t host_show_commands_outstanding(struct device *dev,
@@ -535,8 +535,8 @@ static ssize_t host_show_commands_outstanding(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ctlr_info *h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n",
- atomic_read(&h->commands_outstanding));
+ return sysfs_emit(buf, "%d\n",
+ atomic_read(&h->commands_outstanding));
}
static ssize_t host_show_transport_mode(struct device *dev,
@@ -546,9 +546,9 @@ static ssize_t host_show_transport_mode(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%s\n",
- h->transMethod & CFGTBL_Trans_Performant ?
- "performant" : "simple");
+ return sysfs_emit(buf, "%s\n",
+ h->transMethod & CFGTBL_Trans_Performant ?
+ "performant" : "simple");
}
static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
@@ -558,8 +558,8 @@ static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 30, "HP SSD Smart Path %s\n",
- (h->acciopath_status == 1) ? "enabled" : "disabled");
+ return sysfs_emit(buf, "HP SSD Smart Path %s\n",
+ (h->acciopath_status == 1) ? "enabled" : "disabled");
}
/* List of controllers which cannot be hard reset on kexec with reset_devices */
@@ -642,7 +642,7 @@ static ssize_t host_show_resettable(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
+ return sysfs_emit(buf, "%d\n", ctlr_is_resettable(h->board_id));
}
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
@@ -721,7 +721,7 @@ static ssize_t lunid_show(struct device *dev,
}
memcpy(lunid, hdev->scsi3addr, sizeof(lunid));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "0x%8phN\n", lunid);
+ return sysfs_emit(buf, "0x%8phN\n", lunid);
}
static ssize_t unique_id_show(struct device *dev,
@@ -743,7 +743,7 @@ static ssize_t unique_id_show(struct device *dev,
}
memcpy(sn, hdev->device_id, sizeof(sn));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 16 * 2 + 2,
+ return sysfs_emit(buf,
"%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
@@ -772,7 +772,7 @@ static ssize_t sas_address_show(struct device *dev,
sas_address = hdev->sas_address;
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address);
+ return sysfs_emit(buf, "0x%016llx\n", sas_address);
}
static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
@@ -796,10 +796,10 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
spin_unlock_irqrestore(&h->lock, flags);
if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC)
- return snprintf(buf, 20, "%d\n", offload_enabled);
+ return sysfs_emit(buf, "%d\n", offload_enabled);
else
- return snprintf(buf, 40, "%s\n",
- "Not applicable for a controller");
+ return sysfs_emit(buf, "%s\n",
+ "Not applicable for a controller");
}
#define MAX_PATHS 8
@@ -895,7 +895,7 @@ static ssize_t host_show_ctlr_num(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", h->ctlr);
+ return sysfs_emit(buf, "%d\n", h->ctlr);
}
static ssize_t host_show_legacy_board(struct device *dev,
@@ -905,7 +905,7 @@ static ssize_t host_show_legacy_board(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0);
+ return sysfs_emit(buf, "%d\n", h->legacy_board ? 1 : 0);
}
static DEVICE_ATTR_RO(raid_level);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Richard Cochran <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/ptp/ptp_sysfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index f7a499a1bd39..49737ed6ef5f 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev,
{
struct ptp_clock *ptp = dev_get_drvdata(dev);
- return snprintf(page, PAGE_SIZE - 1, "%d\n",
- ptp->info->getmaxphase(ptp->info));
+ return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info));
}
static DEVICE_ATTR_RO(max_phase_adjustment);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/53c700.c:2074:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/53c700.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 857be0f3ae5b..85439e976143 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -2071,7 +2071,7 @@ NCR_700_show_active_tags(struct device *dev, struct device_attribute *attr, char
{
struct scsi_device *SDp = to_scsi_device(dev);
- return snprintf(buf, 20, "%d\n", NCR_700_get_depth(SDp));
+ return sysfs_emit(buf, "%d\n", NCR_700_get_depth(SDp));
}
static struct device_attribute NCR_700_active_tags_attr = {
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/fcoe/fcoe_sysfs.c:253:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fcoe/fcoe_sysfs.c:268:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fcoe/fcoe_sysfs.c:376:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Hannes Reinecke <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/fcoe/fcoe_sysfs.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index e17957f8085c..9705a579e0d0 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -250,7 +250,7 @@ static ssize_t show_fcf_state(struct device *dev,
name = get_fcoe_fcf_state_name(fcf->state);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_FCF_STATE_MAX_NAMELEN, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL);
@@ -265,8 +265,7 @@ static ssize_t show_ctlr_mode(struct device *dev,
name = get_fcoe_ctlr_mode_name(ctlr->mode);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_MAX_MODENAME_LEN,
- "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static ssize_t store_ctlr_mode(struct device *dev,
@@ -373,8 +372,7 @@ static ssize_t show_ctlr_enabled_state(struct device *dev,
name = get_fcoe_ctlr_enabled_state_name(ctlr->enabled);
if (!name)
return -EINVAL;
- return snprintf(buf, FCOE_CTLR_ENABLED_MAX_NAMELEN,
- "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/pcmcia/sym53c500_cs.c:627:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/pcmcia/sym53c500_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 278c78d066c4..264eeb24b811 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -624,7 +624,7 @@ SYM53C500_show_pio(struct device *dev, struct device_attribute *attr,
struct sym53c500_data *data =
(struct sym53c500_data *)SHp->hostdata;
- return snprintf(buf, 4, "%d\n", data->fast_pio);
+ return sysfs_emit(buf, "%d\n", data->fast_pio);
}
static ssize_t
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3619:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3625:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3633:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Michael Cyr <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index 4dc411a58107..071dd3c4dcf8 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -3616,13 +3616,13 @@ static void ibmvscsis_remove(struct vio_dev *vdev)
static ssize_t system_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
+ return sysfs_emit(buf, "%s\n", system_id);
}
static ssize_t partition_number_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
+ return sysfs_emit(buf, "%x\n", partition_number);
}
static ssize_t unit_address_show(struct device *dev,
@@ -3630,7 +3630,7 @@ static ssize_t unit_address_show(struct device *dev,
{
struct scsi_info *vscsi = container_of(dev, struct scsi_info, dev);
- return snprintf(buf, PAGE_SIZE, "%x\n", vscsi->dma_dev->unit_address);
+ return sysfs_emit(buf, "%x\n", vscsi->dma_dev->unit_address);
}
static int ibmvscsis_get_system_info(void)
--
2.29.2
Per Documentation/filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/hid/hid-picolcd_core.c:259:9-17: WARNING: please use sysfs_emit
> ./drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-sensor-custom.c:375:10-18: WARNING: please use sysfs_emi
No functional change intended
CC: "Bruno Prémont" <[email protected]>
CC: Jiri Kosina <[email protected]>
CC: Benjamin Tissoires <[email protected]>
CC: Jonathan Cameron <[email protected]>
CC: Srinivas Pandruvada <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/hid/hid-picolcd_core.c | 6 +++---
drivers/hid/hid-sensor-custom.c | 3 +--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
index bbda231a7ce3..fa46fb6eab3f 100644
--- a/drivers/hid/hid-picolcd_core.c
+++ b/drivers/hid/hid-picolcd_core.c
@@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_show(struct device *dev,
struct picolcd_data *data = dev_get_drvdata(dev);
if (data->status & PICOLCD_BOOTLOADER)
- return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n");
+ return sysfs_emit(buf, "[bootloader] lcd\n");
else
- return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n");
+ return sysfs_emit(buf, "bootloader [lcd]\n");
}
static ssize_t picolcd_operation_mode_store(struct device *dev,
@@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_delay_show(struct device *dev,
{
struct picolcd_data *data = dev_get_drvdata(dev);
- return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay);
+ return sysfs_emit(buf, "%hu\n", data->opmode_delay);
}
static ssize_t picolcd_operation_mode_delay_store(struct device *dev,
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index d85398721659..4fe8dccf671d 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -372,8 +372,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
sizeof(struct hid_custom_usage_desc),
usage_id_cmp);
if (usage_desc)
- return snprintf(buf, PAGE_SIZE, "%s\n",
- usage_desc->desc);
+ return sysfs_emit(buf, "%s\n", usage_desc->desc);
else
return sprintf(buf, "not-specified\n");
} else
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/pmcraid.c:3541:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/pmcraid.c:3602:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/pmcraid.c:3635:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/pmcraid.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index e8bcc3a88732..eb8973ac4cc7 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3538,7 +3538,7 @@ static ssize_t pmcraid_show_log_level(
struct Scsi_Host *shost = class_to_shost(dev);
struct pmcraid_instance *pinstance =
(struct pmcraid_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level);
+ return sysfs_emit(buf, "%d\n", pinstance->current_log_level);
}
/**
@@ -3599,8 +3599,7 @@ static ssize_t pmcraid_show_drv_version(
char *buf
)
{
- return snprintf(buf, PAGE_SIZE, "version: %s\n",
- PMCRAID_DRIVER_VERSION);
+ return sysfs_emit(buf, "version: %s\n", PMCRAID_DRIVER_VERSION);
}
static struct device_attribute pmcraid_driver_version_attr = {
@@ -3632,9 +3631,9 @@ static ssize_t pmcraid_show_adapter_id(
u32 adapter_id = pci_dev_id(pinstance->pdev);
u32 aen_group = pmcraid_event_family.id;
- return snprintf(buf, PAGE_SIZE,
- "adapter id: %d\nminor: %d\naen group: %d\n",
- adapter_id, MINOR(pinstance->cdev.dev), aen_group);
+ return sysfs_emit(buf,
+ "adapter id: %d\nminor: %d\naen group: %d\n",
+ adapter_id, MINOR(pinstance->cdev.dev), aen_group);
}
static struct device_attribute pmcraid_adapter_id_attr = {
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/myrs.c:1061:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1089:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1193:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1306:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1316:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1391:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1401:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1411:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1421:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:1491:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrs.c:942:9-17: WARNING: please use sysfs_emit
No functional change intended
CC: Hannes Reinecke <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/myrs.c | 56 ++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index a1eec65a9713..deafe5904055 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -939,7 +939,7 @@ static ssize_t raid_state_show(struct device *dev,
int ret;
if (!sdev->hostdata)
- return snprintf(buf, 16, "Unknown\n");
+ return sysfs_emit(buf, "Unknown\n");
if (sdev->channel >= cs->ctlr_info->physchan_present) {
struct myrs_ldev_info *ldev_info = sdev->hostdata;
@@ -947,10 +947,10 @@ static ssize_t raid_state_show(struct device *dev,
name = myrs_devstate_name(ldev_info->dev_state);
if (name)
- ret = snprintf(buf, 32, "%s\n", name);
+ ret = sysfs_emit(buf, "%s\n", name);
else
- ret = snprintf(buf, 32, "Invalid (%02X)\n",
- ldev_info->dev_state);
+ ret = sysfs_emit(buf, "Invalid (%02X)\n",
+ ldev_info->dev_state);
} else {
struct myrs_pdev_info *pdev_info;
const char *name;
@@ -958,10 +958,10 @@ static ssize_t raid_state_show(struct device *dev,
pdev_info = sdev->hostdata;
name = myrs_devstate_name(pdev_info->dev_state);
if (name)
- ret = snprintf(buf, 32, "%s\n", name);
+ ret = sysfs_emit(buf, "%s\n", name);
else
- ret = snprintf(buf, 32, "Invalid (%02X)\n",
- pdev_info->dev_state);
+ ret = sysfs_emit(buf, "Invalid (%02X)\n",
+ pdev_info->dev_state);
}
return ret;
}
@@ -1058,7 +1058,7 @@ static ssize_t raid_level_show(struct device *dev,
const char *name = NULL;
if (!sdev->hostdata)
- return snprintf(buf, 16, "Unknown\n");
+ return sysfs_emit(buf, "Unknown\n");
if (sdev->channel >= cs->ctlr_info->physchan_present) {
struct myrs_ldev_info *ldev_info;
@@ -1066,13 +1066,13 @@ static ssize_t raid_level_show(struct device *dev,
ldev_info = sdev->hostdata;
name = myrs_raid_level_name(ldev_info->raid_level);
if (!name)
- return snprintf(buf, 32, "Invalid (%02X)\n",
+ return sysfs_emit(buf, "Invalid (%02X)\n",
ldev_info->dev_state);
} else
name = myrs_raid_level_name(MYRS_RAID_PHYSICAL);
- return snprintf(buf, 32, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static DEVICE_ATTR_RO(raid_level);
@@ -1086,7 +1086,7 @@ static ssize_t rebuild_show(struct device *dev,
unsigned char status;
if (sdev->channel < cs->ctlr_info->physchan_present)
- return snprintf(buf, 32, "physical device - not rebuilding\n");
+ return sysfs_emit(buf, "physical device - not rebuilding\n");
ldev_info = sdev->hostdata;
ldev_num = ldev_info->ldev_num;
@@ -1098,11 +1098,11 @@ static ssize_t rebuild_show(struct device *dev,
return -EIO;
}
if (ldev_info->rbld_active) {
- return snprintf(buf, 32, "rebuilding block %zu of %zu\n",
+ return sysfs_emit(buf, "rebuilding block %zu of %zu\n",
(size_t)ldev_info->rbld_lba,
(size_t)ldev_info->cfg_devsize);
} else
- return snprintf(buf, 32, "not rebuilding\n");
+ return sysfs_emit(buf, "not rebuilding\n");
}
static ssize_t rebuild_store(struct device *dev,
@@ -1190,7 +1190,7 @@ static ssize_t consistency_check_show(struct device *dev,
unsigned short ldev_num;
if (sdev->channel < cs->ctlr_info->physchan_present)
- return snprintf(buf, 32, "physical device - not checking\n");
+ return sysfs_emit(buf, "physical device - not checking\n");
ldev_info = sdev->hostdata;
if (!ldev_info)
@@ -1198,11 +1198,11 @@ static ssize_t consistency_check_show(struct device *dev,
ldev_num = ldev_info->ldev_num;
myrs_get_ldev_info(cs, ldev_num, ldev_info);
if (ldev_info->cc_active)
- return snprintf(buf, 32, "checking block %zu of %zu\n",
- (size_t)ldev_info->cc_lba,
- (size_t)ldev_info->cfg_devsize);
+ return sysfs_emit(buf, "checking block %zu of %zu\n",
+ (size_t)ldev_info->cc_lba,
+ (size_t)ldev_info->cfg_devsize);
else
- return snprintf(buf, 32, "not checking\n");
+ return sysfs_emit(buf, "not checking\n");
}
static ssize_t consistency_check_store(struct device *dev,
@@ -1303,7 +1303,7 @@ static ssize_t serial_show(struct device *dev,
memcpy(serial, cs->ctlr_info->serial_number, 16);
serial[16] = '\0';
- return snprintf(buf, 16, "%s\n", serial);
+ return sysfs_emit(buf, "%s\n", serial);
}
static DEVICE_ATTR_RO(serial);
@@ -1313,7 +1313,7 @@ static ssize_t ctlr_num_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 20, "%d\n", cs->host->host_no);
+ return sysfs_emit(buf, "%d\n", cs->host->host_no);
}
static DEVICE_ATTR_RO(ctlr_num);
@@ -1388,7 +1388,7 @@ static ssize_t model_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 28, "%s\n", cs->model_name);
+ return sysfs_emit(buf, "%s\n", cs->model_name);
}
static DEVICE_ATTR_RO(model);
@@ -1398,7 +1398,7 @@ static ssize_t ctlr_type_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type);
+ return sysfs_emit(buf, "%d\n", cs->ctlr_info->ctlr_type);
}
static DEVICE_ATTR_RO(ctlr_type);
@@ -1408,7 +1408,7 @@ static ssize_t cache_size_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb);
+ return sysfs_emit(buf, "%d MB\n", cs->ctlr_info->cache_size_mb);
}
static DEVICE_ATTR_RO(cache_size);
@@ -1418,10 +1418,10 @@ static ssize_t firmware_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 16, "%d.%02d-%02d\n",
- cs->ctlr_info->fw_major_version,
- cs->ctlr_info->fw_minor_version,
- cs->ctlr_info->fw_turn_number);
+ return sysfs_emit(buf, "%d.%02d-%02d\n",
+ cs->ctlr_info->fw_major_version,
+ cs->ctlr_info->fw_minor_version,
+ cs->ctlr_info->fw_turn_number);
}
static DEVICE_ATTR_RO(firmware);
@@ -1488,7 +1488,7 @@ static ssize_t disable_enclosure_messages_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrs_hba *cs = shost_priv(shost);
- return snprintf(buf, 3, "%d\n", cs->disable_enc_msg);
+ return sysfs_emit(buf, "%d\n", cs->disable_enc_msg);
}
static ssize_t disable_enclosure_messages_store(struct device *dev,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3336:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3382:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3389:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3399:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3409:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3419:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/megaraid/megaraid_sas_base.c:3473:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Kashyap Desai <[email protected]>
CC: Sumit Saxena <[email protected]>
CC: Shivasharan S <[email protected]>
CC: Chandrakanth patil <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 3d4f13da1ae8..4e4414df1935 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3333,7 +3333,7 @@ fw_crash_buffer_size_show(struct device *cdev,
struct megasas_instance *instance =
(struct megasas_instance *) shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)
+ return sysfs_emit(buf, "%ld\n", (unsigned long)
((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE);
}
@@ -3379,14 +3379,14 @@ fw_crash_state_show(struct device *cdev,
struct megasas_instance *instance =
(struct megasas_instance *) shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state);
+ return sysfs_emit(buf, "%d\n", instance->fw_crash_state);
}
static ssize_t
page_size_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1);
+ return sysfs_emit(buf, "%ld\n", (unsigned long)PAGE_SIZE - 1);
}
static ssize_t
@@ -3396,7 +3396,7 @@ ldio_outstanding_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding));
+ return sysfs_emit(buf, "%d\n", atomic_read(&instance->ldio_outstanding));
}
static ssize_t
@@ -3406,7 +3406,7 @@ fw_cmds_outstanding_show(struct device *cdev,
struct Scsi_Host *shost = class_to_shost(cdev);
struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding));
+ return sysfs_emit(buf, "%d\n", atomic_read(&instance->fw_outstanding));
}
static ssize_t
@@ -3416,7 +3416,7 @@ enable_sdev_max_qd_show(struct device *cdev,
struct Scsi_Host *shost = class_to_shost(cdev);
struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd);
+ return sysfs_emit(buf, "%d\n", instance->enable_sdev_max_qd);
}
static ssize_t
@@ -3470,8 +3470,7 @@ raid_map_id_show(struct device *cdev, struct device_attribute *attr,
struct megasas_instance *instance =
(struct megasas_instance *)shost->hostdata;
- return snprintf(buf, PAGE_SIZE, "%ld\n",
- (unsigned long)instance->map_id);
+ return sysfs_emit(buf, "%ld\n", (unsigned long)instance->map_id);
}
static DEVICE_ATTR_RW(fw_crash_buffer);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/scsi_transport_sas.c:1180:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_sas.c:525:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_sas.c:572:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/scsi_transport_sas.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index d704c484a251..f679034e1048 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -427,7 +427,7 @@ show_sas_phy_##name(struct device *dev, \
{ \
struct sas_phy *phy = transport_class_to_phy(dev); \
\
- return snprintf(buf, 20, format_string, cast phy->field); \
+ return sysfs_emit(buf, format_string, cast phy->field); \
}
#define sas_phy_simple_attr(field, name, format_string, type) \
@@ -442,7 +442,7 @@ show_sas_phy_##name(struct device *dev, \
struct sas_phy *phy = transport_class_to_phy(dev); \
\
if (!phy->field) \
- return snprintf(buf, 20, "none\n"); \
+ return sysfs_emit(buf, "none\n"); \
return get_sas_protocol_names(phy->field, buf); \
}
@@ -507,7 +507,7 @@ show_sas_phy_##field(struct device *dev, \
error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0; \
if (error) \
return error; \
- return snprintf(buf, 20, "%u\n", phy->field); \
+ return sysfs_emit(buf, "%u\n", phy->field); \
}
#define sas_phy_linkerror_attr(field) \
@@ -522,7 +522,7 @@ show_sas_device_type(struct device *dev,
struct sas_phy *phy = transport_class_to_phy(dev);
if (!phy->identify.device_type)
- return snprintf(buf, 20, "none\n");
+ return sysfs_emit(buf, "none\n");
return get_sas_device_type_names(phy->identify.device_type, buf);
}
static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL);
@@ -569,7 +569,7 @@ show_sas_phy_enable(struct device *dev, struct device_attribute *attr,
{
struct sas_phy *phy = transport_class_to_phy(dev);
- return snprintf(buf, 20, "%d\n", phy->enabled);
+ return sysfs_emit(buf, "%d\n", phy->enabled);
}
static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable,
@@ -798,7 +798,7 @@ show_sas_port_##name(struct device *dev, \
{ \
struct sas_port *port = transport_class_to_sas_port(dev); \
\
- return snprintf(buf, 20, format_string, cast port->field); \
+ return sysfs_emit(buf, format_string, cast port->field); \
}
#define sas_port_simple_attr(field, name, format_string, type) \
@@ -1145,7 +1145,7 @@ show_sas_rphy_##name(struct device *dev, \
{ \
struct sas_rphy *rphy = transport_class_to_rphy(dev); \
\
- return snprintf(buf, 20, format_string, cast rphy->field); \
+ return sysfs_emit(buf, format_string, cast rphy->field); \
}
#define sas_rphy_simple_attr(field, name, format_string, type) \
@@ -1161,7 +1161,7 @@ show_sas_rphy_##name(struct device *dev, \
struct sas_rphy *rphy = transport_class_to_rphy(dev); \
\
if (!rphy->field) \
- return snprintf(buf, 20, "none\n"); \
+ return sysfs_emit(buf, "none\n"); \
return get_sas_protocol_names(rphy->field, buf); \
}
@@ -1177,7 +1177,7 @@ show_sas_rphy_device_type(struct device *dev,
struct sas_rphy *rphy = transport_class_to_rphy(dev);
if (!rphy->identify.device_type)
- return snprintf(buf, 20, "none\n");
+ return sysfs_emit(buf, "none\n");
return get_sas_device_type_names(
rphy->identify.device_type, buf);
}
@@ -1280,7 +1280,7 @@ show_sas_end_dev_##name(struct device *dev, \
struct sas_rphy *rphy = transport_class_to_rphy(dev); \
struct sas_end_device *rdev = rphy_to_end_device(rphy); \
\
- return snprintf(buf, 20, format_string, cast rdev->field); \
+ return sysfs_emit(buf, format_string, cast rdev->field); \
}
#define sas_end_dev_simple_attr(field, name, format_string, type) \
@@ -1309,7 +1309,7 @@ show_sas_expander_##name(struct device *dev, \
struct sas_rphy *rphy = transport_class_to_rphy(dev); \
struct sas_expander_device *edev = rphy_to_expander_device(rphy); \
\
- return snprintf(buf, 20, format_string, cast edev->field); \
+ return sysfs_emit(buf, format_string, cast edev->field); \
}
#define sas_expander_simple_attr(field, name, format_string, type) \
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Satish Kharat <[email protected]>
CC: Sesidhar Baddela <[email protected]>
CC: Karan Tilak Kumar <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/fnic/fnic_attrs.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c
index a61e0c5e6506..0c5e57c7e322 100644
--- a/drivers/scsi/fnic/fnic_attrs.c
+++ b/drivers/scsi/fnic/fnic_attrs.c
@@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev,
struct fc_lport *lp = shost_priv(class_to_shost(dev));
struct fnic *fnic = lport_priv(lp);
- return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
+ return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
}
static ssize_t fnic_show_drv_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
+ return sysfs_emit(buf, "%s\n", DRV_VERSION);
}
static ssize_t fnic_show_link_state(struct device *dev,
@@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev,
{
struct fc_lport *lp = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
- ? "Link Up" : "Link Down");
+ return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down");
}
static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/aacraid/linit.c:1299:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/aacraid/linit.c:1325:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/aacraid/linit.c:1332:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/aacraid/linit.c:561:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/aacraid/linit.c:588:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Adaptec OEM Raid Solutions <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/aacraid/linit.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 68f4dbcfff49..f534f5d985f1 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -558,11 +558,10 @@ static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *
struct scsi_device *sdev = to_scsi_device(dev);
struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata);
if (sdev_channel(sdev) != CONTAINER_CHANNEL)
- return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
- ? "Hidden\n" :
+ return sysfs_emit(buf, sdev->no_uld_attacha ? "Hidden\n" :
((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : ""));
- return snprintf(buf, PAGE_SIZE, "%s\n",
- get_container_type(aac->fsa_dev[sdev_id(sdev)].type));
+ return sysfs_emit(buf, "%s\n",
+ get_container_type(aac->fsa_dev[sdev_id(sdev)].type));
}
static struct device_attribute aac_raid_level_attr = {
@@ -585,7 +584,7 @@ static ssize_t aac_show_unique_id(struct device *dev,
if (sdev_channel(sdev) == CONTAINER_CHANNEL)
memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn));
- return snprintf(buf, 16 * 2 + 2,
+ return sysfs_emit(buf,
"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
sn[4], sn[5], sn[6], sn[7],
@@ -1296,7 +1295,7 @@ static ssize_t aac_show_driver_version(struct device *device,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version);
+ return sysfs_emit(buf, "%s\n", aac_driver_version);
}
static ssize_t aac_show_serial_number(struct device *device,
@@ -1322,15 +1321,13 @@ static ssize_t aac_show_serial_number(struct device *device,
static ssize_t aac_show_max_channel(struct device *device,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n",
- class_to_shost(device)->max_channel);
+ return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_channel);
}
static ssize_t aac_show_max_id(struct device *device,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%d\n",
- class_to_shost(device)->max_id);
+ return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_id);
}
static ssize_t aac_store_reset_adapter(struct device *device,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/qla4xxx/ql4_attr.c:159:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:173:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:181:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:190:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:200:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:210:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:223:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:235:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:247:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:256:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:264:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:273:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:281:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:303:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/qla4xxx/ql4_attr.c:312:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Nilesh Javali <[email protected]>
CC: Manish Rangankar <[email protected]>
CC: [email protected]
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/qla4xxx/ql4_attr.c | 48 ++++++++++++++++-----------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c
index abfa6ef60480..8d2ff36338c0 100644
--- a/drivers/scsi/qla4xxx/ql4_attr.c
+++ b/drivers/scsi/qla4xxx/ql4_attr.c
@@ -156,13 +156,13 @@ qla4xxx_fw_version_show(struct device *dev,
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
if (is_qla80XX(ha))
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
- ha->fw_info.fw_major, ha->fw_info.fw_minor,
- ha->fw_info.fw_patch, ha->fw_info.fw_build);
+ return sysfs_emit(buf, "%d.%02d.%02d (%x)\n",
+ ha->fw_info.fw_major, ha->fw_info.fw_minor,
+ ha->fw_info.fw_patch, ha->fw_info.fw_build);
else
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
- ha->fw_info.fw_major, ha->fw_info.fw_minor,
- ha->fw_info.fw_patch, ha->fw_info.fw_build);
+ return sysfs_emit(buf, "%d.%02d.%02d.%02d\n",
+ ha->fw_info.fw_major, ha->fw_info.fw_minor,
+ ha->fw_info.fw_patch, ha->fw_info.fw_build);
}
static ssize_t
@@ -170,7 +170,7 @@ qla4xxx_serial_num_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
+ return sysfs_emit(buf, "%s\n", ha->serial_number);
}
static ssize_t
@@ -178,8 +178,8 @@ qla4xxx_iscsi_version_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fw_info.iscsi_major,
- ha->fw_info.iscsi_minor);
+ return sysfs_emit(buf, "%d.%02d\n", ha->fw_info.iscsi_major,
+ ha->fw_info.iscsi_minor);
}
static ssize_t
@@ -187,7 +187,7 @@ qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
+ return sysfs_emit(buf, "%d.%02d.%02d.%02d\n",
ha->fw_info.bootload_major, ha->fw_info.bootload_minor,
ha->fw_info.bootload_patch, ha->fw_info.bootload_build);
}
@@ -197,7 +197,7 @@ qla4xxx_board_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
+ return sysfs_emit(buf, "0x%08X\n", ha->board_id);
}
static ssize_t
@@ -207,8 +207,8 @@ qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr,
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
qla4xxx_get_firmware_state(ha);
- return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
- ha->addl_fw_state);
+ return sysfs_emit(buf, "0x%08X%8X\n", ha->firmware_state,
+ ha->addl_fw_state);
}
static ssize_t
@@ -220,7 +220,7 @@ qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr,
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
+ return sysfs_emit(buf, "0x%04X\n", ha->phy_port_cnt);
}
static ssize_t
@@ -232,7 +232,7 @@ qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr,
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
+ return sysfs_emit(buf, "0x%04X\n", ha->phy_port_num);
}
static ssize_t
@@ -244,7 +244,7 @@ qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr,
if (is_qla40XX(ha))
return -ENOSYS;
- return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
+ return sysfs_emit(buf, "0x%04X\n", ha->iscsi_pci_func_cnt);
}
static ssize_t
@@ -253,7 +253,7 @@ qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr,
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name);
+ return sysfs_emit(buf, "%s\n", ha->model_name);
}
static ssize_t
@@ -261,8 +261,8 @@ qla4xxx_fw_timestamp_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s %s\n", ha->fw_info.fw_build_date,
- ha->fw_info.fw_build_time);
+ return sysfs_emit(buf, "%s %s\n", ha->fw_info.fw_build_date,
+ ha->fw_info.fw_build_time);
}
static ssize_t
@@ -270,7 +270,7 @@ qla4xxx_fw_build_user_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->fw_info.fw_build_user);
+ return sysfs_emit(buf, "%s\n", ha->fw_info.fw_build_user);
}
static ssize_t
@@ -278,7 +278,7 @@ qla4xxx_fw_ext_timestamp_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", ha->fw_info.extended_timestamp);
+ return sysfs_emit(buf, "%s\n", ha->fw_info.extended_timestamp);
}
static ssize_t
@@ -300,7 +300,7 @@ qla4xxx_fw_load_src_show(struct device *dev, struct device_attribute *attr,
break;
}
- return snprintf(buf, PAGE_SIZE, "%s\n", load_src);
+ return sysfs_emit(buf, "%s\n", load_src);
}
static ssize_t
@@ -309,8 +309,8 @@ qla4xxx_fw_uptime_show(struct device *dev, struct device_attribute *attr,
{
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
qla4xxx_about_firmware(ha);
- return snprintf(buf, PAGE_SIZE, "%u.%u secs\n", ha->fw_uptime_secs,
- ha->fw_uptime_msecs);
+ return sysfs_emit(buf, "%u.%u secs\n", ha->fw_uptime_secs,
+ ha->fw_uptime_msecs);
}
static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/scsi_transport_fc.c:1123:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1218:10-18: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1286:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1304:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1665:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1891:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1915:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:1967:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_transport_fc.c:2000:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/scsi_transport_fc.c | 34 ++++++++++++++++----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index b04075f19445..3335c31772e1 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1120,7 +1120,7 @@ show_fc_rport_supported_classes (struct device *dev,
{
struct fc_rport *rport = transport_class_to_rport(dev);
if (rport->supported_classes == FC_COS_UNSPECIFIED)
- return snprintf(buf, 20, "unspecified\n");
+ return sysfs_emit(buf, "unspecified\n");
return get_fc_cos_names(rport->supported_classes, buf);
}
static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO,
@@ -1215,21 +1215,21 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr,
FC_WELLKNOWN_PORTID_MASK) {
switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) {
case FC_FPORT_PORTID:
- return snprintf(buf, 30, "Fabric Port\n");
+ return sysfs_emit(buf, "Fabric Port\n");
case FC_FABCTLR_PORTID:
- return snprintf(buf, 30, "Fabric Controller\n");
+ return sysfs_emit(buf, "Fabric Controller\n");
case FC_DIRSRVR_PORTID:
- return snprintf(buf, 30, "Directory Server\n");
+ return sysfs_emit(buf, "Directory Server\n");
case FC_TIMESRVR_PORTID:
- return snprintf(buf, 30, "Time Server\n");
+ return sysfs_emit(buf, "Time Server\n");
case FC_MGMTSRVR_PORTID:
- return snprintf(buf, 30, "Management Server\n");
+ return sysfs_emit(buf, "Management Server\n");
default:
- return snprintf(buf, 30, "Unknown Fabric Entity\n");
+ return sysfs_emit(buf, "Unknown Fabric Entity\n");
}
} else {
if (rport->roles == FC_PORT_ROLE_UNKNOWN)
- return snprintf(buf, 20, "unknown\n");
+ return sysfs_emit(buf, "unknown\n");
return get_fc_port_roles_names(rport->roles, buf);
}
}
@@ -1283,7 +1283,7 @@ show_fc_rport_port_state(struct device *dev,
if (!name)
return -EINVAL;
- return snprintf(buf, 20, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static FC_DEVICE_ATTR(rport, port_state, 0444 | 0200,
@@ -1301,8 +1301,8 @@ show_fc_rport_fast_io_fail_tmo (struct device *dev,
struct fc_rport *rport = transport_class_to_rport(dev);
if (rport->fast_io_fail_tmo == -1)
- return snprintf(buf, 5, "off\n");
- return snprintf(buf, 20, "%d\n", rport->fast_io_fail_tmo);
+ return sysfs_emit(buf, "off\n");
+ return sysfs_emit(buf, "%d\n", rport->fast_io_fail_tmo);
}
static ssize_t
@@ -1662,7 +1662,7 @@ show_fc_vport_roles (struct device *dev, struct device_attribute *attr,
struct fc_vport *vport = transport_class_to_vport(dev);
if (vport->roles == FC_PORT_ROLE_UNKNOWN)
- return snprintf(buf, 20, "unknown\n");
+ return sysfs_emit(buf, "unknown\n");
return get_fc_port_roles_names(vport->roles, buf);
}
static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL);
@@ -1888,7 +1888,7 @@ show_fc_host_supported_classes (struct device *dev,
struct Scsi_Host *shost = transport_class_to_shost(dev);
if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED)
- return snprintf(buf, 20, "unspecified\n");
+ return sysfs_emit(buf, "unspecified\n");
return get_fc_cos_names(fc_host_supported_classes(shost), buf);
}
@@ -1912,7 +1912,7 @@ show_fc_host_supported_speeds (struct device *dev,
struct Scsi_Host *shost = transport_class_to_shost(dev);
if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN)
- return snprintf(buf, 20, "unknown\n");
+ return sysfs_emit(buf, "unknown\n");
return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf);
}
@@ -1964,7 +1964,7 @@ show_fc_host_speed (struct device *dev,
i->f->get_host_speed(shost);
if (fc_host_speed(shost) == FC_PORTSPEED_UNKNOWN)
- return snprintf(buf, 20, "unknown\n");
+ return sysfs_emit(buf, "unknown\n");
return get_fc_port_speed_names(fc_host_speed(shost), buf);
}
@@ -1997,7 +1997,7 @@ show_fc_private_host_tgtid_bind_type(struct device *dev,
name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost));
if (!name)
return -EINVAL;
- return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
#define get_list_head_entry(pos, head, member) \
@@ -2106,7 +2106,7 @@ fc_stat_show(const struct device *dev, char *buf, unsigned long offset)
if (i->f->get_fc_host_stats) {
stats = (i->f->get_fc_host_stats)(shost);
if (stats)
- ret = snprintf(buf, 20, "0x%llx\n",
+ ret = sysfs_emit(buf, "0x%llx\n",
(unsigned long long)*(u64 *)(((u8 *) stats) + offset));
}
return ret;
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2825:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2850:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2873:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2893:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2912:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2932:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2952:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2971:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2990:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3012:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3034:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3055:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3077:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3097:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3133:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3170:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3198:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3320:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3407:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3828:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3848:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3996:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:4018:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:4056:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Sathya Prakash <[email protected]>
CC: Sreekanth Reddy <[email protected]>
CC: Suganath Prabu Subramani <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/mpt3sas/mpt3sas_ctl.c | 60 +++++++++++++++---------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index efdb8178db32..e7d7408ce773 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -2822,7 +2822,7 @@ version_fw_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
+ return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n",
(ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
(ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
(ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
@@ -2847,7 +2847,7 @@ version_bios_show(struct device *cdev, struct device_attribute *attr,
u32 version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
- return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
+ return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n",
(version & 0xFF000000) >> 24,
(version & 0x00FF0000) >> 16,
(version & 0x0000FF00) >> 8,
@@ -2870,8 +2870,8 @@ version_mpi_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%03x.%02x\n",
- ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8);
+ return sysfs_emit(buf, "%03x.%02x\n",
+ ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8);
}
static DEVICE_ATTR_RO(version_mpi);
@@ -2890,7 +2890,7 @@ version_product_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", ioc->manu_pg0.ChipName);
+ return sysfs_emit(buf, "%s\n", ioc->manu_pg0.ChipName);
}
static DEVICE_ATTR_RO(version_product);
@@ -2909,7 +2909,7 @@ version_nvdata_persistent_show(struct device *cdev,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%08xh\n",
+ return sysfs_emit(buf, "%08xh\n",
le32_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word));
}
static DEVICE_ATTR_RO(version_nvdata_persistent);
@@ -2929,7 +2929,7 @@ version_nvdata_default_show(struct device *cdev, struct device_attribute
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%08xh\n",
+ return sysfs_emit(buf, "%08xh\n",
le32_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word));
}
static DEVICE_ATTR_RO(version_nvdata_default);
@@ -2949,7 +2949,7 @@ board_name_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardName);
+ return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardName);
}
static DEVICE_ATTR_RO(board_name);
@@ -2968,7 +2968,7 @@ board_assembly_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardAssembly);
+ return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardAssembly);
}
static DEVICE_ATTR_RO(board_assembly);
@@ -2987,7 +2987,7 @@ board_tracer_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardTracerNumber);
+ return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardTracerNumber);
}
static DEVICE_ATTR_RO(board_tracer);
@@ -3009,7 +3009,7 @@ io_delay_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
+ return sysfs_emit(buf, "%02d\n", ioc->io_missing_delay);
}
static DEVICE_ATTR_RO(io_delay);
@@ -3031,7 +3031,7 @@ device_delay_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
+ return sysfs_emit(buf, "%02d\n", ioc->device_missing_delay);
}
static DEVICE_ATTR_RO(device_delay);
@@ -3052,7 +3052,7 @@ fw_queue_depth_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->facts.RequestCredit);
+ return sysfs_emit(buf, "%02d\n", ioc->facts.RequestCredit);
}
static DEVICE_ATTR_RO(fw_queue_depth);
@@ -3074,7 +3074,7 @@ host_sas_address_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
+ return sysfs_emit(buf, "0x%016llx\n",
(unsigned long long)ioc->sas_hba.sas_address);
}
static DEVICE_ATTR_RO(host_sas_address);
@@ -3094,7 +3094,7 @@ logging_level_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->logging_level);
+ return sysfs_emit(buf, "%08xh\n", ioc->logging_level);
}
static ssize_t
logging_level_store(struct device *cdev, struct device_attribute *attr,
@@ -3130,7 +3130,7 @@ fwfault_debug_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%d\n", ioc->fwfault_debug);
+ return sysfs_emit(buf, "%d\n", ioc->fwfault_debug);
}
static ssize_t
fwfault_debug_store(struct device *cdev, struct device_attribute *attr,
@@ -3167,7 +3167,7 @@ ioc_reset_count_show(struct device *cdev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%d\n", ioc->ioc_reset_count);
+ return sysfs_emit(buf, "%d\n", ioc->ioc_reset_count);
}
static DEVICE_ATTR_RO(ioc_reset_count);
@@ -3195,7 +3195,7 @@ reply_queue_count_show(struct device *cdev,
else
reply_queue_count = 1;
- return snprintf(buf, PAGE_SIZE, "%d\n", reply_queue_count);
+ return sysfs_emit(buf, "%d\n", reply_queue_count);
}
static DEVICE_ATTR_RO(reply_queue_count);
@@ -3260,7 +3260,7 @@ BRM_status_show(struct device *cdev, struct device_attribute *attr,
/* BRM status is in bit zero of GPIOVal[24] */
backup_rail_monitor_status = le16_to_cpu(io_unit_pg3.GPIOVal[24]);
- rc = snprintf(buf, PAGE_SIZE, "%d\n", (backup_rail_monitor_status & 1));
+ rc = sysfs_emit(buf, "%d\n", (backup_rail_monitor_status & 1));
out:
mutex_unlock(&ioc->pci_access_mutex);
@@ -3317,7 +3317,7 @@ host_trace_buffer_size_show(struct device *cdev,
size = le32_to_cpu(request_data->Size);
ioc->ring_buffer_sz = size;
- return snprintf(buf, PAGE_SIZE, "%d\n", size);
+ return sysfs_emit(buf, "%d\n", size);
}
static DEVICE_ATTR_RO(host_trace_buffer_size);
@@ -3404,12 +3404,12 @@ host_trace_buffer_enable_show(struct device *cdev,
if ((!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) ||
((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
MPT3_DIAG_BUFFER_IS_REGISTERED) == 0))
- return snprintf(buf, PAGE_SIZE, "off\n");
+ return sysfs_emit(buf, "off\n");
else if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] &
MPT3_DIAG_BUFFER_IS_RELEASED))
- return snprintf(buf, PAGE_SIZE, "release\n");
+ return sysfs_emit(buf, "release\n");
else
- return snprintf(buf, PAGE_SIZE, "post\n");
+ return sysfs_emit(buf, "post\n");
}
static ssize_t
@@ -3825,7 +3825,7 @@ drv_support_bitmap_show(struct device *cdev,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap);
+ return sysfs_emit(buf, "0x%08x\n", ioc->drv_support_bitmap);
}
static DEVICE_ATTR_RO(drv_support_bitmap);
@@ -3845,7 +3845,7 @@ enable_sdev_max_qd_show(struct device *cdev,
struct Scsi_Host *shost = class_to_shost(cdev);
struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%d\n", ioc->enable_sdev_max_qd);
+ return sysfs_emit(buf, "%d\n", ioc->enable_sdev_max_qd);
}
/**
@@ -3993,7 +3993,7 @@ sas_address_show(struct device *dev, struct device_attribute *attr,
struct scsi_device *sdev = to_scsi_device(dev);
struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
- return snprintf(buf, PAGE_SIZE, "0x%016llx\n",
+ return sysfs_emit(buf, "0x%016llx\n",
(unsigned long long)sas_device_priv_data->sas_target->sas_address);
}
static DEVICE_ATTR_RO(sas_address);
@@ -4015,8 +4015,8 @@ sas_device_handle_show(struct device *dev, struct device_attribute *attr,
struct scsi_device *sdev = to_scsi_device(dev);
struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
- return snprintf(buf, PAGE_SIZE, "0x%04x\n",
- sas_device_priv_data->sas_target->handle);
+ return sysfs_emit(buf, "0x%04x\n",
+ sas_device_priv_data->sas_target->handle);
}
static DEVICE_ATTR_RO(sas_device_handle);
@@ -4053,8 +4053,8 @@ sas_ncq_prio_enable_show(struct device *dev,
struct scsi_device *sdev = to_scsi_device(dev);
struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata;
- return snprintf(buf, PAGE_SIZE, "%d\n",
- sas_device_priv_data->ncq_prio_enable);
+ return sysfs_emit(buf, "%d\n",
+ sas_device_priv_data->ncq_prio_enable);
}
static ssize_t
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./kernel/cpu.c:3013:8-16: WARNING: please use sysfs_emit
> ./kernel/cpu.c:3026:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Thomas Gleixner <[email protected]>
CC: Peter Zijlstra <[email protected]>
Signed-off-by: Li Zhijian <[email protected]>
---
kernel/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a86972a91991..a36fcf4a9eb6 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3010,7 +3010,7 @@ static ssize_t control_show(struct device *dev,
return sysfs_emit(buf, "%d\n", cpu_smt_num_threads);
#endif
- return snprintf(buf, PAGE_SIZE - 2, "%s\n", state);
+ return sysfs_emit(buf, "%s\n", state);
}
static ssize_t control_store(struct device *dev, struct device_attribute *attr,
@@ -3023,7 +3023,7 @@ static DEVICE_ATTR_RW(control);
static ssize_t active_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active());
+ return sysfs_emit(buf, "%d\n", sched_smt_active());
}
static DEVICE_ATTR_RO(active);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/arcmsr/arcmsr_attr.c:261:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:273:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:285:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:297:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:309:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:322:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:335:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:348:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:361:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/arcmsr/arcmsr_attr.c:374:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/arcmsr/arcmsr_attr.c | 40 ++++++++-----------------------
1 file changed, 10 insertions(+), 30 deletions(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index baeb5e795690..0eecd354a3d0 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -258,9 +258,7 @@ static ssize_t
arcmsr_attr_host_driver_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE,
- "%s\n",
- ARCMSR_DRIVER_VERSION);
+ return sysfs_emit(buf, "%s\n", ARCMSR_DRIVER_VERSION);
}
static ssize_t
@@ -270,9 +268,7 @@ arcmsr_attr_host_driver_posted_cmd(struct device *dev,
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- atomic_read(&acb->ccboutstandingcount));
+ return sysfs_emit(buf, "%4d\n", atomic_read(&acb->ccboutstandingcount));
}
static ssize_t
@@ -282,9 +278,7 @@ arcmsr_attr_host_driver_reset(struct device *dev,
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->num_resets);
+ return sysfs_emit(buf, "%4d\n", acb->num_resets);
}
static ssize_t
@@ -294,9 +288,7 @@ arcmsr_attr_host_driver_abort(struct device *dev,
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->num_aborts);
+ return sysfs_emit(buf, "%4d\n", acb->num_aborts);
}
static ssize_t
@@ -306,9 +298,7 @@ arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%s\n",
- acb->firm_model);
+ return sysfs_emit(buf, "%s\n", acb->firm_model);
}
static ssize_t
@@ -319,9 +309,7 @@ arcmsr_attr_host_fw_version(struct device *dev,
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%s\n",
- acb->firm_version);
+ return sysfs_emit(buf, "%s\n", acb->firm_version);
}
static ssize_t
@@ -332,9 +320,7 @@ arcmsr_attr_host_fw_request_len(struct device *dev,
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->firm_request_len);
+ return sysfs_emit(buf, "%4d\n", acb->firm_request_len);
}
static ssize_t
@@ -345,9 +331,7 @@ arcmsr_attr_host_fw_numbers_queue(struct device *dev,
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->firm_numbers_queue);
+ return sysfs_emit(buf, "%4d\n", acb->firm_numbers_queue);
}
static ssize_t
@@ -358,9 +342,7 @@ arcmsr_attr_host_fw_sdram_size(struct device *dev,
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->firm_sdram_size);
+ return sysfs_emit(buf, "%4d\n", acb->firm_sdram_size);
}
static ssize_t
@@ -371,9 +353,7 @@ arcmsr_attr_host_fw_hd_channels(struct device *dev,
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
- return snprintf(buf, PAGE_SIZE,
- "%4d\n",
- acb->firm_hd_channels);
+ return sysfs_emit(buf, PAGE_SIZE, "%4d\n", acb->firm_hd_channels);
}
static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/myrb.c:1770:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/myrb.c:1889:10-18: WARNING: please use sysfs_emit
> ./drivers/scsi/myrb.c:1906:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/myrb.c:2143:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrb.c:2153:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/myrb.c:2163:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Hannes Reinecke <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/myrb.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index ca2e932dd9b7..06a5e6fb9f99 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1767,7 +1767,7 @@ static ssize_t raid_state_show(struct device *dev,
int ret;
if (!sdev->hostdata)
- return snprintf(buf, 16, "Unknown\n");
+ return sysfs_emit(buf, "Unknown\n");
if (sdev->channel == myrb_logical_channel(sdev->host)) {
struct myrb_ldev_info *ldev_info = sdev->hostdata;
@@ -1775,10 +1775,10 @@ static ssize_t raid_state_show(struct device *dev,
name = myrb_devstate_name(ldev_info->state);
if (name)
- ret = snprintf(buf, 32, "%s\n", name);
+ ret = sysfs_emit(buf, "%s\n", name);
else
- ret = snprintf(buf, 32, "Invalid (%02X)\n",
- ldev_info->state);
+ ret = sysfs_emit(buf, "Invalid (%02X)\n",
+ ldev_info->state);
} else {
struct myrb_pdev_state *pdev_info = sdev->hostdata;
unsigned short status;
@@ -1796,10 +1796,10 @@ static ssize_t raid_state_show(struct device *dev,
else
name = myrb_devstate_name(pdev_info->state);
if (name)
- ret = snprintf(buf, 32, "%s\n", name);
+ ret = sysfs_emit(buf, "%s\n", name);
else
- ret = snprintf(buf, 32, "Invalid (%02X)\n",
- pdev_info->state);
+ ret = sysfs_emit(buf, "Invalid (%02X)\n",
+ pdev_info->state);
}
return ret;
}
@@ -1886,11 +1886,11 @@ static ssize_t raid_level_show(struct device *dev,
name = myrb_raidlevel_name(ldev_info->raid_level);
if (!name)
- return snprintf(buf, 32, "Invalid (%02X)\n",
- ldev_info->state);
- return snprintf(buf, 32, "%s\n", name);
+ return sysfs_emit(buf, "Invalid (%02X)\n",
+ ldev_info->state);
+ return sysfs_emit(buf, "%s\n", name);
}
- return snprintf(buf, 32, "Physical Drive\n");
+ return sysfs_emit(buf, "Physical Drive\n");
}
static DEVICE_ATTR_RO(raid_level);
@@ -1903,17 +1903,17 @@ static ssize_t rebuild_show(struct device *dev,
unsigned char status;
if (sdev->channel < myrb_logical_channel(sdev->host))
- return snprintf(buf, 32, "physical device - not rebuilding\n");
+ return sysfs_emit(buf, "physical device - not rebuilding\n");
status = myrb_get_rbld_progress(cb, &rbld_buf);
if (rbld_buf.ldev_num != sdev->id ||
status != MYRB_STATUS_SUCCESS)
- return snprintf(buf, 32, "not rebuilding\n");
+ return sysfs_emit(buf, "not rebuilding\n");
- return snprintf(buf, 32, "rebuilding block %u of %u\n",
- rbld_buf.ldev_size - rbld_buf.blocks_left,
- rbld_buf.ldev_size);
+ return sysfs_emit(buf, "rebuilding block %u of %u\n",
+ rbld_buf.ldev_size - rbld_buf.blocks_left,
+ rbld_buf.ldev_size);
}
static ssize_t rebuild_store(struct device *dev,
@@ -2140,7 +2140,7 @@ static ssize_t ctlr_num_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrb_hba *cb = shost_priv(shost);
- return snprintf(buf, 20, "%u\n", cb->ctlr_num);
+ return sysfs_emit(buf, "%u\n", cb->ctlr_num);
}
static DEVICE_ATTR_RO(ctlr_num);
@@ -2150,7 +2150,7 @@ static ssize_t firmware_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrb_hba *cb = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", cb->fw_version);
+ return sysfs_emit(buf, "%s\n", cb->fw_version);
}
static DEVICE_ATTR_RO(firmware);
@@ -2160,7 +2160,7 @@ static ssize_t model_show(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct myrb_hba *cb = shost_priv(shost);
- return snprintf(buf, 16, "%s\n", cb->model_name);
+ return sysfs_emit(buf, "%s\n", cb->model_name);
}
static DEVICE_ATTR_RO(model);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/pm8001/pm8001_ctl.c:883:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Jack Wang <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/pm8001/pm8001_ctl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 5c26a13ffbd2..7b27618fd7b2 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -880,9 +880,9 @@ static ssize_t pm8001_show_update_fw(struct device *cdev,
if (pm8001_ha->fw_status != FLASH_IN_PROGRESS)
pm8001_ha->fw_status = FLASH_OK;
- return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
- flash_error_table[i].err_code,
- flash_error_table[i].reason);
+ return sysfs_emit(buf, "status=%x %s\n",
+ flash_error_table[i].err_code,
+ flash_error_table[i].reason);
}
static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
pm8001_show_update_fw, pm8001_store_update_fw);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/scsi_sysfs.c:1112:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:1202:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:231:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:277:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:327:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:385:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:402:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:680:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:689:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:701:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:722:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:858:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:873:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:953:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/scsi_sysfs.c:979:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/scsi_sysfs.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 24f6eefb6803..e82dc010fea0 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -228,7 +228,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
if (!name)
return -EINVAL;
- return snprintf(buf, 20, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
/* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
@@ -274,7 +274,7 @@ show_shost_active_mode(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
if (shost->active_mode == MODE_UNKNOWN)
- return snprintf(buf, 20, "unknown\n");
+ return sysfs_emit(buf, "unknown\n");
else
return show_shost_mode(shost->active_mode, buf);
}
@@ -324,7 +324,7 @@ show_shost_eh_deadline(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
if (shost->eh_deadline == -1)
- return snprintf(buf, strlen("off") + 2, "off\n");
+ return sysfs_emit(buf, "off\n");
return sprintf(buf, "%u\n", shost->eh_deadline / HZ);
}
@@ -382,7 +382,7 @@ static ssize_t
show_host_busy(struct device *dev, struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
- return snprintf(buf, 20, "%d\n", scsi_host_busy(shost));
+ return sysfs_emit(buf, "%d\n", scsi_host_busy(shost));
}
static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL);
@@ -399,7 +399,7 @@ show_nr_hw_queues(struct device *dev, struct device_attribute *attr, char *buf)
struct Scsi_Host *shost = class_to_shost(dev);
struct blk_mq_tag_set *tag_set = &shost->tag_set;
- return snprintf(buf, 20, "%d\n", tag_set->nr_hw_queues);
+ return sysfs_emit(buf, "%d\n", tag_set->nr_hw_queues);
}
static DEVICE_ATTR(nr_hw_queues, S_IRUGO, show_nr_hw_queues, NULL);
@@ -677,7 +677,7 @@ sdev_show_device_busy(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
- return snprintf(buf, 20, "%d\n", scsi_device_busy(sdev));
+ return sysfs_emit(buf, "%d\n", scsi_device_busy(sdev));
}
static DEVICE_ATTR(device_busy, S_IRUGO, sdev_show_device_busy, NULL);
@@ -686,7 +686,7 @@ sdev_show_device_blocked(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
- return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked));
+ return sysfs_emit(buf, "%d\n", atomic_read(&sdev->device_blocked));
}
static DEVICE_ATTR(device_blocked, S_IRUGO, sdev_show_device_blocked, NULL);
@@ -698,7 +698,7 @@ sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev;
sdev = to_scsi_device(dev);
- return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ);
+ return sysfs_emit(buf, "%d\n", sdev->request_queue->rq_timeout / HZ);
}
static ssize_t
@@ -719,7 +719,7 @@ sdev_show_eh_timeout(struct device *dev, struct device_attribute *attr, char *bu
{
struct scsi_device *sdev;
sdev = to_scsi_device(dev);
- return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ);
+ return sysfs_emit(buf, "%u\n", sdev->eh_timeout / HZ);
}
static ssize_t
@@ -855,7 +855,7 @@ show_state_field(struct device *dev, struct device_attribute *attr, char *buf)
if (!name)
return -EINVAL;
- return snprintf(buf, 20, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field);
@@ -870,7 +870,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr,
if (sdev->simple_tags)
name = "simple";
- return snprintf(buf, 20, "%s\n", name);
+ return sysfs_emit(buf, "%s\n", name);
}
static ssize_t
@@ -950,7 +950,7 @@ static ssize_t
show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
+ return sysfs_emit(buf, "%d\n", (int)sizeof(atomic_t) * 8);
}
static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL);
@@ -976,7 +976,7 @@ sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
{
struct scsi_device *sdev;
sdev = to_scsi_device(dev);
- return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
+ return sysfs_emit(buf, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
}
static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
@@ -1109,9 +1109,9 @@ sdev_show_dh_state(struct device *dev, struct device_attribute *attr,
struct scsi_device *sdev = to_scsi_device(dev);
if (!sdev->handler)
- return snprintf(buf, 20, "detached\n");
+ return sysfs_emit(buf, "detached\n");
- return snprintf(buf, 20, "%s\n", sdev->handler->name);
+ return sysfs_emit(buf, "%s\n", sdev->handler->name);
}
static ssize_t
@@ -1199,8 +1199,8 @@ sdev_show_queue_ramp_up_period(struct device *dev,
{
struct scsi_device *sdev;
sdev = to_scsi_device(dev);
- return snprintf(buf, 20, "%u\n",
- jiffies_to_msecs(sdev->queue_ramp_up_period));
+ return sysfs_emit(buf, "%u\n",
+ jiffies_to_msecs(sdev->queue_ramp_up_period));
}
static ssize_t
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/snic/snic_attrs.c:16:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:26:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:35:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/snic/snic_attrs.c:48:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Karan Tilak Kumar <[email protected]>
CC: Sesidhar Baddela <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/snic/snic_attrs.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
index 3ddbdbc3ded1..03921618182d 100644
--- a/drivers/scsi/snic/snic_attrs.c
+++ b/drivers/scsi/snic/snic_attrs.c
@@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev,
{
struct snic *snic = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
+ return sysfs_emit(buf, "%s\n", snic->name);
}
static ssize_t
@@ -23,7 +23,7 @@ snic_show_state(struct device *dev,
{
struct snic *snic = shost_priv(class_to_shost(dev));
- return snprintf(buf, PAGE_SIZE, "%s\n",
+ return sysfs_emit(buf, "%s\n",
snic_state_str[snic_get_state(snic)]);
}
@@ -32,7 +32,7 @@ snic_show_drv_version(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
+ return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
}
static ssize_t
@@ -45,8 +45,8 @@ snic_show_link_state(struct device *dev,
if (snic->config.xpt_type == SNIC_DAS)
snic->link_status = svnic_dev_link_status(snic->vdev);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- (snic->link_status) ? "Link Up" : "Link Down");
+ return sysfs_emit(buf, "%s\n",
+ (snic->link_status) ? "Link Up" : "Link Down");
}
static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/hid/hid-roccat-isku.c:64:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:403:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:412:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:435:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:444:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:454:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kone.c:556:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-koneplus.c:245:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-koneplus.c:312:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kovaplus.c:275:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kovaplus.c:328:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kovaplus.c:337:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kovaplus.c:347:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-kovaplus.c:368:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-pyra.c:286:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-pyra.c:303:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-roccat-pyra.c:324:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Stefan Achatz <[email protected]>
CC: Jiri Kosina <[email protected]>
CC: Benjamin Tissoires <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/hid/hid-roccat-isku.c | 2 +-
drivers/hid/hid-roccat-kone.c | 12 ++++++------
drivers/hid/hid-roccat-koneplus.c | 4 ++--
drivers/hid/hid-roccat-kovaplus.c | 10 +++++-----
drivers/hid/hid-roccat-pyra.c | 6 +++---
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c
index 458060403397..0cd6208fb371 100644
--- a/drivers/hid/hid-roccat-isku.c
+++ b/drivers/hid/hid-roccat-isku.c
@@ -61,7 +61,7 @@ static ssize_t isku_sysfs_show_actual_profile(struct device *dev,
{
struct isku_device *isku =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", isku->actual_profile);
+ return sysfs_emit(buf, "%d\n", isku->actual_profile);
}
static ssize_t isku_sysfs_set_actual_profile(struct device *dev,
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index 00a1abc7e839..3f8f459edcf3 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -400,7 +400,7 @@ static ssize_t kone_sysfs_show_actual_profile(struct device *dev,
{
struct kone_device *kone =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile);
+ return sysfs_emit(buf, "%d\n", kone->actual_profile);
}
static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
@@ -409,7 +409,7 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev,
{
struct kone_device *kone =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi);
+ return sysfs_emit(buf, "%d\n", kone->actual_dpi);
}
static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
@@ -432,7 +432,7 @@ static ssize_t kone_sysfs_show_weight(struct device *dev,
if (retval)
return retval;
- return snprintf(buf, PAGE_SIZE, "%d\n", weight);
+ return sysfs_emit(buf, "%d\n", weight);
}
static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
@@ -441,7 +441,7 @@ static ssize_t kone_sysfs_show_firmware_version(struct device *dev,
{
struct kone_device *kone =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version);
+ return sysfs_emit(buf, "%d\n", kone->firmware_version);
}
static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version,
NULL);
@@ -451,7 +451,7 @@ static ssize_t kone_sysfs_show_tcu(struct device *dev,
{
struct kone_device *kone =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu);
+ return sysfs_emit(buf, "%d\n", kone->settings.tcu);
}
static int kone_tcu_command(struct usb_device *usb_dev, int number)
@@ -553,7 +553,7 @@ static ssize_t kone_sysfs_show_startup_profile(struct device *dev,
{
struct kone_device *kone =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile);
+ return sysfs_emit(buf, "%d\n", kone->settings.startup_profile);
}
static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
index 22b895436a7c..8ccb3b14a1a9 100644
--- a/drivers/hid/hid-roccat-koneplus.c
+++ b/drivers/hid/hid-roccat-koneplus.c
@@ -242,7 +242,7 @@ static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev,
{
struct koneplus_device *koneplus =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile);
+ return sysfs_emit(buf, "%d\n", koneplus->actual_profile);
}
static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
@@ -309,7 +309,7 @@ static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev,
&info, KONEPLUS_SIZE_INFO);
mutex_unlock(&koneplus->koneplus_lock);
- return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
+ return sysfs_emit(buf, "%d\n", info.firmware_version);
}
static DEVICE_ATTR(firmware_version, 0440,
koneplus_sysfs_show_firmware_version, NULL);
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
index 86af538c10d6..748d4d7cb2fc 100644
--- a/drivers/hid/hid-roccat-kovaplus.c
+++ b/drivers/hid/hid-roccat-kovaplus.c
@@ -272,7 +272,7 @@ static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev,
{
struct kovaplus_device *kovaplus =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile);
+ return sysfs_emit(buf, "%d\n", kovaplus->actual_profile);
}
static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev,
@@ -325,7 +325,7 @@ static ssize_t kovaplus_sysfs_show_actual_cpi(struct device *dev,
{
struct kovaplus_device *kovaplus =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi);
+ return sysfs_emit(buf, "%d\n", kovaplus->actual_cpi);
}
static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL);
@@ -334,7 +334,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_x(struct device *dev,
{
struct kovaplus_device *kovaplus =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity);
+ return sysfs_emit(buf, "%d\n", kovaplus->actual_x_sensitivity);
}
static DEVICE_ATTR(actual_sensitivity_x, 0440,
kovaplus_sysfs_show_actual_sensitivity_x, NULL);
@@ -344,7 +344,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_y(struct device *dev,
{
struct kovaplus_device *kovaplus =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity);
+ return sysfs_emit(buf, "%d\n", kovaplus->actual_y_sensitivity);
}
static DEVICE_ATTR(actual_sensitivity_y, 0440,
kovaplus_sysfs_show_actual_sensitivity_y, NULL);
@@ -365,7 +365,7 @@ static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev,
&info, KOVAPLUS_SIZE_INFO);
mutex_unlock(&kovaplus->kovaplus_lock);
- return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
+ return sysfs_emit(buf, "%d\n", info.firmware_version);
}
static DEVICE_ATTR(firmware_version, 0440,
kovaplus_sysfs_show_firmware_version, NULL);
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c
index 5663b9cd9c69..eeb3d38cd805 100644
--- a/drivers/hid/hid-roccat-pyra.c
+++ b/drivers/hid/hid-roccat-pyra.c
@@ -283,7 +283,7 @@ static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev,
{
struct pyra_device *pyra =
hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
- return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi);
+ return sysfs_emit(buf, "%d\n", pyra->actual_cpi);
}
static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
@@ -300,7 +300,7 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev,
&settings, PYRA_SIZE_SETTINGS);
mutex_unlock(&pyra->pyra_lock);
- return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile);
+ return sysfs_emit(buf, "%d\n", settings.startup_profile);
}
static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
@@ -321,7 +321,7 @@ static ssize_t pyra_sysfs_show_firmware_version(struct device *dev,
&info, PYRA_SIZE_INFO);
mutex_unlock(&pyra->pyra_lock);
- return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version);
+ return sysfs_emit(buf, "%d\n", info.firmware_version);
}
static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version,
NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Artur Paszkiewicz <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/isci/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index 6277162a028b..c582a3932cea 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, c
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha);
- return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id);
+ return sysfs_emit(buf, "%d\n", ihost->id);
}
static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/message/fusion/mptscsih.c:3100:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3116:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3132:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3145:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3159:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3173:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3186:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3198:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3211:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3224:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3237:8-16: WARNING: please use sysfs_emit
> ./drivers/message/fusion/mptscsih.c:3250:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Sathya Prakash <[email protected]>
CC: Sreekanth Reddy <[email protected]>
CC: Suganath Prabu Subramani <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/message/fusion/mptscsih.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 9080a73b4ea6..24063b201699 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -3097,7 +3097,7 @@ mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
+ return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n",
(ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
(ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
(ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
@@ -3113,7 +3113,7 @@ mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
+ return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n",
(ioc->biosVersion & 0xFF000000) >> 24,
(ioc->biosVersion & 0x00FF0000) >> 16,
(ioc->biosVersion & 0x0000FF00) >> 8,
@@ -3129,7 +3129,7 @@ mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
+ return sysfs_emit(buf, "%03x\n", ioc->facts.MsgVersion);
}
static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL);
@@ -3142,7 +3142,7 @@ char *buf)
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
+ return sysfs_emit(buf, "%s\n", ioc->prod_name);
}
static DEVICE_ATTR(version_product, S_IRUGO,
mptscsih_version_product_show, NULL);
@@ -3156,8 +3156,7 @@ mptscsih_version_nvdata_persistent_show(struct device *dev,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02xh\n",
- ioc->nvdata_version_persistent);
+ return sysfs_emit(buf, "%02xh\n", ioc->nvdata_version_persistent);
}
static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
mptscsih_version_nvdata_persistent_show, NULL);
@@ -3170,7 +3169,7 @@ mptscsih_version_nvdata_default_show(struct device *dev,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
+ return sysfs_emit(buf, "%02xh\n",ioc->nvdata_version_default);
}
static DEVICE_ATTR(version_nvdata_default, S_IRUGO,
mptscsih_version_nvdata_default_show, NULL);
@@ -3183,7 +3182,7 @@ mptscsih_board_name_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
+ return sysfs_emit(buf, "%s\n", ioc->board_name);
}
static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL);
@@ -3195,7 +3194,7 @@ mptscsih_board_assembly_show(struct device *dev,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
+ return sysfs_emit(buf, "%s\n", ioc->board_assembly);
}
static DEVICE_ATTR(board_assembly, S_IRUGO,
mptscsih_board_assembly_show, NULL);
@@ -3208,7 +3207,7 @@ mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
+ return sysfs_emit(buf, "%s\n", ioc->board_tracer);
}
static DEVICE_ATTR(board_tracer, S_IRUGO,
mptscsih_board_tracer_show, NULL);
@@ -3221,7 +3220,7 @@ mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
+ return sysfs_emit(buf, "%02d\n", ioc->io_missing_delay);
}
static DEVICE_ATTR(io_delay, S_IRUGO,
mptscsih_io_delay_show, NULL);
@@ -3234,7 +3233,7 @@ mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
+ return sysfs_emit(buf, "%02d\n", ioc->device_missing_delay);
}
static DEVICE_ATTR(device_delay, S_IRUGO,
mptscsih_device_delay_show, NULL);
@@ -3247,7 +3246,7 @@ mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr,
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
- return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
+ return sysfs_emit(buf, "%08xh\n", ioc->debug_level);
}
static ssize_t
mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/video/fbdev/uvesafb.c:1549:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Helge Deller <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/video/fbdev/uvesafb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index e1f421e91b4f..73f00c079a94 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1546,7 +1546,7 @@ static ssize_t uvesafb_show_vbe_ver(struct device *dev,
struct fb_info *info = dev_get_drvdata(dev);
struct uvesafb_par *par = info->par;
- return snprintf(buf, PAGE_SIZE, "%.4x\n", par->vbe_ib.vbe_version);
+ return sysfs_emit(buf, "%.4x\n", par->vbe_ib.vbe_version);
}
static DEVICE_ATTR(vbe_version, S_IRUGO, uvesafb_show_vbe_ver, NULL);
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/ncr53c8xx.c:8034:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/ncr53c8xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 35869b4f9329..2bd74620caf5 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -8031,7 +8031,7 @@ static ssize_t show_ncr53c8xx_revision(struct device *dev,
struct Scsi_Host *host = class_to_shost(dev);
struct host_data *host_data = (struct host_data *)host->hostdata;
- return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
+ return sysfs_emit(buf, "0x%x\n", host_data->ncb->revision_id);
}
static struct device_attribute ncr53c8xx_revision_attr = {
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/be2iscsi/be_mgmt.c:1145:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/be2iscsi/be_mgmt.c:1164:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/be2iscsi/be_mgmt.c:1251:9-17: WARNING: please use sysfs_emit
> ./drivers/scsi/be2iscsi/be_mgmt.c:1280:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Ketan Mukadam <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/be2iscsi/be_mgmt.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 4e899ec1477d..35e12e13d580 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -1142,7 +1142,7 @@ ssize_t
beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr,
char *buf)
{
- return snprintf(buf, PAGE_SIZE, BE_NAME "\n");
+ return sysfs_emit(buf, BE_NAME "\n");
}
/**
@@ -1161,7 +1161,7 @@ beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev);
struct beiscsi_hba *phba = iscsi_host_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str);
+ return sysfs_emit(buf, "%s\n", phba->fw_ver_str);
}
/**
@@ -1248,16 +1248,16 @@ beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr,
case BE_DEVICE_ID1:
case OC_DEVICE_ID1:
case OC_DEVICE_ID2:
- return snprintf(buf, PAGE_SIZE,
- "Obsolete/Unsupported BE2 Adapter Family\n");
+ return sysfs_emit(buf,
+ "Obsolete/Unsupported BE2 Adapter Family\n");
case BE_DEVICE_ID2:
case OC_DEVICE_ID3:
- return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n");
+ return sysfs_emit(buf, "BE3-R Adapter Family\n");
case OC_SKH_ID1:
- return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n");
+ return sysfs_emit(buf, "Skyhawk-R Adapter Family\n");
default:
- return snprintf(buf, PAGE_SIZE,
- "Unknown Adapter Family: 0x%x\n", dev_id);
+ return sysfs_emit(buf,
+ "Unknown Adapter Family: 0x%x\n", dev_id);
}
}
@@ -1277,8 +1277,8 @@ beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev);
struct beiscsi_hba *phba = iscsi_host_priv(shost);
- return snprintf(buf, PAGE_SIZE, "Port Identifier : %u\n",
- phba->fw_config.phys_port);
+ return sysfs_emit(buf, "Port Identifier : %u\n",
+ phba->fw_config.phys_port);
}
void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3483:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3493:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3503:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3513:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3522:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3530:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Tyrel Datwyler <[email protected]>
CC: Michael Ellerman <[email protected]>
CC: Nicholas Piggin <[email protected]>
CC: Christophe Leroy <[email protected]>
CC: "Aneesh Kumar K.V" <[email protected]>
CC: "Naveen N. Rao" <[email protected]>
CC: "James E.J. Bottomley" <[email protected]>
CC: "Martin K. Petersen" <[email protected]>
CC: [email protected]
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/scsi/ibmvscsi/ibmvfc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 92c440f2e3a7..4be013976866 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -3480,8 +3480,7 @@ static ssize_t ibmvfc_show_host_partition_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.partition_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.partition_name);
}
static ssize_t ibmvfc_show_host_device_name(struct device *dev,
@@ -3490,8 +3489,7 @@ static ssize_t ibmvfc_show_host_device_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.device_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.device_name);
}
static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
@@ -3500,8 +3498,7 @@ static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.port_loc_code);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.port_loc_code);
}
static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
@@ -3510,8 +3507,7 @@ static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.drc_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.drc_name);
}
static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
@@ -3519,7 +3515,8 @@ static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%d\n", be32_to_cpu(vhost->login_buf->resp.version));
+ return sysfs_emit(buf, "%d\n",
+ be32_to_cpu(vhost->login_buf->resp.version));
}
static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
@@ -3527,7 +3524,8 @@ static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities));
+ return sysfs_emit(buf, "%llx\n",
+ be64_to_cpu(vhost->login_buf->resp.capabilities));
}
/**
@@ -3548,7 +3546,7 @@ static ssize_t ibmvfc_show_log_level(struct device *dev,
int len;
spin_lock_irqsave(shost->host_lock, flags);
- len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->log_level);
+ len = sysfs_emit(buf, "%d\n", vhost->log_level);
spin_unlock_irqrestore(shost->host_lock, flags);
return len;
}
@@ -3587,7 +3585,7 @@ static ssize_t ibmvfc_show_scsi_channels(struct device *dev,
int len;
spin_lock_irqsave(shost->host_lock, flags);
- len = snprintf(buf, PAGE_SIZE, "%d\n", scsi->desired_queues);
+ len = sysfs_emit(buf, "%d\n", scsi->desired_queues);
spin_unlock_irqrestore(shost->host_lock, flags);
return len;
}
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/hid/hid-lenovo.c:558:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:602:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:792:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:822:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:852:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:882:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:912:8-16: WARNING: please use sysfs_emit
> ./drivers/hid/hid-lenovo.c:941:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Jiri Kosina <[email protected]>
CC: Benjamin Tissoires <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/hid/hid-lenovo.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 149a3c74346b..26768c319361 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -555,7 +555,7 @@ static ssize_t attr_fn_lock_show(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock);
+ return sysfs_emit(buf, "%u\n", data->fn_lock);
}
static ssize_t attr_fn_lock_store(struct device *dev,
@@ -599,8 +599,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n",
- cptkbd_data->sensitivity);
+ return sysfs_emit(buf, "%u\n", cptkbd_data->sensitivity);
}
static ssize_t attr_sensitivity_store_cptkbd(struct device *dev,
@@ -789,7 +788,7 @@ static ssize_t attr_press_to_select_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select);
+ return sysfs_emit(buf, "%u\n", data_pointer->press_to_select);
}
static ssize_t attr_press_to_select_store_tpkbd(struct device *dev,
@@ -819,7 +818,7 @@ static ssize_t attr_dragging_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging);
+ return sysfs_emit(buf, "%u\n", data_pointer->dragging);
}
static ssize_t attr_dragging_store_tpkbd(struct device *dev,
@@ -849,7 +848,7 @@ static ssize_t attr_release_to_select_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select);
+ return sysfs_emit(buf, "%u\n", data_pointer->release_to_select);
}
static ssize_t attr_release_to_select_store_tpkbd(struct device *dev,
@@ -879,7 +878,7 @@ static ssize_t attr_select_right_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right);
+ return sysfs_emit(buf, "%u\n", data_pointer->select_right);
}
static ssize_t attr_select_right_store_tpkbd(struct device *dev,
@@ -909,8 +908,7 @@ static ssize_t attr_sensitivity_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n",
- data_pointer->sensitivity);
+ return sysfs_emit(buf, "%u\n", data_pointer->sensitivity);
}
static ssize_t attr_sensitivity_store_tpkbd(struct device *dev,
@@ -938,8 +936,7 @@ static ssize_t attr_press_speed_show_tpkbd(struct device *dev,
struct hid_device *hdev = to_hid_device(dev);
struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev);
- return snprintf(buf, PAGE_SIZE, "%u\n",
- data_pointer->press_speed);
+ return sysfs_emit(buf, "%u\n", data_pointer->press_speed);
}
static ssize_t attr_press_speed_store_tpkbd(struct device *dev,
--
2.29.2
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
> ./drivers/edac/edac_mc_sysfs.c:210:8-16: WARNING: please use sysfs_emit
> ./drivers/edac/edac_mc_sysfs.c:518:8-16: WARNING: please use sysfs_emit
No functional change intended
CC: Borislav Petkov <[email protected]>
CC: Tony Luck <[email protected]>
CC: James Morse <[email protected]>
CC: Mauro Carvalho Chehab <[email protected]>
CC: Robert Richter <[email protected]>
CC: [email protected]
Signed-off-by: Li Zhijian <[email protected]>
---
drivers/edac/edac_mc_sysfs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 5116873c3330..6ee5030c7207 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -207,8 +207,7 @@ static ssize_t channel_dimm_label_show(struct device *dev,
if (!rank->dimm->label[0])
return 0;
- return snprintf(data, sizeof(rank->dimm->label) + 1, "%s\n",
- rank->dimm->label);
+ return sysfs_emit(data, "%s\n", rank->dimm->label);
}
static ssize_t channel_dimm_label_store(struct device *dev,
@@ -515,7 +514,7 @@ static ssize_t dimmdev_label_show(struct device *dev,
if (!dimm->label[0])
return 0;
- return snprintf(data, sizeof(dimm->label) + 1, "%s\n", dimm->label);
+ return sysfs_emit(data, "%s\n", dimm->label);
}
static ssize_t dimmdev_label_store(struct device *dev,
--
2.29.2
On Tue, 16 Jan, 2024 12:51:24 +0800 Li Zhijian <[email protected]> wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Richard Cochran <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> drivers/ptp/ptp_sysfs.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index f7a499a1bd39..49737ed6ef5f 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev,
> {
> struct ptp_clock *ptp = dev_get_drvdata(dev);
>
> - return snprintf(page, PAGE_SIZE - 1, "%d\n",
> - ptp->info->getmaxphase(ptp->info));
> + return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info));
> }
> static DEVICE_ATTR_RO(max_phase_adjustment);
I authored the lines that are being changed here, so figured I should
provide my review. Doesn't PTP_SHOW_INT in the same file also use
snprintf in the same manner and should be changed to sysfs_emit?
--
Thanks,
Rahul Rameshbabu
On Tue, Jan 16, 2024 at 5:52 AM Li Zhijian <[email protected]> wrote:
>
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
> > ./drivers/scsi/pm8001/pm8001_ctl.c:883:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Jack Wang <[email protected]>
> CC: "James E.J. Bottomley" <[email protected]>
> CC: "Martin K. Petersen" <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
Acked-by: Jack Wang <[email protected]>
> ---
> drivers/scsi/pm8001/pm8001_ctl.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index 5c26a13ffbd2..7b27618fd7b2 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -880,9 +880,9 @@ static ssize_t pm8001_show_update_fw(struct device *cdev,
> if (pm8001_ha->fw_status != FLASH_IN_PROGRESS)
> pm8001_ha->fw_status = FLASH_OK;
>
> - return snprintf(buf, PAGE_SIZE, "status=%x %s\n",
> - flash_error_table[i].err_code,
> - flash_error_table[i].reason);
> + return sysfs_emit(buf, "status=%x %s\n",
> + flash_error_table[i].err_code,
> + flash_error_table[i].reason);
> }
> static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
> pm8001_show_update_fw, pm8001_store_update_fw);
> --
> 2.29.2
>
On 16/01/2024 13:01, Rahul Rameshbabu wrote:
> On Tue, 16 Jan, 2024 12:51:24 +0800 Li Zhijian <[email protected]> wrote:
>> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
>> or sysfs_emit_at() when formatting the value to be returned to user space.
>>
>> coccinelle complains that there are still a couple of functions that use
>> snprintf(). Convert them to sysfs_emit().
>>
>>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
>>
>> No functional change intended
>>
>> CC: Richard Cochran <[email protected]>
>> CC: [email protected]
>> Signed-off-by: Li Zhijian <[email protected]>
>> ---
>> drivers/ptp/ptp_sysfs.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
>> index f7a499a1bd39..49737ed6ef5f 100644
>> --- a/drivers/ptp/ptp_sysfs.c
>> +++ b/drivers/ptp/ptp_sysfs.c
>> @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev,
>> {
>> struct ptp_clock *ptp = dev_get_drvdata(dev);
>>
>> - return snprintf(page, PAGE_SIZE - 1, "%d\n",
>> - ptp->info->getmaxphase(ptp->info));
>> + return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info));
>> }
>> static DEVICE_ATTR_RO(max_phase_adjustment);
>
> I authored the lines that are being changed here, so figured I should
> provide my review. Doesn't PTP_SHOW_INT in the same file also use
> snprintf in the same manner and should be changed to sysfs_emit?
Thanks for you review.
Yes, i think so, beside PTP_SHOW_INT, there are 3 other places not detected by coccinelle should be fixed.
I will update it in V2.
$ grep snprintf drivers/ptp/ptp_sysfs.c
return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->var); \
cnt = snprintf(page, PAGE_SIZE, "%u %lld %u\n",
size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->n_vclocks);
size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->max_vclocks);
Thanks
Zhijian
>
> --
> Thanks,
>
> Rahul Rameshbabu
On 16/01/24 06:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./arch/x86/events/core.c:1895:11-19: WARNING: please use sysfs_emit
>> ./arch/x86/events/core.c:2542:8-16: WARNING: please use sysfs_emit
>> ./arch/x86/events/core.c:2600:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Peter Zijlstra <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Arnaldo Carvalho de Melo <[email protected]>
> CC: Mark Rutland <[email protected]>
> CC: Alexander Shishkin <[email protected]>
> CC: Jiri Olsa <[email protected]>
> CC: Namhyung Kim <[email protected]>
> CC: Ian Rogers <[email protected]>
> CC: Adrian Hunter <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> CC: Borislav Petkov <[email protected]>
> CC: Dave Hansen <[email protected]>
> CC: [email protected]
> CC: "H. Peter Anvin" <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> arch/x86/events/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 40ad1425ffa2..52e5707be03b 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -1892,7 +1892,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
> if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) {
> next_str = strchr(str, ';');
> if (next_str)
> - return snprintf(page, next_str - str + 1, "%s", str);
> + return sysfs_emit(page, "%s", str);
The intention seems to be to print only up to, and not including, the next ';',
but sysfs_emit() is not going to do that.
> else
> return sprintf(page, "%s", str);
> }
> @@ -2539,7 +2539,7 @@ static ssize_t get_attr_rdpmc(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, 40, "%d\n", x86_pmu.attr_rdpmc);
> + return sysfs_emit(buf, "%d\n", x86_pmu.attr_rdpmc);
> }
>
> static ssize_t set_attr_rdpmc(struct device *cdev,
> @@ -2597,7 +2597,7 @@ static ssize_t max_precise_show(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu_max_precise());
> + return sysfs_emit(buf, "%d\n", x86_pmu_max_precise());
> }
>
> static DEVICE_ATTR_RO(max_precise);
On 1/16/24 05:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Artur Paszkiewicz <[email protected]>
> CC: "James E.J. Bottomley" <[email protected]>
> CC: "Martin K. Petersen" <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
Reviewed-by: Artur Paszkiewicz <[email protected]>
Adrian,
On 16/01/2024 15:01, Adrian Hunter wrote:
>> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
>> index 40ad1425ffa2..52e5707be03b 100644
>> --- a/arch/x86/events/core.c
>> +++ b/arch/x86/events/core.c
>> @@ -1892,7 +1892,7 @@ ssize_t events_hybrid_sysfs_show(struct device *dev,
>> if (x86_pmu.hybrid_pmu[i].pmu_type & pmu->pmu_type) {
>> next_str = strchr(str, ';');
>> if (next_str)
>> - return snprintf(page, next_str - str + 1, "%s", str);
>> + return sysfs_emit(page, "%s", str);
> The intention seems to be to print only up to, and not including, the next ';',
> but sysfs_emit() is not going to do that.
Indeed, it intend to print a sub-string only, this conversion was wrong.
Let's leave it alone
On Tue, 16 Jan 2024 12:51:24 +0800 Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
> > ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
If the patches don't depend on each other please post them separately.
Series should only be used if there are dependencies and the same
maintainer is expected to apply all patches.
The ptp change should be reposted after the merge window, we don't take
cleanups during the merge window.
On 1/15/24 20:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3619:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3625:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3633:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Michael Cyr <[email protected]>
> CC: "James E.J. Bottomley" <[email protected]>
> CC: "Martin K. Petersen" <[email protected]>
> CC: [email protected]
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
Acked-by: Tyrel Datwyler <[email protected]>
On 1/15/24 20:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3483:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3493:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3503:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3513:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3522:8-16: WARNING: please use sysfs_emit
>> ./drivers/scsi/ibmvscsi/ibmvfc.c:3530:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Tyrel Datwyler <[email protected]>
> CC: Michael Ellerman <[email protected]>
> CC: Nicholas Piggin <[email protected]>
> CC: Christophe Leroy <[email protected]>
> CC: "Aneesh Kumar K.V" <[email protected]>
> CC: "Naveen N. Rao" <[email protected]>
> CC: "James E.J. Bottomley" <[email protected]>
> CC: "Martin K. Petersen" <[email protected]>
> CC: [email protected]
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
Acked-by: Tyrel Datwyler <[email protected]>
Jakub,
On 16/01/2024 23:33, Jakub Kicinski wrote:
> On Tue, 16 Jan 2024 12:51:24 +0800 Li Zhijian wrote:
>> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
>> or sysfs_emit_at() when formatting the value to be returned to user space.
>>
>> coccinelle complains that there are still a couple of functions that use
>> snprintf(). Convert them to sysfs_emit().
>>
>>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit
>
> If the patches don't depend on each other please post them separately.
> Series should only be used if there are dependencies and the same
> maintainer is expected to apply all patches>
> The ptp change should be reposted after the merge window, we don't take
> cleanups during the merge window.
Understood. i will split them per subsystem/maintainer and repost them
separately after the merge window.
Thanks
Zhijian
(Grouping them into the same set helped us have an overview of this warning.)
On 1/15/24 22:51, Li Zhijian wrote:
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
>> ./drivers/fsi/fsi-master-ast-cf.c:1086:8-16: WARNING: please use sysfs_emit
>> ./drivers/fsi/fsi-master-gpio.c:721:8-16: WARNING: please use sysfs_emit
> No functional change intended
Thanks!
Reviewed-by: Eddie James <[email protected]>
>
> CC: Jeremy Kerr <[email protected]>
> CC: Joel Stanley <[email protected]>
> CC: Alistar Popple <[email protected]>
> CC: Eddie James <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> drivers/fsi/fsi-master-ast-cf.c | 3 +--
> drivers/fsi/fsi-master-gpio.c | 3 +--
> 2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
> index 812dfa9a9140..5740b2d9dace 100644
> --- a/drivers/fsi/fsi-master-ast-cf.c
> +++ b/drivers/fsi/fsi-master-ast-cf.c
> @@ -1083,8 +1083,7 @@ static ssize_t external_mode_show(struct device *dev,
> {
> struct fsi_master_acf *master = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> - master->external_mode ? 1 : 0);
> + return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
> }
>
> static ssize_t external_mode_store(struct device *dev,
> diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
> index ed03da4f2447..286fe1cddf99 100644
> --- a/drivers/fsi/fsi-master-gpio.c
> +++ b/drivers/fsi/fsi-master-gpio.c
> @@ -718,8 +718,7 @@ static ssize_t external_mode_show(struct device *dev,
> {
> struct fsi_master_gpio *master = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> - master->external_mode ? 1 : 0);
> + return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);
> }
>
> static ssize_t external_mode_store(struct device *dev,
On Monday, January 15, 2024 8:52 PM, Li Zhijian <[email protected]> wrote:
>
> Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit().
>
> > ./drivers/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: please use
> > sysfs_emit
> > ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use
> > sysfs_emit
> > ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use
> > sysfs_emit
>
> No functional change intended
>
> CC: Satish Kharat <[email protected]>
> CC: Sesidhar Baddela <[email protected]>
> CC: Karan Tilak Kumar <[email protected]>
> CC: "James E.J. Bottomley" <[email protected]>
> CC: "Martin K. Petersen" <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> drivers/scsi/fnic/fnic_attrs.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c index a61e0c5e6506..0c5e57c7e322 100644
> --- a/drivers/scsi/fnic/fnic_attrs.c
> +++ b/drivers/scsi/fnic/fnic_attrs.c
> @@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev,
> struct fc_lport *lp = shost_priv(class_to_shost(dev));
> struct fnic *fnic = lport_priv(lp);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]);
> + return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]);
> }
>
> static ssize_t fnic_show_drv_version(struct device *dev,
> struct device_attribute *attr, char *buf) {
> - return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
> + return sysfs_emit(buf, "%s\n", DRV_VERSION);
> }
>
> static ssize_t fnic_show_link_state(struct device *dev, @@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev, {
> struct fc_lport *lp = shost_priv(class_to_shost(dev));
>
> - return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up)
> - ? "Link Up" : "Link Down");
> + return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link
> +Down");
> }
>
> static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
> --
> 2.29.2
>
>
Looks good to me.
Reviewed-by: Karan Tilak Kumar <[email protected]>
Regards,
Karan
Hello,
On Mon, Jan 15, 2024 at 8:53 PM Li Zhijian <[email protected]> wrote:
>
> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
> > ./arch/x86/events/intel/core.c:5496:8-16: WARNING: please use sysfs_emit
> > ./arch/x86/events/intel/core.c:5530:8-16: WARNING: please use sysfs_emit
> > ./arch/x86/events/intel/core.c:5546:8-16: WARNING: please use sysfs_emit
> > ./arch/x86/events/intel/pt.c:99:8-16: WARNING: please use sysfs_emit
>
> No functional change intended
>
> CC: Peter Zijlstra <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Arnaldo Carvalho de Melo <[email protected]>
> CC: Mark Rutland <[email protected]>
> CC: Alexander Shishkin <[email protected]>
> CC: Jiri Olsa <[email protected]>
> CC: Namhyung Kim <[email protected]>
> CC: Ian Rogers <[email protected]>
> CC: Adrian Hunter <[email protected]>
> CC: Thomas Gleixner <[email protected]>
> CC: Borislav Petkov <[email protected]>
> CC: Dave Hansen <[email protected]>
> CC: [email protected]
> CC: "H. Peter Anvin" <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> arch/x86/events/intel/core.c | 6 +++---
> arch/x86/events/intel/pt.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
> index 0f2786d4e405..aa5fa64a923b 100644
> --- a/arch/x86/events/intel/core.c
> +++ b/arch/x86/events/intel/core.c
> @@ -5493,7 +5493,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
> + return sysfs_emit(buf, "%d\n", allow_tsx_force_abort);
I guess the size doesn't matter here..
Anyway there's freeze_on_smi_show() even uses sprintf().
Thanks,
Namhyung
> }
>
> static ssize_t set_sysctl_tfa(struct device *cdev,
> @@ -5527,7 +5527,7 @@ static ssize_t branches_show(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
> + return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
> }
>
> static DEVICE_ATTR_RO(branches);
> @@ -5543,7 +5543,7 @@ static ssize_t pmu_name_show(struct device *cdev,
> struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str);
> + return sysfs_emit(buf, "%s\n", pmu_name_str);
> }
>
> static DEVICE_ATTR_RO(pmu_name);
> diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
> index 8e2a12235e62..30bba5f3a840 100644
> --- a/arch/x86/events/intel/pt.c
> +++ b/arch/x86/events/intel/pt.c
> @@ -96,7 +96,7 @@ static ssize_t pt_cap_show(struct device *cdev,
> container_of(attr, struct dev_ext_attribute, attr);
> enum pt_capabilities cap = (long)ea->var;
>
> - return snprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap));
> + return sysfs_emit(buf, "%x\n", intel_pt_validate_hw_cap(cap));
> }
>
> static struct attribute_group pt_cap_group __ro_after_init = {
> --
> 2.29.2
>
On 20/01/2024 06:00, Namhyung Kim wrote:
> Hello,
>
> On Mon, Jan 15, 2024 at 8:53 PM Li Zhijian <[email protected]> wrote:
>>
>> Per filesystems/sysfs.rst, show() should only use sysfs_emit()
>> or sysfs_emit_at() when formatting the value to be returned to user space.
>>
>> coccinelle complains that there are still a couple of functions that use
>> snprintf(). Convert them to sysfs_emit().
>>
>>> ./arch/x86/events/intel/core.c:5496:8-16: WARNING: please use sysfs_emit
>>> ./arch/x86/events/intel/core.c:5530:8-16: WARNING: please use sysfs_emit
>>> ./arch/x86/events/intel/core.c:5546:8-16: WARNING: please use sysfs_emit
>>> ./arch/x86/events/intel/pt.c:99:8-16: WARNING: please use sysfs_emit
>>
>> No functional change intended
>>
>> CC: Peter Zijlstra <[email protected]>
>> CC: Ingo Molnar <[email protected]>
>> CC: Arnaldo Carvalho de Melo <[email protected]>
>> CC: Mark Rutland <[email protected]>
>> CC: Alexander Shishkin <[email protected]>
>> CC: Jiri Olsa <[email protected]>
>> CC: Namhyung Kim <[email protected]>
>> CC: Ian Rogers <[email protected]>
>> CC: Adrian Hunter <[email protected]>
>> CC: Thomas Gleixner <[email protected]>
>> CC: Borislav Petkov <[email protected]>
>> CC: Dave Hansen <[email protected]>
>> CC: [email protected]
>> CC: "H. Peter Anvin" <[email protected]>
>> CC: [email protected]
>> Signed-off-by: Li Zhijian <[email protected]>
>> ---
>> arch/x86/events/intel/core.c | 6 +++---
>> arch/x86/events/intel/pt.c | 2 +-
>> 2 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
>> index 0f2786d4e405..aa5fa64a923b 100644
>> --- a/arch/x86/events/intel/core.c
>> +++ b/arch/x86/events/intel/core.c
>> @@ -5493,7 +5493,7 @@ static ssize_t show_sysctl_tfa(struct device *cdev,
>> struct device_attribute *attr,
>> char *buf)
>> {
>> - return snprintf(buf, 40, "%d\n", allow_tsx_force_abort);
>> + return sysfs_emit(buf, "%d\n", allow_tsx_force_abort);
>
> I guess the size doesn't matter here..
Indeed, it doesn't matter. But the kernel has already formed a unified convention
(see filesystems/sysfs.rst), and we also have static tools to check this issue.
This fix can both make it compliant with convention and eliminate warnings complained
by the coccinelle.
So I hope that the community can accept these fixes to make all source code
consistent and beautiful.
(2 abused cases were newly introduced in 6.8 merge windows)
>
> Anyway there's freeze_on_smi_show() even uses sprintf().
Yes, there are still several places using sprintf() which should also convert
to sysfs_emit IMHO. They are alreay in TODOs(see the cover letter). I plan to fix
them in another set if this set goes smoothly.
Thanks
Zhijian
>
> Thanks,
> Namhyung
>
>> }
>>
>> static ssize_t set_sysctl_tfa(struct device *cdev,
>> @@ -5527,7 +5527,7 @@ static ssize_t branches_show(struct device *cdev,
>> struct device_attribute *attr,
>> char *buf)
>> {
>> - return snprintf(buf, PAGE_SIZE, "%d\n", x86_pmu.lbr_nr);
>> + return sysfs_emit(buf, "%d\n", x86_pmu.lbr_nr);
>> }
>>
>> static DEVICE_ATTR_RO(branches);
>> @@ -5543,7 +5543,7 @@ static ssize_t pmu_name_show(struct device *cdev,
>> struct device_attribute *attr,
>> char *buf)
>> {
>> - return snprintf(buf, PAGE_SIZE, "%s\n", pmu_name_str);
>> + return sysfs_emit(buf, "%s\n", pmu_name_str);
>> }
>>
>> static DEVICE_ATTR_RO(pmu_name);
>> diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
>> index 8e2a12235e62..30bba5f3a840 100644
>> --- a/arch/x86/events/intel/pt.c
>> +++ b/arch/x86/events/intel/pt.c
>> @@ -96,7 +96,7 @@ static ssize_t pt_cap_show(struct device *cdev,
>> container_of(attr, struct dev_ext_attribute, attr);
>> enum pt_capabilities cap = (long)ea->var;
>>
>> - return snprintf(buf, PAGE_SIZE, "%x\n", intel_pt_validate_hw_cap(cap));
>> + return sysfs_emit(buf, "%x\n", intel_pt_validate_hw_cap(cap));
>> }
>>
>> static struct attribute_group pt_cap_group __ro_after_init = {
>> --
>> 2.29.2
>>
The following commit has been merged into the smp/core branch of tip:
Commit-ID: effe6d278e06f85289b6ada0402a6d16ebc149a5
Gitweb: https://git.kernel.org/tip/effe6d278e06f85289b6ada0402a6d16ebc149a5
Author: Li Zhijian <[email protected]>
AuthorDate: Tue, 16 Jan 2024 12:51:51 +08:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Fri, 26 Jan 2024 18:25:16 +01:00
kernel/cpu: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.
coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().
No functional change intended.
Signed-off-by: Li Zhijian <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
kernel/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f059375..ad7d0b0 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -3004,7 +3004,7 @@ static ssize_t control_show(struct device *dev,
return sysfs_emit(buf, "%d\n", cpu_smt_num_threads);
#endif
- return snprintf(buf, PAGE_SIZE - 2, "%s\n", state);
+ return sysfs_emit(buf, "%s\n", state);
}
static ssize_t control_store(struct device *dev, struct device_attribute *attr,
@@ -3017,7 +3017,7 @@ static DEVICE_ATTR_RW(control);
static ssize_t active_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active());
+ return sysfs_emit(buf, "%d\n", sched_smt_active());
}
static DEVICE_ATTR_RO(active);
On Tue, 16 Jan 2024 12:10:47 +0800, Li Zhijian wrote:
> make coccicheck COCCI=$PWD/scripts/coccinelle/api/device_attr_show.cocci`
> complians some warnnings as following[1]:
>
> Not sure if someone had tried these fixes, feel free to ignore this
> patch set if we have come to a *NOT-FIX* conclusion before :)
>
> This patch set also fix a few snprintf() beside coccicheck reported.
> For example, some thing like
> xxx_show() {
> rc = snprintf();
> ...
> return rc;
> }
>
> [...]
Applied to 6.9/scsi-queue, thanks!
[22/42] drivers/scsi/fnic: Convert snprintf to sysfs_emit
https://git.kernel.org/mkp/scsi/c/1ad717c92925
[25/42] drivers/scsi/ibmvscsi: Convert snprintf to sysfs_emit
https://git.kernel.org/mkp/scsi/c/29ff822f466e
[26/42] drivers/scsi/ibmvscsi_tgt: Convert snprintf to sysfs_emit
https://git.kernel.org/mkp/scsi/c/01105c23de42
[27/42] drivers/scsi/isci: Convert snprintf to sysfs_emit
https://git.kernel.org/mkp/scsi/c/5fbf37e53091
[34/42] drivers/scsi/pm8001: Convert snprintf to sysfs_emit
https://git.kernel.org/mkp/scsi/c/8179041f801d
--
Martin K. Petersen Oracle Linux Engineering
Hi Li,
While only looking for the snprintf() in your coccinelle analysis you
probably also want to look for sprintf() (see e.g. else clause in
hid-sensor-custom.c and scnprintf() (see picolcd_fb_update_rate_show
in hid-picolcd_fb.c) to replace more s*printf() calls with sysfs_emit*
variants.
diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
index d726aaafb146..03074d25d662 100644
--- a/drivers/hid/hid-picolcd_fb.c
+++ b/drivers/hid/hid-picolcd_fb.c
@@ -459,9 +459,9 @@ static ssize_t picolcd_fb_update_rate_show(struct device *dev,
if (ret >= PAGE_SIZE)
break;
else if (i == fb_update_rate)
- ret += scnprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
+ ret += sysfs_emit_at(buf, ret, "[%u] ", i);
else
- ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
+ ret += sysfs_emit_at(buf, ret, "%u ", i);
if (ret > 0)
buf[min(ret, (size_t)PAGE_SIZE)-1] = '\n';
return ret;
For hid-picolcd-*.c,
Acked-by: Bruno Prémont <[email protected]>
but preferably with the scnprintf() case is covered too.
Cheers,
Bruno
On Tue, 16 Jan 2024 12:51:20 +0800 Li Zhijian wrote:
> Per Documentation/filesystems/sysfs.rst, show() should only use sysfs_emit()
> or sysfs_emit_at() when formatting the value to be returned to user space.
>
> coccinelle complains that there are still a couple of functions that use
> snprintf(). Convert them to sysfs_emit().
>
> > ./drivers/hid/hid-picolcd_core.c:259:9-17: WARNING: please use sysfs_emit
> > ./drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: please use sysfs_emit
> > ./drivers/hid/hid-sensor-custom.c:375:10-18: WARNING: please use sysfs_emi
>
> No functional change intended
>
> CC: "Bruno Prémont" <[email protected]>
> CC: Jiri Kosina <[email protected]>
> CC: Benjamin Tissoires <[email protected]>
> CC: Jonathan Cameron <[email protected]>
> CC: Srinivas Pandruvada <[email protected]>
> CC: [email protected]
> Signed-off-by: Li Zhijian <[email protected]>
> ---
> drivers/hid/hid-picolcd_core.c | 6 +++---
> drivers/hid/hid-sensor-custom.c | 3 +--
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
> index bbda231a7ce3..fa46fb6eab3f 100644
> --- a/drivers/hid/hid-picolcd_core.c
> +++ b/drivers/hid/hid-picolcd_core.c
> @@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_show(struct device *dev,
> struct picolcd_data *data = dev_get_drvdata(dev);
>
> if (data->status & PICOLCD_BOOTLOADER)
> - return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n");
> + return sysfs_emit(buf, "[bootloader] lcd\n");
> else
> - return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n");
> + return sysfs_emit(buf, "bootloader [lcd]\n");
> }
>
> static ssize_t picolcd_operation_mode_store(struct device *dev,
> @@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_delay_show(struct device *dev,
> {
> struct picolcd_data *data = dev_get_drvdata(dev);
>
> - return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay);
> + return sysfs_emit(buf, "%hu\n", data->opmode_delay);
> }
>
> static ssize_t picolcd_operation_mode_delay_store(struct device *dev,
> diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
> index d85398721659..4fe8dccf671d 100644
> --- a/drivers/hid/hid-sensor-custom.c
> +++ b/drivers/hid/hid-sensor-custom.c
> @@ -372,8 +372,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
> sizeof(struct hid_custom_usage_desc),
> usage_id_cmp);
> if (usage_desc)
> - return snprintf(buf, PAGE_SIZE, "%s\n",
> - usage_desc->desc);
> + return sysfs_emit(buf, "%s\n", usage_desc->desc);
> else
> return sprintf(buf, "not-specified\n");
Shouldn't the sprintf() in the else clause be replaced as well?
> } else
on 2/25/2024 12:59 AM, Bruno Prémont wrote:
> Hi Li,
>
> While only looking for the snprintf() in your coccinelle analysis you
> probably also want to look for sprintf() (see e.g. else clause in
> hid-sensor-custom.c and scnprintf() (see picolcd_fb_update_rate_show
> in hid-picolcd_fb.c) to replace more s*printf() calls with sysfs_emit*
> variants.
Yeah, previously, i intended to do the conversion for the files
reported by coccinelle(snprintf() only),
Think more, I should consider the whole s*printf() family for these
files at the same time.
This will be done in V2.
Thanks
Li, Zhijian
>
>
>
> diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
> index d726aaafb146..03074d25d662 100644
> --- a/drivers/hid/hid-picolcd_fb.c
> +++ b/drivers/hid/hid-picolcd_fb.c
> @@ -459,9 +459,9 @@ static ssize_t picolcd_fb_update_rate_show(struct device *dev,
> if (ret >= PAGE_SIZE)
> break;
> else if (i == fb_update_rate)
> - ret += scnprintf(buf+ret, PAGE_SIZE-ret, "[%u] ", i);
> + ret += sysfs_emit_at(buf, ret, "[%u] ", i);
> else
> - ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%u ", i);
> + ret += sysfs_emit_at(buf, ret, "%u ", i);
> if (ret > 0)
> buf[min(ret, (size_t)PAGE_SIZE)-1] = '\n';
> return ret;
>
>
> For hid-picolcd-*.c,
> Acked-by: Bruno Prémont <[email protected]>
> but preferably with the scnprintf() case is covered too.
>
>
> Cheers,
> Bruno
>
> On Tue, 16 Jan 2024 12:51:20 +0800 Li Zhijian wrote:
>> Per Documentation/filesystems/sysfs.rst, show() should only use sysfs_emit()
>> or sysfs_emit_at() when formatting the value to be returned to user space.
>>
>> coccinelle complains that there are still a couple of functions that use
>> snprintf(). Convert them to sysfs_emit().
>>
>>> ./drivers/hid/hid-picolcd_core.c:259:9-17: WARNING: please use sysfs_emit
>>> ./drivers/hid/hid-picolcd_core.c:304:8-16: WARNING: please use sysfs_emit
>>> ./drivers/hid/hid-sensor-custom.c:375:10-18: WARNING: please use sysfs_emi
>> No functional change intended
>>
>> CC: "Bruno Prémont" <[email protected]>
>> CC: Jiri Kosina <[email protected]>
>> CC: Benjamin Tissoires <[email protected]>
>> CC: Jonathan Cameron <[email protected]>
>> CC: Srinivas Pandruvada <[email protected]>
>> CC: [email protected]
>> Signed-off-by: Li Zhijian <[email protected]>
>> ---
>> drivers/hid/hid-picolcd_core.c | 6 +++---
>> drivers/hid/hid-sensor-custom.c | 3 +--
>> 2 files changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
>> index bbda231a7ce3..fa46fb6eab3f 100644
>> --- a/drivers/hid/hid-picolcd_core.c
>> +++ b/drivers/hid/hid-picolcd_core.c
>> @@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_show(struct device *dev,
>> struct picolcd_data *data = dev_get_drvdata(dev);
>>
>> if (data->status & PICOLCD_BOOTLOADER)
>> - return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n");
>> + return sysfs_emit(buf, "[bootloader] lcd\n");
>> else
>> - return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n");
>> + return sysfs_emit(buf, "bootloader [lcd]\n");
>> }
>>
>> static ssize_t picolcd_operation_mode_store(struct device *dev,
>> @@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_delay_show(struct device *dev,
>> {
>> struct picolcd_data *data = dev_get_drvdata(dev);
>>
>> - return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay);
>> + return sysfs_emit(buf, "%hu\n", data->opmode_delay);
>> }
>>
>> static ssize_t picolcd_operation_mode_delay_store(struct device *dev,
>> diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
>> index d85398721659..4fe8dccf671d 100644
>> --- a/drivers/hid/hid-sensor-custom.c
>> +++ b/drivers/hid/hid-sensor-custom.c
>> @@ -372,8 +372,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr,
>> sizeof(struct hid_custom_usage_desc),
>> usage_id_cmp);
>> if (usage_desc)
>> - return snprintf(buf, PAGE_SIZE, "%s\n",
>> - usage_desc->desc);
>> + return sysfs_emit(buf, "%s\n", usage_desc->desc);
>> else
>> return sprintf(buf, "not-specified\n");
> Shouldn't the sprintf() in the else clause be replaced as well?
>
>> } else