mbox series

[v2,00/10] lib/string_choices: Add new helpers

Message ID 87v7sppmqu.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
Headers show
Series lib/string_choices: Add new helpers | expand

Message

Kuninori Morimoto March 4, 2025, 2:12 a.m. UTC
Hi Kees, Andy

This is v2 patch-set of "add new helpers".
I would like to use string_choices helper to cleanup the code, but it is
missing some of well used string pair in kernel. This patch-set adds it.

Step1
	Add new helpers (This patch-set)
Step2
	Each driver/framework use new helper

You can see "git diff --stat" of Step2 on last of this mail.
One note is that it is including the patch which is using only existing
helper (= not using new helper).
I added sample patch of Step2 in this patch-set as [SAMPLE].

One concern is that it adds "pass/fail", but we can find many similar
strings, like below. I have choiced "pass/fail" and use it on all cases
in my local branch (You can see some of them in [SAMPLE].
I need your opinion

	passed     / failed
	succeed    / failed
	success    / failed
	successful / failed
	succeeded  / failed
	worked     / failed

v1 -> v2
	- add Cc to Andy
	- add [SAMPLE] patches

Kuninori Morimoto (10):
  lib/string_choices: Add str_tx_rx() helper
  lib/string_choices: Add str_enabling_disabling() helper
  lib/string_choices: Add str_in_out() helper
  lib/string_choices: Add str_input_output() helper
  lib/string_choices: Add str_Y_N() helper
  lib/string_choices: Add str_pass_fail() helper
  lib/string_choices: Add str_to_from() helper
  lib/string_choices: Add str_level_edge() helper
  lib/string_choices: Add str_kernel_user() helper
  lib/string_choices: Add str_attach_detach() helper

 include/linux/string_choices.h | 61 ++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

------ diff --stat of Step2 -------
 arch/alpha/kernel/core_cia.c                       |  4 +-
 arch/alpha/kernel/core_tsunami.c                   |  5 +--
 arch/arm/kernel/bios32.c                           |  5 ++-
 arch/arm/mach-omap1/board-ams-delta.c              |  4 +-
 arch/arm/mach-omap2/board-n8x0.c                   |  2 +-
 arch/arm/mach-orion5x/ts78xx-setup.c               |  2 +-
 arch/arm/mach-s3c/pm.c                             |  2 +-
 arch/arm/mm/cache-l2x0.c                           |  7 ++--
 arch/arm/mm/cache-tauros2.c                        |  7 ++--
 arch/arm/mm/fault.c                                |  2 +-
 arch/arm/mm/pmsa-v7.c                              |  2 +-
 arch/arm/plat-orion/gpio.c                         |  6 +--
 arch/arm64/kernel/cpufeature.c                     |  2 +-
 arch/arm64/kernel/reloc_test_core.c                |  3 +-
 arch/arm64/kvm/sys_regs.c                          |  2 +-
 arch/arm64/kvm/sys_regs.h                          |  2 +-
 arch/arm64/kvm/trace_arm.h                         |  6 +--
 arch/arm64/kvm/trace_handle_exit.h                 |  2 +-
 arch/m68k/sun3/mmu_emu.c                           |  2 +-
 arch/microblaze/kernel/exceptions.c                |  4 +-
 arch/mips/jazz/jazzdma.c                           |  2 +-
 arch/mips/kernel/mips-cm.c                         |  5 ++-
 arch/mips/mm/fault.c                               |  5 ++-
 arch/mips/pci/pci-octeon.c                         |  3 +-
 arch/nios2/kernel/traps.c                          |  2 +-
 arch/powerpc/kernel/fadump.c                       |  6 +--
 arch/powerpc/kernel/iommu.c                        |  2 +-
 arch/powerpc/kernel/kvm.c                          |  5 ++-
 arch/powerpc/kernel/prom_init.c                    |  3 +-
 arch/powerpc/mm/fault.c                            |  6 +--
 arch/powerpc/platforms/85xx/ge_imp3a.c             |  3 +-
 arch/powerpc/platforms/86xx/gef_ppc9a.c            |  3 +-
 arch/powerpc/platforms/cell/iommu.c                |  3 +-
 arch/powerpc/platforms/powermac/setup.c            |  3 +-
 arch/powerpc/platforms/powermac/time.c             |  3 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c       |  4 +-
 arch/powerpc/platforms/powernv/pci-ioda.c          |  2 +-
 arch/powerpc/platforms/powernv/pci-sriov.c         |  5 ++-
 arch/powerpc/platforms/powernv/vas.h               |  3 +-
 arch/powerpc/platforms/ps3/device-init.c           |  2 +-
 arch/powerpc/sysdev/mpic.c                         |  3 +-
 arch/powerpc/sysdev/xive/common.c                  |  4 +-
 arch/s390/kernel/dis.c                             |  3 +-
 arch/s390/kernel/dumpstack.c                       |  5 ++-
 arch/s390/kvm/trace-s390.h                         |  2 +-
 arch/um/drivers/virtio_uml.c                       |  3 +-
 arch/um/kernel/um_arch.c                           |  2 +-
 arch/x86/kernel/apic/io_apic.c                     |  6 +--
 arch/x86/kernel/apic/ipi.c                         |  3 +-
 arch/x86/kernel/cet.c                              |  4 +-
 arch/x86/kernel/cpu/mtrr/generic.c                 | 12 +++---
 arch/x86/kvm/trace.h                               | 24 +++++------
 arch/x86/platform/intel-quark/imr.c                |  2 +-
 arch/x86/platform/uv/uv_nmi.c                      |  2 +-
 crypto/aead.c                                      |  3 +-
 crypto/ahash.c                                     |  3 +-
 crypto/async_tx/raid6test.c                        |  3 +-
 crypto/skcipher.c                                  |  3 +-
 drivers/accel/habanalabs/common/firmware_if.c      | 13 +++---
 drivers/accel/habanalabs/gaudi/gaudi.c             | 12 +++---
 drivers/accel/habanalabs/gaudi/gaudi_coresight.c   |  8 ++--
 drivers/accel/habanalabs/gaudi2/gaudi2_coresight.c |  8 ++--
 drivers/accel/habanalabs/goya/goya.c               |  8 ++--
 drivers/accel/habanalabs/goya/goya_coresight.c     |  8 ++--
 drivers/accel/ivpu/ivpu_hw_btrs.c                  |  3 +-
 drivers/acpi/acpi_video.c                          |  6 +--
 drivers/acpi/numa/srat.c                           | 22 ++++-------
 drivers/acpi/pci_irq.c                             |  5 ++-
 drivers/acpi/power.c                               |  5 ++-
 drivers/acpi/proc.c                                |  8 ++--
 drivers/acpi/resource.c                            |  5 ++-
 drivers/acpi/sbs.c                                 |  5 ++-
 drivers/acpi/x86/s2idle.c                          |  6 +--
 drivers/android/binder.c                           |  2 +-
 drivers/ata/pata_arasan_cf.c                       |  2 +-
 drivers/ata/pata_ixp4xx_cf.c                       |  2 +-
 drivers/ata/sata_via.c                             |  2 +-
 drivers/atm/fore200e.c                             |  2 +-
 drivers/atm/nicstar.c                              |  2 +-
 drivers/base/physical_location.c                   |  7 ++--
 drivers/block/amiflop.c                            |  2 +-
 drivers/block/aoe/aoeblk.c                         |  2 +-
 drivers/block/drbd/drbd_actlog.c                   |  6 +--
 drivers/block/drbd/drbd_req.c                      |  2 +-
 drivers/block/mtip32xx/mtip32xx.c                  |  3 +-
 drivers/block/nbd.c                                |  2 +-
 drivers/block/ps3disk.c                            |  5 ++-
 drivers/block/ps3vram.c                            |  2 +-
 drivers/block/rnbd/rnbd-clt.c                      |  2 +-
 drivers/block/xen-blkback/blkback.c                |  3 +-
 drivers/block/xen-blkfront.c                       | 10 ++---
 drivers/bluetooth/bt3c_cs.c                        |  2 +-
 drivers/bluetooth/btmrvl_main.c                    | 10 ++---
 drivers/bluetooth/hci_bcm.c                        |  2 +-
 drivers/bluetooth/hci_ldisc.c                      | 12 +++---
 drivers/bus/intel-ixp4xx-eb.c                      |  3 +-
 drivers/bus/mhi/host/debugfs.c                     |  2 +-
 drivers/bus/uniphier-system-bus.c                  |  3 +-
 drivers/cdrom/cdrom.c                              |  3 +-
 drivers/char/hpet.c                                |  4 +-
 drivers/char/ps3flash.c                            |  3 +-
 drivers/char/sonypi.c                              | 10 ++---
 drivers/char/virtio_console.c                      |  3 +-
 drivers/clk/clk-nomadik.c                          |  6 +--
 drivers/clk/clk-xgene.c                            |  2 +-
 drivers/clk/renesas/renesas-cpg-mssr.c             |  3 +-
 drivers/clk/renesas/rzg2l-cpg.c                    |  4 +-
 drivers/clk/renesas/rzv2h-cpg.c                    |  4 +-
 drivers/counter/stm32-timer-cnt.c                  |  6 ++-
 drivers/cpufreq/amd-pstate-trace.h                 |  3 +-
 drivers/cpufreq/cpufreq.c                          |  2 +-
 drivers/cpuidle/sysfs.c                            |  4 +-
 drivers/crypto/bcm/cipher.c                        |  2 +-
 drivers/crypto/bcm/spu2.c                          |  3 +-
 drivers/crypto/caam/caamalg_qi2.c                  |  2 +-
 drivers/crypto/intel/qat/qat_common/adf_sysfs.c    |  9 +++--
 drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c  |  4 +-
 .../crypto/marvell/octeontx2/otx2_cptpf_ucode.c    |  2 +-
 drivers/crypto/nx/nx-common-powernv.c              |  7 ++--
 drivers/crypto/nx/nx-common-pseries.c              |  9 +++--
 drivers/cxl/core/hdm.c                             |  2 +-
 drivers/cxl/core/port.c                            |  2 +-
 drivers/dax/device.c                               |  3 +-
 drivers/dma-buf/st-dma-fence.c                     |  3 +-
 drivers/dma/amba-pl08x.c                           |  2 +-
 drivers/dma/at_hdmac.c                             |  8 ++--
 drivers/dma/at_xdmac.c                             |  4 +-
 drivers/dma/dw-edma/dw-edma-core.c                 |  4 +-
 drivers/dma/imx-dma.c                              |  2 +-
 drivers/dma/ppc4xx/adma.c                          |  4 +-
 drivers/dma/pxa_dma.c                              |  3 +-
 drivers/dma/sh/rcar-dmac.c                         |  4 +-
 drivers/dma/ste_dma40.c                            |  2 +-
 drivers/dma/sun6i-dma.c                            |  2 +-
 drivers/dma/ti/edma.c                              |  2 +-
 drivers/dma/xilinx/xilinx_dma.c                    |  2 +-
 drivers/edac/amd64_edac.c                          | 46 +++++++++++-----------
 drivers/edac/i5000_edac.c                          |  2 +-
 drivers/edac/i5400_edac.c                          |  2 +-
 drivers/edac/i7300_edac.c                          |  6 +--
 drivers/edac/i82975x_edac.c                        | 10 ++---
 drivers/edac/xgene_edac.c                          | 16 ++++----
 drivers/extcon/extcon-max14577.c                   | 32 +++++++--------
 drivers/extcon/extcon-max77693.c                   | 44 ++++++++++-----------
 drivers/extcon/extcon-max77843.c                   | 40 +++++++++----------
 drivers/extcon/extcon-max8997.c                    | 24 +++++------
 drivers/extcon/extcon-rtk-type-c.c                 |  6 +--
 drivers/firmware/arm_scmi/driver.c                 |  2 +-
 drivers/firmware/arm_scmi/shmem.c                  |  3 +-
 drivers/firmware/arm_scmi/transports/mailbox.c     |  3 +-
 drivers/firmware/arm_scmi/transports/virtio.c      |  3 +-
 drivers/firmware/cirrus/cs_dsp.c                   |  2 +-
 drivers/firmware/efi/cper-x86.c                    |  2 +-
 drivers/firmware/efi/libstub/arm32-stub.c          |  4 +-
 drivers/fpga/altera-fpga2sdram.c                   |  3 +-
 drivers/fpga/altera-hps2fpga.c                     |  3 +-
 drivers/fpga/fpga-bridge.c                         |  3 +-
 drivers/fsi/fsi-core.c                             |  3 +-
 drivers/fsi/fsi-master-ast-cf.c                    |  3 +-
 drivers/fsi/fsi-sbefifo.c                          |  5 ++-
 drivers/gpio/gpio-brcmstb.c                        |  3 +-
 drivers/gpio/gpio-crystalcove.c                    |  7 ++--
 drivers/gpio/gpio-grgpio.c                         |  3 +-
 drivers/gpio/gpio-mvebu.c                          |  6 +--
 drivers/gpio/gpio-nomadik.c                        |  2 +-
 drivers/gpio/gpio-pl061.c                          |  3 +-
 drivers/gpio/gpio-stmpe.c                          |  8 ++--
 drivers/gpio/gpio-virtuser.c                       |  2 +-
 drivers/gpio/gpio-wcove.c                          |  7 ++--
 drivers/gpio/gpio-wm831x.c                         |  4 +-
 drivers/gpio/gpio-xra1403.c                        |  4 +-
 drivers/gpio/gpiolib-sysfs.c                       |  3 +-
 drivers/gpio/gpiolib.c                             | 15 +++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c           |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c           |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c            |  2 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c             |  4 +-
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c             |  4 +-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              |  4 +-
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c              |  4 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              |  3 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  5 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c              |  5 +--
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c              |  5 +--
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c               |  2 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  7 ++--
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c |  4 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c  |  4 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c  |  8 ++--
 drivers/gpu/drm/amd/display/dc/core/dc.c           |  2 +-
 .../drm/amd/display/dc/pg/dcn35/dcn35_pg_cntl.c    |  2 +-
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c                | 10 ++---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c                 |  2 +-
 drivers/gpu/drm/amd/pm/legacy-dpm/kv_dpm.c         |  4 +-
 .../gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c  |  2 +-
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c     | 10 ++---
 drivers/i2c/busses/i2c-exynos5.c                   |  2 +-
 drivers/i2c/busses/i2c-hix5hd2.c                   |  2 +-
 drivers/i2c/busses/i2c-rcar.c                      |  3 +-
 drivers/i2c/busses/i2c-sh_mobile.c                 |  3 +-
 drivers/mailbox/ti-msgmgr.c                        |  5 ++-
 drivers/mmc/host/pxamci.c                          |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c      |  2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c |  3 +-
 drivers/net/ethernet/huawei/hinic/hinic_ethtool.c  |  2 +-
 drivers/net/ethernet/intel/ice/ice_ethtool.c       |  2 +-
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c    |  3 +-
 drivers/net/ethernet/ti/cpsw_ethtool.c             |  6 +--
 drivers/net/wireless/ath/ath10k/usb.c              | 15 +++----
 drivers/net/wireless/ath/ath6kl/trace.h            |  4 +-
 drivers/net/wireless/ath/ath9k/mci.c               |  3 +-
 drivers/rpmsg/qcom_glink_trace.h                   | 26 ++++++------
 drivers/scsi/qla2xxx/qla_edif.c                    |  3 +-
 drivers/spi/spi-rspi.c                             |  3 +-
 drivers/spi/spi-s3c64xx.c                          |  3 +-
 drivers/spi/spi-sh-msiof.c                         |  4 +-
 drivers/spi/spi-tegra114.c                         |  3 +-
 drivers/spi/spi-tegra20-slink.c                    |  3 +-
 drivers/tty/serial/serial-tegra.c                  |  2 +-
 drivers/tty/serial/sh-sci.c                        |  2 +-
 drivers/usb/atm/usbatm.c                           |  2 +-
 drivers/usb/gadget/udc/bcm63xx_udc.c               |  8 ++--
 drivers/usb/musb/musb_trace.h                      |  2 +-
 drivers/usb/musb/tusb6010_omap.c                   | 14 +++----
 include/trace/events/afs.h                         |  4 +-
 sound/core/ump.c                                   |  7 ++--
 sound/drivers/vx/vx_core.c                         |  2 +-
 sound/pci/rme9652/hdspm.c                          |  3 +-
 sound/soc/codecs/tas2781-i2c.c                     |  4 +-
 sound/soc/codecs/tlv320dac33.c                     |  2 +-
 sound/soc/fsl/fsl_asrc_dma.c                       |  2 +-
 sound/soc/pxa/pxa-ssp.c                            |  3 +-
 sound/soc/renesas/fsi.c                            |  2 +-
 sound/soc/renesas/rcar/dma.c                       |  2 +-
 sound/soc/renesas/rcar/rsnd.h                      |  3 +-
 sound/soc/renesas/rcar/src.c                       |  3 +-
 sound/soc/renesas/rcar/ssiu.c                      |  6 +--
 sound/soc/rockchip/rockchip_i2s_tdm.c              |  2 +-
 sound/soc/soc-core.c                               |  2 +-
 sound/soc/soc-dapm.c                               |  2 +-
 sound/usb/proc.c                                   |  2 +-
 244 files changed, 604 insertions(+), 602 deletions(-)

Comments

Andy Shevchenko March 4, 2025, 5:57 a.m. UTC | #1
On Tue, Mar 4, 2025 at 4:12 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>
>
> Hi Kees, Andy
>
> This is v2 patch-set of "add new helpers".

First of all, please rebase your series against the top of the Kees'
branch: https://web.git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=for-next/hardening.
Also use --base when preparing the patch series.

When you do that, you will note that the helpers now are ordered
alphabetically (which your series doesn't follow). So, you will need
the next version. But wait a bit (2-3 days) before sending it out to
give a chance to others to comment on your series and samples.

> I would like to use string_choices helper to cleanup the code, but it is
> missing some of well used string pair in kernel. This patch-set adds it.
>
> Step1
>         Add new helpers (This patch-set)
> Step2
>         Each driver/framework use new helper
>
> You can see "git diff --stat" of Step2 on last of this mail.
> One note is that it is including the patch which is using only existing
> helper (= not using new helper).

The mentioned patch you can send as is separately.

> I added sample patch of Step2 in this patch-set as [SAMPLE].

> One concern is that it adds "pass/fail", but we can find many similar
> strings, like below. I have choiced "pass/fail" and use it on all cases
> in my local branch (You can see some of them in [SAMPLE].
> I need your opinion
>
>         passed     / failed
>         succeed    / failed
>         success    / failed
>         successful / failed
>         succeeded  / failed
>         worked     / failed

It looks like something with the 'successful' / 'succeeded' needs to be present.

But in general here is the BIG NOTE: some of the strings may be used
in ABI, which must not change them.
Kuninori Morimoto March 4, 2025, 6:53 a.m. UTC | #2
Hi Andy

Thank you for the reply

> First of all, please rebase your series against the top of the Kees'
> branch: Also use --base when preparing the patch series.
> 
> When you do that, you will note that the helpers now are ordered
> alphabetically (which your series doesn't follow). So, you will need
> the next version. But wait a bit (2-3 days) before sending it out to
> give a chance to others to comment on your series and samples.

OK, will post v3 in next week.

> >         passed     / failed
> >         succeed    / failed
> >         success    / failed
> >         successful / failed
> >         succeeded  / failed
> >         worked     / failed
> 
> It looks like something with the 'successful' / 'succeeded' needs to be
> present.
> 
> But in general here is the BIG NOTE: some of the strings may be used
> in ABI, which must not change them.

It is indeed one of my concern.
Not only above, but some drivers are using capital letters at the beginning,
but helper uses all lowercase...

I agree we should not change string if it was used on dev_info() or something.
But I think it can be more flexible if it was used on dev_dbg() ? not sure...
I will indicate it (= the strings might be changed) on the patch in Step2,
and follow each maintainer / reviewer opinion. Is it OK for you ?

But hmm... I will double check the new helper, some of them might not needed
if it was used only on dev_info()...

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Andy Shevchenko March 4, 2025, 7:01 a.m. UTC | #3
On Tue, Mar 4, 2025 at 8:53 AM Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:

...

> > >         passed     / failed
> > >         succeed    / failed
> > >         success    / failed
> > >         successful / failed
> > >         succeeded  / failed
> > >         worked     / failed
> >
> > It looks like something with the 'successful' / 'succeeded' needs to be
> > present.
> >
> > But in general here is the BIG NOTE: some of the strings may be used
> > in ABI, which must not change them.
>
> It is indeed one of my concern.
> Not only above, but some drivers are using capital letters at the beginning,
> but helper uses all lowercase...
>
> I agree we should not change string if it was used on dev_info() or something.

dev_*() are not the ABI.

> But I think it can be more flexible if it was used on dev_dbg() ? not sure...

All dev_*() and pr_*() and their derivatives may use these helpers
without thinking of any breakages.

On the contrary sysfs nodes, s*printf() when used to prepare strings
to communicate with the user space and so on are all the ABIs. You
need to study case-by-case. That's why I suggest you reduce this
series to just helpers necessary for let say gpio-crystalcove and
gpio-wcove drivers which I can review and ack and that's what will
have all chances to go in this cycle. Then repeat for other helpers,
no need to send tons of helpers with tons of conversion
patches/samples. Do small steps at a time.

That said, I would expect the series out of 3/4 patches
1) add str_in_out() and/or str_input_output();
2) use it in gpio-crystalcove.c
3) use it in gpio-wcove.c

This can be easily combined into an immutable tag/branch and pulled by
the affected subsystems. With your lengthy series it will be ages to
get it in.

> I will indicate it (= the strings might be changed) on the patch in Step2,
> and follow each maintainer / reviewer opinion. Is it OK for you ?
>
> But hmm... I will double check the new helper, some of them might not needed
> if it was used only on dev_info()...
Kees Cook March 4, 2025, 8:40 p.m. UTC | #4
On Tue, Mar 04, 2025 at 02:12:41AM +0000, Kuninori Morimoto wrote:
> I would like to use string_choices helper to cleanup the code, but it is
> missing some of well used string pair in kernel. This patch-set adds it.
> 
> Step1
> 	Add new helpers (This patch-set)
> Step2
> 	Each driver/framework use new helper

The Coccinelle rules are very easy to write. For example:

@str_input_output@
expression E;
@@

-       (E ? "input" : "output")
+       str_input_output(E)

@str_output_input@
expression E;
@@

-       (E ? "output" : "input")
+       str_output_input(E)

Then running those will generate the treewide patches. I wrote and ran
al of these, and the results for me were:

str_in_out.patch:              66 files changed, 130 insertions(+), 136 deletions(-)
str_tx_rx.patch:               33 files changed, 48 insertions(+), 53 deletions(-)
str_input_output.patch:        17 files changed, 27 insertions(+), 29 deletions(-)
str_enabling_disabling.patch:  16 files changed, 25 insertions(+), 25 deletions(-)
str_Y_N.patch:                 13 files changed, 98 insertions(+), 89 deletions(-)
str_kernel_user.patch:          7 files changed, 8 insertions(+), 7 deletions(-)
str_level_edge.patch:           5 files changed, 6 insertions(+), 6 deletions(-)
str_to_from.patch:              3 files changed, 4 insertions(+), 4 deletions(-)
str_pass_fail.patch:            2 files changed, 2 insertions(+), 2 deletions(-)
str_attach_detach.patch:        1 file changed, 4 insertions(+), 4 deletions(-)

So, IMO, the first 5 are clear winners. The others are probably fine,
but pass/fail and attach/detach are really not used much.

> One concern is that it adds "pass/fail", but we can find many similar
> strings, like below. I have choiced "pass/fail" and use it on all cases
> in my local branch (You can see some of them in [SAMPLE].
> I need your opinion
> 
> 	passed     / failed
> 	succeed    / failed
> 	success    / failed
> 	successful / failed
> 	succeeded  / failed
> 	worked     / failed

As Andy said, don't change any existing strings into something else.
However, of the above 6 styles, I'd say find the most common and do
those conversions.

>  244 files changed, 604 insertions(+), 602 deletions(-)

I only saw:

 161 files changed, 352 insertions(+), 355 deletions(-)

You have a lot in arch/ that I don't have, and when I spot-checked those
files, I don't see what from this series you were converted? Perhaps you
were doing more than those from this series (like "write"/"read")?

-Kees
Kuninori Morimoto March 4, 2025, 11:51 p.m. UTC | #5
Hi Kees, Andy

Thank you for your feedbacks

> That said, I would expect the series out of 3/4 patches
> 1) add str_in_out() and/or str_input_output();
> 2) use it in gpio-crystalcove.c
> 3) use it in gpio-wcove.c
>
> This can be easily combined into an immutable tag/branch and pulled by
> the affected subsystems. With your lengthy series it will be ages to
> get it in.
(snip)
> str_in_out.patch:              66 files changed, 130 insertions(+), 136 deletions(-)
> str_tx_rx.patch:               33 files changed, 48 insertions(+), 53 deletions(-)
> str_input_output.patch:        17 files changed, 27 insertions(+), 29 deletions(-)
> str_enabling_disabling.patch:  16 files changed, 25 insertions(+), 25 deletions(-)
> str_Y_N.patch:                 13 files changed, 98 insertions(+), 89 deletions(-)
> str_kernel_user.patch:          7 files changed, 8 insertions(+), 7 deletions(-)
> str_level_edge.patch:           5 files changed, 6 insertions(+), 6 deletions(-)
> str_to_from.patch:              3 files changed, 4 insertions(+), 4 deletions(-)
> str_pass_fail.patch:            2 files changed, 2 insertions(+), 2 deletions(-)
> str_attach_detach.patch:        1 file changed, 4 insertions(+), 4 deletions(-)
> 
> So, IMO, the first 5 are clear winners. The others are probably fine,
> but pass/fail and attach/detach are really not used much.

Thanks.
My plan was add new helper 1st, and use helper (both new and exists) 2nd
on each driver/framwork. But indeed it is not so good from reviewer point
of view. And (aside from the "success/failed" topic) indeed some of new
helper are not good/needed.

I will try to post v3 patch, but want to cleanup before that.
v3 will be above top 5 helpers only.

Thank you for your help !!

Best regards
---
Kuninori Morimoto