linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
@ 2024-04-11 15:12 Jens Axboe
  2024-04-11 15:12 ` [PATCH 001/437] fs: split do_loop_readv_writev() into separate read/write side helpers Jens Axboe
                   ` (437 more replies)
  0 siblings, 438 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel

Hi,

This patchset will obviously be split, commit messages updated, and
specific driver patches targeted to where they belong. But I figured
it'd be useful to blast out the full set at least once for reference,
and then I'll continue down the right path for the next one.

Subject line says it all, really. 10 years ago we added ->read_iter()
and ->write_iter() to struct file_operations. These are great, as they
pass in an iov_iter rather than a user buffer + length, and they also
take a struct kiocb rather than just a file. Since then we've had two
paths for any read or write - one legacy one that can't do per-IO hints
like "This read should be non-blocking", they strictly only work with
O_NONBLOCK on the file, and a newer one that supports everything the
old path does and a bunch more. We've had a few issues with the
iov_iter based path being slower, but those have basically been
resolved with solutions like ITER_UBUF to optimize the single segment
case that is often the fast path.

There are basically three parts to this series:

1) Add generic helpers that we need to convert drivers.
2) Convert any use of fops->read() and ->write()
3) Kill off old cruft.
3a) Profit.

Notes:

- Part 1 adds FOPS_READ_ITER_HELPER() and FOPS_WRITE_ITER_HELPER() to
  ease conversion of some drivers, as those just wrap the existing
  read or write function with vfs_{read,write}_iter(). Where possible
  this has been avoided and a clean implementation been done. However,
  due to lack of man power, I didn't dig super deep in some spots. It's
  my hope that drivers with active developers/maintainers will take it
  a step further and help get their driver fully converted.

- This is based on my 'read_iter' branch that adds one helper and
  converts timerfd/userfaultfd/signalfd. This branch is queued for
  6.10.

- I'm sure there are a few spots that I haven't converted just yet
  because I've missed them. If you see any, please let me know and
  I'll take care of it.

- The kernel builds allyesconfig/allmodconfig on (at least) the
  following architectures: x86-64, arm64, sparc64, s390, powerpc.
  With the above caveat that there may still be old crufty drivers
  somewhere in the tree that are missing a conversion, it should be
  fairly complete.

- Resulting kernel boots just fine, tested on x86-64 and arm64.
  Caveat emptor if you want to test it, however!

- As you may be able to tell, diffstat looks promising. The lines
  removed will continue to go up with removal of FOPS_*() wrappers.
  There are currently about 150 read side wrappers and 200 write side
  wrappers.

- I haven't done detailed analysis of text/bss sizes just yet, but
  preliminary looks show about a 100K reduction in kernel image size
  for my standard test box build.

Please have a look! A continually rebased branch for these patches can
be found here:

https://git.kernel.dk/cgit/linux/log/?h=rw_iter

 arch/arm/common/bL_switcher_dummy_if.c        |   8 +-
 arch/mips/kernel/rtlx.c                       |   6 +-
 arch/mips/kernel/vpe.c                        |  14 +-
 arch/mips/mm/sc-debugfs.c                     |  16 +-
 arch/parisc/kernel/perf.c                     |  14 +-
 arch/powerpc/kernel/dawr.c                    |  10 +-
 arch/powerpc/kernel/eeh.c                     |  58 +-
 arch/powerpc/kvm/book3s_64_mmu_hv.c           |  25 +-
 arch/powerpc/kvm/book3s_64_mmu_radix.c        |  19 +-
 arch/powerpc/kvm/book3s_hv.c                  |  26 +-
 arch/powerpc/kvm/timing.c                     |  14 +-
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c     |   7 +-
 arch/powerpc/platforms/cell/spufs/file.c      | 312 +++++------
 arch/powerpc/platforms/cell/spufs/inode.c     |   2 +-
 arch/powerpc/platforms/powernv/eeh-powernv.c  |  11 +-
 arch/powerpc/platforms/powernv/memtrace.c     |   9 +-
 arch/powerpc/platforms/powernv/opal-lpc.c     |   6 +-
 arch/powerpc/platforms/powernv/opal-prd.c     |  22 +-
 arch/powerpc/platforms/powernv/opal-xscom.c   |  30 +-
 arch/powerpc/platforms/pseries/dtl.c          |  16 +-
 arch/powerpc/platforms/pseries/lpar.c         |  11 +-
 arch/powerpc/platforms/pseries/papr-vpd.c     |   8 +-
 arch/s390/crypto/prng.c                       |  18 +-
 arch/s390/hypfs/hypfs_dbfs.c                  |  11 +-
 arch/s390/kernel/debug.c                      |  29 +-
 arch/s390/kernel/sysinfo.c                    |   6 +-
 arch/s390/pci/pci_debug.c                     |  12 +-
 arch/sh/mm/tlb-debugfs.c                      |   2 +-
 arch/sparc/kernel/mdesc.c                     |  18 +-
 arch/um/drivers/harddog_kern.c                |   6 +-
 arch/um/drivers/hostaudio_kern.c              |  22 +-
 arch/um/drivers/mmapper_kern.c                |  16 +-
 arch/x86/kernel/apm_32.c                      |  10 +-
 arch/x86/kernel/callthunks.c                  |   2 +-
 arch/x86/kernel/cpu/debugfs.c                 |   4 +-
 arch/x86/kernel/cpu/mce/dev-mcelog.c          |  38 +-
 arch/x86/kernel/cpu/mce/inject.c              |  27 +-
 arch/x86/kernel/cpu/mce/severity.c            |  11 +-
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c     |  18 +-
 arch/x86/kernel/cpuid.c                       |  16 +-
 arch/x86/kernel/kdebugfs.c                    |  14 +-
 arch/x86/kernel/msr.c                         |  28 +-
 arch/x86/kernel/tboot.c                       |  17 +-
 arch/x86/kvm/debugfs.c                        |   2 +-
 arch/x86/mm/pat/memtype.c                     |   2 +-
 arch/x86/mm/pat/set_memory.c                  |   2 +-
 arch/x86/mm/pkeys.c                           |  15 +-
 arch/x86/mm/tlb.c                             |  15 +-
 block/blk-mq-debugfs.c                        |  20 +-
 block/blk-mq-debugfs.h                        |   2 +-
 drivers/accel/habanalabs/common/debugfs.c     | 307 +++++------
 drivers/accel/habanalabs/common/habanalabs.h  |   3 +-
 drivers/accel/ivpu/ivpu_debugfs.c             |  84 ++-
 drivers/accessibility/speakup/devsynth.c      |  27 +-
 drivers/accessibility/speakup/speakup_soft.c  |  46 +-
 drivers/acpi/acpi_dbg.c                       |   6 +-
 drivers/acpi/apei/erst-dbg.c                  |  23 +-
 drivers/acpi/ec_sys.c                         |   6 +-
 drivers/acpi/pfr_update.c                     |   3 +-
 drivers/auxdisplay/charlcd.c                  |   3 +-
 drivers/auxdisplay/panel.c                    |   3 +-
 drivers/base/power/wakeup.c                   |   2 +-
 drivers/base/regmap/regmap-debugfs.c          | 115 ++--
 drivers/block/aoe/aoechr.c                    |  15 +-
 drivers/block/drbd/drbd_debugfs.c             |  10 +-
 drivers/block/mtip32xx/mtip32xx.c             |  36 +-
 drivers/block/zram/zram_drv.c                 |  14 +-
 drivers/bluetooth/btmrvl_debugfs.c            |  57 +-
 drivers/bluetooth/btusb.c                     |  20 +-
 drivers/bluetooth/hci_vhci.c                  |  73 ++-
 drivers/bus/mhi/host/debugfs.c                |  38 +-
 drivers/bus/moxtet.c                          |  30 +-
 drivers/cache/sifive_ccache.c                 |   8 +-
 drivers/char/adi.c                            |  26 +-
 drivers/char/apm-emulation.c                  |  10 +-
 drivers/char/applicom.c                       |   7 +-
 drivers/char/ds1620.c                         |   7 +-
 drivers/char/dsp56k.c                         |   6 +-
 drivers/char/dtlk.c                           |   6 +-
 drivers/char/hpet.c                           |   3 +-
 drivers/char/hw_random/core.c                 |   3 +-
 drivers/char/hw_random/s390-trng.c            |   9 +-
 drivers/char/ipmi/bt-bmc.c                    |  27 +-
 drivers/char/ipmi/ipmb_dev_int.c              |  19 +-
 drivers/char/ipmi/ipmi_watchdog.c             |  16 +-
 drivers/char/ipmi/kcs_bmc_cdev_ipmi.c         |  23 +-
 drivers/char/ipmi/ssif_bmc.c                  |  25 +-
 drivers/char/lp.c                             |  21 +-
 drivers/char/mem.c                            | 106 +---
 drivers/char/mwave/mwavedd.c                  |  19 +-
 drivers/char/nsc_gpio.c                       |  22 +-
 drivers/char/nvram.c                          |  19 +-
 drivers/char/nwbutton.c                       |   7 +-
 drivers/char/nwflash.c                        |  12 +-
 drivers/char/pc8736x_gpio.c                   |   4 +-
 drivers/char/powernv-op-panel.c               |  25 +-
 drivers/char/ppdev.c                          |  18 +-
 drivers/char/ps3flash.c                       |   6 +-
 drivers/char/scx200_gpio.c                    |   4 +-
 drivers/char/sonypi.c                         |   3 +-
 drivers/char/tlclk.c                          |   9 +-
 drivers/char/tpm/eventlog/common.c            |   2 +-
 drivers/char/tpm/tpm-dev-common.c             |  26 +-
 drivers/char/tpm/tpm-dev.c                    |   4 +-
 drivers/char/tpm/tpm-dev.h                    |   6 +-
 drivers/char/tpm/tpm_vtpm_proxy.c             |  20 +-
 drivers/char/tpm/tpmrm-dev.c                  |   4 +-
 drivers/char/virtio_console.c                 |   6 +-
 drivers/char/xilinx_hwicap/xilinx_hwicap.c    |  31 +-
 drivers/char/xillybus/xillybus_core.c         |  36 +-
 drivers/char/xillybus/xillyusb.c              |   6 +-
 drivers/clk/clk.c                             |  11 +-
 .../clk/starfive/clk-starfive-jh7110-pll.c    |   2 +-
 drivers/comedi/comedi_fops.c                  |  26 +-
 drivers/counter/counter-chrdev.c              |   3 +-
 drivers/crypto/ccp/ccp-debugfs.c              |  51 +-
 drivers/crypto/hisilicon/debugfs.c            |  51 +-
 drivers/crypto/hisilicon/hpre/hpre_main.c     |  23 +-
 drivers/crypto/hisilicon/qm.c                 |  22 +-
 drivers/crypto/hisilicon/sec2/sec_main.c      |  23 +-
 drivers/crypto/hisilicon/zip/zip_main.c       |  23 +-
 drivers/crypto/intel/iaa/iaa_crypto_stats.c   |   2 +-
 .../intel/qat/qat_common/adf_cnv_dbgfs.c      |  10 +-
 .../intel/qat/qat_common/adf_fw_counters.c    |   2 +-
 .../qat/qat_common/adf_heartbeat_dbgfs.c      |  60 +--
 .../intel/qat/qat_common/adf_pm_dbgfs.c       |   3 +-
 .../intel/qat/qat_common/adf_tl_debugfs.c     |  18 +-
 drivers/dma/xilinx/xilinx_dpdma.c             |  15 +-
 drivers/edac/altera_edac.c                    |  46 +-
 drivers/edac/debugfs.c                        |   9 +-
 drivers/edac/i5100_edac.c                     |   9 +-
 drivers/edac/npcm_edac.c                      |   8 +-
 drivers/edac/thunderx_edac.c                  |  71 ++-
 drivers/edac/versal_edac.c                    |  20 +-
 drivers/edac/xgene_edac.c                     |  43 +-
 drivers/edac/zynqmp_edac.c                    |  26 +-
 drivers/extcon/extcon-rtk-type-c.c            |   4 +-
 drivers/firewire/core-cdev.c                  |  15 +-
 drivers/firewire/nosy.c                       |  18 +-
 drivers/firmware/arm_scmi/raw_mode.c          |  94 ++--
 drivers/firmware/cirrus/cs_dsp.c              |  26 +-
 drivers/firmware/efi/capsule-loader.c         |  16 +-
 drivers/firmware/psci/psci.c                  |   2 +-
 drivers/firmware/tegra/bpmp-debugfs.c         |  26 +-
 drivers/firmware/turris-mox-rwtm.c            |  22 +-
 drivers/firmware/xilinx/zynqmp-debug.c        |  22 +-
 drivers/fsi/fsi-core.c                        |  28 +-
 drivers/fsi/fsi-occ.c                         |  20 +-
 drivers/fsi/fsi-sbefifo.c                     |   6 +-
 drivers/fsi/fsi-scom.c                        |  24 +-
 drivers/fsi/i2cr-scom.c                       |  23 +-
 drivers/gnss/core.c                           |  14 +-
 drivers/gpio/gpio-mockup.c                    |  26 +-
 drivers/gpio/gpiolib-cdev.c                   |  41 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c       |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c   |  71 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       |   2 +-
 .../drm/amd/amdgpu/amdgpu_fw_attestation.c    |  23 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c       |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c    |  18 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c       |  14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       |  34 +-
 .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c    |  22 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c      |   6 +-
 .../gpu/drm/amd/amdgpu/amdgpu_securedisplay.c |  14 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  56 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c      |  13 +-
 drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c   |  19 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 111 ++--
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  11 +-
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     |  17 +-
 drivers/gpu/drm/arm/malidp_drv.c              |  11 +-
 drivers/gpu/drm/armada/armada_debugfs.c       |  13 +-
 drivers/gpu/drm/bridge/ite-it6505.c           |  14 +-
 drivers/gpu/drm/drm_debugfs.c                 |  28 +-
 drivers/gpu/drm/drm_debugfs_crc.c             |  26 +-
 drivers/gpu/drm/drm_file.c                    |  22 +-
 drivers/gpu/drm/drm_mipi_dbi.c                |  14 +-
 drivers/gpu/drm/gma500/psb_drv.c              |   2 +-
 .../drm/i915/display/intel_display_debugfs.c  | 114 ++--
 .../display/intel_display_debugfs_params.c    |  36 +-
 drivers/gpu/drm/i915/display/intel_hotplug.c  |  28 +-
 drivers/gpu/drm/i915/display/intel_wm.c       |  42 +-
 drivers/gpu/drm/i915/display/skl_watermark.c  |  14 +-
 drivers/gpu/drm/i915/gt/intel_gt_debugfs.c    |   2 +-
 drivers/gpu/drm/i915/gt/intel_gt_debugfs.h    |   2 +-
 .../drm/i915/gt/uc/intel_guc_log_debugfs.c    |  13 +-
 drivers/gpu/drm/i915/i915_debugfs_params.c    |  43 +-
 drivers/gpu/drm/i915/i915_driver.c            |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c         |  28 +-
 drivers/gpu/drm/i915/i915_perf.c              |   3 +-
 drivers/gpu/drm/imagination/pvr_fw_trace.c    |   2 +-
 drivers/gpu/drm/imagination/pvr_params.c      |   4 +-
 drivers/gpu/drm/loongson/lsdc_crtc.c          |  14 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c |  20 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c       |  20 +-
 drivers/gpu/drm/msm/dp/dp_debug.c             |  15 +-
 drivers/gpu/drm/msm/msm_debugfs.c             |   4 +-
 drivers/gpu/drm/msm/msm_perf.c                |  12 +-
 drivers/gpu/drm/msm/msm_rd.c                  |  12 +-
 drivers/gpu/drm/nouveau/dispnv50/crc.c        |  13 +-
 drivers/gpu/drm/nouveau/nouveau_debugfs.c     |  12 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c         |   2 +-
 drivers/gpu/drm/omapdrm/dss/dss.c             |   2 +-
 drivers/gpu/drm/radeon/radeon_drv.c           |   2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c           |  40 +-
 drivers/gpu/drm/tegra/drm.c                   |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c           |   2 +-
 drivers/gpu/drm/xe/xe_device.c                |   2 +-
 drivers/gpu/vga/vga_switcheroo.c              |  10 +-
 drivers/greybus/es2.c                         |  29 +-
 drivers/greybus/svc.c                         |  27 +-
 drivers/hid/hid-debug.c                       |   3 +-
 drivers/hid/hid-picolcd_debugfs.c             |  65 +--
 drivers/hid/hid-roccat.c                      |  12 +-
 drivers/hid/hid-sensor-custom.c               |   3 +-
 drivers/hid/hid-wiimote-debug.c               |  15 +-
 drivers/hid/hidraw.c                          |  15 +-
 drivers/hid/uhid.c                            |  15 +-
 drivers/hid/usbhid/hiddev.c                   |  17 +-
 drivers/hsi/clients/cmt_speech.c              |  22 +-
 drivers/hsi/clients/hsi_char.c                |  22 +-
 drivers/hv/hv_utils_transport.c               |  20 +-
 drivers/hwmon/asus_atk0110.c                  |   9 +-
 drivers/hwmon/fschmd.c                        |  10 +-
 drivers/hwmon/mr75203.c                       |  20 +-
 drivers/hwmon/pmbus/acbel-fsg032.c            |  10 +-
 drivers/hwmon/pmbus/ibm-cffps.c               |  35 +-
 drivers/hwmon/pmbus/max20730.c                |  10 +-
 drivers/hwmon/pmbus/pmbus_core.c              |  10 +-
 drivers/hwmon/pmbus/q54sj108a2.c              |  25 +-
 drivers/hwmon/pmbus/ucd9000.c                 |  11 +-
 drivers/hwmon/pt5161l.c                       |  31 +-
 drivers/hwmon/w83793.c                        |  10 +-
 .../hwtracing/coresight/coresight-cpu-debug.c |  15 +-
 drivers/hwtracing/coresight/coresight-etb10.c |  18 +-
 .../hwtracing/coresight/coresight-tmc-core.c  |  14 +-
 drivers/hwtracing/coresight/ultrasoc-smb.c    |  12 +-
 drivers/hwtracing/intel_th/msu.c              |  46 +-
 drivers/hwtracing/stm/core.c                  |  10 +-
 drivers/i2c/i2c-dev.c                         |  25 +-
 drivers/iio/gyro/adis16136.c                  |   9 +-
 drivers/iio/iio_core.h                        |   7 +-
 drivers/iio/imu/adis16400.c                   |  10 +-
 drivers/iio/imu/adis16475.c                   |  22 +-
 drivers/iio/imu/adis16480.c                   |  20 +-
 drivers/iio/imu/bno055/bno055.c               |   9 +-
 drivers/iio/industrialio-buffer.c             |  20 +-
 drivers/iio/industrialio-core.c               |  34 +-
 drivers/iio/industrialio-event.c              |   3 +-
 drivers/infiniband/core/ucma.c                |   3 +-
 drivers/infiniband/core/user_mad.c            |   6 +-
 drivers/infiniband/core/uverbs_main.c         |  11 +-
 drivers/infiniband/hw/cxgb4/device.c          |  35 +-
 drivers/infiniband/hw/hfi1/debugfs.c          | 162 +++---
 drivers/infiniband/hw/hfi1/debugfs.h          |   6 +-
 drivers/infiniband/hw/hfi1/fault.c            |  27 +-
 drivers/infiniband/hw/hns/hns_roce_debugfs.c  |   2 +-
 drivers/infiniband/hw/mlx5/cong.c             |  19 +-
 drivers/infiniband/hw/mlx5/devx.c             |  24 +-
 drivers/infiniband/hw/mlx5/main.c             |  20 +-
 drivers/infiniband/hw/mlx5/mr.c               |  38 +-
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c   |  26 +-
 drivers/infiniband/hw/qib/qib_debugfs.c       |   2 +-
 drivers/infiniband/hw/qib/qib_diag.c          |  18 +-
 drivers/infiniband/hw/qib/qib_file_ops.c      |   4 +-
 drivers/infiniband/hw/qib/qib_fs.c            | 119 ++---
 drivers/infiniband/hw/usnic/usnic_debugfs.c   |  22 +-
 drivers/input/evdev.c                         |   6 +-
 drivers/input/joydev.c                        |  22 +-
 drivers/input/keyboard/applespi.c             |  11 +-
 drivers/input/misc/uinput.c                   |   6 +-
 drivers/input/mousedev.c                      |  16 +-
 drivers/input/serio/serio_raw.c               |   6 +-
 drivers/input/serio/userio.c                  |  22 +-
 drivers/input/touchscreen/edt-ft5x06.c        |  19 +-
 drivers/iommu/intel/debugfs.c                 |  14 +-
 drivers/iommu/omap-iommu-debug.c              |  11 +-
 drivers/isdn/capi/capi.c                      |  22 +-
 drivers/isdn/mISDN/timerdev.c                 |  16 +-
 drivers/leds/uleds.c                          |  33 +-
 drivers/macintosh/adb.c                       |  22 +-
 drivers/macintosh/ans-lcd.c                   |  29 +-
 drivers/macintosh/smu.c                       |  40 +-
 drivers/macintosh/via-pmu.c                   |  19 +-
 drivers/mailbox/bcm-pdc-mailbox.c             |   9 +-
 drivers/mailbox/mailbox-test.c                |  37 +-
 drivers/md/bcache/debug.c                     |  11 +-
 drivers/media/cec/core/cec-core.c             |  12 +-
 drivers/media/common/siano/smsdvb-debugfs.c   |  17 +-
 drivers/media/dvb-core/dmxdev.c               |   9 +-
 drivers/media/dvb-core/dvb_ca_en50221.c       |  25 +-
 drivers/media/mc/mc-devnode.c                 |   6 +-
 drivers/media/pci/bt8xx/dst_ca.c              |   8 +-
 drivers/media/pci/ddbridge/ddbridge-core.c    |   6 +-
 drivers/media/pci/ngene/ngene-dvb.c           |   6 +-
 drivers/media/platform/amphion/vpu_dbg.c      |  24 +-
 .../mediatek/vcodec/common/mtk_vcodec_dbgfs.c |  21 +-
 drivers/media/platform/mediatek/vpu/mtk_vpu.c |   9 +-
 drivers/media/radio/radio-si476x.c            |  60 +--
 drivers/media/rc/imon.c                       |  26 +-
 drivers/media/rc/lirc_dev.c                   |  15 +-
 drivers/media/usb/uvc/uvc_debugfs.c           |  10 +-
 drivers/media/v4l2-core/v4l2-dev.c            |   6 +-
 drivers/mfd/aat2870-core.c                    |  20 +-
 drivers/mfd/tps65010.c                        |   2 +-
 drivers/misc/bcm-vk/bcm_vk.h                  |   6 +-
 drivers/misc/bcm-vk/bcm_vk_dev.c              |   4 +-
 drivers/misc/bcm-vk/bcm_vk_msg.c              |  23 +-
 drivers/misc/cxl/api.c                        |   7 +-
 drivers/misc/cxl/cxl.h                        |   2 +-
 drivers/misc/cxl/file.c                       |  23 +-
 drivers/misc/eeprom/idt_89hpesx.c             |  21 +-
 drivers/misc/hpilo.c                          |  21 +-
 drivers/misc/ibmasm/ibmasmfs.c                |  94 ++--
 drivers/misc/ibmvmc.c                         |  40 +-
 drivers/misc/lis3lv02d/lis3lv02d.c            |  13 +-
 drivers/misc/lkdtm/core.c                     |  40 +-
 drivers/misc/mei/debugfs.c                    |  12 +-
 drivers/misc/mei/main.c                       |  53 +-
 drivers/misc/ocxl/file.c                      |  20 +-
 drivers/misc/open-dice.c                      |  19 +-
 drivers/misc/tps6594-pfsm.c                   |  30 +-
 drivers/mmc/core/block.c                      |  10 +-
 drivers/mmc/core/debugfs.c                    |  11 +-
 drivers/mmc/core/mmc_test.c                   |  12 +-
 drivers/most/most_cdev.c                      |  50 +-
 drivers/mtd/mtdchar.c                         |  52 +-
 drivers/mtd/ubi/cdev.c                        |  58 +-
 drivers/mtd/ubi/debug.c                       |  38 +-
 drivers/mtd/ubi/ubi.h                         |   4 +-
 drivers/mtd/ubi/upd.c                         |  24 +-
 drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c  | 233 ++++----
 .../net/ethernet/broadcom/bnxt/bnxt_debugfs.c |  13 +-
 .../net/ethernet/brocade/bna/bnad_debugfs.c   |  47 +-
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 321 +++++------
 drivers/net/ethernet/chelsio/cxgb4/l2t.c      |   2 +-
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  15 +-
 .../net/ethernet/huawei/hinic/hinic_debugfs.c |  13 +-
 .../net/ethernet/intel/fm10k/fm10k_debugfs.c  |  10 +-
 .../net/ethernet/intel/i40e/i40e_debugfs.c    | 103 ++--
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 181 +++----
 .../net/ethernet/intel/ixgbe/ixgbe_debugfs.c  |  99 ++--
 .../marvell/octeontx2/af/rvu_debugfs.c        | 159 +++---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c |  78 +--
 .../net/ethernet/mellanox/mlx5/core/debugfs.c |  49 +-
 .../net/ethernet/mellanox/mlx5/core/lib/sd.c  |  13 +-
 drivers/net/ieee802154/ca8210.c               |  29 +-
 drivers/net/netdevsim/dev.c                   |  73 ++-
 drivers/net/netdevsim/fib.c                   |  16 +-
 drivers/net/netdevsim/health.c                |  12 +-
 drivers/net/netdevsim/hwstats.c               |  13 +-
 drivers/net/netdevsim/ipsec.c                 |  10 +-
 drivers/net/netdevsim/psample.c               |  12 +-
 drivers/net/netdevsim/udp_tunnels.c           |   9 +-
 drivers/net/ppp/ppp_generic.c                 |  13 +-
 drivers/net/wireless/ath/ath10k/debug.c       | 502 ++++++++----------
 drivers/net/wireless/ath/ath10k/debugfs_sta.c | 119 ++---
 drivers/net/wireless/ath/ath10k/spectral.c    |  65 ++-
 drivers/net/wireless/ath/ath11k/debugfs.c     | 300 +++++------
 .../wireless/ath/ath11k/debugfs_htt_stats.c   |  56 +-
 drivers/net/wireless/ath/ath11k/debugfs_sta.c | 163 +++---
 drivers/net/wireless/ath/ath11k/spectral.c    |  69 ++-
 drivers/net/wireless/ath/ath5k/debug.c        | 148 +++---
 drivers/net/wireless/ath/ath6kl/debug.c       | 312 +++++------
 drivers/net/wireless/ath/ath9k/common-debug.c |  36 +-
 .../net/wireless/ath/ath9k/common-spectral.c  | 111 ++--
 drivers/net/wireless/ath/ath9k/debug.c        | 210 ++++----
 drivers/net/wireless/ath/ath9k/debug_sta.c    |  18 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c    |  30 +-
 .../net/wireless/ath/ath9k/htc_drv_debug.c    |  82 ++-
 drivers/net/wireless/ath/ath9k/tx99.c         |  40 +-
 drivers/net/wireless/ath/carl9170/debug.c     |  25 +-
 drivers/net/wireless/ath/wcn36xx/debug.c      |  42 +-
 drivers/net/wireless/ath/wil6210/debugfs.c    | 235 ++++----
 drivers/net/wireless/ath/wil6210/pmc.c        |  27 +-
 drivers/net/wireless/ath/wil6210/pmc.h        |   2 +-
 drivers/net/wireless/broadcom/b43/debugfs.c   |  30 +-
 .../net/wireless/broadcom/b43legacy/debugfs.c |  31 +-
 .../broadcom/brcm80211/brcmfmac/core.c        |  10 +-
 .../broadcom/brcm80211/brcmsmac/debug.c       |   2 +-
 drivers/net/wireless/intel/iwlegacy/3945-rs.c |   9 +-
 drivers/net/wireless/intel/iwlegacy/4965-rs.c |  39 +-
 drivers/net/wireless/intel/iwlegacy/debug.c   | 280 +++++-----
 .../net/wireless/intel/iwlwifi/dvm/debugfs.c  | 455 ++++++++--------
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c   |  42 +-
 .../net/wireless/intel/iwlwifi/fw/debugfs.c   |  23 +-
 drivers/net/wireless/intel/iwlwifi/mei/main.c |  18 +-
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   7 +-
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  81 ++-
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  | 227 ++++----
 .../net/wireless/intel/iwlwifi/mvm/debugfs.h  |   9 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c   |  62 ++-
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  85 ++-
 .../net/wireless/marvell/libertas/debugfs.c   | 242 ++++-----
 .../net/wireless/marvell/mwifiex/debugfs.c    | 183 +++----
 .../wireless/mediatek/mt76/mt7615/debugfs.c   |  20 +-
 .../wireless/mediatek/mt76/mt7915/debugfs.c   |  52 +-
 .../wireless/mediatek/mt76/mt7996/debugfs.c   |  33 +-
 .../net/wireless/ralink/rt2x00/rt2x00debug.c  | 122 ++---
 drivers/net/wireless/realtek/rtlwifi/debug.c  |   5 +-
 drivers/net/wireless/realtek/rtw88/debug.c    | 163 +++---
 drivers/net/wireless/realtek/rtw89/debug.c    | 155 +++---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c    |  20 +-
 drivers/net/wireless/silabs/wfx/debug.c       |  34 +-
 drivers/net/wireless/st/cw1200/debug.c        |  10 +-
 drivers/net/wireless/ti/wl1251/debugfs.c      |  38 +-
 drivers/net/wireless/ti/wl18xx/debugfs.c      |  73 ++-
 drivers/net/wireless/ti/wlcore/debugfs.c      | 373 ++++++-------
 drivers/net/wireless/ti/wlcore/debugfs.h      |  37 +-
 drivers/net/wwan/iosm/iosm_ipc_trace.c        |  21 +-
 drivers/net/wwan/wwan_core.c                  |  26 +-
 drivers/net/wwan/wwan_hwsim.c                 |  42 +-
 drivers/net/xen-netback/xenbus.c              |  19 +-
 drivers/nfc/virtual_ncidev.c                  |  21 +-
 drivers/ntb/hw/amd/ntb_hw_amd.c               |  10 +-
 drivers/ntb/hw/idt/ntb_hw_idt.c               |  29 +-
 drivers/ntb/hw/intel/ntb_hw_gen1.c            |  21 +-
 drivers/ntb/hw/intel/ntb_hw_gen3.c            |   8 +-
 drivers/ntb/hw/intel/ntb_hw_gen3.h            |   3 +-
 drivers/ntb/hw/intel/ntb_hw_gen4.c            |   8 +-
 drivers/ntb/hw/intel/ntb_hw_gen4.h            |   5 +-
 drivers/ntb/ntb_transport.c                   |   9 +-
 drivers/ntb/test/ntb_perf.c                   |  49 +-
 drivers/ntb/test/ntb_tool.c                   | 307 +++++------
 drivers/nvme/host/fabrics.c                   |  12 +-
 drivers/opp/debugfs.c                         |   9 +-
 drivers/parisc/eisa_eeprom.c                  |  12 +-
 drivers/pci/hotplug/cpqphp_sysfs.c            |   9 +-
 drivers/pci/pcie/aer_inject.c                 |   9 +-
 drivers/pci/switch/switchtec.c                |  33 +-
 drivers/pci/vgaarb.c                          |  21 +-
 drivers/phy/mediatek/phy-mtk-tphy.c           |  28 +-
 drivers/pinctrl/pinmux.c                      |  10 +-
 drivers/platform/chrome/cros_ec_chardev.c     |  20 +-
 drivers/platform/chrome/cros_ec_debugfs.c     |  33 +-
 drivers/platform/chrome/wilco_ec/debugfs.c    |  19 +-
 drivers/platform/chrome/wilco_ec/event.c      |  18 +-
 drivers/platform/chrome/wilco_ec/telemetry.c  |  20 +-
 drivers/platform/goldfish/goldfish_pipe.c     |   6 +-
 drivers/platform/olpc/olpc-ec.c               |  15 +-
 .../surface/surface_aggregator_cdev.c         |   3 +-
 drivers/platform/surface/surface_dtx.c        |   3 +-
 drivers/platform/x86/amd/pmc/pmc.c            |  21 +-
 drivers/platform/x86/amd/pmf/tee-if.c         |  10 +-
 drivers/platform/x86/apple-gmux.c             |  25 +-
 drivers/platform/x86/asus-wmi.c               |   2 +-
 drivers/platform/x86/dell/dell-smbios-wmi.c   |  11 +-
 drivers/platform/x86/dell/dell-smo8800.c      |   3 +-
 drivers/platform/x86/intel/pmc/core.c         |  24 +-
 drivers/platform/x86/intel/pmc/core.h         |   4 +-
 .../platform/x86/intel/telemetry/debugfs.c    |  24 +-
 drivers/platform/x86/intel/tpmi.c             |  11 +-
 drivers/platform/x86/sony-laptop.c            |   3 +-
 drivers/rapidio/devices/rio_mport_cdev.c      |  14 +-
 drivers/ras/amd/fmpm.c                        |   2 +-
 drivers/ras/debugfs.c                         |   2 +-
 drivers/regulator/core.c                      |  12 +-
 drivers/remoteproc/remoteproc_cdev.c          |   9 +-
 drivers/remoteproc/remoteproc_debugfs.c       |  68 ++-
 drivers/rtc/dev.c                             |  20 +-
 drivers/rtc/rtc-m41t80.c                      |  18 +-
 drivers/s390/block/dasd.c                     |  34 +-
 drivers/s390/block/dasd_eer.c                 |  12 +-
 drivers/s390/block/dasd_int.h                 |   1 +
 drivers/s390/block/dasd_proc.c                |   2 +-
 drivers/s390/char/fs3270.c                    |   6 +-
 drivers/s390/char/hmcdrv_dev.c                |  12 +-
 drivers/s390/char/monreader.c                 |  16 +-
 drivers/s390/char/monwriter.c                 |  12 +-
 drivers/s390/char/tape_char.c                 |  10 +-
 drivers/s390/char/vmcp.c                      |  23 +-
 drivers/s390/char/vmlogrdr.c                  |  15 +-
 drivers/s390/char/vmur.c                      |   6 +-
 drivers/s390/char/zcore.c                     |  25 +-
 drivers/s390/cio/cio_inject.c                 |  11 +-
 drivers/s390/cio/qdio_debug.c                 |  12 +-
 drivers/s390/crypto/zcrypt_api.c              |  10 +-
 drivers/sbus/char/envctrl.c                   |  27 +-
 drivers/sbus/char/flash.c                     |  14 +-
 drivers/sbus/char/oradax.c                    |  37 +-
 drivers/scsi/bfa/bfad_debugfs.c               |  51 +-
 drivers/scsi/csiostor/csio_init.c             |  16 +-
 drivers/scsi/cxlflash/ocxl_hw.c               |  17 +-
 drivers/scsi/fnic/fnic_debugfs.c              |  82 ++-
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c        | 105 ++--
 drivers/scsi/lpfc/lpfc_debugfs.c              | 427 +++++++--------
 drivers/scsi/megaraid/megaraid_sas_debugfs.c  |   9 +-
 drivers/scsi/mpt3sas/mpt3sas_debugfs.c        |  10 +-
 drivers/scsi/qedf/qedf_dbg.h                  |   6 +-
 drivers/scsi/qedf/qedf_debugfs.c              |  76 ++-
 drivers/scsi/qedi/qedi_dbg.h                  |   6 +-
 drivers/scsi/qedi/qedi_debugfs.c              |  20 +-
 drivers/scsi/qla2xxx/qla_dfs.c                |  12 +-
 drivers/scsi/scsi_debug.c                     |  26 +-
 drivers/scsi/sg.c                             |   6 +-
 drivers/scsi/snic/snic_debugfs.c              |  25 +-
 drivers/scsi/st.c                             |  10 +-
 drivers/soc/aspeed/aspeed-lpc-snoop.c         |   3 +-
 drivers/soc/fsl/dpaa2-console.c               |  15 +-
 drivers/soc/mediatek/mtk-svs.c                |  15 +-
 drivers/soc/qcom/cmd-db.c                     |   2 +-
 drivers/soc/qcom/qcom_aoss.c                  |  14 +-
 drivers/soc/qcom/rmtfs_mem.c                  |  38 +-
 drivers/soc/qcom/socinfo.c                    |   4 +-
 drivers/spi/spidev.c                          |  33 +-
 drivers/staging/axis-fifo/axis-fifo.c         |  35 +-
 drivers/staging/fieldbus/dev_core.c           |   6 +-
 drivers/staging/greybus/camera.c              |  22 +-
 drivers/staging/greybus/raw.c                 |   6 +-
 drivers/staging/media/av7110/av7110_av.c      |   6 +-
 drivers/staging/media/av7110/av7110_ca.c      |   6 +-
 drivers/staging/pi433/pi433_if.c              |  13 +-
 .../interface/vchiq_arm/vchiq_debugfs.c       |  16 +-
 drivers/staging/vme_user/vme_user.c           |   6 +-
 drivers/thunderbolt/debugfs.c                 |  19 +-
 drivers/tty/serial/pch_uart.c                 |   9 +-
 drivers/tty/vt/vc_screen.c                    |  32 +-
 drivers/ufs/core/ufs-debugfs.c                |  14 +-
 drivers/uio/uio.c                             |  22 +-
 drivers/usb/chipidea/debug.c                  |  13 +-
 drivers/usb/class/cdc-wdm.c                   |  18 +-
 drivers/usb/class/usblp.c                     |   6 +-
 drivers/usb/class/usbtmc.c                    |   6 +-
 drivers/usb/core/devices.c                    |   3 +-
 drivers/usb/core/devio.c                      |   3 +-
 drivers/usb/dwc2/debugfs.c                    |  12 +-
 drivers/usb/dwc3/debugfs.c                    |  48 +-
 drivers/usb/fotg210/fotg210-hcd.c             |  17 +-
 drivers/usb/gadget/function/f_fs.c            |   6 +-
 drivers/usb/gadget/function/f_hid.c           |  17 +-
 drivers/usb/gadget/function/f_printer.c       |  26 +-
 drivers/usb/gadget/legacy/inode.c             |   6 +-
 drivers/usb/gadget/udc/atmel_usba_udc.c       |  15 +-
 drivers/usb/gadget/udc/renesas_usb3.c         |  14 +-
 drivers/usb/host/ehci-dbg.c                   |  19 +-
 drivers/usb/host/ohci-dbg.c                   |  17 +-
 drivers/usb/host/uhci-debug.c                 |   9 +-
 drivers/usb/host/xhci-debugfs.c               |  28 +-
 drivers/usb/image/mdc800.c                    |  15 +-
 drivers/usb/misc/adutux.c                     |   6 +-
 drivers/usb/misc/chaoskey.c                   |  13 +-
 drivers/usb/misc/idmouse.c                    |  15 +-
 drivers/usb/misc/iowarrior.c                  |   6 +-
 drivers/usb/misc/ldusb.c                      |  24 +-
 drivers/usb/misc/legousbtower.c               |  26 +-
 drivers/usb/misc/sisusbvga/sisusbvga.c        |   6 +-
 drivers/usb/misc/usblcd.c                     |  20 +-
 drivers/usb/misc/yurex.c                      |  19 +-
 drivers/usb/mon/mon_bin.c                     |   3 +-
 drivers/usb/mon/mon_stat.c                    |   9 +-
 drivers/usb/mon/mon_text.c                    |   6 +-
 drivers/usb/mtu3/mtu3_debugfs.c               |  40 +-
 drivers/usb/musb/musb_debugfs.c               |  24 +-
 drivers/usb/usb-skeleton.c                    |  26 +-
 .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c    |  31 +-
 drivers/vfio/pci/mlx5/main.c                  |   6 +-
 drivers/vfio/pci/pds/lm.c                     |  32 +-
 drivers/vfio/vfio_main.c                      |   6 +-
 drivers/video/fbdev/core/fb_chrdev.c          |   6 +-
 drivers/video/fbdev/pxa3xx-gcu.c              |  12 +-
 drivers/virt/fsl_hypervisor.c                 |  14 +-
 drivers/watchdog/acquirewdt.c                 |   8 +-
 drivers/watchdog/advantechwdt.c               |   8 +-
 drivers/watchdog/alim1535_wdt.c               |   8 +-
 drivers/watchdog/alim7101_wdt.c               |   8 +-
 drivers/watchdog/at91rm9200_wdt.c             |   7 +-
 drivers/watchdog/ath79_wdt.c                  |   9 +-
 drivers/watchdog/cpu5wdt.c                    |   6 +-
 drivers/watchdog/cpwd.c                       |  13 +-
 drivers/watchdog/eurotechwdt.c                |  14 +-
 drivers/watchdog/gef_wdt.c                    |   9 +-
 drivers/watchdog/geodewdt.c                   |   8 +-
 drivers/watchdog/ib700wdt.c                   |   8 +-
 drivers/watchdog/ibmasr.c                     |   8 +-
 drivers/watchdog/indydog.c                    |   6 +-
 drivers/watchdog/it8712f_wdt.c                |   8 +-
 drivers/watchdog/m54xx_wdt.c                  |   9 +-
 drivers/watchdog/machzwd.c                    |   8 +-
 drivers/watchdog/mei_wdt.c                    |  18 +-
 drivers/watchdog/mixcomwd.c                   |   9 +-
 drivers/watchdog/mtx-1_wdt.c                  |   6 +-
 drivers/watchdog/nv_tco.c                     |   8 +-
 drivers/watchdog/pc87413_wdt.c                |  14 +-
 drivers/watchdog/pcwd.c                       |  15 +-
 drivers/watchdog/pcwd_pci.c                   |  15 +-
 drivers/watchdog/pcwd_usb.c                   |  16 +-
 drivers/watchdog/pika_wdt.c                   |   9 +-
 drivers/watchdog/rc32434_wdt.c                |   8 +-
 drivers/watchdog/rdc321x_wdt.c                |   6 +-
 drivers/watchdog/riowd.c                      |   6 +-
 drivers/watchdog/sa1100_wdt.c                 |   6 +-
 drivers/watchdog/sb_wdog.c                    |   8 +-
 drivers/watchdog/sbc60xxwdt.c                 |   8 +-
 drivers/watchdog/sbc7240_wdt.c                |   8 +-
 drivers/watchdog/sbc8360.c                    |   9 +-
 drivers/watchdog/sbc_epx_c3.c                 |   6 +-
 drivers/watchdog/sbc_fitpc2_wdt.c             |   9 +-
 drivers/watchdog/sc1200wdt.c                  |   9 +-
 drivers/watchdog/sc520_wdt.c                  |   8 +-
 drivers/watchdog/sch311x_wdt.c                |   8 +-
 drivers/watchdog/scx200_wdt.c                 |   9 +-
 drivers/watchdog/smsc37b787_wdt.c             |   8 +-
 drivers/watchdog/w83877f_wdt.c                |   8 +-
 drivers/watchdog/w83977f_wdt.c                |   8 +-
 drivers/watchdog/wafer5823wdt.c               |   8 +-
 drivers/watchdog/watchdog_dev.c               |  10 +-
 drivers/watchdog/wdrtas.c                     |  21 +-
 drivers/watchdog/wdt.c                        |  28 +-
 drivers/watchdog/wdt285.c                     |   7 +-
 drivers/watchdog/wdt977.c                     |   9 +-
 drivers/watchdog/wdt_pci.c                    |  21 +-
 drivers/xen/evtchn.c                          |  25 +-
 drivers/xen/mcelog.c                          |  17 +-
 drivers/xen/xenbus/xenbus_dev_frontend.c      |  24 +-
 drivers/xen/xenfs/super.c                     |   7 +-
 drivers/xen/xenfs/xenstored.c                 |  11 +-
 drivers/xen/xenfs/xensyms.c                   |   2 +-
 fs/9p/vfs_dir.c                               |   4 +-
 fs/adfs/dir.c                                 |   2 +-
 fs/affs/dir.c                                 |   2 +-
 fs/autofs/root.c                              |   4 +-
 fs/bcachefs/chardev.c                         |  10 +-
 fs/bcachefs/debug.c                           |  24 +-
 fs/bcachefs/fs.c                              |   2 +-
 fs/bcachefs/thread_with_file.c                |  14 +-
 fs/befs/linuxvfs.c                            |   2 +-
 fs/bfs/dir.c                                  |   2 +-
 fs/binfmt_misc.c                              |  27 +-
 fs/btrfs/inode.c                              |   2 +-
 fs/cachefiles/daemon.c                        |  35 +-
 fs/cachefiles/internal.h                      |   4 +-
 fs/cachefiles/ondemand.c                      |   5 +-
 fs/ceph/dir.c                                 |  15 +-
 fs/coda/dir.c                                 |   2 +-
 fs/coda/psdev.c                               |  17 +-
 fs/configfs/dir.c                             |   2 +-
 fs/cramfs/inode.c                             |   2 +-
 fs/debugfs/file.c                             | 160 +++---
 fs/dlm/debug_fs.c                             |  51 +-
 fs/dlm/plock.c                                |  16 +-
 fs/dlm/user.c                                 |  17 +-
 fs/ecryptfs/file.c                            |   2 +-
 fs/ecryptfs/miscdev.c                         |  24 +-
 fs/efivarfs/file.c                            |  31 +-
 fs/efs/dir.c                                  |   2 +-
 fs/erofs/dir.c                                |   2 +-
 fs/eventfd.c                                  |  12 +-
 fs/exfat/dir.c                                |   2 +-
 fs/ext2/dir.c                                 |   2 +-
 fs/ext4/dir.c                                 |   2 +-
 fs/f2fs/dir.c                                 |   2 +-
 fs/fat/dir.c                                  |   2 +-
 fs/file_table.c                               |   4 +-
 fs/freevxfs/vxfs_lookup.c                     |   2 +-
 fs/fsopen.c                                   |  11 +-
 fs/fuse/control.c                             |  86 ++-
 fs/fuse/dir.c                                 |   2 +-
 fs/gfs2/glock.c                               |   6 +-
 fs/hfs/dir.c                                  |   2 +-
 fs/hfsplus/dir.c                              |   2 +-
 fs/hostfs/hostfs_kern.c                       |   2 +-
 fs/hpfs/dir.c                                 |   2 +-
 fs/isofs/dir.c                                |   2 +-
 fs/jffs2/dir.c                                |   2 +-
 fs/jfs/namei.c                                |   2 +-
 fs/kernfs/dir.c                               |   2 +-
 fs/libfs.c                                    | 127 ++++-
 fs/minix/dir.c                                |   2 +-
 fs/nfs/dir.c                                  |   2 +-
 fs/nfsd/nfs4state.c                           |   5 +-
 fs/nfsd/nfsctl.c                              |  10 +-
 fs/nilfs2/dir.c                               |   2 +-
 fs/notify/fanotify/fanotify_user.c            |   6 +-
 fs/notify/inotify/inotify_user.c              |   3 +-
 fs/ntfs3/dir.c                                |   2 +-
 fs/ocfs2/cluster/heartbeat.c                  |  15 +-
 fs/ocfs2/cluster/netdebug.c                   |  17 +-
 fs/ocfs2/dlm/dlmdebug.c                       |  18 +-
 fs/ocfs2/dlmfs/dlmfs.c                        |  38 +-
 fs/ocfs2/dlmglue.c                            |   2 +-
 fs/ocfs2/file.c                               |   4 +-
 fs/ocfs2/stack_user.c                         |   6 +-
 fs/ocfs2/super.c                              |  15 +-
 fs/omfs/dir.c                                 |   2 +-
 fs/open.c                                     |   4 +-
 fs/openpromfs/inode.c                         |   4 +-
 fs/orangefs/devorangefs-req.c                 |  23 +-
 fs/orangefs/dir.c                             |   2 +-
 fs/orangefs/orangefs-debugfs.c                |  42 +-
 fs/overlayfs/readdir.c                        |   2 +-
 fs/proc/array.c                               |   2 +-
 fs/proc/base.c                                | 328 ++++++------
 fs/proc/fd.c                                  |   6 +-
 fs/proc/generic.c                             |   2 +-
 fs/proc/inode.c                               |  18 +-
 fs/proc/namespaces.c                          |   2 +-
 fs/proc/proc_net.c                            |   2 +-
 fs/proc/proc_sysctl.c                         |   2 +-
 fs/proc/root.c                                |   2 +-
 fs/proc/task_mmu.c                            |  37 +-
 fs/proc/task_nommu.c                          |   2 +-
 fs/pstore/ftrace.c                            |  16 +-
 fs/pstore/inode.c                             |  13 +-
 fs/pstore/pmsg.c                              |   3 +-
 fs/qnx4/dir.c                                 |   2 +-
 fs/qnx6/dir.c                                 |   2 +-
 fs/read_write.c                               |  74 ++-
 fs/reiserfs/dir.c                             |   2 +-
 fs/romfs/super.c                              |   2 +-
 fs/smb/client/cifsfs.c                        |   2 +-
 fs/squashfs/dir.c                             |   2 +-
 fs/sysv/dir.c                                 |   2 +-
 fs/tracefs/event_inode.c                      |   2 +-
 fs/tracefs/inode.c                            |  12 +-
 fs/ubifs/debug.c                              |  57 +-
 fs/ubifs/dir.c                                |   2 +-
 fs/udf/dir.c                                  |   2 +-
 fs/ufs/dir.c                                  |   2 +-
 fs/vboxsf/dir.c                               |   2 +-
 fs/xfs/scrub/stats.c                          |  27 +-
 fs/xfs/xfs_file.c                             |   2 +-
 fs/zonefs/super.c                             |   2 +-
 include/drm/drm_accel.h                       |   2 +-
 include/drm/drm_file.h                        |   3 +-
 include/drm/drm_gem.h                         |   2 +-
 include/drm/drm_gem_dma_helper.h              |   2 +-
 include/linux/debugfs.h                       |  55 +-
 include/linux/fs.h                            |  48 +-
 include/linux/ftrace.h                        |  11 +-
 include/linux/kstrtox.h                       |  33 +-
 include/linux/nsc_gpio.h                      |   8 +-
 include/linux/seq_file.h                      |   8 +-
 include/linux/string.h                        |   4 +
 include/linux/string_helpers.h                |   3 +-
 include/linux/uio.h                           |   3 +
 include/linux/user_namespace.h                |  10 +-
 include/misc/cxl.h                            |   3 +-
 include/net/cfg80211.h                        |  24 +-
 io_uring/rw.c                                 |  70 ---
 ipc/mqueue.c                                  |  10 +-
 kernel/bpf/bpf_iter.c                         |  14 +-
 kernel/bpf/inode.c                            |   2 +-
 kernel/bpf/syscall.c                          |  18 +-
 kernel/dma/debug.c                            |  15 +-
 kernel/events/core.c                          |   3 +-
 kernel/fail_function.c                        |  10 +-
 kernel/gcov/fs.c                              |  23 +-
 kernel/irq/debugfs.c                          |  12 +-
 kernel/kcsan/debugfs.c                        |  10 +-
 kernel/kprobes.c                              |  15 +-
 kernel/locking/lock_events.c                  |  18 +-
 kernel/locking/lock_events.h                  |   4 +-
 kernel/locking/qspinlock_stat.h               |   7 +-
 kernel/module/stats.c                         |   8 +-
 kernel/module/tracking.c                      |   2 +-
 kernel/power/qos.c                            |  21 +-
 kernel/power/user.c                           |  28 +-
 kernel/printk/printk.c                        |  12 +-
 kernel/relay.c                                |  20 +-
 kernel/sched/debug.c                          |  53 +-
 kernel/time/posix-clock.c                     |   3 +-
 kernel/time/test_udelay.c                     |  10 +-
 kernel/trace/blktrace.c                       |  19 +-
 kernel/trace/ftrace.c                         |  68 ++-
 kernel/trace/rv/rv.c                          |  58 +-
 kernel/trace/rv/rv_reactors.c                 |  32 +-
 kernel/trace/trace.c                          | 386 ++++++--------
 kernel/trace/trace_dynevent.c                 |   5 +-
 kernel/trace/trace_events.c                   | 116 ++--
 kernel/trace/trace_events_hist.c              |   4 +-
 kernel/trace/trace_events_inject.c            |  19 +-
 kernel/trace/trace_events_synth.c             |   5 +-
 kernel/trace/trace_events_trigger.c           |  22 +-
 kernel/trace/trace_events_user.c              |  17 +-
 kernel/trace/trace_functions_graph.c          |  20 +-
 kernel/trace/trace_hwlat.c                    |  20 +-
 kernel/trace/trace_kprobe.c                   |   7 +-
 kernel/trace/trace_osnoise.c                  |  42 +-
 kernel/trace/trace_printk.c                   |   2 +-
 kernel/trace/trace_recursion_record.c         |  10 +-
 kernel/trace/trace_sched_switch.c             |  21 +-
 kernel/trace/trace_stack.c                    |  27 +-
 kernel/trace/trace_stat.c                     |   2 +-
 kernel/trace/trace_uprobe.c                   |   7 +-
 kernel/user_namespace.c                       |  39 +-
 lib/dynamic_debug.c                           |   5 +-
 lib/kstrtox.c                                 |  46 +-
 lib/kunit/debugfs.c                           |  13 +-
 lib/string_helpers.c                          |  14 +-
 lib/test_firmware.c                           |  10 +-
 lib/xz/xz_dec_test.c                          |   9 +-
 mm/damon/dbgfs.c                              |  84 +--
 mm/huge_memory.c                              |  10 +-
 mm/kmemleak.c                                 |   5 +-
 mm/page_owner.c                               |   5 +-
 mm/shrinker_debug.c                           |  12 +-
 mm/slub.c                                     |   2 +-
 mm/util.c                                     |  57 ++
 mm/vmscan.c                                   |  14 +-
 net/6lowpan/debugfs.c                         |  14 +-
 net/bluetooth/6lowpan.c                       |  12 +-
 net/bluetooth/hci_debugfs.c                   | 150 +++---
 net/bluetooth/selftest.c                      |   9 +-
 net/bluetooth/smp.c                           |   9 +-
 net/core/datagram.c                           |  10 +-
 net/l2tp/l2tp_debugfs.c                       |   2 +-
 net/mac80211/debugfs.c                        | 185 +++----
 net/mac80211/debugfs.h                        |   4 +-
 net/mac80211/debugfs_key.c                    |  81 ++-
 net/mac80211/debugfs_netdev.c                 | 126 ++---
 net/mac80211/debugfs_sta.c                    | 146 +++--
 net/mac80211/rate.c                           |  10 +-
 net/mac80211/rc80211_minstrel_ht_debugfs.c    |  11 +-
 net/rfkill/core.c                             |  22 +-
 net/sunrpc/cache.c                            |  14 +-
 net/sunrpc/debugfs.c                          |   4 +-
 net/sunrpc/rpc_pipe.c                         |   8 +-
 net/wireless/debugfs.c                        |  57 +-
 samples/vfio-mdev/mtty.c                      |  30 +-
 security/apparmor/apparmorfs.c                |  55 +-
 security/inode.c                              |   9 +-
 security/integrity/evm/evm_secfs.c            |  60 +--
 security/integrity/ima/ima_fs.c               |  41 +-
 security/landlock/syscalls.c                  |  15 +-
 security/lockdown/lockdown.c                  |  10 +-
 security/safesetid/securityfs.c               |  14 +-
 security/selinux/selinuxfs.c                  | 168 +++---
 security/smack/smackfs.c                      | 281 +++++-----
 security/tomoyo/securityfs_if.c               |  21 +-
 sound/core/compress_offload.c                 |   7 +-
 sound/core/control.c                          |  14 +-
 sound/core/hwdep.c                            |   6 +-
 sound/core/init.c                             |  10 +-
 sound/core/jack.c                             |  83 ++-
 sound/core/oss/pcm_oss.c                      |   6 +-
 sound/core/pcm_native.c                       |  22 +-
 sound/core/rawmidi.c                          |   6 +-
 sound/core/seq/oss/seq_oss.c                  |  11 +-
 sound/core/seq/seq_clientmgr.c                |   8 +-
 sound/core/timer.c                            |  23 +-
 sound/drivers/pcmtest.c                       |  36 +-
 sound/oss/dmasound/dmasound_core.c            |   8 +-
 sound/soc/fsl/imx-audmux.c                    |  11 +-
 sound/soc/intel/avs/debugfs.c                 |  69 +--
 sound/soc/intel/avs/pcm.c                     |   9 +-
 sound/soc/intel/skylake/skl-debug.c           |  19 +-
 sound/soc/soc-dapm.c                          |  21 +-
 sound/soc/soc-pcm.c                           |  10 +-
 sound/soc/sof/debug.c                         |  34 +-
 sound/soc/sof/ipc3-dtrace.c                   |  17 +-
 sound/soc/sof/ipc4-mtrace.c                   |  17 +-
 sound/soc/sof/ipc4-telemetry.c                |  14 +-
 sound/soc/sof/sof-client-ipc-flood-test.c     |  19 +-
 .../soc/sof/sof-client-ipc-kernel-injector.c  |  15 +-
 sound/soc/sof/sof-client-ipc-msg-injector.c   |  67 ++-
 sound/soc/sof/sof-client-probes.c             |  31 +-
 virt/kvm/kvm_main.c                           |  10 +-
 859 files changed, 11379 insertions(+), 12492 deletions(-)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

* [PATCH 001/437] fs: split do_loop_readv_writev() into separate read/write side helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 002/437] fs: add generic read/write iterator helpers Jens Axboe
                   ` (436 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

No functional changes, just in preparation for using these separately.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/read_write.c | 43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index d4c036e82b6c..82ec75937b08 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -746,8 +746,10 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
 }
 
 /* Do it by hand, with file-ops */
-static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
-		loff_t *ppos, int type, rwf_t flags)
+static ssize_t do_loop_readv(struct file *file, struct iov_iter *iter,
+			     loff_t *ppos, rwf_t flags,
+			     ssize_t (*read)(struct file *, char __user *,
+					     size_t, loff_t *))
 {
 	ssize_t ret = 0;
 
@@ -757,14 +759,35 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter,
 	while (iov_iter_count(iter)) {
 		ssize_t nr;
 
-		if (type == READ) {
-			nr = filp->f_op->read(filp, iter_iov_addr(iter),
-						iter_iov_len(iter), ppos);
-		} else {
-			nr = filp->f_op->write(filp, iter_iov_addr(iter),
-						iter_iov_len(iter), ppos);
+		nr = read(file, iter_iov_addr(iter), iter_iov_len(iter), ppos);
+		if (nr < 0) {
+			if (!ret)
+				ret = nr;
+			break;
 		}
+		ret += nr;
+		if (nr != iter_iov_len(iter))
+			break;
+		iov_iter_advance(iter, nr);
+	}
+
+	return ret;
+}
+
+static ssize_t do_loop_writev(struct file *file, struct iov_iter *iter,
+			      loff_t *ppos, rwf_t flags,
+			      ssize_t (*write)(struct file *, const char __user *,
+					       size_t, loff_t *))
+{
+	ssize_t ret = 0;
+
+	if (flags & ~RWF_HIPRI)
+		return -EOPNOTSUPP;
+
+	while (iov_iter_count(iter)) {
+		ssize_t nr;
 
+		nr = write(file, iter_iov_addr(iter), iter_iov_len(iter), ppos);
 		if (nr < 0) {
 			if (!ret)
 				ret = nr;
@@ -931,7 +954,7 @@ static ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,
 	if (file->f_op->read_iter)
 		ret = do_iter_readv_writev(file, &iter, pos, READ, flags);
 	else
-		ret = do_loop_readv_writev(file, &iter, pos, READ, flags);
+		ret = do_loop_readv(file, &iter, pos, flags, file->f_op->read);
 out:
 	if (ret >= 0)
 		fsnotify_access(file);
@@ -970,7 +993,7 @@ static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
 	if (file->f_op->write_iter)
 		ret = do_iter_readv_writev(file, &iter, pos, WRITE, flags);
 	else
-		ret = do_loop_readv_writev(file, &iter, pos, WRITE, flags);
+		ret = do_loop_writev(file, &iter, pos, flags, file->f_op->write);
 	if (ret > 0)
 		fsnotify_modify(file);
 	file_end_write(file);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
  2024-04-11 15:12 ` [PATCH 001/437] fs: split do_loop_readv_writev() into separate read/write side helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-15 19:55   ` Al Viro
  2024-04-11 15:12 ` [PATCH 003/437] fs: add helpers for defining " Jens Axboe
                   ` (435 subsequent siblings)
  437 siblings, 1 reply; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

We already do this internally for vfs_readv() and vfs_writev(), which
need to check what method to use. Add generic helpers for this so that
drivers can do this themselves, if they haven't converted to using the
read/write iterator file_operations hooks just yet.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/read_write.c    | 18 ++++++++++++++++++
 include/linux/fs.h |  6 ++++++
 2 files changed, 24 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 82ec75937b08..1d035293607b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -802,6 +802,24 @@ static ssize_t do_loop_writev(struct file *file, struct iov_iter *iter,
 	return ret;
 }
 
+/* generic read side helper for drivers converting to ->read_iter() */
+ssize_t vfs_read_iter(struct kiocb *iocb, struct iov_iter *to,
+		      ssize_t (*read)(struct file *, char __user *,
+				     size_t, loff_t *))
+{
+	return do_loop_readv(iocb->ki_filp, to, &iocb->ki_pos, 0, read);
+}
+EXPORT_SYMBOL(vfs_read_iter);
+
+/* generic write side helper for drivers converting to ->write_iter() */
+ssize_t vfs_write_iter(struct kiocb *iocb, struct iov_iter *from,
+		       ssize_t (*write)(struct file *, const char __user *,
+				       size_t, loff_t *))
+{
+	return do_loop_writev(iocb->ki_filp, from, &iocb->ki_pos, 0, write);
+}
+EXPORT_SYMBOL(vfs_write_iter);
+
 ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb,
 			   struct iov_iter *iter)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8dfd53b52744..fd862985a309 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2119,6 +2119,12 @@ extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
 				   loff_t, size_t, unsigned int);
+ssize_t vfs_write_iter(struct kiocb *iocb, struct iov_iter *from,
+		       ssize_t (*write)(struct file *, const char __user *,
+				        size_t, loff_t *));
+ssize_t vfs_read_iter(struct kiocb *iocb, struct iov_iter *to,
+		      ssize_t (*read)(struct file *, char __user *,
+				      size_t, loff_t *));
 int __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 				    struct file *file_out, loff_t pos_out,
 				    loff_t *len, unsigned int remap_flags,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 003/437] fs: add helpers for defining read/write iterator helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
  2024-04-11 15:12 ` [PATCH 001/437] fs: split do_loop_readv_writev() into separate read/write side helpers Jens Axboe
  2024-04-11 15:12 ` [PATCH 002/437] fs: add generic read/write iterator helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 004/437] fs: add simple_copy_{to,from}_iter() helpers Jens Axboe
                   ` (434 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

To ease conversion for drivers, add helpers that allow a driver to simply
wrap their existing read/write file_operations hook and turn it into one
that is appropriate for ->read_iter() or ->write_iter().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/fs.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index fd862985a309..72de0b1d5647 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2141,6 +2141,22 @@ extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
 					struct file *dst_file, loff_t dst_pos,
 					loff_t len, unsigned int remap_flags);
 
+/*
+ * Drivers can use these to ease transition to using ->read_iter() instead
+ * of ->read(), and ->write_iter() instead of ->write(). Ideally these will
+ * go away one day.
+ */
+#define FOPS_READ_ITER_HELPER(name)					\
+static ssize_t name## _iter(struct kiocb *iocb, struct iov_iter *to)	\
+{									\
+	return vfs_read_iter(iocb, to, name);				\
+}
+#define FOPS_WRITE_ITER_HELPER(name)					\
+static ssize_t name## _iter(struct kiocb *iocb, struct iov_iter *from)	\
+{									\
+	return vfs_write_iter(iocb, from, name);			\
+}
+
 /**
  * enum freeze_holder - holder of the freeze
  * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 004/437] fs: add simple_copy_{to,from}_iter() helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (2 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 003/437] fs: add helpers for defining " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 005/437] uio: add get/put_iter helpers Jens Axboe
                   ` (433 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

While doing so, rename the networking helper that has the same name.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/libfs.c          | 73 ++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/fs.h  |  5 ++++
 net/core/datagram.c | 10 +++----
 3 files changed, 82 insertions(+), 6 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 3a6f2cb364f8..074cfacc377f 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1102,13 +1102,84 @@ ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
 	if (count > available - pos)
 		count = available - pos;
 	res = copy_from_user(to + pos, from, count);
+	if (res < 0)
+		return res;
+	count -= res;
+	*ppos = pos + count;
+	return count;
+}
+EXPORT_SYMBOL(simple_write_to_buffer);
+
+/**
+ * simple_copy_to_iter - copy data userspace to iter
+ * @from: the buffer to read from
+ * @ppos: the current position in the buffer
+ * @count: the maximum number of bytes to copy
+ * @to: the iov_iter to copy to
+ *
+ * The simple_copy_to_iter() function reads up to @count bytes from the
+ * buffer @from at offset @ppos into the user space address starting at @to.
+ *
+ * On success, the number of bytes copied is returned, or negative value is
+ * returned on error.
+ **/
+ssize_t simple_copy_to_iter(const void *from, loff_t *ppos, size_t count,
+			    struct iov_iter *to)
+{
+	size_t available = iov_iter_count(to);
+	loff_t pos = *ppos;
+	size_t ret;
+
+	if (pos < 0)
+		return -EINVAL;
+	if (pos >= available || !count)
+		return 0;
+	if (count > available - pos)
+		count = available - pos;
+	ret = copy_to_iter(from + pos, count, to);
+	if (ret < 0)
+		return ret;
+	count -= ret;
+	*ppos = pos + count;
+	return count;
+}
+EXPORT_SYMBOL(simple_copy_to_iter);
+
+/**
+ * simple_copy_from_iter - copy data from iter to user space buffer
+ * @to: the buffer to write to
+ * @available: the size of the buffer
+ * @ppos: the current position in the buffer
+ * @from: the user space buffer to read from
+ * @count: the maximum number of bytes to read
+ *
+ * The simple_write_to_buffer() function reads up to @count bytes from the user
+ * space address starting at @from into the buffer @to at offset @ppos.
+ *
+ * On success, the number of bytes written is returned and the offset @ppos is
+ * advanced by this number, or negative value is returned on error.
+ **/
+ssize_t simple_copy_from_iter(void *to, loff_t *ppos, size_t count,
+			      struct iov_iter *from)
+{
+	size_t available = iov_iter_count(to);
+	loff_t pos = *ppos;
+	size_t res;
+
+	if (pos < 0)
+		return -EINVAL;
+	if (pos >= available || !count)
+		return 0;
+	if (count > available - pos)
+		count = available - pos;
+	res = copy_from_iter(to + pos, count, from);
 	if (res == count)
 		return -EFAULT;
 	count -= res;
 	*ppos = pos + count;
 	return count;
 }
-EXPORT_SYMBOL(simple_write_to_buffer);
+EXPORT_SYMBOL(simple_copy_from_iter);
 
 /**
  * memory_read_from_buffer - copy data from the buffer
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 72de0b1d5647..f75049fa1d50 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3353,6 +3353,11 @@ extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
 extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
 		const void __user *from, size_t count);
 
+ssize_t simple_copy_to_iter(const void *from, loff_t *ppos, size_t count,
+			    struct iov_iter *to);
+ssize_t simple_copy_from_iter(void *to, loff_t *ppos, size_t count,
+			      struct iov_iter *from);
+
 struct offset_ctx {
 	struct maple_tree	mt;
 	unsigned long		next_offset;
diff --git a/net/core/datagram.c b/net/core/datagram.c
index a8b625abe242..3dfdddeaf695 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -399,7 +399,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
 }
 EXPORT_SYMBOL(skb_kill_datagram);
 
-INDIRECT_CALLABLE_DECLARE(static size_t simple_copy_to_iter(const void *addr,
+INDIRECT_CALLABLE_DECLARE(static size_t __simple_copy_to_iter(const void *addr,
 						size_t bytes,
 						void *data __always_unused,
 						struct iov_iter *i));
@@ -417,7 +417,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 	if (copy > 0) {
 		if (copy > len)
 			copy = len;
-		n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
+		n = INDIRECT_CALL_1(cb, __simple_copy_to_iter,
 				    skb->data + offset, copy, data, to);
 		offset += n;
 		if (n != copy)
@@ -440,7 +440,7 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 
 			if (copy > len)
 				copy = len;
-			n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
+			n = INDIRECT_CALL_1(cb, __simple_copy_to_iter,
 					vaddr + skb_frag_off(frag) + offset - start,
 					copy, data, to);
 			kunmap(page);
@@ -526,7 +526,7 @@ int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
 }
 EXPORT_SYMBOL(skb_copy_and_hash_datagram_iter);
 
-static size_t simple_copy_to_iter(const void *addr, size_t bytes,
+static size_t __simple_copy_to_iter(const void *addr, size_t bytes,
 		void *data __always_unused, struct iov_iter *i)
 {
 	return copy_to_iter(addr, bytes, i);
@@ -544,7 +544,7 @@ int skb_copy_datagram_iter(const struct sk_buff *skb, int offset,
 {
 	trace_skb_copy_datagram_iovec(skb, len);
 	return __skb_datagram_iter(skb, offset, to, len, false,
-			simple_copy_to_iter, NULL);
+			__simple_copy_to_iter, NULL);
 }
 EXPORT_SYMBOL(skb_copy_datagram_iter);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 005/437] uio: add get/put_iter helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (3 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 004/437] fs: add simple_copy_{to,from}_iter() helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 006/437] fs: add uio.h to fs.h Jens Axboe
                   ` (432 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

For users that currently do put_user(val, uaddr) or get_user(val, uaddr),
add iterator versions that do the same thing.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/uio.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/uio.h b/include/linux/uio.h
index 7020adedfa08..ed1711201597 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -215,6 +215,9 @@ bool copy_to_iter_full(const void *addr, size_t bytes, struct iov_iter *i)
 	return false;
 }
 
+#define put_iter(val, to)	!copy_to_iter_full(&(val), sizeof((val)), to)
+#define get_iter(val, from)	!copy_from_iter_full(&(val), sizeof((val)), from)
+
 static __always_inline __must_check
 bool copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 006/437] fs: add uio.h to fs.h
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (4 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 005/437] uio: add get/put_iter helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 007/437] mm/util: add iterdup_nul() and iterdup() helpers Jens Axboe
                   ` (431 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Most conversions will end up pulling in fs.h already, but not uio.h.
As the fs iterators will need that, just include it from fs.h rather
than need to add it everywhere. It's pretty natural to need user copy
helpers for read/write operators anyway.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/fs.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index f75049fa1d50..5806cea7a3ac 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -45,6 +45,7 @@
 #include <linux/slab.h>
 #include <linux/maple_tree.h>
 #include <linux/rw_hint.h>
+#include <linux/uio.h>
 
 #include <asm/byteorder.h>
 #include <uapi/linux/fs.h>
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 007/437] mm/util: add iterdup_nul() and iterdup() helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (5 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 006/437] fs: add uio.h to fs.h Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 008/437] kstrtox: add iov_iter versions of the string conversion helpers Jens Axboe
                   ` (430 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

This is identical to the memdup variants, except it operates on a struct
iov_iter rather than a direct user pointer.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/string.h |  4 +++
 mm/util.c              | 57 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 9ba8b4597009..1983d2bf8840 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -18,6 +18,10 @@ extern void *memdup_user(const void __user *, size_t);
 extern void *vmemdup_user(const void __user *, size_t);
 extern void *memdup_user_nul(const void __user *, size_t);
 
+struct iov_iter;
+void *iterdup_nul(struct iov_iter *, size_t);
+void *iterdup(struct iov_iter *, size_t);
+
 /**
  * memdup_array_user - duplicate array from user space
  * @src: source address in user space
diff --git a/mm/util.c b/mm/util.c
index 669397235787..5d701cf693b0 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -224,6 +224,32 @@ void *memdup_user(const void __user *src, size_t len)
 }
 EXPORT_SYMBOL(memdup_user);
 
+/**
+ * iterdup - duplicate memory region
+ *
+ * @src: source iov_iter
+ * @len: number of bytes to copy
+ *
+ * Return: an ERR_PTR() on failure.  Result is physically
+ * contiguous, to be freed by kfree().
+ */
+void *iterdup(struct iov_iter *src, size_t len)
+{
+	void *p;
+
+	p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN);
+	if (!p)
+		return ERR_PTR(-ENOMEM);
+
+	if (!copy_from_iter_full(p, len, src)) {
+		kfree(p);
+		return ERR_PTR(-EFAULT);
+	}
+
+	return p;
+}
+EXPORT_SYMBOL(iterdup);
+
 /**
  * vmemdup_user - duplicate memory region from user space
  *
@@ -312,6 +338,37 @@ void *memdup_user_nul(const void __user *src, size_t len)
 }
 EXPORT_SYMBOL(memdup_user_nul);
 
+/**
+ * iterdup_nul - duplicate memory region from iov_iter and NUL-terminate
+ *
+ * @src: source address to copy from
+ * @len: number of bytes to copy
+ *
+ * Return: an ERR_PTR() on failure.
+ */
+void *iterdup_nul(struct iov_iter *src, size_t len)
+{
+	char *p;
+
+	/*
+	 * Always use GFP_KERNEL, since copy_from_iter_full() can sleep and
+	 * cause pagefault, which makes it pointless to use GFP_NOFS
+	 * or GFP_ATOMIC.
+	 */
+	p = kmalloc_track_caller(len + 1, GFP_KERNEL);
+	if (!p)
+		return ERR_PTR(-ENOMEM);
+
+	if (!copy_from_iter_full(p, len, src)) {
+		kfree(p);
+		return ERR_PTR(-EFAULT);
+	}
+	p[len] = '\0';
+
+	return p;
+}
+EXPORT_SYMBOL(iterdup_nul);
+
 /* Check if the vma is being used as a stack by this task */
 int vma_is_stack_for_current(struct vm_area_struct *vma)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 008/437] kstrtox: add iov_iter versions of the string conversion helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (6 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 007/437] mm/util: add iterdup_nul() and iterdup() helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 009/437] lib/string_helpers: split __parse_int_array() into a helper Jens Axboe
                   ` (429 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/kstrtox.h | 25 +++++++++++++++++++++++++
 lib/kstrtox.c           | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/include/linux/kstrtox.h b/include/linux/kstrtox.h
index 7fcf29a4e0de..229e0162849a 100644
--- a/include/linux/kstrtox.h
+++ b/include/linux/kstrtox.h
@@ -109,11 +109,26 @@ int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned
 int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
 int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool *res);
 
+struct iov_iter;
+int __must_check kstrtoull_from_iter(struct iov_iter *s, size_t count, unsigned int base, unsigned long long *res);
+int __must_check kstrtoul_from_iter(struct iov_iter *s, size_t count, unsigned int base, unsigned long *res);
+int __must_check kstrtol_from_iter(struct iov_iter *s, size_t count, unsigned int base, long *res);
+int __must_check kstrtouint_from_iter(struct iov_iter *s, size_t count, unsigned int base, unsigned int *res);
+int __must_check kstrtoint_from_iter(struct iov_iter *s, size_t count, unsigned int base, int *res);
+int __must_check kstrtou16_from_iter(struct iov_iter *s, size_t count, unsigned int base, u16 *res);
+int __must_check kstrtou8_from_iter(struct iov_iter *s, size_t count, unsigned int base, u8 *res);
+int __must_check kstrtobool_from_iter(struct iov_iter *src, size_t count, bool *res);
+
 static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
 {
 	return kstrtoull_from_user(s, count, base, res);
 }
 
+static inline int __must_check kstrtou64_from_iter(struct iov_iter *src, size_t count, unsigned int base, u64 *res)
+{
+	return kstrtoull_from_iter(src, count, base, res);
+}
+
 static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
 {
 	return kstrtoll_from_user(s, count, base, res);
@@ -124,11 +139,21 @@ static inline int __must_check kstrtou32_from_user(const char __user *s, size_t
 	return kstrtouint_from_user(s, count, base, res);
 }
 
+static inline int __must_check kstrtou32_from_iter(struct iov_iter *src, size_t count, unsigned int base, u32 *res)
+{
+	return kstrtouint_from_iter(src, count, base, res);
+}
+
 static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
 {
 	return kstrtoint_from_user(s, count, base, res);
 }
 
+static inline int __must_check kstrtos32_from_iter(struct iov_iter *src, size_t count, unsigned int base, s32 *res)
+{
+	return kstrtoint_from_iter(src, count, base, res);
+}
+
 /*
  * Use kstrto<foo> instead.
  *
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index d586e6af5e5a..111231cb4148 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -19,6 +19,7 @@
 #include <linux/math64.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 
 #include "kstrtox.h"
 
@@ -405,6 +406,23 @@ int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
 }
 EXPORT_SYMBOL(kstrtobool_from_user);
 
+/*
+ * Like kstrtobool_from_user(), but takes a source iov_iter rather than a
+ * buffer.
+ */
+int kstrtobool_from_iter(struct iov_iter *src, size_t count, bool *res)
+{
+	/* Longest string needed to differentiate, newline, terminator */
+	char buf[4];
+
+	count = min(count, sizeof(buf) - 1);
+	if (!copy_from_iter_full(buf, count, src))
+		return -EFAULT;
+	buf[count] = '\0';
+	return kstrtobool(buf, res);
+}
+EXPORT_SYMBOL(kstrtobool_from_iter);
+
 #define kstrto_from_user(f, g, type)					\
 int f(const char __user *s, size_t count, unsigned int base, type *res)	\
 {									\
@@ -429,3 +447,25 @@ kstrto_from_user(kstrtou16_from_user,	kstrtou16,	u16);
 kstrto_from_user(kstrtos16_from_user,	kstrtos16,	s16);
 kstrto_from_user(kstrtou8_from_user,	kstrtou8,	u8);
 kstrto_from_user(kstrtos8_from_user,	kstrtos8,	s8);
+
+#define kstrto_from_iter(f, g, type)					\
+int f(struct iov_iter *s, size_t count, unsigned int base, type *res)	\
+{									\
+	/* sign, base 2 representation, newline, terminator */		\
+	char buf[1 + sizeof(type) * 8 + 1 + 1];				\
+									\
+	count = min(count, sizeof(buf) - 1);				\
+	if (!copy_from_iter_full(buf, count, s))			\
+		return -EFAULT;						\
+	buf[count] = '\0';						\
+	return g(buf, base, res);					\
+}									\
+EXPORT_SYMBOL(f)
+
+kstrto_from_iter(kstrtoull_from_iter,	kstrtoull,	unsigned long long);
+kstrto_from_iter(kstrtoul_from_iter,	kstrtoul,	unsigned long);
+kstrto_from_iter(kstrtol_from_iter,	kstrtol,	long);
+kstrto_from_iter(kstrtouint_from_iter,	kstrtouint,	unsigned int);
+kstrto_from_iter(kstrtoint_from_iter,	kstrtoint,	int);
+kstrto_from_iter(kstrtou16_from_iter,	kstrtou16,	u16);
+kstrto_from_iter(kstrtou8_from_iter,	kstrtou8,	u8);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 009/437] lib/string_helpers: split __parse_int_array() into a helper
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (7 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 008/437] kstrtox: add iov_iter versions of the string conversion helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 010/437] lib/string_helpers: add parse_int_array_iter() Jens Axboe
                   ` (428 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

No functional changes, just in preparation for providing an iter based
version.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 lib/string_helpers.c | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 69ba49b853c7..77f942809556 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -138,29 +138,11 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 }
 EXPORT_SYMBOL(string_get_size);
 
-/**
- * parse_int_array_user - Split string into a sequence of integers
- * @from:	The user space buffer to read from
- * @count:	The maximum number of bytes to read
- * @array:	Returned pointer to sequence of integers
- *
- * On success @array is allocated and initialized with a sequence of
- * integers extracted from the @from plus an additional element that
- * begins the sequence and specifies the integers count.
- *
- * Caller takes responsibility for freeing @array when it is no longer
- * needed.
- */
-int parse_int_array_user(const char __user *from, size_t count, int **array)
+static int __parse_int_array(char *buf, int **array)
 {
 	int *ints, nints;
-	char *buf;
 	int ret = 0;
 
-	buf = memdup_user_nul(from, count);
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
-
 	get_options(buf, 0, &nints);
 	if (!nints) {
 		ret = -ENOENT;
@@ -180,6 +162,30 @@ int parse_int_array_user(const char __user *from, size_t count, int **array)
 	kfree(buf);
 	return ret;
 }
+
+/**
+ * parse_int_array_user - Split string into a sequence of integers
+ * @from:	The user space buffer to read from
+ * @count:	The maximum number of bytes to read
+ * @array:	Returned pointer to sequence of integers
+ *
+ * On success @array is allocated and initialized with a sequence of
+ * integers extracted from the @from plus an additional element that
+ * begins the sequence and specifies the integers count.
+ *
+ * Caller takes responsibility for freeing @array when it is no longer
+ * needed.
+ */
+int parse_int_array_user(const char __user *from, size_t count, int **array)
+{
+	char *buf;
+
+	buf = memdup_user_nul(from, count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	return __parse_int_array(buf, array);
+}
 EXPORT_SYMBOL(parse_int_array_user);
 
 static bool unescape_space(char **src, char **dst)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 010/437] lib/string_helpers: add parse_int_array_iter()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (8 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 009/437] lib/string_helpers: split __parse_int_array() into a helper Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 011/437] virtio_console: convert to read/write iterator helpers Jens Axboe
                   ` (427 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Works just like parse_int_array_user(), except it takes and iov_iter
instead of a ubuf + length.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/string_helpers.h |  2 ++
 lib/string_helpers.c           | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index e93fbb5b0c01..f38157114fc0 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -11,6 +11,7 @@
 struct device;
 struct file;
 struct task_struct;
+struct iov_iter;
 
 static inline bool string_is_terminated(const char *s, int len)
 {
@@ -32,6 +33,7 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 		    char *buf, int len);
 
 int parse_int_array_user(const char __user *from, size_t count, int **array);
+int parse_int_array_iter(struct iov_iter *from, int **array);
 
 #define UNESCAPE_SPACE		BIT(0)
 #define UNESCAPE_OCTAL		BIT(1)
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 77f942809556..ced4f77dc5e8 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -188,6 +188,25 @@ int parse_int_array_user(const char __user *from, size_t count, int **array)
 }
 EXPORT_SYMBOL(parse_int_array_user);
 
+/**
+ * parse_int_array_iter - Split string into a sequence of integers
+ * @from:	The iov_iter buffer to read from
+ * @array:	Returned pointer to sequence of integers
+ *
+ * See @parse_int_array_user, this is just the iov_iter variant.
+ */
+int parse_int_array_iter(struct iov_iter *from, int **array)
+{
+	char *buf;
+
+	buf = iterdup_nul(from, iov_iter_count(from));
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	return __parse_int_array(buf, array);
+}
+EXPORT_SYMBOL(parse_int_array_iter);
+
 static bool unescape_space(char **src, char **dst)
 {
 	char *p = *dst, *q = *src;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 011/437] virtio_console: convert to read/write iterator helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (9 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 010/437] lib/string_helpers: add parse_int_array_iter() Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 012/437] char/adi: convert to read/write iterators Jens Axboe
                   ` (426 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Add stub read/write iterators which just use the VFS helpers, and
kill the ->read() and ->write() usage.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/virtio_console.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 035f89f1a251..154934eb9ae9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -771,6 +771,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
 
 	return fill_readbuf(port, ubuf, count, true);
 }
+FOPS_READ_ITER_HELPER(port_fops_read);
 
 static int wait_port_writable(struct port *port, bool nonblock)
 {
@@ -844,6 +845,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
 out:
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(port_fops_write);
 
 struct sg_list {
 	unsigned int n;
@@ -1087,8 +1089,8 @@ static int port_fops_fasync(int fd, struct file *filp, int mode)
 static const struct file_operations port_fops = {
 	.owner = THIS_MODULE,
 	.open  = port_fops_open,
-	.read  = port_fops_read,
-	.write = port_fops_write,
+	.read_iter  = port_fops_read_iter,
+	.write_iter = port_fops_write_iter,
 	.splice_write = port_fops_splice_write,
 	.poll  = port_fops_poll,
 	.release = port_fops_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 012/437] char/adi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (10 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 011/437] virtio_console: convert to read/write iterator helpers Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 013/437] char/apm-emulation: " Jens Axboe
                   ` (425 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/adi.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/char/adi.c b/drivers/char/adi.c
index 751d7cc0da1b..941188be2385 100644
--- a/drivers/char/adi.c
+++ b/drivers/char/adi.c
@@ -51,10 +51,10 @@ static int read_mcd_tag(unsigned long addr)
 		return ver;
 }
 
-static ssize_t adi_read(struct file *file, char __user *buf,
-			size_t count, loff_t *offp)
+static ssize_t adi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	size_t ver_buf_sz, bytes_read = 0;
+	size_t count = iov_iter_count(to);
 	int ver_buf_idx = 0;
 	loff_t offset;
 	u8 *ver_buf;
@@ -65,7 +65,7 @@ static ssize_t adi_read(struct file *file, char __user *buf,
 	if (!ver_buf)
 		return -ENOMEM;
 
-	offset = (*offp) * adi_blksize();
+	offset = iocb->ki_pos * adi_blksize();
 
 	while (bytes_read < count) {
 		ret = read_mcd_tag(offset);
@@ -77,8 +77,7 @@ static ssize_t adi_read(struct file *file, char __user *buf,
 		offset += adi_blksize();
 
 		if (ver_buf_idx >= ver_buf_sz) {
-			if (copy_to_user(buf + bytes_read, ver_buf,
-					 ver_buf_sz)) {
+			if (!copy_to_iter_full(ver_buf, ver_buf_sz, to)) {
 				ret = -EFAULT;
 				goto out;
 			}
@@ -91,7 +90,7 @@ static ssize_t adi_read(struct file *file, char __user *buf,
 		}
 	}
 
-	(*offp) += bytes_read;
+	iocb->ki_pos += bytes_read;
 	ret = bytes_read;
 out:
 	kfree(ver_buf);
@@ -128,10 +127,10 @@ static int set_mcd_tag(unsigned long addr, u8 ver)
 		return ver;
 }
 
-static ssize_t adi_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *offp)
+static ssize_t adi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	size_t ver_buf_sz, bytes_written = 0;
+	size_t count = iov_iter_count(from);
 	loff_t offset;
 	u8 *ver_buf;
 	ssize_t ret;
@@ -145,11 +144,10 @@ static ssize_t adi_write(struct file *file, const char __user *buf,
 	if (!ver_buf)
 		return -ENOMEM;
 
-	offset = (*offp) * adi_blksize();
+	offset = iocb->ki_pos * adi_blksize();
 
 	do {
-		if (copy_from_user(ver_buf, &buf[bytes_written],
-				   ver_buf_sz)) {
+		if (!copy_from_iter_full(ver_buf, ver_buf_sz, from)) {
 			ret = -EFAULT;
 			goto out;
 		}
@@ -166,7 +164,7 @@ static ssize_t adi_write(struct file *file, const char __user *buf,
 		ver_buf_sz = min(count - bytes_written, (size_t)MAX_BUF_SZ);
 	} while (bytes_written < count);
 
-	(*offp) += bytes_written;
+	iocb->ki_pos += bytes_written;
 	ret = bytes_written;
 out:
 	__asm__ __volatile__("membar #Sync");
@@ -207,8 +205,8 @@ static const struct file_operations adi_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= adi_llseek,
 	.open		= adi_open,
-	.read		= adi_read,
-	.write		= adi_write,
+	.read_iter	= adi_read,
+	.write_iter	= adi_write,
 };
 
 static struct miscdevice adi_miscdev = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 013/437] char/apm-emulation: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (11 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 012/437] char/adi: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 014/437] char/applicom: " Jens Axboe
                   ` (424 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/apm-emulation.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index e795390b070f..6b0ea84cf9c6 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -31,6 +31,7 @@
 #include <linux/completion.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
+#include <linux/uio.h>
 
 /*
  * One option can be changed at boot time as follows:
@@ -200,9 +201,11 @@ static void queue_event(apm_event_t event)
 	wake_up_interruptible(&apm_waitqueue);
 }
 
-static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t apm_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *fp = iocb->ki_filp;
 	struct apm_user *as = fp->private_data;
+	size_t count = iov_iter_count(to);
 	apm_event_t event;
 	int i = count, ret = 0;
 
@@ -218,7 +221,7 @@ static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t
 		event = queue_get_event(&as->queue);
 
 		ret = -EFAULT;
-		if (copy_to_user(buf, &event, sizeof(event)))
+		if (!copy_to_iter_full(&event, sizeof(event), to))
 			break;
 
 		mutex_lock(&state_lock);
@@ -227,7 +230,6 @@ static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t
 			as->suspend_state = SUSPEND_READ;
 		mutex_unlock(&state_lock);
 
-		buf += sizeof(event);
 		i -= sizeof(event);
 	}
 
@@ -379,7 +381,7 @@ static int apm_open(struct inode * inode, struct file * filp)
 
 static const struct file_operations apm_bios_fops = {
 	.owner		= THIS_MODULE,
-	.read		= apm_read,
+	.read_iter	= apm_read,
 	.poll		= apm_poll,
 	.unlocked_ioctl	= apm_ioctl,
 	.open		= apm_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 014/437] char/applicom: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (12 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 013/437] char/apm-emulation: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 015/437] char/nsc_gpio: " Jens Axboe
                   ` (423 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/applicom.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index 69314532f38c..9a1e5f7111b1 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -109,11 +109,14 @@ static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *);
 static long ac_ioctl(struct file *, unsigned int, unsigned long);
 static irqreturn_t ac_interrupt(int, void *);
 
+FOPS_READ_ITER_HELPER(ac_read);
+FOPS_WRITE_ITER_HELPER(ac_write);
+
 static const struct file_operations ac_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.read = ac_read,
-	.write = ac_write,
+	.read_iter = ac_read_iter,
+	.write_iter = ac_write_iter,
 	.unlocked_ioctl = ac_ioctl,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 015/437] char/nsc_gpio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (13 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 014/437] char/applicom: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 016/437] char/dsp1620: " Jens Axboe
                   ` (422 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/nsc_gpio.c  | 22 ++++++++++++++++------
 include/linux/nsc_gpio.h |  8 ++------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
index da930c72bc74..0df6fb1232cd 100644
--- a/drivers/char/nsc_gpio.c
+++ b/drivers/char/nsc_gpio.c
@@ -39,8 +39,8 @@ void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
 		 amp->gpio_get(index), amp->gpio_current(index));
 }
 
-ssize_t nsc_gpio_write(struct file *file, const char __user *data,
-		       size_t len, loff_t *ppos)
+static ssize_t nsc_gpio_write(struct file *file, const char __user *data,
+			      size_t len, loff_t *ppos)
 {
 	unsigned m = iminor(file_inode(file));
 	struct nsc_gpio_ops *amp = file->private_data;
@@ -102,8 +102,8 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
 	return len;
 }
 
-ssize_t nsc_gpio_read(struct file *file, char __user * buf,
-		      size_t len, loff_t * ppos)
+static ssize_t nsc_gpio_read(struct file *file, char __user * buf, size_t len,
+			     loff_t * ppos)
 {
 	unsigned m = iminor(file_inode(file));
 	int value;
@@ -116,9 +116,19 @@ ssize_t nsc_gpio_read(struct file *file, char __user * buf,
 	return 1;
 }
 
+ssize_t nsc_gpio_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, nsc_gpio_read);
+}
+EXPORT_SYMBOL(nsc_gpio_read_iter);
+
+ssize_t nsc_gpio_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, nsc_gpio_write);
+}
+EXPORT_SYMBOL(nsc_gpio_write_iter);
+
 /* common file-ops routines for both scx200_gpio and pc87360_gpio */
-EXPORT_SYMBOL(nsc_gpio_write);
-EXPORT_SYMBOL(nsc_gpio_read);
 EXPORT_SYMBOL(nsc_gpio_dump);
 
 static int __init nsc_gpio_init(void)
diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h
index d7a04a6e3783..a97111b2e85d 100644
--- a/include/linux/nsc_gpio.h
+++ b/include/linux/nsc_gpio.h
@@ -31,11 +31,7 @@ struct nsc_gpio_ops {
 	struct device*	dev;	/* for dev_dbg() support, set in init  */
 };
 
-extern ssize_t nsc_gpio_write(struct file *file, const char __user *data,
-			      size_t len, loff_t *ppos);
-
-extern ssize_t nsc_gpio_read(struct file *file, char __user *buf,
-			     size_t len, loff_t *ppos);
-
+ssize_t nsc_gpio_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t nsc_gpio_read_iter(struct kiocb *iocb, struct iov_iter *to);
 extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 016/437] char/dsp1620: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (14 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 015/437] char/nsc_gpio: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 017/437] char/dsp56k: " Jens Axboe
                   ` (421 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/ds1620.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index cf89a9631107..036f1db308d2 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -216,8 +216,7 @@ static int ds1620_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t
-ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
+static ssize_t ds1620_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	signed int cur_temp;
 	signed char cur_temp_degF;
@@ -227,7 +226,7 @@ ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
 	/* convert to Fahrenheit, as per wdt.c */
 	cur_temp_degF = (cur_temp * 9) / 5 + 32;
 
-	if (copy_to_user(buf, &cur_temp_degF, 1))
+	if (!copy_to_iter_full(&cur_temp_degF, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -351,7 +350,7 @@ static int ds1620_proc_therm_show(struct seq_file *m, void *v)
 static const struct file_operations ds1620_fops = {
 	.owner		= THIS_MODULE,
 	.open		= ds1620_open,
-	.read		= ds1620_read,
+	.read_iter	= ds1620_read,
 	.unlocked_ioctl	= ds1620_unlocked_ioctl,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 017/437] char/dsp56k: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (15 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 016/437] char/dsp1620: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 018/437] char/dtlk: " Jens Axboe
                   ` (420 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/dsp56k.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index bda27e595da1..14f0f284c944 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -242,6 +242,7 @@ static ssize_t dsp56k_read(struct file *file, char __user *buf, size_t count,
 		return -ENXIO;
 	}
 }
+FOPS_READ_ITER_HELPER(dsp56k_read);
 
 static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t count,
 			    loff_t *ppos)
@@ -304,6 +305,7 @@ static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t co
 		return -ENXIO;
 	}
 }
+FOPS_WRITE_ITER_HELPER(dsp56k_write);
 
 static long dsp56k_ioctl(struct file *file, unsigned int cmd,
 			 unsigned long arg)
@@ -480,8 +482,8 @@ static int dsp56k_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dsp56k_fops = {
 	.owner		= THIS_MODULE,
-	.read		= dsp56k_read,
-	.write		= dsp56k_write,
+	.read_iter	= dsp56k_read_iter,
+	.write_iter	= dsp56k_write_iter,
 	.unlocked_ioctl	= dsp56k_ioctl,
 	.open		= dsp56k_open,
 	.release	= dsp56k_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 018/437] char/dtlk: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (16 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 017/437] char/dsp56k: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 019/437] char/hpet: " Jens Axboe
                   ` (419 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/dtlk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 6946c1cad9f6..60858db14c43 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -101,8 +101,8 @@ static long dtlk_ioctl(struct file *file,
 static const struct file_operations dtlk_fops =
 {
 	.owner		= THIS_MODULE,
-	.read		= dtlk_read,
-	.write		= dtlk_write,
+	.read_iter	= dtlk_read_iter,
+	.write_iter	= dtlk_write_iter,
 	.poll		= dtlk_poll,
 	.unlocked_ioctl	= dtlk_ioctl,
 	.open		= dtlk_open,
@@ -155,6 +155,7 @@ static ssize_t dtlk_read(struct file *file, char __user *buf,
 	TRACE_RET;
 	return -EAGAIN;
 }
+FOPS_READ_ITER_HELPER(dtlk_read);
 
 static ssize_t dtlk_write(struct file *file, const char __user *buf,
 			  size_t count, loff_t * ppos)
@@ -228,6 +229,7 @@ static ssize_t dtlk_write(struct file *file, const char __user *buf,
 	TRACE_RET;
 	return -EAGAIN;
 }
+FOPS_WRITE_ITER_HELPER(dtlk_write);
 
 static __poll_t dtlk_poll(struct file *file, poll_table * wait)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 019/437] char/hpet: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (17 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 018/437] char/dtlk: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 020/437] char/hw_random: " Jens Axboe
                   ` (418 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/hpet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index d51fc8321d41..68a3ab149e72 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -303,6 +303,7 @@ hpet_read(struct file *file, char __user *buf, size_t count, loff_t * ppos)
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(hpet_read);
 
 static __poll_t hpet_poll(struct file *file, poll_table * wait)
 {
@@ -677,7 +678,7 @@ hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations hpet_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.read = hpet_read,
+	.read_iter = hpet_read_iter,
 	.poll = hpet_poll,
 	.unlocked_ioctl = hpet_ioctl,
 #ifdef CONFIG_COMPAT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 020/437] char/hw_random: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (18 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 019/437] char/hpet: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 021/437] char/ipmi: " Jens Axboe
                   ` (417 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/hw_random/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index a3bbdd6e60fc..810c3dd013b0 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -290,11 +290,12 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
 	put_rng(rng);
 	goto out;
 }
+FOPS_READ_ITER_HELPER(rng_dev_read);
 
 static const struct file_operations rng_chrdev_ops = {
 	.owner		= THIS_MODULE,
 	.open		= rng_dev_open,
-	.read		= rng_dev_read,
+	.read_iter	= rng_dev_read_iter,
 	.llseek		= noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 021/437] char/ipmi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (19 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 020/437] char/hw_random: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 022/437] char/tpm: " Jens Axboe
                   ` (416 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/ipmi/bt-bmc.c            | 27 +++++++++++++--------------
 drivers/char/ipmi/ipmb_dev_int.c      | 19 ++++++++++---------
 drivers/char/ipmi/ipmi_watchdog.c     | 16 ++++++++--------
 drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 23 ++++++++++++-----------
 drivers/char/ipmi/ssif_bmc.c          | 25 ++++++++++++++-----------
 5 files changed, 57 insertions(+), 53 deletions(-)

diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
index 7450904e330a..d8b2e513ed2a 100644
--- a/drivers/char/ipmi/bt-bmc.c
+++ b/drivers/char/ipmi/bt-bmc.c
@@ -15,6 +15,7 @@
 #include <linux/poll.h>
 #include <linux/sched.h>
 #include <linux/timer.h>
+#include <linux/uio.h>
 
 /*
  * This is a BMC device used to communicate to the host
@@ -172,17 +173,17 @@ static int bt_bmc_open(struct inode *inode, struct file *file)
  *    Length  NetFn/LUN  Seq     Cmd     Data
  *
  */
-static ssize_t bt_bmc_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t bt_bmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bt_bmc *bt_bmc = file_bt_bmc(file);
+	struct bt_bmc *bt_bmc = file_bt_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	u8 len;
 	int len_byte = 1;
 	u8 kbuffer[BT_BMC_BUFFER_SIZE];
 	ssize_t ret = 0;
 	ssize_t nread;
 
-	WARN_ON(*ppos);
+	WARN_ON(iocb->ki_pos);
 
 	if (wait_event_interruptible(bt_bmc->queue,
 				     bt_inb(bt_bmc, BT_CTRL) & BT_CTRL_H2B_ATN))
@@ -215,12 +216,11 @@ static ssize_t bt_bmc_read(struct file *file, char __user *buf,
 
 		bt_readn(bt_bmc, kbuffer + len_byte, nread);
 
-		if (copy_to_user(buf, kbuffer, nread + len_byte)) {
+		if (!copy_to_iter_full(kbuffer, nread + len_byte, to)) {
 			ret = -EFAULT;
 			break;
 		}
 		len -= nread;
-		buf += nread + len_byte;
 		ret += nread + len_byte;
 		len_byte = 0;
 	}
@@ -238,10 +238,10 @@ static ssize_t bt_bmc_read(struct file *file, char __user *buf,
  *    Byte 1  Byte 2     Byte 3  Byte 4  Byte 5  Byte 6:N
  *    Length  NetFn/LUN  Seq     Cmd     Code    Data
  */
-static ssize_t bt_bmc_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t bt_bmc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bt_bmc *bt_bmc = file_bt_bmc(file);
+	struct bt_bmc *bt_bmc = file_bt_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	u8 kbuffer[BT_BMC_BUFFER_SIZE];
 	ssize_t ret = 0;
 	ssize_t nwritten;
@@ -252,7 +252,7 @@ static ssize_t bt_bmc_write(struct file *file, const char __user *buf,
 	if (count < 5)
 		return -EINVAL;
 
-	WARN_ON(*ppos);
+	WARN_ON(iocb->ki_pos);
 
 	/*
 	 * There's no interrupt for clearing bmc busy so we have to
@@ -275,7 +275,7 @@ static ssize_t bt_bmc_write(struct file *file, const char __user *buf,
 
 	while (count) {
 		nwritten = min_t(ssize_t, count, sizeof(kbuffer));
-		if (copy_from_user(&kbuffer, buf, nwritten)) {
+		if (!copy_from_iter_full(&kbuffer, nwritten, from)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -283,7 +283,6 @@ static ssize_t bt_bmc_write(struct file *file, const char __user *buf,
 		bt_writen(bt_bmc, kbuffer, nwritten);
 
 		count -= nwritten;
-		buf += nwritten;
 		ret += nwritten;
 	}
 
@@ -338,8 +337,8 @@ static __poll_t bt_bmc_poll(struct file *file, poll_table *wait)
 static const struct file_operations bt_bmc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= bt_bmc_open,
-	.read		= bt_bmc_read,
-	.write		= bt_bmc_write,
+	.read_iter	= bt_bmc_read,
+	.write_iter	= bt_bmc_write,
 	.release	= bt_bmc_release,
 	.poll		= bt_bmc_poll,
 	.unlocked_ioctl	= bt_bmc_ioctl,
diff --git a/drivers/char/ipmi/ipmb_dev_int.c b/drivers/char/ipmi/ipmb_dev_int.c
index 49100845fcb7..5344095e32a0 100644
--- a/drivers/char/ipmi/ipmb_dev_int.c
+++ b/drivers/char/ipmi/ipmb_dev_int.c
@@ -71,11 +71,11 @@ static inline struct ipmb_dev *to_ipmb_dev(struct file *file)
 	return container_of(file->private_data, struct ipmb_dev, miscdev);
 }
 
-static ssize_t ipmb_read(struct file *file, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t ipmb_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ipmb_dev *ipmb_dev = to_ipmb_dev(file);
+	struct ipmb_dev *ipmb_dev = to_ipmb_dev(iocb->ki_filp);
 	struct ipmb_request_elem *queue_elem;
+	size_t count = iov_iter_count(to);
 	struct ipmb_msg msg;
 	ssize_t ret = 0;
 
@@ -86,7 +86,7 @@ static ssize_t ipmb_read(struct file *file, char __user *buf, size_t count,
 	while (list_empty(&ipmb_dev->request_queue)) {
 		spin_unlock_irq(&ipmb_dev->lock);
 
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		ret = wait_event_interruptible(ipmb_dev->wait_queue,
@@ -107,7 +107,7 @@ static ssize_t ipmb_read(struct file *file, char __user *buf, size_t count,
 	spin_unlock_irq(&ipmb_dev->lock);
 
 	count = min_t(size_t, count, msg.len + 1);
-	if (copy_to_user(buf, &msg, count))
+	if (!copy_to_iter_full(&msg, count, to))
 		ret = -EFAULT;
 
 	return ret < 0 ? ret : count;
@@ -176,6 +176,7 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
 
 	return ret < 0 ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(ipmb_write);
 
 static __poll_t ipmb_poll(struct file *file, poll_table *wait)
 {
@@ -193,10 +194,10 @@ static __poll_t ipmb_poll(struct file *file, poll_table *wait)
 }
 
 static const struct file_operations ipmb_fops = {
-	.owner	= THIS_MODULE,
-	.read	= ipmb_read,
-	.write	= ipmb_write,
-	.poll	= ipmb_poll,
+	.owner		= THIS_MODULE,
+	.read_iter	= ipmb_read,
+	.write_iter	= ipmb_write_iter,
+	.poll		= ipmb_poll,
 };
 
 /* Called with ipmb_dev->lock held. */
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 9a459257489f..001a6b522ce4 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -37,6 +37,7 @@
 #include <linux/delay.h>
 #include <linux/atomic.h>
 #include <linux/sched/signal.h>
+#include <linux/uio.h>
 
 #ifdef CONFIG_X86
 /*
@@ -777,12 +778,11 @@ static ssize_t ipmi_write(struct file *file,
 	}
 	return len;
 }
+FOPS_WRITE_ITER_HELPER(ipmi_write);
 
-static ssize_t ipmi_read(struct file *file,
-			 char        __user *buf,
-			 size_t      count,
-			 loff_t      *ppos)
+static ssize_t ipmi_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int          rv = 0;
 	wait_queue_entry_t wait;
 
@@ -795,7 +795,7 @@ static ssize_t ipmi_read(struct file *file,
 	 */
 	spin_lock_irq(&ipmi_read_lock);
 	if (!data_to_read) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			rv = -EAGAIN;
 			goto out;
 		}
@@ -821,7 +821,7 @@ static ssize_t ipmi_read(struct file *file,
 	spin_unlock_irq(&ipmi_read_lock);
 
 	if (rv == 0) {
-		if (copy_to_user(buf, &data_to_read, 1))
+		if (!copy_to_iter_full(&data_to_read, 1, to))
 			rv = -EFAULT;
 		else
 			rv = 1;
@@ -895,9 +895,9 @@ static int ipmi_close(struct inode *ino, struct file *filep)
 
 static const struct file_operations ipmi_wdog_fops = {
 	.owner   = THIS_MODULE,
-	.read    = ipmi_read,
+	.read_iter    = ipmi_read,
 	.poll    = ipmi_poll,
-	.write   = ipmi_write,
+	.write_iter   = ipmi_write_iter,
 	.unlocked_ioctl = ipmi_unlocked_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open    = ipmi_open,
diff --git a/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c b/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
index cf670e891966..1cd9b4c1fec9 100644
--- a/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
+++ b/drivers/char/ipmi/kcs_bmc_cdev_ipmi.c
@@ -16,6 +16,7 @@
 #include <linux/poll.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/uio.h>
 
 #include "kcs_bmc_client.h"
 
@@ -317,15 +318,15 @@ static __poll_t kcs_bmc_ipmi_poll(struct file *filp, poll_table *wait)
 	return mask;
 }
 
-static ssize_t kcs_bmc_ipmi_read(struct file *filp, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t kcs_bmc_ipmi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct kcs_bmc_ipmi *priv = to_kcs_bmc(filp);
+	struct kcs_bmc_ipmi *priv = to_kcs_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	bool data_avail;
 	size_t data_len;
 	ssize_t ret;
 
-	if (!(filp->f_flags & O_NONBLOCK))
+	if (!(iocb->ki_filp->f_flags & O_NONBLOCK))
 		wait_event_interruptible(priv->queue,
 					 priv->data_in_avail);
 
@@ -356,7 +357,7 @@ static ssize_t kcs_bmc_ipmi_read(struct file *filp, char __user *buf,
 		goto out_unlock;
 	}
 
-	if (copy_to_user(buf, priv->kbuffer, data_len)) {
+	if (!copy_to_iter_full(priv->kbuffer, data_len, to)) {
 		ret = -EFAULT;
 		goto out_unlock;
 	}
@@ -379,10 +380,10 @@ static ssize_t kcs_bmc_ipmi_read(struct file *filp, char __user *buf,
 	return ret;
 }
 
-static ssize_t kcs_bmc_ipmi_write(struct file *filp, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t kcs_bmc_ipmi_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct kcs_bmc_ipmi *priv = to_kcs_bmc(filp);
+	struct kcs_bmc_ipmi *priv = to_kcs_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 
 	/* a minimum response size '3' : netfn + cmd + ccode */
@@ -391,7 +392,7 @@ static ssize_t kcs_bmc_ipmi_write(struct file *filp, const char __user *buf,
 
 	mutex_lock(&priv->mutex);
 
-	if (copy_from_user(priv->kbuffer, buf, count)) {
+	if (!copy_from_iter_full(priv->kbuffer, count, from)) {
 		ret = -EFAULT;
 		goto out_unlock;
 	}
@@ -459,8 +460,8 @@ static int kcs_bmc_ipmi_release(struct inode *inode, struct file *filp)
 static const struct file_operations kcs_bmc_ipmi_fops = {
 	.owner          = THIS_MODULE,
 	.open           = kcs_bmc_ipmi_open,
-	.read           = kcs_bmc_ipmi_read,
-	.write          = kcs_bmc_ipmi_write,
+	.read_iter      = kcs_bmc_ipmi_read,
+	.write_iter     = kcs_bmc_ipmi_write,
 	.release        = kcs_bmc_ipmi_release,
 	.poll           = kcs_bmc_ipmi_poll,
 	.unlocked_ioctl = kcs_bmc_ipmi_ioctl,
diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c
index 56346fb32872..9a907c84d182 100644
--- a/drivers/char/ipmi/ssif_bmc.c
+++ b/drivers/char/ipmi/ssif_bmc.c
@@ -130,9 +130,10 @@ static const char *state_to_string(enum ssif_state state)
 }
 
 /* Handle SSIF message that will be sent to user */
-static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t ssif_bmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(file);
+	struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	struct ipmi_ssif_msg msg;
 	unsigned long flags;
 	ssize_t ret;
@@ -140,7 +141,7 @@ static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count,
 	spin_lock_irqsave(&ssif_bmc->lock, flags);
 	while (!ssif_bmc->request_available) {
 		spin_unlock_irqrestore(&ssif_bmc->lock, flags);
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		ret = wait_event_interruptible(ssif_bmc->wait_queue,
 					       ssif_bmc->request_available);
@@ -162,17 +163,19 @@ static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count,
 		ssif_bmc->request_available = false;
 		spin_unlock_irqrestore(&ssif_bmc->lock, flags);
 
-		ret = copy_to_user(buf, &msg, count);
+		ret = -EFAULT;
+		if (copy_to_iter_full(&msg, count, to))
+			ret = 0;
 	}
 
 	return (ret < 0) ? ret : count;
 }
 
 /* Handle SSIF message that is written by user */
-static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t count,
-			      loff_t *ppos)
+static ssize_t ssif_bmc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(file);
+	struct ssif_bmc_ctx *ssif_bmc = to_ssif_bmc(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct ipmi_ssif_msg msg;
 	unsigned long flags;
 	ssize_t ret;
@@ -180,7 +183,7 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
 	if (count > sizeof(struct ipmi_ssif_msg))
 		return -EINVAL;
 
-	if (copy_from_user(&msg, buf, count))
+	if (!copy_from_iter_full(&msg, count, from))
 		return -EFAULT;
 
 	if (!msg.len || count < sizeof_field(struct ipmi_ssif_msg, len) + msg.len)
@@ -189,7 +192,7 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
 	spin_lock_irqsave(&ssif_bmc->lock, flags);
 	while (ssif_bmc->response_in_progress) {
 		spin_unlock_irqrestore(&ssif_bmc->lock, flags);
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		ret = wait_event_interruptible(ssif_bmc->wait_queue,
 					       !ssif_bmc->response_in_progress);
@@ -275,8 +278,8 @@ static int ssif_bmc_release(struct inode *inode, struct file *file)
 static const struct file_operations ssif_bmc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= ssif_bmc_open,
-	.read		= ssif_bmc_read,
-	.write		= ssif_bmc_write,
+	.read_iter	= ssif_bmc_read,
+	.write_iter	= ssif_bmc_write,
 	.release	= ssif_bmc_release,
 	.poll		= ssif_bmc_poll,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 022/437] char/tpm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (20 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 021/437] char/ipmi: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 023/437] char/lp: " Jens Axboe
                   ` (415 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/tpm/eventlog/common.c |  2 +-
 drivers/char/tpm/tpm-dev-common.c  | 26 +++++++++++++-------------
 drivers/char/tpm/tpm-dev.c         |  4 ++--
 drivers/char/tpm/tpm-dev.h         |  6 ++----
 drivers/char/tpm/tpm_vtpm_proxy.c  | 20 ++++++++++----------
 drivers/char/tpm/tpmrm-dev.c       |  4 ++--
 6 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/drivers/char/tpm/eventlog/common.c b/drivers/char/tpm/eventlog/common.c
index 639c3f395a5a..5df887f7b119 100644
--- a/drivers/char/tpm/eventlog/common.c
+++ b/drivers/char/tpm/eventlog/common.c
@@ -66,7 +66,7 @@ static int tpm_bios_measurements_release(struct inode *inode,
 static const struct file_operations tpm_bios_measurements_ops = {
 	.owner = THIS_MODULE,
 	.open = tpm_bios_measurements_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = tpm_bios_measurements_release,
 };
diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index 30b4c288c1bb..6cb20cb43ac0 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -122,10 +122,10 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
 	file->private_data = priv;
 }
 
-ssize_t tpm_common_read(struct file *file, char __user *buf,
-			size_t size, loff_t *off)
+ssize_t tpm_common_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct file_priv *priv = file->private_data;
+	struct file_priv *priv = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	ssize_t ret_size = 0;
 	int rc;
 
@@ -140,21 +140,21 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 			goto out;
 		}
 
-		rc = copy_to_user(buf, priv->data_buffer + *off, ret_size);
+		rc = !copy_to_iter_full(priv->data_buffer + iocb->ki_pos, ret_size, to);
 		if (rc) {
 			memset(priv->data_buffer, 0, TPM_BUFSIZE);
 			priv->response_length = 0;
 			ret_size = -EFAULT;
 		} else {
-			memset(priv->data_buffer + *off, 0, ret_size);
+			memset(priv->data_buffer + iocb->ki_pos, 0, ret_size);
 			priv->response_length -= ret_size;
-			*off += ret_size;
+			iocb->ki_pos += ret_size;
 		}
 	}
 
 out:
 	if (!priv->response_length) {
-		*off = 0;
+		iocb->ki_pos = 0;
 		del_timer_sync(&priv->user_read_timer);
 		flush_work(&priv->timeout_work);
 	}
@@ -162,10 +162,10 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 	return ret_size;
 }
 
-ssize_t tpm_common_write(struct file *file, const char __user *buf,
-			 size_t size, loff_t *off)
+ssize_t tpm_common_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct file_priv *priv = file->private_data;
+	struct file_priv *priv = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	int ret = 0;
 
 	if (size > TPM_BUFSIZE)
@@ -183,7 +183,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
 		goto out;
 	}
 
-	if (copy_from_user(priv->data_buffer, buf, size)) {
+	if (!copy_from_iter_full(priv->data_buffer, size, from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -196,7 +196,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
 
 	priv->response_length = 0;
 	priv->response_read = false;
-	*off = 0;
+	iocb->ki_pos = 0;
 
 	/*
 	 * If in nonblocking mode schedule an async job to send
@@ -204,7 +204,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
 	 * In case of error the err code will be returned in
 	 * the subsequent read call.
 	 */
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		priv->command_enqueued = true;
 		queue_work(tpm_dev_wq, &priv->async_work);
 		mutex_unlock(&priv->buffer_mutex);
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index e2c0baa69fef..2f499c38fef5 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -61,8 +61,8 @@ const struct file_operations tpm_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 	.open = tpm_open,
-	.read = tpm_common_read,
-	.write = tpm_common_write,
+	.read_iter = tpm_common_read_iter,
+	.write_iter = tpm_common_write_iter,
 	.poll = tpm_common_poll,
 	.release = tpm_release,
 };
diff --git a/drivers/char/tpm/tpm-dev.h b/drivers/char/tpm/tpm-dev.h
index f3742bcc73e3..bc02b9509724 100644
--- a/drivers/char/tpm/tpm-dev.h
+++ b/drivers/char/tpm/tpm-dev.h
@@ -23,10 +23,8 @@ struct file_priv {
 
 void tpm_common_open(struct file *file, struct tpm_chip *chip,
 		     struct file_priv *priv, struct tpm_space *space);
-ssize_t tpm_common_read(struct file *file, char __user *buf,
-			size_t size, loff_t *off);
-ssize_t tpm_common_write(struct file *file, const char __user *buf,
-			 size_t size, loff_t *off);
+ssize_t tpm_common_read_iter(struct kiocb *iocb, struct iov_iter *to);
+ssize_t tpm_common_write_iter(struct kiocb *iocb, struct iov_iter *from);
 __poll_t tpm_common_poll(struct file *file, poll_table *wait);
 
 void tpm_common_release(struct file *file, struct file_priv *priv);
diff --git a/drivers/char/tpm/tpm_vtpm_proxy.c b/drivers/char/tpm/tpm_vtpm_proxy.c
index 11c502039faf..70d51ccb9a98 100644
--- a/drivers/char/tpm/tpm_vtpm_proxy.c
+++ b/drivers/char/tpm/tpm_vtpm_proxy.c
@@ -69,10 +69,10 @@ static void vtpm_proxy_delete_device(struct proxy_dev *proxy_dev);
  * Return:
  *	Number of bytes read or negative error code
  */
-static ssize_t vtpm_proxy_fops_read(struct file *filp, char __user *buf,
-				    size_t count, loff_t *off)
+static ssize_t vtpm_proxy_fops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct proxy_dev *proxy_dev = filp->private_data;
+	struct proxy_dev *proxy_dev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	size_t len;
 	int sig, rc;
 
@@ -98,7 +98,7 @@ static ssize_t vtpm_proxy_fops_read(struct file *filp, char __user *buf,
 		return -EIO;
 	}
 
-	rc = copy_to_user(buf, proxy_dev->buffer, len);
+	rc = !copy_to_iter_full(proxy_dev->buffer, len, to);
 	memset(proxy_dev->buffer, 0, len);
 	proxy_dev->req_len = 0;
 
@@ -124,10 +124,10 @@ static ssize_t vtpm_proxy_fops_read(struct file *filp, char __user *buf,
  * Return:
  *	Number of bytes read or negative error value
  */
-static ssize_t vtpm_proxy_fops_write(struct file *filp, const char __user *buf,
-				     size_t count, loff_t *off)
+static ssize_t vtpm_proxy_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct proxy_dev *proxy_dev = filp->private_data;
+	struct proxy_dev *proxy_dev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	mutex_lock(&proxy_dev->buf_lock);
 
@@ -146,7 +146,7 @@ static ssize_t vtpm_proxy_fops_write(struct file *filp, const char __user *buf,
 
 	proxy_dev->req_len = 0;
 
-	if (copy_from_user(proxy_dev->buffer, buf, count)) {
+	if (!copy_from_iter_full(proxy_dev->buffer, count, from)) {
 		mutex_unlock(&proxy_dev->buf_lock);
 		return -EFAULT;
 	}
@@ -244,8 +244,8 @@ static int vtpm_proxy_fops_release(struct inode *inode, struct file *filp)
 static const struct file_operations vtpm_proxy_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.read = vtpm_proxy_fops_read,
-	.write = vtpm_proxy_fops_write,
+	.read_iter = vtpm_proxy_fops_read,
+	.write_iter = vtpm_proxy_fops_write,
 	.poll = vtpm_proxy_fops_poll,
 	.release = vtpm_proxy_fops_release,
 };
diff --git a/drivers/char/tpm/tpmrm-dev.c b/drivers/char/tpm/tpmrm-dev.c
index eef0fb06ea83..f1f5cc0ba627 100644
--- a/drivers/char/tpm/tpmrm-dev.c
+++ b/drivers/char/tpm/tpmrm-dev.c
@@ -48,8 +48,8 @@ const struct file_operations tpmrm_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 	.open = tpmrm_open,
-	.read = tpm_common_read,
-	.write = tpm_common_write,
+	.read_iter = tpm_common_read_iter,
+	.write_iter = tpm_common_write_iter,
 	.poll = tpm_common_poll,
 	.release = tpmrm_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 023/437] char/lp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (21 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 022/437] char/tpm: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 024/437] char/mem: " Jens Axboe
                   ` (414 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/lp.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 2f171d14b9b5..3967115f6c75 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -298,10 +298,11 @@ static int lp_wait_ready(int minor, int nonblock)
 	return error;
 }
 
-static ssize_t lp_write(struct file *file, const char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t lp_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	unsigned int minor = iminor(file_inode(file));
+	size_t count = iov_iter_count(from);
 	struct parport *port = lp_table[minor].dev->port;
 	char *kbuf = lp_table[minor].lp_buffer;
 	ssize_t retv = 0;
@@ -324,7 +325,7 @@ static ssize_t lp_write(struct file *file, const char __user *buf,
 	if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
 		return -EINTR;
 
-	if (copy_from_user(kbuf, buf, copy_size)) {
+	if (!copy_from_iter_full(kbuf, copy_size, from)) {
 		retv = -EFAULT;
 		goto out_unlock;
 	}
@@ -347,7 +348,6 @@ static ssize_t lp_write(struct file *file, const char __user *buf,
 		if (written > 0) {
 			copy_size -= written;
 			count -= written;
-			buf  += written;
 			retv += written;
 		}
 
@@ -391,7 +391,7 @@ static ssize_t lp_write(struct file *file, const char __user *buf,
 			if (copy_size > LP_BUFFER_SIZE)
 				copy_size = LP_BUFFER_SIZE;
 
-			if (copy_from_user(kbuf, buf, copy_size)) {
+			if (!copy_from_iter_full(kbuf, copy_size, from)) {
 				if (retv == 0)
 					retv = -EFAULT;
 				break;
@@ -416,9 +416,10 @@ static ssize_t lp_write(struct file *file, const char __user *buf,
 #ifdef CONFIG_PARPORT_1284
 
 /* Status readback conforming to ieee1284 */
-static ssize_t lp_read(struct file *file, char __user *buf,
-		       size_t count, loff_t *ppos)
+static ssize_t lp_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
+	size_t count = iov_iter_count(to);
 	DEFINE_WAIT(wait);
 	unsigned int minor=iminor(file_inode(file));
 	struct parport *port = lp_table[minor].dev->port;
@@ -485,7 +486,7 @@ static ssize_t lp_read(struct file *file, char __user *buf,
  out:
 	lp_release_parport(&lp_table[minor]);
 
-	if (retval > 0 && copy_to_user(buf, kbuf, retval))
+	if (retval > 0 && !copy_to_iter_full(kbuf, retval, to))
 		retval = -EFAULT;
 
 	mutex_unlock(&lp_table[minor].port_mutex);
@@ -785,7 +786,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
 
 static const struct file_operations lp_fops = {
 	.owner		= THIS_MODULE,
-	.write		= lp_write,
+	.write_iter	= lp_write,
 	.unlocked_ioctl	= lp_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= lp_compat_ioctl,
@@ -793,7 +794,7 @@ static const struct file_operations lp_fops = {
 	.open		= lp_open,
 	.release	= lp_release,
 #ifdef CONFIG_PARPORT_1284
-	.read		= lp_read,
+	.read_iter	= lp_read,
 #endif
 	.llseek		= noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 024/437] char/mem: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (22 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 023/437] char/lp: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 025/437] char/mwave: " Jens Axboe
                   ` (413 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/mem.c | 106 ++++++++++++---------------------------------
 1 file changed, 27 insertions(+), 79 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 3c6670cf905f..00ab09ad98e6 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -183,16 +183,17 @@ static ssize_t read_mem(struct file *file, char __user *buf,
 	kfree(bounce);
 	return err;
 }
+FOPS_READ_ITER_HELPER(read_mem);
 
-static ssize_t write_mem(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t write_mem(struct kiocb *iocb, struct iov_iter *from)
 {
-	phys_addr_t p = *ppos;
+	size_t count = iov_iter_count(from);
+	phys_addr_t p = iocb->ki_pos;
 	ssize_t written, sz;
 	unsigned long copied;
 	void *ptr;
 
-	if (p != *ppos)
+	if (p != iocb->ki_pos)
 		return -EFBIG;
 
 	if (!valid_phys_addr_range(p, count))
@@ -235,7 +236,7 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
 				return -EFAULT;
 			}
 
-			copied = copy_from_user(ptr, buf, sz);
+			copied = copy_from_iter(ptr, sz, from);
 			unxlate_dev_mem_ptr(p, ptr);
 			if (copied) {
 				written += sz - copied;
@@ -245,7 +246,6 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
 			}
 		}
 
-		buf += sz;
 		p += sz;
 		count -= sz;
 		written += sz;
@@ -253,7 +253,7 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
 			break;
 	}
 
-	*ppos += written;
+	iocb->ki_pos += written;
 	return written;
 }
 
@@ -383,58 +383,39 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
 	return 0;
 }
 
-static ssize_t read_port(struct file *file, char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t read_port(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long i = *ppos;
-	char __user *tmp = buf;
+	unsigned long i = iocb->ki_pos, org_i = i;
+	size_t count = iov_iter_count(to);
 
-	if (!access_ok(buf, count))
-		return -EFAULT;
 	while (count-- > 0 && i < 65536) {
-		if (__put_user(inb(i), tmp) < 0)
+		char val = inb(i);
+		if (put_iter(val, to))
 			return -EFAULT;
 		i++;
-		tmp++;
 	}
-	*ppos = i;
-	return tmp-buf;
+	iocb->ki_pos = i;
+	return i - org_i;
 }
 
-static ssize_t write_port(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t write_port(struct kiocb *iocb, struct iov_iter *from)
 {
-	unsigned long i = *ppos;
-	const char __user *tmp = buf;
+	unsigned long i = iocb->ki_pos, org_i = i;
+	size_t count = iov_iter_count(from);
 
-	if (!access_ok(buf, count))
-		return -EFAULT;
 	while (count-- > 0 && i < 65536) {
 		char c;
 
-		if (__get_user(c, tmp)) {
-			if (tmp > buf)
+		if (get_iter(c, from)) {
+			if (i != org_i)
 				break;
 			return -EFAULT;
 		}
 		outb(c, i);
 		i++;
-		tmp++;
 	}
-	*ppos = i;
-	return tmp-buf;
-}
-
-static ssize_t read_null(struct file *file, char __user *buf,
-			 size_t count, loff_t *ppos)
-{
-	return 0;
-}
-
-static ssize_t write_null(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	return count;
+	iocb->ki_pos = i;
+	return i - org_i;
 }
 
 static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
@@ -490,33 +471,6 @@ static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
 	return written;
 }
 
-static ssize_t read_zero(struct file *file, char __user *buf,
-			 size_t count, loff_t *ppos)
-{
-	size_t cleared = 0;
-
-	while (count) {
-		size_t chunk = min_t(size_t, count, PAGE_SIZE);
-		size_t left;
-
-		left = clear_user(buf + cleared, chunk);
-		if (unlikely(left)) {
-			cleared += (chunk - left);
-			if (!cleared)
-				return -EFAULT;
-			break;
-		}
-		cleared += chunk;
-		count -= chunk;
-
-		if (signal_pending(current))
-			break;
-		cond_resched();
-	}
-
-	return cleared;
-}
-
 static int mmap_zero(struct file *file, struct vm_area_struct *vma)
 {
 #ifndef CONFIG_MMU
@@ -550,8 +504,7 @@ static unsigned long get_unmapped_area_zero(struct file *file,
 #endif
 }
 
-static ssize_t write_full(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t write_full_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -ENOSPC;
 }
@@ -626,15 +579,14 @@ static int open_port(struct inode *inode, struct file *filp)
 
 #define zero_lseek	null_lseek
 #define full_lseek      null_lseek
-#define write_zero	write_null
 #define write_iter_zero	write_iter_null
 #define splice_write_zero	splice_write_null
 #define open_mem	open_port
 
 static const struct file_operations __maybe_unused mem_fops = {
 	.llseek		= memory_lseek,
-	.read		= read_mem,
-	.write		= write_mem,
+	.read_iter	= read_mem_iter,
+	.write_iter	= write_mem,
 	.mmap		= mmap_mem,
 	.open		= open_mem,
 #ifndef CONFIG_MMU
@@ -645,8 +597,6 @@ static const struct file_operations __maybe_unused mem_fops = {
 
 static const struct file_operations null_fops = {
 	.llseek		= null_lseek,
-	.read		= read_null,
-	.write		= write_null,
 	.read_iter	= read_iter_null,
 	.write_iter	= write_iter_null,
 	.splice_write	= splice_write_null,
@@ -655,16 +605,14 @@ static const struct file_operations null_fops = {
 
 static const struct file_operations __maybe_unused port_fops = {
 	.llseek		= memory_lseek,
-	.read		= read_port,
-	.write		= write_port,
+	.read_iter	= read_port,
+	.write_iter	= write_port,
 	.open		= open_port,
 };
 
 static const struct file_operations zero_fops = {
 	.llseek		= zero_lseek,
-	.write		= write_zero,
 	.read_iter	= read_iter_zero,
-	.read		= read_zero,
 	.write_iter	= write_iter_zero,
 	.splice_read	= copy_splice_read,
 	.splice_write	= splice_write_zero,
@@ -678,7 +626,7 @@ static const struct file_operations zero_fops = {
 static const struct file_operations full_fops = {
 	.llseek		= full_lseek,
 	.read_iter	= read_iter_zero,
-	.write		= write_full,
+	.write_iter	= write_full_iter,
 	.splice_read	= copy_splice_read,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 025/437] char/mwave: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (23 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 024/437] char/mem: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 026/437] char/nvram: " Jens Axboe
                   ` (412 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/mwave/mwavedd.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
index 11272d605ecd..34b00a663d22 100644
--- a/drivers/char/mwave/mwavedd.c
+++ b/drivers/char/mwave/mwavedd.c
@@ -411,25 +411,14 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
 }
 
 
-static ssize_t mwave_read(struct file *file, char __user *buf, size_t count,
-                          loff_t * ppos)
+static ssize_t mwave_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	PRINTK_5(TRACE_MWAVE,
-		"mwavedd::mwave_read entry file %p, buf %p, count %zx ppos %p\n",
-		file, buf, count, ppos);
-
 	return -EINVAL;
 }
 
 
-static ssize_t mwave_write(struct file *file, const char __user *buf,
-                           size_t count, loff_t * ppos)
+static ssize_t mwave_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	PRINTK_5(TRACE_MWAVE,
-		"mwavedd::mwave_write entry file %p, buf %p,"
-		" count %zx ppos %p\n",
-		file, buf, count, ppos);
-
 	return -EINVAL;
 }
 
@@ -481,8 +470,8 @@ static int register_serial_portandirq(unsigned int port, int irq)
 
 static const struct file_operations mwave_fops = {
 	.owner		= THIS_MODULE,
-	.read		= mwave_read,
-	.write		= mwave_write,
+	.read_iter	= mwave_read,
+	.write_iter	= mwave_write,
 	.unlocked_ioctl	= mwave_ioctl,
 	.open		= mwave_open,
 	.release	= mwave_close,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 026/437] char/nvram: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (24 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 025/437] char/mwave: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 027/437] char/nwbutton: " Jens Axboe
                   ` (411 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/nvram.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index e9f694b36871..911370aa2a1a 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -225,29 +225,29 @@ static loff_t nvram_misc_llseek(struct file *file, loff_t offset, int origin)
 					nvram_size);
 }
 
-static ssize_t nvram_misc_read(struct file *file, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t nvram_misc_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	char *tmp;
 	ssize_t ret;
 
 
-	if (*ppos >= nvram_size)
+	if (iocb->ki_pos >= nvram_size)
 		return 0;
 
-	count = min_t(size_t, count, nvram_size - *ppos);
+	count = min_t(size_t, count, nvram_size - iocb->ki_pos);
 	count = min_t(size_t, count, PAGE_SIZE);
 
 	tmp = kmalloc(count, GFP_KERNEL);
 	if (!tmp)
 		return -ENOMEM;
 
-	ret = nvram_read(tmp, count, ppos);
+	ret = nvram_read(tmp, count, &iocb->ki_pos);
 	if (ret <= 0)
 		goto out;
 
-	if (copy_to_user(buf, tmp, ret)) {
-		*ppos -= ret;
+	if (!copy_to_iter_full(tmp, ret, to)) {
+		iocb->ki_pos -= ret;
 		ret = -EFAULT;
 	}
 
@@ -276,6 +276,7 @@ static ssize_t nvram_misc_write(struct file *file, const char __user *buf,
 	kfree(tmp);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(nvram_misc_write);
 
 static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
 			     unsigned long arg)
@@ -490,8 +491,8 @@ static int nvram_proc_read(struct seq_file *seq, void *offset)
 static const struct file_operations nvram_misc_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= nvram_misc_llseek,
-	.read		= nvram_misc_read,
-	.write		= nvram_misc_write,
+	.read_iter	= nvram_misc_read,
+	.write_iter	= nvram_misc_write_iter,
 	.unlocked_ioctl	= nvram_misc_ioctl,
 	.open		= nvram_misc_open,
 	.release	= nvram_misc_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 027/437] char/nwbutton: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (25 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 026/437] char/nvram: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 028/437] char/nwflash: " Jens Axboe
                   ` (410 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/nwbutton.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/char/nwbutton.c b/drivers/char/nwbutton.c
index ea378c0ed549..3b60ee911c68 100644
--- a/drivers/char/nwbutton.c
+++ b/drivers/char/nwbutton.c
@@ -165,14 +165,13 @@ static irqreturn_t button_handler (int irq, void *dev_id)
  * device at any one time.
  */
 
-static int button_read (struct file *filp, char __user *buffer,
-			size_t count, loff_t *ppos)
+static int button_read (struct kiocb *iocb, struct iov_iter *to)
 {
 	DEFINE_WAIT(wait);
 	prepare_to_wait(&button_wait_queue, &wait, TASK_INTERRUPTIBLE);
 	schedule();
 	finish_wait(&button_wait_queue, &wait);
-	return (copy_to_user (buffer, &button_output_buffer, bcount))
+	return (!copy_to_iter_full(&button_output_buffer, bcount, to))
 		 ? -EFAULT : bcount;
 }
 
@@ -184,7 +183,7 @@ static int button_read (struct file *filp, char __user *buffer,
 
 static const struct file_operations button_fops = {
 	.owner		= THIS_MODULE,
-	.read		= button_read,
+	.read_iter	= button_read,
 	.llseek		= noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 028/437] char/nwflash: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (26 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 027/437] char/nwbutton: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 029/437] char/pc8736x_gpio: " Jens Axboe
                   ` (409 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/nwflash.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index 0973c2c2b01a..0b66135c7cd4 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -120,8 +120,7 @@ static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
-static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
-			  loff_t *ppos)
+static ssize_t flash_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 
@@ -134,7 +133,8 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
 	if (mutex_lock_interruptible(&nwflash_mutex))
 		return -ERESTARTSYS;
 
-	ret = simple_read_from_buffer(buf, size, ppos, (void *)FLASH_BASE, gbFlashSize);
+	ret = simple_copy_to_iter((void *)FLASH_BASE, &iocb->ki_pos,
+					gbFlashSize, to);
 	mutex_unlock(&nwflash_mutex);
 
 	return ret;
@@ -259,7 +259,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
 
 	return written;
 }
-
+FOPS_WRITE_ITER_HELPER(flash_write);
 
 /*
  * The memory devices use the full 32/64 bits of the offset, and so we cannot
@@ -569,8 +569,8 @@ static const struct file_operations flash_fops =
 {
 	.owner		= THIS_MODULE,
 	.llseek		= flash_llseek,
-	.read		= flash_read,
-	.write		= flash_write,
+	.read_iter	= flash_read,
+	.write_iter	= flash_write_iter,
 	.unlocked_ioctl	= flash_ioctl,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 029/437] char/pc8736x_gpio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (27 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 028/437] char/nwflash: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 030/437] char/powernv-op-panel: " Jens Axboe
                   ` (408 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/pc8736x_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index c39a836ebd15..9ffd84788550 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -233,8 +233,8 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file)
 static const struct file_operations pc8736x_gpio_fileops = {
 	.owner	= THIS_MODULE,
 	.open	= pc8736x_gpio_open,
-	.write	= nsc_gpio_write,
-	.read	= nsc_gpio_read,
+	.write_iter	= nsc_gpio_write_iter,
+	.read_iter	= nsc_gpio_read_iter,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 030/437] char/powernv-op-panel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (28 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 029/437] char/pc8736x_gpio: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 031/437] char/ppdev: " Jens Axboe
                   ` (407 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/powernv-op-panel.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/char/powernv-op-panel.c b/drivers/char/powernv-op-panel.c
index 3c99696b145e..8e9e2d47087f 100644
--- a/drivers/char/powernv-op-panel.c
+++ b/drivers/char/powernv-op-panel.c
@@ -40,11 +40,9 @@ static loff_t oppanel_llseek(struct file *filp, loff_t offset, int whence)
 	return fixed_size_llseek(filp, offset, whence, oppanel_size);
 }
 
-static ssize_t oppanel_read(struct file *filp, char __user *userbuf, size_t len,
-			    loff_t *f_pos)
+static ssize_t oppanel_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(userbuf, len, f_pos, oppanel_data,
-			oppanel_size);
+	return simple_copy_to_iter(oppanel_data, &iocb->ki_pos, oppanel_size, to);
 }
 
 static int __op_panel_update_display(void)
@@ -86,26 +84,25 @@ static int __op_panel_update_display(void)
 	return rc;
 }
 
-static ssize_t oppanel_write(struct file *filp, const char __user *userbuf,
-			     size_t len, loff_t *f_pos)
+static ssize_t oppanel_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	loff_t f_pos_prev = *f_pos;
+	loff_t f_pos_prev = iocb->ki_pos;
+	size_t len = iov_iter_count(from);
 	ssize_t ret;
 	int rc;
 
-	if (!*f_pos)
+	if (!iocb->ki_pos)
 		memset(oppanel_data, ' ', oppanel_size);
-	else if (*f_pos >= oppanel_size)
+	else if (iocb->ki_pos >= oppanel_size)
 		return -EFBIG;
 
-	ret = simple_write_to_buffer(oppanel_data, oppanel_size, f_pos, userbuf,
-			len);
+	ret = simple_copy_from_iter(oppanel_data, &iocb->ki_pos, len, from);
 	if (ret > 0) {
 		rc = __op_panel_update_display();
 		if (rc != OPAL_SUCCESS) {
 			pr_err_ratelimited("OPAL call failed to write to op panel display [rc=%d]\n",
 				rc);
-			*f_pos = f_pos_prev;
+			iocb->ki_pos = f_pos_prev;
 			return -EIO;
 		}
 	}
@@ -130,8 +127,8 @@ static int oppanel_release(struct inode *inode, struct file *filp)
 static const struct file_operations oppanel_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= oppanel_llseek,
-	.read		= oppanel_read,
-	.write		= oppanel_write,
+	.read_iter	= oppanel_read,
+	.write_iter	= oppanel_write,
 	.open		= oppanel_open,
 	.release	= oppanel_release
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 031/437] char/ppdev: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (29 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 030/437] char/powernv-op-panel: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 032/437] char/ps3flash: " Jens Axboe
                   ` (406 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/ppdev.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index ee951b265213..4176b2b59dc9 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -112,10 +112,11 @@ static inline void pp_enable_irq(struct pp_struct *pp)
 	port->ops->enable_irq(port);
 }
 
-static ssize_t pp_read(struct file *file, char __user *buf, size_t count,
-		       loff_t *ppos)
+static ssize_t pp_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	unsigned int minor = iminor(file_inode(file));
+	size_t count = iov_iter_count(to);
 	struct pp_struct *pp = file->private_data;
 	char *kbuffer;
 	ssize_t bytes_read = 0;
@@ -182,7 +183,7 @@ static ssize_t pp_read(struct file *file, char __user *buf, size_t count,
 
 	parport_set_timeout(pp->pdev, pp->default_inactivity);
 
-	if (bytes_read > 0 && copy_to_user(buf, kbuffer, bytes_read))
+	if (bytes_read > 0 && !copy_to_iter_full(kbuffer, bytes_read, to))
 		bytes_read = -EFAULT;
 
 	kfree(kbuffer);
@@ -190,10 +191,11 @@ static ssize_t pp_read(struct file *file, char __user *buf, size_t count,
 	return bytes_read;
 }
 
-static ssize_t pp_write(struct file *file, const char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t pp_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	unsigned int minor = iminor(file_inode(file));
+	size_t count = iov_iter_count(from);
 	struct pp_struct *pp = file->private_data;
 	char *kbuffer;
 	ssize_t bytes_written = 0;
@@ -222,7 +224,7 @@ static ssize_t pp_write(struct file *file, const char __user *buf,
 	while (bytes_written < count) {
 		ssize_t n = min_t(unsigned long, count - bytes_written, PP_BUFFER_SIZE);
 
-		if (copy_from_user(kbuffer, buf + bytes_written, n)) {
+		if (!copy_from_iter_full(kbuffer, n, from)) {
 			bytes_written = -EFAULT;
 			break;
 		}
@@ -780,8 +782,8 @@ static const struct class ppdev_class = {
 static const struct file_operations pp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= pp_read,
-	.write		= pp_write,
+	.read_iter	= pp_read,
+	.write_iter	= pp_write,
 	.poll		= pp_poll,
 	.unlocked_ioctl	= pp_ioctl,
 	.compat_ioctl   = compat_ptr_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 032/437] char/ps3flash: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (30 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 031/437] char/ppdev: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 033/437] char/scx200_gpio: " Jens Axboe
                   ` (405 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/ps3flash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index 23871cde41fb..0d8c29116891 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -239,12 +239,14 @@ static ssize_t ps3flash_user_read(struct file *file, char __user *buf,
 {
 	return ps3flash_read(buf, NULL, count, pos);
 }
+FOPS_READ_ITER_HELPER(ps3flash_user_read);
 
 static ssize_t ps3flash_user_write(struct file *file, const char __user *buf,
 				   size_t count, loff_t *pos)
 {
 	return ps3flash_write(buf, NULL, count, pos);
 }
+FOPS_WRITE_ITER_HELPER(ps3flash_user_write);
 
 static ssize_t ps3flash_kernel_read(void *buf, size_t count, loff_t pos)
 {
@@ -310,8 +312,8 @@ static irqreturn_t ps3flash_interrupt(int irq, void *data)
 static const struct file_operations ps3flash_fops = {
 	.owner	= THIS_MODULE,
 	.llseek	= ps3flash_llseek,
-	.read	= ps3flash_user_read,
-	.write	= ps3flash_user_write,
+	.read_iter	= ps3flash_user_read_iter,
+	.write_iter	= ps3flash_user_write_iter,
 	.flush	= ps3flash_flush,
 	.fsync	= ps3flash_fsync,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 033/437] char/scx200_gpio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (31 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 032/437] char/ps3flash: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 034/437] char/sonypi: " Jens Axboe
                   ` (404 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/scx200_gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 9f701dcba95c..e6369766f7e3 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -64,8 +64,8 @@ static int scx200_gpio_release(struct inode *inode, struct file *file)
 
 static const struct file_operations scx200_gpio_fileops = {
 	.owner   = THIS_MODULE,
-	.write   = nsc_gpio_write,
-	.read    = nsc_gpio_read,
+	.write_iter   = nsc_gpio_write_iter,
+	.read_iter    = nsc_gpio_read_iter,
 	.open    = scx200_gpio_open,
 	.release = scx200_gpio_release,
 	.llseek  = no_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 034/437] char/sonypi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (32 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 033/437] char/scx200_gpio: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 035/437] char/tlclk: " Jens Axboe
                   ` (403 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/sonypi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 22d249333f53..2bb9f0a17989 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -925,6 +925,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(sonypi_misc_read);
 
 static __poll_t sonypi_misc_poll(struct file *file, poll_table *wait)
 {
@@ -1048,7 +1049,7 @@ static long sonypi_misc_ioctl(struct file *fp,
 
 static const struct file_operations sonypi_misc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= sonypi_misc_read,
+	.read_iter	= sonypi_misc_read_iter,
 	.poll		= sonypi_misc_poll,
 	.open		= sonypi_misc_open,
 	.release	= sonypi_misc_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 035/437] char/tlclk: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (33 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 034/437] char/sonypi: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 036/437] char/xilinx_hwicap: " Jens Axboe
                   ` (402 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/tlclk.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 896a3550fba9..17a312cfe46a 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -240,9 +240,10 @@ static int tlclk_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
-		loff_t *f_pos)
+static ssize_t tlclk_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
+
 	if (count < sizeof(struct tlclk_alarms))
 		return -EIO;
 	if (mutex_lock_interruptible(&tlclk_mutex))
@@ -250,7 +251,7 @@ static ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
 
 
 	wait_event_interruptible(wq, got_event);
-	if (copy_to_user(buf, alarm_events, sizeof(struct tlclk_alarms))) {
+	if (!copy_to_iter_full(alarm_events, sizeof(struct tlclk_alarms), to)) {
 		mutex_unlock(&tlclk_mutex);
 		return -EFAULT;
 	}
@@ -263,7 +264,7 @@ static ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
 }
 
 static const struct file_operations tlclk_fops = {
-	.read = tlclk_read,
+	.read_iter = tlclk_read,
 	.open = tlclk_open,
 	.release = tlclk_release,
 	.llseek = noop_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 036/437] char/xilinx_hwicap: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (34 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 035/437] char/tlclk: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 037/437] char/xillybus: " Jens Axboe
                   ` (401 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/xilinx_hwicap/xilinx_hwicap.c | 31 ++++++++++------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 4f6c3cb8aa41..fc5b8d18234d 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -349,10 +349,10 @@ static int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
 	return 0;
 }
 
-static ssize_t
-hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t hwicap_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hwicap_drvdata *drvdata = file->private_data;
+	struct hwicap_drvdata *drvdata = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	ssize_t bytes_to_read = 0;
 	u32 *kbuf;
 	u32 words;
@@ -372,7 +372,7 @@ hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			drvdata->read_buffer_in_use;
 
 		/* Return the data currently in the read buffer. */
-		if (copy_to_user(buf, drvdata->read_buffer, bytes_to_read)) {
+		if (!copy_to_iter_full(drvdata->read_buffer, bytes_to_read, to)) {
 			status = -EFAULT;
 			goto error;
 		}
@@ -417,7 +417,7 @@ hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		}
 
 		/* If we fail to return the data to the user, then bail out. */
-		if (copy_to_user(buf, kbuf, bytes_to_read)) {
+		if (!copy_to_iter_full(kbuf, bytes_to_read, to)) {
 			free_page((unsigned long)kbuf);
 			status = -EFAULT;
 			goto error;
@@ -434,11 +434,10 @@ hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	return status;
 }
 
-static ssize_t
-hwicap_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t hwicap_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hwicap_drvdata *drvdata = file->private_data;
+	struct hwicap_drvdata *drvdata = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t written = 0;
 	ssize_t left = count;
 	u32 *kbuf;
@@ -475,16 +474,15 @@ hwicap_write(struct file *file, const char __user *buf,
 		if (drvdata->write_buffer_in_use) {
 			memcpy(kbuf, drvdata->write_buffer,
 					drvdata->write_buffer_in_use);
-			if (copy_from_user(
+			if (!copy_from_iter_full(
 			    (((char *)kbuf) + drvdata->write_buffer_in_use),
-			    buf + written,
-			    len - (drvdata->write_buffer_in_use))) {
+			    len - (drvdata->write_buffer_in_use), from)) {
 				free_page((unsigned long)kbuf);
 				status = -EFAULT;
 				goto error;
 			}
 		} else {
-			if (copy_from_user(kbuf, buf + written, len)) {
+			if (!copy_from_iter_full(kbuf, len, from)) {
 				free_page((unsigned long)kbuf);
 				status = -EFAULT;
 				goto error;
@@ -508,8 +506,7 @@ hwicap_write(struct file *file, const char __user *buf,
 		left -= len;
 	}
 	if ((left > 0) && (left < 4)) {
-		if (!copy_from_user(drvdata->write_buffer,
-						buf + written, left)) {
+		if (copy_from_iter_full(drvdata->write_buffer, left, from)) {
 			drvdata->write_buffer_in_use = left;
 			written += left;
 			left = 0;
@@ -589,8 +586,8 @@ static int hwicap_release(struct inode *inode, struct file *file)
 
 static const struct file_operations hwicap_fops = {
 	.owner = THIS_MODULE,
-	.write = hwicap_write,
-	.read = hwicap_read,
+	.write_iter = hwicap_write,
+	.read_iter = hwicap_read,
 	.open = hwicap_open,
 	.release = hwicap_release,
 	.llseek = noop_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 037/437] char/xillybus: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (35 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 036/437] char/xilinx_hwicap: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 038/437] debugfs: convert to ->read_iter() Jens Axboe
                   ` (400 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/xillybus/xillybus_core.c | 36 +++++++++++++--------------
 drivers/char/xillybus/xillyusb.c      |  6 +++--
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c
index 11b7c4749274..d2f85c01bb74 100644
--- a/drivers/char/xillybus/xillybus_core.c
+++ b/drivers/char/xillybus/xillybus_core.c
@@ -28,6 +28,7 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
+#include <linux/uio.h>
 #include "xillybus.h"
 #include "xillybus_class.h"
 
@@ -687,15 +688,15 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint)
 	return 0;
 }
 
-static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
-			     size_t count, loff_t *f_pos)
+static ssize_t xillybus_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	ssize_t rc;
 	unsigned long flags;
 	int bytes_done = 0;
 	int no_time_left = 0;
 	long deadline, left_to_sleep;
-	struct xilly_channel *channel = filp->private_data;
+	struct xilly_channel *channel = iocb->ki_filp->private_data;
 
 	int empty, reached_eof, exhausted, ready;
 	/* Initializations are there only to silence warnings */
@@ -775,13 +776,11 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
 							channel->wr_buf_size,
 							DMA_FROM_DEVICE);
 
-			if (copy_to_user(
-				    userbuf,
+			if (!copy_to_iter_full(
 				    channel->wr_buffers[bufidx]->addr
-				    + bufpos, howmany))
+				    + bufpos, howmany, to))
 				rc = -EFAULT;
 
-			userbuf += howmany;
 			bytes_done += howmany;
 
 			if (bufferdone) {
@@ -831,7 +830,7 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
 		 * nonblocking mode, but only for a very short time.
 		 */
 
-		if (!no_time_left && (filp->f_flags & O_NONBLOCK)) {
+		if (!no_time_left && (iocb->ki_filp->f_flags & O_NONBLOCK)) {
 			if (bytes_done > 0)
 				break;
 
@@ -933,7 +932,7 @@ static ssize_t xillybus_read(struct file *filp, char __user *userbuf,
 				return -EIO;
 			if (bytes_done)
 				return bytes_done;
-			if (filp->f_flags & O_NONBLOCK)
+			if (iocb->ki_filp->f_flags & O_NONBLOCK)
 				return -EAGAIN; /* Don't admit snoozing */
 			return -EINTR;
 		}
@@ -1199,13 +1198,13 @@ static void xillybus_autoflush(struct work_struct *work)
 			"Autoflush failed under weird circumstances.\n");
 }
 
-static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
-			      size_t count, loff_t *f_pos)
+static ssize_t xillybus_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 	unsigned long flags;
 	int bytes_done = 0;
-	struct xilly_channel *channel = filp->private_data;
+	struct xilly_channel *channel = iocb->ki_filp->private_data;
 
 	int full, exhausted;
 	/* Initializations are there only to silence warnings */
@@ -1319,12 +1318,11 @@ static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
 				channel->rd_leftovers[3] = 0; /* Clear flag */
 			}
 
-			if (copy_from_user(
+			if (!copy_from_iter_full(
 				    channel->rd_buffers[bufidx]->addr + bufpos,
-				    userbuf, howmany))
+				    howmany, from))
 				rc = -EFAULT;
 
-			userbuf += howmany;
 			bytes_done += howmany;
 
 			if (bufferdone) {
@@ -1383,7 +1381,7 @@ static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
 		 * sleeps.
 		 */
 
-		if (filp->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			rc = -EAGAIN;
 			break;
 		}
@@ -1415,7 +1413,7 @@ static ssize_t xillybus_write(struct file *filp, const char __user *userbuf,
 		return rc;
 
 	if ((channel->rd_synchronous) && (bytes_done > 0)) {
-		rc = xillybus_myflush(filp->private_data, 0); /* No timeout */
+		rc = xillybus_myflush(channel, 0); /* No timeout */
 
 		if (rc && (rc != -EINTR))
 			return rc;
@@ -1793,8 +1791,8 @@ static __poll_t xillybus_poll(struct file *filp, poll_table *wait)
 
 static const struct file_operations xillybus_fops = {
 	.owner      = THIS_MODULE,
-	.read       = xillybus_read,
-	.write      = xillybus_write,
+	.read_iter  = xillybus_read,
+	.write_iter = xillybus_write,
 	.open       = xillybus_open,
 	.flush      = xillybus_flush,
 	.release    = xillybus_release,
diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index 5a5afa14ca8c..7a3aad47aabc 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -1605,6 +1605,7 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,
 
 	return rc;
 }
+FOPS_READ_ITER_HELPER(xillyusb_read);
 
 static int xillyusb_flush(struct file *filp, fl_owner_t id)
 {
@@ -1705,6 +1706,7 @@ static ssize_t xillyusb_write(struct file *filp, const char __user *userbuf,
 
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(xillyusb_write);
 
 static int xillyusb_release(struct inode *inode, struct file *filp)
 {
@@ -1895,8 +1897,8 @@ static __poll_t xillyusb_poll(struct file *filp, poll_table *wait)
 
 static const struct file_operations xillyusb_fops = {
 	.owner      = THIS_MODULE,
-	.read       = xillyusb_read,
-	.write      = xillyusb_write,
+	.read_iter  = xillyusb_read_iter,
+	.write_iter = xillyusb_write_iter,
 	.open       = xillyusb_open,
 	.flush      = xillyusb_flush,
 	.release    = xillyusb_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 038/437] debugfs: convert to ->read_iter()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (36 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 037/437] char/xillybus: " Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:12 ` [PATCH 039/437] libfs: switch to read iter and add copy helpers Jens Axboe
                   ` (399 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/kernel/dawr.c           |  10 ++-
 drivers/base/regmap/regmap-debugfs.c |  32 ++++++---
 drivers/misc/mei/debugfs.c           |  12 ++--
 fs/debugfs/file.c                    | 104 ++++++++++++++++++---------
 include/linux/debugfs.h              |  24 +++----
 kernel/sched/debug.c                 |   9 ++-
 6 files changed, 114 insertions(+), 77 deletions(-)

diff --git a/arch/powerpc/kernel/dawr.c b/arch/powerpc/kernel/dawr.c
index 909a05cd2809..03ab57564a18 100644
--- a/arch/powerpc/kernel/dawr.c
+++ b/arch/powerpc/kernel/dawr.c
@@ -59,9 +59,7 @@ static void disable_dawrs_cb(void *info)
 		set_dawr(i, &null_brk);
 }
 
-static ssize_t dawr_write_file_bool(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t dawr_write_file_bool(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct arch_hw_breakpoint null_brk = {0};
 	size_t rc;
@@ -72,7 +70,7 @@ static ssize_t dawr_write_file_bool(struct file *file,
 	    set_dawr(0, &null_brk) != H_SUCCESS)
 		return -ENODEV;
 
-	rc = debugfs_write_file_bool(file, user_buf, count, ppos);
+	rc = debugfs_write_file_bool(iocb, from);
 	if (rc)
 		return rc;
 
@@ -84,8 +82,8 @@ static ssize_t dawr_write_file_bool(struct file *file,
 }
 
 static const struct file_operations dawr_enable_fops = {
-	.read =		debugfs_read_file_bool,
-	.write =	dawr_write_file_bool,
+	.read_iter =	debugfs_read_file_bool,
+	.write_iter =	dawr_write_file_bool,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fb84cda92a75..571b5c00a28e 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -456,9 +456,9 @@ static int regmap_access_show(struct seq_file *s, void *ignored)
 
 DEFINE_SHOW_ATTRIBUTE(regmap_access);
 
-static ssize_t regmap_cache_only_write_file(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t __regmap_cache_only_write_file(struct file *file,
+					      const char __user *user_buf,
+					      size_t count, loff_t *ppos)
 {
 	struct regmap *map = container_of(file->private_data,
 					  struct regmap, cache_only);
@@ -497,15 +497,21 @@ static ssize_t regmap_cache_only_write_file(struct file *file,
 	return count;
 }
 
+static ssize_t regmap_cache_only_write_file(struct kiocb *iocb,
+					    struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __regmap_cache_only_write_file);
+}
+
 static const struct file_operations regmap_cache_only_fops = {
 	.open = simple_open,
-	.read = debugfs_read_file_bool,
-	.write = regmap_cache_only_write_file,
+	.read_iter = debugfs_read_file_bool,
+	.write_iter = regmap_cache_only_write_file,
 };
 
-static ssize_t regmap_cache_bypass_write_file(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t __regmap_cache_bypass_write_file(struct file *file,
+						const char __user *user_buf,
+						size_t count, loff_t *ppos)
 {
 	struct regmap *map = container_of(file->private_data,
 					  struct regmap, cache_bypass);
@@ -537,10 +543,16 @@ static ssize_t regmap_cache_bypass_write_file(struct file *file,
 	return count;
 }
 
+static ssize_t regmap_cache_bypass_write_file(struct kiocb *iocb,
+					      struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __regmap_cache_bypass_write_file);
+}
+
 static const struct file_operations regmap_cache_bypass_fops = {
 	.open = simple_open,
-	.read = debugfs_read_file_bool,
-	.write = regmap_cache_bypass_write_file,
+	.read_iter = debugfs_read_file_bool,
+	.write_iter = regmap_cache_bypass_write_file,
 };
 
 void regmap_debugfs_init(struct regmap *map)
diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 3b098d4c8e3d..b2e9fa911817 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -133,17 +133,15 @@ static int mei_dbgfs_devstate_show(struct seq_file *m, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(mei_dbgfs_devstate);
 
-static ssize_t mei_dbgfs_write_allow_fa(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t mei_dbgfs_write_allow_fa(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct mei_device *dev;
 	int ret;
 
-	dev = container_of(file->private_data,
+	dev = container_of(iocb->ki_filp->private_data,
 			   struct mei_device, allow_fixed_address);
 
-	ret = debugfs_write_file_bool(file, user_buf, count, ppos);
+	ret = debugfs_write_file_bool(iocb, from);
 	if (ret < 0)
 		return ret;
 	dev->override_fixed_address = true;
@@ -152,8 +150,8 @@ static ssize_t mei_dbgfs_write_allow_fa(struct file *file,
 
 static const struct file_operations mei_dbgfs_allow_fa_fops = {
 	.open = simple_open,
-	.read = debugfs_read_file_bool,
-	.write = mei_dbgfs_write_allow_fa,
+	.read_iter = debugfs_read_file_bool,
+	.write_iter = mei_dbgfs_write_allow_fa,
 	.llseek = generic_file_llseek,
 };
 
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index c6f4a9a98b85..c6ff9084bc0f 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -26,21 +26,19 @@
 
 struct poll_table_struct;
 
-static ssize_t default_read_file(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t default_read_file_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
 
-static ssize_t default_write_file(struct file *file, const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t default_write_file_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	return count;
+	return iov_iter_count(from);
 }
 
 const struct file_operations debugfs_noop_file_operations = {
-	.read =		default_read_file,
-	.write =	default_write_file,
+	.read_iter =	default_read_file_iter,
+	.write_iter =	default_write_file_iter,
 	.open =		simple_open,
 	.llseek =	noop_llseek,
 };
@@ -872,8 +870,9 @@ void debugfs_create_atomic_t(const char *name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(debugfs_create_atomic_t);
 
-ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t __debugfs_read_file_bool(struct file *file,
+					char __user *user_buf, size_t count,
+					loff_t *ppos)
 {
 	char buf[2];
 	bool val;
@@ -893,10 +892,16 @@ ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
 }
+
+ssize_t debugfs_read_file_bool(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __debugfs_read_file_bool);
+}
 EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
 
-ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t __debugfs_write_file_bool(struct file *file,
+					 const char __user *user_buf,
+					 size_t count, loff_t *ppos)
 {
 	bool bv;
 	int r;
@@ -914,23 +919,28 @@ ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
 
 	return count;
 }
+
+ssize_t debugfs_write_file_bool(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __debugfs_write_file_bool);
+}
 EXPORT_SYMBOL_GPL(debugfs_write_file_bool);
 
 static const struct file_operations fops_bool = {
-	.read =		debugfs_read_file_bool,
-	.write =	debugfs_write_file_bool,
+	.read_iter =	debugfs_read_file_bool,
+	.write_iter =	debugfs_write_file_bool,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
 
 static const struct file_operations fops_bool_ro = {
-	.read =		debugfs_read_file_bool,
+	.read_iter =	debugfs_read_file_bool,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
 
 static const struct file_operations fops_bool_wo = {
-	.write =	debugfs_write_file_bool,
+	.write_iter =	debugfs_write_file_bool,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
@@ -957,8 +967,8 @@ void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
 }
 EXPORT_SYMBOL_GPL(debugfs_create_bool);
 
-ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t __debugfs_read_file_str(struct file *file, char __user *user_buf,
+				       size_t count, loff_t *ppos)
 {
 	struct dentry *dentry = F_DENTRY(file);
 	char *str, *copy = NULL;
@@ -991,10 +1001,15 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(debugfs_create_str);
 
-static ssize_t debugfs_write_file_str(struct file *file, const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+ssize_t debugfs_read_file_str(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __debugfs_read_file_str);
+}
+
+static ssize_t __debugfs_write_file_str(struct file *file,
+					const char __user *user_buf,
+					size_t count, loff_t *ppos)
 {
 	struct dentry *dentry = F_DENTRY(file);
 	char *old, *new = NULL;
@@ -1044,21 +1059,26 @@ static ssize_t debugfs_write_file_str(struct file *file, const char __user *user
 	return r;
 }
 
+static ssize_t debugfs_write_file_str(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __debugfs_write_file_str);
+}
+
 static const struct file_operations fops_str = {
-	.read =		debugfs_read_file_str,
-	.write =	debugfs_write_file_str,
+	.read_iter =	debugfs_read_file_str,
+	.write_iter =	debugfs_write_file_str,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
 
 static const struct file_operations fops_str_ro = {
-	.read =		debugfs_read_file_str,
+	.read_iter =	debugfs_read_file_str,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
 
 static const struct file_operations fops_str_wo = {
-	.write =	debugfs_write_file_str,
+	.write_iter =	debugfs_write_file_str,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
@@ -1083,9 +1103,10 @@ void debugfs_create_str(const char *name, umode_t mode,
 	debugfs_create_mode_unsafe(name, mode, parent, value, &fops_str,
 				   &fops_str_ro, &fops_str_wo);
 }
+EXPORT_SYMBOL_GPL(debugfs_create_str);
 
-static ssize_t read_file_blob(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t __read_file_blob(struct file *file, char __user *user_buf,
+				size_t count, loff_t *ppos)
 {
 	struct debugfs_blob_wrapper *blob = file->private_data;
 	struct dentry *dentry = F_DENTRY(file);
@@ -1100,8 +1121,13 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf,
 	return r;
 }
 
-static ssize_t write_file_blob(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t read_file_blob(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __read_file_blob);
+}
+
+static ssize_t __write_file_blob(struct file *file, const char __user *user_buf,
+				 size_t count, loff_t *ppos)
 {
 	struct debugfs_blob_wrapper *blob = file->private_data;
 	struct dentry *dentry = F_DENTRY(file);
@@ -1117,9 +1143,14 @@ static ssize_t write_file_blob(struct file *file, const char __user *user_buf,
 	return r;
 }
 
+static ssize_t write_file_blob(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __write_file_blob);
+}
+
 static const struct file_operations fops_blob = {
-	.read =		read_file_blob,
-	.write =	write_file_blob,
+	.read_iter =	read_file_blob,
+	.write_iter =	write_file_blob,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
@@ -1197,8 +1228,8 @@ static int u32_array_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
-			      loff_t *ppos)
+static ssize_t __u32_array_read(struct file *file, char __user *buf, size_t len,
+				loff_t *ppos)
 {
 	size_t size = strlen(file->private_data);
 
@@ -1206,6 +1237,11 @@ static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len,
 					file->private_data, size);
 }
 
+static ssize_t u32_array_read(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __u32_array_read);
+}
+
 static int u32_array_release(struct inode *inode, struct file *file)
 {
 	kfree(file->private_data);
@@ -1217,7 +1253,7 @@ static const struct file_operations u32_array_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = u32_array_open,
 	.release = u32_array_release,
-	.read	 = u32_array_read,
+	.read_iter = u32_array_read,
 	.llseek  = no_llseek,
 };
 
@@ -1341,7 +1377,7 @@ static const struct file_operations debugfs_devm_entry_ops = {
 	.owner = THIS_MODULE,
 	.open = debugfs_devm_entry_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index c9c65b132c0f..ad417d079ec9 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -162,14 +162,11 @@ void debugfs_create_devm_seqfile(struct device *dev, const char *name,
 
 bool debugfs_initialized(void);
 
-ssize_t debugfs_read_file_bool(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos);
+ssize_t debugfs_read_file_bool(struct kiocb *iocb, struct iov_iter *to);
 
-ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos);
+ssize_t debugfs_write_file_bool(struct kiocb *iocb, struct iov_iter *from);
 
-ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos);
+ssize_t debugfs_read_file_str(struct kiocb *iocb, struct iov_iter *to);
 
 /**
  * struct debugfs_cancellation - cancellation data
@@ -376,23 +373,20 @@ static inline void debugfs_create_devm_seqfile(struct device *dev,
 {
 }
 
-static inline ssize_t debugfs_read_file_bool(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static inline ssize_t debugfs_read_file_bool(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	return -ENODEV;
 }
 
-static inline ssize_t debugfs_write_file_bool(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static inline ssize_t debugfs_write_file_bool(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
 	return -ENODEV;
 }
 
-static inline ssize_t debugfs_read_file_str(struct file *file,
-					    char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static inline ssize_t debugfs_read_file_str(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
 	return -ENODEV;
 }
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 8d5d98a5834d..686a21ea1791 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -284,8 +284,7 @@ __read_mostly bool sched_debug_verbose;
 static struct dentry           *sd_dentry;
 
 
-static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+static ssize_t sched_verbose_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	ssize_t result;
 	bool orig;
@@ -294,7 +293,7 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
 	mutex_lock(&sched_domains_mutex);
 
 	orig = sched_debug_verbose;
-	result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
+	result = debugfs_write_file_bool(iocb, from);
 
 	if (sched_debug_verbose && !orig)
 		update_sched_domain_debugfs();
@@ -313,8 +312,8 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
 #endif
 
 static const struct file_operations sched_verbose_fops = {
-	.read =         debugfs_read_file_bool,
-	.write =        sched_verbose_write,
+	.read_iter =         debugfs_read_file_bool,
+	.write_iter =        sched_verbose_write,
 	.open =         simple_open,
 	.llseek =       default_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 039/437] libfs: switch to read iter and add copy helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (37 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 038/437] debugfs: convert to ->read_iter() Jens Axboe
@ 2024-04-11 15:12 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 040/437] fs: convert generic_read_dir() to ->read_iter() Jens Axboe
                   ` (398 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/debugfs/file.c       | 44 +++++++++++++++++++++
 fs/libfs.c              | 87 +++++++++++++++++++++++++++++++++++++++++
 include/linux/debugfs.h | 25 +++++++++++-
 include/linux/fs.h      |  7 +++-
 4 files changed, 159 insertions(+), 4 deletions(-)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index c6ff9084bc0f..31749d8c35f8 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -468,6 +468,20 @@ ssize_t debugfs_attr_read(struct file *file, char __user *buf,
 }
 EXPORT_SYMBOL_GPL(debugfs_attr_read);
 
+ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	struct dentry *dentry = F_DENTRY(iocb->ki_filp);
+	ssize_t ret;
+
+	ret = debugfs_file_get(dentry);
+	if (unlikely(ret))
+		return ret;
+	ret = simple_attr_read_iter(iocb, to);
+	debugfs_file_put(dentry);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(debugfs_attr_read_iter);
+
 static ssize_t debugfs_attr_write_xsigned(struct file *file, const char __user *buf,
 			 size_t len, loff_t *ppos, bool is_signed)
 {
@@ -499,6 +513,36 @@ ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
 }
 EXPORT_SYMBOL_GPL(debugfs_attr_write_signed);
 
+static ssize_t debugfs_attr_write_iter_xsigned(struct kiocb *iocb,
+					       struct iov_iter *from,
+					       bool is_signed)
+{
+	struct dentry *dentry = F_DENTRY(iocb->ki_filp);
+	ssize_t ret;
+
+	ret = debugfs_file_get(dentry);
+	if (unlikely(ret))
+		return ret;
+	if (is_signed)
+		ret = simple_attr_write_iter_signed(iocb, from);
+	else
+		ret = simple_attr_write_iter(iocb, from);
+	debugfs_file_put(dentry);
+	return ret;
+}
+
+ssize_t debugfs_attr_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return debugfs_attr_write_iter_xsigned(iocb, from, false);
+}
+EXPORT_SYMBOL_GPL(debugfs_attr_write_iter);
+
+ssize_t debugfs_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from)
+{
+	return debugfs_attr_write_iter_xsigned(iocb, from, true);
+}
+EXPORT_SYMBOL_GPL(debugfs_attr_write_iter_signed);
+
 static struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode,
 					struct dentry *parent, void *value,
 					const struct file_operations *fops,
diff --git a/fs/libfs.c b/fs/libfs.c
index 074cfacc377f..90f79113e48b 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1365,6 +1365,93 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
 }
 EXPORT_SYMBOL_GPL(simple_attr_read);
 
+/* read from the buffer that is filled with the get function */
+ssize_t simple_attr_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	struct simple_attr *attr;
+	size_t size;
+	ssize_t ret;
+
+	attr = iocb->ki_filp->private_data;
+
+	if (!attr->get)
+		return -EACCES;
+
+	ret = mutex_lock_interruptible(&attr->mutex);
+	if (ret)
+		return ret;
+
+	if (iocb->ki_pos && attr->get_buf[0]) {
+		/* continued read */
+		size = strlen(attr->get_buf);
+	} else {
+		/* first read */
+		u64 val;
+		ret = attr->get(attr->data, &val);
+		if (ret)
+			goto out;
+
+		size = scnprintf(attr->get_buf, sizeof(attr->get_buf),
+				 attr->fmt, (unsigned long long)val);
+	}
+
+	ret = simple_copy_to_iter(attr->get_buf, &iocb->ki_pos, size, to);
+out:
+	mutex_unlock(&attr->mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(simple_attr_read_iter);
+
+static ssize_t __simple_write_iter(struct kiocb *iocb, struct iov_iter *from,
+				   bool is_signed)
+{
+	struct simple_attr *attr;
+	unsigned long long val;
+	size_t len = iov_iter_count(from);
+	size_t size;
+	ssize_t ret;
+
+	attr = iocb->ki_filp->private_data;
+	if (!attr->set)
+		return -EACCES;
+
+	ret = mutex_lock_interruptible(&attr->mutex);
+	if (ret)
+		return ret;
+
+	ret = -EFAULT;
+	size = min(sizeof(attr->set_buf) - 1, len);
+	if (!copy_from_iter(attr->set_buf, size, from))
+		goto out;
+
+	attr->set_buf[size] = '\0';
+	if (is_signed)
+		ret = kstrtoll(attr->set_buf, 0, &val);
+	else
+		ret = kstrtoull(attr->set_buf, 0, &val);
+	if (ret)
+		goto out;
+	ret = attr->set(attr->data, val);
+	if (ret == 0)
+		ret = len; /* on success, claim we got the whole input */
+out:
+	mutex_unlock(&attr->mutex);
+	return ret;
+}
+
+ssize_t simple_attr_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return __simple_write_iter(iocb, from, false);
+}
+EXPORT_SYMBOL_GPL(simple_attr_write_iter);
+
+ssize_t simple_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from)
+
+{
+	return __simple_write_iter(iocb, from, true);
+}
+EXPORT_SYMBOL_GPL(simple_attr_write_iter_signed);
+
 /* interpret the buffer as a number to call the set function with */
 static ssize_t simple_attr_write_xsigned(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos, bool is_signed)
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index ad417d079ec9..c6d189059d3d 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -55,8 +55,8 @@ static const struct file_operations __fops = {				\
 	.owner	 = THIS_MODULE,						\
 	.open	 = __fops ## _open,					\
 	.release = simple_attr_release,					\
-	.read	 = debugfs_attr_read,					\
-	.write	 = (__is_signed) ? debugfs_attr_write_signed : debugfs_attr_write,	\
+	.read_iter = debugfs_attr_read_iter,				\
+	.write_iter= (__is_signed) ? debugfs_attr_write_iter_signed : debugfs_attr_write_iter,	\
 	.llseek  = no_llseek,						\
 }
 
@@ -106,10 +106,13 @@ void debugfs_file_put(struct dentry *dentry);
 
 ssize_t debugfs_attr_read(struct file *file, char __user *buf,
 			size_t len, loff_t *ppos);
+ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to);
 ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
 			size_t len, loff_t *ppos);
+ssize_t debugfs_attr_write_iter(struct kiocb *iocb, struct iov_iter *from);
 ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
 			size_t len, loff_t *ppos);
+ssize_t debugfs_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from);
 
 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, const char *new_name);
@@ -271,6 +274,12 @@ static inline ssize_t debugfs_attr_read(struct file *file, char __user *buf,
 	return -ENODEV;
 }
 
+static inline ssize_t debugfs_attr_read_iter(struct kiocb *iocb,
+					     struct iov_iter *to)
+{
+	return -ENODEV;
+}
+
 static inline ssize_t debugfs_attr_write(struct file *file,
 					const char __user *buf,
 					size_t len, loff_t *ppos)
@@ -278,6 +287,12 @@ static inline ssize_t debugfs_attr_write(struct file *file,
 	return -ENODEV;
 }
 
+static inline ssize_t debugfs_attr_write_iter(struct kiocb *iocb,
+					      struct iov_iter *from)
+{
+	return -ENODEV;
+}
+
 static inline ssize_t debugfs_attr_write_signed(struct file *file,
 					const char __user *buf,
 					size_t len, loff_t *ppos)
@@ -285,6 +300,12 @@ static inline ssize_t debugfs_attr_write_signed(struct file *file,
 	return -ENODEV;
 }
 
+static inline ssize_t debugfs_attr_write_iter_signed(struct kiocb *iocb,
+						     struct iov_iter *from)
+{
+	return -ENODEV;
+}
+
 static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, char *new_name)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5806cea7a3ac..d15a79020efa 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3528,8 +3528,8 @@ static const struct file_operations __fops = {				\
 	.owner	 = THIS_MODULE,						\
 	.open	 = __fops ## _open,					\
 	.release = simple_attr_release,					\
-	.read	 = simple_attr_read,					\
-	.write	 = (__is_signed) ? simple_attr_write_signed : simple_attr_write,	\
+	.read_iter = simple_attr_read_iter,				\
+	.write_iter = (__is_signed) ? simple_attr_write_iter_signed : simple_attr_write_iter,	\
 	.llseek	 = generic_file_llseek,					\
 }
 
@@ -3555,6 +3555,9 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
 				 size_t len, loff_t *ppos);
+ssize_t simple_attr_read_iter(struct kiocb *iocb, struct iov_iter *to);
+ssize_t simple_attr_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t simple_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from);
 
 struct ctl_table;
 int __init list_bdev_fs_names(char *buf, size_t size);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 040/437] fs: convert generic_read_dir() to ->read_iter()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (38 preceding siblings ...)
  2024-04-11 15:12 ` [PATCH 039/437] libfs: switch to read iter and add copy helpers Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 041/437] fs: convert any user of fops->read() for seq_read to read_iter Jens Axboe
                   ` (397 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

No functional changes here, just a straight forward mechanical
conversion.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/platforms/cell/spufs/inode.c |  2 +-
 fs/9p/vfs_dir.c                           |  4 ++--
 fs/adfs/dir.c                             |  2 +-
 fs/affs/dir.c                             |  2 +-
 fs/autofs/root.c                          |  4 ++--
 fs/bcachefs/fs.c                          |  2 +-
 fs/befs/linuxvfs.c                        |  2 +-
 fs/bfs/dir.c                              |  2 +-
 fs/btrfs/inode.c                          |  2 +-
 fs/coda/dir.c                             |  2 +-
 fs/configfs/dir.c                         |  2 +-
 fs/cramfs/inode.c                         |  2 +-
 fs/ecryptfs/file.c                        |  2 +-
 fs/efs/dir.c                              |  2 +-
 fs/erofs/dir.c                            |  2 +-
 fs/exfat/dir.c                            |  2 +-
 fs/ext2/dir.c                             |  2 +-
 fs/ext4/dir.c                             |  2 +-
 fs/f2fs/dir.c                             |  2 +-
 fs/fat/dir.c                              |  2 +-
 fs/freevxfs/vxfs_lookup.c                 |  2 +-
 fs/fuse/dir.c                             |  2 +-
 fs/hfs/dir.c                              |  2 +-
 fs/hfsplus/dir.c                          |  2 +-
 fs/hostfs/hostfs_kern.c                   |  2 +-
 fs/hpfs/dir.c                             |  2 +-
 fs/isofs/dir.c                            |  2 +-
 fs/jffs2/dir.c                            |  2 +-
 fs/jfs/namei.c                            |  2 +-
 fs/kernfs/dir.c                           |  2 +-
 fs/libfs.c                                |  8 ++++----
 fs/minix/dir.c                            |  2 +-
 fs/nfs/dir.c                              |  2 +-
 fs/nilfs2/dir.c                           |  2 +-
 fs/ntfs3/dir.c                            |  2 +-
 fs/ocfs2/file.c                           |  4 ++--
 fs/omfs/dir.c                             |  2 +-
 fs/openpromfs/inode.c                     |  2 +-
 fs/orangefs/dir.c                         |  2 +-
 fs/overlayfs/readdir.c                    |  2 +-
 fs/proc/base.c                            | 12 ++++++------
 fs/proc/fd.c                              |  4 ++--
 fs/proc/generic.c                         |  2 +-
 fs/proc/namespaces.c                      |  2 +-
 fs/proc/proc_net.c                        |  2 +-
 fs/proc/proc_sysctl.c                     |  2 +-
 fs/proc/root.c                            |  2 +-
 fs/qnx4/dir.c                             |  2 +-
 fs/qnx6/dir.c                             |  2 +-
 fs/reiserfs/dir.c                         |  2 +-
 fs/romfs/super.c                          |  2 +-
 fs/smb/client/cifsfs.c                    |  2 +-
 fs/squashfs/dir.c                         |  2 +-
 fs/sysv/dir.c                             |  2 +-
 fs/tracefs/event_inode.c                  |  2 +-
 fs/ubifs/dir.c                            |  2 +-
 fs/udf/dir.c                              |  2 +-
 fs/ufs/dir.c                              |  2 +-
 fs/vboxsf/dir.c                           |  2 +-
 fs/xfs/xfs_file.c                         |  2 +-
 fs/zonefs/super.c                         |  2 +-
 include/linux/fs.h                        |  2 +-
 62 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 030de2b8c145..cdb3cc344eb4 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -220,7 +220,7 @@ const struct file_operations spufs_context_fops = {
 	.open		= dcache_dir_open,
 	.release	= spufs_dir_close,
 	.llseek		= dcache_dir_lseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= dcache_readdir,
 	.fsync		= noop_fsync,
 };
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index e0d34e4e9076..b1e2a8b7b289 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -237,7 +237,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
 }
 
 const struct file_operations v9fs_dir_operations = {
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.llseek = generic_file_llseek,
 	.iterate_shared = v9fs_dir_readdir,
 	.open = v9fs_file_open,
@@ -245,7 +245,7 @@ const struct file_operations v9fs_dir_operations = {
 };
 
 const struct file_operations v9fs_dir_operations_dotl = {
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.llseek = generic_file_llseek,
 	.iterate_shared = v9fs_dir_readdir_dotl,
 	.open = v9fs_file_open,
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 77fbd196008f..22b93599d4bb 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -385,7 +385,7 @@ static int adfs_dir_lookup_byname(struct inode *inode, const struct qstr *qstr,
 }
 
 const struct file_operations adfs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.llseek		= generic_file_llseek,
 	.iterate_shared	= adfs_iterate,
 	.fsync		= generic_file_fsync,
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index b2bf7016e1b3..dc51f7bfbb27 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -20,7 +20,7 @@
 static int affs_readdir(struct file *, struct dir_context *);
 
 const struct file_operations affs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.llseek		= generic_file_llseek,
 	.iterate_shared	= affs_readdir,
 	.fsync		= affs_file_fsync,
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 530d18827e35..eb69ab79633d 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -32,7 +32,7 @@ static void autofs_dentry_release(struct dentry *);
 const struct file_operations autofs_root_operations = {
 	.open		= dcache_dir_open,
 	.release	= dcache_dir_close,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= dcache_readdir,
 	.llseek		= dcache_dir_lseek,
 	.unlocked_ioctl	= autofs_root_ioctl,
@@ -44,7 +44,7 @@ const struct file_operations autofs_root_operations = {
 const struct file_operations autofs_dir_operations = {
 	.open		= autofs_dir_open,
 	.release	= dcache_dir_close,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= dcache_readdir,
 	.llseek		= dcache_dir_lseek,
 };
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index b5ea9fa1259d..a804e1a898f2 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -1156,7 +1156,7 @@ static const struct inode_operations bch_dir_inode_operations = {
 
 static const struct file_operations bch_dir_file_operations = {
 	.llseek		= bch2_dir_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= bch2_vfs_readdir,
 	.fsync		= bch2_fsync,
 	.unlocked_ioctl = bch2_fs_file_ioctl,
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index d76f406d3b2e..24af5f365539 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -77,7 +77,7 @@ static const struct super_operations befs_sops = {
 static struct kmem_cache *befs_inode_cachep;
 
 static const struct file_operations befs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= befs_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index c375e22c4c0c..d646e597402b 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -69,7 +69,7 @@ static int bfs_readdir(struct file *f, struct dir_context *ctx)
 }
 
 const struct file_operations bfs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= bfs_readdir,
 	.fsync		= generic_file_fsync,
 	.llseek		= generic_file_llseek,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c65fe5de4022..2aa1bb9977e9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -11029,7 +11029,7 @@ static const struct inode_operations btrfs_dir_inode_operations = {
 
 static const struct file_operations btrfs_dir_file_operations = {
 	.llseek		= btrfs_dir_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= btrfs_real_readdir,
 	.open		= btrfs_opendir,
 	.unlocked_ioctl	= btrfs_ioctl,
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 4e552ba7bd43..b0f80d6324fa 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -581,7 +581,7 @@ const struct inode_operations coda_dir_inode_operations = {
 WRAP_DIR_ITER(coda_readdir) // FIXME!
 const struct file_operations coda_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= shared_coda_readdir,
 	.open		= coda_open,
 	.release	= coda_release,
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 18677cd4e62f..3bfee6589f77 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1706,7 +1706,7 @@ const struct file_operations configfs_dir_operations = {
 	.open		= configfs_dir_open,
 	.release	= configfs_dir_close,
 	.llseek		= configfs_dir_lseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= configfs_readdir,
 };
 
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 9901057a15ba..fd73b433a5ad 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -933,7 +933,7 @@ static const struct address_space_operations cramfs_aops = {
  */
 static const struct file_operations cramfs_directory_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= cramfs_readdir,
 };
 
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index ce0a3c5ed0ca..96e24760f1c6 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -414,7 +414,7 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 const struct file_operations ecryptfs_dir_fops = {
 	.iterate_shared = ecryptfs_readdir,
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.unlocked_ioctl = ecryptfs_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = ecryptfs_compat_ioctl,
diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index f892ac7c2a35..4071a68d31a8 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -12,7 +12,7 @@ static int efs_readdir(struct file *, struct dir_context *);
 
 const struct file_operations efs_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= efs_readdir,
 };
 
diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c
index b80abec0531a..0241036883e2 100644
--- a/fs/erofs/dir.c
+++ b/fs/erofs/dir.c
@@ -106,6 +106,6 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
 
 const struct file_operations erofs_dir_fops = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= erofs_readdir,
 };
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 077944d3c2c0..90482fcca07a 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -309,7 +309,7 @@ static int exfat_iterate(struct file *file, struct dir_context *ctx)
 WRAP_DIR_ITER(exfat_iterate) // FIXME!
 const struct file_operations exfat_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= shared_exfat_iterate,
 	.unlocked_ioctl = exfat_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 4fb155b5a958..93fa6c54286d 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -706,7 +706,7 @@ int ext2_empty_dir(struct inode *inode)
 
 const struct file_operations ext2_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= ext2_readdir,
 	.unlocked_ioctl = ext2_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 3985f8c33f95..955679a8f6b3 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -666,7 +666,7 @@ int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf,
 
 const struct file_operations ext4_dir_operations = {
 	.llseek		= ext4_dir_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= ext4_readdir,
 	.unlocked_ioctl = ext4_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 02c9355176d3..1338883797bd 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -1133,7 +1133,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
 
 const struct file_operations f2fs_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= f2fs_readdir,
 	.fsync		= f2fs_sync_file,
 	.unlocked_ioctl	= f2fs_ioctl,
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 00235b8a1823..79b569cf2ea3 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -857,7 +857,7 @@ static long fat_compat_dir_ioctl(struct file *filp, unsigned cmd,
 
 const struct file_operations fat_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= fat_readdir,
 	.unlocked_ioctl	= fat_dir_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index 1b0bca8b4cc6..cf4dd54adc9c 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -34,7 +34,7 @@ const struct inode_operations vxfs_dir_inode_ops = {
 
 const struct file_operations vxfs_dir_operations = {
 	.llseek =		generic_file_llseek,
-	.read =			generic_read_dir,
+	.read_iter =		generic_read_dir,
 	.iterate_shared =	vxfs_readdir,
 };
 
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 4a6df591add6..b59420d3284b 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -2149,7 +2149,7 @@ static const struct inode_operations fuse_dir_inode_operations = {
 
 static const struct file_operations fuse_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= fuse_readdir,
 	.open		= fuse_dir_open,
 	.release	= fuse_dir_release,
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index b75c26045df4..cb20b9419a1b 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -307,7 +307,7 @@ static int hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
 }
 
 const struct file_operations hfs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= hfs_readdir,
 	.llseek		= generic_file_llseek,
 	.release	= hfs_dir_release,
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index f5c4b3e31a1c..6910ed8a0f54 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -575,7 +575,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
 
 const struct file_operations hfsplus_dir_operations = {
 	.fsync		= hfsplus_file_fsync,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= hfsplus_readdir,
 	.unlocked_ioctl = hfsplus_ioctl,
 	.llseek		= generic_file_llseek,
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index a73d27c4dd58..4f3a7d9d8949 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -390,7 +390,7 @@ static const struct file_operations hostfs_file_fops = {
 static const struct file_operations hostfs_dir_fops = {
 	.llseek		= generic_file_llseek,
 	.iterate_shared	= hostfs_readdir,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.open		= hostfs_open,
 	.fsync		= hostfs_fsync,
 };
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 49dd585c2b17..2672f123cbda 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -322,7 +322,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
 const struct file_operations hpfs_dir_ops =
 {
 	.llseek		= hpfs_dir_lseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= hpfs_readdir,
 	.release	= hpfs_dir_release,
 	.fsync		= hpfs_file_fsync,
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index eb2f8273e6f1..278f5111feb3 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -268,7 +268,7 @@ static int isofs_readdir(struct file *file, struct dir_context *ctx)
 const struct file_operations isofs_dir_operations =
 {
 	.llseek = generic_file_llseek,
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.iterate_shared = isofs_readdir,
 };
 
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 2b2938970da3..6b6a8228d75c 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -43,7 +43,7 @@ static int jffs2_rename (struct mnt_idmap *, struct inode *,
 
 const struct file_operations jffs2_dir_operations =
 {
-	.read =		generic_read_dir,
+	.read_iter =	generic_read_dir,
 	.iterate_shared=jffs2_readdir,
 	.unlocked_ioctl=jffs2_ioctl,
 	.fsync =	jffs2_fsync,
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index d68a4e6ac345..e6d27d7b9636 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1539,7 +1539,7 @@ const struct inode_operations jfs_dir_inode_operations = {
 
 WRAP_DIR_ITER(jfs_readdir) // FIXME!
 const struct file_operations jfs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= shared_jfs_readdir,
 	.fsync		= jfs_fsync,
 	.unlocked_ioctl = jfs_ioctl,
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 458519e416fe..12f57e4d8664 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1880,7 +1880,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)
 }
 
 const struct file_operations kernfs_dir_fops = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= kernfs_fop_readdir,
 	.release	= kernfs_dir_fop_release,
 	.llseek		= generic_file_llseek,
diff --git a/fs/libfs.c b/fs/libfs.c
index 90f79113e48b..3280d02fc385 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -220,7 +220,7 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
 }
 EXPORT_SYMBOL(dcache_readdir);
 
-ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
+ssize_t generic_read_dir(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EISDIR;
 }
@@ -230,7 +230,7 @@ const struct file_operations simple_dir_operations = {
 	.open		= dcache_dir_open,
 	.release	= dcache_dir_close,
 	.llseek		= dcache_dir_lseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= dcache_readdir,
 	.fsync		= noop_fsync,
 };
@@ -527,7 +527,7 @@ static int offset_readdir(struct file *file, struct dir_context *ctx)
 const struct file_operations simple_offset_dir_operations = {
 	.llseek		= offset_dir_llseek,
 	.iterate_shared	= offset_readdir,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.fsync		= noop_fsync,
 };
 
@@ -1856,7 +1856,7 @@ static int empty_dir_readdir(struct file *file, struct dir_context *ctx)
 
 static const struct file_operations empty_dir_operations = {
 	.llseek		= empty_dir_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= empty_dir_readdir,
 	.fsync		= noop_fsync,
 };
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index a224cf222570..4cd7f7a0b412 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -21,7 +21,7 @@ static int minix_readdir(struct file *, struct dir_context *);
 
 const struct file_operations minix_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= minix_readdir,
 	.fsync		= generic_file_fsync,
 };
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ac505671efbd..bb746c6fa8eb 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -59,7 +59,7 @@ static void nfs_readdir_clear_array(struct folio *);
 
 const struct file_operations nfs_dir_operations = {
 	.llseek		= nfs_llseek_dir,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= nfs_readdir,
 	.open		= nfs_opendir,
 	.release	= nfs_closedir,
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index bc846b904b68..9aea991801af 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -646,7 +646,7 @@ int nilfs_empty_dir(struct inode *inode)
 
 const struct file_operations nilfs_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= nilfs_readdir,
 	.unlocked_ioctl	= nilfs_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c
index 5cf3d9decf64..c7913821c238 100644
--- a/fs/ntfs3/dir.c
+++ b/fs/ntfs3/dir.c
@@ -607,7 +607,7 @@ bool dir_is_empty(struct inode *dir)
 // clang-format off
 const struct file_operations ntfs_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= ntfs_readdir,
 	.fsync		= generic_file_fsync,
 	.open		= ntfs_file_open,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 0da8e7bd3261..dc55dc87af7a 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2796,7 +2796,7 @@ const struct file_operations ocfs2_fops = {
 WRAP_DIR_ITER(ocfs2_readdir) // FIXME!
 const struct file_operations ocfs2_dops = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= shared_ocfs2_readdir,
 	.fsync		= ocfs2_sync_file,
 	.release	= ocfs2_dir_release,
@@ -2842,7 +2842,7 @@ const struct file_operations ocfs2_fops_no_plocks = {
 
 const struct file_operations ocfs2_dops_no_plocks = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= shared_ocfs2_readdir,
 	.fsync		= ocfs2_sync_file,
 	.release	= ocfs2_dir_release,
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 6bda275826d6..9cfc68191917 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -455,7 +455,7 @@ const struct inode_operations omfs_dir_inops = {
 };
 
 const struct file_operations omfs_dir_operations = {
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.iterate_shared = omfs_readdir,
 	.llseek = generic_file_llseek,
 };
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 4a0779e3ef79..e25eceac86f4 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -167,7 +167,7 @@ static const struct file_operations openpromfs_prop_ops = {
 static int openpromfs_readdir(struct file *, struct dir_context *);
 
 static const struct file_operations openprom_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= openpromfs_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index 6d1fbeca9d81..e28d41f0d1e2 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -389,7 +389,7 @@ static int orangefs_dir_release(struct inode *inode, struct file *file)
 
 const struct file_operations orangefs_dir_operations = {
 	.llseek = orangefs_dir_llseek,
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.iterate_shared = orangefs_dir_iterate,
 	.open = orangefs_dir_open,
 	.release = orangefs_dir_release
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 0ca8af060b0c..cfd6995e67bd 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -970,7 +970,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
 
 WRAP_DIR_ITER(ovl_iterate) // FIXME!
 const struct file_operations ovl_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.open		= ovl_dir_open,
 	.iterate_shared	= shared_ovl_iterate,
 	.llseek		= ovl_dir_llseek,
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 18550c071d71..4c6a7aafe66a 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2430,7 +2430,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
 }
 
 static const struct file_operations proc_map_files_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_map_files_readdir,
 	.llseek		= generic_file_llseek,
 };
@@ -2811,7 +2811,7 @@ static int proc_##LSM##_attr_dir_iterate(struct file *filp, \
 } \
 \
 static const struct file_operations proc_##LSM##_attr_dir_ops = { \
-	.read		= generic_read_dir, \
+	.read_iter	= generic_read_dir, \
 	.iterate_shared	= proc_##LSM##_attr_dir_iterate, \
 	.llseek		= default_llseek, \
 }; \
@@ -2870,7 +2870,7 @@ static int proc_attr_dir_readdir(struct file *file, struct dir_context *ctx)
 }
 
 static const struct file_operations proc_attr_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_attr_dir_readdir,
 	.llseek		= generic_file_llseek,
 };
@@ -3368,7 +3368,7 @@ static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
 }
 
 static const struct file_operations proc_tgid_base_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_tgid_base_readdir,
 	.llseek		= generic_file_llseek,
 };
@@ -3714,7 +3714,7 @@ static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *den
 }
 
 static const struct file_operations proc_tid_base_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_tid_base_readdir,
 	.llseek		= generic_file_llseek,
 };
@@ -3923,7 +3923,7 @@ static const struct inode_operations proc_task_inode_operations = {
 };
 
 static const struct file_operations proc_task_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_task_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 6e72e5ad42bc..63a3aebdf223 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -314,7 +314,7 @@ static int proc_readfd(struct file *file, struct dir_context *ctx)
 }
 
 const struct file_operations proc_fd_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_readfd,
 	.llseek		= generic_file_llseek,
 };
@@ -424,7 +424,7 @@ const struct inode_operations proc_fdinfo_inode_operations = {
 
 const struct file_operations proc_fdinfo_operations = {
 	.open		= proc_open_fdinfo,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_readfdinfo,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 775ce0bcf08c..ec5d7ebc8576 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -339,7 +339,7 @@ int proc_readdir(struct file *file, struct dir_context *ctx)
  */
 static const struct file_operations proc_dir_operations = {
 	.llseek			= generic_file_llseek,
-	.read			= generic_read_dir,
+	.read_iter		= generic_read_dir,
 	.iterate_shared		= proc_readdir,
 };
 
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 8e159fc78c0a..fdd3452ad990 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -143,7 +143,7 @@ static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx)
 }
 
 const struct file_operations proc_ns_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_ns_dir_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 2ba31b6d68c0..0779fc13ae17 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -340,7 +340,7 @@ static int proc_tgid_net_readdir(struct file *file, struct dir_context *ctx)
 
 const struct file_operations proc_net_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_tgid_net_readdir,
 };
 
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 37cde0efee57..72939941686b 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -860,7 +860,7 @@ static const struct file_operations proc_sys_file_operations = {
 };
 
 static const struct file_operations proc_sys_dir_file_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= proc_sys_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 06a297a27ba3..579a204fec8b 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -346,7 +346,7 @@ static int proc_root_readdir(struct file *file, struct dir_context *ctx)
  * directory handling functions for that..
  */
 static const struct file_operations proc_root_operations = {
-	.read		 = generic_read_dir,
+	.read_iter	 = generic_read_dir,
 	.iterate_shared	 = proc_root_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
index 42a529e26bd6..55ff69c5a6bb 100644
--- a/fs/qnx4/dir.c
+++ b/fs/qnx4/dir.c
@@ -68,7 +68,7 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx)
 const struct file_operations qnx4_dir_operations =
 {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= qnx4_readdir,
 	.fsync		= generic_file_fsync,
 };
diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c
index c1cfb8a19e9d..e678486d737a 100644
--- a/fs/qnx6/dir.c
+++ b/fs/qnx6/dir.c
@@ -272,7 +272,7 @@ unsigned qnx6_find_entry(int len, struct inode *dir, const char *name,
 
 const struct file_operations qnx6_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= qnx6_readdir,
 	.fsync		= generic_file_fsync,
 };
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 79ee2b436685..c1a01dd186b3 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -19,7 +19,7 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
 
 const struct file_operations reiserfs_dir_operations = {
 	.llseek = generic_file_llseek,
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.iterate_shared = reiserfs_readdir,
 	.fsync = reiserfs_dir_fsync,
 	.unlocked_ioctl = reiserfs_ioctl,
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 2cbb92462074..48780a2dd12c 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -263,7 +263,7 @@ static struct dentry *romfs_lookup(struct inode *dir, struct dentry *dentry,
 }
 
 static const struct file_operations romfs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= romfs_readdir,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index d41eedbff674..c6515979b8f2 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -1640,7 +1640,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
 const struct file_operations cifs_dir_ops = {
 	.iterate_shared = cifs_readdir,
 	.release = cifs_closedir,
-	.read    = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.unlocked_ioctl  = cifs_ioctl,
 	.copy_file_range = cifs_copy_file_range,
 	.remap_file_range = cifs_remap_file_range,
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c
index a2ade63eccdf..c2d7d29a2a0d 100644
--- a/fs/squashfs/dir.c
+++ b/fs/squashfs/dir.c
@@ -217,7 +217,7 @@ static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 
 
 const struct file_operations squashfs_dir_ops = {
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.iterate_shared = squashfs_readdir,
 	.llseek = generic_file_llseek,
 };
diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 2e126d72d619..7a68d075e95d 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -23,7 +23,7 @@ static int sysv_readdir(struct file *, struct dir_context *);
 
 const struct file_operations sysv_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= sysv_readdir,
 	.fsync		= generic_file_fsync,
 };
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index dc067eeb6387..4dfec30b2228 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -277,7 +277,7 @@ static const struct inode_operations eventfs_file_inode_operations = {
 };
 
 static const struct file_operations eventfs_file_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= eventfs_iterate,
 	.llseek		= generic_file_llseek,
 };
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index eac0fef801f1..3f70d4edd0ee 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1719,7 +1719,7 @@ const struct inode_operations ubifs_dir_inode_operations = {
 const struct file_operations ubifs_dir_operations = {
 	.llseek         = generic_file_llseek,
 	.release        = ubifs_dir_release,
-	.read           = generic_read_dir,
+	.read_iter      = generic_read_dir,
 	.iterate_shared = ubifs_readdir,
 	.fsync          = ubifs_fsync,
 	.unlocked_ioctl = ubifs_ioctl,
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index f94f45fe2c91..309dbe1a62e5 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -131,7 +131,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
 /* readdir and lookup functions */
 const struct file_operations udf_dir_operations = {
 	.llseek			= generic_file_llseek,
-	.read			= generic_read_dir,
+	.read_iter		= generic_read_dir,
 	.iterate_shared		= udf_readdir,
 	.unlocked_ioctl		= udf_ioctl,
 	.fsync			= generic_file_fsync,
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 27c85d92d1dc..8656f264b3be 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -648,7 +648,7 @@ int ufs_empty_dir(struct inode * inode)
 }
 
 const struct file_operations ufs_dir_operations = {
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= ufs_readdir,
 	.fsync		= generic_file_fsync,
 	.llseek		= generic_file_llseek,
diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
index 5f1a14d5b927..917cfbcc75f2 100644
--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -184,7 +184,7 @@ const struct file_operations vboxsf_dir_fops = {
 	.open = vboxsf_dir_open,
 	.iterate_shared = shared_vboxsf_dir_iterate,
 	.release = vboxsf_dir_release,
-	.read = generic_read_dir,
+	.read_iter = generic_read_dir,
 	.llseek = generic_file_llseek,
 };
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 632653e00906..24ce652bd1f8 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1502,7 +1502,7 @@ const struct file_operations xfs_file_operations = {
 
 const struct file_operations xfs_dir_file_operations = {
 	.open		= xfs_dir_open,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= xfs_file_readdir,
 	.llseek		= generic_file_llseek,
 	.unlocked_ioctl	= xfs_file_ioctl,
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index c6a124e8d565..d0460b2bf4f5 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -838,7 +838,7 @@ const struct inode_operations zonefs_dir_inode_operations = {
 
 const struct file_operations zonefs_dir_operations = {
 	.llseek		= generic_file_llseek,
-	.read		= generic_read_dir,
+	.read_iter	= generic_read_dir,
 	.iterate_shared	= zonefs_readdir,
 };
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d15a79020efa..483c70d3941e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3337,7 +3337,7 @@ extern int simple_nosetlease(struct file *, int, struct file_lease **, void **);
 extern const struct dentry_operations simple_dentry_operations;
 
 extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);
-extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);
+extern ssize_t generic_read_dir(struct kiocb *, struct iov_iter *);
 extern const struct file_operations simple_dir_operations;
 extern const struct inode_operations simple_dir_inode_operations;
 extern void make_empty_dir_inode(struct inode *inode);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 041/437] fs: convert any user of fops->read() for seq_read to read_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (39 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 040/437] fs: convert generic_read_dir() to ->read_iter() Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 042/437] ceph: convert read_dir handler to read_iter() Jens Axboe
                   ` (396 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

There's a seq_read_iter that can be used, do that.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/dlm/debug_fs.c              | 10 +++++-----
 fs/gfs2/glock.c                |  6 +++---
 fs/ocfs2/cluster/netdebug.c    |  6 +++---
 fs/ocfs2/dlm/dlmdebug.c        |  2 +-
 fs/ocfs2/dlmglue.c             |  2 +-
 fs/orangefs/orangefs-debugfs.c |  2 +-
 fs/proc/array.c                |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 4fa11d9ddbb6..1236e8d13453 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -774,7 +774,7 @@ static int table_open5(struct inode *inode, struct file *file)
 static const struct file_operations format1_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open1,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -782,7 +782,7 @@ static const struct file_operations format1_fops = {
 static const struct file_operations format2_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open2,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.write   = table_write2,
 	.llseek  = seq_lseek,
 	.release = seq_release
@@ -791,7 +791,7 @@ static const struct file_operations format2_fops = {
 static const struct file_operations format3_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open3,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -799,7 +799,7 @@ static const struct file_operations format3_fops = {
 static const struct file_operations format4_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open4,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -807,7 +807,7 @@ static const struct file_operations format4_fops = {
 static const struct file_operations format5_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open5,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 34540f9d011c..c57d468dce21 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -2699,7 +2699,7 @@ static int gfs2_glstats_open(struct inode *inode, struct file *file)
 static const struct file_operations gfs2_glocks_fops = {
 	.owner   = THIS_MODULE,
 	.open    = gfs2_glocks_open,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = gfs2_glocks_release,
 };
@@ -2707,7 +2707,7 @@ static const struct file_operations gfs2_glocks_fops = {
 static const struct file_operations gfs2_glstats_fops = {
 	.owner   = THIS_MODULE,
 	.open    = gfs2_glstats_open,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = gfs2_glocks_release,
 };
@@ -2876,7 +2876,7 @@ static int gfs2_glockfd_open(struct inode *inode, struct file *file)
 static const struct file_operations gfs2_glockfd_fops = {
 	.owner   = THIS_MODULE,
 	.open    = gfs2_glockfd_open,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release_private,
 };
diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
index bc27301eab6d..fde10358c8ee 100644
--- a/fs/ocfs2/cluster/netdebug.c
+++ b/fs/ocfs2/cluster/netdebug.c
@@ -184,7 +184,7 @@ static int nst_fop_release(struct inode *inode, struct file *file)
 
 static const struct file_operations nst_seq_fops = {
 	.open = nst_fop_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = nst_fop_release,
 };
@@ -416,7 +416,7 @@ static int stats_fop_open(struct inode *inode, struct file *file)
 
 static const struct file_operations stats_seq_fops = {
 	.open = stats_fop_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = sc_fop_release,
 };
@@ -428,7 +428,7 @@ static int sc_fop_open(struct inode *inode, struct file *file)
 
 static const struct file_operations sc_seq_fops = {
 	.open = sc_fop_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = sc_fop_release,
 };
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index be5e9ed7da8d..cd4857d5a44a 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -651,7 +651,7 @@ static int debug_lockres_release(struct inode *inode, struct file *file)
 static const struct file_operations debug_lockres_fops = {
 	.open =		debug_lockres_open,
 	.release =	debug_lockres_release,
-	.read =		seq_read,
+	.read_iter =	seq_read_iter,
 	.llseek =	seq_lseek,
 };
 /* end - debug lockres funcs */
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index cb40cafbc062..673697bfae39 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3299,7 +3299,7 @@ static int ocfs2_dlm_debug_open(struct inode *inode, struct file *file)
 static const struct file_operations ocfs2_dlm_debug_fops = {
 	.open =		ocfs2_dlm_debug_open,
 	.release =	ocfs2_dlm_debug_release,
-	.read =		seq_read,
+	.read_iter =	seq_read_iter,
 	.llseek =	seq_lseek,
 };
 
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 1b508f543384..2f1ed95ac8fb 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -116,7 +116,7 @@ static const struct seq_operations help_debug_ops = {
 static const struct file_operations debug_help_fops = {
 	.owner		= THIS_MODULE,
 	.open           = orangefs_debug_help_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.release        = seq_release,
 	.llseek         = seq_lseek,
 };
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 34a47fb0c57f..756fc6accd26 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -815,7 +815,7 @@ static int children_seq_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_tid_children_operations = {
 	.open    = children_seq_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 042/437] ceph: convert read_dir handler to read_iter()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (40 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 041/437] fs: convert any user of fops->read() for seq_read to read_iter Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 043/437] ecryptfs: miscdev: convert to read/write iterators Jens Axboe
                   ` (395 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ceph/dir.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 0e9f56eaba1e..3397b24f9e1a 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -2110,12 +2110,13 @@ static void ceph_d_prune(struct dentry *dentry)
  * read() on a dir.  This weird interface hack only works if mounted
  * with '-o dirstat'.
  */
-static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
-			     loff_t *ppos)
+static ssize_t ceph_read_dir(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	struct ceph_dir_file_info *dfi = file->private_data;
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
+	size_t size;
 	int left;
 	const int bufsize = 1024;
 
@@ -2147,13 +2148,13 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
 				ci->i_rctime.tv_nsec);
 	}
 
-	if (*ppos >= dfi->dir_info_len)
+	if (iocb->ki_pos >= dfi->dir_info_len)
 		return 0;
-	size = min_t(unsigned, size, dfi->dir_info_len-*ppos);
-	left = copy_to_user(buf, dfi->dir_info + *ppos, size);
+	size = min_t(unsigned, iov_iter_count(to), dfi->dir_info_len-iocb->ki_pos);
+	left = copy_to_iter(dfi->dir_info + iocb->ki_pos, size, to);
 	if (left == size)
 		return -EFAULT;
-	*ppos += (size - left);
+	iocb->ki_pos += (size - left);
 	return size - left;
 }
 
@@ -2184,7 +2185,7 @@ unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn)
 
 WRAP_DIR_ITER(ceph_readdir) // FIXME!
 const struct file_operations ceph_dir_fops = {
-	.read = ceph_read_dir,
+	.read_iter = ceph_read_dir,
 	.iterate_shared = shared_ceph_readdir,
 	.llseek = ceph_dir_llseek,
 	.open = ceph_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 043/437] ecryptfs: miscdev: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (41 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 042/437] ceph: convert read_dir handler to read_iter() Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 044/437] ocfs2: " Jens Axboe
                   ` (394 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ecryptfs/miscdev.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index 4e62c3cef70f..6ea67a64e2ff 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -309,6 +309,7 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
 	mutex_unlock(&daemon->mux);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(ecryptfs_miscdev_read);
 
 /**
  * ecryptfs_miscdev_response - miscdevess response to message previously sent to daemon
@@ -342,22 +343,20 @@ static int ecryptfs_miscdev_response(struct ecryptfs_daemon *daemon, char *data,
 
 /**
  * ecryptfs_miscdev_write - handle write to daemon miscdev handle
- * @file: File for misc dev handle
- * @buf: Buffer containing user data
- * @count: Amount of data in @buf
- * @ppos: Pointer to offset in file (ignored)
+ * @iocb: Metadata for IO
+ * @from: Buffer containing user data
  *
  * Returns the number of bytes read from @buf
  */
 static ssize_t
-ecryptfs_miscdev_write(struct file *file, const char __user *buf,
-		       size_t count, loff_t *ppos)
+ecryptfs_miscdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	__be32 counter_nbo;
 	u32 seq;
 	size_t packet_size, packet_size_length;
 	char *data;
 	unsigned char packet_size_peek[ECRYPTFS_MAX_PKT_LEN_SIZE];
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 
 	if (count == 0) {
@@ -372,8 +371,8 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
 		return -EINVAL;
 	}
 
-	if (copy_from_user(packet_size_peek, &buf[PKT_LEN_OFFSET],
-			   sizeof(packet_size_peek))) {
+	if (!copy_from_iter_full(packet_size_peek, sizeof(packet_size_peek),
+				 from)) {
 		printk(KERN_WARNING "%s: Error while inspecting packet size\n",
 		       __func__);
 		return -EFAULT;
@@ -395,7 +394,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
 	}
 
 memdup:
-	data = memdup_user(buf, count);
+	data = iterdup(from, count);
 	if (IS_ERR(data)) {
 		printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
 		       __func__, PTR_ERR(data));
@@ -416,7 +415,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
 		}
 		memcpy(&counter_nbo, &data[PKT_CTR_OFFSET], PKT_CTR_SIZE);
 		seq = be32_to_cpu(counter_nbo);
-		rc = ecryptfs_miscdev_response(file->private_data,
+		rc = ecryptfs_miscdev_response(iocb->ki_filp->private_data,
 				&data[PKT_LEN_OFFSET + packet_size_length],
 				packet_size, seq);
 		if (rc) {
@@ -442,13 +441,12 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
 	return rc;
 }
 
-
 static const struct file_operations ecryptfs_miscdev_fops = {
 	.owner   = THIS_MODULE,
 	.open    = ecryptfs_miscdev_open,
 	.poll    = ecryptfs_miscdev_poll,
-	.read    = ecryptfs_miscdev_read,
-	.write   = ecryptfs_miscdev_write,
+	.read_iter    = ecryptfs_miscdev_read_iter,
+	.write_iter   = ecryptfs_miscdev_write,
 	.release = ecryptfs_miscdev_release,
 	.llseek  = noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 044/437] ocfs2: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (42 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 043/437] ecryptfs: miscdev: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 045/437] orangefs: " Jens Axboe
                   ` (393 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ocfs2/cluster/heartbeat.c | 15 ++++++++-------
 fs/ocfs2/dlm/dlmdebug.c      | 16 +++++++++-------
 fs/ocfs2/stack_user.c        |  6 ++++--
 fs/ocfs2/super.c             | 15 ++++++++-------
 4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 1bde1281d514..6baff47a3a08 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1350,12 +1350,14 @@ static int o2hb_debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
-				 size_t nbytes, loff_t *ppos)
+static ssize_t o2hb_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
+
 #else
 static int o2hb_debug_open(struct inode *inode, struct file *file)
 {
@@ -1365,8 +1367,7 @@ static int o2hb_debug_release(struct inode *inode, struct file *file)
 {
 	return 0;
 }
-static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
-			       size_t nbytes, loff_t *ppos)
+static ssize_t o2hb_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -1375,7 +1376,7 @@ static ssize_t o2hb_debug_read(struct file *file, char __user *buf,
 static const struct file_operations o2hb_debug_fops = {
 	.open =		o2hb_debug_open,
 	.release =	o2hb_debug_release,
-	.read =		o2hb_debug_read,
+	.read_iter =	o2hb_debug_read,
 	.llseek =	generic_file_llseek,
 };
 
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index cd4857d5a44a..bad07f55bbf6 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -336,12 +336,14 @@ static int debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debug_read(struct file *file, char __user *buf,
-			  size_t nbytes, loff_t *ppos)
+static ssize_t debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
+
 /* end - util funcs */
 
 /* begin - purge list funcs */
@@ -395,7 +397,7 @@ static int debug_purgelist_open(struct inode *inode, struct file *file)
 static const struct file_operations debug_purgelist_fops = {
 	.open =		debug_purgelist_open,
 	.release =	debug_release,
-	.read =		debug_read,
+	.read_iter =	debug_read,
 	.llseek =	generic_file_llseek,
 };
 /* end - purge list funcs */
@@ -452,7 +454,7 @@ static int debug_mle_open(struct inode *inode, struct file *file)
 static const struct file_operations debug_mle_fops = {
 	.open =		debug_mle_open,
 	.release =	debug_release,
-	.read =		debug_read,
+	.read_iter =	debug_read,
 	.llseek =	generic_file_llseek,
 };
 
@@ -843,7 +845,7 @@ static int debug_state_open(struct inode *inode, struct file *file)
 static const struct file_operations debug_state_fops = {
 	.open =		debug_state_open,
 	.release =	debug_release,
-	.read =		debug_read,
+	.read_iter =	debug_read,
 	.llseek =	generic_file_llseek,
 };
 /* end  - debug state funcs */
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index c11406cd87a8..360fb8f35e43 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -534,6 +534,7 @@ static ssize_t ocfs2_control_write(struct file *file,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ocfs2_control_write);
 
 /*
  * This is a naive version.  If we ever have a new protocol, we'll expand
@@ -556,6 +557,7 @@ static ssize_t ocfs2_control_read(struct file *file,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(ocfs2_control_read);
 
 static int ocfs2_control_release(struct inode *inode, struct file *file)
 {
@@ -616,8 +618,8 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
 static const struct file_operations ocfs2_control_fops = {
 	.open    = ocfs2_control_open,
 	.release = ocfs2_control_release,
-	.read    = ocfs2_control_read,
-	.write   = ocfs2_control_write,
+	.read_iter = ocfs2_control_read_iter,
+	.write_iter = ocfs2_control_write_iter,
 	.owner   = THIS_MODULE,
 	.llseek  = default_llseek,
 };
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 8aabaed2c1cb..6f7107ecd6c6 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -360,12 +360,14 @@ static int ocfs2_debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t ocfs2_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
+
 #else
 static int ocfs2_osb_debug_open(struct inode *inode, struct file *file)
 {
@@ -375,8 +377,7 @@ static int ocfs2_debug_release(struct inode *inode, struct file *file)
 {
 	return 0;
 }
-static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t ocfs2_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -385,7 +386,7 @@ static ssize_t ocfs2_debug_read(struct file *file, char __user *buf,
 static const struct file_operations ocfs2_osb_debug_fops = {
 	.open =		ocfs2_osb_debug_open,
 	.release =	ocfs2_debug_release,
-	.read =		ocfs2_debug_read,
+	.read_iter =	ocfs2_debug_read,
 	.llseek =	generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 045/437] orangefs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (43 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 044/437] ocfs2: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 046/437] dlm: " Jens Axboe
                   ` (392 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/orangefs/devorangefs-req.c  | 23 +++++++++----------
 fs/orangefs/orangefs-debugfs.c | 40 ++++++++++++----------------------
 2 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c
index 33ee8cb32f83..b3325cc88b63 100644
--- a/fs/orangefs/devorangefs-req.c
+++ b/fs/orangefs/devorangefs-req.c
@@ -155,18 +155,18 @@ static int orangefs_devreq_open(struct inode *inode, struct file *file)
 }
 
 /* Function for read() callers into the device */
-static ssize_t orangefs_devreq_read(struct file *file,
-				 char __user *buf,
-				 size_t count, loff_t *offset)
+static ssize_t orangefs_devreq_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct orangefs_kernel_op_s *op, *temp;
 	__s32 proto_ver = ORANGEFS_KERNEL_PROTO_VERSION;
 	static __s32 magic = ORANGEFS_DEVREQ_MAGIC;
 	struct orangefs_kernel_op_s *cur_op;
+	size_t count = iov_iter_count(to);
 	unsigned long ret;
 
 	/* We do not support blocking IO. */
-	if (!(file->f_flags & O_NONBLOCK)) {
+	if (!((iocb->ki_filp->f_flags & O_NONBLOCK) &&
+	     (iocb->ki_flags & IOCB_NOWAIT))) {
 		gossip_err("%s: blocking read from client-core.\n",
 			   __func__);
 		return -EINVAL;
@@ -278,20 +278,17 @@ static ssize_t orangefs_devreq_read(struct file *file,
 	spin_unlock(&cur_op->lock);
 
 	/* Push the upcall out. */
-	ret = copy_to_user(buf, &proto_ver, sizeof(__s32));
+	ret = !copy_to_iter_full(&proto_ver, sizeof(__s32), to);
 	if (ret != 0)
 		goto error;
-	ret = copy_to_user(buf + sizeof(__s32), &magic, sizeof(__s32));
+	ret = !copy_to_iter_full(&magic, sizeof(__s32), to);
 	if (ret != 0)
 		goto error;
-	ret = copy_to_user(buf + 2 * sizeof(__s32),
-		&cur_op->tag,
-		sizeof(__u64));
+	ret = !copy_to_iter_full(&cur_op->tag, sizeof(__u64), to);
 	if (ret != 0)
 		goto error;
-	ret = copy_to_user(buf + 2 * sizeof(__s32) + sizeof(__u64),
-		&cur_op->upcall,
-		sizeof(struct orangefs_upcall_s));
+	ret = !copy_to_iter_full(&cur_op->upcall,
+				 sizeof(struct orangefs_upcall_s), to);
 	if (ret != 0)
 		goto error;
 
@@ -768,7 +765,7 @@ static int orangefs_dev_major;
 
 static const struct file_operations orangefs_devreq_file_operations = {
 	.owner = THIS_MODULE,
-	.read = orangefs_devreq_read,
+	.read_iter = orangefs_devreq_read,
 	.write_iter = orangefs_devreq_write_iter,
 	.open = orangefs_devreq_open,
 	.release = orangefs_devreq_release,
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 2f1ed95ac8fb..926800659a41 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -74,15 +74,8 @@ static int help_show(struct seq_file *, void *);
 
 static int orangefs_debug_open(struct inode *, struct file *);
 
-static ssize_t orangefs_debug_read(struct file *,
-				 char __user *,
-				 size_t,
-				 loff_t *);
-
-static ssize_t orangefs_debug_write(struct file *,
-				  const char __user *,
-				  size_t,
-				  loff_t *);
+static ssize_t orangefs_debug_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t orangefs_debug_write(struct kiocb *iocb, struct iov_iter *to);
 
 static int orangefs_prepare_cdm_array(char *);
 static void debug_mask_to_string(void *, int);
@@ -124,8 +117,8 @@ static const struct file_operations debug_help_fops = {
 static const struct file_operations kernel_debug_fops = {
 	.owner		= THIS_MODULE,
 	.open           = orangefs_debug_open,
-	.read           = orangefs_debug_read,
-	.write		= orangefs_debug_write,
+	.read_iter      = orangefs_debug_read,
+	.write_iter	= orangefs_debug_write,
 	.llseek         = generic_file_llseek,
 };
 
@@ -338,10 +331,7 @@ static int orangefs_debug_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static ssize_t orangefs_debug_read(struct file *file,
-				 char __user *ubuf,
-				 size_t count,
-				 loff_t *ppos)
+static ssize_t orangefs_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buf;
 	int sprintf_ret;
@@ -354,10 +344,10 @@ static ssize_t orangefs_debug_read(struct file *file,
 		goto out;
 
 	mutex_lock(&orangefs_debug_lock);
-	sprintf_ret = sprintf(buf, "%s", (char *)file->private_data);
+	sprintf_ret = sprintf(buf, "%s", (char *)iocb->ki_filp->private_data);
 	mutex_unlock(&orangefs_debug_lock);
 
-	read_ret = simple_read_from_buffer(ubuf, count, ppos, buf, sprintf_ret);
+	read_ret = simple_copy_to_iter(buf, &iocb->ki_pos, sprintf_ret, to);
 
 	kfree(buf);
 
@@ -369,11 +359,9 @@ static ssize_t orangefs_debug_read(struct file *file,
 	return read_ret;
 }
 
-static ssize_t orangefs_debug_write(struct file *file,
-				  const char __user *ubuf,
-				  size_t count,
-				  loff_t *ppos)
+static ssize_t orangefs_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int rc = -EFAULT;
 	size_t silly = 0;
@@ -384,7 +372,7 @@ static ssize_t orangefs_debug_write(struct file *file,
 
 	gossip_debug(GOSSIP_DEBUGFS_DEBUG,
 		"orangefs_debug_write: %pD\n",
-		file);
+		iocb->ki_filp);
 
 	if (count == 0)
 		return 0;
@@ -402,7 +390,7 @@ static ssize_t orangefs_debug_write(struct file *file,
 	if (!buf)
 		goto out;
 
-	if (copy_from_user(buf, ubuf, count - 1)) {
+	if (!copy_from_iter_full(buf, count - 1, from)) {
 		gossip_debug(GOSSIP_DEBUGFS_DEBUG,
 			     "%s: copy_from_user failed!\n",
 			     __func__);
@@ -418,7 +406,7 @@ static ssize_t orangefs_debug_write(struct file *file,
 	 * A service operation is required to set a new client-side
 	 * debug mask.
 	 */
-	if (!strcmp(file->f_path.dentry->d_name.name,
+	if (!strcmp(iocb->ki_filp->f_path.dentry->d_name.name,
 		    ORANGEFS_KMOD_DEBUG_FILE)) {
 		debug_string_to_mask(buf, &orangefs_gossip_debug_mask, 0);
 		debug_mask_to_string(&orangefs_gossip_debug_mask, 0);
@@ -471,12 +459,12 @@ static ssize_t orangefs_debug_write(struct file *file,
 	}
 
 	mutex_lock(&orangefs_debug_lock);
-	s = file_inode(file)->i_private;
+	s = file_inode(iocb->ki_filp)->i_private;
 	memset(s, 0, ORANGEFS_MAX_DEBUG_STRING_LEN);
 	sprintf(s, "%s\n", debug_string);
 	mutex_unlock(&orangefs_debug_lock);
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	if (silly)
 		rc = silly;
 	else
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 046/437] dlm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (44 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 045/437] orangefs: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 047/437] tracefs: " Jens Axboe
                   ` (391 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/dlm/debug_fs.c | 41 +++++++++++++++++++----------------------
 fs/dlm/plock.c    | 16 ++++++++--------
 fs/dlm/user.c     | 17 +++++++++--------
 3 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 1236e8d13453..2207cd83ab09 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -700,10 +700,10 @@ static int table_open2(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t table_write2(struct file *file, const char __user *user_buf,
-			    size_t count, loff_t *ppos)
+static ssize_t table_write2(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int n, len, lkb_nodeid, lkb_status, error;
 	char name[DLM_RESNAME_MAXLEN + 1] = {};
 	struct dlm_ls *ls = seq->private;
@@ -711,8 +711,7 @@ static ssize_t table_write2(struct file *file, const char __user *user_buf,
 	char buf[256] = {};
 	uint32_t lkb_id;
 
-	if (copy_from_user(buf, user_buf,
-			   min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	n = sscanf(buf, "%x %" __stringify(DLM_RESNAME_MAXLEN) "s %x %d %d",
@@ -783,7 +782,7 @@ static const struct file_operations format2_fops = {
 	.owner   = THIS_MODULE,
 	.open    = table_open2,
 	.read_iter    = seq_read_iter,
-	.write   = table_write2,
+	.write_iter   = table_write2,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -815,10 +814,9 @@ static const struct file_operations format5_fops = {
 /*
  * dump lkb's on the ls_waiters list
  */
-static ssize_t waiters_read(struct file *file, char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t waiters_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dlm_ls *ls = file->private_data;
+	struct dlm_ls *ls = iocb->ki_filp->private_data;
 	struct dlm_lkb *lkb;
 	size_t len = DLM_DEBUG_BUF_LEN, pos = 0, ret, rv;
 
@@ -836,22 +834,21 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
 	}
 	mutex_unlock(&ls->ls_waiters_mutex);
 
-	rv = simple_read_from_buffer(userbuf, count, ppos, debug_buf, pos);
+	rv = simple_copy_to_iter(debug_buf, &iocb->ki_pos, pos, to);
 	mutex_unlock(&debug_buf_lock);
 	return rv;
 }
 
-static ssize_t waiters_write(struct file *file, const char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t waiters_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dlm_ls *ls = file->private_data;
+	struct dlm_ls *ls = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int mstype, to_nodeid;
 	char buf[128] = {};
 	uint32_t lkb_id;
 	int n, error;
 
-	if (copy_from_user(buf, user_buf,
-			   min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	n = sscanf(buf, "%x %d %d", &lkb_id, &mstype, &to_nodeid);
@@ -868,8 +865,8 @@ static ssize_t waiters_write(struct file *file, const char __user *user_buf,
 static const struct file_operations waiters_fops = {
 	.owner   = THIS_MODULE,
 	.open    = simple_open,
-	.read    = waiters_read,
-	.write   = waiters_write,
+	.read_iter    = waiters_read,
+	.write_iter   = waiters_write,
 	.llseek  = default_llseek,
 };
 
@@ -911,9 +908,9 @@ static int dlm_version_show(struct seq_file *file, void *offset)
 }
 DEFINE_SHOW_ATTRIBUTE(dlm_version);
 
-static ssize_t dlm_rawmsg_write(struct file *fp, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t dlm_rawmsg_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	void *buf;
 	int ret;
 
@@ -924,12 +921,12 @@ static ssize_t dlm_rawmsg_write(struct file *fp, const char __user *user_buf,
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, user_buf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		ret = -EFAULT;
 		goto out;
 	}
 
-	ret = dlm_midcomms_rawmsg_send(fp->private_data, buf, count);
+	ret = dlm_midcomms_rawmsg_send(iocb->ki_filp->private_data, buf, count);
 	if (ret)
 		goto out;
 
@@ -943,7 +940,7 @@ static ssize_t dlm_rawmsg_write(struct file *fp, const char __user *user_buf,
 
 static const struct file_operations dlm_rawmsg_fops = {
 	.open	= simple_open,
-	.write	= dlm_rawmsg_write,
+	.write_iter	= dlm_rawmsg_write,
 	.llseek	= no_llseek,
 };
 
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 9ca83ef70ed1..f6d00f39f991 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -478,9 +478,9 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
 EXPORT_SYMBOL_GPL(dlm_posix_get);
 
 /* a read copies out one plock request from the send list */
-static ssize_t dev_read(struct file *file, char __user *u, size_t count,
-			loff_t *ppos)
+static ssize_t dev_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct dlm_plock_info info;
 	struct plock_op *op = NULL;
 
@@ -510,16 +510,16 @@ static ssize_t dev_read(struct file *file, char __user *u, size_t count,
 	if (op->info.flags & DLM_PLOCK_FL_CLOSE)
 		dlm_release_plock_op(op);
 
-	if (copy_to_user(u, &info, sizeof(info)))
+	if (!copy_to_iter_full(&info, sizeof(info), to))
 		return -EFAULT;
 	return sizeof(info);
 }
 
 /* a write copies in one plock result that should match a plock_op
    on the recv list */
-static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
-			 loff_t *ppos)
+static ssize_t dev_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct plock_op *op = NULL, *iter;
 	struct dlm_plock_info info;
 	int do_callback = 0;
@@ -527,7 +527,7 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
 	if (count != sizeof(info))
 		return -EINVAL;
 
-	if (copy_from_user(&info, u, sizeof(info)))
+	if (!copy_from_iter_full(&info, sizeof(info), from))
 		return -EFAULT;
 
 	trace_dlm_plock_write(&info);
@@ -598,8 +598,8 @@ static __poll_t dev_poll(struct file *file, poll_table *wait)
 }
 
 static const struct file_operations dev_fops = {
-	.read    = dev_read,
-	.write   = dev_write,
+	.read_iter    = dev_read,
+	.write_iter   = dev_write,
 	.poll    = dev_poll,
 	.owner   = THIS_MODULE,
 	.llseek  = noop_llseek,
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 9f9b68448830..362c9998929e 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -524,10 +524,10 @@ static int check_version(struct dlm_write_request *req)
 /* a write to a lockspace device is a lock or unlock request, a write
    to the control device is to create/remove a lockspace */
 
-static ssize_t device_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t device_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dlm_user_proc *proc = file->private_data;
+	struct dlm_user_proc *proc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct dlm_write_request *kbuf;
 	int error;
 
@@ -545,7 +545,7 @@ static ssize_t device_write(struct file *file, const char __user *buf,
 	if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN)
 		return -EINVAL;
 
-	kbuf = memdup_user_nul(buf, count);
+	kbuf = iterdup_nul(from, count);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
@@ -918,6 +918,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(device_read);
 
 static __poll_t device_poll(struct file *file, poll_table *wait)
 {
@@ -982,8 +983,8 @@ static int monitor_device_close(struct inode *inode, struct file *file)
 static const struct file_operations device_fops = {
 	.open    = device_open,
 	.release = device_close,
-	.read    = device_read,
-	.write   = device_write,
+	.read_iter    = device_read_iter,
+	.write_iter   = device_write,
 	.poll    = device_poll,
 	.owner   = THIS_MODULE,
 	.llseek  = noop_llseek,
@@ -992,8 +993,8 @@ static const struct file_operations device_fops = {
 static const struct file_operations ctl_device_fops = {
 	.open    = ctl_device_open,
 	.release = ctl_device_close,
-	.read    = device_read,
-	.write   = device_write,
+	.read_iter    = device_read_iter,
+	.write_iter   = device_write,
 	.owner   = THIS_MODULE,
 	.llseek  = noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 047/437] tracefs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (45 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 046/437] dlm: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 048/437] ubifs: " Jens Axboe
                   ` (390 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/tracefs/inode.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 5545e6bf7d26..b1a9b5f10581 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -46,21 +46,19 @@ static void tracefs_free_inode(struct inode *inode)
 	kmem_cache_free(tracefs_inode_cachep, get_tracefs(inode));
 }
 
-static ssize_t default_read_file(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t default_read_file_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
 
-static ssize_t default_write_file(struct file *file, const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t default_write_file_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations tracefs_file_operations = {
-	.read =		default_read_file,
-	.write =	default_write_file,
+	.read_iter =	default_read_file_iter,
+	.write_iter =	default_write_file_iter,
 	.open =		simple_open,
 	.llseek =	noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 048/437] ubifs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (46 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 047/437] tracefs: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 049/437] fuse: " Jens Axboe
                   ` (389 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ubifs/debug.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index ac77ac1fd73e..2d63f57aca6f 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2728,6 +2728,7 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
 
 	return provide_user_output(val, u, count, ppos);
 }
+FOPS_READ_ITER_HELPER(dfs_file_read);
 
 /**
  * interpret_user_input - interpret user debugfs file input.
@@ -2801,11 +2802,12 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(dfs_file_write);
 
 static const struct file_operations dfs_fops = {
 	.open = dfs_file_open,
-	.read = dfs_file_read,
-	.write = dfs_file_write,
+	.read_iter = dfs_file_read_iter,
+	.write_iter = dfs_file_write_iter,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 049/437] fuse: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (47 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 048/437] ubifs: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 050/437] staging: convert drivers " Jens Axboe
                   ` (388 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/fuse/control.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 97ac994ff78f..0ca1d1f418c3 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -31,37 +31,36 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
 	return fc;
 }
 
-static ssize_t fuse_conn_abort_write(struct file *file, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t fuse_conn_abort_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+	struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (fc) {
 		if (fc->abort_err)
 			fc->aborted = true;
 		fuse_abort_conn(fc);
 		fuse_conn_put(fc);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
-static ssize_t fuse_conn_waiting_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *ppos)
+static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
 	char tmp[32];
 	size_t size;
 
-	if (!*ppos) {
+	if (!iocb->ki_pos) {
 		long value;
-		struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+		struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 		if (!fc)
 			return 0;
 
 		value = atomic_read(&fc->num_waiting);
-		file->private_data = (void *)value;
+		iocb->ki_filp->private_data = (void *)value;
 		fuse_conn_put(fc);
 	}
-	size = sprintf(tmp, "%ld\n", (long)file->private_data);
-	return simple_read_from_buffer(buf, len, ppos, tmp, size);
+	size = sprintf(tmp, "%ld\n", (long)iocb->ki_filp->private_data);
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
 static ssize_t fuse_conn_limit_read(struct file *file, char __user *buf,
@@ -115,6 +114,7 @@ static ssize_t fuse_conn_max_background_read(struct file *file,
 
 	return fuse_conn_limit_read(file, buf, len, ppos, val);
 }
+FOPS_READ_ITER_HELPER(fuse_conn_max_background_read);
 
 static ssize_t fuse_conn_max_background_write(struct file *file,
 					      const char __user *buf,
@@ -140,6 +140,7 @@ static ssize_t fuse_conn_max_background_write(struct file *file,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(fuse_conn_max_background_write);
 
 static ssize_t fuse_conn_congestion_threshold_read(struct file *file,
 						   char __user *buf, size_t len,
@@ -179,30 +180,31 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
 out:
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(fuse_conn_congestion_threshold_write);
 
 static const struct file_operations fuse_ctl_abort_ops = {
 	.open = nonseekable_open,
-	.write = fuse_conn_abort_write,
+	.write_iter = fuse_conn_abort_write,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_ctl_waiting_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_waiting_read,
+	.read_iter = fuse_conn_waiting_read_iter,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_max_background_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_max_background_read,
-	.write = fuse_conn_max_background_write,
+	.read_iter = fuse_conn_max_background_read_iter,
+	.write_iter = fuse_conn_max_background_write_iter,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_congestion_threshold_ops = {
 	.open = nonseekable_open,
 	.read = fuse_conn_congestion_threshold_read,
-	.write = fuse_conn_congestion_threshold_write,
+	.write_iter = fuse_conn_congestion_threshold_write_iter,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 050/437] staging: convert drivers to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (48 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 049/437] fuse: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 051/437] Bluetooth: convert " Jens Axboe
                   ` (387 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/staging/axis-fifo/axis-fifo.c | 22 ++++++++++------------
 drivers/staging/pi433/pi433_if.c      | 13 +++++++------
 drivers/staging/vme_user/vme_user.c   |  6 ++++--
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index c51818c56dd2..ba8e08be0daf 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -345,10 +345,10 @@ static void reset_ip_core(struct axis_fifo *fifo)
  * Returns the number of bytes read from the device or negative error code
  *	on failure.
  */
-static ssize_t axis_fifo_read(struct file *f, char __user *buf,
-			      size_t len, loff_t *off)
+static ssize_t axis_fifo_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct axis_fifo *fifo = (struct axis_fifo *)f->private_data;
+	struct axis_fifo *fifo = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	size_t bytes_available;
 	unsigned int words_available;
 	unsigned int copied;
@@ -431,8 +431,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
 					      XLLF_RDFD_OFFSET);
 		}
 
-		if (copy_to_user(buf + copied * sizeof(u32), tmp_buf,
-				 copy * sizeof(u32))) {
+		if (!copy_to_iter_full(tmp_buf, copy * sizeof(u32), to)) {
 			reset_ip_core(fifo);
 			ret = -EFAULT;
 			goto end_unlock;
@@ -465,10 +464,10 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
  * Returns the number of bytes written to the device or negative error code
  *	on failure.
  */
-static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
-			       size_t len, loff_t *off)
+static ssize_t axis_fifo_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct axis_fifo *fifo = (struct axis_fifo *)f->private_data;
+	struct axis_fifo *fifo = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	unsigned int words_to_write;
 	unsigned int copied;
 	unsigned int copy;
@@ -540,8 +539,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
 	while (words_to_write > 0) {
 		copy = min(words_to_write, WRITE_BUF_SIZE);
 
-		if (copy_from_user(tmp_buf, buf + copied * sizeof(u32),
-				   copy * sizeof(u32))) {
+		if (!copy_from_iter_full(tmp_buf, copy * sizeof(u32), from)) {
 			reset_ip_core(fifo);
 			ret = -EFAULT;
 			goto end_unlock;
@@ -712,8 +710,8 @@ static const struct file_operations fops = {
 	.owner = THIS_MODULE,
 	.open = axis_fifo_open,
 	.release = axis_fifo_close,
-	.read = axis_fifo_read,
-	.write = axis_fifo_write
+	.read_iter = axis_fifo_read,
+	.write_iter = axis_fifo_write,
 };
 
 /* read named property from the device tree */
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b6c4917d515e..f6563e3a7603 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -765,11 +765,11 @@ static int pi433_tx_thread(void *data)
 
 /*-------------------------------------------------------------------------*/
 
-static ssize_t
-pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
+static ssize_t pi433_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct pi433_instance	*instance;
 	struct pi433_device	*device;
+	size_t			size = iov_iter_count(to);
 	int			bytes_received;
 	ssize_t			retval;
 
@@ -777,7 +777,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
 	if (size > MAX_MSG_SIZE)
 		return -EMSGSIZE;
 
-	instance = filp->private_data;
+	instance = iocb->ki_filp->private_data;
 	device = instance->device;
 
 	/* just one read request at a time */
@@ -802,7 +802,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
 
 	/* if read was successful copy to user space*/
 	if (bytes_received > 0) {
-		retval = copy_to_user(buf, device->rx_buffer, bytes_received);
+		retval = !copy_to_iter_full(device->rx_buffer, bytes_received, to);
 		if (retval)
 			return -EFAULT;
 	}
@@ -883,6 +883,7 @@ pi433_write(struct file *filp, const char __user *buf,
 	mutex_unlock(&device->tx_fifo_lock);
 	return -EAGAIN;
 }
+FOPS_WRITE_ITER_HELPER(pi433_write);
 
 static long pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
@@ -1094,8 +1095,8 @@ static const struct file_operations pi433_fops = {
 	 * gets more complete API coverage.  It'll simplify things
 	 * too, except for the locking.
 	 */
-	.write =	pi433_write,
-	.read =		pi433_read,
+	.write_iter =	pi433_write_iter,
+	.read_iter =	pi433_read,
 	.unlocked_ioctl = pi433_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open =		pi433_open,
diff --git a/drivers/staging/vme_user/vme_user.c b/drivers/staging/vme_user/vme_user.c
index 36183f923768..4ca38d0af25a 100644
--- a/drivers/staging/vme_user/vme_user.c
+++ b/drivers/staging/vme_user/vme_user.c
@@ -216,6 +216,7 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(vme_user_read);
 
 static ssize_t vme_user_write(struct file *file, const char __user *buf,
 			      size_t count, loff_t *ppos)
@@ -259,6 +260,7 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
 
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(vme_user_write);
 
 static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
 {
@@ -492,8 +494,8 @@ static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
 }
 
 static const struct file_operations vme_user_fops = {
-	.read = vme_user_read,
-	.write = vme_user_write,
+	.read_iter = vme_user_read_iter,
+	.write_iter = vme_user_write_iter,
 	.llseek = vme_user_llseek,
 	.unlocked_ioctl = vme_user_unlocked_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 051/437] Bluetooth: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (49 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 050/437] staging: convert drivers " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 052/437] net: mac80211: " Jens Axboe
                   ` (386 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/bluetooth/6lowpan.c     |  12 ++-
 net/bluetooth/hci_debugfs.c | 150 ++++++++++++++++--------------------
 net/bluetooth/selftest.c    |   9 +--
 net/bluetooth/smp.c         |   9 +--
 4 files changed, 80 insertions(+), 100 deletions(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 27520a8a486f..74e8ce90f12b 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -1079,19 +1079,17 @@ static int lowpan_enable_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(lowpan_enable_fops, lowpan_enable_get,
 			 lowpan_enable_set, "%llu\n");
 
-static ssize_t lowpan_control_write(struct file *fp,
-				    const char __user *user_buffer,
-				    size_t count,
-				    loff_t *position)
+static ssize_t lowpan_control_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[32];
+	size_t count = iov_iter_count(from);
 	size_t buf_size = min(count, sizeof(buf) - 1);
 	int ret;
 	bdaddr_t addr;
 	u8 addr_type;
 	struct l2cap_conn *conn = NULL;
 
-	if (copy_from_user(buf, user_buffer, buf_size))
+	if (!copy_to_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1173,8 +1171,8 @@ static int lowpan_control_open(struct inode *inode, struct file *file)
 
 static const struct file_operations lowpan_control_fops = {
 	.open		= lowpan_control_open,
-	.read		= seq_read,
-	.write		= lowpan_control_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= lowpan_control_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index ce3ff2fa72e5..736c265e3ddf 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -32,31 +32,28 @@
 #include "hci_debugfs.h"
 
 #define DEFINE_QUIRK_ATTRIBUTE(__name, __quirk)				      \
-static ssize_t __name ## _read(struct file *file,			      \
-				char __user *user_buf,			      \
-				size_t count, loff_t *ppos)		      \
+static ssize_t __name ## _read(struct kiocb *iocb, struct iov_iter *to)	      \
 {									      \
-	struct hci_dev *hdev = file->private_data;			      \
+	struct hci_dev *hdev = iocb->ki_filp->private_data;		      \
 	char buf[3];							      \
 									      \
 	buf[0] = test_bit(__quirk, &hdev->quirks) ? 'Y' : 'N';		      \
 	buf[1] = '\n';							      \
 	buf[2] = '\0';							      \
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);	      \
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);	      \
 }									      \
 									      \
-static ssize_t __name ## _write(struct file *file,			      \
-				 const char __user *user_buf,		      \
-				 size_t count, loff_t *ppos)		      \
+static ssize_t __name ## _write(struct kiocb *iocb, struct iov_iter *from)    \
 {									      \
-	struct hci_dev *hdev = file->private_data;			      \
+	struct hci_dev *hdev = iocb->ki_filp->private_data;		      \
+	size_t count = iov_iter_count(from);				      \
 	bool enable;							      \
 	int err;							      \
 									      \
 	if (test_bit(HCI_UP, &hdev->flags))				      \
 		return -EBUSY;						      \
 									      \
-	err = kstrtobool_from_user(user_buf, count, &enable);		      \
+	err = kstrtobool_from_iter(from, count, &enable);		      \
 	if (err)							      \
 		return err;						      \
 									      \
@@ -70,8 +67,8 @@ static ssize_t __name ## _write(struct file *file,			      \
 									      \
 static const struct file_operations __name ## _fops = {			      \
 	.open		= simple_open,					      \
-	.read		= __name ## _read,				      \
-	.write		= __name ## _write,				      \
+	.read_iter	= __name ## _read,				      \
+	.write_iter	= __name ## _write,				      \
 	.llseek		= default_llseek,				      \
 }									      \
 
@@ -274,39 +271,37 @@ static int conn_info_max_age_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(conn_info_max_age_fops, conn_info_max_age_get,
 			  conn_info_max_age_set, "%llu\n");
 
-static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t use_debug_keys_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_USE_DEBUG_KEYS) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static const struct file_operations use_debug_keys_fops = {
 	.open		= simple_open,
-	.read		= use_debug_keys_read,
+	.read_iter	= use_debug_keys_read,
 	.llseek		= default_llseek,
 };
 
-static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t sc_only_mode_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_SC_ONLY) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static const struct file_operations sc_only_mode_fops = {
 	.open		= simple_open,
-	.read		= sc_only_mode_read,
+	.read_iter	= sc_only_mode_read,
 	.llseek		= default_llseek,
 };
 
@@ -428,21 +423,20 @@ static int voice_setting_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(voice_setting_fops, voice_setting_get,
 			  NULL, "0x%4.4llx\n");
 
-static ssize_t ssp_debug_mode_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t ssp_debug_mode_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hdev->ssp_debug_mode ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static const struct file_operations ssp_debug_mode_fops = {
 	.open		= simple_open,
-	.read		= ssp_debug_mode_read,
+	.read_iter	= ssp_debug_mode_read,
 	.llseek		= default_llseek,
 };
 
@@ -500,28 +494,25 @@ static int auto_accept_delay_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
 			  auto_accept_delay_set, "%llu\n");
 
-static ssize_t force_bredr_smp_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t force_bredr_smp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t force_bredr_smp_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t force_bredr_smp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -534,8 +525,8 @@ static ssize_t force_bredr_smp_write(struct file *file,
 
 static const struct file_operations force_bredr_smp_fops = {
 	.open		= simple_open,
-	.read		= force_bredr_smp_read,
-	.write		= force_bredr_smp_write,
+	.read_iter	= force_bredr_smp_read,
+	.write_iter	= force_bredr_smp_write,
 	.llseek		= default_llseek,
 };
 
@@ -745,31 +736,29 @@ static int static_address_show(struct seq_file *f, void *p)
 
 DEFINE_SHOW_ATTRIBUTE(static_address);
 
-static ssize_t force_static_address_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t force_static_address_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t force_static_address_write(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t force_static_address_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
 	if (hdev_is_powered(hdev))
 		return -EBUSY;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -783,8 +772,8 @@ static ssize_t force_static_address_write(struct file *file,
 
 static const struct file_operations force_static_address_fops = {
 	.open		= simple_open,
-	.read		= force_static_address_read,
-	.write		= force_static_address_write,
+	.read_iter	= force_static_address_read,
+	.write_iter	= force_static_address_write,
 	.llseek		= default_llseek,
 };
 
@@ -1147,29 +1136,26 @@ DEFINE_DEBUGFS_ATTRIBUTE(auth_payload_timeout_fops,
 			  auth_payload_timeout_get,
 			  auth_payload_timeout_set, "%llu\n");
 
-static ssize_t force_no_mitm_read(struct file *file,
-				  char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t force_no_mitm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_FORCE_NO_MITM) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t force_no_mitm_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t force_no_mitm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size = min(count, (sizeof(buf) - 1));
 	bool enable;
 
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1186,8 +1172,8 @@ static ssize_t force_no_mitm_write(struct file *file,
 
 static const struct file_operations force_no_mitm_fops = {
 	.open		= simple_open,
-	.read		= force_no_mitm_read,
-	.write		= force_no_mitm_write,
+	.read_iter	= force_no_mitm_read,
+	.write_iter	= force_no_mitm_write,
 	.llseek		= default_llseek,
 };
 
@@ -1273,22 +1259,21 @@ void hci_debugfs_create_conn(struct hci_conn *conn)
 	conn->debugfs = debugfs_create_dir(name, hdev->debugfs);
 }
 
-static ssize_t dut_mode_read(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t dut_mode_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_DUT_MODE) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t dut_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 	bool enable;
 	int err;
@@ -1296,7 +1281,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
 	if (!test_bit(HCI_UP, &hdev->flags))
 		return -ENETDOWN;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -1324,31 +1309,30 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
 
 static const struct file_operations dut_mode_fops = {
 	.open		= simple_open,
-	.read		= dut_mode_read,
-	.write		= dut_mode_write,
+	.read_iter	= dut_mode_read,
+	.write_iter	= dut_mode_write,
 	.llseek		= default_llseek,
 };
 
-static ssize_t vendor_diag_read(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t vendor_diag_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = hci_dev_test_flag(hdev, HCI_VENDOR_DIAG) ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t vendor_diag_write(struct file *file, const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t vendor_diag_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hci_dev *hdev = file->private_data;
+	struct hci_dev *hdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -1380,8 +1364,8 @@ static ssize_t vendor_diag_write(struct file *file, const char __user *user_buf,
 
 static const struct file_operations vendor_diag_fops = {
 	.open		= simple_open,
-	.read		= vendor_diag_read,
-	.write		= vendor_diag_write,
+	.read_iter	= vendor_diag_read,
+	.write_iter	= vendor_diag_write,
 	.llseek		= default_llseek,
 };
 
diff --git a/net/bluetooth/selftest.c b/net/bluetooth/selftest.c
index f49604d44b87..e8f3e5d63c01 100644
--- a/net/bluetooth/selftest.c
+++ b/net/bluetooth/selftest.c
@@ -183,16 +183,15 @@ static int __init test_ecdh_sample(struct crypto_kpp *tfm, const u8 priv_a[32],
 
 static char test_ecdh_buffer[32];
 
-static ssize_t test_ecdh_read(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t test_ecdh_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(user_buf, count, ppos, test_ecdh_buffer,
-				       strlen(test_ecdh_buffer));
+	return simple_copy_to_iter(test_ecdh_buffer, &iocb->ki_pos,
+				   strlen(test_ecdh_buffer), to);
 }
 
 static const struct file_operations test_ecdh_fops = {
 	.open		= simple_open,
-	.read		= test_ecdh_read,
+	.read_iter	= test_ecdh_read,
 	.llseek		= default_llseek,
 };
 
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 1e7ea3a4b7ef..fcd35201712b 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -3729,16 +3729,15 @@ static int __init test_h6(struct crypto_shash *tfm_cmac)
 
 static char test_smp_buffer[32];
 
-static ssize_t test_smp_read(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t test_smp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(user_buf, count, ppos, test_smp_buffer,
-				       strlen(test_smp_buffer));
+	return simple_copy_to_iter(test_smp_buffer, &iocb->ki_pos,
+				   strlen(test_smp_buffer), to);
 }
 
 static const struct file_operations test_smp_fops = {
 	.open		= simple_open,
-	.read		= test_smp_read,
+	.read_iter	= test_smp_read,
 	.llseek		= default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 052/437] net: mac80211: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (50 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 051/437] Bluetooth: convert " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 053/437] net: 6lowpan: convert debugfs " Jens Axboe
                   ` (385 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/net/cfg80211.h                     |  24 +--
 net/mac80211/debugfs.c                     | 185 +++++++++------------
 net/mac80211/debugfs.h                     |   4 +-
 net/mac80211/debugfs_key.c                 |  81 ++++-----
 net/mac80211/debugfs_netdev.c              | 126 ++++++--------
 net/mac80211/debugfs_sta.c                 | 146 +++++++---------
 net/mac80211/rate.c                        |  10 +-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  11 +-
 net/wireless/debugfs.c                     |  36 ++--
 9 files changed, 260 insertions(+), 363 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1e09329acc42..4c33df652196 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -9469,21 +9469,17 @@ void cfg80211_schedule_channels_check(struct wireless_dev *wdev);
 /**
  * wiphy_locked_debugfs_read - do a locked read in debugfs
  * @wiphy: the wiphy to use
- * @file: the file being read
+ * @iocb: metadata for the IO
  * @buf: the buffer to fill and then read from
  * @bufsize: size of the buffer
- * @userbuf: the user buffer to copy to
- * @count: read count
- * @ppos: read position
+ * @to: the user buffer to copy to
  * @handler: the read handler to call (under wiphy lock)
  * @data: additional data to pass to the read handler
  */
-ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
+ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct kiocb *iocb,
 				  char *buf, size_t bufsize,
-				  char __user *userbuf, size_t count,
-				  loff_t *ppos,
+				  struct iov_iter *to,
 				  ssize_t (*handler)(struct wiphy *wiphy,
-						     struct file *file,
 						     char *buf,
 						     size_t bufsize,
 						     void *data),
@@ -9492,21 +9488,19 @@ ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
 /**
  * wiphy_locked_debugfs_write - do a locked write in debugfs
  * @wiphy: the wiphy to use
- * @file: the file being written to
+ * @iocb: metadata for the IO
  * @buf: the buffer to copy the user data to
  * @bufsize: size of the buffer
- * @userbuf: the user buffer to copy from
- * @count: read count
+ * @from: the user buffer to copy from
  * @handler: the write handler to call (under wiphy lock)
  * @data: additional data to pass to the write handler
  */
-ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file,
+ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct kiocb *iocb,
 				   char *buf, size_t bufsize,
-				   const char __user *userbuf, size_t count,
+				   struct iov_iter *from,
 				   ssize_t (*handler)(struct wiphy *wiphy,
-						      struct file *file,
 						      char *buf,
-						      size_t count,
+						      size_t bufsize,
 						      void *data),
 				   void *data);
 #endif
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 2f68e92a7404..6d83b91373ce 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -17,8 +17,8 @@
 
 #define DEBUGFS_FORMAT_BUFFER_SIZE 100
 
-int mac80211_format_buffer(char __user *userbuf, size_t count,
-				  loff_t *ppos, char *fmt, ...)
+int mac80211_format_buffer(struct kiocb *iocb, struct iov_iter *to,
+			   char *fmt, ...)
 {
 	va_list args;
 	char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
@@ -28,22 +28,20 @@ int mac80211_format_buffer(char __user *userbuf, size_t count,
 	res = vscnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 #define DEBUGFS_READONLY_FILE_FN(name, fmt, value...)			\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct ieee80211_local *local = file->private_data;		\
+	struct ieee80211_local *local = iocb->ki_filp->private_data;	\
 									\
-	return mac80211_format_buffer(userbuf, count, ppos, 		\
-				      fmt "\n", ##value);		\
-}
+	return mac80211_format_buffer(iocb, to, fmt "\n", ##value);	\
+}									\
 
 #define DEBUGFS_READONLY_FILE_OPS(name)			\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
@@ -72,12 +70,9 @@ DEBUGFS_READONLY_FILE(wep_iv, "%#08x",
 DEBUGFS_READONLY_FILE(rate_ctrl_alg, "%s",
 	local->rate_ctrl ? local->rate_ctrl->ops->name : "hw/driver");
 
-static ssize_t aqm_read(struct file *file,
-			char __user *user_buf,
-			size_t count,
-			loff_t *ppos)
+static ssize_t aqm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	struct fq *fq = &local->fq;
 	char buf[200];
 	int len = 0;
@@ -109,22 +104,19 @@ static ssize_t aqm_read(struct file *file,
 	rcu_read_unlock();
 	spin_unlock_bh(&local->fq.lock);
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t aqm_write(struct file *file,
-			 const char __user *user_buf,
-			 size_t count,
-			 loff_t *ppos)
+static ssize_t aqm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[100];
 
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -143,17 +135,15 @@ static ssize_t aqm_write(struct file *file,
 }
 
 static const struct file_operations aqm_ops = {
-	.write = aqm_write,
-	.read = aqm_read,
+	.write_iter = aqm_write,
+	.read_iter = aqm_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t airtime_flags_read(struct file *file,
-				  char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t airtime_flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	char buf[128] = {}, *pos, *end;
 
 	pos = buf;
@@ -166,21 +156,19 @@ static ssize_t airtime_flags_read(struct file *file,
 		pos += scnprintf(pos, end - pos, "AIRTIME_RX\t(%lx)\n",
 				 AIRTIME_USE_RX);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf,
-				       strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
-static ssize_t airtime_flags_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t airtime_flags_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[16];
 
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -195,17 +183,15 @@ static ssize_t airtime_flags_write(struct file *file,
 }
 
 static const struct file_operations airtime_flags_ops = {
-	.write = airtime_flags_write,
-	.read = airtime_flags_read,
+	.write_iter = airtime_flags_write,
+	.read_iter = airtime_flags_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t aql_pending_read(struct file *file,
-				char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t aql_pending_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	char buf[400];
 	int len = 0;
 
@@ -221,22 +207,18 @@ static ssize_t aql_pending_read(struct file *file,
 			atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_BE]),
 			atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_BK]),
 			atomic_read(&local->aql_total_pending_airtime));
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, len);
+	return simple_copy_to_iter( buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations aql_pending_ops = {
-	.read = aql_pending_read,
+	.read_iter = aql_pending_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t aql_txq_limit_read(struct file *file,
-				  char __user *user_buf,
-				  size_t count,
-				  loff_t *ppos)
+static ssize_t aql_txq_limit_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	char buf[400];
 	int len = 0;
 
@@ -254,24 +236,21 @@ static ssize_t aql_txq_limit_read(struct file *file,
 			local->aql_txq_limit_high[IEEE80211_AC_BE],
 			local->aql_txq_limit_low[IEEE80211_AC_BK],
 			local->aql_txq_limit_high[IEEE80211_AC_BK]);
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t aql_txq_limit_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count,
-				   loff_t *ppos)
+static ssize_t aql_txq_limit_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	char buf[100];
 	u32 ac, q_limit_low, q_limit_high, q_limit_low_old, q_limit_high_old;
 	struct sta_info *sta;
+	size_t count = iov_iter_count(from);
 
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -306,14 +285,13 @@ static ssize_t aql_txq_limit_write(struct file *file,
 }
 
 static const struct file_operations aql_txq_limit_ops = {
-	.write = aql_txq_limit_write,
-	.read = aql_txq_limit_read,
+	.write_iter = aql_txq_limit_write,
+	.read_iter = aql_txq_limit_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t aql_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[3];
 	int len;
@@ -321,20 +299,20 @@ static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
 	len = scnprintf(buf, sizeof(buf), "%d\n",
 			!static_key_false(&aql_disable.key));
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t aql_enable_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	bool aql_disabled = static_key_false(&aql_disable.key);
+	size_t count = iov_iter_count(from);
 	char buf[3];
 	size_t len;
 
 	if (count > sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[sizeof(buf) - 1] = '\0';
@@ -356,39 +334,33 @@ static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations aql_enable_ops = {
-	.write = aql_enable_write,
-	.read = aql_enable_read,
+	.write_iter = aql_enable_write,
+	.read_iter = aql_enable_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t force_tx_status_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count,
-				    loff_t *ppos)
+static ssize_t force_tx_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	char buf[3];
 	int len = 0;
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", (int)local->force_tx_status);
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t force_tx_status_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count,
-				     loff_t *ppos)
+static ssize_t force_tx_status_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[3];
 
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -407,17 +379,17 @@ static ssize_t force_tx_status_write(struct file *file,
 }
 
 static const struct file_operations force_tx_status_ops = {
-	.write = force_tx_status_write,
-	.read = force_tx_status_read,
+	.write_iter = force_tx_status_write,
+	.read_iter = force_tx_status_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 #ifdef CONFIG_PM
-static ssize_t reset_write(struct file *file, const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	rtnl_lock();
@@ -435,7 +407,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations reset_ops = {
-	.write = reset_write,
+	.write_iter = reset_write,
 	.open = simple_open,
 	.llseek = noop_llseek,
 };
@@ -502,10 +474,9 @@ static const char *hw_flag_names[] = {
 #undef FLAG
 };
 
-static ssize_t hwflags_read(struct file *file, char __user *user_buf,
-			    size_t count, loff_t *ppos)
+static ssize_t hwflags_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	size_t bufsz = 30 * NUM_IEEE80211_HW_FLAGS;
 	char *buf = kzalloc(bufsz, GFP_KERNEL);
 	char *pos = buf, *end = buf + bufsz - 1;
@@ -526,15 +497,14 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
 					 hw_flag_names[i]);
 	}
 
-	rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	rv = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 	return rv;
 }
 
-static ssize_t misc_read(struct file *file, char __user *user_buf,
-			 size_t count, loff_t *ppos)
+static ssize_t misc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	/* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
 	size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
 	char *buf;
@@ -558,15 +528,14 @@ static ssize_t misc_read(struct file *file, char __user *user_buf,
 				 i, ln);
 	}
 
-	rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	rv = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 	return rv;
 }
 
-static ssize_t queues_read(struct file *file, char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t queues_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_local *local = file->private_data;
+	struct ieee80211_local *local = iocb->ki_filp->private_data;
 	unsigned long flags;
 	char buf[IEEE80211_MAX_QUEUES * 20];
 	int q, res = 0;
@@ -578,7 +547,7 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
 				skb_queue_len(&local->pending[q]));
 	spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 DEBUGFS_READONLY_FILE_OPS(hwflags);
@@ -588,8 +557,7 @@ DEBUGFS_READONLY_FILE_OPS(misc);
 /* statistics stuff */
 
 static ssize_t format_devstat_counter(struct ieee80211_local *local,
-	char __user *userbuf,
-	size_t count, loff_t *ppos,
+	struct kiocb *iocb, struct iov_iter *to,
 	int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
 			  int buflen))
 {
@@ -603,7 +571,7 @@ static ssize_t format_devstat_counter(struct ieee80211_local *local,
 	if (res)
 		return res;
 	res = printvalue(&stats, buf, sizeof(buf));
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 #define DEBUGFS_DEVSTATS_FILE(name)					\
@@ -612,19 +580,16 @@ static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
 {									\
 	return scnprintf(buf, buflen, "%u\n", stats->name);		\
 }									\
-static ssize_t stats_ ##name## _read(struct file *file,			\
-				     char __user *userbuf,		\
-				     size_t count, loff_t *ppos)	\
+static ssize_t stats_ ##name## _read(struct kiocb *iocb,		\
+				     struct iov_iter *to)		\
 {									\
-	return format_devstat_counter(file->private_data,		\
-				      userbuf,				\
-				      count,				\
-				      ppos,				\
+	return format_devstat_counter(iocb->ki_filp->private_data,	\
+				      iocb, to,				\
 				      print_devstats_##name);		\
 }									\
 									\
 static const struct file_operations stats_ ##name## _ops = {		\
-	.read = stats_ ##name## _read,					\
+	.read_iter = stats_ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
diff --git a/net/mac80211/debugfs.h b/net/mac80211/debugfs.h
index d2c424787463..786f08f19713 100644
--- a/net/mac80211/debugfs.h
+++ b/net/mac80211/debugfs.h
@@ -6,8 +6,8 @@
 
 #ifdef CONFIG_MAC80211_DEBUGFS
 void debugfs_hw_add(struct ieee80211_local *local);
-int __printf(4, 5) mac80211_format_buffer(char __user *userbuf, size_t count,
-					  loff_t *ppos, char *fmt, ...);
+int __printf(3, 4) mac80211_format_buffer(struct kiocb *iocb,
+					  struct iov_iter *to, char *fmt, ...);
 #else
 static inline void debugfs_hw_add(struct ieee80211_local *local)
 {
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 7e54da508765..decf19878e79 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -15,27 +15,27 @@
 #include "debugfs_key.h"
 
 #define KEY_READ(name, prop, format_string)				\
-static ssize_t key_##name##_read(struct file *file,			\
-				 char __user *userbuf,			\
-				 size_t count, loff_t *ppos)		\
+static ssize_t key_##name##_read(struct kiocb *iocb,			\
+				 struct iov_iter *to)			\
 {									\
-	struct ieee80211_key *key = file->private_data;			\
-	return mac80211_format_buffer(userbuf, count, ppos, 		\
-				      format_string, key->prop);	\
-}
+	struct ieee80211_key *key = iocb->ki_filp->private_data;	\
+	return mac80211_format_buffer(iocb, to, format_string,		\
+				      key->prop);			\
+}									\
+
 #define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n")
 
 #define KEY_OPS(name)							\
 static const struct file_operations key_ ##name## _ops = {		\
-	.read = key_##name##_read,					\
+	.read_iter = key_##name##_read,					\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
 
 #define KEY_OPS_W(name)							\
 static const struct file_operations key_ ##name## _ops = {		\
-	.read = key_##name##_read,					\
-	.write = key_##name##_write,					\
+	.read_iter = key_##name##_read,					\
+	.write_iter = key_##name##_write,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -50,7 +50,7 @@ static const struct file_operations key_ ##name## _ops = {		\
 
 #define KEY_CONF_OPS(name)						\
 static const struct file_operations key_ ##name## _ops = {		\
-	.read = key_conf_##name##_read,					\
+	.read_iter = key_conf_##name##_read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -66,24 +66,22 @@ KEY_FILE(flags, X);
 KEY_READ(ifindex, sdata->name, "%s\n");
 KEY_OPS(ifindex);
 
-static ssize_t key_algorithm_read(struct file *file,
-				  char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t key_algorithm_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[15];
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	u32 c = key->conf.cipher;
 
 	sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
 		c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 KEY_OPS(algorithm);
 
-static ssize_t key_tx_spec_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t key_tx_spec_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u64 pn;
 	int ret;
 
@@ -102,7 +100,7 @@ static ssize_t key_tx_spec_write(struct file *file, const char __user *userbuf,
 	case WLAN_CIPHER_SUITE_BIP_GMAC_256:
 	case WLAN_CIPHER_SUITE_GCMP:
 	case WLAN_CIPHER_SUITE_GCMP_256:
-		ret = kstrtou64_from_user(userbuf, count, 16, &pn);
+		ret = kstrtou64_from_iter(from, count, 16, &pn);
 		if (ret)
 			return ret;
 		/* PN is a 48-bit counter */
@@ -115,13 +113,12 @@ static ssize_t key_tx_spec_write(struct file *file, const char __user *userbuf,
 	}
 }
 
-static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t key_tx_spec_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 pn;
 	char buf[20];
 	int len;
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 
 	switch (key->conf.cipher) {
 	case WLAN_CIPHER_SUITE_WEP40:
@@ -150,14 +147,13 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
 	default:
 		return 0;
 	}
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 KEY_OPS_W(tx_spec);
 
-static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t key_rx_spec_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	char buf[14*IEEE80211_NUM_TIDS+1], *p = buf;
 	int i, len;
 	const u8 *rpn;
@@ -218,14 +214,13 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
 	default:
 		return 0;
 	}
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 KEY_OPS(rx_spec);
 
-static ssize_t key_replays_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t key_replays_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	char buf[20];
 	int len;
 
@@ -251,14 +246,13 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
 	default:
 		return 0;
 	}
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 KEY_OPS(replays);
 
-static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t key_icverrors_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	char buf[20];
 	int len;
 
@@ -276,14 +270,13 @@ static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
 	default:
 		return 0;
 	}
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 KEY_OPS(icverrors);
 
-static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t key_mic_failures_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	char buf[20];
 	int len;
 
@@ -291,15 +284,13 @@ static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf,
 		return -EINVAL;
 
 	len = scnprintf(buf, sizeof(buf), "%u\n", key->u.tkip.mic_failures);
-
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 KEY_OPS(mic_failures);
 
-static ssize_t key_key_read(struct file *file, char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t key_key_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ieee80211_key *key = file->private_data;
+	struct ieee80211_key *key = iocb->ki_filp->private_data;
 	int i, bufsize = 2 * key->conf.keylen + 2;
 	char *buf = kmalloc(bufsize, GFP_KERNEL);
 	char *p = buf;
@@ -311,7 +302,7 @@ static ssize_t key_key_read(struct file *file, char __user *userbuf,
 	for (i = 0; i < key->conf.keylen; i++)
 		p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]);
 	p += scnprintf(p, bufsize+buf-p, "\n");
-	res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	res = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return res;
 }
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 68596ef78b15..41f1072334c3 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -28,9 +28,7 @@ struct ieee80211_if_read_sdata_data {
 };
 
 static ssize_t ieee80211_if_read_sdata_handler(struct wiphy *wiphy,
-					       struct file *file,
-					       char *buf,
-					       size_t bufsize,
+					       char *buf, size_t bufsize,
 					       void *data)
 {
 	struct ieee80211_if_read_sdata_data *d = data;
@@ -39,12 +37,11 @@ static ssize_t ieee80211_if_read_sdata_handler(struct wiphy *wiphy,
 }
 
 static ssize_t ieee80211_if_read_sdata(
-	struct file *file,
-	char __user *userbuf,
-	size_t count, loff_t *ppos,
+	struct kiocb *iocb,
+	struct iov_iter *to,
 	ssize_t (*format)(const struct ieee80211_sub_if_data *sdata, char *, int))
 {
-	struct ieee80211_sub_if_data *sdata = file->private_data;
+	struct ieee80211_sub_if_data *sdata = iocb->ki_filp->private_data;
 	struct ieee80211_if_read_sdata_data data = {
 		.format = format,
 		.sdata = sdata,
@@ -52,44 +49,39 @@ static ssize_t ieee80211_if_read_sdata(
 	char buf[200];
 
 	return wiphy_locked_debugfs_read(sdata->local->hw.wiphy,
-					 file, buf, sizeof(buf),
-					 userbuf, count, ppos,
+					 iocb, buf, sizeof(buf), to,
 					 ieee80211_if_read_sdata_handler,
 					 &data);
 }
 
 struct ieee80211_if_write_sdata_data {
-	ssize_t (*write)(struct ieee80211_sub_if_data *, const char *, int);
+	ssize_t (*write)(struct ieee80211_sub_if_data *, char *, size_t);
 	struct ieee80211_sub_if_data *sdata;
 };
 
 static ssize_t ieee80211_if_write_sdata_handler(struct wiphy *wiphy,
-						struct file *file,
-						char *buf,
-						size_t count,
+						char *buf, size_t bufsize,
 						void *data)
 {
 	struct ieee80211_if_write_sdata_data *d = data;
 
-	return d->write(d->sdata, buf, count);
+	return d->write(d->sdata, buf, bufsize);
 }
 
 static ssize_t ieee80211_if_write_sdata(
-	struct file *file,
-	const char __user *userbuf,
-	size_t count, loff_t *ppos,
-	ssize_t (*write)(struct ieee80211_sub_if_data *sdata, const char *, int))
+	struct kiocb *iocb,
+	struct iov_iter *from,
+	ssize_t (*write)(struct ieee80211_sub_if_data *sdata, char *, size_t))
 {
-	struct ieee80211_sub_if_data *sdata = file->private_data;
+	struct ieee80211_sub_if_data *sdata = iocb->ki_filp->private_data;
 	struct ieee80211_if_write_sdata_data data = {
 		.write = write,
 		.sdata = sdata,
 	};
 	char buf[64];
 
-	return wiphy_locked_debugfs_write(sdata->local->hw.wiphy,
-					  file, buf, sizeof(buf),
-					  userbuf, count,
+	return wiphy_locked_debugfs_write(sdata->local->hw.wiphy, iocb,
+					  buf, sizeof(buf), from,
 					  ieee80211_if_write_sdata_handler,
 					  &data);
 }
@@ -100,7 +92,6 @@ struct ieee80211_if_read_link_data {
 };
 
 static ssize_t ieee80211_if_read_link_handler(struct wiphy *wiphy,
-					      struct file *file,
 					      char *buf,
 					      size_t bufsize,
 					      void *data)
@@ -111,12 +102,11 @@ static ssize_t ieee80211_if_read_link_handler(struct wiphy *wiphy,
 }
 
 static ssize_t ieee80211_if_read_link(
-	struct file *file,
-	char __user *userbuf,
-	size_t count, loff_t *ppos,
+	struct kiocb *iocb,
+	struct iov_iter *to,
 	ssize_t (*format)(const struct ieee80211_link_data *link, char *, int))
 {
-	struct ieee80211_link_data *link = file->private_data;
+	struct ieee80211_link_data *link = iocb->ki_filp->private_data;
 	struct ieee80211_if_read_link_data data = {
 		.format = format,
 		.link = link,
@@ -124,8 +114,7 @@ static ssize_t ieee80211_if_read_link(
 	char buf[200];
 
 	return wiphy_locked_debugfs_read(link->sdata->local->hw.wiphy,
-					 file, buf, sizeof(buf),
-					 userbuf, count, ppos,
+					 iocb, buf, sizeof(buf), to,
 					 ieee80211_if_read_link_handler,
 					 &data);
 }
@@ -136,23 +125,19 @@ struct ieee80211_if_write_link_data {
 };
 
 static ssize_t ieee80211_if_write_link_handler(struct wiphy *wiphy,
-					       struct file *file,
-					       char *buf,
-					       size_t count,
+					       char *buf, size_t bufsize,
 					       void *data)
 {
 	struct ieee80211_if_write_sdata_data *d = data;
 
-	return d->write(d->sdata, buf, count);
+	return d->write(d->sdata, buf, bufsize);
 }
 
-static ssize_t ieee80211_if_write_link(
-	struct file *file,
-	const char __user *userbuf,
-	size_t count, loff_t *ppos,
+static ssize_t ieee80211_if_write_link(struct kiocb *iocb,
+	struct iov_iter *from,
 	ssize_t (*write)(struct ieee80211_link_data *link, const char *, int))
 {
-	struct ieee80211_link_data *link = file->private_data;
+	struct ieee80211_link_data *link = iocb->ki_filp->private_data;
 	struct ieee80211_if_write_link_data data = {
 		.write = write,
 		.link = link,
@@ -160,8 +145,7 @@ static ssize_t ieee80211_if_write_link(
 	char buf[64];
 
 	return wiphy_locked_debugfs_write(link->sdata->local->hw.wiphy,
-					  file, buf, sizeof(buf),
-					  userbuf, count,
+					  iocb, buf, sizeof(buf), from,
 					  ieee80211_if_write_link_handler,
 					  &data);
 }
@@ -222,31 +206,27 @@ static ssize_t ieee80211_if_fmt_##name(					\
 
 #define _IEEE80211_IF_FILE_OPS(name, _read, _write)			\
 static const struct file_operations name##_ops = {			\
-	.read = (_read),						\
-	.write = (_write),						\
+	.read_iter = (_read),						\
+	.write_iter = (_write),						\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
 
 #define _IEEE80211_IF_FILE_R_FN(name)					\
-static ssize_t ieee80211_if_read_##name(struct file *file,		\
-					char __user *userbuf,		\
-					size_t count, loff_t *ppos)	\
+static ssize_t ieee80211_if_read_##name(struct kiocb *iocb,		\
+					struct iov_iter *to)		\
 {									\
-	return ieee80211_if_read_sdata(file,				\
-				       userbuf, count, ppos,		\
-				       ieee80211_if_fmt_##name);	\
-}
+	return ieee80211_if_read_sdata(iocb,				\
+				       to, ieee80211_if_fmt_##name);	\
+}									\
 
 #define _IEEE80211_IF_FILE_W_FN(name)					\
-static ssize_t ieee80211_if_write_##name(struct file *file,		\
-					 const char __user *userbuf,	\
-					 size_t count, loff_t *ppos)	\
+static ssize_t ieee80211_if_write_##name(struct kiocb *iocb,		\
+					 struct iov_iter *from)		\
 {									\
-	return ieee80211_if_write_sdata(file, userbuf,			\
-					count, ppos,			\
+	return ieee80211_if_write_sdata(iocb, from,			\
 					ieee80211_if_parse_##name);	\
-}
+}									\
 
 #define IEEE80211_IF_FILE_R(name)					\
 	_IEEE80211_IF_FILE_R_FN(name)					\
@@ -267,24 +247,20 @@ static ssize_t ieee80211_if_write_##name(struct file *file,		\
 	IEEE80211_IF_FILE_R(name)
 
 #define _IEEE80211_IF_LINK_R_FN(name)					\
-static ssize_t ieee80211_if_read_##name(struct file *file,		\
-					char __user *userbuf,		\
-					size_t count, loff_t *ppos)	\
+static ssize_t ieee80211_if_read_##name(struct kiocb *iocb,		\
+					struct iov_iter *to)		\
 {									\
-	return ieee80211_if_read_link(file,				\
-				      userbuf, count, ppos,		\
-				      ieee80211_if_fmt_##name);	\
-}
+	return ieee80211_if_read_link(iocb, to,				\
+				      ieee80211_if_fmt_##name);		\
+}									\
 
 #define _IEEE80211_IF_LINK_W_FN(name)					\
-static ssize_t ieee80211_if_write_##name(struct file *file,		\
-					 const char __user *userbuf,	\
-					 size_t count, loff_t *ppos)	\
+static ssize_t ieee80211_if_write_##name(struct kiocb *iocb,		\
+					 struct iov_iter *from)		\
 {									\
-	return ieee80211_if_write_link(file, userbuf,			\
-				       count, ppos,			\
+	return ieee80211_if_write_link(iocb, from,			\
 				       ieee80211_if_parse_##name);	\
-}
+}									\
 
 #define IEEE80211_IF_LINK_FILE_R(name)					\
 	_IEEE80211_IF_LINK_R_FN(name)					\
@@ -441,7 +417,7 @@ static ssize_t ieee80211_if_parse_smps(struct ieee80211_link_data *link,
 IEEE80211_IF_LINK_FILE_RW(smps);
 
 static ssize_t ieee80211_if_parse_tkip_mic_test(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	struct ieee80211_local *local = sdata->local;
 	u8 addr[ETH_ALEN];
@@ -504,7 +480,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test(
 IEEE80211_IF_FILE_W(tkip_mic_test);
 
 static ssize_t ieee80211_if_parse_beacon_loss(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	if (!ieee80211_sdata_running(sdata) || !sdata->vif.cfg.assoc)
 		return -ENOTCONN;
@@ -524,7 +500,7 @@ static ssize_t ieee80211_if_fmt_uapsd_queues(
 }
 
 static ssize_t ieee80211_if_parse_uapsd_queues(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 	u8 val;
@@ -552,7 +528,7 @@ static ssize_t ieee80211_if_fmt_uapsd_max_sp_len(
 }
 
 static ssize_t ieee80211_if_parse_uapsd_max_sp_len(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 	unsigned long val;
@@ -584,7 +560,7 @@ static ssize_t ieee80211_if_fmt_tdls_wider_bw(
 }
 
 static ssize_t ieee80211_if_parse_tdls_wider_bw(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 	u8 val;
@@ -665,7 +641,7 @@ static ssize_t ieee80211_if_fmt_tsf(
 }
 
 static ssize_t ieee80211_if_parse_tsf(
-	struct ieee80211_sub_if_data *sdata, const char *buf, int buflen)
+	struct ieee80211_sub_if_data *sdata, char *buf, size_t buflen)
 {
 	struct ieee80211_local *local = sdata->local;
 	unsigned long long tsf;
@@ -724,7 +700,7 @@ static ssize_t ieee80211_if_fmt_active_links(const struct ieee80211_sub_if_data
 }
 
 static ssize_t ieee80211_if_parse_active_links(struct ieee80211_sub_if_data *sdata,
-					       const char *buf, int buflen)
+					       char *buf, size_t buflen)
 {
 	u16 active_links;
 
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 1e9389c49a57..6a900c671ced 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -19,27 +19,27 @@
 /* sta attributes */
 
 #define STA_READ(name, field, format_string)				\
-static ssize_t sta_ ##name## _read(struct file *file,			\
-				   char __user *userbuf,		\
-				   size_t count, loff_t *ppos)		\
+static ssize_t sta_ ##name## _read(struct kiocb *iocb,			\
+				   struct iov_iter *to)			\
 {									\
-	struct sta_info *sta = file->private_data;			\
-	return mac80211_format_buffer(userbuf, count, ppos, 		\
-				      format_string, sta->field);	\
-}
+	struct sta_info *sta = iocb->ki_filp->private_data;		\
+	return mac80211_format_buffer(iocb, to, format_string,		\
+				      sta->field);			\
+}									\
+
 #define STA_READ_D(name, field) STA_READ(name, field, "%d\n")
 
 #define STA_OPS(name)							\
 static const struct file_operations sta_ ##name## _ops = {		\
-	.read = sta_##name##_read,					\
+	.read_iter = sta_##name##_read,					\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
 
 #define STA_OPS_RW(name)						\
 static const struct file_operations sta_ ##name## _ops = {		\
-	.read = sta_##name##_read,					\
-	.write = sta_##name##_write,					\
+	.read_iter = sta_##name##_read,					\
+	.write_iter = sta_##name##_write,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -83,12 +83,11 @@ static const char * const sta_flag_names[] = {
 #undef FLAG
 };
 
-static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
-			      size_t count, loff_t *ppos)
+static ssize_t sta_flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[16 * NUM_WLAN_STA_FLAGS], *pos = buf;
 	char *end = buf + sizeof(buf) - 1;
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	unsigned int flg;
 
 	BUILD_BUG_ON(ARRAY_SIZE(sta_flag_names) != NUM_WLAN_STA_FLAGS);
@@ -99,15 +98,14 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
 					 sta_flag_names[flg]);
 	}
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 STA_OPS(flags);
 
-static ssize_t sta_num_ps_buf_frames_read(struct file *file,
-					  char __user *userbuf,
-					  size_t count, loff_t *ppos)
+static ssize_t sta_num_ps_buf_frames_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	char buf[17*IEEE80211_NUM_ACS], *p = buf;
 	int ac;
 
@@ -115,30 +113,28 @@ static ssize_t sta_num_ps_buf_frames_read(struct file *file,
 		p += scnprintf(p, sizeof(buf)+buf-p, "AC%d: %d\n", ac,
 			       skb_queue_len(&sta->ps_tx_buf[ac]) +
 			       skb_queue_len(&sta->tx_filtered[ac]));
-	return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 }
 STA_OPS(num_ps_buf_frames);
 
-static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t sta_last_seq_ctrl_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[15*IEEE80211_NUM_TIDS], *p = buf;
 	int i;
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	for (i = 0; i < IEEE80211_NUM_TIDS; i++)
 		p += scnprintf(p, sizeof(buf)+buf-p, "%x ",
 			       le16_to_cpu(sta->last_seq_ctrl[i]));
 	p += scnprintf(p, sizeof(buf)+buf-p, "\n");
-	return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 }
 STA_OPS(last_seq_ctrl);
 
 #define AQM_TXQ_ENTRY_LEN 130
 
-static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
-			size_t count, loff_t *ppos)
+static ssize_t sta_aqm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct ieee80211_local *local = sta->local;
 	size_t bufsz = AQM_TXQ_ENTRY_LEN * (IEEE80211_NUM_TIDS + 2);
 	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
@@ -189,16 +185,15 @@ static ssize_t sta_aqm_read(struct file *file, char __user *userbuf,
 	rcu_read_unlock();
 	spin_unlock_bh(&local->fq.lock);
 
-	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	rv = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return rv;
 }
 STA_OPS(aqm);
 
-static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t sta_airtime_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct ieee80211_local *local = sta->sdata->local;
 	size_t bufsz = 400;
 	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
@@ -224,15 +219,14 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,
 		rx_airtime, tx_airtime, sta->airtime_weight,
 		deficit[0], deficit[1], deficit[2], deficit[3]);
 
-	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	rv = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return rv;
 }
 
-static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t sta_airtime_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct ieee80211_local *local = sta->sdata->local;
 	int ac;
 
@@ -244,14 +238,13 @@ static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,
 		spin_unlock_bh(&local->active_txq_lock[ac]);
 	}
 
-	return count;
+	return iov_iter_count(from);
 }
 STA_OPS_RW(airtime);
 
-static ssize_t sta_aql_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t sta_aql_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct ieee80211_local *local = sta->sdata->local;
 	size_t bufsz = 400;
 	char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
@@ -278,22 +271,22 @@ static ssize_t sta_aql_read(struct file *file, char __user *userbuf,
 		q_limit_l[0], q_limit_h[0], q_limit_l[1], q_limit_h[1],
 		q_limit_l[2], q_limit_h[2], q_limit_l[3], q_limit_h[3]);
 
-	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	rv = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return rv;
 }
 
-static ssize_t sta_aql_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t sta_aql_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	u32 ac, q_limit_l, q_limit_h;
 	char _buf[100] = {}, *buf = _buf;
+	size_t count = iov_iter_count(from);
 
 	if (count > sizeof(_buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter(buf, count, from))
 		return -EFAULT;
 
 	buf[sizeof(_buf) - 1] = '\0';
@@ -312,8 +305,8 @@ static ssize_t sta_aql_write(struct file *file, const char __user *userbuf,
 STA_OPS_RW(aql);
 
 
-static ssize_t sta_agg_status_do_read(struct wiphy *wiphy, struct file *file,
-				      char *buf, size_t bufsz, void *data)
+static ssize_t sta_agg_status_do_read(struct wiphy *wiphy, char *buf,
+				      size_t bufsz, void *data)
 {
 	struct sta_info *sta = data;
 	char *p = buf;
@@ -353,10 +346,9 @@ static ssize_t sta_agg_status_do_read(struct wiphy *wiphy, struct file *file,
 	return p - buf;
 }
 
-static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
-				   size_t count, loff_t *ppos)
+static ssize_t sta_agg_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct wiphy *wiphy = sta->local->hw.wiphy;
 	size_t bufsz = 71 + IEEE80211_NUM_TIDS * 40;
 	char *buf = kmalloc(bufsz, GFP_KERNEL);
@@ -365,16 +357,15 @@ static ssize_t sta_agg_status_read(struct file *file, char __user *userbuf,
 	if (!buf)
 		return -ENOMEM;
 
-	ret = wiphy_locked_debugfs_read(wiphy, file, buf, bufsz,
-					userbuf, count, ppos,
-					sta_agg_status_do_read, sta);
+	ret = wiphy_locked_debugfs_read(wiphy, iocb, buf, bufsz,
+					to, sta_agg_status_do_read, sta);
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t sta_agg_status_do_write(struct wiphy *wiphy, struct file *file,
-				       char *buf, size_t count, void *data)
+static ssize_t sta_agg_status_do_write(struct wiphy *wiphy, char *buf,
+				       size_t count, void *data)
 {
 	struct sta_info *sta = data;
 	bool start, tx;
@@ -434,43 +425,37 @@ static ssize_t sta_agg_status_do_write(struct wiphy *wiphy, struct file *file,
 	return ret ?: count;
 }
 
-static ssize_t sta_agg_status_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t sta_agg_status_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sta_info *sta = file->private_data;
+	struct sta_info *sta = iocb->ki_filp->private_data;
 	struct wiphy *wiphy = sta->local->hw.wiphy;
 	char _buf[26];
 
-	return wiphy_locked_debugfs_write(wiphy, file, _buf, sizeof(_buf),
-					  userbuf, count,
-					  sta_agg_status_do_write, sta);
+	return wiphy_locked_debugfs_write(wiphy, iocb, _buf, sizeof(_buf),
+					  from, sta_agg_status_do_write, sta);
 }
 STA_OPS_RW(agg_status);
 
 /* link sta attributes */
 #define LINK_STA_OPS(name)						\
 static const struct file_operations link_sta_ ##name## _ops = {		\
-	.read = link_sta_##name##_read,					\
+	.read_iter = link_sta_##name##_read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
 
-static ssize_t link_sta_addr_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t link_sta_addr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct link_sta_info *link_sta = file->private_data;
+	struct link_sta_info *link_sta = iocb->ki_filp->private_data;
 	u8 mac[3 * ETH_ALEN + 1];
 
 	snprintf(mac, sizeof(mac), "%pM\n", link_sta->pub->addr);
 
-	return simple_read_from_buffer(userbuf, count, ppos, mac, 3 * ETH_ALEN);
+	return simple_copy_to_iter(mac, &iocb->ki_pos, 3 * ETH_ALEN, to);
 }
-
 LINK_STA_OPS(addr);
 
-static ssize_t link_sta_ht_capa_read(struct file *file, char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t link_sta_ht_capa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 #define PRINT_HT_CAP(_cond, _str) \
 	do { \
@@ -480,7 +465,7 @@ static ssize_t link_sta_ht_capa_read(struct file *file, char __user *userbuf,
 	char *buf, *p;
 	int i;
 	ssize_t bufsz = 512;
-	struct link_sta_info *link_sta = file->private_data;
+	struct link_sta_info *link_sta = iocb->ki_filp->private_data;
 	struct ieee80211_sta_ht_cap *htc = &link_sta->pub->ht_cap;
 	ssize_t ret;
 
@@ -554,17 +539,16 @@ static ssize_t link_sta_ht_capa_read(struct file *file, char __user *userbuf,
 				htc->mcs.tx_params);
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return ret;
 }
 LINK_STA_OPS(ht_capa);
 
-static ssize_t link_sta_vht_capa_read(struct file *file, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t link_sta_vht_capa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buf, *p;
-	struct link_sta_info *link_sta = file->private_data;
+	struct link_sta_info *link_sta = iocb->ki_filp->private_data;
 	struct ieee80211_sta_vht_cap *vhtc = &link_sta->pub->vht_cap;
 	ssize_t ret;
 	ssize_t bufsz = 512;
@@ -668,18 +652,17 @@ static ssize_t link_sta_vht_capa_read(struct file *file, char __user *userbuf,
 #undef PFLAG
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return ret;
 }
 LINK_STA_OPS(vht_capa);
 
-static ssize_t link_sta_he_capa_read(struct file *file, char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t link_sta_he_capa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buf, *p;
 	size_t buf_sz = PAGE_SIZE;
-	struct link_sta_info *link_sta = file->private_data;
+	struct link_sta_info *link_sta = iocb->ki_filp->private_data;
 	struct ieee80211_sta_he_cap *hec = &link_sta->pub->he_cap;
 	struct ieee80211_he_mcs_nss_supp *nss = &hec->he_mcs_nss_supp;
 	u8 ppe_size;
@@ -1041,18 +1024,17 @@ static ssize_t link_sta_he_capa_read(struct file *file, char __user *userbuf,
 	p += scnprintf(p, buf_sz + buf - p, "\n");
 
 out:
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return ret;
 }
 LINK_STA_OPS(he_capa);
 
-static ssize_t link_sta_eht_capa_read(struct file *file, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t link_sta_eht_capa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buf, *p;
 	size_t buf_sz = PAGE_SIZE;
-	struct link_sta_info *link_sta = file->private_data;
+	struct link_sta_info *link_sta = iocb->ki_filp->private_data;
 	struct ieee80211_sta_eht_cap *bec = &link_sta->pub->eht_cap;
 	struct ieee80211_eht_cap_elem_fixed *fixed = &bec->eht_cap_elem;
 	struct ieee80211_eht_mcs_nss_supp *nss = &bec->eht_mcs_nss_supp;
@@ -1225,7 +1207,7 @@ static ssize_t link_sta_eht_capa_read(struct file *file, char __user *userbuf,
 	}
 
 out:
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 	kfree(buf);
 	return ret;
 }
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 23404b275457..d8715afa8a6a 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -219,18 +219,16 @@ ieee80211_rate_control_ops_get(const char *name)
 }
 
 #ifdef CONFIG_MAC80211_DEBUGFS
-static ssize_t rcname_read(struct file *file, char __user *userbuf,
-			   size_t count, loff_t *ppos)
+static ssize_t rcname_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rate_control_ref *ref = file->private_data;
+	struct rate_control_ref *ref = iocb->ki_filp->private_data;
 	int len = strlen(ref->ops->name);
 
-	return simple_read_from_buffer(userbuf, count, ppos,
-				       ref->ops->name, len);
+	return simple_copy_to_iter(ref->ops->name, &iocb->ki_pos, len, to);
 }
 
 const struct file_operations rcname_ops = {
-	.read = rcname_read,
+	.read_iter = rcname_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index 25b8a67a63a4..426c63e4e475 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -16,13 +16,12 @@ struct minstrel_debugfs_info {
 	char buf[];
 };
 
-static ssize_t
-minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
+static ssize_t minstrel_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct minstrel_debugfs_info *ms;
 
-	ms = file->private_data;
-	return simple_read_from_buffer(buf, len, ppos, ms->buf, ms->len);
+	ms = iocb->ki_filp->private_data;
+	return simple_copy_to_iter(ms->buf, &iocb->ki_pos, ms->len, to);
 }
 
 static int
@@ -185,7 +184,7 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
 static const struct file_operations minstrel_ht_stat_fops = {
 	.owner = THIS_MODULE,
 	.open = minstrel_ht_stats_open,
-	.read = minstrel_stats_read,
+	.read_iter = minstrel_stats_read,
 	.release = minstrel_stats_release,
 	.llseek = no_llseek,
 };
@@ -321,7 +320,7 @@ minstrel_ht_stats_csv_open(struct inode *inode, struct file *file)
 static const struct file_operations minstrel_ht_stat_csv_fops = {
 	.owner = THIS_MODULE,
 	.open = minstrel_ht_stats_csv_open,
-	.read = minstrel_stats_read,
+	.read_iter = minstrel_stats_read,
 	.release = minstrel_stats_release,
 	.llseek = no_llseek,
 };
diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c
index 40e49074e2ee..fd4509acec37 100644
--- a/net/wireless/debugfs.c
+++ b/net/wireless/debugfs.c
@@ -114,12 +114,10 @@ void cfg80211_debugfs_rdev_add(struct cfg80211_registered_device *rdev)
 struct debugfs_read_work {
 	struct wiphy_work work;
 	ssize_t (*handler)(struct wiphy *wiphy,
-			   struct file *file,
 			   char *buf,
 			   size_t count,
 			   void *data);
 	struct wiphy *wiphy;
-	struct file *file;
 	char *buf;
 	size_t bufsize;
 	void *data;
@@ -132,7 +130,7 @@ static void wiphy_locked_debugfs_read_work(struct wiphy *wiphy,
 {
 	struct debugfs_read_work *w = container_of(work, typeof(*w), work);
 
-	w->ret = w->handler(w->wiphy, w->file, w->buf, w->bufsize, w->data);
+	w->ret = w->handler(w->wiphy, w->buf, w->bufsize, w->data);
 	complete(&w->completion);
 }
 
@@ -145,12 +143,10 @@ static void wiphy_locked_debugfs_read_cancel(struct dentry *dentry,
 	complete(&w->completion);
 }
 
-ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
+ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct kiocb *iocb,
 				  char *buf, size_t bufsize,
-				  char __user *userbuf, size_t count,
-				  loff_t *ppos,
+				  struct iov_iter *to,
 				  ssize_t (*handler)(struct wiphy *wiphy,
-						     struct file *file,
 						     char *buf,
 						     size_t bufsize,
 						     void *data),
@@ -159,7 +155,6 @@ ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
 	struct debugfs_read_work work = {
 		.handler = handler,
 		.wiphy = wiphy,
-		.file = file,
 		.buf = buf,
 		.bufsize = bufsize,
 		.data = data,
@@ -177,9 +172,9 @@ ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
 	wiphy_work_init(&work.work, wiphy_locked_debugfs_read_work);
 	wiphy_work_queue(wiphy, &work.work);
 
-	debugfs_enter_cancellation(file, &cancellation);
+	debugfs_enter_cancellation(iocb->ki_filp, &cancellation);
 	wait_for_completion(&work.completion);
-	debugfs_leave_cancellation(file, &cancellation);
+	debugfs_leave_cancellation(iocb->ki_filp, &cancellation);
 
 	if (work.ret < 0)
 		return work.ret;
@@ -187,19 +182,17 @@ ssize_t wiphy_locked_debugfs_read(struct wiphy *wiphy, struct file *file,
 	if (WARN_ON(work.ret > bufsize))
 		return -EINVAL;
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, work.ret);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, work.ret, to);
 }
 EXPORT_SYMBOL_GPL(wiphy_locked_debugfs_read);
 
 struct debugfs_write_work {
 	struct wiphy_work work;
 	ssize_t (*handler)(struct wiphy *wiphy,
-			   struct file *file,
 			   char *buf,
 			   size_t count,
 			   void *data);
 	struct wiphy *wiphy;
-	struct file *file;
 	char *buf;
 	size_t count;
 	void *data;
@@ -212,7 +205,7 @@ static void wiphy_locked_debugfs_write_work(struct wiphy *wiphy,
 {
 	struct debugfs_write_work *w = container_of(work, typeof(*w), work);
 
-	w->ret = w->handler(w->wiphy, w->file, w->buf, w->count, w->data);
+	w->ret = w->handler(w->wiphy, w->buf, w->count, w->data);
 	complete(&w->completion);
 }
 
@@ -226,10 +219,9 @@ static void wiphy_locked_debugfs_write_cancel(struct dentry *dentry,
 }
 
 ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy,
-				   struct file *file, char *buf, size_t bufsize,
-				   const char __user *userbuf, size_t count,
+				   struct kiocb *iocb, char *buf, size_t bufsize,
+				   struct iov_iter *from,
 				   ssize_t (*handler)(struct wiphy *wiphy,
-						      struct file *file,
 						      char *buf,
 						      size_t count,
 						      void *data),
@@ -238,9 +230,8 @@ ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy,
 	struct debugfs_write_work work = {
 		.handler = handler,
 		.wiphy = wiphy,
-		.file = file,
 		.buf = buf,
-		.count = count,
+		.count = bufsize,
 		.data = data,
 		.ret = -ENODEV,
 		.completion = COMPLETION_INITIALIZER_ONSTACK(work.completion),
@@ -249,6 +240,7 @@ ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy,
 		.cancel = wiphy_locked_debugfs_write_cancel,
 		.cancel_data = &work,
 	};
+	size_t count = iov_iter_count(from);
 
 	/* mostly used for strings so enforce NUL-termination for safety */
 	if (count >= bufsize)
@@ -256,15 +248,15 @@ ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy,
 
 	memset(buf, 0, bufsize);
 
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	wiphy_work_init(&work.work, wiphy_locked_debugfs_write_work);
 	wiphy_work_queue(wiphy, &work.work);
 
-	debugfs_enter_cancellation(file, &cancellation);
+	debugfs_enter_cancellation(iocb->ki_filp, &cancellation);
 	wait_for_completion(&work.completion);
-	debugfs_leave_cancellation(file, &cancellation);
+	debugfs_leave_cancellation(iocb->ki_filp, &cancellation);
 
 	return work.ret;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 053/437] net: 6lowpan: convert debugfs to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (51 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 052/437] net: mac80211: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 054/437] net: sunrpc: convert " Jens Axboe
                   ` (384 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/6lowpan/debugfs.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/net/6lowpan/debugfs.c b/net/6lowpan/debugfs.c
index 600b9563bfc5..0ec0da78c39c 100644
--- a/net/6lowpan/debugfs.c
+++ b/net/6lowpan/debugfs.c
@@ -120,20 +120,18 @@ static int lowpan_ctx_pfx_open(struct inode *inode, struct file *file)
 	return single_open(file, lowpan_ctx_pfx_show, inode->i_private);
 }
 
-static ssize_t lowpan_ctx_pfx_write(struct file *fp,
-				    const char __user *user_buf, size_t count,
-				    loff_t *ppos)
+static ssize_t lowpan_ctx_pfx_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[128] = {};
-	struct seq_file *file = fp->private_data;
+	struct seq_file *file = iocb->ki_filp->private_data;
 	struct lowpan_iphc_ctx *ctx = file->private;
 	struct lowpan_iphc_ctx_table *t =
 		container_of(ctx, struct lowpan_iphc_ctx_table, table[ctx->id]);
+	size_t count = iov_iter_count(from);
 	int status = count, n, i;
 	unsigned int addr[8];
 
-	if (copy_from_user(&buf, user_buf, min_t(size_t, sizeof(buf) - 1,
-						 count))) {
+	if (!copy_from_iter_full(&buf, count, from)) {
 		status = -EFAULT;
 		goto out;
 	}
@@ -157,8 +155,8 @@ static ssize_t lowpan_ctx_pfx_write(struct file *fp,
 
 static const struct file_operations lowpan_ctx_pfx_fops = {
 	.open		= lowpan_ctx_pfx_open,
-	.read		= seq_read,
-	.write		= lowpan_ctx_pfx_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= lowpan_ctx_pfx_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 054/437] net: sunrpc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (52 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 053/437] net: 6lowpan: convert debugfs " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 055/437] net: wireless: " Jens Axboe
                   ` (383 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/sunrpc/cache.c    | 14 +++++++++-----
 net/sunrpc/debugfs.c  |  4 ++--
 net/sunrpc/rpc_pipe.c |  8 +++++---
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 95ff74706104..451b93494585 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1774,6 +1774,7 @@ static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
 
 	return cache_read(filp, buf, count, ppos, cd);
 }
+FOPS_READ_ITER_HELPER(cache_read_pipefs);
 
 static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
 				  size_t count, loff_t *ppos)
@@ -1782,6 +1783,7 @@ static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
 
 	return cache_write(filp, buf, count, ppos, cd);
 }
+FOPS_WRITE_ITER_HELPER(cache_write_pipefs);
 
 static __poll_t cache_poll_pipefs(struct file *filp, poll_table *wait)
 {
@@ -1816,8 +1818,8 @@ static int cache_release_pipefs(struct inode *inode, struct file *filp)
 const struct file_operations cache_file_operations_pipefs = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= cache_read_pipefs,
-	.write		= cache_write_pipefs,
+	.read_iter	= cache_read_pipefs_iter,
+	.write_iter	= cache_write_pipefs_iter,
 	.poll		= cache_poll_pipefs,
 	.unlocked_ioctl	= cache_ioctl_pipefs, /* for FIONREAD */
 	.open		= cache_open_pipefs,
@@ -1840,7 +1842,7 @@ static int content_release_pipefs(struct inode *inode, struct file *filp)
 
 const struct file_operations content_file_operations_pipefs = {
 	.open		= content_open_pipefs,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= content_release_pipefs,
 };
@@ -1866,6 +1868,7 @@ static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
 
 	return read_flush(filp, buf, count, ppos, cd);
 }
+FOPS_READ_ITER_HELPER(read_flush_pipefs);
 
 static ssize_t write_flush_pipefs(struct file *filp,
 				  const char __user *buf,
@@ -1875,11 +1878,12 @@ static ssize_t write_flush_pipefs(struct file *filp,
 
 	return write_flush(filp, buf, count, ppos, cd);
 }
+FOPS_WRITE_ITER_HELPER(write_flush_pipefs);
 
 const struct file_operations cache_flush_operations_pipefs = {
 	.open		= open_flush_pipefs,
-	.read		= read_flush_pipefs,
-	.write		= write_flush_pipefs,
+	.read_iter	= read_flush_pipefs_iter,
+	.write_iter	= write_flush_pipefs_iter,
 	.release	= release_flush_pipefs,
 	.llseek		= no_llseek,
 };
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index a176d5a0b0ee..8fb085c614ef 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -112,7 +112,7 @@ tasks_release(struct inode *inode, struct file *filp)
 static const struct file_operations tasks_fops = {
 	.owner		= THIS_MODULE,
 	.open		= tasks_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= tasks_release,
 };
@@ -211,7 +211,7 @@ xprt_info_release(struct inode *inode, struct file *filp)
 static const struct file_operations xprt_info_fops = {
 	.owner		= THIS_MODULE,
 	.open		= xprt_info_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= xprt_info_release,
 };
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 910a5d850d04..73189ac4d9f7 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -320,6 +320,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
 	inode_unlock(inode);
 	return res;
 }
+FOPS_READ_ITER_HELPER(rpc_pipe_read);
 
 static ssize_t
 rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset)
@@ -334,6 +335,7 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of
 	inode_unlock(inode);
 	return res;
 }
+FOPS_WRITE_ITER_HELPER(rpc_pipe_write);
 
 static __poll_t
 rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
@@ -386,8 +388,8 @@ rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 static const struct file_operations rpc_pipe_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= rpc_pipe_read,
-	.write		= rpc_pipe_write,
+	.read_iter	= rpc_pipe_read_iter,
+	.write_iter	= rpc_pipe_write_iter,
 	.poll		= rpc_pipe_poll,
 	.unlocked_ioctl	= rpc_pipe_ioctl,
 	.open		= rpc_pipe_open,
@@ -449,7 +451,7 @@ rpc_info_release(struct inode *inode, struct file *file)
 static const struct file_operations rpc_info_operations = {
 	.owner		= THIS_MODULE,
 	.open		= rpc_info_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= rpc_info_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 055/437] net: wireless: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (53 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 054/437] net: sunrpc: convert " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 056/437] net: rfkill: " Jens Axboe
                   ` (382 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/wireless/debugfs.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c
index fd4509acec37..014bacd8f6a5 100644
--- a/net/wireless/debugfs.c
+++ b/net/wireless/debugfs.c
@@ -12,19 +12,18 @@
 #include "debugfs.h"
 
 #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...)		\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct wiphy *wiphy = file->private_data;			\
+	struct wiphy *wiphy = iocb->ki_filp->private_data;		\
 	char buf[buflen];						\
 	int res;							\
 									\
 	res = scnprintf(buf, buflen, fmt "\n", ##value);		\
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);	\
 }									\
 									\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -60,11 +59,9 @@ static int ht_print_chan(struct ieee80211_channel *chan,
 				' ' : '+');
 }
 
-static ssize_t ht40allow_map_read(struct file *file,
-				  char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t ht40allow_map_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wiphy *wiphy = file->private_data;
+	struct wiphy *wiphy = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int offset = 0, buf_size = PAGE_SIZE, i;
 	enum nl80211_band band;
@@ -84,15 +81,13 @@ static ssize_t ht40allow_map_read(struct file *file,
 						buf, buf_size, offset);
 	}
 
-	r = simple_read_from_buffer(user_buf, count, ppos, buf, offset);
-
+	r = simple_copy_to_iter(buf, &iocb->ki_pos, offset, to);
 	kfree(buf);
-
 	return r;
 }
 
 static const struct file_operations ht40allow_map_ops = {
-	.read = ht40allow_map_read,
+	.read_iter = ht40allow_map_read_iter,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 056/437] net: rfkill: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (54 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 055/437] net: wireless: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 057/437] net: l2tp: " Jens Axboe
                   ` (381 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/rfkill/core.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index c3feb4f49d09..36271888c130 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1226,10 +1226,10 @@ static __poll_t rfkill_fop_poll(struct file *file, poll_table *wait)
 	return res;
 }
 
-static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t rfkill_fop_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rfkill_data *data = file->private_data;
+	struct rfkill_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct rfkill_int_event *ev;
 	unsigned long sz;
 	int ret;
@@ -1237,7 +1237,7 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	mutex_lock(&data->mtx);
 
 	while (list_empty(&data->events)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto out;
 		}
@@ -1259,7 +1259,7 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	sz = min_t(unsigned long, sizeof(ev->ev), count);
 	sz = min_t(unsigned long, sz, data->max_size);
 	ret = sz;
-	if (copy_to_user(buf, &ev->ev, sz))
+	if (!copy_to_iter_full(&ev->ev, sz, to))
 		ret = -EFAULT;
 
 	list_del(&ev->list);
@@ -1269,10 +1269,10 @@ static ssize_t rfkill_fop_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *pos)
+static ssize_t rfkill_fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rfkill_data *data = file->private_data;
+	struct rfkill_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct rfkill *rfkill;
 	struct rfkill_event_ext ev;
 	int ret;
@@ -1288,7 +1288,7 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
 	 */
 	count = min(count, sizeof(ev));
 	count = min_t(size_t, count, data->max_size);
-	if (copy_from_user(&ev, buf, count))
+	if (!copy_from_iter_full(&ev, count, from))
 		return -EFAULT;
 
 	if (ev.type >= NUM_RFKILL_TYPES)
@@ -1392,8 +1392,8 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations rfkill_fops = {
 	.owner		= THIS_MODULE,
 	.open		= rfkill_fop_open,
-	.read		= rfkill_fop_read,
-	.write		= rfkill_fop_write,
+	.read_iter	= rfkill_fop_read,
+	.write_iter	= rfkill_fop_write,
 	.poll		= rfkill_fop_poll,
 	.release	= rfkill_fop_release,
 	.unlocked_ioctl	= rfkill_fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 057/437] net: l2tp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (55 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 056/437] net: rfkill: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 058/437] fs: add IOCB_VECTORED flags Jens Axboe
                   ` (380 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 net/l2tp/l2tp_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
index 4595b56d175d..943c1ea51900 100644
--- a/net/l2tp/l2tp_debugfs.c
+++ b/net/l2tp/l2tp_debugfs.c
@@ -318,7 +318,7 @@ static int l2tp_dfs_seq_release(struct inode *inode, struct file *file)
 static const struct file_operations l2tp_dfs_fops = {
 	.owner		= THIS_MODULE,
 	.open		= l2tp_dfs_seq_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= l2tp_dfs_seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 058/437] fs: add IOCB_VECTORED flags
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (56 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 057/437] net: l2tp: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 059/437] ALSA: core: convert to read/write iterators Jens Axboe
                   ` (379 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

This allows a user of ->read_iter() or ->write_iter() to tell if this
request originally came as a readv/writev, or if it was a normal
read/write operation.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/read_write.c    | 1 +
 include/linux/fs.h | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 1d035293607b..efddd395d436 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -733,6 +733,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter,
 	ret = kiocb_set_rw_flags(&kiocb, flags);
 	if (ret)
 		return ret;
+	kiocb.ki_flags |= IOCB_VECTORED;
 	kiocb.ki_pos = (ppos ? *ppos : 0);
 
 	if (type == READ)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 483c70d3941e..69e4dfac2853 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -346,6 +346,8 @@ struct readahead_control;
 #define IOCB_DIO_CALLER_COMP	(1 << 22)
 /* kiocb is a read or write operation submitted by fs/aio.c. */
 #define IOCB_AIO_RW		(1 << 23)
+/* came from readv/writev */
+#define IOCB_VECTORED		(1 << 24)
 
 /* for use in trace events */
 #define TRACE_IOCB_STRINGS \
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 059/437] ALSA: core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (57 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 058/437] fs: add IOCB_VECTORED flags Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 060/437] ASoC: Intel: " Jens Axboe
                   ` (378 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/core/compress_offload.c  |  7 +--
 sound/core/control.c           | 14 +++---
 sound/core/hwdep.c             |  6 ++-
 sound/core/init.c              | 10 ++--
 sound/core/jack.c              | 83 ++++++++++++++--------------------
 sound/core/oss/pcm_oss.c       |  6 ++-
 sound/core/pcm_native.c        | 22 +++++++--
 sound/core/rawmidi.c           |  6 ++-
 sound/core/seq/oss/seq_oss.c   | 11 +++--
 sound/core/seq/seq_clientmgr.c |  8 ++--
 sound/core/timer.c             | 23 +++++-----
 11 files changed, 100 insertions(+), 96 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index f0008fa2d839..3d2df5eda81b 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -322,7 +322,7 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 
 	return retval;
 }
-
+FOPS_WRITE_ITER_HELPER(snd_compr_write);
 
 static ssize_t snd_compr_read(struct file *f, char __user *buf,
 		size_t count, loff_t *offset)
@@ -367,6 +367,7 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(snd_compr_read);
 
 static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma)
 {
@@ -1004,8 +1005,8 @@ static const struct file_operations snd_compr_file_ops = {
 		.owner =	THIS_MODULE,
 		.open =		snd_compr_open,
 		.release =	snd_compr_free,
-		.write =	snd_compr_write,
-		.read =		snd_compr_read,
+		.write_iter =	snd_compr_write_iter,
+		.read_iter =	snd_compr_read_iter,
 		.unlocked_ioctl = snd_compr_ioctl,
 #ifdef CONFIG_COMPAT
 		.compat_ioctl = snd_compr_ioctl_compat,
diff --git a/sound/core/control.c b/sound/core/control.c
index fb0c60044f7b..1faa740c5ec4 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1985,14 +1985,14 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
 	return -ENOTTY;
 }
 
-static ssize_t snd_ctl_read(struct file *file, char __user *buffer,
-			    size_t count, loff_t * offset)
+static ssize_t snd_ctl_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct snd_ctl_file *ctl;
 	int err = 0;
 	ssize_t result = 0;
 
-	ctl = file->private_data;
+	ctl = iocb->ki_filp->private_data;
 	if (snd_BUG_ON(!ctl || !ctl->card))
 		return -ENXIO;
 	if (!ctl->subscribed)
@@ -2005,7 +2005,8 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer,
 		struct snd_kctl_event *kev;
 		while (list_empty(&ctl->events)) {
 			wait_queue_entry_t wait;
-			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
+			if ((iocb->ki_filp->f_flags & O_NONBLOCK) != 0 ||
+			    result > 0) {
 				err = -EAGAIN;
 				goto __end_lock;
 			}
@@ -2028,12 +2029,11 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer,
 		list_del(&kev->list);
 		spin_unlock_irq(&ctl->read_lock);
 		kfree(kev);
-		if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
+		if (!copy_to_iter_full(&ev, sizeof(struct snd_ctl_event), to)) {
 			err = -EFAULT;
 			goto __end;
 		}
 		spin_lock_irq(&ctl->read_lock);
-		buffer += sizeof(struct snd_ctl_event);
 		count -= sizeof(struct snd_ctl_event);
 		result += sizeof(struct snd_ctl_event);
 	}
@@ -2277,7 +2277,7 @@ EXPORT_SYMBOL_GPL(snd_ctl_disconnect_layer);
 static const struct file_operations snd_ctl_f_ops =
 {
 	.owner =	THIS_MODULE,
-	.read =		snd_ctl_read,
+	.read_iter =	snd_ctl_read,
 	.open =		snd_ctl_open,
 	.release =	snd_ctl_release,
 	.llseek =	no_llseek,
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 09200df2932c..3db085c2ec6e 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -55,6 +55,7 @@ static ssize_t snd_hwdep_read(struct file * file, char __user *buf,
 		return hw->ops.read(hw, buf, count, offset);
 	return -ENXIO;	
 }
+FOPS_READ_ITER_HELPER(snd_hwdep_read);
 
 static ssize_t snd_hwdep_write(struct file * file, const char __user *buf,
 			       size_t count, loff_t *offset)
@@ -64,6 +65,7 @@ static ssize_t snd_hwdep_write(struct file * file, const char __user *buf,
 		return hw->ops.write(hw, buf, count, offset);
 	return -ENXIO;	
 }
+FOPS_WRITE_ITER_HELPER(snd_hwdep_write);
 
 static int snd_hwdep_open(struct inode *inode, struct file * file)
 {
@@ -327,8 +329,8 @@ static const struct file_operations snd_hwdep_f_ops =
 {
 	.owner = 	THIS_MODULE,
 	.llseek =	snd_hwdep_llseek,
-	.read = 	snd_hwdep_read,
-	.write =	snd_hwdep_write,
+	.read_iter = 	snd_hwdep_read_iter,
+	.write_iter =	snd_hwdep_write_iter,
 	.open =		snd_hwdep_open,
 	.release =	snd_hwdep_release,
 	.poll =		snd_hwdep_poll,
diff --git a/sound/core/init.c b/sound/core/init.c
index 4ed5037d8693..d2045533e33d 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -407,14 +407,12 @@ static loff_t snd_disconnect_llseek(struct file *file, loff_t offset, int orig)
 	return -ENODEV;
 }
 
-static ssize_t snd_disconnect_read(struct file *file, char __user *buf,
-				   size_t count, loff_t *offset)
+static ssize_t snd_disconnect_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -ENODEV;
 }
 
-static ssize_t snd_disconnect_write(struct file *file, const char __user *buf,
-				    size_t count, loff_t *offset)
+static ssize_t snd_disconnect_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -ENODEV;
 }
@@ -467,8 +465,8 @@ static const struct file_operations snd_shutdown_f_ops =
 {
 	.owner = 	THIS_MODULE,
 	.llseek =	snd_disconnect_llseek,
-	.read = 	snd_disconnect_read,
-	.write =	snd_disconnect_write,
+	.read_iter = 	snd_disconnect_read,
+	.write_iter =	snd_disconnect_write,
 	.release =	snd_disconnect_release,
 	.poll =		snd_disconnect_poll,
 	.unlocked_ioctl = snd_disconnect_ioctl,
diff --git a/sound/core/jack.c b/sound/core/jack.c
index e08b2c4fbd1a..d7a0a26389ca 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -161,29 +161,25 @@ static void snd_jack_inject_report(struct snd_jack_kctl *jack_kctl, int status)
 #endif /* CONFIG_SND_JACK_INPUT_DEV */
 }
 
-static ssize_t sw_inject_enable_read(struct file *file,
-				     char __user *to, size_t count, loff_t *ppos)
+static ssize_t sw_inject_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
-	int len, ret;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	char buf[128];
+	int len;
 
 	len = scnprintf(buf, sizeof(buf), "%s: %s\t\t%s: %i\n", "Jack", jack_kctl->kctl->id.name,
 			"Inject Enabled", jack_kctl->sw_inject_enable);
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t sw_inject_enable_write(struct file *file,
-				      const char __user *from, size_t count, loff_t *ppos)
+static ssize_t sw_inject_enable_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	int ret, err;
 	unsigned long enable;
 	char buf[8] = { 0 };
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, from, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	err = kstrtoul(buf, 0, &enable);
 	if (err)
 		return err;
@@ -199,10 +195,9 @@ static ssize_t sw_inject_enable_write(struct file *file,
 	return ret;
 }
 
-static ssize_t jackin_inject_write(struct file *file,
-				   const char __user *from, size_t count, loff_t *ppos)
+static ssize_t jackin_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	int ret, err;
 	unsigned long enable;
 	char buf[8] = { 0 };
@@ -210,7 +205,7 @@ static ssize_t jackin_inject_write(struct file *file,
 	if (!jack_kctl->sw_inject_enable)
 		return -EINVAL;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, from, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	err = kstrtoul(buf, 0, &enable);
 	if (err)
 		return err;
@@ -220,17 +215,14 @@ static ssize_t jackin_inject_write(struct file *file,
 	return ret;
 }
 
-static ssize_t jack_kctl_id_read(struct file *file,
-				 char __user *to, size_t count, loff_t *ppos)
+static ssize_t jack_kctl_id_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	char buf[64];
-	int len, ret;
+	int len;
 
 	len = scnprintf(buf, sizeof(buf), "%s\n", jack_kctl->kctl->id.name);
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /* the bit definition is aligned with snd_jack_types in jack.h */
@@ -258,82 +250,73 @@ static int parse_mask_bits(unsigned int mask_bits, char *buf, size_t buf_size)
 	return strlen(buf);
 }
 
-static ssize_t jack_kctl_mask_bits_read(struct file *file,
-					char __user *to, size_t count, loff_t *ppos)
+static ssize_t jack_kctl_mask_bits_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	char buf[256];
-	int len, ret;
+	int len;
 
 	len = parse_mask_bits(jack_kctl->mask_bits, buf, sizeof(buf));
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t jack_kctl_status_read(struct file *file,
-				     char __user *to, size_t count, loff_t *ppos)
+static ssize_t jack_kctl_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	char buf[16];
-	int len, ret;
+	int len;
 
 	len = scnprintf(buf, sizeof(buf), "%s\n", jack_kctl->kctl->private_value ?
 			"Plugged" : "Unplugged");
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 #ifdef CONFIG_SND_JACK_INPUT_DEV
-static ssize_t jack_type_read(struct file *file,
-			      char __user *to, size_t count, loff_t *ppos)
+static ssize_t jack_type_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_jack_kctl *jack_kctl = file->private_data;
+	struct snd_jack_kctl *jack_kctl = iocb->ki_filp->private_data;
 	char buf[256];
-	int len, ret;
+	int len;
 
 	len = parse_mask_bits(jack_kctl->jack->type, buf, sizeof(buf));
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations jack_type_fops = {
 	.open = simple_open,
-	.read = jack_type_read,
+	.read_iter = jack_type_read,
 	.llseek = default_llseek,
 };
 #endif
 
 static const struct file_operations sw_inject_enable_fops = {
 	.open = simple_open,
-	.read = sw_inject_enable_read,
-	.write = sw_inject_enable_write,
+	.read_iter = sw_inject_enable_read,
+	.write_iter = sw_inject_enable_write,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations jackin_inject_fops = {
 	.open = simple_open,
-	.write = jackin_inject_write,
+	.write_iter = jackin_inject_write,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations jack_kctl_id_fops = {
 	.open = simple_open,
-	.read = jack_kctl_id_read,
+	.read_iter = jack_kctl_id_read,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations jack_kctl_mask_bits_fops = {
 	.open = simple_open,
-	.read = jack_kctl_mask_bits_read,
+	.read_iter = jack_kctl_mask_bits_read,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations jack_kctl_status_fops = {
 	.open = simple_open,
-	.read = jack_kctl_status_read,
+	.read_iter = jack_kctl_status_read,
 	.llseek = default_llseek,
 };
 
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 7386982cf40e..40a51f9743ea 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2781,6 +2781,7 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t coun
 	}
 #endif
 }
+FOPS_READ_ITER_HELPER(snd_pcm_oss_read);
 
 static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
 {
@@ -2800,6 +2801,7 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size
 #endif
 	return result;
 }
+FOPS_WRITE_ITER_HELPER(snd_pcm_oss_write);
 
 static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream)
 {
@@ -3102,8 +3104,8 @@ static inline void snd_pcm_oss_proc_done(struct snd_pcm *pcm)
 static const struct file_operations snd_pcm_oss_f_reg =
 {
 	.owner =	THIS_MODULE,
-	.read =		snd_pcm_oss_read,
-	.write =	snd_pcm_oss_write,
+	.read_iter =	snd_pcm_oss_read_iter,
+	.write_iter =	snd_pcm_oss_write_iter,
 	.open =		snd_pcm_oss_open,
 	.release =	snd_pcm_oss_release,
 	.llseek =	no_llseek,
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 0b76e76823d2..a3278321bcb0 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3577,6 +3577,22 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from)
 	return result;
 }
 
+static ssize_t snd_pcm_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	if (!(iocb->ki_flags & IOCB_VECTORED))
+		return vfs_read_iter(iocb, to, snd_pcm_read);
+
+	return snd_pcm_readv(iocb, to);
+}
+
+static ssize_t snd_pcm_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	if (!(iocb->ki_flags & IOCB_VECTORED))
+		return vfs_write_iter(iocb, from, snd_pcm_write);
+
+	return snd_pcm_writev(iocb, from);
+}
+
 static __poll_t snd_pcm_poll(struct file *file, poll_table *wait)
 {
 	struct snd_pcm_file *pcm_file;
@@ -4099,8 +4115,7 @@ static unsigned long snd_pcm_get_unmapped_area(struct file *file,
 const struct file_operations snd_pcm_f_ops[2] = {
 	{
 		.owner =		THIS_MODULE,
-		.write =		snd_pcm_write,
-		.write_iter =		snd_pcm_writev,
+		.write_iter =		snd_pcm_write_iter,
 		.open =			snd_pcm_playback_open,
 		.release =		snd_pcm_release,
 		.llseek =		no_llseek,
@@ -4113,8 +4128,7 @@ const struct file_operations snd_pcm_f_ops[2] = {
 	},
 	{
 		.owner =		THIS_MODULE,
-		.read =			snd_pcm_read,
-		.read_iter =		snd_pcm_readv,
+		.read_iter =		snd_pcm_read_iter,
 		.open =			snd_pcm_capture_open,
 		.release =		snd_pcm_release,
 		.llseek =		no_llseek,
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 7accf9a1ddf4..37590a2f447e 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -1316,6 +1316,7 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
 	}
 	return result;
 }
+FOPS_READ_ITER_HELPER(snd_rawmidi_read);
 
 /**
  * snd_rawmidi_transmit_empty - check whether the output buffer is empty
@@ -1652,6 +1653,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
 	}
 	return result;
 }
+FOPS_WRITE_ITER_HELPER(snd_rawmidi_write);
 
 static __poll_t snd_rawmidi_poll(struct file *file, poll_table *wait)
 {
@@ -1780,8 +1782,8 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
 
 static const struct file_operations snd_rawmidi_f_ops = {
 	.owner =	THIS_MODULE,
-	.read =		snd_rawmidi_read,
-	.write =	snd_rawmidi_write,
+	.read_iter =	snd_rawmidi_read_iter,
+	.write_iter =	snd_rawmidi_write_iter,
 	.open =		snd_rawmidi_open,
 	.release =	snd_rawmidi_release,
 	.llseek =	no_llseek,
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index 77c1214acd90..6bc9454c83e9 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -43,8 +43,8 @@ static inline void unregister_proc(void) {}
 
 static int odev_open(struct inode *inode, struct file *file);
 static int odev_release(struct inode *inode, struct file *file);
-static ssize_t odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset);
-static ssize_t odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset);
+static ssize_t odev_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t odev_write_iter(struct kiocb *iocb, struct iov_iter *from);
 static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 static __poll_t odev_poll(struct file *file, poll_table * wait);
 
@@ -156,7 +156,7 @@ odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
 		return -ENXIO;
 	return snd_seq_oss_read(dp, buf, count);
 }
-
+FOPS_READ_ITER_HELPER(odev_read);
 
 static ssize_t
 odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
@@ -167,6 +167,7 @@ odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offs
 		return -ENXIO;
 	return snd_seq_oss_write(dp, buf, count, file);
 }
+FOPS_WRITE_ITER_HELPER(odev_write);
 
 static long
 odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -214,8 +215,8 @@ odev_poll(struct file *file, poll_table * wait)
 static const struct file_operations seq_oss_f_ops =
 {
 	.owner =	THIS_MODULE,
-	.read =		odev_read,
-	.write =	odev_write,
+	.read_iter =	odev_read_iter,
+	.write_iter =	odev_write_iter,
 	.open =		odev_open,
 	.release =	odev_release,
 	.poll =		odev_poll,
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 42a705141050..8945d2b0a16f 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -511,7 +511,7 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count,
 
 	return (err < 0) ? err : result;
 }
-
+FOPS_READ_ITER_HELPER(snd_seq_read);
 
 /*
  * check access permission to the port
@@ -1107,7 +1107,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
 	mutex_unlock(&client->ioctl_mutex);
 	return written ? written : err;
 }
-
+FOPS_WRITE_ITER_HELPER(snd_seq_write);
 
 /*
  * handle polling
@@ -2711,8 +2711,8 @@ void snd_seq_info_clients_read(struct snd_info_entry *entry,
 static const struct file_operations snd_seq_f_ops =
 {
 	.owner =	THIS_MODULE,
-	.read =		snd_seq_read,
-	.write =	snd_seq_write,
+	.read_iter =	snd_seq_read_iter,
+	.write_iter =	snd_seq_write_iter,
 	.open =		snd_seq_open,
 	.release =	snd_seq_release,
 	.llseek =	no_llseek,
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 4d2ee99c12a3..9727e2db3eec 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -2066,9 +2066,9 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on)
 	return snd_fasync_helper(fd, file, on, &tu->fasync);
 }
 
-static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
-				   size_t count, loff_t *offset)
+static ssize_t snd_timer_user_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct snd_timer_tread64 *tread;
 	struct snd_timer_tread32 tread32;
 	struct snd_timer_user *tu;
@@ -2076,7 +2076,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 	int qhead;
 	int err = 0;
 
-	tu = file->private_data;
+	tu = iocb->ki_filp->private_data;
 	switch (tu->tread) {
 	case TREAD_FORMAT_TIME64:
 		unit = sizeof(struct snd_timer_tread64);
@@ -2098,7 +2098,8 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 		while (!tu->qused) {
 			wait_queue_entry_t wait;
 
-			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
+			if ((iocb->ki_filp->f_flags & O_NONBLOCK) != 0 ||
+			     result > 0) {
 				err = -EAGAIN;
 				goto _error;
 			}
@@ -2134,8 +2135,9 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 
 		switch (tu->tread) {
 		case TREAD_FORMAT_TIME64:
-			if (copy_to_user(buffer, tread,
-					 sizeof(struct snd_timer_tread64)))
+			if (!copy_to_iter_full(tread,
+					       sizeof(struct snd_timer_tread64),
+					       to))
 				err = -EFAULT;
 			break;
 		case TREAD_FORMAT_TIME32:
@@ -2147,12 +2149,12 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 				.val = tread->val,
 			};
 
-			if (copy_to_user(buffer, &tread32, sizeof(tread32)))
+			if (!copy_to_iter_full(&tread32, sizeof(tread32), to))
 				err = -EFAULT;
 			break;
 		case TREAD_FORMAT_NONE:
-			if (copy_to_user(buffer, &tu->queue[qhead],
-					 sizeof(struct snd_timer_read)))
+			if (!copy_to_iter_full(&tu->queue[qhead],
+					 sizeof(struct snd_timer_read), to))
 				err = -EFAULT;
 			break;
 		default:
@@ -2164,7 +2166,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 		if (err < 0)
 			goto _error;
 		result += unit;
-		buffer += unit;
 	}
  _error:
 	spin_unlock_irq(&tu->qlock);
@@ -2200,7 +2201,7 @@ static __poll_t snd_timer_user_poll(struct file *file, poll_table * wait)
 static const struct file_operations snd_timer_f_ops =
 {
 	.owner =	THIS_MODULE,
-	.read =		snd_timer_user_read,
+	.read_iter =	snd_timer_user_read,
 	.open =		snd_timer_user_open,
 	.release =	snd_timer_user_release,
 	.llseek =	no_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 060/437] ASoC: Intel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (58 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 059/437] ALSA: core: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 061/437] ASoC: fsl: " Jens Axboe
                   ` (377 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/intel/avs/debugfs.c       | 69 +++++++++++++++--------------
 sound/soc/intel/avs/pcm.c           |  9 ++--
 sound/soc/intel/skylake/skl-debug.c | 19 ++++----
 3 files changed, 47 insertions(+), 50 deletions(-)

diff --git a/sound/soc/intel/avs/debugfs.c b/sound/soc/intel/avs/debugfs.c
index 4dfbff0ce508..ebab29e5e2bd 100644
--- a/sound/soc/intel/avs/debugfs.c
+++ b/sound/soc/intel/avs/debugfs.c
@@ -48,9 +48,9 @@ void avs_dump_fw_log_wakeup(struct avs_dev *adev, const void __iomem *src, unsig
 	wake_up(&adev->trace_waitq);
 }
 
-static ssize_t fw_regs_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
+static ssize_t fw_regs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
 	char *buf;
 	int ret;
 
@@ -60,20 +60,20 @@ static ssize_t fw_regs_read(struct file *file, char __user *to, size_t count, lo
 
 	memcpy_fromio(buf, avs_sram_addr(adev, AVS_FW_REGS_WINDOW), AVS_FW_REGS_SIZE);
 
-	ret = simple_read_from_buffer(to, count, ppos, buf, AVS_FW_REGS_SIZE);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, AVS_FW_REGS_SIZE, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations fw_regs_fops = {
 	.open = simple_open,
-	.read = fw_regs_read,
+	.read_iter = fw_regs_read,
 	.llseek = no_llseek,
 };
 
-static ssize_t debug_window_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
+static ssize_t debug_window_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
 	size_t size;
 	char *buf;
 	int ret;
@@ -85,27 +85,27 @@ static ssize_t debug_window_read(struct file *file, char __user *to, size_t coun
 
 	memcpy_fromio(buf, avs_sram_addr(adev, AVS_DEBUG_WINDOW), size);
 
-	ret = simple_read_from_buffer(to, count, ppos, buf, size);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, size, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations debug_window_fops = {
 	.open = simple_open,
-	.read = debug_window_read,
+	.read_iter = debug_window_read,
 	.llseek = no_llseek,
 };
 
-static ssize_t probe_points_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
+static ssize_t probe_points_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
 	struct avs_probe_point_desc *desc;
 	size_t num_desc, len = 0;
 	char *buf;
 	int i, ret;
 
 	/* Prevent chaining, send and dump IPC value just once. */
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
@@ -127,7 +127,7 @@ static ssize_t probe_points_read(struct file *file, char __user *to, size_t coun
 		len += ret;
 	}
 
-	ret = simple_read_from_buffer(to, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 free_desc:
 	kfree(desc);
 exit:
@@ -135,16 +135,16 @@ static ssize_t probe_points_read(struct file *file, char __user *to, size_t coun
 	return ret;
 }
 
-static ssize_t probe_points_write(struct file *file, const char __user *from, size_t count,
-				  loff_t *ppos)
+static ssize_t probe_points_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct avs_probe_point_desc *desc;
 	u32 *array, num_elems;
 	size_t bytes;
 	int ret;
 
-	ret = parse_int_array_user(from, count, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -168,21 +168,22 @@ static ssize_t probe_points_write(struct file *file, const char __user *from, si
 
 static const struct file_operations probe_points_fops = {
 	.open = simple_open,
-	.read = probe_points_read,
-	.write = probe_points_write,
+	.read_iter = probe_points_read,
+	.write_iter = probe_points_write,
 	.llseek = no_llseek,
 };
 
-static ssize_t probe_points_disconnect_write(struct file *file, const char __user *from,
-					     size_t count, loff_t *ppos)
+static ssize_t probe_points_disconnect_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	union avs_probe_point_id *id;
 	u32 *array, num_elems;
 	size_t bytes;
 	int ret;
 
-	ret = parse_int_array_user(from, count, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -206,7 +207,7 @@ static ssize_t probe_points_disconnect_write(struct file *file, const char __use
 
 static const struct file_operations probe_points_disconnect_fops = {
 	.open = simple_open,
-	.write = probe_points_disconnect_write,
+	.write_iter = probe_points_disconnect_write,
 	.llseek = default_llseek,
 };
 
@@ -230,6 +231,7 @@ static ssize_t strace_read(struct file *file, char __user *to, size_t count, lof
 	*ppos += copied;
 	return copied;
 }
+FOPS_READ_ITER_HELPER(strace_read);
 
 static int strace_open(struct inode *inode, struct file *file)
 {
@@ -279,7 +281,7 @@ static int strace_release(struct inode *inode, struct file *file)
 
 static const struct file_operations strace_fops = {
 	.llseek = default_llseek,
-	.read = strace_read,
+	.read_iter = strace_read_iter,
 	.open = strace_open,
 	.release = strace_release,
 };
@@ -351,26 +353,25 @@ static int disable_logs(struct avs_dev *adev, u32 resource_mask)
 	return ret;
 }
 
-static ssize_t trace_control_read(struct file *file, char __user *to, size_t count, loff_t *ppos)
+static ssize_t trace_control_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
 	char buf[64];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "0x%08x\n", adev->logged_resources);
-
-	return simple_read_from_buffer(to, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t trace_control_write(struct file *file, const char __user *from, size_t count,
-				   loff_t *ppos)
+static ssize_t trace_control_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct avs_dev *adev = file->private_data;
+	struct avs_dev *adev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 *array, num_elems;
 	u32 resource_mask;
 	int ret;
 
-	ret = parse_int_array_user(from, count, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -403,8 +404,8 @@ static ssize_t trace_control_write(struct file *file, const char __user *from, s
 
 static const struct file_operations trace_control_fops = {
 	.llseek = default_llseek,
-	.read = trace_control_read,
-	.write = trace_control_write,
+	.read_iter = trace_control_read,
+	.write_iter = trace_control_write,
 	.open = simple_open,
 };
 
diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index 2cafbc392cdb..631cb410fdfe 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -792,10 +792,9 @@ const struct snd_soc_dai_ops avs_dai_fe_ops = {
 	.trigger = avs_dai_fe_trigger,
 };
 
-static ssize_t topology_name_read(struct file *file, char __user *user_buf, size_t count,
-				  loff_t *ppos)
+static ssize_t topology_name_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_soc_component *component = file->private_data;
+	struct snd_soc_component *component = iocb->ki_filp->private_data;
 	struct snd_soc_card *card = component->card;
 	struct snd_soc_acpi_mach *mach = dev_get_platdata(card->dev);
 	char buf[64];
@@ -804,12 +803,12 @@ static ssize_t topology_name_read(struct file *file, char __user *user_buf, size
 	len = scnprintf(buf, sizeof(buf), "%s/%s\n", component->driver->topology_name_prefix,
 			mach->tplg_filename);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations topology_name_fops = {
 	.open = simple_open,
-	.read = topology_name_read,
+	.read_iter = topology_name_read,
 	.llseek = default_llseek,
 };
 
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index a15aa2ffa681..a1715364729d 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -64,10 +64,9 @@ static ssize_t skl_print_fmt(struct skl_module_fmt *fmt, char *buf,
 			fmt->ch_map);
 }
 
-static ssize_t module_read(struct file *file, char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t module_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct skl_module_cfg *mconfig = file->private_data;
+	struct skl_module_cfg *mconfig = iocb->ki_filp->private_data;
 	struct skl_module *module = mconfig->module;
 	struct skl_module_res *res = &module->resources[mconfig->res_idx];
 	char *buf;
@@ -149,7 +148,7 @@ static ssize_t module_read(struct file *file, char __user *user_buf,
 			mconfig->dma_id, mconfig->mem_pages, mconfig->m_state,
 			mconfig->m_type);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 
 	kfree(buf);
 	return ret;
@@ -157,7 +156,7 @@ static ssize_t module_read(struct file *file, char __user *user_buf,
 
 static const struct file_operations mcfg_fops = {
 	.open = simple_open,
-	.read = module_read,
+	.read_iter = module_read,
 	.llseek = default_llseek,
 };
 
@@ -170,10 +169,9 @@ void skl_debug_init_module(struct skl_debug *d,
 			    &mcfg_fops);
 }
 
-static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t fw_softreg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct skl_debug *d = file->private_data;
+	struct skl_debug *d = iocb->ki_filp->private_data;
 	struct sst_dsp *sst = d->skl->dsp;
 	size_t w0_stat_sz = sst->addr.w0_stat_sz;
 	void __iomem *in_base = sst->mailbox.in_base;
@@ -203,15 +201,14 @@ static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
 			tmp[ret++] = '\n';
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, tmp, ret);
+	ret = simple_copy_to_iter(tmp, &iocb->ki_pos, ret, to);
 	kfree(tmp);
-
 	return ret;
 }
 
 static const struct file_operations soft_regs_ctrl_fops = {
 	.open = simple_open,
-	.read = fw_softreg_read,
+	.read_iter = fw_softreg_read,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 061/437] ASoC: fsl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (59 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 060/437] ASoC: Intel: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 062/437] ALSA: pcmtest: " Jens Axboe
                   ` (376 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/fsl/imx-audmux.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index 747ab2f1aae3..479fd59e329c 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -53,12 +53,11 @@ static const char *audmux_port_string(int port)
 	}
 }
 
-static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t audmux_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	char *buf;
-	uintptr_t port = (uintptr_t)file->private_data;
+	uintptr_t port = (uintptr_t)iocb->ki_filp->private_data;
 	u32 pdcr, ptcr;
 
 	ret = clk_prepare_enable(audmux_clk);
@@ -119,16 +118,14 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
 			"\nData received from %s\n",
 			audmux_port_string((pdcr >> 13) & 0x7));
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
-
 	return ret;
 }
 
 static const struct file_operations audmux_debugfs_fops = {
 	.open = simple_open,
-	.read = audmux_read_file,
+	.read_iter = audmux_read_file,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 062/437] ALSA: pcmtest: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (60 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 061/437] ASoC: fsl: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 063/437] sound/oss/dmasound: " Jens Axboe
                   ` (375 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/drivers/pcmtest.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c
index b8bff5522bce..8a09d82d2207 100644
--- a/sound/drivers/pcmtest.c
+++ b/sound/drivers/pcmtest.c
@@ -646,48 +646,48 @@ static struct platform_driver pcmtst_pdrv = {
 	},
 };
 
-static ssize_t pattern_write(struct file *file, const char __user *u_buff, size_t len, loff_t *off)
+static ssize_t pattern_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct pattern_buf *patt_buf = file->f_inode->i_private;
-	ssize_t to_write = len;
+	struct pattern_buf *patt_buf = iocb->ki_filp->f_inode->i_private;
+	ssize_t to_write = iov_iter_count(from);
 
-	if (*off + to_write > MAX_PATTERN_LEN)
-		to_write = MAX_PATTERN_LEN - *off;
+	if (iocb->ki_pos + to_write > MAX_PATTERN_LEN)
+		to_write = MAX_PATTERN_LEN - iocb->ki_pos;
 
 	// Crop silently everything over the buffer
 	if (to_write <= 0)
-		return len;
+		return iov_iter_count(from);
 
-	if (copy_from_user(patt_buf->buf + *off, u_buff, to_write))
+	if (!copy_from_iter_full(patt_buf->buf + iocb->ki_pos, to_write, from))
 		return -EFAULT;
 
-	patt_buf->len = *off + to_write;
-	*off += to_write;
+	patt_buf->len = iocb->ki_pos + to_write;
+	iocb->ki_pos += to_write;
 
 	return to_write;
 }
 
-static ssize_t pattern_read(struct file *file, char __user *u_buff, size_t len, loff_t *off)
+static ssize_t pattern_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct pattern_buf *patt_buf = file->f_inode->i_private;
-	ssize_t to_read = len;
+	struct pattern_buf *patt_buf = iocb->ki_filp->f_inode->i_private;
+	ssize_t to_read = iov_iter_count(to);
 
-	if (*off + to_read >= MAX_PATTERN_LEN)
-		to_read = MAX_PATTERN_LEN - *off;
+	if (iocb->ki_pos + to_read >= MAX_PATTERN_LEN)
+		to_read = MAX_PATTERN_LEN - iocb->ki_pos;
 	if (to_read <= 0)
 		return 0;
 
-	if (copy_to_user(u_buff, patt_buf->buf + *off, to_read))
+	if (!copy_to_iter_full(patt_buf->buf + iocb->ki_pos, to_read, to))
 		to_read = 0;
 	else
-		*off += to_read;
+		iocb->ki_pos += to_read;
 
 	return to_read;
 }
 
 static const struct file_operations fill_pattern_fops = {
-	.read = pattern_read,
-	.write = pattern_write,
+	.read_iter = pattern_read,
+	.write_iter = pattern_write,
 };
 
 static int setup_patt_bufs(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 063/437] sound/oss/dmasound: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (61 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 062/437] ALSA: pcmtest: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 064/437] ASoC: SOF: icp3-dtrace: " Jens Axboe
                   ` (374 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/oss/dmasound/dmasound_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index 164335d3c200..c702a8c5c668 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -1334,15 +1334,15 @@ static int state_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t state_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *ppos)
+static ssize_t state_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int n = state.len - state.ptr;
 	if (n > count)
 		n = count;
 	if (n <= 0)
 		return 0;
-	if (copy_to_user(buf, &state.buf[state.ptr], n))
+	if (!copy_to_iter_full(&state.buf[state.ptr], n, to))
 		return -EFAULT;
 	state.ptr += n;
 	return n;
@@ -1351,7 +1351,7 @@ static ssize_t state_read(struct file *file, char __user *buf, size_t count,
 static const struct file_operations state_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= state_read,
+	.read_iter	= state_read,
 	.open		= state_open,
 	.release	= state_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 064/437] ASoC: SOF: icp3-dtrace: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (62 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 063/437] sound/oss/dmasound: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 065/437] SoC: SOF: icp4: " Jens Axboe
                   ` (373 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/sof/ipc3-dtrace.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sof/ipc3-dtrace.c b/sound/soc/sof/ipc3-dtrace.c
index 0dca139322f3..e8cc151b8110 100644
--- a/sound/soc/sof/ipc3-dtrace.c
+++ b/sound/soc/sof/ipc3-dtrace.c
@@ -217,10 +217,11 @@ static ssize_t dfsentry_trace_filter_write(struct file *file, const char __user
 	kfree(elems);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dfsentry_trace_filter_write);
 
 static const struct file_operations sof_dfs_trace_filter_fops = {
 	.open = simple_open,
-	.write = dfsentry_trace_filter_write,
+	.write_iter = dfsentry_trace_filter_write_iter,
 	.llseek = default_llseek,
 };
 
@@ -313,14 +314,14 @@ static size_t sof_wait_dtrace_avail(struct snd_sof_dev *sdev, loff_t pos,
 	return sof_dtrace_avail(sdev, pos, buffer_size);
 }
 
-static ssize_t dfsentry_dtrace_read(struct file *file, char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t dfsentry_dtrace_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_sof_dfsentry *dfse = file->private_data;
+	struct snd_sof_dfsentry *dfse = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct snd_sof_dev *sdev = dfse->sdev;
 	struct sof_dtrace_priv *priv = sdev->fw_trace_data;
 	unsigned long rem;
-	loff_t lpos = *ppos;
+	loff_t lpos = iocb->ki_pos;
 	size_t avail, buffer_size = dfse->size;
 	u64 lpos_64;
 
@@ -360,11 +361,11 @@ static ssize_t dfsentry_dtrace_read(struct file *file, char __user *buffer,
 	 */
 	snd_dma_buffer_sync(&priv->dmatb, SNDRV_DMA_SYNC_CPU);
 	/* copy available trace data to debugfs */
-	rem = copy_to_user(buffer, ((u8 *)(dfse->buf) + lpos), count);
+	rem = !copy_to_iter_full(((u8 *)(dfse->buf) + lpos), count, to);
 	if (rem)
 		return -EFAULT;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 
 	/* move debugfs reading position */
 	return count;
@@ -385,7 +386,7 @@ static int dfsentry_dtrace_release(struct inode *inode, struct file *file)
 
 static const struct file_operations sof_dfs_dtrace_fops = {
 	.open = simple_open,
-	.read = dfsentry_dtrace_read,
+	.read_iter = dfsentry_dtrace_read,
 	.llseek = default_llseek,
 	.release = dfsentry_dtrace_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 065/437] SoC: SOF: icp4: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (63 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 064/437] ASoC: SOF: icp3-dtrace: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 066/437] ASoC: SOF: Core: " Jens Axboe
                   ` (372 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/sof/ipc4-mtrace.c    | 17 +++++++++--------
 sound/soc/sof/ipc4-telemetry.c | 14 +++++++-------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/sound/soc/sof/ipc4-mtrace.c b/sound/soc/sof/ipc4-mtrace.c
index 0e04bea9432d..976951a486b5 100644
--- a/sound/soc/sof/ipc4-mtrace.c
+++ b/sound/soc/sof/ipc4-mtrace.c
@@ -274,6 +274,7 @@ static ssize_t sof_ipc4_mtrace_dfs_read(struct file *file, char __user *buffer,
 
 	return count;
 }
+FOPS_READ_ITER_HELPER(sof_ipc4_mtrace_dfs_read);
 
 static int sof_ipc4_mtrace_dfs_release(struct inode *inode, struct file *file)
 {
@@ -291,17 +292,17 @@ static int sof_ipc4_mtrace_dfs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations sof_dfs_mtrace_fops = {
 	.open = sof_ipc4_mtrace_dfs_open,
-	.read = sof_ipc4_mtrace_dfs_read,
+	.read_iter = sof_ipc4_mtrace_dfs_read_iter,
 	.llseek = default_llseek,
 	.release = sof_ipc4_mtrace_dfs_release,
 
 	.owner = THIS_MODULE,
 };
 
-static ssize_t sof_ipc4_priority_mask_dfs_read(struct file *file, char __user *to,
-					       size_t count, loff_t *ppos)
+static ssize_t sof_ipc4_priority_mask_dfs_read(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct sof_mtrace_priv *priv = file->private_data;
+	struct sof_mtrace_priv *priv = iocb->ki_filp->private_data;
 	int i, ret, offset, remaining;
 	char *buf;
 
@@ -322,8 +323,7 @@ static ssize_t sof_ipc4_priority_mask_dfs_read(struct file *file, char __user *t
 			 priv->state_info.logs_priorities_mask[i]);
 	}
 
-	ret = simple_read_from_buffer(to, count, ppos, buf, strlen(buf));
-
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 	return ret;
 }
@@ -368,11 +368,12 @@ static ssize_t sof_ipc4_priority_mask_dfs_write(struct file *file,
 	kfree(buf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(sof_ipc4_priority_mask_dfs_write);
 
 static const struct file_operations sof_dfs_priority_mask_fops = {
 	.open = simple_open,
-	.read = sof_ipc4_priority_mask_dfs_read,
-	.write = sof_ipc4_priority_mask_dfs_write,
+	.read_iter = sof_ipc4_priority_mask_dfs_read,
+	.write_iter = sof_ipc4_priority_mask_dfs_write_iter,
 	.llseek = default_llseek,
 
 	.owner = THIS_MODULE,
diff --git a/sound/soc/sof/ipc4-telemetry.c b/sound/soc/sof/ipc4-telemetry.c
index ec4ae9674364..8b4ef6ae8753 100644
--- a/sound/soc/sof/ipc4-telemetry.c
+++ b/sound/soc/sof/ipc4-telemetry.c
@@ -32,13 +32,13 @@ static void __iomem *sof_ipc4_query_exception_address(struct snd_sof_dev *sdev)
 	return sdev->bar[sdev->mailbox_bar] + offset;
 }
 
-static ssize_t sof_telemetry_entry_read(struct file *file, char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t sof_telemetry_entry_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_sof_dfsentry *dfse = file->private_data;
+	struct snd_sof_dfsentry *dfse = iocb->ki_filp->private_data;
 	struct snd_sof_dev *sdev = dfse->sdev;
+	size_t count = iov_iter_count(to);
 	void __iomem *io_addr;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 	size_t size_ret;
 	u8 *buf;
 
@@ -59,13 +59,13 @@ static ssize_t sof_telemetry_entry_read(struct file *file, char __user *buffer,
 		return -ENOMEM;
 
 	memcpy_fromio(buf, io_addr, SOF_IPC4_DEBUG_SLOT_SIZE - 4);
-	size_ret = copy_to_user(buffer, buf + pos, count);
+	size_ret = !copy_to_iter_full(buf + pos, count, to);
 	if (size_ret) {
 		kfree(buf);
 		return -EFAULT;
 	}
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 	kfree(buf);
 
 	return count;
@@ -73,7 +73,7 @@ static ssize_t sof_telemetry_entry_read(struct file *file, char __user *buffer,
 
 static const struct file_operations sof_telemetry_fops = {
 	.open = simple_open,
-	.read = sof_telemetry_entry_read,
+	.read_iter = sof_telemetry_entry_read,
 };
 
 void sof_ipc4_create_exception_debugfs_node(struct snd_sof_dev *sdev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 066/437] ASoC: SOF: Core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (64 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 065/437] SoC: SOF: icp4: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 067/437] ASoC: SOF: " Jens Axboe
                   ` (371 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/sof/debug.c                         | 34 +++++-----
 sound/soc/sof/sof-client-ipc-flood-test.c     | 19 +++---
 .../soc/sof/sof-client-ipc-kernel-injector.c  | 15 +++--
 sound/soc/sof/sof-client-ipc-msg-injector.c   | 67 +++++++++----------
 sound/soc/sof/sof-client-probes.c             | 31 +++++----
 5 files changed, 85 insertions(+), 81 deletions(-)

diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c
index 7c8aafca8fde..c735af9a5f23 100644
--- a/sound/soc/sof/debug.c
+++ b/sound/soc/sof/debug.c
@@ -19,9 +19,9 @@
 #include "sof-priv.h"
 #include "ops.h"
 
-static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
-				  size_t count, loff_t *ppos)
+static ssize_t sof_dfsentry_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t size;
 	char *string;
 	int ret;
@@ -30,19 +30,19 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer,
 	if (!string)
 		return -ENOMEM;
 
-	size = simple_write_to_buffer(string, count, ppos, buffer, count);
+	size = simple_copy_from_iter(string, &iocb->ki_pos, count, from);
 	ret = size;
 
 	kfree(string);
 	return ret;
 }
 
-static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
-				 size_t count, loff_t *ppos)
+static ssize_t sof_dfsentry_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_sof_dfsentry *dfse = file->private_data;
+	struct snd_sof_dfsentry *dfse = iocb->ki_filp->private_data;
 	struct snd_sof_dev *sdev = dfse->sdev;
-	loff_t pos = *ppos;
+	size_t count = iov_iter_count(to);
+	loff_t pos = iocb->ki_pos;
 	size_t size_ret;
 	int skip = 0;
 	int size;
@@ -66,8 +66,8 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
 	size = ALIGN(count, 4);
 
 	/* if start position is unaligned, read extra u32 */
-	if (unlikely(pos != *ppos)) {
-		skip = *ppos - pos;
+	if (unlikely(pos != iocb->ki_pos)) {
+		skip = iocb->ki_pos - pos;
 		if (pos + size + 4 < dfse->size)
 			size += 4;
 	}
@@ -109,7 +109,7 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
 	}
 
 	/* copy to userspace */
-	size_ret = copy_to_user(buffer, buf + skip, count);
+	size_ret = !copy_to_iter_full(buf + skip, count, to);
 
 	kfree(buf);
 
@@ -117,16 +117,15 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer,
 	if (size_ret)
 		return -EFAULT;
 
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
 static const struct file_operations sof_dfs_fops = {
 	.open = simple_open,
-	.read = sof_dfsentry_read,
+	.read_iter = sof_dfsentry_read,
 	.llseek = default_llseek,
-	.write = sof_dfsentry_write,
+	.write_iter = sof_dfsentry_write,
 };
 
 /* create FS entry for debug files that can expose DSP memories, registers */
@@ -284,6 +283,11 @@ static ssize_t memory_info_read(struct file *file, char __user *to, size_t count
 	return simple_read_from_buffer(to, count, ppos, dfse->buf, dfse->buf_data_size);
 }
 
+static ssize_t memory_info_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, memory_info_read);
+}
+
 static int memory_info_open(struct inode *inode, struct file *file)
 {
 	struct snd_sof_dfsentry *dfse = inode->i_private;
@@ -304,7 +308,7 @@ static int memory_info_open(struct inode *inode, struct file *file)
 
 static const struct file_operations memory_info_fops = {
 	.open = memory_info_open,
-	.read = memory_info_read,
+	.read_iter = memory_info_read_iter,
 	.llseek = default_llseek,
 };
 
diff --git a/sound/soc/sof/sof-client-ipc-flood-test.c b/sound/soc/sof/sof-client-ipc-flood-test.c
index c0d6723aed59..6e53d60975c9 100644
--- a/sound/soc/sof/sof-client-ipc-flood-test.c
+++ b/sound/soc/sof/sof-client-ipc-flood-test.c
@@ -238,29 +238,30 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf
 	kfree(string);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(sof_ipc_flood_dfs_write);
 
 /* return the result of the last IPC flood test */
-static ssize_t sof_ipc_flood_dfs_read(struct file *file, char __user *buffer,
-				      size_t count, loff_t *ppos)
+static ssize_t sof_ipc_flood_dfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_ipc_flood_priv *priv = cdev->data;
+	size_t count = iov_iter_count(to);
 	size_t size_ret;
 
 	struct dentry *dentry;
 
-	dentry = file->f_path.dentry;
+	dentry = iocb->ki_filp->f_path.dentry;
 	if (!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_COUNT) ||
 	    !strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION)) {
-		if (*ppos)
+		if (iocb->ki_pos)
 			return 0;
 
 		count = min_t(size_t, count, strlen(priv->buf));
-		size_ret = copy_to_user(buffer, priv->buf, count);
+		size_ret = !copy_to_iter_full(priv->buf, count, to);
 		if (size_ret)
 			return -EFAULT;
 
-		*ppos += count;
+		iocb->ki_pos += count;
 		return count;
 	}
 	return count;
@@ -275,9 +276,9 @@ static int sof_ipc_flood_dfs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations sof_ipc_flood_fops = {
 	.open = sof_ipc_flood_dfs_open,
-	.read = sof_ipc_flood_dfs_read,
+	.read_iter = sof_ipc_flood_dfs_read,
 	.llseek = default_llseek,
-	.write = sof_ipc_flood_dfs_write,
+	.write_iter = sof_ipc_flood_dfs_write_iter,
 	.release = sof_ipc_flood_dfs_release,
 
 	.owner = THIS_MODULE,
diff --git a/sound/soc/sof/sof-client-ipc-kernel-injector.c b/sound/soc/sof/sof-client-ipc-kernel-injector.c
index ad0ed2d570a9..77f5d73a126e 100644
--- a/sound/soc/sof/sof-client-ipc-kernel-injector.c
+++ b/sound/soc/sof/sof-client-ipc-kernel-injector.c
@@ -37,21 +37,22 @@ static int sof_msg_inject_dfs_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t sof_kernel_msg_inject_dfs_write(struct file *file, const char __user *buffer,
-					       size_t count, loff_t *ppos)
+static ssize_t sof_kernel_msg_inject_dfs_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_msg_inject_priv *priv = cdev->data;
 	struct sof_ipc_cmd_hdr *hdr = priv->kernel_buffer;
 	struct device *dev = &cdev->auxdev.dev;
+	size_t count = iov_iter_count(from);
 	ssize_t size;
 	int ret;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
-	size = simple_write_to_buffer(priv->kernel_buffer, priv->max_msg_size,
-				      ppos, buffer, count);
+	size = simple_copy_from_iter(priv->kernel_buffer, &iocb->ki_pos,
+				      priv->max_msg_size, from);
 	if (size < 0)
 		return size;
 	if (size != count)
@@ -82,7 +83,7 @@ static int sof_msg_inject_dfs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations sof_kernel_msg_inject_fops = {
 	.open = sof_msg_inject_dfs_open,
-	.write = sof_kernel_msg_inject_dfs_write,
+	.write_iter = sof_kernel_msg_inject_dfs_write,
 	.release = sof_msg_inject_dfs_release,
 
 	.owner = THIS_MODULE,
diff --git a/sound/soc/sof/sof-client-ipc-msg-injector.c b/sound/soc/sof/sof-client-ipc-msg-injector.c
index e249d3a9afb5..e13f867b4e1e 100644
--- a/sound/soc/sof/sof-client-ipc-msg-injector.c
+++ b/sound/soc/sof/sof-client-ipc-msg-injector.c
@@ -49,37 +49,37 @@ static int sof_msg_inject_dfs_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t sof_msg_inject_dfs_read(struct file *file, char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t sof_msg_inject_dfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_msg_inject_priv *priv = cdev->data;
 	struct sof_ipc_reply *rhdr = priv->rx_buffer;
+	size_t count = iov_iter_count(to);
 
-	if (!rhdr->hdr.size || !count || *ppos)
+	if (!rhdr->hdr.size || !count || iocb->ki_pos)
 		return 0;
 
 	if (count > rhdr->hdr.size)
 		count = rhdr->hdr.size;
 
-	if (copy_to_user(buffer, priv->rx_buffer, count))
+	if (!copy_to_iter_full(priv->rx_buffer, count, to))
 		return -EFAULT;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
-static ssize_t sof_msg_inject_ipc4_dfs_read(struct file *file,
-					    char __user *buffer,
-					    size_t count, loff_t *ppos)
+static ssize_t sof_msg_inject_ipc4_dfs_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_msg_inject_priv *priv = cdev->data;
 	struct sof_ipc4_msg *ipc4_msg = priv->rx_buffer;
 	size_t header_size = sizeof(ipc4_msg->header_u64);
+	size_t count = iov_iter_count(to);
 	size_t remaining;
 
-	if (!ipc4_msg->header_u64 || !count || *ppos)
+	if (!ipc4_msg->header_u64 || !count || iocb->ki_pos)
 		return 0;
 
 	/* we need space for the header at minimum (u64) */
@@ -99,10 +99,10 @@ static ssize_t sof_msg_inject_ipc4_dfs_read(struct file *file,
 		remaining = count;
 
 	/* copy the header first */
-	if (copy_to_user(buffer, &ipc4_msg->header_u64, header_size))
+	if (!copy_to_iter_full(&ipc4_msg->header_u64, header_size, to))
 		return -EFAULT;
 
-	*ppos += header_size;
+	iocb->ki_pos += header_size;
 	remaining -= header_size;
 
 	if (!remaining)
@@ -112,10 +112,10 @@ static ssize_t sof_msg_inject_ipc4_dfs_read(struct file *file,
 		remaining = ipc4_msg->data_size;
 
 	/* Copy the payload */
-	if (copy_to_user(buffer + *ppos, ipc4_msg->data_ptr, remaining))
+	if (!copy_to_iter_full(ipc4_msg->data_ptr, remaining, to))
 		return -EFAULT;
 
-	*ppos += remaining;
+	iocb->ki_pos += remaining;
 	return count;
 }
 
@@ -145,19 +145,19 @@ static int sof_msg_inject_send_message(struct sof_client_dev *cdev)
 	return ret;
 }
 
-static ssize_t sof_msg_inject_dfs_write(struct file *file, const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t sof_msg_inject_dfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_msg_inject_priv *priv = cdev->data;
+	size_t count = iov_iter_count(from);
 	ssize_t size;
 	int ret;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
-	size = simple_write_to_buffer(priv->tx_buffer, priv->max_msg_size,
-				      ppos, buffer, count);
+	size = simple_copy_from_iter(priv->tx_buffer, &iocb->ki_pos,
+				     priv->max_msg_size, from);
 	if (size < 0)
 		return size;
 	if (size != count)
@@ -174,25 +174,25 @@ static ssize_t sof_msg_inject_dfs_write(struct file *file, const char __user *bu
 	return size;
 };
 
-static ssize_t sof_msg_inject_ipc4_dfs_write(struct file *file,
-					     const char __user *buffer,
-					     size_t count, loff_t *ppos)
+static ssize_t sof_msg_inject_ipc4_dfs_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_msg_inject_priv *priv = cdev->data;
 	struct sof_ipc4_msg *ipc4_msg = priv->tx_buffer;
+	size_t count = iov_iter_count(from);
 	size_t data_size;
 	int ret;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (count < sizeof(ipc4_msg->header_u64))
 		return -EINVAL;
 
 	/* copy the header first */
-	if (copy_from_user(&ipc4_msg->header_u64, buffer,
-			   sizeof(ipc4_msg->header_u64)))
+	if (!copy_from_iter_full(&ipc4_msg->header_u64,
+				 sizeof(ipc4_msg->header_u64), from))
 		return -EFAULT;
 
 	data_size = count - sizeof(ipc4_msg->header_u64);
@@ -200,8 +200,7 @@ static ssize_t sof_msg_inject_ipc4_dfs_write(struct file *file,
 		return -EINVAL;
 
 	/* Copy the payload */
-	if (copy_from_user(ipc4_msg->data_ptr,
-			   buffer + sizeof(ipc4_msg->header_u64), data_size))
+	if (!copy_from_iter_full(ipc4_msg->data_ptr, data_size, from))
 		return -EFAULT;
 
 	ipc4_msg->data_size = data_size;
@@ -230,8 +229,8 @@ static int sof_msg_inject_dfs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations sof_msg_inject_fops = {
 	.open = sof_msg_inject_dfs_open,
-	.read = sof_msg_inject_dfs_read,
-	.write = sof_msg_inject_dfs_write,
+	.read_iter = sof_msg_inject_dfs_read,
+	.write_iter = sof_msg_inject_dfs_write,
 	.llseek = default_llseek,
 	.release = sof_msg_inject_dfs_release,
 
@@ -240,8 +239,8 @@ static const struct file_operations sof_msg_inject_fops = {
 
 static const struct file_operations sof_msg_inject_ipc4_fops = {
 	.open = sof_msg_inject_dfs_open,
-	.read = sof_msg_inject_ipc4_dfs_read,
-	.write = sof_msg_inject_ipc4_dfs_write,
+	.read_iter = sof_msg_inject_ipc4_dfs_read,
+	.write_iter = sof_msg_inject_ipc4_dfs_write,
 	.llseek = default_llseek,
 	.release = sof_msg_inject_dfs_release,
 
diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c
index 30f771ac7bbf..d81da01b6d87 100644
--- a/sound/soc/sof/sof-client-probes.c
+++ b/sound/soc/sof/sof-client-probes.c
@@ -188,10 +188,10 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
 	.copy = sof_probes_compr_copy,
 };
 
-static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
-					  size_t count, loff_t *ppos)
+static ssize_t sof_probes_dfs_points_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_probes_priv *priv = cdev->data;
 	struct device *dev = &cdev->auxdev.dev;
 	struct sof_probe_point_desc *desc;
@@ -233,8 +233,7 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
 		}
 	}
 
-	ret = simple_read_from_buffer(to, count, ppos, buf, strlen(buf));
-
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(desc);
 
 pm_error:
@@ -249,13 +248,13 @@ static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
 }
 
 static ssize_t
-sof_probes_dfs_points_write(struct file *file, const char __user *from,
-			    size_t count, loff_t *ppos)
+sof_probes_dfs_points_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_probes_priv *priv = cdev->data;
 	const struct sof_probes_ipc_ops *ipc = priv->ipc_ops;
 	struct device *dev = &cdev->auxdev.dev;
+	size_t count = iov_iter_count(from);
 	struct sof_probe_point_desc *desc;
 	u32 num_elems, *array;
 	size_t bytes;
@@ -266,7 +265,7 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
 		return -ENOENT;
 	}
 
-	ret = parse_int_array_user(from, count, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -300,21 +299,21 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
 
 static const struct file_operations sof_probes_points_fops = {
 	.open = simple_open,
-	.read = sof_probes_dfs_points_read,
-	.write = sof_probes_dfs_points_write,
+	.read_iter = sof_probes_dfs_points_read,
+	.write_iter = sof_probes_dfs_points_write,
 	.llseek = default_llseek,
 
 	.owner = THIS_MODULE,
 };
 
 static ssize_t
-sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
-				   size_t count, loff_t *ppos)
+sof_probes_dfs_points_remove_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sof_client_dev *cdev = file->private_data;
+	struct sof_client_dev *cdev = iocb->ki_filp->private_data;
 	struct sof_probes_priv *priv = cdev->data;
 	const struct sof_probes_ipc_ops *ipc = priv->ipc_ops;
 	struct device *dev = &cdev->auxdev.dev;
+	size_t count = iov_iter_count(from);
 	int ret, err;
 	u32 *array;
 
@@ -323,7 +322,7 @@ sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
 		return -ENOENT;
 	}
 
-	ret = parse_int_array_user(from, count, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -348,7 +347,7 @@ sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
 
 static const struct file_operations sof_probes_points_remove_fops = {
 	.open = simple_open,
-	.write = sof_probes_dfs_points_remove_write,
+	.write_iter = sof_probes_dfs_points_remove_write,
 	.llseek = default_llseek,
 
 	.owner = THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 067/437] ASoC: SOF: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (65 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 066/437] ASoC: SOF: Core: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 068/437] block: " Jens Axboe
                   ` (370 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 sound/soc/soc-dapm.c | 21 ++++++++-------------
 sound/soc/soc-pcm.c  | 10 ++++------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index ad8ba8fbbaee..f3cfbf70f8a4 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2094,11 +2094,9 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t dapm_widget_power_read_file(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t dapm_widget_power_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_soc_dapm_widget *w = file->private_data;
+	struct snd_soc_dapm_widget *w = iocb->ki_filp->private_data;
 	enum snd_soc_dapm_direction dir, rdir;
 	char *buf;
 	int in, out;
@@ -2155,22 +2153,20 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
 
 	snd_soc_dapm_mutex_unlock(w->dapm);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
-
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations dapm_widget_power_fops = {
 	.open = simple_open,
-	.read = dapm_widget_power_read_file,
+	.read_iter = dapm_widget_power_read,
 	.llseek = default_llseek,
 };
 
-static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t dapm_bias_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_soc_dapm_context *dapm = file->private_data;
+	struct snd_soc_dapm_context *dapm = iocb->ki_filp->private_data;
 	char *level;
 
 	switch (dapm->bias_level) {
@@ -2192,13 +2188,12 @@ static ssize_t dapm_bias_read_file(struct file *file, char __user *user_buf,
 		break;
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos, level,
-				       strlen(level));
+	return simple_copy_to_iter(level, &iocb->ki_pos, strlen(level), to);
 }
 
 static const struct file_operations dapm_bias_fops = {
 	.open = simple_open,
-	.read = dapm_bias_read_file,
+	.read_iter = dapm_bias_read_file,
 	.llseek = default_llseek,
 };
 
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 77ee103b7cd1..611845526491 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -164,10 +164,9 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
 	return offset;
 }
 
-static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t dpcm_state_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snd_soc_pcm_runtime *fe = file->private_data;
+	struct snd_soc_pcm_runtime *fe = iocb->ki_filp->private_data;
 	ssize_t out_count = PAGE_SIZE, offset = 0, ret = 0;
 	int stream;
 	char *buf;
@@ -190,15 +189,14 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf,
 						  out_count - offset);
 	snd_soc_dpcm_mutex_unlock(fe);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, offset);
-
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, offset, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations dpcm_state_fops = {
 	.open = simple_open,
-	.read = dpcm_state_read_file,
+	.read_iter = dpcm_state_read,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 068/437] block: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (66 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 067/437] ASoC: SOF: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 069/437] bpf: " Jens Axboe
                   ` (369 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 block/blk-mq-debugfs.c | 20 ++++++++++----------
 block/blk-mq-debugfs.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 94668e72ab09..a9fa3d7311ac 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -119,9 +119,10 @@ static int queue_state_show(void *data, struct seq_file *m)
 	return 0;
 }
 
-static ssize_t queue_state_write(void *data, const char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t queue_state_write(void *data, struct kiocb *iocb,
+				 struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct request_queue *q = data;
 	char opbuf[16] = { }, *op;
 
@@ -137,7 +138,7 @@ static ssize_t queue_state_write(void *data, const char __user *buf,
 		goto inval;
 	}
 
-	if (copy_from_user(opbuf, buf, count))
+	if (!copy_from_iter_full(opbuf, count, from))
 		return -EFAULT;
 	op = strstrip(opbuf);
 	if (strcmp(op, "run") == 0) {
@@ -540,12 +541,11 @@ static int blk_mq_debugfs_show(struct seq_file *m, void *v)
 	return attr->show(data, m);
 }
 
-static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t blk_mq_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	const struct blk_mq_debugfs_attr *attr = m->private;
-	void *data = d_inode(file->f_path.dentry->d_parent)->i_private;
+	void *data = d_inode(iocb->ki_filp->f_path.dentry->d_parent)->i_private;
 
 	/*
 	 * Attributes that only implement .seq_ops are read-only and 'attr' is
@@ -554,7 +554,7 @@ static ssize_t blk_mq_debugfs_write(struct file *file, const char __user *buf,
 	if (attr == data || !attr->write)
 		return -EPERM;
 
-	return attr->write(data, buf, count, ppos);
+	return attr->write(data, iocb, from);
 }
 
 static int blk_mq_debugfs_open(struct inode *inode, struct file *file)
@@ -591,8 +591,8 @@ static int blk_mq_debugfs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations blk_mq_debugfs_fops = {
 	.open		= blk_mq_debugfs_open,
-	.read		= seq_read,
-	.write		= blk_mq_debugfs_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= blk_mq_debugfs_write,
 	.llseek		= seq_lseek,
 	.release	= blk_mq_debugfs_release,
 };
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index 9c7d4b6117d4..22c65e5ff430 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -12,7 +12,7 @@ struct blk_mq_debugfs_attr {
 	const char *name;
 	umode_t mode;
 	int (*show)(void *, struct seq_file *);
-	ssize_t (*write)(void *, const char __user *, size_t, loff_t *);
+	ssize_t (*write)(void *, struct kiocb *, struct iov_iter *);
 	/* Set either .show or .seq_ops. */
 	const struct seq_operations *seq_ops;
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 069/437] bpf: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (67 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 068/437] block: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 070/437] perf: convert events " Jens Axboe
                   ` (368 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/bpf/bpf_iter.c | 14 +++++++-------
 kernel/bpf/inode.c    |  2 +-
 kernel/bpf/syscall.c  | 18 ++++++++----------
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
index 112581cf97e7..f2bbe98234df 100644
--- a/kernel/bpf/bpf_iter.c
+++ b/kernel/bpf/bpf_iter.c
@@ -91,10 +91,10 @@ static bool bpf_iter_support_resched(struct seq_file *seq)
  *  . assuming NULL ->llseek()
  *  . stop() may call bpf program, handling potential overflow there
  */
-static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
-			    loff_t *ppos)
+static ssize_t bpf_seq_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	size_t n, offs, copied = 0;
 	int err = 0, num_objs = 0;
 	bool can_resched;
@@ -113,7 +113,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
 
 	if (seq->count) {
 		n = min(seq->count, size);
-		err = copy_to_user(buf, seq->buf + seq->from, n);
+		err = !copy_to_iter_full(seq->buf + seq->from, n, to);
 		if (err) {
 			err = -EFAULT;
 			goto done;
@@ -222,7 +222,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
 	}
 
 	n = min(seq->count, size);
-	err = copy_to_user(buf, seq->buf, n);
+	err = !copy_to_iter_full(seq->buf, n, to);
 	if (err) {
 		err = -EFAULT;
 		goto done;
@@ -234,7 +234,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
 	if (!copied)
 		copied = err;
 	else
-		*ppos += copied;
+		iocb->ki_pos += copied;
 	mutex_unlock(&seq->lock);
 	return copied;
 }
@@ -284,7 +284,7 @@ static int iter_release(struct inode *inode, struct file *file)
 const struct file_operations bpf_iter_fops = {
 	.open		= iter_open,
 	.llseek		= no_llseek,
-	.read		= bpf_seq_read,
+	.read_iter	= bpf_seq_read_iter,
 	.release	= iter_release,
 };
 
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index af5d2ffadd70..5e35f1eb1dec 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -313,7 +313,7 @@ static int bpffs_map_release(struct inode *inode, struct file *file)
  */
 static const struct file_operations bpffs_map_fops = {
 	.open		= bpffs_map_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.release	= bpffs_map_release,
 };
 
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index c287925471f6..385995dc69a0 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -872,8 +872,7 @@ static void bpf_map_show_fdinfo(struct seq_file *m, struct file *filp)
 }
 #endif
 
-static ssize_t bpf_dummy_read(struct file *filp, char __user *buf, size_t siz,
-			      loff_t *ppos)
+static ssize_t bpf_dummy_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	/* We need this handler such that alloc_file() enables
 	 * f_mode with FMODE_CAN_READ.
@@ -881,8 +880,7 @@ static ssize_t bpf_dummy_read(struct file *filp, char __user *buf, size_t siz,
 	return -EINVAL;
 }
 
-static ssize_t bpf_dummy_write(struct file *filp, const char __user *buf,
-			       size_t siz, loff_t *ppos)
+static ssize_t bpf_dummy_write(struct kiocb *iocb, struct iov_iter *to)
 {
 	/* We need this handler such that alloc_file() enables
 	 * f_mode with FMODE_CAN_WRITE.
@@ -991,8 +989,8 @@ const struct file_operations bpf_map_fops = {
 	.show_fdinfo	= bpf_map_show_fdinfo,
 #endif
 	.release	= bpf_map_release,
-	.read		= bpf_dummy_read,
-	.write		= bpf_dummy_write,
+	.read_iter	= bpf_dummy_read,
+	.write_iter	= bpf_dummy_write,
 	.mmap		= bpf_map_mmap,
 	.poll		= bpf_map_poll,
 	.get_unmapped_area = bpf_get_unmapped_area,
@@ -2378,8 +2376,8 @@ const struct file_operations bpf_prog_fops = {
 	.show_fdinfo	= bpf_prog_show_fdinfo,
 #endif
 	.release	= bpf_prog_release,
-	.read		= bpf_dummy_read,
-	.write		= bpf_dummy_write,
+	.read_iter	= bpf_dummy_read,
+	.write_iter	= bpf_dummy_write,
 };
 
 int bpf_prog_new_fd(struct bpf_prog *prog)
@@ -3142,8 +3140,8 @@ static const struct file_operations bpf_link_fops = {
 	.show_fdinfo	= bpf_link_show_fdinfo,
 #endif
 	.release	= bpf_link_release,
-	.read		= bpf_dummy_read,
-	.write		= bpf_dummy_write,
+	.read_iter	= bpf_dummy_read,
+	.write_iter	= bpf_dummy_write,
 };
 
 static int bpf_link_alloc_id(struct bpf_link *link)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 070/437] perf: convert events to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (68 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 069/437] bpf: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 071/437] dma-debug: convert " Jens Axboe
                   ` (367 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/events/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 724e6d7e128f..2c94801bef4b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5688,6 +5688,7 @@ perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(perf_read);
 
 static __poll_t perf_poll(struct file *file, poll_table *wait)
 {
@@ -6669,7 +6670,7 @@ static int perf_fasync(int fd, struct file *filp, int on)
 static const struct file_operations perf_fops = {
 	.llseek			= no_llseek,
 	.release		= perf_release,
-	.read			= perf_read,
+	.read_iter		= perf_read_iter,
 	.poll			= perf_poll,
 	.unlocked_ioctl		= perf_ioctl,
 	.compat_ioctl		= perf_compat_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 071/437] dma-debug: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (69 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 070/437] perf: convert events " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 072/437] kernel/fail_function: " Jens Axboe
                   ` (366 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/dma/debug.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index a6e3792b15f8..4be49922129b 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -717,8 +717,7 @@ static void dma_entry_free(struct dma_debug_entry *entry)
  *   2. Preallocate a given number of dma_debug_entry structs
  */
 
-static ssize_t filter_read(struct file *file, char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t filter_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[NAME_MAX_LEN + 1];
 	unsigned long flags;
@@ -736,12 +735,12 @@ static ssize_t filter_read(struct file *file, char __user *user_buf,
 	len = scnprintf(buf, NAME_MAX_LEN + 1, "%s\n", current_driver_name);
 	read_unlock_irqrestore(&driver_name_lock, flags);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t filter_write(struct file *file, const char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t filter_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[NAME_MAX_LEN];
 	unsigned long flags;
 	size_t len;
@@ -754,7 +753,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
 	 * need to copy to temporary buffer first
 	 */
 	len = min(count, (size_t)(NAME_MAX_LEN - 1));
-	if (copy_from_user(buf, userbuf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = 0;
@@ -804,8 +803,8 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
 }
 
 static const struct file_operations filter_fops = {
-	.read  = filter_read,
-	.write = filter_write,
+	.read_iter  = filter_read,
+	.write_iter = filter_write,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 072/437] kernel/fail_function: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (70 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 071/437] dma-debug: convert " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 073/437] kcsan: " Jens Axboe
                   ` (365 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/fail_function.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/fail_function.c b/kernel/fail_function.c
index d971a0189319..de35a346899c 100644
--- a/kernel/fail_function.c
+++ b/kernel/fail_function.c
@@ -233,9 +233,9 @@ static void fei_attr_remove_all(void)
 	}
 }
 
-static ssize_t fei_write(struct file *file, const char __user *buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t fei_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct fei_attr *attr;
 	unsigned long addr;
 	char *buf, *sym;
@@ -245,7 +245,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 	if (count > KSYM_NAME_LEN)
 		count = KSYM_NAME_LEN;
 
-	buf = memdup_user_nul(buffer, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -306,8 +306,8 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
 
 static const struct file_operations fei_ops = {
 	.open =		fei_open,
-	.read =		seq_read,
-	.write =	fei_write,
+	.read_iter =	seq_read_iter,
+	.write_iter =	fei_write,
 	.llseek =	seq_lseek,
 	.release =	seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 073/437] kcsan: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (71 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 072/437] kernel/fail_function: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 074/437] module: " Jens Axboe
                   ` (364 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/kcsan/debugfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index 1d1d1b0e4248..71f444ddc27e 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -220,14 +220,14 @@ static int debugfs_open(struct inode *inode, struct file *file)
 	return single_open(file, show_info, NULL);
 }
 
-static ssize_t
-debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
+static ssize_t debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char kbuf[KSYM_NAME_LEN];
 	char *arg;
+	size_t count = iov_iter_count(from);
 	int read_len = count < (sizeof(kbuf) - 1) ? count : (sizeof(kbuf) - 1);
 
-	if (copy_from_user(kbuf, buf, read_len))
+	if (!copy_from_iter_full(kbuf, read_len, from))
 		return -EFAULT;
 	kbuf[read_len] = '\0';
 	arg = strstrip(kbuf);
@@ -260,9 +260,9 @@ debugfs_write(struct file *file, const char __user *buf, size_t count, loff_t *o
 
 static const struct file_operations debugfs_ops =
 {
-	.read	 = seq_read,
+	.read_iter	 = seq_read_iter,
 	.open	 = debugfs_open,
-	.write	 = debugfs_write,
+	.write_iter	 = debugfs_write,
 	.release = single_release
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 074/437] module: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (72 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 073/437] kcsan: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 075/437] kernel/power: " Jens Axboe
                   ` (363 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/module/stats.c    | 8 ++++----
 kernel/module/tracking.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/module/stats.c b/kernel/module/stats.c
index 3ba0e98b3c91..42bb95beb834 100644
--- a/kernel/module/stats.c
+++ b/kernel/module/stats.c
@@ -270,8 +270,7 @@ int try_add_failed_module(const char *name, enum fail_dup_mod_reason reason)
 #define MAX_PREAMBLE 1024
 #define MAX_FAILED_MOD_PRINT 112
 #define MAX_BYTES_PER_MOD 64
-static ssize_t read_file_mod_stats(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_mod_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mod_fail_load *mod_fail;
 	unsigned int len, size, count_failed = 0;
@@ -391,16 +390,17 @@ static ssize_t read_file_mod_stats(struct file *file, char __user *user_buf,
 out_unlock:
 	mutex_unlock(&module_mutex);
 out:
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret;
 }
+
 #undef MAX_PREAMBLE
 #undef MAX_FAILED_MOD_PRINT
 #undef MAX_BYTES_PER_MOD
 
 static const struct file_operations fops_mod_stats = {
-	.read = read_file_mod_stats,
+	.read_iter = read_file_mod_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/kernel/module/tracking.c b/kernel/module/tracking.c
index 16742d1c630c..a163944f609d 100644
--- a/kernel/module/tracking.c
+++ b/kernel/module/tracking.c
@@ -114,7 +114,7 @@ static int unloaded_tainted_modules_open(struct inode *inode, struct file *file)
 
 static const struct file_operations unloaded_tainted_modules_fops = {
 	.open = unloaded_tainted_modules_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 075/437] kernel/power: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (73 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 074/437] module: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 076/437] printk: " Jens Axboe
                   ` (362 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/power/qos.c  | 21 ++++++++++-----------
 kernel/power/user.c | 28 ++++++++++++----------------
 2 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 4244b069442e..eeea74bc639a 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -363,10 +363,9 @@ static int cpu_latency_qos_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t cpu_latency_qos_read(struct file *filp, char __user *buf,
-				    size_t count, loff_t *f_pos)
+static ssize_t cpu_latency_qos_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct pm_qos_request *req = filp->private_data;
+	struct pm_qos_request *req = iocb->ki_filp->private_data;
 	unsigned long flags;
 	s32 value;
 
@@ -377,33 +376,33 @@ static ssize_t cpu_latency_qos_read(struct file *filp, char __user *buf,
 	value = pm_qos_get_value(&cpu_latency_constraints);
 	spin_unlock_irqrestore(&pm_qos_lock, flags);
 
-	return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32));
+	return simple_copy_to_iter(&value, &iocb->ki_pos, sizeof(s32), to);
 }
 
-static ssize_t cpu_latency_qos_write(struct file *filp, const char __user *buf,
-				     size_t count, loff_t *f_pos)
+static ssize_t cpu_latency_qos_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	s32 value;
 
 	if (count == sizeof(s32)) {
-		if (copy_from_user(&value, buf, sizeof(s32)))
+		if (!copy_from_iter_full(&value, sizeof(s32), from))
 			return -EFAULT;
 	} else {
 		int ret;
 
-		ret = kstrtos32_from_user(buf, count, 16, &value);
+		ret = kstrtos32_from_iter(from, count, 16, &value);
 		if (ret)
 			return ret;
 	}
 
-	cpu_latency_qos_update_request(filp->private_data, value);
+	cpu_latency_qos_update_request(iocb->ki_filp->private_data, value);
 
 	return count;
 }
 
 static const struct file_operations cpu_latency_qos_fops = {
-	.write = cpu_latency_qos_write,
-	.read = cpu_latency_qos_read,
+	.write_iter = cpu_latency_qos_write,
+	.read_iter = cpu_latency_qos_read,
 	.open = cpu_latency_qos_open,
 	.release = cpu_latency_qos_release,
 	.llseek = noop_llseek,
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 3aa41ba22129..1dcdfbf240a9 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -131,17 +131,16 @@ static int snapshot_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t snapshot_read(struct file *filp, char __user *buf,
-                             size_t count, loff_t *offp)
+static ssize_t snapshot_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pg_offp = *offp & ~PAGE_MASK;
+	loff_t pg_offp = iocb->ki_pos & ~PAGE_MASK;
 	struct snapshot_data *data;
 	unsigned int sleep_flags;
 	ssize_t res;
 
 	sleep_flags = lock_system_sleep();
 
-	data = filp->private_data;
+	data = iocb->ki_filp->private_data;
 	if (!data->ready) {
 		res = -ENODATA;
 		goto Unlock;
@@ -154,10 +153,9 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
 		res = PAGE_SIZE - pg_offp;
 	}
 
-	res = simple_read_from_buffer(buf, count, &pg_offp,
-			data_of(data->handle), res);
+	res = simple_copy_to_iter(data_of(data->handle), &iocb->ki_pos, res, to);
 	if (res > 0)
-		*offp += res;
+		iocb->ki_pos += res;
 
  Unlock:
 	unlock_system_sleep(sleep_flags);
@@ -165,10 +163,9 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
 	return res;
 }
 
-static ssize_t snapshot_write(struct file *filp, const char __user *buf,
-                              size_t count, loff_t *offp)
+static ssize_t snapshot_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	loff_t pg_offp = *offp & ~PAGE_MASK;
+	loff_t pg_offp = iocb->ki_pos & ~PAGE_MASK;
 	struct snapshot_data *data;
 	unsigned long sleep_flags;
 	ssize_t res;
@@ -180,7 +177,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
 
 	sleep_flags = lock_system_sleep();
 
-	data = filp->private_data;
+	data = iocb->ki_filp->private_data;
 
 	if (!pg_offp) {
 		res = snapshot_write_next(&data->handle);
@@ -195,10 +192,9 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
 		goto unlock;
 	}
 
-	res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp,
-			buf, count);
+	res = simple_copy_from_iter(data_of(data->handle), &iocb->ki_pos, res, from);
 	if (res > 0)
-		*offp += res;
+		iocb->ki_pos += res;
 unlock:
 	unlock_system_sleep(sleep_flags);
 
@@ -445,8 +441,8 @@ snapshot_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations snapshot_fops = {
 	.open = snapshot_open,
 	.release = snapshot_release,
-	.read = snapshot_read,
-	.write = snapshot_write,
+	.read_iter = snapshot_read,
+	.write_iter = snapshot_write,
 	.llseek = no_llseek,
 	.unlocked_ioctl = snapshot_ioctl,
 #ifdef CONFIG_COMPAT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 076/437] printk: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (74 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 075/437] kernel/power: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 077/437] relay: " Jens Axboe
                   ` (361 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/printk/printk.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index adf99c05adca..a383f92915e3 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -787,11 +787,11 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 	return ret;
 }
 
-static ssize_t devkmsg_read(struct file *file, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t devkmsg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct devkmsg_user *user = file->private_data;
+	struct devkmsg_user *user = iocb->ki_filp->private_data;
 	char *outbuf = &user->pbufs.outbuf[0];
+	size_t count = iov_iter_count(to);
 	struct printk_message pmsg = {
 		.pbufs = &user->pbufs,
 	};
@@ -802,7 +802,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
 		return ret;
 
 	if (!printk_get_next_message(&pmsg, atomic64_read(&user->seq), true, false)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto out;
 		}
@@ -838,7 +838,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf,
 		goto out;
 	}
 
-	if (copy_to_user(buf, outbuf, pmsg.outbuf_len)) {
+	if (!copy_to_iter_full(outbuf, pmsg.outbuf_len, to)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -950,7 +950,7 @@ static int devkmsg_release(struct inode *inode, struct file *file)
 
 const struct file_operations kmsg_fops = {
 	.open = devkmsg_open,
-	.read = devkmsg_read,
+	.read_iter = devkmsg_read,
 	.write_iter = devkmsg_write,
 	.llseek = devkmsg_llseek,
 	.poll = devkmsg_poll,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 077/437] relay: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (75 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 076/437] printk: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 078/437] kernel/time: " Jens Axboe
                   ` (360 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/relay.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index a8e90e98bf2c..d34f5b0e4e53 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1030,12 +1030,10 @@ static size_t relay_file_read_end_pos(struct rchan_buf *buf,
 	return end_pos;
 }
 
-static ssize_t relay_file_read(struct file *filp,
-			       char __user *buffer,
-			       size_t count,
-			       loff_t *ppos)
+static ssize_t relay_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rchan_buf *buf = filp->private_data;
+	struct rchan_buf *buf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	size_t read_start, avail;
 	size_t written = 0;
 	int ret;
@@ -1043,7 +1041,7 @@ static ssize_t relay_file_read(struct file *filp,
 	if (!count)
 		return 0;
 
-	inode_lock(file_inode(filp));
+	inode_lock(file_inode(iocb->ki_filp));
 	do {
 		void *from;
 
@@ -1058,27 +1056,25 @@ static ssize_t relay_file_read(struct file *filp,
 		avail = min(count, avail);
 		from = buf->start + read_start;
 		ret = avail;
-		if (copy_to_user(buffer, from, avail))
+		if (!copy_to_iter_full(from, avail, to))
 			break;
 
-		buffer += ret;
 		written += ret;
 		count -= ret;
 
 		relay_file_read_consume(buf, read_start, ret);
-		*ppos = relay_file_read_end_pos(buf, read_start, ret);
+		iocb->ki_pos = relay_file_read_end_pos(buf, read_start, ret);
 	} while (count);
-	inode_unlock(file_inode(filp));
+	inode_unlock(file_inode(iocb->ki_filp));
 
 	return written;
 }
 
-
 const struct file_operations relay_file_operations = {
 	.open		= relay_file_open,
 	.poll		= relay_file_poll,
 	.mmap		= relay_file_mmap,
-	.read		= relay_file_read,
+	.read_iter	= relay_file_read,
 	.llseek		= no_llseek,
 	.release	= relay_file_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 078/437] kernel/time: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (76 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 077/437] relay: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 079/437] rv: " Jens Axboe
                   ` (359 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/time/posix-clock.c |  3 ++-
 kernel/time/test_udelay.c | 10 +++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 4782edcbe7b9..766ff113753a 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -54,6 +54,7 @@ static ssize_t posix_clock_read(struct file *fp, char __user *buf,
 
 	return err;
 }
+FOPS_READ_ITER_HELPER(posix_clock_read);
 
 static __poll_t posix_clock_poll(struct file *fp, poll_table *wait)
 {
@@ -169,7 +170,7 @@ static int posix_clock_release(struct inode *inode, struct file *fp)
 static const struct file_operations posix_clock_file_operations = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= posix_clock_read,
+	.read_iter	= posix_clock_read_iter,
 	.poll		= posix_clock_poll,
 	.unlocked_ioctl	= posix_clock_ioctl,
 	.open		= posix_clock_open,
diff --git a/kernel/time/test_udelay.c b/kernel/time/test_udelay.c
index 20d5df631570..9b6e832f4f47 100644
--- a/kernel/time/test_udelay.c
+++ b/kernel/time/test_udelay.c
@@ -96,9 +96,9 @@ static int udelay_test_open(struct inode *inode, struct file *file)
 	return single_open(file, udelay_test_show, inode->i_private);
 }
 
-static ssize_t udelay_test_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *pos)
+static ssize_t udelay_test_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char lbuf[32];
 	int ret;
 	int usecs;
@@ -107,7 +107,7 @@ static ssize_t udelay_test_write(struct file *file, const char __user *buf,
 	if (count >= sizeof(lbuf))
 		return -EINVAL;
 
-	if (copy_from_user(lbuf, buf, count))
+	if (!copy_from_iter_full(lbuf, count, from))
 		return -EFAULT;
 	lbuf[count] = '\0';
 
@@ -128,8 +128,8 @@ static ssize_t udelay_test_write(struct file *file, const char __user *buf,
 static const struct file_operations udelay_test_debugfs_ops = {
 	.owner = THIS_MODULE,
 	.open = udelay_test_open,
-	.read = seq_read,
-	.write = udelay_test_write,
+	.read_iter = seq_read_iter,
+	.write_iter = udelay_test_write,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 079/437] rv: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (77 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 078/437] kernel/time: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 080/437] tracing: " Jens Axboe
                   ` (358 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/trace/rv/rv.c          | 58 +++++++++++++++++------------------
 kernel/trace/rv/rv_reactors.c | 32 +++++++++----------
 2 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
index 2f68e93fff0b..7402b77a1b89 100644
--- a/kernel/trace/rv/rv.c
+++ b/kernel/trace/rv/rv.c
@@ -209,15 +209,14 @@ void rv_put_task_monitor_slot(int slot)
 /*
  * This section collects the monitor/ files and folders.
  */
-static ssize_t monitor_enable_read_data(struct file *filp, char __user *user_buf, size_t count,
-					loff_t *ppos)
+static ssize_t monitor_enable_read_data(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rv_monitor_def *mdef = filp->private_data;
+	struct rv_monitor_def *mdef = iocb->ki_filp->private_data;
 	const char *buff;
 
 	buff = mdef->monitor->enabled ? "1\n" : "0\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff)+1);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff)+1, to);
 }
 
 /*
@@ -279,14 +278,15 @@ int rv_enable_monitor(struct rv_monitor_def *mdef)
 /*
  * interface for enabling/disabling a monitor.
  */
-static ssize_t monitor_enable_write_data(struct file *filp, const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t monitor_enable_write_data(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct rv_monitor_def *mdef = filp->private_data;
+	struct rv_monitor_def *mdef = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int retval;
 	bool val;
 
-	retval = kstrtobool_from_user(user_buf, count, &val);
+	retval = kstrtobool_from_iter(from, count, &val);
 	if (retval)
 		return retval;
 
@@ -305,30 +305,29 @@ static ssize_t monitor_enable_write_data(struct file *filp, const char __user *u
 static const struct file_operations interface_enable_fops = {
 	.open   = simple_open,
 	.llseek = no_llseek,
-	.write  = monitor_enable_write_data,
-	.read   = monitor_enable_read_data,
+	.write_iter  = monitor_enable_write_data,
+	.read_iter   = monitor_enable_read_data,
 };
 
 /*
  * Interface to read monitors description.
  */
-static ssize_t monitor_desc_read_data(struct file *filp, char __user *user_buf, size_t count,
-				      loff_t *ppos)
+static ssize_t monitor_desc_read_data(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rv_monitor_def *mdef = filp->private_data;
+	struct rv_monitor_def *mdef = iocb->ki_filp->private_data;
 	char buff[256];
 
 	memset(buff, 0, sizeof(buff));
 
 	snprintf(buff, sizeof(buff), "%s\n", mdef->monitor->description);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff) + 1);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff) + 1, to);
 }
 
 static const struct file_operations interface_desc_fops = {
 	.open   = simple_open,
 	.llseek	= no_llseek,
-	.read	= monitor_desc_read_data,
+	.read_iter = monitor_desc_read_data,
 };
 
 /*
@@ -469,7 +468,7 @@ static int available_monitors_open(struct inode *inode, struct file *file)
 
 static const struct file_operations available_monitors_ops = {
 	.open    = available_monitors_open,
-	.read    = seq_read,
+	.read_iter    = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -507,10 +506,10 @@ static int enabled_monitors_open(struct inode *inode, struct file *file)
 	return seq_open(file, &enabled_monitors_seq_ops);
 };
 
-static ssize_t enabled_monitors_write(struct file *filp, const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t enabled_monitors_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buff[MAX_RV_MONITOR_NAME_SIZE + 2];
+	size_t count = iov_iter_count(from);
 	struct rv_monitor_def *mdef;
 	int retval = -EINVAL;
 	bool enable = true;
@@ -522,7 +521,8 @@ static ssize_t enabled_monitors_write(struct file *filp, const char __user *user
 
 	memset(buff, 0, sizeof(buff));
 
-	retval = simple_write_to_buffer(buff, sizeof(buff) - 1, ppos, user_buf, count);
+	retval = simple_copy_from_iter(buff, &iocb->ki_pos, sizeof(buff) - 1,
+					from);
 	if (retval < 0)
 		return -EFAULT;
 
@@ -565,8 +565,8 @@ static ssize_t enabled_monitors_write(struct file *filp, const char __user *user
 
 static const struct file_operations enabled_monitors_ops = {
 	.open		= enabled_monitors_open,
-	.read		= seq_read,
-	.write		= enabled_monitors_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= enabled_monitors_write,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -591,14 +591,13 @@ bool rv_monitoring_on(void)
 /*
  * monitoring_on general switcher.
  */
-static ssize_t monitoring_on_read_data(struct file *filp, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t monitoring_on_read_data(struct kiocb *iocb, struct iov_iter *to)
 {
 	const char *buff;
 
 	buff = rv_monitoring_on() ? "1\n" : "0\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff) + 1);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff) + 1, to);
 }
 
 static void turn_monitoring_off(void)
@@ -642,13 +641,14 @@ static void turn_monitoring_on_with_reset(void)
 	turn_monitoring_on();
 }
 
-static ssize_t monitoring_on_write_data(struct file *filp, const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t monitoring_on_write_data(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int retval;
 	bool val;
 
-	retval = kstrtobool_from_user(user_buf, count, &val);
+	retval = kstrtobool_from_iter(from, count, &val);
 	if (retval)
 		return retval;
 
@@ -673,8 +673,8 @@ static ssize_t monitoring_on_write_data(struct file *filp, const char __user *us
 static const struct file_operations monitoring_on_fops = {
 	.open   = simple_open,
 	.llseek = no_llseek,
-	.write  = monitoring_on_write_data,
-	.read   = monitoring_on_read_data,
+	.write_iter  = monitoring_on_write_data,
+	.read_iter   = monitoring_on_read_data,
 };
 
 static void destroy_monitor_dir(struct rv_monitor_def *mdef)
diff --git a/kernel/trace/rv/rv_reactors.c b/kernel/trace/rv/rv_reactors.c
index 6aae106695b6..0649acd03726 100644
--- a/kernel/trace/rv/rv_reactors.c
+++ b/kernel/trace/rv/rv_reactors.c
@@ -128,7 +128,7 @@ static int available_reactors_open(struct inode *inode, struct file *file)
 
 static const struct file_operations available_reactors_ops = {
 	.open    = available_reactors_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release
 };
@@ -183,11 +183,10 @@ static void monitor_swap_reactors(struct rv_monitor_def *mdef, struct rv_reactor
 		rv_enable_monitor(mdef);
 }
 
-static ssize_t
-monitor_reactors_write(struct file *file, const char __user *user_buf,
-		      size_t count, loff_t *ppos)
+static ssize_t monitor_reactors_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buff[MAX_RV_REACTOR_NAME_SIZE + 2];
+	size_t count = iov_iter_count(from);
 	struct rv_monitor_def *mdef;
 	struct rv_reactor_def *rdef;
 	struct seq_file *seq_f;
@@ -201,7 +200,8 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
 
 	memset(buff, 0, sizeof(buff));
 
-	retval = simple_write_to_buffer(buff, sizeof(buff) - 1, ppos, user_buf, count);
+	retval = simple_copy_from_iter(buff, &iocb->ki_pos, sizeof(buff) - 1,
+					from);
 	if (retval < 0)
 		return -EFAULT;
 
@@ -214,7 +214,7 @@ monitor_reactors_write(struct file *file, const char __user *user_buf,
 	/*
 	 * See monitor_reactors_open()
 	 */
-	seq_f = file->private_data;
+	seq_f = iocb->ki_filp->private_data;
 	mdef = seq_f->private;
 
 	mutex_lock(&rv_interface_lock);
@@ -269,10 +269,10 @@ static int monitor_reactors_open(struct inode *inode, struct file *file)
 
 static const struct file_operations monitor_reactors_ops = {
 	.open    = monitor_reactors_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release,
-	.write = monitor_reactors_write
+	.write_iter = monitor_reactors_write
 };
 
 static int __rv_register_reactor(struct rv_reactor *reactor)
@@ -371,15 +371,13 @@ bool rv_reacting_on(void)
 	return READ_ONCE(reacting_on);
 }
 
-static ssize_t reacting_on_read_data(struct file *filp,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t reacting_on_read_data(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 
 	buff = rv_reacting_on() ? "1\n" : "0\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, strlen(buff)+1);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff)+1, to);
 }
 
 static void turn_reacting_off(void)
@@ -396,13 +394,13 @@ static void turn_reacting_on(void)
 	smp_wmb();
 }
 
-static ssize_t reacting_on_write_data(struct file *filp, const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t reacting_on_write_data(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int retval;
 	bool val;
 
-	retval = kstrtobool_from_user(user_buf, count, &val);
+	retval = kstrtobool_from_iter(from, count, &val);
 	if (retval)
 		return retval;
 
@@ -427,8 +425,8 @@ static ssize_t reacting_on_write_data(struct file *filp, const char __user *user
 static const struct file_operations reacting_on_fops = {
 	.open   = simple_open,
 	.llseek = no_llseek,
-	.write  = reacting_on_write_data,
-	.read   = reacting_on_read_data,
+	.write_iter  = reacting_on_write_data,
+	.read_iter   = reacting_on_read_data,
 };
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 080/437] tracing: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (78 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 079/437] rv: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 081/437] gcov: " Jens Axboe
                   ` (357 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/ftrace.h                |  11 +-
 kernel/trace/blktrace.c               |  19 +-
 kernel/trace/ftrace.c                 |  68 +++--
 kernel/trace/trace.c                  | 386 ++++++++++++--------------
 kernel/trace/trace_dynevent.c         |   5 +-
 kernel/trace/trace_events.c           | 116 ++++----
 kernel/trace/trace_events_hist.c      |   4 +-
 kernel/trace/trace_events_inject.c    |  19 +-
 kernel/trace/trace_events_synth.c     |   5 +-
 kernel/trace/trace_events_trigger.c   |  22 +-
 kernel/trace/trace_events_user.c      |  17 +-
 kernel/trace/trace_functions_graph.c  |  20 +-
 kernel/trace/trace_hwlat.c            |  20 +-
 kernel/trace/trace_kprobe.c           |   7 +-
 kernel/trace/trace_osnoise.c          |  42 ++-
 kernel/trace/trace_printk.c           |   2 +-
 kernel/trace/trace_recursion_record.c |  10 +-
 kernel/trace/trace_sched_switch.c     |  21 +-
 kernel/trace/trace_stack.c            |  27 +-
 kernel/trace/trace_stat.c             |   2 +-
 kernel/trace/trace_uprobe.c           |   7 +-
 21 files changed, 378 insertions(+), 452 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 54d53f345d14..468db649094b 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -674,10 +674,8 @@ extern ftrace_func_t ftrace_trace_function;
 
 int ftrace_regex_open(struct ftrace_ops *ops, int flag,
 		  struct inode *inode, struct file *file);
-ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
-			    size_t cnt, loff_t *ppos);
-ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
-			     size_t cnt, loff_t *ppos);
+ssize_t ftrace_filter_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t ftrace_notrace_write_iter(struct kiocb *iocb, struct iov_iter *from);
 int ftrace_regex_release(struct inode *inode, struct file *file);
 
 void __init
@@ -890,8 +888,9 @@ static inline unsigned long ftrace_location(unsigned long ip)
 #define ftrace_free_filter(ops) do { } while (0)
 #define ftrace_ops_set_global_filter(ops) do { } while (0)
 
-static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
-			    size_t cnt, loff_t *ppos) { return -ENODEV; }
+static inline ssize_t ftrace_filter_write_iter(struct kiocb *iocb,
+					       struct iov_iter *from)
+{ return -ENODEV; }
 static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
 			     size_t cnt, loff_t *ppos) { return -ENODEV; }
 static inline int
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index d5d94510afd3..737551849daf 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -411,38 +411,37 @@ int blk_trace_remove(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_trace_remove);
 
-static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
-				size_t count, loff_t *ppos)
+static ssize_t blk_dropped_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct blk_trace *bt = filp->private_data;
+	struct blk_trace *bt = iocb->ki_filp->private_data;
 	char buf[16];
 
 	snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
 
-	return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 static const struct file_operations blk_dropped_fops = {
 	.owner =	THIS_MODULE,
 	.open =		simple_open,
-	.read =		blk_dropped_read,
+	.read_iter =	blk_dropped_read,
 	.llseek =	default_llseek,
 };
 
-static ssize_t blk_msg_write(struct file *filp, const char __user *buffer,
-				size_t count, loff_t *ppos)
+static ssize_t blk_msg_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char *msg;
 	struct blk_trace *bt;
 
 	if (count >= BLK_TN_MAX_MSG)
 		return -EINVAL;
 
-	msg = memdup_user_nul(buffer, count);
+	msg = iterdup_nul(from, count);
 	if (IS_ERR(msg))
 		return PTR_ERR(msg);
 
-	bt = filp->private_data;
+	bt = iocb->ki_filp->private_data;
 	__blk_trace_note_message(bt, NULL, "%s", msg);
 	kfree(msg);
 
@@ -452,7 +451,7 @@ static ssize_t blk_msg_write(struct file *filp, const char __user *buffer,
 static const struct file_operations blk_msg_fops = {
 	.owner =	THIS_MODULE,
 	.open =		simple_open,
-	.write =	blk_msg_write,
+	.write_iter =	blk_msg_write,
 	.llseek =	noop_llseek,
 };
 
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index da1710499698..fa9b0bcc7cb1 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -909,14 +909,13 @@ static void unregister_ftrace_profiler(void)
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
-static ssize_t
-ftrace_profile_write(struct file *filp, const char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t ftrace_profile_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -949,26 +948,24 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf,
  out:
 	mutex_unlock(&ftrace_profile_lock);
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
-static ssize_t
-ftrace_profile_read(struct file *filp, char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t ftrace_profile_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];		/* big enough to hold a number */
 	int r;
 
 	r = sprintf(buf, "%u\n", ftrace_profile_enabled);
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
 static const struct file_operations ftrace_profile_fops = {
 	.open		= tracing_open_generic,
-	.read		= ftrace_profile_read,
-	.write		= ftrace_profile_write,
+	.read_iter	= ftrace_profile_read,
+	.write_iter	= ftrace_profile_write,
 	.llseek		= default_llseek,
 };
 
@@ -5204,20 +5201,30 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
 	return ret;
 }
 
-ssize_t
+static ssize_t
 ftrace_filter_write(struct file *file, const char __user *ubuf,
 		    size_t cnt, loff_t *ppos)
 {
 	return ftrace_regex_write(file, ubuf, cnt, ppos, 1);
 }
 
-ssize_t
+ssize_t ftrace_filter_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, ftrace_filter_write);
+}
+
+static ssize_t
 ftrace_notrace_write(struct file *file, const char __user *ubuf,
 		     size_t cnt, loff_t *ppos)
 {
 	return ftrace_regex_write(file, ubuf, cnt, ppos, 0);
 }
 
+ssize_t ftrace_notrace_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, ftrace_notrace_write);
+}
+
 static int
 __ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
 {
@@ -5937,44 +5944,44 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
 
 static const struct file_operations ftrace_avail_fops = {
 	.open = ftrace_avail_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
 
 static const struct file_operations ftrace_enabled_fops = {
 	.open = ftrace_enabled_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
 
 static const struct file_operations ftrace_touched_fops = {
 	.open = ftrace_touched_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
 
 static const struct file_operations ftrace_avail_addrs_fops = {
 	.open = ftrace_avail_addrs_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
 
 static const struct file_operations ftrace_filter_fops = {
 	.open = ftrace_filter_open,
-	.read = seq_read,
-	.write = ftrace_filter_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_filter_write_iter,
 	.llseek = tracing_lseek,
 	.release = ftrace_regex_release,
 };
 
 static const struct file_operations ftrace_notrace_fops = {
 	.open = ftrace_notrace_open,
-	.read = seq_read,
-	.write = ftrace_notrace_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_notrace_write_iter,
 	.llseek = tracing_lseek,
 	.release = ftrace_regex_release,
 };
@@ -6369,19 +6376,20 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ftrace_graph_write);
 
 static const struct file_operations ftrace_graph_fops = {
 	.open		= ftrace_graph_open,
-	.read		= seq_read,
-	.write		= ftrace_graph_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= ftrace_graph_write_iter,
 	.llseek		= tracing_lseek,
 	.release	= ftrace_graph_release,
 };
 
 static const struct file_operations ftrace_graph_notrace_fops = {
 	.open		= ftrace_graph_notrace_open,
-	.read		= seq_read,
-	.write		= ftrace_graph_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= ftrace_graph_write_iter,
 	.llseek		= tracing_lseek,
 	.release	= ftrace_graph_release,
 };
@@ -7831,6 +7839,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
 {
 	return pid_write(filp, ubuf, cnt, ppos, TRACE_PIDS);
 }
+FOPS_WRITE_ITER_HELPER(ftrace_pid_write);
 
 static ssize_t
 ftrace_no_pid_write(struct file *filp, const char __user *ubuf,
@@ -7838,6 +7847,7 @@ ftrace_no_pid_write(struct file *filp, const char __user *ubuf,
 {
 	return pid_write(filp, ubuf, cnt, ppos, TRACE_NO_PIDS);
 }
+FOPS_WRITE_ITER_HELPER(ftrace_no_pid_write);
 
 static int
 ftrace_pid_release(struct inode *inode, struct file *file)
@@ -7851,16 +7861,16 @@ ftrace_pid_release(struct inode *inode, struct file *file)
 
 static const struct file_operations ftrace_pid_fops = {
 	.open		= ftrace_pid_open,
-	.write		= ftrace_pid_write,
-	.read		= seq_read,
+	.write_iter	= ftrace_pid_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= tracing_lseek,
 	.release	= ftrace_pid_release,
 };
 
 static const struct file_operations ftrace_no_pid_fops = {
 	.open		= ftrace_no_pid_open,
-	.write		= ftrace_no_pid_write,
-	.read		= seq_read,
+	.write_iter	= ftrace_no_pid_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= tracing_lseek,
 	.release	= ftrace_pid_release,
 };
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 233d1af39fff..317aa6a5944f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5015,11 +5015,9 @@ static int show_traces_release(struct inode *inode, struct file *file)
 	return seq_release(inode, file);
 }
 
-static ssize_t
-tracing_write_stub(struct file *filp, const char __user *ubuf,
-		   size_t count, loff_t *ppos)
+static ssize_t tracing_write_stub(struct kiocb *iocb, struct iov_iter *to)
 {
-	return count;
+	return iov_iter_count(to);
 }
 
 loff_t tracing_lseek(struct file *file, loff_t offset, int whence)
@@ -5036,26 +5034,24 @@ loff_t tracing_lseek(struct file *file, loff_t offset, int whence)
 
 static const struct file_operations tracing_fops = {
 	.open		= tracing_open,
-	.read		= seq_read,
 	.read_iter	= seq_read_iter,
 	.splice_read	= copy_splice_read,
-	.write		= tracing_write_stub,
+	.write_iter	= tracing_write_stub,
 	.llseek		= tracing_lseek,
 	.release	= tracing_release,
 };
 
 static const struct file_operations show_traces_fops = {
 	.open		= show_traces_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= show_traces_release,
 };
 
-static ssize_t
-tracing_cpumask_read(struct file *filp, char __user *ubuf,
-		     size_t count, loff_t *ppos)
+static ssize_t tracing_cpumask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = file_inode(filp)->i_private;
+	struct trace_array *tr = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(to);
 	char *mask_str;
 	int len;
 
@@ -5071,7 +5067,7 @@ tracing_cpumask_read(struct file *filp, char __user *ubuf,
 		count = -EINVAL;
 		goto out_err;
 	}
-	count = simple_read_from_buffer(ubuf, count, ppos, mask_str, len);
+	count = simple_copy_to_iter(mask_str, &iocb->ki_pos, len, to);
 
 out_err:
 	kfree(mask_str);
@@ -5147,11 +5143,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 
 	return err;
 }
+FOPS_WRITE_ITER_HELPER(tracing_cpumask_write);
 
 static const struct file_operations tracing_cpumask_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_cpumask_read,
-	.write		= tracing_cpumask_write,
+	.read_iter	= tracing_cpumask_read,
+	.write_iter	= tracing_cpumask_write_iter,
 	.release	= tracing_release_generic_tr,
 	.llseek		= generic_file_llseek,
 };
@@ -5343,19 +5340,19 @@ static void __init apply_trace_boot_options(void)
 	}
 }
 
-static ssize_t
-tracing_trace_options_write(struct file *filp, const char __user *ubuf,
-			size_t cnt, loff_t *ppos)
+static ssize_t tracing_trace_options_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct trace_array *tr = m->private;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	int ret;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, cnt))
+	if (!copy_from_iter_full(buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -5364,7 +5361,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 	if (ret < 0)
 		return ret;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -5387,10 +5384,10 @@ static int tracing_trace_options_open(struct inode *inode, struct file *file)
 
 static const struct file_operations tracing_iter_fops = {
 	.open		= tracing_trace_options_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= tracing_single_release_tr,
-	.write		= tracing_trace_options_write,
+	.write_iter	= tracing_trace_options_write,
 };
 
 static const char readme_msg[] =
@@ -5685,17 +5682,15 @@ static const char readme_msg[] =
 #endif
 ;
 
-static ssize_t
-tracing_readme_read(struct file *filp, char __user *ubuf,
-		       size_t cnt, loff_t *ppos)
+static ssize_t tracing_readme_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(ubuf, cnt, ppos,
-					readme_msg, strlen(readme_msg));
+	return simple_copy_to_iter(readme_msg, &iocb->ki_pos,
+				   strlen(readme_msg), to);
 }
 
 static const struct file_operations tracing_readme_fops = {
 	.open		= tracing_open_generic,
-	.read		= tracing_readme_read,
+	.read_iter	= tracing_readme_read,
 	.llseek		= generic_file_llseek,
 };
 
@@ -5787,7 +5782,7 @@ static int tracing_eval_map_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations tracing_eval_map_fops = {
 	.open		= tracing_eval_map_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -5876,11 +5871,9 @@ static void trace_insert_eval_map(struct module *mod,
 	trace_insert_eval_map_file(mod, start, len);
 }
 
-static ssize_t
-tracing_set_trace_read(struct file *filp, char __user *ubuf,
-		       size_t cnt, loff_t *ppos)
+static ssize_t tracing_set_trace_read(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	char buf[MAX_TRACER_SIZE+2];
 	int r;
 
@@ -5888,7 +5881,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
 	r = sprintf(buf, "%s\n", tr->current_trace->name);
 	mutex_unlock(&trace_types_lock);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_from_iter(buf, &iocb->ki_pos, r, from);
 }
 
 int tracer_init(struct tracer *t, struct trace_array *tr)
@@ -6207,11 +6200,11 @@ int tracing_set_tracer(struct trace_array *tr, const char *buf)
 	return ret;
 }
 
-static ssize_t
-tracing_set_trace_write(struct file *filp, const char __user *ubuf,
-			size_t cnt, loff_t *ppos)
+static ssize_t tracing_set_trace_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	char buf[MAX_TRACER_SIZE+1];
 	char *name;
 	size_t ret;
@@ -6222,7 +6215,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
 	if (cnt > MAX_TRACER_SIZE)
 		cnt = MAX_TRACER_SIZE;
 
-	if (copy_from_user(buf, ubuf, cnt))
+	if (!copy_from_iter_full(buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -6233,14 +6226,13 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
 	if (err)
 		return err;
 
-	*ppos += ret;
+	iocb->ki_pos += ret;
 
 	return ret;
 }
 
 static ssize_t
-tracing_nsecs_read(unsigned long *ptr, char __user *ubuf,
-		   size_t cnt, loff_t *ppos)
+tracing_nsecs_read(unsigned long *ptr, struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int r;
@@ -6249,17 +6241,18 @@ tracing_nsecs_read(unsigned long *ptr, char __user *ubuf,
 		     *ptr == (unsigned long)-1 ? -1 : nsecs_to_usecs(*ptr));
 	if (r > sizeof(buf))
 		r = sizeof(buf);
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
 static ssize_t
-tracing_nsecs_write(unsigned long *ptr, const char __user *ubuf,
-		    size_t cnt, loff_t *ppos)
+tracing_nsecs_write(unsigned long *ptr, struct kiocb *iocb,
+		    struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -6268,22 +6261,19 @@ tracing_nsecs_write(unsigned long *ptr, const char __user *ubuf,
 	return cnt;
 }
 
-static ssize_t
-tracing_thresh_read(struct file *filp, char __user *ubuf,
-		    size_t cnt, loff_t *ppos)
+static ssize_t tracing_thresh_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return tracing_nsecs_read(&tracing_thresh, ubuf, cnt, ppos);
+	return tracing_nsecs_read(&tracing_thresh, iocb, to);
 }
 
-static ssize_t
-tracing_thresh_write(struct file *filp, const char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t tracing_thresh_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	int ret;
 
 	mutex_lock(&trace_types_lock);
-	ret = tracing_nsecs_write(&tracing_thresh, ubuf, cnt, ppos);
+	ret = tracing_nsecs_write(&tracing_thresh, iocb, from);
 	if (ret < 0)
 		goto out;
 
@@ -6302,22 +6292,18 @@ tracing_thresh_write(struct file *filp, const char __user *ubuf,
 
 #ifdef CONFIG_TRACER_MAX_TRACE
 
-static ssize_t
-tracing_max_lat_read(struct file *filp, char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t tracing_max_lat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 
-	return tracing_nsecs_read(&tr->max_latency, ubuf, cnt, ppos);
+	return tracing_nsecs_read(&tr->max_latency, iocb, to);
 }
 
-static ssize_t
-tracing_max_lat_write(struct file *filp, const char __user *ubuf,
-		      size_t cnt, loff_t *ppos)
+static ssize_t tracing_max_lat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 
-	return tracing_nsecs_write(&tr->max_latency, ubuf, cnt, ppos);
+	return tracing_nsecs_write(&tr->max_latency, iocb, from);
 }
 
 #endif
@@ -6609,6 +6595,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
 
 	return sret;
 }
+FOPS_READ_ITER_HELPER(tracing_read_pipe);
 
 static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
 				     unsigned int idx)
@@ -6749,16 +6736,13 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
 	goto out;
 }
 
-static ssize_t
-tracing_entries_read(struct file *filp, char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t tracing_entries_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(filp);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct trace_array *tr = inode->i_private;
 	int cpu = tracing_get_cpu(inode);
 	char buf[64];
 	int r = 0;
-	ssize_t ret;
 
 	mutex_lock(&trace_types_lock);
 
@@ -6792,21 +6776,18 @@ tracing_entries_read(struct file *filp, char __user *ubuf,
 		r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->array_buffer.data, cpu)->entries >> 10);
 
 	mutex_unlock(&trace_types_lock);
-
-	ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
-static ssize_t
-tracing_entries_write(struct file *filp, const char __user *ubuf,
-		      size_t cnt, loff_t *ppos)
+static ssize_t tracing_entries_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(filp);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct trace_array *tr = inode->i_private;
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -6820,16 +6801,15 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 	if (ret < 0)
 		return ret;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
 static ssize_t
-tracing_total_entries_read(struct file *filp, char __user *ubuf,
-				size_t cnt, loff_t *ppos)
+tracing_total_entries_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	char buf[64];
 	int r, cpu;
 	unsigned long size = 0, expanded_size = 0;
@@ -6846,19 +6826,20 @@ tracing_total_entries_read(struct file *filp, char __user *ubuf,
 		r = sprintf(buf, "%lu (expanded: %lu)\n", size, expanded_size);
 	mutex_unlock(&trace_types_lock);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
 static ssize_t
-tracing_free_buffer_write(struct file *filp, const char __user *ubuf,
-			  size_t cnt, loff_t *ppos)
+tracing_free_buffer_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
+
 	/*
 	 * There is no need to read what the user has written, this function
 	 * is just to make sure that there is no error when "echo" is used
 	 */
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -6974,6 +6955,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
 
 	return written;
 }
+FOPS_WRITE_ITER_HELPER(tracing_mark_write);
 
 static ssize_t
 tracing_mark_raw_write(struct file *filp, const char __user *ubuf,
@@ -7028,6 +7010,7 @@ tracing_mark_raw_write(struct file *filp, const char __user *ubuf,
 
 	return written;
 }
+FOPS_WRITE_ITER_HELPER(tracing_mark_raw_write);
 
 static int tracing_clock_show(struct seq_file *m, void *v)
 {
@@ -7078,11 +7061,11 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)
 	return 0;
 }
 
-static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
-				   size_t cnt, loff_t *fpos)
+static ssize_t tracing_clock_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct trace_array *tr = m->private;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	const char *clockstr;
 	int ret;
@@ -7090,7 +7073,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, cnt))
+	if (!copy_from_iter(buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -7101,7 +7084,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
 	if (ret)
 		return ret;
 
-	*fpos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -7331,6 +7314,7 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	mutex_unlock(&trace_types_lock);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(tracing_snapshot_write);
 
 static int tracing_snapshot_release(struct inode *inode, struct file *file)
 {
@@ -7351,8 +7335,7 @@ static int tracing_snapshot_release(struct inode *inode, struct file *file)
 }
 
 static int tracing_buffers_open(struct inode *inode, struct file *filp);
-static ssize_t tracing_buffers_read(struct file *filp, char __user *ubuf,
-				    size_t count, loff_t *ppos);
+static ssize_t tracing_buffers_read(struct kiocb *iocb, struct iov_iter *to);
 static int tracing_buffers_release(struct inode *inode, struct file *file);
 static ssize_t tracing_buffers_splice_read(struct file *file, loff_t *ppos,
 		   struct pipe_inode_info *pipe, size_t len, unsigned int flags);
@@ -7385,16 +7368,16 @@ static int snapshot_raw_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations tracing_thresh_fops = {
 	.open		= tracing_open_generic,
-	.read		= tracing_thresh_read,
-	.write		= tracing_thresh_write,
+	.read_iter	= tracing_thresh_read,
+	.write_iter	= tracing_thresh_write,
 	.llseek		= generic_file_llseek,
 };
 
 #ifdef CONFIG_TRACER_MAX_TRACE
 static const struct file_operations tracing_max_lat_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_max_lat_read,
-	.write		= tracing_max_lat_write,
+	.read_iter	= tracing_max_lat_read,
+	.write_iter	= tracing_max_lat_write,
 	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
@@ -7402,8 +7385,8 @@ static const struct file_operations tracing_max_lat_fops = {
 
 static const struct file_operations set_tracer_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_set_trace_read,
-	.write		= tracing_set_trace_write,
+	.read_iter	= tracing_set_trace_read,
+	.write_iter	= tracing_set_trace_write,
 	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
@@ -7411,7 +7394,7 @@ static const struct file_operations set_tracer_fops = {
 static const struct file_operations tracing_pipe_fops = {
 	.open		= tracing_open_pipe,
 	.poll		= tracing_poll_pipe,
-	.read		= tracing_read_pipe,
+	.read_iter	= tracing_read_pipe_iter,
 	.splice_read	= tracing_splice_read_pipe,
 	.release	= tracing_release_pipe,
 	.llseek		= no_llseek,
@@ -7419,48 +7402,48 @@ static const struct file_operations tracing_pipe_fops = {
 
 static const struct file_operations tracing_entries_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_entries_read,
-	.write		= tracing_entries_write,
+	.read_iter	= tracing_entries_read,
+	.write_iter	= tracing_entries_write,
 	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
 
 static const struct file_operations tracing_total_entries_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_total_entries_read,
+	.read_iter	= tracing_total_entries_read,
 	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
 
 static const struct file_operations tracing_free_buffer_fops = {
 	.open		= tracing_open_generic_tr,
-	.write		= tracing_free_buffer_write,
+	.write_iter	= tracing_free_buffer_write,
 	.release	= tracing_free_buffer_release,
 };
 
 static const struct file_operations tracing_mark_fops = {
 	.open		= tracing_mark_open,
-	.write		= tracing_mark_write,
+	.write_iter	= tracing_mark_write_iter,
 	.release	= tracing_release_generic_tr,
 };
 
 static const struct file_operations tracing_mark_raw_fops = {
 	.open		= tracing_mark_open,
-	.write		= tracing_mark_raw_write,
+	.write_iter	= tracing_mark_raw_write_iter,
 	.release	= tracing_release_generic_tr,
 };
 
 static const struct file_operations trace_clock_fops = {
 	.open		= tracing_clock_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= tracing_single_release_tr,
-	.write		= tracing_clock_write,
+	.write_iter	= tracing_clock_write,
 };
 
 static const struct file_operations trace_time_stamp_mode_fops = {
 	.open		= tracing_time_stamp_mode_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= tracing_single_release_tr,
 };
@@ -7468,15 +7451,15 @@ static const struct file_operations trace_time_stamp_mode_fops = {
 #ifdef CONFIG_TRACER_SNAPSHOT
 static const struct file_operations snapshot_fops = {
 	.open		= tracing_snapshot_open,
-	.read		= seq_read,
-	.write		= tracing_snapshot_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= tracing_snapshot_write_iter,
 	.llseek		= tracing_lseek,
 	.release	= tracing_snapshot_release,
 };
 
 static const struct file_operations snapshot_raw_fops = {
 	.open		= snapshot_raw_open,
-	.read		= tracing_buffers_read,
+	.read_iter	= tracing_buffers_read,
 	.release	= tracing_buffers_release,
 	.splice_read	= tracing_buffers_splice_read,
 	.llseek		= no_llseek,
@@ -7496,17 +7479,17 @@ static const struct file_operations snapshot_raw_fops = {
  * defines where to write the value, the min and the max acceptable values,
  * and a lock to protect the write.
  */
-static ssize_t
-trace_min_max_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t trace_min_max_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_min_max_param *param = filp->private_data;
+	struct trace_min_max_param *param = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	u64 val;
 	int err;
 
 	if (!param)
 		return -EFAULT;
 
-	err = kstrtoull_from_user(ubuf, cnt, 10, &val);
+	err = kstrtoull_from_iter(from, cnt, 10, &val);
 	if (err)
 		return err;
 
@@ -7542,10 +7525,10 @@ trace_min_max_write(struct file *filp, const char __user *ubuf, size_t cnt, loff
  * The filp->private_data must point to a trace_min_max_param struct with valid
  * data.
  */
-static ssize_t
-trace_min_max_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t trace_min_max_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_min_max_param *param = filp->private_data;
+	struct trace_min_max_param *param = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(to);
 	char buf[U64_STR_SIZE];
 	int len;
 	u64 val;
@@ -7560,13 +7543,13 @@ trace_min_max_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppo
 
 	len = snprintf(buf, sizeof(buf), "%llu\n", val);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 const struct file_operations trace_min_max_fops = {
 	.open		= tracing_open_generic,
-	.read		= trace_min_max_read,
-	.write		= trace_min_max_write,
+	.read_iter	= trace_min_max_read,
+	.write_iter	= trace_min_max_write,
 };
 
 #define TRACING_LOG_ERRS_MAX	8
@@ -7818,11 +7801,9 @@ static int tracing_err_log_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t tracing_err_log_write(struct file *file,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t tracing_err_log_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return count;
+	return iov_iter_count(from);
 }
 
 static int tracing_err_log_release(struct inode *inode, struct file *file)
@@ -7839,8 +7820,8 @@ static int tracing_err_log_release(struct inode *inode, struct file *file)
 
 static const struct file_operations tracing_err_log_fops = {
 	.open           = tracing_err_log_open,
-	.write		= tracing_err_log_write,
-	.read           = seq_read,
+	.write_iter	= tracing_err_log_write,
+	.read_iter      = seq_read_iter,
 	.llseek         = tracing_lseek,
 	.release        = tracing_err_log_release,
 };
@@ -7893,12 +7874,11 @@ tracing_buffers_poll(struct file *filp, poll_table *poll_table)
 	return trace_poll(iter, filp, poll_table);
 }
 
-static ssize_t
-tracing_buffers_read(struct file *filp, char __user *ubuf,
-		     size_t count, loff_t *ppos)
+static ssize_t tracing_buffers_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ftrace_buffer_info *info = filp->private_data;
+	struct ftrace_buffer_info *info = iocb->ki_filp->private_data;
 	struct trace_iterator *iter = &info->iter;
+	size_t count = iov_iter_count(to);
 	void *trace_data;
 	int page_size;
 	ssize_t ret = 0;
@@ -7951,7 +7931,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
 
 	if (ret < 0) {
 		if (trace_empty(iter)) {
-			if ((filp->f_flags & O_NONBLOCK))
+			if (iocb->ki_filp->f_flags & O_NONBLOCK)
 				return -EAGAIN;
 
 			ret = wait_on_pipe(iter, 0);
@@ -7969,13 +7949,13 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
 	if (size > count)
 		size = count;
 	trace_data = ring_buffer_read_page_data(info->spare);
-	ret = copy_to_user(ubuf, trace_data + info->read, size);
+	ret = copy_to_iter(trace_data + info->read, size, to);
 	if (ret == size)
 		return -EFAULT;
 
 	size -= ret;
 
-	*ppos += size;
+	iocb->ki_pos += size;
 	info->read += size;
 
 	return size;
@@ -8216,7 +8196,7 @@ static long tracing_buffers_ioctl(struct file *file, unsigned int cmd, unsigned
 
 static const struct file_operations tracing_buffers_fops = {
 	.open		= tracing_buffers_open,
-	.read		= tracing_buffers_read,
+	.read_iter	= tracing_buffers_read,
 	.poll		= tracing_buffers_poll,
 	.release	= tracing_buffers_release,
 	.flush		= tracing_buffers_flush,
@@ -8225,11 +8205,9 @@ static const struct file_operations tracing_buffers_fops = {
 	.llseek		= no_llseek,
 };
 
-static ssize_t
-tracing_stats_read(struct file *filp, char __user *ubuf,
-		   size_t count, loff_t *ppos)
+static ssize_t tracing_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(filp);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct trace_array *tr = inode->i_private;
 	struct array_buffer *trace_buf = &tr->array_buffer;
 	int cpu = tracing_get_cpu(inode);
@@ -8237,6 +8215,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 	unsigned long cnt;
 	unsigned long long t;
 	unsigned long usec_rem;
+	ssize_t count;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
 	if (!s)
@@ -8281,17 +8260,15 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 	cnt = ring_buffer_read_events_cpu(trace_buf->buffer, cpu);
 	trace_seq_printf(s, "read events: %ld\n", cnt);
 
-	count = simple_read_from_buffer(ubuf, count, ppos,
-					s->buffer, trace_seq_used(s));
-
+	count = simple_copy_to_iter(s->buffer, &iocb->ki_pos, trace_seq_used(s),
+					to);
 	kfree(s);
-
 	return count;
 }
 
 static const struct file_operations tracing_stats_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= tracing_stats_read,
+	.read_iter	= tracing_stats_read,
 	.llseek		= generic_file_llseek,
 	.release	= tracing_release_generic_tr,
 };
@@ -8299,8 +8276,7 @@ static const struct file_operations tracing_stats_fops = {
 #ifdef CONFIG_DYNAMIC_FTRACE
 
 static ssize_t
-tracing_read_dyn_info(struct file *filp, char __user *ubuf,
-		  size_t cnt, loff_t *ppos)
+tracing_read_dyn_info(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	char *buf;
@@ -8316,14 +8292,14 @@ tracing_read_dyn_info(struct file *filp, char __user *ubuf,
 		      ftrace_number_of_pages,
 		      ftrace_number_of_groups);
 
-	ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations tracing_dyn_info_fops = {
 	.open		= tracing_open_generic,
-	.read		= tracing_read_dyn_info,
+	.read_iter	= tracing_read_dyn_info,
 	.llseek		= generic_file_llseek,
 };
 #endif /* CONFIG_DYNAMIC_FTRACE */
@@ -8583,11 +8559,9 @@ tracing_init_tracefs_percpu(struct trace_array *tr, long cpu)
 #include "trace_selftest.c"
 #endif
 
-static ssize_t
-trace_options_read(struct file *filp, char __user *ubuf, size_t cnt,
-			loff_t *ppos)
+static ssize_t trace_options_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_option_dentry *topt = filp->private_data;
+	struct trace_option_dentry *topt = iocb->ki_filp->private_data;
 	char *buf;
 
 	if (topt->flags->val & topt->opt->bit)
@@ -8595,18 +8569,17 @@ trace_options_read(struct file *filp, char __user *ubuf, size_t cnt,
 	else
 		buf = "0\n";
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t
-trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
-			 loff_t *ppos)
+static ssize_t trace_options_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_option_dentry *topt = filp->private_data;
+	struct trace_option_dentry *topt = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -8622,7 +8595,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
 			return ret;
 	}
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -8650,8 +8623,8 @@ static int tracing_release_options(struct inode *inode, struct file *file)
 
 static const struct file_operations trace_options_fops = {
 	.open = tracing_open_options,
-	.read = trace_options_read,
-	.write = trace_options_write,
+	.read_iter = trace_options_read,
+	.write_iter = trace_options_write,
 	.llseek	= generic_file_llseek,
 	.release = tracing_release_options,
 };
@@ -8689,11 +8662,9 @@ static void get_tr_index(void *data, struct trace_array **ptr,
 			    trace_flags_index);
 }
 
-static ssize_t
-trace_options_core_read(struct file *filp, char __user *ubuf, size_t cnt,
-			loff_t *ppos)
+static ssize_t trace_options_core_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	void *tr_index = filp->private_data;
+	void *tr_index = iocb->ki_filp->private_data;
 	struct trace_array *tr;
 	unsigned int index;
 	char *buf;
@@ -8705,14 +8676,14 @@ trace_options_core_read(struct file *filp, char __user *ubuf, size_t cnt,
 	else
 		buf = "0\n";
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static ssize_t
-trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
-			 loff_t *ppos)
+trace_options_core_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	void *tr_index = filp->private_data;
+	void *tr_index = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	struct trace_array *tr;
 	unsigned int index;
 	unsigned long val;
@@ -8720,7 +8691,7 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	get_tr_index(tr_index, &tr, &index);
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -8736,15 +8707,15 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (ret < 0)
 		return ret;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
 static const struct file_operations trace_options_core_fops = {
 	.open = tracing_open_generic,
-	.read = trace_options_core_read,
-	.write = trace_options_core_write,
+	.read_iter = trace_options_core_read,
+	.write_iter = trace_options_core_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -8898,30 +8869,27 @@ static void create_trace_options_dir(struct trace_array *tr)
 	}
 }
 
-static ssize_t
-rb_simple_read(struct file *filp, char __user *ubuf,
-	       size_t cnt, loff_t *ppos)
+static ssize_t rb_simple_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	char buf[64];
 	int r;
 
 	r = tracer_tracing_is_on(tr);
 	r = sprintf(buf, "%d\n", r);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
-static ssize_t
-rb_simple_write(struct file *filp, const char __user *ubuf,
-		size_t cnt, loff_t *ppos)
+static ssize_t rb_simple_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	struct trace_buffer *buffer = tr->array_buffer.buffer;
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -8943,42 +8911,39 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
 		mutex_unlock(&trace_types_lock);
 	}
 
-	(*ppos)++;
+	iocb->ki_pos++;
 
 	return cnt;
 }
 
 static const struct file_operations rb_simple_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= rb_simple_read,
-	.write		= rb_simple_write,
+	.read_iter	= rb_simple_read,
+	.write_iter	= rb_simple_write,
 	.release	= tracing_release_generic_tr,
 	.llseek		= default_llseek,
 };
 
-static ssize_t
-buffer_percent_read(struct file *filp, char __user *ubuf,
-		    size_t cnt, loff_t *ppos)
+static ssize_t buffer_percent_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	char buf[64];
 	int r;
 
 	r = tr->buffer_percent;
 	r = sprintf(buf, "%d\n", r);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
-static ssize_t
-buffer_percent_write(struct file *filp, const char __user *ubuf,
-		     size_t cnt, loff_t *ppos)
+static ssize_t buffer_percent_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -8987,23 +8952,22 @@ buffer_percent_write(struct file *filp, const char __user *ubuf,
 
 	tr->buffer_percent = val;
 
-	(*ppos)++;
+	iocb->ki_pos++;
 
 	return cnt;
 }
 
 static const struct file_operations buffer_percent_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= buffer_percent_read,
-	.write		= buffer_percent_write,
+	.read_iter	= buffer_percent_read,
+	.write_iter	= buffer_percent_write,
 	.release	= tracing_release_generic_tr,
 	.llseek		= default_llseek,
 };
 
-static ssize_t
-buffer_subbuf_size_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t buffer_subbuf_size_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	size_t size;
 	char buf[64];
 	int order;
@@ -9014,21 +8978,21 @@ buffer_subbuf_size_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t
 
 	r = sprintf(buf, "%zd\n", size);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
 static ssize_t
-buffer_subbuf_size_write(struct file *filp, const char __user *ubuf,
-			 size_t cnt, loff_t *ppos)
+buffer_subbuf_size_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int old_order;
 	int order;
 	int pages;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -9081,7 +9045,7 @@ buffer_subbuf_size_write(struct file *filp, const char __user *ubuf,
 	}
  out_max:
 #endif
-	(*ppos)++;
+	iocb->ki_pos++;
  out:
 	if (ret)
 		cnt = ret;
@@ -9091,8 +9055,8 @@ buffer_subbuf_size_write(struct file *filp, const char __user *ubuf,
 
 static const struct file_operations buffer_subbuf_size_fops = {
 	.open		= tracing_open_generic_tr,
-	.read		= buffer_subbuf_size_read,
-	.write		= buffer_subbuf_size_write,
+	.read_iter	= buffer_subbuf_size_read,
+	.write_iter	= buffer_subbuf_size_write,
 	.release	= tracing_release_generic_tr,
 	.llseek		= default_llseek,
 };
diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c
index 4376887e0d8a..cea3f5947025 100644
--- a/kernel/trace/trace_dynevent.c
+++ b/kernel/trace/trace_dynevent.c
@@ -244,14 +244,15 @@ static ssize_t dyn_event_write(struct file *file, const char __user *buffer,
 	return trace_parse_run_command(file, buffer, count, ppos,
 				       create_dyn_event);
 }
+FOPS_WRITE_ITER_HELPER(dyn_event_write);
 
 static const struct file_operations dynamic_events_ops = {
 	.owner          = THIS_MODULE,
 	.open           = dyn_event_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = seq_release,
-	.write		= dyn_event_write,
+	.write_iter	= dyn_event_write_iter,
 };
 
 /* Make a tracefs interface for controlling dynamic events */
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 7c364b87352e..bc1bfc3f387c 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1215,6 +1215,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ftrace_event_write);
 
 static void *
 t_next(struct seq_file *m, void *v, loff_t *pos)
@@ -1377,16 +1378,14 @@ static void p_stop(struct seq_file *m, void *p)
 	mutex_unlock(&event_mutex);
 }
 
-static ssize_t
-event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
-		  loff_t *ppos)
+static ssize_t event_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct trace_event_file *file;
 	unsigned long flags;
 	char buf[4] = "0";
 
 	mutex_lock(&event_mutex);
-	file = event_file_data(filp);
+	file = event_file_data(iocb->ki_filp);
 	if (likely(file))
 		flags = file->flags;
 	mutex_unlock(&event_mutex);
@@ -1404,7 +1403,7 @@ event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
 
 	strcat(buf, "\n");
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 static ssize_t
@@ -1444,20 +1443,18 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	return ret ? ret : cnt;
 }
+FOPS_WRITE_ITER_HELPER(event_enable_write);
 
-static ssize_t
-system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
-		   loff_t *ppos)
+static ssize_t system_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	const char set_to_char[4] = { '?', '0', '1', 'X' };
-	struct trace_subsystem_dir *dir = filp->private_data;
+	struct trace_subsystem_dir *dir = iocb->ki_filp->private_data;
 	struct event_subsystem *system = dir->subsystem;
 	struct trace_event_call *call;
 	struct trace_event_file *file;
 	struct trace_array *tr = dir->tr;
 	char buf[2];
 	int set = 0;
-	int ret;
 
 	mutex_lock(&event_mutex);
 	list_for_each_entry(file, &tr->events, list) {
@@ -1487,9 +1484,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
 	buf[0] = set_to_char[set];
 	buf[1] = '\n';
 
-	ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
-
-	return ret;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static ssize_t
@@ -1531,6 +1526,7 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(system_enable_write);
 
 enum {
 	FORMAT_HEADER		= 1,
@@ -1670,10 +1666,9 @@ static int trace_format_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t event_id_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	int id = (long)event_file_data(filp);
+	int id = (long)event_file_data(iocb->ki_filp);
 	char buf[32];
 	int len;
 
@@ -1682,18 +1677,16 @@ event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
 
 	len = sprintf(buf, "%d\n", id);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t
-event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
-		  loff_t *ppos)
+static ssize_t event_filter_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct trace_event_file *file;
 	struct trace_seq *s;
 	int r = -ENODEV;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
@@ -1704,14 +1697,14 @@ event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
 	trace_seq_init(s);
 
 	mutex_lock(&event_mutex);
-	file = event_file_data(filp);
+	file = event_file_data(iocb->ki_filp);
 	if (file && !(file->flags & EVENT_FILE_FL_FREED))
 		print_event_filter(file, s);
 	mutex_unlock(&event_mutex);
 
 	if (file)
-		r = simple_read_from_buffer(ubuf, cnt, ppos,
-					    s->buffer, trace_seq_used(s));
+		r = simple_copy_to_iter(s->buffer, &iocb->ki_pos,
+					trace_seq_used(s), to);
 
 	kfree(s);
 
@@ -1747,6 +1740,7 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	return cnt;
 }
+FOPS_WRITE_ITER_HELPER(event_filter_write);
 
 static LIST_HEAD(event_subsystems);
 
@@ -1840,16 +1834,14 @@ static int subsystem_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
-		      loff_t *ppos)
+static ssize_t subsystem_filter_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_subsystem_dir *dir = filp->private_data;
+	struct trace_subsystem_dir *dir = iocb->ki_filp->private_data;
 	struct event_subsystem *system = dir->subsystem;
 	struct trace_seq *s;
 	int r;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
@@ -1859,8 +1851,7 @@ subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
 	trace_seq_init(s);
 
 	print_subsystem_event_filter(system, s);
-	r = simple_read_from_buffer(ubuf, cnt, ppos,
-				    s->buffer, trace_seq_used(s));
+	r = simple_copy_to_iter(s->buffer, &iocb->ki_pos, trace_seq_used(s), to);
 
 	kfree(s);
 
@@ -1891,15 +1882,15 @@ subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	return cnt;
 }
+FOPS_WRITE_ITER_HELPER(subsystem_filter_write);
 
-static ssize_t
-show_header_page_file(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t show_header_page_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct trace_array *tr = filp->private_data;
+	struct trace_array *tr = iocb->ki_filp->private_data;
 	struct trace_seq *s;
 	int r;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
@@ -1909,21 +1900,19 @@ show_header_page_file(struct file *filp, char __user *ubuf, size_t cnt, loff_t *
 	trace_seq_init(s);
 
 	ring_buffer_print_page_header(tr->array_buffer.buffer, s);
-	r = simple_read_from_buffer(ubuf, cnt, ppos,
-				    s->buffer, trace_seq_used(s));
+	r = simple_copy_to_iter(s->buffer, &iocb->ki_pos, trace_seq_used(s), to);
 
 	kfree(s);
 
 	return r;
 }
 
-static ssize_t
-show_header_event_file(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
+static ssize_t show_header_event_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct trace_seq *s;
 	int r;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	s = kmalloc(sizeof(*s), GFP_KERNEL);
@@ -1933,8 +1922,7 @@ show_header_event_file(struct file *filp, char __user *ubuf, size_t cnt, loff_t
 	trace_seq_init(s);
 
 	ring_buffer_print_entry_header(s);
-	r = simple_read_from_buffer(ubuf, cnt, ppos,
-				    s->buffer, trace_seq_used(s));
+	r = simple_copy_to_iter(s->buffer, &iocb->ki_pos, trace_seq_used(s), to);
 
 	kfree(s);
 
@@ -2064,6 +2052,7 @@ ftrace_event_pid_write(struct file *filp, const char __user *ubuf,
 {
 	return event_pid_write(filp, ubuf, cnt, ppos, TRACE_PIDS);
 }
+FOPS_WRITE_ITER_HELPER(ftrace_event_pid_write);
 
 static ssize_t
 ftrace_event_npid_write(struct file *filp, const char __user *ubuf,
@@ -2071,6 +2060,7 @@ ftrace_event_npid_write(struct file *filp, const char __user *ubuf,
 {
 	return event_pid_write(filp, ubuf, cnt, ppos, TRACE_NO_PIDS);
 }
+FOPS_WRITE_ITER_HELPER(ftrace_event_npid_write);
 
 static int ftrace_event_avail_open(struct inode *inode, struct file *file);
 static int ftrace_event_set_open(struct inode *inode, struct file *file);
@@ -2108,97 +2098,97 @@ static const struct seq_operations show_set_no_pid_seq_ops = {
 
 static const struct file_operations ftrace_avail_fops = {
 	.open = ftrace_event_avail_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
 
 static const struct file_operations ftrace_set_event_fops = {
 	.open = ftrace_event_set_open,
-	.read = seq_read,
-	.write = ftrace_event_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_event_write_iter,
 	.llseek = seq_lseek,
 	.release = ftrace_event_release,
 };
 
 static const struct file_operations ftrace_set_event_pid_fops = {
 	.open = ftrace_event_set_pid_open,
-	.read = seq_read,
-	.write = ftrace_event_pid_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_event_pid_write_iter,
 	.llseek = seq_lseek,
 	.release = ftrace_event_release,
 };
 
 static const struct file_operations ftrace_set_event_notrace_pid_fops = {
 	.open = ftrace_event_set_npid_open,
-	.read = seq_read,
-	.write = ftrace_event_npid_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_event_npid_write_iter,
 	.llseek = seq_lseek,
 	.release = ftrace_event_release,
 };
 
 static const struct file_operations ftrace_enable_fops = {
 	.open = tracing_open_file_tr,
-	.read = event_enable_read,
-	.write = event_enable_write,
+	.read_iter = event_enable_read,
+	.write_iter = event_enable_write_iter,
 	.release = tracing_release_file_tr,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations ftrace_event_format_fops = {
 	.open = trace_format_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
 
 static const struct file_operations ftrace_event_id_fops = {
-	.read = event_id_read,
+	.read_iter = event_id_read,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations ftrace_event_filter_fops = {
 	.open = tracing_open_file_tr,
-	.read = event_filter_read,
-	.write = event_filter_write,
+	.read_iter = event_filter_read,
+	.write_iter = event_filter_write_iter,
 	.release = tracing_release_file_tr,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations ftrace_subsystem_filter_fops = {
 	.open = subsystem_open,
-	.read = subsystem_filter_read,
-	.write = subsystem_filter_write,
+	.read_iter = subsystem_filter_read,
+	.write_iter = subsystem_filter_write_iter,
 	.llseek = default_llseek,
 	.release = subsystem_release,
 };
 
 static const struct file_operations ftrace_system_enable_fops = {
 	.open = subsystem_open,
-	.read = system_enable_read,
-	.write = system_enable_write,
+	.read_iter = system_enable_read,
+	.write_iter = system_enable_write_iter,
 	.llseek = default_llseek,
 	.release = subsystem_release,
 };
 
 static const struct file_operations ftrace_tr_enable_fops = {
 	.open = system_tr_open,
-	.read = system_enable_read,
-	.write = system_enable_write,
+	.read_iter = system_enable_read,
+	.write_iter = system_enable_write_iter,
 	.llseek = default_llseek,
 	.release = subsystem_release,
 };
 
 static const struct file_operations ftrace_show_header_page_fops = {
 	.open = tracing_open_generic_tr,
-	.read = show_header_page_file,
+	.read_iter = show_header_page_file,
 	.llseek = default_llseek,
 	.release = tracing_release_generic_tr,
 };
 
 static const struct file_operations ftrace_show_header_event_fops = {
 	.open = tracing_open_generic_tr,
-	.read = show_header_event_file,
+	.read_iter = show_header_event_file,
 	.llseek = default_llseek,
 	.release = tracing_release_generic_tr,
 };
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 6ece1308d36a..18e8914ffa67 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -5633,7 +5633,7 @@ static int event_hist_open(struct inode *inode, struct file *file)
 
 const struct file_operations event_hist_fops = {
 	.open = event_hist_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = tracing_single_release_file_tr,
 };
@@ -5912,7 +5912,7 @@ static int event_hist_debug_open(struct inode *inode, struct file *file)
 
 const struct file_operations event_hist_debug_fops = {
 	.open = event_hist_debug_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = tracing_single_release_file_tr,
 };
diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c
index 8650562bdaa9..840c3e786968 100644
--- a/kernel/trace/trace_events_inject.c
+++ b/kernel/trace/trace_events_inject.c
@@ -280,10 +280,9 @@ static int parse_entry(char *str, struct trace_event_call *call, void **pentry)
 	return entry_size;
 }
 
-static ssize_t
-event_inject_write(struct file *filp, const char __user *ubuf, size_t cnt,
-		   loff_t *ppos)
+static ssize_t event_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	struct trace_event_call *call;
 	struct trace_event_file *file;
 	int err = -ENODEV, size;
@@ -293,13 +292,13 @@ event_inject_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = memdup_user_nul(ubuf, cnt);
+	buf = iterdup_nul(from, cnt);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 	strim(buf);
 
 	mutex_lock(&event_mutex);
-	file = event_file_data(filp);
+	file = event_file_data(iocb->ki_filp);
 	if (file) {
 		call = file->event_call;
 		size = parse_entry(buf, call, &entry);
@@ -316,20 +315,18 @@ event_inject_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (err < 0)
 		return err;
 
-	*ppos += err;
+	iocb->ki_pos += err;
 	return cnt;
 }
 
-static ssize_t
-event_inject_read(struct file *file, char __user *buf, size_t size,
-		  loff_t *ppos)
+static ssize_t event_inject_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EPERM;
 }
 
 const struct file_operations event_inject_fops = {
 	.open = tracing_open_file_tr,
-	.read = event_inject_read,
-	.write = event_inject_write,
+	.read_iter = event_inject_read,
+	.write_iter = event_inject_write,
 	.release = tracing_release_file_tr,
 };
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index c82b401a294d..5ff782e5870e 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -2286,11 +2286,12 @@ static ssize_t synth_events_write(struct file *file,
 	return trace_parse_run_command(file, buffer, count, ppos,
 				       create_or_delete_synth_event);
 }
+FOPS_WRITE_ITER_HELPER(synth_events_write);
 
 static const struct file_operations synth_events_fops = {
 	.open           = synth_events_open,
-	.write		= synth_events_write,
-	.read           = seq_read,
+	.write_iter	= synth_events_write_iter,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = seq_release,
 };
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 4bec043c8690..9f838fa4691e 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -272,11 +272,11 @@ int trigger_process_regex(struct trace_event_file *file, char *buff)
 	return ret;
 }
 
-static ssize_t event_trigger_regex_write(struct file *file,
-					 const char __user *ubuf,
-					 size_t cnt, loff_t *ppos)
+static ssize_t event_trigger_regex_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 	struct trace_event_file *event_file;
+	size_t cnt = iov_iter_count(from);
 	ssize_t ret;
 	char *buf;
 
@@ -286,14 +286,14 @@ static ssize_t event_trigger_regex_write(struct file *file,
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = memdup_user_nul(ubuf, cnt);
+	buf = iterdup_nul(from, cnt);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
 	strim(buf);
 
 	mutex_lock(&event_mutex);
-	event_file = event_file_data(file);
+	event_file = event_file_data(iocb->ki_filp);
 	if (unlikely(!event_file)) {
 		mutex_unlock(&event_mutex);
 		kfree(buf);
@@ -306,7 +306,7 @@ static ssize_t event_trigger_regex_write(struct file *file,
 	if (ret < 0)
 		goto out;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 	ret = cnt;
  out:
 	return ret;
@@ -324,11 +324,9 @@ static int event_trigger_regex_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-event_trigger_write(struct file *filp, const char __user *ubuf,
-		    size_t cnt, loff_t *ppos)
+static ssize_t event_trigger_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return event_trigger_regex_write(filp, ubuf, cnt, ppos);
+	return event_trigger_regex_write(iocb, from);
 }
 
 static int
@@ -346,8 +344,8 @@ event_trigger_release(struct inode *inode, struct file *file)
 
 const struct file_operations event_trigger_fops = {
 	.open = event_trigger_open,
-	.read = seq_read,
-	.write = event_trigger_write,
+	.read_iter = seq_read_iter,
+	.write_iter = event_trigger_write,
 	.llseek = tracing_lseek,
 	.release = event_trigger_release,
 };
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 70d428c394b6..780329517bd5 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -2263,20 +2263,6 @@ static int user_events_open(struct inode *node, struct file *file)
 	return 0;
 }
 
-static ssize_t user_events_write(struct file *file, const char __user *ubuf,
-				 size_t count, loff_t *ppos)
-{
-	struct iov_iter i;
-
-	if (unlikely(*ppos != 0))
-		return -EFAULT;
-
-	if (unlikely(import_ubuf(ITER_SOURCE, (char __user *)ubuf, count, &i)))
-		return -EFAULT;
-
-	return user_events_write_core(file, &i);
-}
-
 static ssize_t user_events_write_iter(struct kiocb *kp, struct iov_iter *i)
 {
 	return user_events_write_core(kp->ki_filp, i);
@@ -2678,7 +2664,6 @@ static int user_events_release(struct inode *node, struct file *file)
 
 static const struct file_operations user_data_fops = {
 	.open		= user_events_open,
-	.write		= user_events_write,
 	.write_iter	= user_events_write_iter,
 	.unlocked_ioctl	= user_events_ioctl,
 	.release	= user_events_release,
@@ -2777,7 +2762,7 @@ static int user_status_open(struct inode *node, struct file *file)
 
 static const struct file_operations user_status_fops = {
 	.open		= user_status_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index c35fbaab2a47..1d761e2de910 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -1368,40 +1368,36 @@ static struct tracer graph_trace __tracer_data = {
 };
 
 
-static ssize_t
-graph_depth_write(struct file *filp, const char __user *ubuf, size_t cnt,
-		  loff_t *ppos)
+static ssize_t graph_depth_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
 	fgraph_max_depth = val;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
-static ssize_t
-graph_depth_read(struct file *filp, char __user *ubuf, size_t cnt,
-		 loff_t *ppos)
+static ssize_t graph_depth_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[15]; /* More than enough to hold UINT_MAX + "\n"*/
 	int n;
 
 	n = sprintf(buf, "%d\n", fgraph_max_depth);
-
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
 static const struct file_operations graph_depth_fops = {
 	.open		= tracing_open_generic,
-	.write		= graph_depth_write,
-	.read		= graph_depth_read,
+	.write_iter	= graph_depth_write,
+	.read_iter	= graph_depth_read,
 	.llseek		= generic_file_llseek,
 };
 
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index b791524a6536..eea28d7205ed 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -664,10 +664,8 @@ static void hwlat_tracer_stop(struct trace_array *tr);
 
 /**
  * hwlat_mode_write - Write function for "mode" entry
- * @filp: The active open file structure
- * @ubuf: The user buffer that contains the value to write
- * @cnt: The maximum number of bytes to write to "file"
- * @ppos: The current position in @file
+ * @iocb: Metadata for IO
+ * @from: The user buffer that contains the value to write
  *
  * This function provides a write implementation for the "mode" interface
  * to the hardware latency detector. hwlatd has different operation modes.
@@ -677,10 +675,10 @@ static void hwlat_tracer_stop(struct trace_array *tr);
  * among the allowed CPUs in a round-robin fashion. The "per-cpu" mode
  * creates one hwlatd thread per allowed CPU.
  */
-static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
-				 size_t cnt, loff_t *ppos)
+static ssize_t hwlat_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct trace_array *tr = hwlat_trace;
+	size_t cnt = iov_iter_count(from);
 	const char *mode;
 	char buf[64];
 	int ret, i;
@@ -688,7 +686,7 @@ static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, cnt))
+	if (!copy_from_iter_full(buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -720,9 +718,7 @@ static ssize_t hwlat_mode_write(struct file *filp, const char __user *ubuf,
 		hwlat_tracer_start(tr);
 	mutex_unlock(&trace_types_lock);
 
-	*ppos += cnt;
-
-
+	iocb->ki_pos += cnt;
 
 	return ret;
 }
@@ -753,10 +749,10 @@ static struct trace_min_max_param hwlat_window = {
 
 static const struct file_operations thread_mode_fops = {
 	.open		= hwlat_mode_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
-	.write		= hwlat_mode_write
+	.write_iter	= hwlat_mode_write
 };
 /**
  * init_tracefs - A function to initialize the tracefs interface files
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 14099cc17fc9..65006adc0854 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1247,14 +1247,15 @@ static ssize_t probes_write(struct file *file, const char __user *buffer,
 	return trace_parse_run_command(file, buffer, count, ppos,
 				       create_or_delete_trace_kprobe);
 }
+FOPS_WRITE_ITER_HELPER(probes_write);
 
 static const struct file_operations kprobe_events_ops = {
 	.owner          = THIS_MODULE,
 	.open           = probes_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = seq_release,
-	.write		= probes_write,
+	.write_iter	= probes_write_iter,
 };
 
 static unsigned long trace_kprobe_missed(struct trace_kprobe *tk)
@@ -1304,7 +1305,7 @@ static int profile_open(struct inode *inode, struct file *file)
 static const struct file_operations kprobe_profile_ops = {
 	.owner          = THIS_MODULE,
 	.open           = profile_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = seq_release,
 };
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index a8e28f9b9271..ac11c293656e 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2198,26 +2198,24 @@ static int osnoise_options_open(struct inode *inode, struct file *file)
 
 /**
  * osnoise_options_write - Write function for "options" entry
- * @filp: The active open file structure
- * @ubuf: The user buffer that contains the value to write
- * @cnt: The maximum number of bytes to write to "file"
- * @ppos: The current position in @file
+ * @iocb: Metadata for IO
+ * @from: The user buffer that contains the value to write
  *
  * Writing the option name sets the option, writing the "NO_"
  * prefix in front of the option name disables it.
  *
  * Writing "DEFAULTS" resets the option values to the default ones.
  */
-static ssize_t osnoise_options_write(struct file *filp, const char __user *ubuf,
-				     size_t cnt, loff_t *ppos)
+static ssize_t osnoise_options_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int running, option, enable, retval;
+	size_t cnt = iov_iter_count(from);
 	char buf[256], *option_str;
 
 	if (cnt >= 256)
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, cnt))
+	if (!copy_from_iter_full(buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -2281,10 +2279,9 @@ static ssize_t osnoise_options_write(struct file *filp, const char __user *ubuf,
  *
  * Prints the "cpus" output into the user-provided buffer.
  */
-static ssize_t
-osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
-		  loff_t *ppos)
+static ssize_t osnoise_cpus_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	ssize_t count = iov_iter_count(to);
 	char *mask_str;
 	int len;
 
@@ -2303,7 +2300,7 @@ osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
 		goto out_free;
 	}
 
-	count = simple_read_from_buffer(ubuf, count, ppos, mask_str, len);
+	count = simple_copy_to_iter(mask_str, &iocb->ki_pos, len, to);
 
 out_free:
 	kfree(mask_str);
@@ -2329,18 +2326,17 @@ osnoise_cpus_read(struct file *filp, char __user *ubuf, size_t count,
  * other CPUs. For instance, one might run osnoise in one HT CPU
  * while observing what is running on the sibling HT CPU.
  */
-static ssize_t
-osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
-		   loff_t *ppos)
+static ssize_t osnoise_cpus_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	cpumask_var_t osnoise_cpumask_new;
+	size_t count = iov_iter_count(from);
 	int running, err;
 	char buf[256];
 
 	if (count >= 256)
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL))
@@ -2460,11 +2456,9 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
  *
  * Prints 1 on timerlat, the number of interferences on osnoise, -1 on error.
  */
-static ssize_t
-timerlat_fd_read(struct file *file, char __user *ubuf, size_t count,
-		  loff_t *ppos)
+static ssize_t timerlat_fd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	long cpu = (long) file->private_data;
+	long cpu = (long) iocb->ki_filp->private_data;
 	struct osnoise_variables *osn_var;
 	struct timerlat_variables *tlat;
 	struct timerlat_sample s;
@@ -2665,7 +2659,7 @@ static struct trace_min_max_param timerlat_period = {
 
 static const struct file_operations timerlat_fd_fops = {
 	.open		= timerlat_fd_open,
-	.read		= timerlat_fd_read,
+	.read_iter	= timerlat_fd_read,
 	.release	= timerlat_fd_release,
 	.llseek		= generic_file_llseek,
 };
@@ -2673,17 +2667,17 @@ static const struct file_operations timerlat_fd_fops = {
 
 static const struct file_operations cpus_fops = {
 	.open		= tracing_open_generic,
-	.read		= osnoise_cpus_read,
-	.write		= osnoise_cpus_write,
+	.read_iter	= osnoise_cpus_read,
+	.write_iter	= osnoise_cpus_write,
 	.llseek		= generic_file_llseek,
 };
 
 static const struct file_operations osnoise_options_fops = {
 	.open		= osnoise_options_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
-	.write		= osnoise_options_write
+	.write_iter	= osnoise_options_write
 };
 
 #ifdef CONFIG_TIMERLAT_TRACER
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index 29f6e95439b6..c98e09959e3c 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -371,7 +371,7 @@ ftrace_formats_open(struct inode *inode, struct file *file)
 
 static const struct file_operations ftrace_formats_fops = {
 	.open = ftrace_formats_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
diff --git a/kernel/trace/trace_recursion_record.c b/kernel/trace/trace_recursion_record.c
index a520b11afb0d..d3b91a732d25 100644
--- a/kernel/trace/trace_recursion_record.c
+++ b/kernel/trace/trace_recursion_record.c
@@ -200,11 +200,9 @@ static int recursed_function_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t recursed_function_write(struct file *file,
-				       const char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t recursed_function_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return count;
+	return iov_iter_count(from);
 }
 
 static int recursed_function_release(struct inode *inode, struct file *file)
@@ -216,8 +214,8 @@ static int recursed_function_release(struct inode *inode, struct file *file)
 
 static const struct file_operations recursed_functions_fops = {
 	.open           = recursed_function_open,
-	.write		= recursed_function_write,
-	.read           = seq_read,
+	.write_iter	= recursed_function_write,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = recursed_function_release,
 };
diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
index 8a407adb0e1c..510c6320f7c7 100644
--- a/kernel/trace/trace_sched_switch.c
+++ b/kernel/trace/trace_sched_switch.c
@@ -510,7 +510,7 @@ static int tracing_saved_tgids_open(struct inode *inode, struct file *filp)
 
 const struct file_operations tracing_saved_tgids_fops = {
 	.open		= tracing_saved_tgids_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -589,14 +589,13 @@ static int tracing_saved_cmdlines_open(struct inode *inode, struct file *filp)
 
 const struct file_operations tracing_saved_cmdlines_fops = {
 	.open		= tracing_saved_cmdlines_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
 
 static ssize_t
-tracing_saved_cmdlines_size_read(struct file *filp, char __user *ubuf,
-				 size_t cnt, loff_t *ppos)
+tracing_saved_cmdlines_size_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int r;
@@ -607,7 +606,7 @@ tracing_saved_cmdlines_size_read(struct file *filp, char __user *ubuf,
 	arch_spin_unlock(&trace_cmdline_lock);
 	preempt_enable();
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
 void trace_free_saved_cmdlines_buffer(void)
@@ -635,13 +634,13 @@ static int tracing_resize_saved_cmdlines(unsigned int val)
 }
 
 static ssize_t
-tracing_saved_cmdlines_size_write(struct file *filp, const char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+tracing_saved_cmdlines_size_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+	ret = kstrtoul_from_iter(from, cnt, 10, &val);
 	if (ret)
 		return ret;
 
@@ -653,13 +652,13 @@ tracing_saved_cmdlines_size_write(struct file *filp, const char __user *ubuf,
 	if (ret < 0)
 		return ret;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
 const struct file_operations tracing_saved_cmdlines_size_fops = {
 	.open		= tracing_open_generic,
-	.read		= tracing_saved_cmdlines_size_read,
-	.write		= tracing_saved_cmdlines_size_write,
+	.read_iter	= tracing_saved_cmdlines_size_read,
+	.write_iter	= tracing_saved_cmdlines_size_write,
 };
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 5a48dba912ea..fb657b1203de 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -320,29 +320,26 @@ static struct ftrace_ops trace_ops __read_mostly =
 	.func = stack_trace_call,
 };
 
-static ssize_t
-stack_max_size_read(struct file *filp, char __user *ubuf,
-		    size_t count, loff_t *ppos)
+static ssize_t stack_max_size_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long *ptr = filp->private_data;
+	unsigned long *ptr = iocb->ki_filp->private_data;
 	char buf[64];
 	int r;
 
 	r = snprintf(buf, sizeof(buf), "%ld\n", *ptr);
 	if (r > sizeof(buf))
 		r = sizeof(buf);
-	return simple_read_from_buffer(ubuf, count, ppos, buf, r);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, r, to);
 }
 
-static ssize_t
-stack_max_size_write(struct file *filp, const char __user *ubuf,
-		     size_t count, loff_t *ppos)
+static ssize_t stack_max_size_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	long *ptr = filp->private_data;
+	long *ptr = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val, flags;
 	int ret;
 
-	ret = kstrtoul_from_user(ubuf, count, 10, &val);
+	ret = kstrtoul_from_iter(from, count, 10, &val);
 	if (ret)
 		return ret;
 
@@ -367,8 +364,8 @@ stack_max_size_write(struct file *filp, const char __user *ubuf,
 
 static const struct file_operations stack_max_size_fops = {
 	.open		= tracing_open_generic,
-	.read		= stack_max_size_read,
-	.write		= stack_max_size_write,
+	.read_iter	= stack_max_size_read,
+	.write_iter	= stack_max_size_write,
 	.llseek		= default_llseek,
 };
 
@@ -486,7 +483,7 @@ static int stack_trace_open(struct inode *inode, struct file *file)
 
 static const struct file_operations stack_trace_fops = {
 	.open		= stack_trace_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -505,8 +502,8 @@ stack_trace_filter_open(struct inode *inode, struct file *file)
 
 static const struct file_operations stack_trace_filter_fops = {
 	.open = stack_trace_filter_open,
-	.read = seq_read,
-	.write = ftrace_filter_write,
+	.read_iter = seq_read_iter,
+	.write_iter = ftrace_filter_write_iter,
 	.llseek = tracing_lseek,
 	.release = ftrace_regex_release,
 };
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index bb247beec447..d6cf9e0ecf81 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -269,7 +269,7 @@ static int tracing_stat_release(struct inode *i, struct file *f)
 
 static const struct file_operations tracing_stat_fops = {
 	.open		= tracing_stat_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= tracing_stat_release
 };
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 9e461362450a..04a06f938969 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -800,14 +800,15 @@ static ssize_t probes_write(struct file *file, const char __user *buffer,
 	return trace_parse_run_command(file, buffer, count, ppos,
 					create_or_delete_trace_uprobe);
 }
+FOPS_WRITE_ITER_HELPER(probes_write);
 
 static const struct file_operations uprobe_events_ops = {
 	.owner		= THIS_MODULE,
 	.open		= probes_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
-	.write		= probes_write,
+	.write_iter	= probes_write_iter,
 };
 
 /* Probes profiling interfaces */
@@ -846,7 +847,7 @@ static int profile_open(struct inode *inode, struct file *file)
 static const struct file_operations uprobe_profile_ops = {
 	.owner		= THIS_MODULE,
 	.open		= profile_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 081/437] gcov: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (79 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 080/437] tracing: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 082/437] sched/debug: " Jens Axboe
                   ` (356 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/gcov/fs.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 01520689b57c..02f966688ca3 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -379,14 +379,13 @@ static void remove_node(struct gcov_node *node);
  * corresponding file. If all associated object files have been unloaded,
  * remove the debug fs node as well.
  */
-static ssize_t gcov_seq_write(struct file *file, const char __user *addr,
-			      size_t len, loff_t *pos)
+static ssize_t gcov_seq_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct seq_file *seq;
 	struct gcov_info *info;
 	struct gcov_node *node;
 
-	seq = file->private_data;
+	seq = iocb->ki_filp->private_data;
 	info = gcov_iter_get_info(seq->private);
 	mutex_lock(&node_lock);
 	node = get_node_by_name(gcov_info_filename(info));
@@ -401,7 +400,7 @@ static ssize_t gcov_seq_write(struct file *file, const char __user *addr,
 	gcov_info_reset(info);
 	mutex_unlock(&node_lock);
 
-	return len;
+	return iov_iter_count(from);
 }
 
 /*
@@ -511,9 +510,9 @@ static void add_links(struct gcov_node *node, struct dentry *parent)
 static const struct file_operations gcov_data_fops = {
 	.open		= gcov_seq_open,
 	.release	= gcov_seq_release,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
-	.write		= gcov_seq_write,
+	.write_iter	= gcov_seq_write,
 };
 
 /* Basic initialization of a new node. */
@@ -632,8 +631,7 @@ static struct gcov_node *get_child_by_name(struct gcov_node *parent,
  * write() implementation for reset file. Reset all profiling data to zero
  * and remove nodes for which all associated object files are unloaded.
  */
-static ssize_t reset_write(struct file *file, const char __user *addr,
-			   size_t len, loff_t *pos)
+static ssize_t reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct gcov_node *node;
 
@@ -650,20 +648,19 @@ static ssize_t reset_write(struct file *file, const char __user *addr,
 	}
 	mutex_unlock(&node_lock);
 
-	return len;
+	return iov_iter_count(from);
 }
 
 /* read() implementation for reset file. Unused. */
-static ssize_t reset_read(struct file *file, char __user *addr, size_t len,
-			  loff_t *pos)
+static ssize_t reset_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	/* Allow read operation so that a recursive copy won't fail. */
 	return 0;
 }
 
 static const struct file_operations gcov_reset_fops = {
-	.write	= reset_write,
-	.read	= reset_read,
+	.write_iter	= reset_write,
+	.read_iter	= reset_read,
 	.llseek = noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 082/437] sched/debug: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (80 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 081/437] gcov: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 083/437] kernel/irq: convert debugfs helpers " Jens Axboe
                   ` (355 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/sched/debug.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 686a21ea1791..e1e7856727cb 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -120,26 +120,25 @@ static int sched_feat_set(char *cmp)
 	return 0;
 }
 
-static ssize_t
-sched_feat_write(struct file *filp, const char __user *ubuf,
-		size_t cnt, loff_t *ppos)
+static ssize_t sched_feat_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[64];
 	char *cmp;
 	int ret;
 	struct inode *inode;
+	size_t cnt = iov_iter_count(from);
 
 	if (cnt > 63)
 		cnt = 63;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
 	cmp = strstrip(buf);
 
 	/* Ensure the static_key remains in a consistent state */
-	inode = file_inode(filp);
+	inode = file_inode(iocb->ki_filp);
 	cpus_read_lock();
 	inode_lock(inode);
 	ret = sched_feat_set(cmp);
@@ -148,7 +147,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
 	if (ret < 0)
 		return ret;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -160,24 +159,25 @@ static int sched_feat_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations sched_feat_fops = {
 	.open		= sched_feat_open,
-	.write		= sched_feat_write,
-	.read		= seq_read,
+	.write_iter	= sched_feat_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
 
 #ifdef CONFIG_SMP
 
-static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
-				   size_t cnt, loff_t *ppos)
+static ssize_t sched_scaling_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	char buf[16];
 	unsigned int scaling;
 
 	if (cnt > 15)
 		cnt = 15;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 	buf[cnt] = '\0';
 
@@ -191,7 +191,7 @@ static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
 	if (sched_update_scaling())
 		return -EINVAL;
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 	return cnt;
 }
 
@@ -208,8 +208,8 @@ static int sched_scaling_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations sched_scaling_fops = {
 	.open		= sched_scaling_open,
-	.write		= sched_scaling_write,
-	.read		= seq_read,
+	.write_iter	= sched_scaling_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -218,16 +218,16 @@ static const struct file_operations sched_scaling_fops = {
 
 #ifdef CONFIG_PREEMPT_DYNAMIC
 
-static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
-				   size_t cnt, loff_t *ppos)
+static ssize_t sched_dynamic_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	char buf[16];
 	int mode;
 
 	if (cnt > 15)
 		cnt = 15;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -237,7 +237,7 @@ static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
 
 	sched_dynamic_update(mode);
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
@@ -270,8 +270,8 @@ static int sched_dynamic_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations sched_dynamic_fops = {
 	.open		= sched_dynamic_open,
-	.write		= sched_dynamic_write,
-	.read		= seq_read,
+	.write_iter	= sched_dynamic_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -327,7 +327,7 @@ static int sched_debug_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations sched_debug_fops = {
 	.open		= sched_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -402,7 +402,7 @@ static int sd_flags_open(struct inode *inode, struct file *file)
 
 static const struct file_operations sd_flags_fops = {
 	.open		= sd_flags_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 083/437] kernel/irq: convert debugfs helpers to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (81 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 082/437] sched/debug: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 084/437] locking/lock_events: convert " Jens Axboe
                   ` (354 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/irq/debugfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index aae0402507ed..addf000046b8 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -193,15 +193,15 @@ static int irq_debug_open(struct inode *inode, struct file *file)
 	return single_open(file, irq_debug_show, inode->i_private);
 }
 
-static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t irq_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct irq_desc *desc = file_inode(file)->i_private;
+	struct irq_desc *desc = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	char buf[8] = { 0, };
 	size_t size;
 
 	size = min(sizeof(buf) - 1, count);
-	if (copy_from_user(buf, user_buf, size))
+	if (!copy_from_iter_full(buf, size, from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "trigger", size)) {
@@ -215,8 +215,8 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
 
 static const struct file_operations dfs_irq_ops = {
 	.open		= irq_debug_open,
-	.write		= irq_debug_write,
-	.read		= seq_read,
+	.write_iter	= irq_debug_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 084/437] locking/lock_events: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (82 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 083/437] kernel/irq: convert debugfs helpers " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 085/437] kprobes: " Jens Axboe
                   ` (353 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/locking/lock_events.c    | 18 +++++++++---------
 kernel/locking/lock_events.h    |  4 ++--
 kernel/locking/qspinlock_stat.h |  7 +++----
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/kernel/locking/lock_events.c b/kernel/locking/lock_events.c
index e68d82099558..1f1efb123a1b 100644
--- a/kernel/locking/lock_events.c
+++ b/kernel/locking/lock_events.c
@@ -20,6 +20,7 @@
 #include <linux/sched.h>
 #include <linux/sched/clock.h>
 #include <linux/fs.h>
+#include <linux/uio.h>
 
 #include "lock_events.h"
 
@@ -58,8 +59,7 @@ DEFINE_PER_CPU(unsigned long, lockevents[lockevent_num]);
 /*
  * The lockevent_read() function can be overridden.
  */
-ssize_t __weak lockevent_read(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+ssize_t __weak lockevent_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int cpu, id, len;
@@ -68,7 +68,7 @@ ssize_t __weak lockevent_read(struct file *file, char __user *user_buf,
 	/*
 	 * Get the counter ID stored in file->f_inode->i_private
 	 */
-	id = (long)file_inode(file)->i_private;
+	id = (long)file_inode(iocb->ki_filp)->i_private;
 
 	if (id >= lockevent_num)
 		return -EBADF;
@@ -77,7 +77,7 @@ ssize_t __weak lockevent_read(struct file *file, char __user *user_buf,
 		sum += per_cpu(lockevents[id], cpu);
 	len = snprintf(buf, sizeof(buf) - 1, "%llu\n", sum);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -85,15 +85,15 @@ ssize_t __weak lockevent_read(struct file *file, char __user *user_buf,
  *
  * When idx = reset_cnts, reset all the counts.
  */
-static ssize_t lockevent_write(struct file *file, const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t lockevent_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int cpu;
 
 	/*
 	 * Get the counter ID stored in file->f_inode->i_private
 	 */
-	if ((long)file_inode(file)->i_private != LOCKEVENT_reset_cnts)
+	if ((long)file_inode(iocb->ki_filp)->i_private != LOCKEVENT_reset_cnts)
 		return count;
 
 	for_each_possible_cpu(cpu) {
@@ -110,8 +110,8 @@ static ssize_t lockevent_write(struct file *file, const char __user *user_buf,
  * Debugfs data structures
  */
 static const struct file_operations fops_lockevent = {
-	.read = lockevent_read,
-	.write = lockevent_write,
+	.read_iter = lockevent_read,
+	.write_iter = lockevent_write,
 	.llseek = default_llseek,
 };
 
diff --git a/kernel/locking/lock_events.h b/kernel/locking/lock_events.h
index a6016b91803d..0210d1abc4d7 100644
--- a/kernel/locking/lock_events.h
+++ b/kernel/locking/lock_events.h
@@ -58,7 +58,7 @@ static inline void __lockevent_add(enum lock_events event, int inc)
 
 #endif /* CONFIG_LOCK_EVENT_COUNTS */
 
-ssize_t lockevent_read(struct file *file, char __user *user_buf,
-		       size_t count, loff_t *ppos);
+struct kiocb;
+ssize_t lockevent_read(struct kiocb *iocb, struct iov_iter *to);
 
 #endif /* __LOCKING_LOCK_EVENTS_H */
diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h
index e625bb410aa2..efaabdcfcddc 100644
--- a/kernel/locking/qspinlock_stat.h
+++ b/kernel/locking/qspinlock_stat.h
@@ -33,8 +33,7 @@ static DEFINE_PER_CPU(u64, pv_kick_time);
  * 3. pv_hash_hops
  *    Average hops/hash = pv_hash_hops/pv_kick_unlock
  */
-ssize_t lockevent_read(struct file *file, char __user *user_buf,
-		       size_t count, loff_t *ppos)
+ssize_t lockevent_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int cpu, id, len;
@@ -43,7 +42,7 @@ ssize_t lockevent_read(struct file *file, char __user *user_buf,
 	/*
 	 * Get the counter ID stored in file->f_inode->i_private
 	 */
-	id = (long)file_inode(file)->i_private;
+	id = (long)file_inode(iocb->ki_filp)->i_private;
 
 	if (id >= lockevent_num)
 		return -EBADF;
@@ -91,7 +90,7 @@ ssize_t lockevent_read(struct file *file, char __user *user_buf,
 		len = snprintf(buf, sizeof(buf) - 1, "%llu\n", sum);
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 085/437] kprobes: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (83 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 084/437] locking/lock_events: convert " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 086/437] fs: add iterator based version of simple_transaction_read() Jens Axboe
                   ` (352 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 kernel/kprobes.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 9d9095e81792..ead4b7cb70d0 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2971,8 +2971,7 @@ static int disarm_all_kprobes(void)
  * when the bool state is switched. We can reuse that facility when
  * available
  */
-static ssize_t read_enabled_file_bool(struct file *file,
-	       char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t read_enabled_file_bool(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[3];
 
@@ -2982,16 +2981,16 @@ static ssize_t read_enabled_file_bool(struct file *file,
 		buf[0] = '0';
 	buf[1] = '\n';
 	buf[2] = 0x00;
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t write_enabled_file_bool(struct file *file,
-	       const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t write_enabled_file_bool(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int ret;
 
-	ret = kstrtobool_from_user(user_buf, count, &enable);
+	ret = kstrtobool_from_iter(from, count, &enable);
 	if (ret)
 		return ret;
 
@@ -3003,8 +3002,8 @@ static ssize_t write_enabled_file_bool(struct file *file,
 }
 
 static const struct file_operations fops_kp = {
-	.read =         read_enabled_file_bool,
-	.write =        write_enabled_file_bool,
+	.read_iter =    read_enabled_file_bool,
+	.write_iter =   write_enabled_file_bool,
 	.llseek =	default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 086/437] fs: add iterator based version of simple_transaction_read()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (84 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 085/437] kprobes: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 087/437] tomoyo: convert to read/write iterators Jens Axboe
                   ` (351 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/libfs.c         | 10 ++++++++++
 include/linux/fs.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/fs/libfs.c b/fs/libfs.c
index 3280d02fc385..56b404ad4cfb 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1277,6 +1277,16 @@ ssize_t simple_transaction_read(struct file *file, char __user *buf, size_t size
 }
 EXPORT_SYMBOL(simple_transaction_read);
 
+ssize_t simple_transaction_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	struct simple_transaction_argresp *ar = iocb->ki_filp->private_data;
+
+	if (!ar)
+		return 0;
+	return simple_copy_to_iter(ar->data, &iocb->ki_pos, ar->size, to);
+}
+EXPORT_SYMBOL(simple_transaction_read_iter);
+
 int simple_transaction_release(struct inode *inode, struct file *file)
 {
 	free_page((unsigned long)file->private_data);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 69e4dfac2853..85db7dde4778 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3500,6 +3500,7 @@ char *simple_transaction_get(struct file *file, const char __user *buf,
 				size_t size);
 ssize_t simple_transaction_read(struct file *file, char __user *buf,
 				size_t size, loff_t *pos);
+ssize_t simple_transaction_read_iter(struct kiocb *iocb, struct iov_iter *to);
 int simple_transaction_release(struct inode *inode, struct file *file);
 
 void simple_transaction_set(struct file *file, size_t n);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 087/437] tomoyo: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (85 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 086/437] fs: add iterator based version of simple_transaction_read() Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 088/437] smack: " Jens Axboe
                   ` (350 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/tomoyo/securityfs_if.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c
index a2705798476f..49421d5377f7 100644
--- a/security/tomoyo/securityfs_if.c
+++ b/security/tomoyo/securityfs_if.c
@@ -86,6 +86,7 @@ static ssize_t tomoyo_write_self(struct file *file, const char __user *buf,
 	kfree(data);
 	return error ? error : count;
 }
+FOPS_WRITE_ITER_HELPER(tomoyo_write_self);
 
 /**
  * tomoyo_read_self - read() for /sys/kernel/security/tomoyo/self_domain interface.
@@ -97,28 +98,28 @@ static ssize_t tomoyo_write_self(struct file *file, const char __user *buf,
  *
  * Returns read size on success, negative value otherwise.
  */
-static ssize_t tomoyo_read_self(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t tomoyo_read_self(struct kiocb *iocb, struct iov_iter *to)
 {
 	const char *domain = tomoyo_domain()->domainname->name;
+	size_t count = iov_iter_count(to);
 	loff_t len = strlen(domain);
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 
 	if (pos >= len || !count)
 		return 0;
 	len -= pos;
 	if (count < len)
 		len = count;
-	if (copy_to_user(buf, domain + pos, len))
+	if (copy_to_iter(domain + pos, len, to))
 		return -EFAULT;
-	*ppos += len;
+	iocb->ki_pos += len;
 	return len;
 }
 
 /* Operations for /sys/kernel/security/tomoyo/self_domain interface. */
 static const struct file_operations tomoyo_self_operations = {
-	.write = tomoyo_write_self,
-	.read  = tomoyo_read_self,
+	.write_iter = tomoyo_write_self_iter,
+	.read_iter  = tomoyo_read_self,
 };
 
 /**
@@ -178,6 +179,7 @@ static ssize_t tomoyo_read(struct file *file, char __user *buf, size_t count,
 {
 	return tomoyo_read_control(file->private_data, buf, count);
 }
+FOPS_READ_ITER_HELPER(tomoyo_read);
 
 /**
  * tomoyo_write - write() for /sys/kernel/security/tomoyo/ interface.
@@ -194,6 +196,7 @@ static ssize_t tomoyo_write(struct file *file, const char __user *buf,
 {
 	return tomoyo_write_control(file->private_data, buf, count);
 }
+FOPS_WRITE_ITER_HELPER(tomoyo_write);
 
 /*
  * tomoyo_operations is a "struct file_operations" which is used for handling
@@ -206,8 +209,8 @@ static const struct file_operations tomoyo_operations = {
 	.open    = tomoyo_open,
 	.release = tomoyo_release,
 	.poll    = tomoyo_poll,
-	.read    = tomoyo_read,
-	.write   = tomoyo_write,
+	.read_iter = tomoyo_read_iter,
+	.write_iter = tomoyo_write_iter,
 	.llseek  = noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 088/437] smack: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (86 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 087/437] tomoyo: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 089/437] apparmor: " Jens Axboe
                   ` (349 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/smack/smackfs.c | 281 ++++++++++++++++++---------------------
 1 file changed, 132 insertions(+), 149 deletions(-)

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index e22aad7604e8..49a380e45eb1 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -669,12 +669,13 @@ static ssize_t smk_write_load(struct file *file, const char __user *buf,
 	return smk_write_rules_list(file, buf, count, ppos, NULL, NULL,
 				    SMK_FIXED24_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_load);
 
 static const struct file_operations smk_load_ops = {
 	.open           = smk_open_load,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_load,
+	.write_iter	= smk_write_load_iter,
 	.release        = seq_release,
 };
 
@@ -964,12 +965,13 @@ static ssize_t smk_write_cipso(struct file *file, const char __user *buf,
 {
 	return smk_set_cipso(file, buf, count, ppos, SMK_FIXED24_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_cipso);
 
 static const struct file_operations smk_cipso_ops = {
 	.open           = smk_open_cipso,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_cipso,
+	.write_iter	= smk_write_cipso_iter,
 	.release        = seq_release,
 };
 
@@ -1038,12 +1040,13 @@ static ssize_t smk_write_cipso2(struct file *file, const char __user *buf,
 {
 	return smk_set_cipso(file, buf, count, ppos, SMK_LONG_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_cipso2);
 
 static const struct file_operations smk_cipso2_ops = {
 	.open           = smk_open_cipso2,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_cipso2,
+	.write_iter	= smk_write_cipso2_iter,
 	.release        = seq_release,
 };
 
@@ -1302,12 +1305,13 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf,
 
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_net4addr);
 
 static const struct file_operations smk_net4addr_ops = {
 	.open           = smk_open_net4addr,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_net4addr,
+	.write_iter	= smk_write_net4addr_iter,
 	.release        = seq_release,
 };
 
@@ -1559,52 +1563,48 @@ static ssize_t smk_write_net6addr(struct file *file, const char __user *buf,
 
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_net6addr);
 
 static const struct file_operations smk_net6addr_ops = {
 	.open           = smk_open_net6addr,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_net6addr,
+	.write_iter	= smk_write_net6addr_iter,
 	.release        = seq_release,
 };
 #endif /* CONFIG_IPV6 */
 
 /**
  * smk_read_doi - read() for /smack/doi
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_doi(struct file *filp, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t smk_read_doi(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[80];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d", smk_cipso_doi_value);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 
 	return rc;
 }
 
 /**
  * smk_write_doi - write() for /smack/doi
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t smk_write_doi(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t smk_write_doi(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char temp[80];
 	int i;
 
@@ -1614,7 +1614,7 @@ static ssize_t smk_write_doi(struct file *file, const char __user *buf,
 	if (count >= sizeof(temp) || count == 0)
 		return -EINVAL;
 
-	if (copy_from_user(temp, buf, count) != 0)
+	if (!copy_from_iter(temp, count, from))
 		return -EFAULT;
 
 	temp[count] = '\0';
@@ -1630,47 +1630,42 @@ static ssize_t smk_write_doi(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations smk_doi_ops = {
-	.read		= smk_read_doi,
-	.write		= smk_write_doi,
+	.read_iter	= smk_read_doi,
+	.write_iter	= smk_write_doi,
 	.llseek		= default_llseek,
 };
 
 /**
  * smk_read_direct - read() for /smack/direct
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_direct(struct file *filp, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t smk_read_direct(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[80];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d", smack_cipso_direct);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 
 	return rc;
 }
 
 /**
  * smk_write_direct - write() for /smack/direct
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t smk_write_direct(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t smk_write_direct(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct smack_known *skp;
 	char temp[80];
 	int i;
@@ -1681,7 +1676,7 @@ static ssize_t smk_write_direct(struct file *file, const char __user *buf,
 	if (count >= sizeof(temp) || count == 0)
 		return -EINVAL;
 
-	if (copy_from_user(temp, buf, count) != 0)
+	if (!copy_from_iter(temp, count, from))
 		return -EFAULT;
 
 	temp[count] = '\0';
@@ -1708,47 +1703,42 @@ static ssize_t smk_write_direct(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations smk_direct_ops = {
-	.read		= smk_read_direct,
-	.write		= smk_write_direct,
+	.read_iter	= smk_read_direct,
+	.write_iter	= smk_write_direct,
 	.llseek		= default_llseek,
 };
 
 /**
  * smk_read_mapped - read() for /smack/mapped
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_mapped(struct file *filp, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t smk_read_mapped(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[80];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d", smack_cipso_mapped);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 
 	return rc;
 }
 
 /**
  * smk_write_mapped - write() for /smack/mapped
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t smk_write_mapped(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t smk_write_mapped(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct smack_known *skp;
 	char temp[80];
 	int i;
@@ -1759,7 +1749,7 @@ static ssize_t smk_write_mapped(struct file *file, const char __user *buf,
 	if (count >= sizeof(temp) || count == 0)
 		return -EINVAL;
 
-	if (copy_from_user(temp, buf, count) != 0)
+	if (!copy_from_iter(temp, count, from))
 		return -EFAULT;
 
 	temp[count] = '\0';
@@ -1786,27 +1776,25 @@ static ssize_t smk_write_mapped(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations smk_mapped_ops = {
-	.read		= smk_read_mapped,
-	.write		= smk_write_mapped,
+	.read_iter	= smk_read_mapped,
+	.write_iter	= smk_write_mapped,
 	.llseek		= default_llseek,
 };
 
 /**
  * smk_read_ambient - read() for /smack/ambient
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @cn: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_ambient(struct file *filp, char __user *buf,
-				size_t cn, loff_t *ppos)
+static ssize_t smk_read_ambient(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t cn = iov_iter_count(to);
 	ssize_t rc;
 	int asize;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	/*
 	 * Being careful to avoid a problem in the case where
@@ -1817,9 +1805,8 @@ static ssize_t smk_read_ambient(struct file *filp, char __user *buf,
 	asize = strlen(smack_net_ambient->smk_known) + 1;
 
 	if (cn >= asize)
-		rc = simple_read_from_buffer(buf, cn, ppos,
-					     smack_net_ambient->smk_known,
-					     asize);
+		rc = simple_copy_to_iter(smack_net_ambient->smk_known,
+					 &iocb->ki_pos, asize, to);
 	else
 		rc = -EINVAL;
 
@@ -1874,10 +1861,11 @@ static ssize_t smk_write_ambient(struct file *file, const char __user *buf,
 	kfree(data);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_ambient);
 
 static const struct file_operations smk_ambient_ops = {
-	.read		= smk_read_ambient,
-	.write		= smk_write_ambient,
+	.read_iter	= smk_read_ambient,
+	.write_iter	= smk_write_ambient_iter,
 	.llseek		= default_llseek,
 };
 
@@ -2054,11 +2042,12 @@ static ssize_t smk_write_onlycap(struct file *file, const char __user *buf,
 
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_onlycap);
 
 static const struct file_operations smk_onlycap_ops = {
 	.open		= smk_open_onlycap,
-	.read		= seq_read,
-	.write		= smk_write_onlycap,
+	.read_iter	= seq_read_iter,
+	.write_iter	= smk_write_onlycap_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -2066,21 +2055,19 @@ static const struct file_operations smk_onlycap_ops = {
 #ifdef CONFIG_SECURITY_SMACK_BRINGUP
 /**
  * smk_read_unconfined - read() for smackfs/unconfined
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @cn: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_unconfined(struct file *filp, char __user *buf,
-					size_t cn, loff_t *ppos)
+static ssize_t smk_read_unconfined(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t cn = iov_iter_count(to);
 	char *smack = "";
 	ssize_t rc = -EINVAL;
 	int asize;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (smack_unconfined != NULL)
@@ -2089,7 +2076,7 @@ static ssize_t smk_read_unconfined(struct file *filp, char __user *buf,
 	asize = strlen(smack) + 1;
 
 	if (cn >= asize)
-		rc = simple_read_from_buffer(buf, cn, ppos, smack, asize);
+		rc = simple_copy_to_iter(smack, &iocb->ki_pos, asize, to);
 
 	return rc;
 }
@@ -2143,49 +2130,45 @@ static ssize_t smk_write_unconfined(struct file *file, const char __user *buf,
 	kfree(data);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_unconfined);
 
 static const struct file_operations smk_unconfined_ops = {
-	.read		= smk_read_unconfined,
-	.write		= smk_write_unconfined,
+	.read_iter	= smk_read_unconfined,
+	.write_iter	= smk_write_unconfined_iter,
 	.llseek		= default_llseek,
 };
 #endif /* CONFIG_SECURITY_SMACK_BRINGUP */
 
 /**
  * smk_read_logging - read() for /smack/logging
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_logging(struct file *filp, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t smk_read_logging(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[32];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d\n", log_policy);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 	return rc;
 }
 
 /**
  * smk_write_logging - write() for /smack/logging
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t smk_write_logging(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t smk_write_logging(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char temp[32];
 	int i;
 
@@ -2195,7 +2178,7 @@ static ssize_t smk_write_logging(struct file *file, const char __user *buf,
 	if (count >= sizeof(temp) || count == 0)
 		return -EINVAL;
 
-	if (copy_from_user(temp, buf, count) != 0)
+	if (!copy_from_iter(temp, count, from))
 		return -EFAULT;
 
 	temp[count] = '\0';
@@ -2208,11 +2191,9 @@ static ssize_t smk_write_logging(struct file *file, const char __user *buf,
 	return count;
 }
 
-
-
 static const struct file_operations smk_logging_ops = {
-	.read		= smk_read_logging,
-	.write		= smk_write_logging,
+	.read_iter	= smk_read_logging,
+	.write_iter	= smk_write_logging,
 	.llseek		= default_llseek,
 };
 
@@ -2281,12 +2262,13 @@ static ssize_t smk_write_load_self(struct file *file, const char __user *buf,
 	return smk_write_rules_list(file, buf, count, ppos, &tsp->smk_rules,
 				    &tsp->smk_rules_lock, SMK_FIXED24_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_load_self);
 
 static const struct file_operations smk_load_self_ops = {
 	.open           = smk_open_load_self,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_load_self,
+	.write_iter	= smk_write_load_self_iter,
 	.release        = seq_release,
 };
 
@@ -2351,10 +2333,11 @@ static ssize_t smk_write_access(struct file *file, const char __user *buf,
 {
 	return smk_user_access(file, buf, count, ppos, SMK_FIXED24_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_access);
 
 static const struct file_operations smk_access_ops = {
-	.write		= smk_write_access,
-	.read		= simple_transaction_read,
+	.write_iter	= smk_write_access_iter,
+	.read_iter	= simple_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= generic_file_llseek,
 };
@@ -2416,12 +2399,13 @@ static ssize_t smk_write_load2(struct file *file, const char __user *buf,
 	return smk_write_rules_list(file, buf, count, ppos, NULL, NULL,
 				    SMK_LONG_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_load2);
 
 static const struct file_operations smk_load2_ops = {
 	.open           = smk_open_load2,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_load2,
+	.write_iter	= smk_write_load2_iter,
 	.release        = seq_release,
 };
 
@@ -2489,12 +2473,13 @@ static ssize_t smk_write_load_self2(struct file *file, const char __user *buf,
 	return smk_write_rules_list(file, buf, count, ppos, &tsp->smk_rules,
 				    &tsp->smk_rules_lock, SMK_LONG_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_load_self2);
 
 static const struct file_operations smk_load_self2_ops = {
 	.open           = smk_open_load_self2,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek         = seq_lseek,
-	.write		= smk_write_load_self2,
+	.write_iter	= smk_write_load_self2_iter,
 	.release        = seq_release,
 };
 
@@ -2510,10 +2495,11 @@ static ssize_t smk_write_access2(struct file *file, const char __user *buf,
 {
 	return smk_user_access(file, buf, count, ppos, SMK_LONG_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_access2);
 
 static const struct file_operations smk_access2_ops = {
-	.write		= smk_write_access2,
-	.read		= simple_transaction_read,
+	.write_iter	= smk_write_access2_iter,
+	.read_iter	= simple_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= generic_file_llseek,
 };
@@ -2576,10 +2562,11 @@ static ssize_t smk_write_revoke_subj(struct file *file, const char __user *buf,
 
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_revoke_subj);
 
 static const struct file_operations smk_revoke_subj_ops = {
-	.write		= smk_write_revoke_subj,
-	.read		= simple_transaction_read,
+	.write_iter	= smk_write_revoke_subj_iter,
+	.read_iter	= simple_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= generic_file_llseek,
 };
@@ -2612,31 +2599,30 @@ static ssize_t smk_write_change_rule(struct file *file, const char __user *buf,
 	return smk_write_rules_list(file, buf, count, ppos, NULL, NULL,
 				    SMK_CHANGE_FMT);
 }
+FOPS_WRITE_ITER_HELPER(smk_write_change_rule);
 
 static const struct file_operations smk_change_rule_ops = {
-	.write		= smk_write_change_rule,
-	.read		= simple_transaction_read,
+	.write_iter	= smk_write_change_rule_iter,
+	.read_iter	= simple_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= generic_file_llseek,
 };
 
 /**
  * smk_read_syslog - read() for smackfs/syslog
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @cn: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_syslog(struct file *filp, char __user *buf,
-				size_t cn, loff_t *ppos)
+static ssize_t smk_read_syslog(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t cn = iov_iter_count(to);
 	struct smack_known *skp;
 	ssize_t rc = -EINVAL;
 	int asize;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (smack_syslog_label == NULL)
@@ -2647,8 +2633,8 @@ static ssize_t smk_read_syslog(struct file *filp, char __user *buf,
 	asize = strlen(skp->smk_known) + 1;
 
 	if (cn >= asize)
-		rc = simple_read_from_buffer(buf, cn, ppos, skp->smk_known,
-						asize);
+		rc = simple_copy_to_iter(skp->smk_known, &iocb->ki_pos, asize,
+					 to);
 
 	return rc;
 }
@@ -2689,10 +2675,11 @@ static ssize_t smk_write_syslog(struct file *file, const char __user *buf,
 	kfree(data);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_syslog);
 
 static const struct file_operations smk_syslog_ops = {
-	.read		= smk_read_syslog,
-	.write		= smk_write_syslog,
+	.read_iter	= smk_read_syslog,
+	.write_iter	= smk_write_syslog_iter,
 	.llseek		= default_llseek,
 };
 
@@ -2802,58 +2789,54 @@ static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf,
 	smk_destroy_label_list(&list_tmp);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(smk_write_relabel_self);
 
 static const struct file_operations smk_relabel_self_ops = {
 	.open		= smk_open_relabel_self,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
-	.write		= smk_write_relabel_self,
+	.write_iter	= smk_write_relabel_self_iter,
 	.release	= seq_release,
 };
 
 /**
  * smk_read_ptrace - read() for /smack/ptrace
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t smk_read_ptrace(struct file *filp, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t smk_read_ptrace(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[32];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d\n", smack_ptrace_rule);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 	return rc;
 }
 
 /**
  * smk_write_ptrace - write() for /smack/ptrace
- * @file: file pointer
- * @buf: data from user space
- * @count: bytes sent
- * @ppos: where to start - must be 0
+ * @iocb: metadata for IO
+ * @to: data from user space
  */
-static ssize_t smk_write_ptrace(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t smk_write_ptrace(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	char temp[32];
 	int i;
 
 	if (!smack_privileged(CAP_MAC_ADMIN))
 		return -EPERM;
 
-	if (*ppos != 0 || count >= sizeof(temp) || count == 0)
+	if (iocb->ki_pos != 0 || count >= sizeof(temp) || count == 0)
 		return -EINVAL;
 
-	if (copy_from_user(temp, buf, count) != 0)
+	if (!copy_from_iter(temp, count, to))
 		return -EFAULT;
 
 	temp[count] = '\0';
@@ -2868,8 +2851,8 @@ static ssize_t smk_write_ptrace(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations smk_ptrace_ops = {
-	.write		= smk_write_ptrace,
-	.read		= smk_read_ptrace,
+	.write_iter	= smk_write_ptrace,
+	.read_iter	= smk_read_ptrace,
 	.llseek		= default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 089/437] apparmor: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (87 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 088/437] smack: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 090/437] landlock: " Jens Axboe
                   ` (348 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/apparmor/apparmorfs.c | 55 ++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index bcfea073e3f2..b8d54d54a441 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -450,9 +450,10 @@ static ssize_t profile_load(struct file *f, const char __user *buf, size_t size,
 
 	return error;
 }
+FOPS_WRITE_ITER_HELPER(profile_load);
 
 static const struct file_operations aa_fs_profile_load = {
-	.write = profile_load,
+	.write_iter = profile_load_iter,
 	.llseek = default_llseek,
 };
 
@@ -467,9 +468,10 @@ static ssize_t profile_replace(struct file *f, const char __user *buf,
 
 	return error;
 }
+FOPS_WRITE_ITER_HELPER(profile_replace);
 
 static const struct file_operations aa_fs_profile_replace = {
-	.write = profile_replace,
+	.write_iter = profile_replace_iter,
 	.llseek = default_llseek,
 };
 
@@ -508,9 +510,10 @@ static ssize_t profile_remove(struct file *f, const char __user *buf,
 	aa_put_ns(ns);
 	return error;
 }
+FOPS_WRITE_ITER_HELPER(profile_remove);
 
 static const struct file_operations aa_fs_profile_remove = {
-	.write = profile_remove,
+	.write_iter = profile_remove_iter,
 	.llseek = default_llseek,
 };
 
@@ -532,10 +535,11 @@ static int ns_revision_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ns_revision_read(struct file *file, char __user *buf,
-				size_t size, loff_t *ppos)
+static ssize_t ns_revision_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	struct aa_revision *rev = file->private_data;
+	size_t size = iov_iter_count(to);
 	char buffer[32];
 	long last_read;
 	int avail;
@@ -554,13 +558,13 @@ static ssize_t ns_revision_read(struct file *file, char __user *buf,
 	}
 
 	avail = sprintf(buffer, "%ld\n", rev->ns->revision);
-	if (*ppos + size > avail) {
+	if (iocb->ki_pos + size > avail) {
 		rev->last_read = rev->ns->revision;
-		*ppos = 0;
+		iocb->ki_pos = 0;
 	}
 	mutex_unlock(&rev->ns->lock);
 
-	return simple_read_from_buffer(buf, size, ppos, buffer, avail);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, avail, to);
 }
 
 static int ns_revision_open(struct inode *inode, struct file *file)
@@ -604,7 +608,7 @@ static const struct file_operations aa_fs_ns_revision_fops = {
 	.owner		= THIS_MODULE,
 	.open		= ns_revision_open,
 	.poll		= ns_revision_poll,
-	.read		= ns_revision_read,
+	.read_iter	= ns_revision_read,
 	.llseek		= generic_file_llseek,
 	.release	= ns_revision_release,
 };
@@ -878,9 +882,9 @@ static struct multi_transaction *multi_transaction_new(struct file *file,
 	return t;
 }
 
-static ssize_t multi_transaction_read(struct file *file, char __user *buf,
-				       size_t size, loff_t *pos)
+static ssize_t multi_transaction_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	struct multi_transaction *t;
 	ssize_t ret;
 
@@ -891,7 +895,7 @@ static ssize_t multi_transaction_read(struct file *file, char __user *buf,
 	if (!t)
 		return 0;
 
-	ret = simple_read_from_buffer(buf, size, pos, t->data, t->size);
+	ret = simple_copy_to_iter(t->data, &iocb->ki_pos, t->size, to);
 	put_multi_transaction(t);
 
 	return ret;
@@ -980,10 +984,11 @@ static ssize_t aa_write_access(struct file *file, const char __user *ubuf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(aa_write_access);
 
 static const struct file_operations aa_sfs_access = {
-	.write		= aa_write_access,
-	.read		= multi_transaction_read,
+	.write_iter	= aa_write_access_iter,
+	.read_iter	= multi_transaction_read,
 	.release	= multi_transaction_release,
 	.llseek		= generic_file_llseek,
 };
@@ -1021,7 +1026,7 @@ static int aa_sfs_seq_open(struct inode *inode, struct file *file)
 const struct file_operations aa_sfs_seq_file_ops = {
 	.owner		= THIS_MODULE,
 	.open		= aa_sfs_seq_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1040,7 +1045,7 @@ static int seq_profile_ ##NAME ##_open(struct inode *inode, struct file *file)\
 static const struct file_operations seq_profile_ ##NAME ##_fops = {	      \
 	.owner		= THIS_MODULE,					      \
 	.open		= seq_profile_ ##NAME ##_open,			      \
-	.read		= seq_read,					      \
+	.read_iter	= seq_read_iter,				      \
 	.llseek		= seq_lseek,					      \
 	.release	= seq_profile_release,				      \
 }									      \
@@ -1142,7 +1147,7 @@ static int seq_ns_ ##NAME ##_open(struct inode *inode, struct file *file)     \
 static const struct file_operations seq_ns_ ##NAME ##_fops = {	      \
 	.owner		= THIS_MODULE,					      \
 	.open		= seq_ns_ ##NAME ##_open,			      \
-	.read		= seq_read,					      \
+	.read_iter	= seq_read_iter,				      \
 	.llseek		= seq_lseek,					      \
 	.release	= single_release,				      \
 }									      \
@@ -1232,7 +1237,7 @@ static int seq_rawdata_ ##NAME ##_open(struct inode *inode, struct file *file)\
 static const struct file_operations seq_rawdata_ ##NAME ##_fops = {	      \
 	.owner		= THIS_MODULE,					      \
 	.open		= seq_rawdata_ ##NAME ##_open,			      \
-	.read		= seq_read,					      \
+	.read_iter	= seq_read_iter,				      \
 	.llseek		= seq_lseek,					      \
 	.release	= seq_rawdata_release,				      \
 }									      \
@@ -1348,14 +1353,12 @@ static int decompress_zstd(char *src, size_t slen, char *dst, size_t dlen)
 	return 0;
 }
 
-static ssize_t rawdata_read(struct file *file, char __user *buf, size_t size,
-			    loff_t *ppos)
+static ssize_t rawdata_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rawdata_f_data *private = file->private_data;
+	struct rawdata_f_data *private = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, size, ppos,
-				       RAWDATA_F_DATA_BUF(private),
-				       private->loaddata->size);
+	return simple_copy_to_iter(RAWDATA_F_DATA_BUF(private), &iocb->ki_pos,
+				       private->loaddata->size, to);
 }
 
 static int rawdata_release(struct inode *inode, struct file *file)
@@ -1407,7 +1410,7 @@ static int rawdata_open(struct inode *inode, struct file *file)
 
 static const struct file_operations rawdata_fops = {
 	.open = rawdata_open,
-	.read = rawdata_read,
+	.read_iter = rawdata_read,
 	.llseek = generic_file_llseek,
 	.release = rawdata_release,
 };
@@ -2298,7 +2301,7 @@ static int profiles_release(struct inode *inode, struct file *file)
 
 static const struct file_operations aa_sfs_profiles_fops = {
 	.open = profiles_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = profiles_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 090/437] landlock: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (88 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 089/437] apparmor: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 091/437] lsm: " Jens Axboe
                   ` (347 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/landlock/syscalls.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c
index 6788e73b6681..9a79b90f4dc9 100644
--- a/security/landlock/syscalls.c
+++ b/security/landlock/syscalls.c
@@ -122,21 +122,12 @@ static int fop_ruleset_release(struct inode *const inode,
 	return 0;
 }
 
-static ssize_t fop_dummy_read(struct file *const filp, char __user *const buf,
-			      const size_t size, loff_t *const ppos)
+static ssize_t fop_dummy_iter(struct kiocb *iocb, struct iov_iter *iov)
 {
 	/* Dummy handler to enable FMODE_CAN_READ. */
 	return -EINVAL;
 }
 
-static ssize_t fop_dummy_write(struct file *const filp,
-			       const char __user *const buf, const size_t size,
-			       loff_t *const ppos)
-{
-	/* Dummy handler to enable FMODE_CAN_WRITE. */
-	return -EINVAL;
-}
-
 /*
  * A ruleset file descriptor enables to build a ruleset by adding (i.e.
  * writing) rule after rule, without relying on the task's context.  This
@@ -145,8 +136,8 @@ static ssize_t fop_dummy_write(struct file *const filp,
  */
 static const struct file_operations ruleset_fops = {
 	.release = fop_ruleset_release,
-	.read = fop_dummy_read,
-	.write = fop_dummy_write,
+	.read_iter = fop_dummy_iter,
+	.write_iter = fop_dummy_iter,
 };
 
 #define LANDLOCK_ABI_VERSION 4
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 091/437] lsm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (89 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 090/437] landlock: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 092/437] selinux: " Jens Axboe
                   ` (346 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/safesetid/securityfs.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
index 25310468bcdd..82e1e9c37db2 100644
--- a/security/safesetid/securityfs.c
+++ b/security/safesetid/securityfs.c
@@ -245,6 +245,7 @@ static ssize_t safesetid_uid_file_write(struct file *file,
 
 	return handle_policy_update(file, buf, len, UID);
 }
+FOPS_WRITE_ITER_HELPER(safesetid_uid_file_write);
 
 static ssize_t safesetid_gid_file_write(struct file *file,
 				    const char __user *buf,
@@ -259,6 +260,7 @@ static ssize_t safesetid_gid_file_write(struct file *file,
 
 	return handle_policy_update(file, buf, len, GID);
 }
+FOPS_WRITE_ITER_HELPER(safesetid_gid_file_write);
 
 static ssize_t safesetid_file_read(struct file *file, char __user *buf,
 				   size_t len, loff_t *ppos, struct mutex *policy_update_lock, struct __rcu setid_ruleset* ruleset)
@@ -285,6 +287,7 @@ static ssize_t safesetid_uid_file_read(struct file *file, char __user *buf,
 	return safesetid_file_read(file, buf, len, ppos,
 				   &uid_policy_update_lock, safesetid_setuid_rules);
 }
+FOPS_READ_ITER_HELPER(safesetid_uid_file_read);
 
 static ssize_t safesetid_gid_file_read(struct file *file, char __user *buf,
 				   size_t len, loff_t *ppos)
@@ -292,17 +295,16 @@ static ssize_t safesetid_gid_file_read(struct file *file, char __user *buf,
 	return safesetid_file_read(file, buf, len, ppos,
 				   &gid_policy_update_lock, safesetid_setgid_rules);
 }
-
-
+FOPS_READ_ITER_HELPER(safesetid_gid_file_read);
 
 static const struct file_operations safesetid_uid_file_fops = {
-	.read = safesetid_uid_file_read,
-	.write = safesetid_uid_file_write,
+	.read_iter = safesetid_uid_file_read_iter,
+	.write_iter = safesetid_uid_file_write_iter,
 };
 
 static const struct file_operations safesetid_gid_file_fops = {
-	.read = safesetid_gid_file_read,
-	.write = safesetid_gid_file_write,
+	.read_iter = safesetid_gid_file_read_iter,
+	.write_iter = safesetid_gid_file_write_iter,
 };
 
 static int __init safesetid_init_securityfs(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 092/437] selinux: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (90 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 091/437] lsm: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 093/437] integrity: " Jens Axboe
                   ` (345 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/selinux/selinuxfs.c | 168 +++++++++++++++++------------------
 1 file changed, 82 insertions(+), 86 deletions(-)

diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 074d6c2714eb..9ac5bcf5edc4 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -120,15 +120,14 @@ static void selinux_fs_info_free(struct super_block *sb)
 #define POLICYCAP_DIR_NAME "policy_capabilities"
 
 #define TMPBUFLEN	12
-static ssize_t sel_read_enforce(struct file *filp, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t sel_read_enforce(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%d",
 			   enforcing_enabled());
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
@@ -186,32 +185,32 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
 	kfree(page);
 	return length;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_enforce);
 #else
-#define sel_write_enforce NULL
+#define sel_write_enforce_iter NULL
 #endif
 
 static const struct file_operations sel_enforce_ops = {
-	.read		= sel_read_enforce,
-	.write		= sel_write_enforce,
+	.read_iter	= sel_read_enforce,
+	.write_iter	= sel_write_enforce_iter,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t sel_read_handle_unknown(struct file *filp, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t sel_read_handle_unknown(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
-	ino_t ino = file_inode(filp)->i_ino;
+	ino_t ino = file_inode(iocb->ki_filp)->i_ino;
 	int handle_unknown = (ino == SEL_REJECT_UNKNOWN) ?
 		security_get_reject_unknown() :
 		!security_get_allow_unknown();
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%d", handle_unknown);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations sel_handle_unknown_ops = {
-	.read		= sel_read_handle_unknown,
+	.read_iter	= sel_read_handle_unknown,
 	.llseek		= generic_file_llseek,
 };
 
@@ -227,16 +226,14 @@ static int sel_open_handle_status(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t sel_read_handle_status(struct file *filp, char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t sel_read_handle_status(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct page    *status = filp->private_data;
+	struct page    *status = iocb->ki_filp->private_data;
 
 	BUG_ON(!status);
 
-	return simple_read_from_buffer(buf, count, ppos,
-				       page_address(status),
-				       sizeof(struct selinux_kernel_status));
+	return simple_copy_to_iter(page_address(status), &iocb->ki_pos,
+				       sizeof(struct selinux_kernel_status), to);
 }
 
 static int sel_mmap_handle_status(struct file *filp,
@@ -263,7 +260,7 @@ static int sel_mmap_handle_status(struct file *filp,
 
 static const struct file_operations sel_handle_status_ops = {
 	.open		= sel_open_handle_status,
-	.read		= sel_read_handle_status,
+	.read_iter	= sel_read_handle_status,
 	.mmap		= sel_mmap_handle_status,
 	.llseek		= generic_file_llseek,
 };
@@ -302,24 +299,24 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
 	kfree(page);
 	return length;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_disable);
 
 static const struct file_operations sel_disable_ops = {
-	.write		= sel_write_disable,
+	.write_iter	= sel_write_disable_iter,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t sel_read_policyvers(struct file *filp, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t sel_read_policyvers(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u", POLICYDB_VERSION_MAX);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations sel_policyvers_ops = {
-	.read		= sel_read_policyvers,
+	.read_iter	= sel_read_policyvers,
 	.llseek		= generic_file_llseek,
 };
 
@@ -339,19 +336,18 @@ static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
 static struct dentry *sel_make_swapover_dir(struct super_block *sb,
 						unsigned long *ino);
 
-static ssize_t sel_read_mls(struct file *filp, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t sel_read_mls(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%d",
 			   security_mls_enabled());
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations sel_mls_ops = {
-	.read		= sel_read_mls,
+	.read_iter	= sel_read_mls,
 	.llseek		= generic_file_llseek,
 };
 
@@ -425,10 +421,9 @@ static int sel_release_policy(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t sel_read_policy(struct file *filp, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t sel_read_policy(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct policy_load_memory *plm = filp->private_data;
+	struct policy_load_memory *plm = iocb->ki_filp->private_data;
 	int ret;
 
 	ret = avc_has_perm(current_sid(), SECINITSID_SECURITY,
@@ -436,7 +431,7 @@ static ssize_t sel_read_policy(struct file *filp, char __user *buf,
 	if (ret)
 		return ret;
 
-	return simple_read_from_buffer(buf, count, ppos, plm->data, plm->len);
+	return simple_copy_to_iter(plm->data, &iocb->ki_pos, plm->len, to);
 }
 
 static vm_fault_t sel_mmap_policy_fault(struct vm_fault *vmf)
@@ -483,7 +478,7 @@ static int sel_mmap_policy(struct file *filp, struct vm_area_struct *vma)
 
 static const struct file_operations sel_policy_ops = {
 	.open		= sel_open_policy,
-	.read		= sel_read_policy,
+	.read_iter	= sel_read_policy,
 	.mmap		= sel_mmap_policy,
 	.release	= sel_release_policy,
 	.llseek		= generic_file_llseek,
@@ -567,12 +562,13 @@ static int sel_make_policy_nodes(struct selinux_fs_info *fsi,
 	return ret;
 }
 
-static ssize_t sel_write_load(struct file *file, const char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t sel_write_load(struct kiocb *iocb, struct iov_iter *from)
 
 {
+	struct file *file = iocb->ki_filp;
 	struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info;
 	struct selinux_load_state load_state;
+	size_t count = iov_iter_count(from);
 	ssize_t length;
 	void *data = NULL;
 
@@ -585,7 +581,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
 
 	/* No partial writes. */
 	length = -EINVAL;
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		goto out;
 
 	length = -ENOMEM;
@@ -594,7 +590,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
 		goto out;
 
 	length = -EFAULT;
-	if (copy_from_user(data, buf, count) != 0)
+	if (!copy_from_iter_full(data, count, from))
 		goto out;
 
 	length = security_load_policy(data, count, &load_state);
@@ -625,7 +621,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations sel_load_ops = {
-	.write		= sel_write_load,
+	.write_iter	= sel_write_load,
 	.llseek		= generic_file_llseek,
 };
 
@@ -662,15 +658,14 @@ static ssize_t sel_write_context(struct file *file, char *buf, size_t size)
 	return length;
 }
 
-static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t sel_read_checkreqprot(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
 			   checkreqprot_get());
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
@@ -717,9 +712,11 @@ static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf,
 	kfree(page);
 	return length;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_checkreqprot);
+
 static const struct file_operations sel_checkreqprot_ops = {
-	.read		= sel_read_checkreqprot,
-	.write		= sel_write_checkreqprot,
+	.read_iter	= sel_read_checkreqprot,
+	.write_iter	= sel_write_checkreqprot_iter,
 	.llseek		= generic_file_llseek,
 };
 
@@ -793,9 +790,10 @@ static ssize_t sel_write_validatetrans(struct file *file,
 	kfree(taskcon);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_validatetrans);
 
 static const struct file_operations sel_transition_ops = {
-	.write		= sel_write_validatetrans,
+	.write_iter	= sel_write_validatetrans_iter,
 	.llseek		= generic_file_llseek,
 };
 
@@ -837,10 +835,11 @@ static ssize_t selinux_transaction_write(struct file *file, const char __user *b
 	}
 	return rv;
 }
+FOPS_WRITE_ITER_HELPER(selinux_transaction_write);
 
 static const struct file_operations transaction_ops = {
-	.write		= selinux_transaction_write,
-	.read		= simple_transaction_read,
+	.write_iter	= selinux_transaction_write_iter,
+	.read_iter	= simple_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= generic_file_llseek,
 };
@@ -1192,9 +1191,9 @@ static struct inode *sel_make_inode(struct super_block *sb, umode_t mode)
 	return ret;
 }
 
-static ssize_t sel_read_bool(struct file *filep, char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t sel_read_bool(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *filep = iocb->ki_filp;
 	struct selinux_fs_info *fsi = file_inode(filep)->i_sb->s_fs_info;
 	char *page = NULL;
 	ssize_t length;
@@ -1223,7 +1222,7 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
 	length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing,
 			  fsi->bool_pending_values[index]);
 	mutex_unlock(&selinux_state.policy_mutex);
-	ret = simple_read_from_buffer(buf, count, ppos, page, length);
+	ret = simple_copy_to_iter(page, &iocb->ki_pos, length, to);
 out_free:
 	free_page((unsigned long)page);
 	return ret;
@@ -1282,10 +1281,11 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
 	kfree(page);
 	return length;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_bool);
 
 static const struct file_operations sel_bool_ops = {
-	.read		= sel_read_bool,
-	.write		= sel_write_bool,
+	.read_iter	= sel_read_bool,
+	.write_iter	= sel_write_bool_iter,
 	.llseek		= generic_file_llseek,
 };
 
@@ -1334,9 +1334,10 @@ static ssize_t sel_commit_bools_write(struct file *filep,
 	kfree(page);
 	return length;
 }
+FOPS_WRITE_ITER_HELPER(sel_commit_bools_write);
 
 static const struct file_operations sel_commit_bools_ops = {
-	.write		= sel_commit_bools_write,
+	.write_iter	= sel_commit_bools_write_iter,
 	.llseek		= generic_file_llseek,
 };
 
@@ -1404,15 +1405,15 @@ static int sel_make_bools(struct selinux_policy *newpolicy, struct dentry *bool_
 	return ret;
 }
 
-static ssize_t sel_read_avc_cache_threshold(struct file *filp, char __user *buf,
-					    size_t count, loff_t *ppos)
+static ssize_t sel_read_avc_cache_threshold(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
 
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
 			   avc_get_cache_threshold());
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static ssize_t sel_write_avc_cache_threshold(struct file *file,
@@ -1452,9 +1453,9 @@ static ssize_t sel_write_avc_cache_threshold(struct file *file,
 	kfree(page);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(sel_write_avc_cache_threshold);
 
-static ssize_t sel_read_avc_hash_stats(struct file *filp, char __user *buf,
-				       size_t count, loff_t *ppos)
+static ssize_t sel_read_avc_hash_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *page;
 	ssize_t length;
@@ -1465,14 +1466,14 @@ static ssize_t sel_read_avc_hash_stats(struct file *filp, char __user *buf,
 
 	length = avc_get_hash_stats(page);
 	if (length >= 0)
-		length = simple_read_from_buffer(buf, count, ppos, page, length);
+		length = simple_copy_to_iter(page, &iocb->ki_pos, length, to);
 	free_page((unsigned long)page);
 
 	return length;
 }
 
-static ssize_t sel_read_sidtab_hash_stats(struct file *filp, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t sel_read_sidtab_hash_stats(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	char *page;
 	ssize_t length;
@@ -1483,26 +1484,25 @@ static ssize_t sel_read_sidtab_hash_stats(struct file *filp, char __user *buf,
 
 	length = security_sidtab_hash_stats(page);
 	if (length >= 0)
-		length = simple_read_from_buffer(buf, count, ppos, page,
-						length);
+		length = simple_copy_to_iter(page, &iocb->ki_pos, length, to);
 	free_page((unsigned long)page);
 
 	return length;
 }
 
 static const struct file_operations sel_sidtab_hash_stats_ops = {
-	.read		= sel_read_sidtab_hash_stats,
+	.read_iter	= sel_read_sidtab_hash_stats,
 	.llseek		= generic_file_llseek,
 };
 
 static const struct file_operations sel_avc_cache_threshold_ops = {
-	.read		= sel_read_avc_cache_threshold,
-	.write		= sel_write_avc_cache_threshold,
+	.read_iter	= sel_read_avc_cache_threshold,
+	.write_iter	= sel_write_avc_cache_threshold_iter,
 	.llseek		= generic_file_llseek,
 };
 
 static const struct file_operations sel_avc_hash_stats_ops = {
-	.read		= sel_read_avc_hash_stats,
+	.read_iter	= sel_read_avc_hash_stats,
 	.llseek		= generic_file_llseek,
 };
 
@@ -1571,7 +1571,7 @@ static int sel_open_avc_cache_stats(struct inode *inode, struct file *file)
 
 static const struct file_operations sel_avc_cache_stats_ops = {
 	.open		= sel_open_avc_cache_stats,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -1644,25 +1644,24 @@ static int sel_make_ss_files(struct dentry *dir)
 	return 0;
 }
 
-static ssize_t sel_read_initcon(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t sel_read_initcon(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *con;
 	u32 sid, len;
 	ssize_t ret;
 
-	sid = file_inode(file)->i_ino&SEL_INO_MASK;
+	sid = file_inode(iocb->ki_filp)->i_ino&SEL_INO_MASK;
 	ret = security_sid_to_context(sid, &con, &len);
 	if (ret)
 		return ret;
 
-	ret = simple_read_from_buffer(buf, count, ppos, con, len);
+	ret = simple_copy_to_iter(con, &iocb->ki_pos, len, to);
 	kfree(con);
 	return ret;
 }
 
 static const struct file_operations sel_initcon_ops = {
-	.read		= sel_read_initcon,
+	.read_iter	= sel_read_initcon,
 	.llseek		= generic_file_llseek,
 };
 
@@ -1715,50 +1714,47 @@ static inline u32 sel_ino_to_perm(unsigned long ino)
 	return (ino & SEL_INO_MASK) % (SEL_VEC_MAX + 1);
 }
 
-static ssize_t sel_read_class(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t sel_read_class(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long ino = file_inode(file)->i_ino;
+	unsigned long ino = file_inode(iocb->ki_filp)->i_ino;
 	char res[TMPBUFLEN];
 	ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_class(ino));
-	return simple_read_from_buffer(buf, count, ppos, res, len);
+	return simple_copy_to_iter(res, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations sel_class_ops = {
-	.read		= sel_read_class,
+	.read_iter	= sel_read_class,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t sel_read_perm(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t sel_read_perm(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long ino = file_inode(file)->i_ino;
+	unsigned long ino = file_inode(iocb->ki_filp)->i_ino;
 	char res[TMPBUFLEN];
 	ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
-	return simple_read_from_buffer(buf, count, ppos, res, len);
+	return simple_copy_to_iter(res, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations sel_perm_ops = {
-	.read		= sel_read_perm,
+	.read_iter	= sel_read_perm,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t sel_read_policycap(struct file *file, char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t sel_read_policycap(struct kiocb *iocb, struct iov_iter *to)
 {
 	int value;
 	char tmpbuf[TMPBUFLEN];
 	ssize_t length;
-	unsigned long i_ino = file_inode(file)->i_ino;
+	unsigned long i_ino = file_inode(iocb->ki_filp)->i_ino;
 
 	value = security_policycap_supported(i_ino & SEL_INO_MASK);
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%d", value);
 
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations sel_policycap_ops = {
-	.read		= sel_read_policycap,
+	.read_iter	= sel_read_policycap,
 	.llseek		= generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 093/437] integrity: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (91 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 092/437] selinux: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 094/437] lockdown: " Jens Axboe
                   ` (344 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/integrity/evm/evm_secfs.c | 60 +++++++++++++-----------------
 security/integrity/ima/ima_fs.c    | 41 ++++++++++----------
 2 files changed, 44 insertions(+), 57 deletions(-)

diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
index 9b907c2fee60..2ff3b5d04eae 100644
--- a/security/integrity/evm/evm_secfs.c
+++ b/security/integrity/evm/evm_secfs.c
@@ -29,50 +29,45 @@ static int evm_xattrs_locked;
 /**
  * evm_read_key - read() for <securityfs>/evm
  *
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t evm_read_key(struct file *filp, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t evm_read_key(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[80];
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	sprintf(temp, "%d", (evm_initialized & ~EVM_SETUP_COMPLETE));
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 
 	return rc;
 }
 
 /**
  * evm_write_key - write() for <securityfs>/evm
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Used to signal that key is on the kernel key ring.
  * - get the integrity hmac key from the kernel key ring
  * - create list of hmac protected extended attributes
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t evm_write_key(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t evm_write_key(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	unsigned int i;
 	int ret;
 
 	if (!capable(CAP_SYS_ADMIN) || (evm_initialized & EVM_SETUP_COMPLETE))
 		return -EPERM;
 
-	ret = kstrtouint_from_user(buf, count, 0, &i);
+	ret = kstrtouint_from_iter(from, count, 0, &i);
 
 	if (ret)
 		return ret;
@@ -109,30 +104,27 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations evm_key_ops = {
-	.read		= evm_read_key,
-	.write		= evm_write_key,
+	.read_iter	= evm_read_key,
+	.write_iter	= evm_write_key,
 };
 
 #ifdef CONFIG_EVM_ADD_XATTRS
 /**
  * evm_read_xattrs - read() for <securityfs>/evm_xattrs
  *
- * @filp: file pointer, not actually used
- * @buf: where to put the result
- * @count: maximum to send along
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @to: where to put the result
  *
  * Returns number of bytes read or error code, as appropriate
  */
-static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t evm_read_xattrs(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *temp;
 	int offset = 0;
 	ssize_t rc, size = 0;
 	struct xattr_list *xattr;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	rc = mutex_lock_interruptible(&xattr_list_mutex);
@@ -161,7 +153,7 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
 	}
 
 	mutex_unlock(&xattr_list_mutex);
-	rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	rc = simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 
 	kfree(temp);
 
@@ -170,26 +162,24 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf,
 
 /**
  * evm_write_xattrs - write() for <securityfs>/evm_xattrs
- * @file: file pointer, not actually used
- * @buf: where to get the data from
- * @count: bytes sent
- * @ppos: where to start
+ * @iocb: metadata for IO
+ * @from: where to get the data from
  *
  * Returns number of bytes written or error code, as appropriate
  */
-static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t evm_write_xattrs(struct kiocb *iocb, struct iov_iter *from)
 {
 	int len, err;
 	struct xattr_list *xattr, *tmp;
 	struct audit_buffer *ab;
 	struct iattr newattrs;
 	struct inode *inode;
+	size_t count = iov_iter_count(from);
 
 	if (!capable(CAP_SYS_ADMIN) || evm_xattrs_locked)
 		return -EPERM;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
 	if (count > XATTR_NAME_MAX)
@@ -207,7 +197,7 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
 	}
 
 	xattr->enabled = true;
-	xattr->name = memdup_user_nul(buf, count);
+	xattr->name = iterdup_nul(from, count);
 	if (IS_ERR(xattr->name)) {
 		err = PTR_ERR(xattr->name);
 		xattr->name = NULL;
@@ -278,8 +268,8 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations evm_xattr_ops = {
-	.read		= evm_read_xattrs,
-	.write		= evm_write_xattrs,
+	.read_iter	= evm_read_xattrs,
+	.write_iter	= evm_write_xattrs,
 };
 
 static int evm_init_xattrs(void)
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index cd1683dad3bf..e33896afec46 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -38,38 +38,35 @@ __setup("ima_canonical_fmt", default_canonical_fmt_setup);
 
 static int valid_policy = 1;
 
-static ssize_t ima_show_htable_value(char __user *buf, size_t count,
-				     loff_t *ppos, atomic_long_t *val)
+static ssize_t ima_show_htable_value(struct kiocb *iocb, struct iov_iter *to,
+				     atomic_long_t *val)
 {
 	char tmpbuf[32];	/* greater than largest 'long' string value */
 	ssize_t len;
 
 	len = scnprintf(tmpbuf, sizeof(tmpbuf), "%li\n", atomic_long_read(val));
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ima_show_htable_violations(struct file *filp,
-					  char __user *buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ima_show_htable_violations(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	return ima_show_htable_value(buf, count, ppos, &ima_htable.violations);
+	return ima_show_htable_value(iocb, to, &ima_htable.violations);
 }
 
 static const struct file_operations ima_htable_violations_ops = {
-	.read = ima_show_htable_violations,
+	.read_iter = ima_show_htable_violations,
 	.llseek = generic_file_llseek,
 };
 
-static ssize_t ima_show_measurements_count(struct file *filp,
-					   char __user *buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ima_show_measurements_count(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	return ima_show_htable_value(buf, count, ppos, &ima_htable.len);
-
+	return ima_show_htable_value(iocb, to, &ima_htable.len);
 }
 
 static const struct file_operations ima_measurements_count_ops = {
-	.read = ima_show_measurements_count,
+	.read_iter = ima_show_measurements_count,
 	.llseek = generic_file_llseek,
 };
 
@@ -200,7 +197,7 @@ static int ima_measurements_open(struct inode *inode, struct file *file)
 
 static const struct file_operations ima_measurements_ops = {
 	.open = ima_measurements_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
@@ -266,7 +263,7 @@ static int ima_ascii_measurements_open(struct inode *inode, struct file *file)
 
 static const struct file_operations ima_ascii_measurements_ops = {
 	.open = ima_ascii_measurements_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
@@ -311,9 +308,9 @@ static ssize_t ima_read_policy(char *path)
 		return pathlen;
 }
 
-static ssize_t ima_write_policy(struct file *file, const char __user *buf,
-				size_t datalen, loff_t *ppos)
+static ssize_t ima_write_policy(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t datalen = iov_iter_count(from);
 	char *data;
 	ssize_t result;
 
@@ -322,10 +319,10 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
 
 	/* No partial writes. */
 	result = -EINVAL;
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		goto out;
 
-	data = memdup_user_nul(buf, datalen);
+	data = iterdup_nul(from, datalen);
 	if (IS_ERR(data)) {
 		result = PTR_ERR(data);
 		goto out;
@@ -444,8 +441,8 @@ static int ima_release_policy(struct inode *inode, struct file *file)
 
 static const struct file_operations ima_measure_policy_ops = {
 	.open = ima_open_policy,
-	.write = ima_write_policy,
-	.read = seq_read,
+	.write_iter = ima_write_policy,
+	.read_iter = seq_read_iter,
 	.release = ima_release_policy,
 	.llseek = generic_file_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 094/437] lockdown: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (92 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 093/437] integrity: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 095/437] security: " Jens Axboe
                   ` (343 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/lockdown/lockdown.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index cd84d8ea1dfb..ea208d3251e6 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -93,8 +93,7 @@ static int __init lockdown_lsm_init(void)
 	return 0;
 }
 
-static ssize_t lockdown_read(struct file *filp, char __user *buf, size_t count,
-			     loff_t *ppos)
+static ssize_t lockdown_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char temp[80];
 	int i, offset = 0;
@@ -116,7 +115,7 @@ static ssize_t lockdown_read(struct file *filp, char __user *buf, size_t count,
 	if (offset > 0)
 		temp[offset-1] = '\n';
 
-	return simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
+	return simple_copy_to_iter(temp, &iocb->ki_pos, strlen(temp), to);
 }
 
 static ssize_t lockdown_write(struct file *file, const char __user *buf,
@@ -146,10 +145,11 @@ static ssize_t lockdown_write(struct file *file, const char __user *buf,
 	kfree(state);
 	return err ? err : n;
 }
+FOPS_WRITE_ITER_HELPER(lockdown_write);
 
 static const struct file_operations lockdown_ops = {
-	.read  = lockdown_read,
-	.write = lockdown_write,
+	.read_iter  = lockdown_read,
+	.write_iter = lockdown_write_iter,
 };
 
 static int __init lockdown_secfs_init(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 095/437] security: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (93 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 094/437] lockdown: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 096/437] mm: " Jens Axboe
                   ` (342 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 security/inode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/security/inode.c b/security/inode.c
index 9e7cde913667..81a7b43a0009 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -315,15 +315,14 @@ EXPORT_SYMBOL_GPL(securityfs_remove);
 
 #ifdef CONFIG_SECURITY
 static struct dentry *lsm_dentry;
-static ssize_t lsm_read(struct file *filp, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t lsm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, count, ppos, lsm_names,
-		strlen(lsm_names));
+	return simple_copy_to_iter(lsm_names, &iocb->ki_pos, strlen(lsm_names),
+					to);
 }
 
 static const struct file_operations lsm_ops = {
-	.read = lsm_read,
+	.read_iter = lsm_read,
 	.llseek = generic_file_llseek,
 };
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 096/437] mm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (94 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 095/437] security: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 097/437] aoe: " Jens Axboe
                   ` (341 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 mm/damon/dbgfs.c    | 84 ++++++++++++++++++++++++---------------------
 mm/huge_memory.c    | 10 +++---
 mm/kmemleak.c       |  5 +--
 mm/page_owner.c     |  5 +--
 mm/shrinker_debug.c | 12 +++----
 mm/slub.c           |  2 +-
 mm/vmscan.c         | 14 ++++----
 7 files changed, 69 insertions(+), 63 deletions(-)

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index 2461cfe2e968..1ee9d28ded80 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -56,10 +56,9 @@ static char *user_input_str(const char __user *buf, size_t count, loff_t *ppos)
 	return kbuf;
 }
 
-static ssize_t dbgfs_attrs_read(struct file *file,
-		char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dbgfs_attrs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct damon_ctx *ctx = file->private_data;
+	struct damon_ctx *ctx = iocb->ki_filp->private_data;
 	char kbuf[128];
 	int ret;
 
@@ -70,7 +69,7 @@ static ssize_t dbgfs_attrs_read(struct file *file,
 			ctx->attrs.min_nr_regions, ctx->attrs.max_nr_regions);
 	mutex_unlock(&ctx->kdamond_lock);
 
-	return simple_read_from_buffer(buf, count, ppos, kbuf, ret);
+	return simple_copy_to_iter(kbuf, &iocb->ki_pos, ret, to);
 }
 
 static ssize_t dbgfs_attrs_write(struct file *file,
@@ -109,6 +108,7 @@ static ssize_t dbgfs_attrs_write(struct file *file,
 	kfree(kbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_attrs_write);
 
 /*
  * Return corresponding dbgfs' scheme action value (int) for the given
@@ -169,10 +169,10 @@ static ssize_t sprint_schemes(struct damon_ctx *c, char *buf, ssize_t len)
 	return written;
 }
 
-static ssize_t dbgfs_schemes_read(struct file *file, char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t dbgfs_schemes_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct damon_ctx *ctx = file->private_data;
+	struct damon_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *kbuf;
 	ssize_t len;
 
@@ -185,7 +185,7 @@ static ssize_t dbgfs_schemes_read(struct file *file, char __user *buf,
 	mutex_unlock(&ctx->kdamond_lock);
 	if (len < 0)
 		goto out;
-	len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
+	len = simple_copy_to_iter(kbuf, &iocb->ki_pos, len, to);
 
 out:
 	kfree(kbuf);
@@ -329,6 +329,7 @@ static ssize_t dbgfs_schemes_write(struct file *file, const char __user *buf,
 	kfree(kbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_schemes_write);
 
 static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len)
 {
@@ -356,10 +357,9 @@ static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len)
 	return written;
 }
 
-static ssize_t dbgfs_target_ids_read(struct file *file,
-		char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dbgfs_target_ids_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct damon_ctx *ctx = file->private_data;
+	struct damon_ctx *ctx = iocb->ki_filp->private_data;
 	ssize_t len;
 	char ids_buf[320];
 
@@ -369,7 +369,7 @@ static ssize_t dbgfs_target_ids_read(struct file *file,
 	if (len < 0)
 		return len;
 
-	return simple_read_from_buffer(buf, count, ppos, ids_buf, len);
+	return simple_copy_to_iter(ids_buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -548,6 +548,7 @@ static ssize_t dbgfs_target_ids_write(struct file *file,
 	kfree(kbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_target_ids_write);
 
 static ssize_t sprint_init_regions(struct damon_ctx *c, char *buf, ssize_t len)
 {
@@ -571,10 +572,10 @@ static ssize_t sprint_init_regions(struct damon_ctx *c, char *buf, ssize_t len)
 	return written;
 }
 
-static ssize_t dbgfs_init_regions_read(struct file *file, char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t dbgfs_init_regions_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct damon_ctx *ctx = file->private_data;
+	struct damon_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *kbuf;
 	ssize_t len;
 
@@ -593,7 +594,7 @@ static ssize_t dbgfs_init_regions_read(struct file *file, char __user *buf,
 	mutex_unlock(&ctx->kdamond_lock);
 	if (len < 0)
 		goto out;
-	len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
+	len = simple_copy_to_iter(kbuf, &iocb->ki_pos, len, to);
 
 out:
 	kfree(kbuf);
@@ -693,11 +694,12 @@ static ssize_t dbgfs_init_regions_write(struct file *file,
 	kfree(kbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_init_regions_write);
 
-static ssize_t dbgfs_kdamond_pid_read(struct file *file,
-		char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dbgfs_kdamond_pid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct damon_ctx *ctx = file->private_data;
+	struct damon_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *kbuf;
 	ssize_t len;
 
@@ -713,7 +715,7 @@ static ssize_t dbgfs_kdamond_pid_read(struct file *file,
 	mutex_unlock(&ctx->kdamond_lock);
 	if (!len)
 		goto out;
-	len = simple_read_from_buffer(buf, count, ppos, kbuf, len);
+	len = simple_copy_to_iter(kbuf, &iocb->ki_pos, len, to);
 
 out:
 	kfree(kbuf);
@@ -731,31 +733,31 @@ static int damon_dbgfs_open(struct inode *inode, struct file *file)
 
 static const struct file_operations attrs_fops = {
 	.open = damon_dbgfs_open,
-	.read = dbgfs_attrs_read,
-	.write = dbgfs_attrs_write,
+	.read_iter = dbgfs_attrs_read,
+	.write_iter = dbgfs_attrs_write_iter,
 };
 
 static const struct file_operations schemes_fops = {
 	.open = damon_dbgfs_open,
-	.read = dbgfs_schemes_read,
-	.write = dbgfs_schemes_write,
+	.read_iter = dbgfs_schemes_read,
+	.write_iter = dbgfs_schemes_write_iter,
 };
 
 static const struct file_operations target_ids_fops = {
 	.open = damon_dbgfs_open,
-	.read = dbgfs_target_ids_read,
-	.write = dbgfs_target_ids_write,
+	.read_iter = dbgfs_target_ids_read,
+	.write_iter = dbgfs_target_ids_write_iter,
 };
 
 static const struct file_operations init_regions_fops = {
 	.open = damon_dbgfs_open,
-	.read = dbgfs_init_regions_read,
-	.write = dbgfs_init_regions_write,
+	.read_iter = dbgfs_init_regions_read,
+	.write_iter = dbgfs_init_regions_write_iter,
 };
 
 static const struct file_operations kdamond_pid_fops = {
 	.open = damon_dbgfs_open,
-	.read = dbgfs_kdamond_pid_read,
+	.read_iter = dbgfs_kdamond_pid_read,
 };
 
 static void dbgfs_fill_ctx_dir(struct dentry *dir, struct damon_ctx *ctx)
@@ -807,12 +809,12 @@ static void dbgfs_destroy_ctx(struct damon_ctx *ctx)
 	damon_destroy_ctx(ctx);
 }
 
-static ssize_t damon_dbgfs_deprecated_read(struct file *file,
-		char __user *buf, size_t count, loff_t *ppos)
+static ssize_t damon_dbgfs_deprecated_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
 	static const char kbuf[512] = DAMON_DBGFS_DEPRECATION_NOTICE;
 
-	return simple_read_from_buffer(buf, count, ppos, kbuf, strlen(kbuf));
+	return simple_copy_to_iter(kbuf, &iocb->ki_pos, strlen(kbuf), to);
 }
 
 /*
@@ -900,6 +902,7 @@ static ssize_t dbgfs_mk_context_write(struct file *file,
 	kfree(ctx_name);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_mk_context_write);
 
 /*
  * Remove a context of @name and its debugfs directory.
@@ -1006,9 +1009,9 @@ static ssize_t dbgfs_rm_context_write(struct file *file,
 	kfree(ctx_name);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_rm_context_write);
 
-static ssize_t dbgfs_monitor_on_read(struct file *file,
-		char __user *buf, size_t count, loff_t *ppos)
+static ssize_t dbgfs_monitor_on_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char monitor_on_buf[5];
 	bool monitor_on = damon_nr_running_ctxs() != 0;
@@ -1016,7 +1019,7 @@ static ssize_t dbgfs_monitor_on_read(struct file *file,
 
 	len = scnprintf(monitor_on_buf, 5, monitor_on ? "on\n" : "off\n");
 
-	return simple_read_from_buffer(buf, count, ppos, monitor_on_buf, len);
+	return simple_copy_to_iter(monitor_on_buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t dbgfs_monitor_on_write(struct file *file,
@@ -1059,6 +1062,7 @@ static ssize_t dbgfs_monitor_on_write(struct file *file,
 	kfree(kbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dbgfs_monitor_on_write);
 
 static int damon_dbgfs_static_file_open(struct inode *inode, struct file *file)
 {
@@ -1067,23 +1071,23 @@ static int damon_dbgfs_static_file_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations deprecated_fops = {
-	.read = damon_dbgfs_deprecated_read,
+	.read_iter = damon_dbgfs_deprecated_read,
 };
 
 static const struct file_operations mk_contexts_fops = {
 	.open = damon_dbgfs_static_file_open,
-	.write = dbgfs_mk_context_write,
+	.write_iter = dbgfs_mk_context_write_iter,
 };
 
 static const struct file_operations rm_contexts_fops = {
 	.open = damon_dbgfs_static_file_open,
-	.write = dbgfs_rm_context_write,
+	.write_iter = dbgfs_rm_context_write_iter,
 };
 
 static const struct file_operations monitor_on_fops = {
 	.open = damon_dbgfs_static_file_open,
-	.read = dbgfs_monitor_on_read,
-	.write = dbgfs_monitor_on_write,
+	.read_iter = dbgfs_monitor_on_read,
+	.write_iter = dbgfs_monitor_on_write_iter,
 };
 
 static int __init __damon_dbgfs_init(void)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9859aa4f7553..989847ed0f92 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3582,8 +3582,7 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start,
 
 #define MAX_INPUT_BUF_SZ 255
 
-static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppops)
+static ssize_t split_huge_pages_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	static DEFINE_MUTEX(split_debug_mutex);
 	ssize_t ret;
@@ -3594,6 +3593,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
 	char input_buf[MAX_INPUT_BUF_SZ];
 	int pid;
 	unsigned long vaddr_start, vaddr_end;
+	size_t count = iov_iter_count(from);
 	unsigned int new_order = 0;
 
 	ret = mutex_lock_interruptible(&split_debug_mutex);
@@ -3603,7 +3603,8 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
 	ret = -EFAULT;
 
 	memset(input_buf, 0, MAX_INPUT_BUF_SZ);
-	if (copy_from_user(input_buf, buf, min_t(size_t, count, MAX_INPUT_BUF_SZ)))
+	if (!copy_from_iter_full(input_buf,
+				 min_t(size_t, count, MAX_INPUT_BUF_SZ), from))
 		goto out;
 
 	input_buf[MAX_INPUT_BUF_SZ - 1] = '\0';
@@ -3651,12 +3652,11 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
 out:
 	mutex_unlock(&split_debug_mutex);
 	return ret;
-
 }
 
 static const struct file_operations split_huge_pages_fops = {
 	.owner	 = THIS_MODULE,
-	.write	 = split_huge_pages_write,
+	.write_iter = split_huge_pages_write,
 	.llseek  = no_llseek,
 };
 
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 6a540c2b27c5..3ff7dc613e70 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -2063,12 +2063,13 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
 	*ppos += size;
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(kmemleak_write);
 
 static const struct file_operations kmemleak_fops = {
 	.owner		= THIS_MODULE,
 	.open		= kmemleak_open,
-	.read		= seq_read,
-	.write		= kmemleak_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= kmemleak_write_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
diff --git a/mm/page_owner.c b/mm/page_owner.c
index d17d1351ec84..ab5cfbc718b4 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -715,6 +715,7 @@ read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 	return 0;
 }
+FOPS_READ_ITER_HELPER(read_page_owner);
 
 static loff_t lseek_page_owner(struct file *file, loff_t offset, int orig)
 {
@@ -822,7 +823,7 @@ static void init_early_allocated_pages(void)
 }
 
 static const struct file_operations proc_page_owner_operations = {
-	.read		= read_page_owner,
+	.read_iter	= read_page_owner_iter,
 	.llseek		= lseek_page_owner,
 };
 
@@ -906,7 +907,7 @@ static int page_owner_stack_open(struct inode *inode, struct file *file)
 
 static const struct file_operations page_owner_stack_operations = {
 	.open		= page_owner_stack_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c
index 12ea5486a3e9..b3b4d5a36dc0 100644
--- a/mm/shrinker_debug.c
+++ b/mm/shrinker_debug.c
@@ -101,11 +101,11 @@ static int shrinker_debugfs_scan_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t shrinker_debugfs_scan_write(struct file *file,
-					   const char __user *buf,
-					   size_t size, loff_t *pos)
+static ssize_t shrinker_debugfs_scan_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct shrinker *shrinker = file->private_data;
+	struct shrinker *shrinker = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	unsigned long nr_to_scan = 0, ino, read_len;
 	struct shrink_control sc = {
 		.gfp_mask = GFP_KERNEL,
@@ -115,7 +115,7 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file,
 	char kbuf[72];
 
 	read_len = size < (sizeof(kbuf) - 1) ? size : (sizeof(kbuf) - 1);
-	if (copy_from_user(kbuf, buf, read_len))
+	if (!copy_from_iter_full(kbuf, read_len, from))
 		return -EFAULT;
 	kbuf[read_len] = '\0';
 
@@ -156,7 +156,7 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file,
 static const struct file_operations shrinker_debugfs_scan_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = shrinker_debugfs_scan_open,
-	.write	 = shrinker_debugfs_scan_write,
+	.write_iter	 = shrinker_debugfs_scan_write,
 };
 
 int shrinker_debugfs_add(struct shrinker *shrinker)
diff --git a/mm/slub.c b/mm/slub.c
index 1bb2a93cf7b6..aff701599b6a 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -7033,7 +7033,7 @@ static int slab_debug_trace_release(struct inode *inode, struct file *file)
 
 static const struct file_operations slab_debugfs_fops = {
 	.open    = slab_debug_trace_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = slab_debug_trace_release,
 };
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3ef654addd44..bf6e9292aea2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -5278,7 +5278,7 @@ static void lru_gen_seq_show_full(struct seq_file *m, struct lruvec *lruvec,
 static int lru_gen_seq_show(struct seq_file *m, void *v)
 {
 	unsigned long seq;
-	bool full = !debugfs_real_fops(m->file)->write;
+	bool full = !debugfs_real_fops(m->file)->write_iter;
 	struct lruvec *lruvec = v;
 	struct lru_gen_folio *lrugen = &lruvec->lrugen;
 	int nid = lruvec_pgdat(lruvec)->node_id;
@@ -5434,9 +5434,9 @@ static int run_cmd(char cmd, int memcg_id, int nid, unsigned long seq,
 }
 
 /* see Documentation/admin-guide/mm/multigen_lru.rst for details */
-static ssize_t lru_gen_seq_write(struct file *file, const char __user *src,
-				 size_t len, loff_t *pos)
+static ssize_t lru_gen_seq_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	void *buf;
 	char *cur, *next;
 	unsigned int flags;
@@ -5454,7 +5454,7 @@ static ssize_t lru_gen_seq_write(struct file *file, const char __user *src,
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, src, len)) {
+	if (!copy_from_iter_full(buf, len, from)) {
 		kvfree(buf);
 		return -EFAULT;
 	}
@@ -5513,15 +5513,15 @@ static int lru_gen_seq_open(struct inode *inode, struct file *file)
 
 static const struct file_operations lru_gen_rw_fops = {
 	.open = lru_gen_seq_open,
-	.read = seq_read,
-	.write = lru_gen_seq_write,
+	.read_iter = seq_read_iter,
+	.write_iter = lru_gen_seq_write,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
 
 static const struct file_operations lru_gen_ro_fops = {
 	.open = lru_gen_seq_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 097/437] aoe: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (95 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 096/437] mm: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 098/437] drbd: " Jens Axboe
                   ` (340 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/block/aoe/aoechr.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index a42c4bcc85ba..828499156a5f 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -192,6 +192,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp
 		ret = cnt;
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(aoechr_write);
 
 static int
 aoechr_open(struct inode *inode, struct file *filp)
@@ -217,16 +218,16 @@ aoechr_rel(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t
-aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
+static ssize_t aoechr_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t cnt = iov_iter_count(to);
 	unsigned long n;
 	char *mp;
 	struct ErrMsg *em;
 	ssize_t len;
 	ulong flags;
 
-	n = (unsigned long) filp->private_data;
+	n = (unsigned long) iocb->ki_filp->private_data;
 	if (n != MINOR_ERR)
 		return -EFAULT;
 
@@ -236,7 +237,7 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
 		em = emsgs + emsgs_head_idx;
 		if ((em->flags & EMFL_VALID) != 0)
 			break;
-		if (filp->f_flags & O_NDELAY) {
+		if (iocb->ki_filp->f_flags & O_NDELAY) {
 			spin_unlock_irqrestore(&emsgs_lock, flags);
 			return -EAGAIN;
 		}
@@ -269,14 +270,14 @@ aoechr_read(struct file *filp, char __user *buf, size_t cnt, loff_t *off)
 
 	spin_unlock_irqrestore(&emsgs_lock, flags);
 
-	n = copy_to_user(buf, mp, len);
+	n = !copy_to_iter_full(mp, len, to);
 	kfree(mp);
 	return n == 0 ? len : -EFAULT;
 }
 
 static const struct file_operations aoe_fops = {
-	.write = aoechr_write,
-	.read = aoechr_read,
+	.write_iter = aoechr_write_iter,
+	.read_iter = aoechr_read,
 	.open = aoechr_open,
 	.release = aoechr_rel,
 	.owner = THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 098/437] drbd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (96 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 097/437] aoe: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:13 ` [PATCH 099/437] mtip32xx: " Jens Axboe
                   ` (339 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/block/drbd/drbd_debugfs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c
index 12460b584bcb..b23baa80eb37 100644
--- a/drivers/block/drbd/drbd_debugfs.c
+++ b/drivers/block/drbd/drbd_debugfs.c
@@ -457,7 +457,7 @@ static int in_flight_summary_release(struct inode *inode, struct file *file)
 static const struct file_operations in_flight_summary_fops = {
 	.owner		= THIS_MODULE,
 	.open		= in_flight_summary_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= in_flight_summary_release,
 };
@@ -565,7 +565,7 @@ static int callback_history_release(struct inode *inode, struct file *file)
 static const struct file_operations connection_callback_history_fops = {
 	.owner		= THIS_MODULE,
 	.open		= callback_history_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= callback_history_release,
 };
@@ -612,7 +612,7 @@ static int connection_oldest_requests_release(struct inode *inode, struct file *
 static const struct file_operations connection_oldest_requests_fops = {
 	.owner		= THIS_MODULE,
 	.open		= connection_oldest_requests_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= connection_oldest_requests_release,
 };
@@ -757,7 +757,7 @@ static int device_ ## name ## _release(struct inode *inode, struct file *file)	\
 static const struct file_operations device_ ## name ## _fops = {		\
 	.owner		= THIS_MODULE,						\
 	.open		= device_ ## name ## _open,				\
-	.read		= seq_read,						\
+	.read_iter	= seq_read_iter,					\
 	.llseek		= seq_lseek,						\
 	.release	= device_ ## name ## _release,				\
 };
@@ -859,7 +859,7 @@ static const struct file_operations drbd_version_fops = {
 	.owner = THIS_MODULE,
 	.open = drbd_version_open,
 	.llseek = seq_lseek,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.release = single_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 099/437] mtip32xx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (97 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 098/437] drbd: " Jens Axboe
@ 2024-04-11 15:13 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 100/437] zram: " Jens Axboe
                   ` (338 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/block/mtip32xx/mtip32xx.c | 36 +++++++++++++++----------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 43a187609ef7..28ea499cbbfd 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2162,13 +2162,13 @@ static const struct attribute_group *mtip_disk_attr_groups[] = {
 	NULL,
 };
 
-static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
-				  size_t len, loff_t *offset)
+static ssize_t mtip_hw_read_registers(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct driver_data *dd =  (struct driver_data *)f->private_data;
+	struct driver_data *dd =  iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	char *buf;
 	u32 group_allocated;
-	int size = *offset;
+	int size = iocb->ki_pos;
 	int n, rv = 0;
 
 	if (!len || size)
@@ -2217,21 +2217,21 @@ static ssize_t mtip_hw_read_registers(struct file *f, char __user *ubuf,
 	}
 	size += sprintf(&buf[size], "]\n");
 
-	*offset = size <= len ? size : len;
-	size = copy_to_user(ubuf, buf, *offset);
-	if (size)
+	iocb->ki_pos = size <= len ? size : len;
+	size = copy_to_iter(buf, iocb->ki_pos, to);
+	if (!size)
 		rv = -EFAULT;
 
 	kfree(buf);
-	return rv ? rv : *offset;
+	return rv ? rv : iocb->ki_pos;
 }
 
-static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
-				  size_t len, loff_t *offset)
+static ssize_t mtip_hw_read_flags(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct driver_data *dd =  (struct driver_data *)f->private_data;
+	struct driver_data *dd =  iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	char *buf;
-	int size = *offset;
+	int size = iocb->ki_pos;
 	int rv = 0;
 
 	if (!len || size)
@@ -2246,26 +2246,26 @@ static ssize_t mtip_hw_read_flags(struct file *f, char __user *ubuf,
 	size += sprintf(&buf[size], "Flag-dd   : [ %08lX ]\n",
 							dd->dd_flag);
 
-	*offset = size <= len ? size : len;
-	size = copy_to_user(ubuf, buf, *offset);
-	if (size)
+	iocb->ki_pos = size <= len ? size : len;
+	size = copy_to_iter(buf, iocb->ki_pos, to);
+	if (!size)
 		rv = -EFAULT;
 
 	kfree(buf);
-	return rv ? rv : *offset;
+	return rv ? rv : iocb->ki_pos;
 }
 
 static const struct file_operations mtip_regs_fops = {
 	.owner  = THIS_MODULE,
 	.open   = simple_open,
-	.read   = mtip_hw_read_registers,
+	.read_iter   = mtip_hw_read_registers,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations mtip_flags_fops = {
 	.owner  = THIS_MODULE,
 	.open   = simple_open,
-	.read   = mtip_hw_read_flags,
+	.read_iter   = mtip_hw_read_flags,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 100/437] zram: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (98 preceding siblings ...)
  2024-04-11 15:13 ` [PATCH 099/437] mtip32xx: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 101/437] s390/dasd: " Jens Axboe
                   ` (337 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/block/zram/zram_drv.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f0639df6cd18..eac46889b4b2 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -850,13 +850,13 @@ static void zram_debugfs_destroy(void)
 	debugfs_remove_recursive(zram_debugfs_root);
 }
 
-static ssize_t read_block_state(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t read_block_state(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *kbuf;
 	ssize_t index, written = 0;
-	struct zram *zram = file->private_data;
+	struct zram *zram = iocb->ki_filp->private_data;
 	unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
+	size_t count = iov_iter_count(to);
 	struct timespec64 ts;
 
 	kbuf = kvmalloc(count, GFP_KERNEL);
@@ -870,7 +870,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 		return -EINVAL;
 	}
 
-	for (index = *ppos; index < nr_pages; index++) {
+	for (index = iocb->ki_pos; index < nr_pages; index++) {
 		int copied;
 
 		zram_slot_lock(zram, index);
@@ -898,11 +898,11 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 		count -= copied;
 next:
 		zram_slot_unlock(zram, index);
-		*ppos += 1;
+		iocb->ki_pos++;
 	}
 
 	up_read(&zram->init_lock);
-	if (copy_to_user(buf, kbuf, written))
+	if (!copy_to_iter(kbuf, written, to))
 		written = -EFAULT;
 	kvfree(kbuf);
 
@@ -911,7 +911,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
 
 static const struct file_operations proc_zram_block_state_op = {
 	.open = simple_open,
-	.read = read_block_state,
+	.read_iter = read_block_state,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 101/437] s390/dasd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (99 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 100/437] zram: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 102/437] lib: " Jens Axboe
                   ` (336 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/block/dasd.c      | 34 +++++++++++++++++++++++++++-------
 drivers/s390/block/dasd_eer.c  | 12 ++++++------
 drivers/s390/block/dasd_int.h  |  1 +
 drivers/s390/block/dasd_proc.c |  2 +-
 4 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 0a97cfedd706..789e8c47e6ee 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -897,6 +897,7 @@ void dasd_profile_off(struct dasd_profile *profile)
 	spin_unlock_bh(&profile->lock);
 }
 
+/* this can go away once proc is converted to ->write_iter() */
 char *dasd_get_user_string(const char __user *user_buf, size_t user_len)
 {
 	char *buffer;
@@ -916,18 +917,37 @@ char *dasd_get_user_string(const char __user *user_buf, size_t user_len)
 	return buffer;
 }
 
-static ssize_t dasd_stats_write(struct file *file,
-				const char __user *user_buf,
-				size_t user_len, loff_t *pos)
+char *dasd_get_iter_string(struct iov_iter *from)
+{
+	size_t user_len = iov_iter_count(from);
+	char *buffer;
+
+	buffer = vmalloc(user_len + 1);
+	if (buffer == NULL)
+		return ERR_PTR(-ENOMEM);
+	if (!copy_from_iter_full(buffer, user_len, from)) {
+		vfree(buffer);
+		return ERR_PTR(-EFAULT);
+	}
+	/* got the string, now strip linefeed. */
+	if (buffer[user_len - 1] == '\n')
+		buffer[user_len - 1] = 0;
+	else
+		buffer[user_len] = 0;
+	return buffer;
+}
+
+static ssize_t dasd_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buffer, *str;
 	int rc;
-	struct seq_file *m = (struct seq_file *)file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct dasd_profile *prof = m->private;
+	size_t user_len = iov_iter_count(from);
 
 	if (user_len > 65536)
 		user_len = 65536;
-	buffer = dasd_get_user_string(user_buf, user_len);
+	buffer = dasd_get_iter_string(from);
 	if (IS_ERR(buffer))
 		return PTR_ERR(buffer);
 
@@ -1042,10 +1062,10 @@ static int dasd_stats_open(struct inode *inode, struct file *file)
 static const struct file_operations dasd_stats_raw_fops = {
 	.owner		= THIS_MODULE,
 	.open		= dasd_stats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
-	.write		= dasd_stats_write,
+	.write_iter	= dasd_stats_write,
 };
 
 static void dasd_profile_init(struct dasd_profile *profile,
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 194e9e2d9cb8..476d6cf80089 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -592,15 +592,15 @@ static int dasd_eer_close(struct inode *inp, struct file *filp)
 	return 0;
 }
 
-static ssize_t dasd_eer_read(struct file *filp, char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t dasd_eer_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int tc,rc;
 	int tailcount,effective_count;
         unsigned long flags;
 	struct eerbuffer *eerb;
 
-	eerb = (struct eerbuffer *) filp->private_data;
+	eerb = (struct eerbuffer *) iocb->ki_filp->private_data;
 	if (mutex_lock_interruptible(&readbuffer_mutex))
 		return -ERESTARTSYS;
 
@@ -625,7 +625,7 @@ static ssize_t dasd_eer_read(struct file *filp, char __user *buf,
 				/* no data available */
 				spin_unlock_irqrestore(&bufferlock, flags);
 				mutex_unlock(&readbuffer_mutex);
-				if (filp->f_flags & O_NONBLOCK)
+				if (iocb->ki_filp->f_flags & O_NONBLOCK)
 					return -EAGAIN;
 				rc = wait_event_interruptible(
 					dasd_eer_read_wait_queue,
@@ -647,7 +647,7 @@ static ssize_t dasd_eer_read(struct file *filp, char __user *buf,
 
 	spin_unlock_irqrestore(&bufferlock, flags);
 
-	if (copy_to_user(buf, readbuffer, effective_count)) {
+	if (!copy_to_iter_full(readbuffer, effective_count, to)) {
 		mutex_unlock(&readbuffer_mutex);
 		return -EFAULT;
 	}
@@ -676,7 +676,7 @@ static __poll_t dasd_eer_poll(struct file *filp, poll_table *ptable)
 static const struct file_operations dasd_eer_fops = {
 	.open		= &dasd_eer_open,
 	.release	= &dasd_eer_close,
-	.read		= &dasd_eer_read,
+	.read_iter	= &dasd_eer_read,
 	.poll		= &dasd_eer_poll,
 	.owner		= THIS_MODULE,
 	.llseek		= noop_llseek,
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index e5f40536b425..be7d6875b054 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -897,6 +897,7 @@ void dasd_profile_reset(struct dasd_profile *);
 int dasd_profile_on(struct dasd_profile *);
 void dasd_profile_off(struct dasd_profile *);
 char *dasd_get_user_string(const char __user *, size_t);
+char *dasd_get_iter_string(struct iov_iter *);
 
 /* externals in dasd_devmap.c */
 extern int dasd_max_devindex;
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 0faaa437d9be..b97d1227b9b0 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -317,7 +317,7 @@ static ssize_t dasd_stats_proc_write(struct file *file,
 
 static const struct proc_ops dasd_stats_proc_ops = {
 	.proc_open	= dasd_stats_proc_open,
-	.proc_read	= seq_read,
+	.proc_read_iter	= seq_read_iter,
 	.proc_lseek	= seq_lseek,
 	.proc_release	= single_release,
 	.proc_write	= dasd_stats_proc_write,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 102/437] lib: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (100 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 101/437] s390/dasd: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 103/437] ipc: " Jens Axboe
                   ` (335 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 lib/dynamic_debug.c  |  5 +++--
 lib/kunit/debugfs.c  | 13 ++++++-------
 lib/test_firmware.c  | 10 ++++------
 lib/xz/xz_dec_test.c |  9 ++++-----
 4 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index c78f335fa981..534ad9218557 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1022,6 +1022,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
 	*offp += len;
 	return len;
 }
+FOPS_WRITE_ITER_HELPER(ddebug_proc_write);
 
 /*
  * Set the iterator to point to the first _ddebug object
@@ -1182,10 +1183,10 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
 static const struct file_operations ddebug_proc_fops = {
 	.owner = THIS_MODULE,
 	.open = ddebug_proc_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
-	.write = ddebug_proc_write
+	.write_iter = ddebug_proc_write_iter
 };
 
 static const struct proc_ops proc_fops = {
diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c
index d548750a325a..ea7be601cf9e 100644
--- a/lib/kunit/debugfs.c
+++ b/lib/kunit/debugfs.c
@@ -139,28 +139,27 @@ static int debugfs_run_open(struct inode *inode, struct file *file)
  *
  * Note: what is written to this file will not be saved.
  */
-static ssize_t debugfs_run(struct file *file,
-		const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t debugfs_run(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *f_inode = file->f_inode;
+	struct inode *f_inode = iocb->ki_filp->f_inode;
 	struct kunit_suite *suite = (struct kunit_suite *) f_inode->i_private;
 
 	__kunit_test_suites_init(&suite, 1);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations debugfs_results_fops = {
 	.open = debugfs_results_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = debugfs_release,
 };
 
 static const struct file_operations debugfs_run_fops = {
 	.open = debugfs_run_open,
-	.read = seq_read,
-	.write = debugfs_run,
+	.read_iter = seq_read_iter,
+	.write_iter = debugfs_run,
 	.llseek = seq_lseek,
 	.release = debugfs_release,
 };
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 9cfdcd6d21db..face875a52e2 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -147,23 +147,21 @@ static struct test_firmware_upload *upload_lookup_name(const char *name)
 	return NULL;
 }
 
-static ssize_t test_fw_misc_read(struct file *f, char __user *buf,
-				 size_t size, loff_t *offset)
+static ssize_t test_fw_misc_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t rc = 0;
 
 	mutex_lock(&test_fw_mutex);
 	if (test_firmware)
-		rc = simple_read_from_buffer(buf, size, offset,
-					     test_firmware->data,
-					     test_firmware->size);
+		rc = simple_copy_to_iter(test_firmware->data, &iocb->ki_pos,
+					     test_firmware->size, to);
 	mutex_unlock(&test_fw_mutex);
 	return rc;
 }
 
 static const struct file_operations test_fw_fops = {
 	.owner          = THIS_MODULE,
-	.read           = test_fw_misc_read,
+	.read_iter      = test_fw_misc_read,
 };
 
 static void __test_release_all_firmware(void)
diff --git a/lib/xz/xz_dec_test.c b/lib/xz/xz_dec_test.c
index da28a19d6c98..42dc077e247b 100644
--- a/lib/xz/xz_dec_test.c
+++ b/lib/xz/xz_dec_test.c
@@ -99,9 +99,9 @@ static int xz_dec_test_release(struct inode *i, struct file *f)
  * The .xz file must have exactly one Stream and no Stream Padding. The data
  * after the first Stream is considered to be garbage.
  */
-static ssize_t xz_dec_test_write(struct file *file, const char __user *buf,
-				 size_t size, loff_t *pos)
+static ssize_t xz_dec_test_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t size = iov_iter_count(from);
 	size_t remaining;
 
 	if (ret != XZ_OK) {
@@ -122,10 +122,9 @@ static ssize_t xz_dec_test_write(struct file *file, const char __user *buf,
 		if (buffers.in_pos == buffers.in_size) {
 			buffers.in_pos = 0;
 			buffers.in_size = min(remaining, sizeof(buffer_in));
-			if (copy_from_user(buffer_in, buf, buffers.in_size))
+			if (!copy_from_iter_full(buffer_in, buffers.in_size, from))
 				return -EFAULT;
 
-			buf += buffers.in_size;
 			remaining -= buffers.in_size;
 		}
 
@@ -179,7 +178,7 @@ static int __init xz_dec_test_init(void)
 		.owner = THIS_MODULE,
 		.open = &xz_dec_test_open,
 		.release = &xz_dec_test_release,
-		.write = &xz_dec_test_write
+		.write_iter = &xz_dec_test_write
 	};
 
 	state = xz_dec_init(XZ_PREALLOC, DICT_MAX);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 103/437] ipc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (101 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 102/437] lib: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 104/437] drivers/accel: " Jens Axboe
                   ` (334 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 ipc/mqueue.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 5eea4dc0509e..812b03cf4273 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -632,10 +632,9 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
 *	that are interesting from user point of view and aren't accessible
 *	through std routines)
 */
-static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
-				size_t count, loff_t *off)
+static ssize_t mqueue_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(filp);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct mqueue_inode_info *info = MQUEUE_I(inode);
 	char buffer[FILENT_SIZE];
 	ssize_t ret;
@@ -652,8 +651,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
 	spin_unlock(&info->lock);
 	buffer[sizeof(buffer)-1] = '\0';
 
-	ret = simple_read_from_buffer(u_data, count, off, buffer,
-				strlen(buffer));
+	ret = simple_copy_to_iter(buffer, &iocb->ki_pos, strlen(buffer), to);
 	if (ret <= 0)
 		return ret;
 
@@ -1663,7 +1661,7 @@ static const struct inode_operations mqueue_dir_inode_operations = {
 static const struct file_operations mqueue_file_operations = {
 	.flush = mqueue_flush_file,
 	.poll = mqueue_poll_file,
-	.read = mqueue_read_file,
+	.read_iter = mqueue_read_file,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 104/437] drivers/accel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (102 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 103/437] ipc: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 105/437] drivers/acpi: " Jens Axboe
                   ` (333 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/accel/habanalabs/common/debugfs.c    | 307 +++++++++----------
 drivers/accel/habanalabs/common/habanalabs.h |   3 +-
 drivers/accel/ivpu/ivpu_debugfs.c            |  84 +++--
 3 files changed, 183 insertions(+), 211 deletions(-)

diff --git a/drivers/accel/habanalabs/common/debugfs.c b/drivers/accel/habanalabs/common/debugfs.c
index b1c88d1837d9..350dcfc5300e 100644
--- a/drivers/accel/habanalabs/common/debugfs.c
+++ b/drivers/accel/habanalabs/common/debugfs.c
@@ -403,16 +403,16 @@ static int userptr_lookup_show(struct seq_file *s, void *data)
 	return 0;
 }
 
-static ssize_t userptr_lookup_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t userptr_lookup_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct hl_debugfs_entry *entry = s->private;
 	struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 	u64 value;
 
-	rc = kstrtoull_from_user(buf, count, 16, &value);
+	rc = kstrtoull_from_iter(from, count, 16, &value);
 	if (rc)
 		return rc;
 
@@ -477,20 +477,20 @@ static int mmu_show(struct seq_file *s, void *data)
 	return 0;
 }
 
-static ssize_t mmu_asid_va_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t mmu_asid_va_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct hl_debugfs_entry *entry = s->private;
 	struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
 	struct hl_device *hdev = dev_entry->hdev;
+	size_t count = iov_iter_count(from);
 	char kbuf[MMU_KBUF_SIZE] = {0};
 	char *c;
 	ssize_t rc;
 
 	if (count > sizeof(kbuf) - 1)
 		goto err;
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		goto err;
 	kbuf[count] = 0;
 
@@ -538,21 +538,21 @@ static int mmu_ack_error(struct seq_file *s, void *data)
 	return -EINVAL;
 }
 
-static ssize_t mmu_ack_error_value_write(struct file *file,
-		const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t mmu_ack_error_value_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct hl_debugfs_entry *entry = s->private;
 	struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
 	struct hl_device *hdev = dev_entry->hdev;
+	size_t count = iov_iter_count(from);
 	char kbuf[MMU_KBUF_SIZE] = {0};
 	ssize_t rc;
 
 	if (count > sizeof(kbuf) - 1)
 		goto err;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter(kbuf, count, from))
 		goto err;
 
 	kbuf[count] = 0;
@@ -607,10 +607,9 @@ static int engines_show(struct seq_file *s, void *data)
 	return 0;
 }
 
-static ssize_t hl_memory_scrub(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_memory_scrub(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	u64 val = hdev->memory_scrub_val;
 	int rc;
@@ -637,7 +636,7 @@ static ssize_t hl_memory_scrub(struct file *f, const char __user *buf,
 
 	if (rc)
 		return rc;
-	return count;
+	return iov_iter_count(from);
 }
 
 static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
@@ -839,10 +838,9 @@ static int hl_access_mem(struct hl_device *hdev, u64 addr, u64 *val,
 	return rc;
 }
 
-static ssize_t hl_data_read32(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_data_read32(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	u64 value64, addr = entry->addr;
 	char tmp_buf[32];
@@ -854,7 +852,7 @@ static ssize_t hl_data_read32(struct file *f, char __user *buf,
 		return 0;
 	}
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	rc = hl_access_mem(hdev, addr, &value64, DEBUGFS_READ32);
@@ -864,14 +862,13 @@ static ssize_t hl_data_read32(struct file *f, char __user *buf,
 	val = value64; /* downcast back to 32 */
 
 	sprintf(tmp_buf, "0x%08x\n", val);
-	return simple_read_from_buffer(buf, count, ppos, tmp_buf,
-			strlen(tmp_buf));
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf), to);
 }
 
-static ssize_t hl_data_write32(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_data_write32(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u64 value64, addr = entry->addr;
 	u32 value;
@@ -882,7 +879,7 @@ static ssize_t hl_data_write32(struct file *f, const char __user *buf,
 		return 0;
 	}
 
-	rc = kstrtouint_from_user(buf, count, 16, &value);
+	rc = kstrtouint_from_iter(from, count, 16, &value);
 	if (rc)
 		return rc;
 
@@ -894,10 +891,9 @@ static ssize_t hl_data_write32(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_data_read64(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_data_read64(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	u64 addr = entry->addr;
 	char tmp_buf[32];
@@ -909,7 +905,7 @@ static ssize_t hl_data_read64(struct file *f, char __user *buf,
 		return 0;
 	}
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	rc = hl_access_mem(hdev, addr, &val, DEBUGFS_READ64);
@@ -917,14 +913,13 @@ static ssize_t hl_data_read64(struct file *f, char __user *buf,
 		return rc;
 
 	sprintf(tmp_buf, "0x%016llx\n", val);
-	return simple_read_from_buffer(buf, count, ppos, tmp_buf,
-			strlen(tmp_buf));
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf), to);
 }
 
-static ssize_t hl_data_write64(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_data_write64(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u64 addr = entry->addr;
 	u64 value;
@@ -935,7 +930,7 @@ static ssize_t hl_data_write64(struct file *f, const char __user *buf,
 		return 0;
 	}
 
-	rc = kstrtoull_from_user(buf, count, 16, &value);
+	rc = kstrtoull_from_iter(from, count, 16, &value);
 	if (rc)
 		return rc;
 
@@ -946,10 +941,10 @@ static ssize_t hl_data_write64(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_dma_size_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_dma_size_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u64 addr = entry->addr;
 	ssize_t rc;
@@ -959,7 +954,7 @@ static ssize_t hl_dma_size_write(struct file *f, const char __user *buf,
 		dev_warn_ratelimited(hdev->dev, "Can't DMA during reset\n");
 		return 0;
 	}
-	rc = kstrtouint_from_user(buf, count, 16, &size);
+	rc = kstrtouint_from_iter(from, count, 16, &size);
 	if (rc)
 		return rc;
 
@@ -1003,10 +998,11 @@ static ssize_t hl_dma_size_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_monitor_dump_trigger(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_monitor_dump_trigger(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 size, trig;
 	ssize_t rc;
@@ -1015,7 +1011,7 @@ static ssize_t hl_monitor_dump_trigger(struct file *f, const char __user *buf,
 		dev_warn_ratelimited(hdev->dev, "Can't dump monitors during reset\n");
 		return 0;
 	}
-	rc = kstrtouint_from_user(buf, count, 10, &trig);
+	rc = kstrtouint_from_iter(from, count, 10, &trig);
 	if (rc)
 		return rc;
 
@@ -1047,15 +1043,14 @@ static ssize_t hl_monitor_dump_trigger(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_get_power_state(struct file *f, char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t hl_get_power_state(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	char tmp_buf[200];
 	int i;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (hdev->pdev->current_state == PCI_D0)
@@ -1067,19 +1062,18 @@ static ssize_t hl_get_power_state(struct file *f, char __user *buf,
 
 	sprintf(tmp_buf,
 		"current power state: %d\n1 - D0\n2 - D3hot\n3 - Unknown\n", i);
-	return simple_read_from_buffer(buf, count, ppos, tmp_buf,
-			strlen(tmp_buf));
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf), to);
 }
 
-static ssize_t hl_set_power_state(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_set_power_state(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1101,16 +1095,15 @@ static ssize_t hl_set_power_state(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_i2c_data_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	char tmp_buf[32];
 	u64 val;
 	ssize_t rc;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	rc = hl_debugfs_i2c_read(hdev, entry->i2c_bus, entry->i2c_addr,
@@ -1123,21 +1116,18 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
 	}
 
 	sprintf(tmp_buf, "%#02llx\n", val);
-	rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
-			strlen(tmp_buf));
-
-	return rc;
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf), to);
 }
 
-static ssize_t hl_i2c_data_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_i2c_data_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u64 value;
 	ssize_t rc;
 
-	rc = kstrtou64_from_user(buf, count, 16, &value);
+	rc = kstrtou64_from_iter(from, count, 16, &value);
 	if (rc)
 		return rc;
 
@@ -1153,15 +1143,15 @@ static ssize_t hl_i2c_data_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_led0_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_led0_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1172,15 +1162,15 @@ static ssize_t hl_led0_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_led1_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_led1_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1191,15 +1181,15 @@ static ssize_t hl_led1_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_led2_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_led2_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1210,26 +1200,25 @@ static ssize_t hl_led2_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_device_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_device_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	static const char *help =
 		"Valid values: disable, enable, suspend, resume, cpu_timeout\n";
-	return simple_read_from_buffer(buf, count, ppos, help, strlen(help));
+	return simple_copy_to_iter(help, &iocb->ki_pos, strlen(help), to);
 }
 
-static ssize_t hl_device_write(struct file *f, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t hl_device_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
+	size_t count = iov_iter_count(from);
 	char data[30] = {0};
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos)
 		return 0;
 
-	simple_write_to_buffer(data, 29, ppos, buf, count);
+	simple_copy_from_iter(data, &iocb->ki_pos, 29, from);
 
 	if (strncmp("disable", data, strlen("disable")) == 0) {
 		hdev->disabled = true;
@@ -1250,43 +1239,36 @@ static ssize_t hl_device_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_clk_gate_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_clk_gate_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
 
-static ssize_t hl_clk_gate_write(struct file *f, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t hl_clk_gate_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return count;
+	return iov_iter_count(from);
 }
 
-static ssize_t hl_stop_on_err_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_stop_on_err_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	char tmp_buf[200];
-	ssize_t rc;
 
 	if (!hdev->asic_prop.configurable_stop_on_err)
 		return -EOPNOTSUPP;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	sprintf(tmp_buf, "%d\n", hdev->stop_on_err);
-	rc = simple_read_from_buffer(buf, strlen(tmp_buf) + 1, ppos, tmp_buf,
-			strlen(tmp_buf) + 1);
-
-	return rc;
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf) + 1, to);
 }
 
-static ssize_t hl_stop_on_err_write(struct file *f, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t hl_stop_on_err_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
@@ -1300,7 +1282,7 @@ static ssize_t hl_stop_on_err_write(struct file *f, const char __user *buf,
 		return 0;
 	}
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1311,10 +1293,10 @@ static ssize_t hl_stop_on_err_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_security_violations_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_security_violations_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 
 	hdev->asic_funcs->ack_protection_bits_errors(hdev);
@@ -1322,35 +1304,34 @@ static ssize_t hl_security_violations_read(struct file *f, char __user *buf,
 	return 0;
 }
 
-static ssize_t hl_state_dump_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_state_dump_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	ssize_t rc;
 
 	down_read(&entry->state_dump_sem);
 	if (!entry->state_dump[entry->state_dump_head])
 		rc = 0;
 	else
-		rc = simple_read_from_buffer(
-			buf, count, ppos,
+		rc = simple_copy_to_iter(
 			entry->state_dump[entry->state_dump_head],
-			strlen(entry->state_dump[entry->state_dump_head]));
+			&iocb->ki_pos,
+			strlen(entry->state_dump[entry->state_dump_head]), to);
 	up_read(&entry->state_dump_sem);
 
 	return rc;
 }
 
-static ssize_t hl_state_dump_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_state_dump_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	ssize_t rc;
 	u32 size;
 	int i;
 
-	rc = kstrtouint_from_user(buf, count, 10, &size);
+	rc = kstrtouint_from_iter(from, count, 10, &size);
 	if (rc)
 		return rc;
 
@@ -1376,34 +1357,30 @@ static ssize_t hl_state_dump_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_timeout_locked_read(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_timeout_locked_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 	char tmp_buf[200];
-	ssize_t rc;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	sprintf(tmp_buf, "%d\n",
 		jiffies_to_msecs(hdev->timeout_jiffies) / 1000);
-	rc = simple_read_from_buffer(buf, strlen(tmp_buf) + 1, ppos, tmp_buf,
-			strlen(tmp_buf) + 1);
-
-	return rc;
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, strlen(tmp_buf) + 1, to);
 }
 
-static ssize_t hl_timeout_locked_write(struct file *f, const char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t hl_timeout_locked_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 	struct hl_device *hdev = entry->hdev;
 	u32 value;
 	ssize_t rc;
 
-	rc = kstrtouint_from_user(buf, count, 10, &value);
+	rc = kstrtouint_from_iter(from, count, 10, &value);
 	if (rc)
 		return rc;
 
@@ -1415,10 +1392,9 @@ static ssize_t hl_timeout_locked_write(struct file *f, const char __user *buf,
 	return count;
 }
 
-static ssize_t hl_check_razwi_happened(struct file *f, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t hl_check_razwi_happened(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
+	struct hl_dbg_device_entry *entry = file_inode(iocb->ki_filp)->i_private;
 	struct hl_device *hdev = entry->hdev;
 
 	hdev->asic_funcs->check_if_razwi_happened(hdev);
@@ -1428,96 +1404,96 @@ static ssize_t hl_check_razwi_happened(struct file *f, char __user *buf,
 
 static const struct file_operations hl_mem_scrub_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_memory_scrub,
+	.write_iter = hl_memory_scrub
 };
 
 static const struct file_operations hl_data32b_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_data_read32,
-	.write = hl_data_write32
+	.read_iter = hl_data_read32,
+	.write_iter = hl_data_write32
 };
 
 static const struct file_operations hl_data64b_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_data_read64,
-	.write = hl_data_write64
+	.read_iter = hl_data_read64,
+	.write_iter = hl_data_write64
 };
 
 static const struct file_operations hl_dma_size_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_dma_size_write
+	.write_iter = hl_dma_size_write
 };
 
 static const struct file_operations hl_monitor_dump_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_monitor_dump_trigger
+	.write_iter = hl_monitor_dump_trigger
 };
 
 static const struct file_operations hl_i2c_data_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_i2c_data_read,
-	.write = hl_i2c_data_write
+	.read_iter = hl_i2c_data_read,
+	.write_iter = hl_i2c_data_write
 };
 
 static const struct file_operations hl_power_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_get_power_state,
-	.write = hl_set_power_state
+	.read_iter = hl_get_power_state,
+	.write_iter = hl_set_power_state
 };
 
 static const struct file_operations hl_led0_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_led0_write
+	.write_iter = hl_led0_write
 };
 
 static const struct file_operations hl_led1_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_led1_write
+	.write_iter = hl_led1_write
 };
 
 static const struct file_operations hl_led2_fops = {
 	.owner = THIS_MODULE,
-	.write = hl_led2_write
+	.write_iter = hl_led2_write
 };
 
 static const struct file_operations hl_device_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_device_read,
-	.write = hl_device_write
+	.read_iter = hl_device_read,
+	.write_iter = hl_device_write
 };
 
 static const struct file_operations hl_clk_gate_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_clk_gate_read,
-	.write = hl_clk_gate_write
+	.read_iter = hl_clk_gate_read,
+	.write_iter = hl_clk_gate_write
 };
 
 static const struct file_operations hl_stop_on_err_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_stop_on_err_read,
-	.write = hl_stop_on_err_write
+	.read_iter = hl_stop_on_err_read,
+	.write_iter = hl_stop_on_err_write
 };
 
 static const struct file_operations hl_security_violations_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_security_violations_read
+	.read_iter = hl_security_violations_read
 };
 
 static const struct file_operations hl_state_dump_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_state_dump_read,
-	.write = hl_state_dump_write
+	.read_iter = hl_state_dump_read,
+	.write_iter = hl_state_dump_write
 };
 
 static const struct file_operations hl_timeout_locked_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_timeout_locked_read,
-	.write = hl_timeout_locked_write
+	.read_iter = hl_timeout_locked_read,
+	.write_iter = hl_timeout_locked_write
 };
 
 static const struct file_operations hl_razwi_check_fops = {
 	.owner = THIS_MODULE,
-	.read = hl_check_razwi_happened
+	.read_iter = hl_check_razwi_happened
 };
 
 static const struct hl_info_list hl_debugfs_list[] = {
@@ -1539,13 +1515,12 @@ static int hl_debugfs_open(struct inode *inode, struct file *file)
 	return single_open(file, node->info_ent->show, node);
 }
 
-static ssize_t hl_debugfs_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t hl_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hl_debugfs_entry *node = file->f_inode->i_private;
+	struct hl_debugfs_entry *node = iocb->ki_filp->f_inode->i_private;
 
 	if (node->info_ent->write)
-		return node->info_ent->write(file, buf, count, f_pos);
+		return node->info_ent->write(iocb, from);
 	else
 		return -EINVAL;
 
@@ -1554,8 +1529,8 @@ static ssize_t hl_debugfs_write(struct file *file, const char __user *buf,
 static const struct file_operations hl_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = hl_debugfs_open,
-	.read = seq_read,
-	.write = hl_debugfs_write,
+	.read_iter = seq_read_iter,
+	.write_iter = hl_debugfs_write,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/accel/habanalabs/common/habanalabs.h b/drivers/accel/habanalabs/common/habanalabs.h
index 48f0f3eea1ef..ccf329c83f30 100644
--- a/drivers/accel/habanalabs/common/habanalabs.h
+++ b/drivers/accel/habanalabs/common/habanalabs.h
@@ -2338,8 +2338,7 @@ struct hl_fpriv {
 struct hl_info_list {
 	const char	*name;
 	int		(*show)(struct seq_file *s, void *data);
-	ssize_t		(*write)(struct file *file, const char __user *buf,
-				size_t count, loff_t *f_pos);
+	ssize_t		(*write)(struct kiocb *, struct iov_iter *);
 };
 
 /**
diff --git a/drivers/accel/ivpu/ivpu_debugfs.c b/drivers/accel/ivpu/ivpu_debugfs.c
index d09d29775b3f..c2db7689437c 100644
--- a/drivers/accel/ivpu/ivpu_debugfs.c
+++ b/drivers/accel/ivpu/ivpu_debugfs.c
@@ -116,15 +116,15 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = {
 	{"reset_pending", reset_pending_show, 0},
 };
 
-static ssize_t
-dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+static ssize_t dvfs_mode_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct ivpu_fw_info *fw = vdev->fw;
 	u32 dvfs_mode;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, size, 0, &dvfs_mode);
+	ret = kstrtou32_from_iter(from, size, 0, &dvfs_mode);
 	if (ret < 0)
 		return ret;
 
@@ -140,7 +140,7 @@ dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size
 static const struct file_operations dvfs_mode_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = dvfs_mode_fops_write,
+	.write_iter = dvfs_mode_fops_write,
 };
 
 static int fw_log_show(struct seq_file *s, void *v)
@@ -157,37 +157,36 @@ static int fw_log_fops_open(struct inode *inode, struct file *file)
 	return single_open(file, fw_log_show, inode->i_private);
 }
 
-static ssize_t
-fw_log_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+static ssize_t fw_log_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct ivpu_device *vdev = s->private;
 
-	if (!size)
+	if (!iov_iter_count(from))
 		return -EINVAL;
 
 	ivpu_fw_log_clear(vdev);
-	return size;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fw_log_fops = {
 	.owner = THIS_MODULE,
 	.open = fw_log_fops_open,
-	.write = fw_log_fops_write,
-	.read = seq_read,
+	.write_iter = fw_log_fops_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
 
 static ssize_t
-fw_profiling_freq_fops_write(struct file *file, const char __user *user_buf,
-			     size_t size, loff_t *pos)
+fw_profiling_freq_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	bool enable;
 	int ret;
 
-	ret = kstrtobool_from_user(user_buf, size, &enable);
+	ret = kstrtobool_from_iter(from, size, &enable);
 	if (ret < 0)
 		return ret;
 
@@ -203,19 +202,19 @@ fw_profiling_freq_fops_write(struct file *file, const char __user *user_buf,
 static const struct file_operations fw_profiling_freq_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = fw_profiling_freq_fops_write,
+	.write_iter = fw_profiling_freq_fops_write,
 };
 
 static ssize_t
-fw_trace_destination_mask_fops_write(struct file *file, const char __user *user_buf,
-				     size_t size, loff_t *pos)
+fw_trace_destination_mask_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct ivpu_fw_info *fw = vdev->fw;
 	u32 trace_destination_mask;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, size, 0, &trace_destination_mask);
+	ret = kstrtou32_from_iter(from, size, 0, &trace_destination_mask);
 	if (ret < 0)
 		return ret;
 
@@ -230,19 +229,19 @@ fw_trace_destination_mask_fops_write(struct file *file, const char __user *user_
 static const struct file_operations fw_trace_destination_mask_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = fw_trace_destination_mask_fops_write,
+	.write_iter = fw_trace_destination_mask_fops_write,
 };
 
 static ssize_t
-fw_trace_hw_comp_mask_fops_write(struct file *file, const char __user *user_buf,
-				 size_t size, loff_t *pos)
+fw_trace_hw_comp_mask_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct ivpu_fw_info *fw = vdev->fw;
 	u64 trace_hw_component_mask;
 	int ret;
 
-	ret = kstrtou64_from_user(user_buf, size, 0, &trace_hw_component_mask);
+	ret = kstrtou64_from_iter(from, size, 0, &trace_hw_component_mask);
 	if (ret < 0)
 		return ret;
 
@@ -257,18 +256,19 @@ fw_trace_hw_comp_mask_fops_write(struct file *file, const char __user *user_buf,
 static const struct file_operations fw_trace_hw_comp_mask_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = fw_trace_hw_comp_mask_fops_write,
+	.write_iter = fw_trace_hw_comp_mask_fops_write,
 };
 
 static ssize_t
-fw_trace_level_fops_write(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+fw_trace_level_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct ivpu_fw_info *fw = vdev->fw;
 	u32 trace_level;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, size, 0, &trace_level);
+	ret = kstrtou32_from_iter(from, size, 0, &trace_level);
 	if (ret < 0)
 		return ret;
 
@@ -283,16 +283,15 @@ fw_trace_level_fops_write(struct file *file, const char __user *user_buf, size_t
 static const struct file_operations fw_trace_level_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = fw_trace_level_fops_write,
+	.write_iter = fw_trace_level_fops_write,
 };
 
-static ssize_t
-ivpu_force_recovery_fn(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+static ssize_t ivpu_force_recovery_fn(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
 	int ret;
 
-	if (!size)
+	if (!iov_iter_count(from))
 		return -EINVAL;
 
 	ret = ivpu_rpm_get(vdev);
@@ -302,21 +301,20 @@ ivpu_force_recovery_fn(struct file *file, const char __user *user_buf, size_t si
 	ivpu_pm_trigger_recovery(vdev, "debugfs");
 	flush_work(&vdev->pm->recovery_work);
 	ivpu_rpm_put(vdev);
-	return size;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations ivpu_force_recovery_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = ivpu_force_recovery_fn,
+	.write_iter = ivpu_force_recovery_fn,
 };
 
-static ssize_t
-ivpu_reset_engine_fn(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
+static ssize_t ivpu_reset_engine_fn(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ivpu_device *vdev = file->private_data;
+	struct ivpu_device *vdev = iocb->ki_filp->private_data;
 
-	if (!size)
+	if (!iov_iter_count(from))
 		return -EINVAL;
 
 	if (ivpu_jsm_reset_engine(vdev, DRM_IVPU_ENGINE_COMPUTE))
@@ -324,13 +322,13 @@ ivpu_reset_engine_fn(struct file *file, const char __user *user_buf, size_t size
 	if (ivpu_jsm_reset_engine(vdev, DRM_IVPU_ENGINE_COPY))
 		return -ENODEV;
 
-	return size;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations ivpu_reset_engine_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = ivpu_reset_engine_fn,
+	.write_iter = ivpu_reset_engine_fn,
 };
 
 void ivpu_debugfs_init(struct ivpu_device *vdev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 105/437] drivers/acpi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (103 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 104/437] drivers/accel: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 106/437] crypto: hisilicon: " Jens Axboe
                   ` (332 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/acpi/acpi_dbg.c      |  6 ++++--
 drivers/acpi/apei/erst-dbg.c | 23 ++++++++++++-----------
 drivers/acpi/ec_sys.c        |  6 ++++--
 drivers/acpi/pfr_update.c    |  3 ++-
 4 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/acpi_dbg.c b/drivers/acpi/acpi_dbg.c
index d50261d05f3a..2ee3bc767693 100644
--- a/drivers/acpi/acpi_dbg.c
+++ b/drivers/acpi/acpi_dbg.c
@@ -638,6 +638,7 @@ static ssize_t acpi_aml_read(struct file *file, char __user *buf,
 	}
 	return size > 0 ? size : ret;
 }
+FOPS_READ_ITER_HELPER(acpi_aml_read);
 
 static int acpi_aml_write_user(const char __user *buf, int len)
 {
@@ -707,6 +708,7 @@ static ssize_t acpi_aml_write(struct file *file, const char __user *buf,
 	}
 	return size > 0 ? size : ret;
 }
+FOPS_WRITE_ITER_HELPER(acpi_aml_write);
 
 static __poll_t acpi_aml_poll(struct file *file, poll_table *wait)
 {
@@ -722,8 +724,8 @@ static __poll_t acpi_aml_poll(struct file *file, poll_table *wait)
 }
 
 static const struct file_operations acpi_aml_operations = {
-	.read		= acpi_aml_read,
-	.write		= acpi_aml_write,
+	.read_iter	= acpi_aml_read_iter,
+	.write_iter	= acpi_aml_write_iter,
 	.poll		= acpi_aml_poll,
 	.open		= acpi_aml_open,
 	.release	= acpi_aml_release,
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 8bc71cdc2270..293fac1a2821 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <acpi/apei.h>
 #include <linux/miscdevice.h>
 
@@ -79,20 +80,20 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 	}
 }
 
-static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
-			     size_t usize, loff_t *off)
+static ssize_t erst_dbg_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t usize = iov_iter_count(to);
 	int rc, *pos;
 	ssize_t len = 0;
 	u64 id;
 
-	if (*off)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
 	if (mutex_lock_interruptible(&erst_dbg_mutex) != 0)
 		return -EINTR;
 
-	pos = (int *)&filp->private_data;
+	pos = (int *)&iocb->ki_filp->private_data;
 
 retry_next:
 	rc = erst_get_record_id_next(pos, &id);
@@ -141,7 +142,7 @@ static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
 		goto out;
 
 	rc = -EFAULT;
-	if (copy_to_user(ubuf, erst_dbg_buf, len))
+	if (!copy_to_iter_full(erst_dbg_buf, len, to))
 		goto out;
 	rc = 0;
 out:
@@ -149,9 +150,9 @@ static ssize_t erst_dbg_read(struct file *filp, char __user *ubuf,
 	return rc ? rc : len;
 }
 
-static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
-			      size_t usize, loff_t *off)
+static ssize_t erst_dbg_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t usize = iov_iter_count(from);
 	int rc;
 	struct cper_record_header *rcd;
 
@@ -175,8 +176,8 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
 		erst_dbg_buf = p;
 		erst_dbg_buf_len = usize;
 	}
-	rc = copy_from_user(erst_dbg_buf, ubuf, usize);
-	if (rc) {
+	rc = copy_from_iter_full(erst_dbg_buf, usize, from);
+	if (!rc) {
 		rc = -EFAULT;
 		goto out;
 	}
@@ -196,8 +197,8 @@ static const struct file_operations erst_dbg_ops = {
 	.owner		= THIS_MODULE,
 	.open		= erst_dbg_open,
 	.release	= erst_dbg_release,
-	.read		= erst_dbg_read,
-	.write		= erst_dbg_write,
+	.read_iter	= erst_dbg_read,
+	.write_iter	= erst_dbg_write,
 	.unlocked_ioctl	= erst_dbg_ioctl,
 	.llseek		= no_llseek,
 };
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index c074a0fae059..47c811cb75f4 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -60,6 +60,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
 	}
 	return count;
 }
+FOPS_READ_ITER_HELPER(acpi_ec_read_io);
 
 static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 				size_t count, loff_t *off)
@@ -98,12 +99,13 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
 	}
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(acpi_ec_write_io);
 
 static const struct file_operations acpi_ec_io_ops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read  = acpi_ec_read_io,
-	.write = acpi_ec_write_io,
+	.read_iter  = acpi_ec_read_io_iter,
+	.write_iter = acpi_ec_write_io_iter,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
index 8b2910995fc1..a7a4d3bb74d3 100644
--- a/drivers/acpi/pfr_update.c
+++ b/drivers/acpi/pfr_update.c
@@ -481,10 +481,11 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
 
 	return ret ?: len;
 }
+FOPS_WRITE_ITER_HELPER(pfru_write);
 
 static const struct file_operations acpi_pfru_fops = {
 	.owner		= THIS_MODULE,
-	.write		= pfru_write,
+	.write_iter	= pfru_write_iter,
 	.unlocked_ioctl = pfru_ioctl,
 	.llseek		= noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 106/437] crypto: hisilicon: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (104 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 105/437] drivers/acpi: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 107/437] crypto: iaa: " Jens Axboe
                   ` (331 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/crypto/hisilicon/debugfs.c        | 51 +++++++++++------------
 drivers/crypto/hisilicon/hpre/hpre_main.c | 23 +++++-----
 drivers/crypto/hisilicon/qm.c             | 22 +++++-----
 drivers/crypto/hisilicon/sec2/sec_main.c  | 23 +++++-----
 drivers/crypto/hisilicon/zip/zip_main.c   | 23 +++++-----
 5 files changed, 68 insertions(+), 74 deletions(-)

diff --git a/drivers/crypto/hisilicon/debugfs.c b/drivers/crypto/hisilicon/debugfs.c
index cd67fa348ca7..6dd67b0fcf36 100644
--- a/drivers/crypto/hisilicon/debugfs.c
+++ b/drivers/crypto/hisilicon/debugfs.c
@@ -137,8 +137,7 @@ static struct hisi_qm *file_to_qm(struct debugfs_file *file)
 	return container_of(debug, struct hisi_qm, debug);
 }
 
-static ssize_t qm_cmd_read(struct file *filp, char __user *buffer,
-			   size_t count, loff_t *pos)
+static ssize_t qm_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[QM_DBG_READ_LEN];
 	int len;
@@ -146,7 +145,7 @@ static ssize_t qm_cmd_read(struct file *filp, char __user *buffer,
 	len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n",
 			"Please echo help to cmd to get help information");
 
-	return simple_read_from_buffer(buffer, count, pos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static void dump_show(struct hisi_qm *qm, void *info,
@@ -502,14 +501,14 @@ static int qm_cmd_write_dump(struct hisi_qm *qm, const char *cmd_buf)
 	return ret;
 }
 
-static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer,
-			    size_t count, loff_t *pos)
+static ssize_t qm_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hisi_qm *qm = filp->private_data;
+	struct hisi_qm *qm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *cmd_buf, *cmd_buf_tmp;
 	int ret;
 
-	if (*pos)
+	if (iocb->ki_pos)
 		return 0;
 
 	ret = hisi_qm_get_dfx_access(qm);
@@ -527,7 +526,7 @@ static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer,
 		goto put_dfx_access;
 	}
 
-	cmd_buf = memdup_user_nul(buffer, count);
+	cmd_buf = iterdup_nul(from, count);
 	if (IS_ERR(cmd_buf)) {
 		ret = PTR_ERR(cmd_buf);
 		goto put_dfx_access;
@@ -557,8 +556,8 @@ static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer,
 static const struct file_operations qm_cmd_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = qm_cmd_read,
-	.write = qm_cmd_write,
+	.read_iter = qm_cmd_read,
+	.write_iter = qm_cmd_write,
 };
 
 /**
@@ -704,10 +703,9 @@ static int current_qm_write(struct hisi_qm *qm, u32 val)
 	return 0;
 }
 
-static ssize_t qm_debug_read(struct file *filp, char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t qm_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_file *file = filp->private_data;
+	struct debugfs_file *file = iocb->ki_filp->private_data;
 	enum qm_debug_file index = file->index;
 	struct hisi_qm *qm = file_to_qm(file);
 	char tbuf[QM_DBG_TMP_BUF_LEN];
@@ -736,7 +734,7 @@ static ssize_t qm_debug_read(struct file *filp, char __user *buf,
 
 	hisi_qm_put_dfx_access(qm);
 	ret = scnprintf(tbuf, QM_DBG_TMP_BUF_LEN, "%u\n", val);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 
 err_input:
 	mutex_unlock(&file->lock);
@@ -744,24 +742,24 @@ static ssize_t qm_debug_read(struct file *filp, char __user *buf,
 	return -EINVAL;
 }
 
-static ssize_t qm_debug_write(struct file *filp, const char __user *buf,
-			      size_t count, loff_t *pos)
+static ssize_t qm_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct debugfs_file *file = filp->private_data;
+	struct debugfs_file *file = iocb->ki_filp->private_data;
 	enum qm_debug_file index = file->index;
 	struct hisi_qm *qm = file_to_qm(file);
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	char tbuf[QM_DBG_TMP_BUF_LEN];
 	int len, ret;
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= QM_DBG_TMP_BUF_LEN)
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(tbuf, QM_DBG_TMP_BUF_LEN - 1, pos, buf,
-				     count);
+	len = simple_copy_from_iter(tbuf, &iocb->ki_pos, QM_DBG_TMP_BUF_LEN - 1,
+					from);
 	if (len < 0)
 		return len;
 
@@ -800,8 +798,8 @@ static ssize_t qm_debug_write(struct file *filp, const char __user *buf,
 static const struct file_operations qm_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = qm_debug_read,
-	.write = qm_debug_write,
+	.read_iter = qm_debug_read,
+	.write_iter = qm_debug_write,
 };
 
 static void dfx_regs_uninit(struct hisi_qm *qm,
@@ -1051,23 +1049,22 @@ static int qm_state_show(struct seq_file *s, void *unused)
 
 DEFINE_SHOW_ATTRIBUTE(qm_state);
 
-static ssize_t qm_status_read(struct file *filp, char __user *buffer,
-			      size_t count, loff_t *pos)
+static ssize_t qm_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hisi_qm *qm = filp->private_data;
+	struct hisi_qm *qm = iocb->ki_filp->private_data;
 	char buf[QM_DBG_READ_LEN];
 	int val, len;
 
 	val = atomic_read(&qm->status.flags);
 	len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]);
 
-	return simple_read_from_buffer(buffer, count, pos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations qm_status_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = qm_status_read,
+	.read_iter = qm_status_read,
 };
 
 static void qm_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir,
diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c
index d93aa6630a57..b9257a368aa9 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -829,10 +829,9 @@ static void hpre_cluster_inqry_write(struct hpre_debugfs_file *file, u32 val)
 	writel(val, qm->io_base + offset + HPRE_CLUSTER_INQURY);
 }
 
-static ssize_t hpre_ctrl_debug_read(struct file *filp, char __user *buf,
-				    size_t count, loff_t *pos)
+static ssize_t hpre_ctrl_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hpre_debugfs_file *file = filp->private_data;
+	struct hpre_debugfs_file *file = iocb->ki_filp->private_data;
 	struct hisi_qm *qm = hpre_file_to_qm(file);
 	char tbuf[HPRE_DBGFS_VAL_MAX_LEN];
 	u32 val;
@@ -857,7 +856,7 @@ static ssize_t hpre_ctrl_debug_read(struct file *filp, char __user *buf,
 
 	hisi_qm_put_dfx_access(qm);
 	ret = snprintf(tbuf, HPRE_DBGFS_VAL_MAX_LEN, "%u\n", val);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 
 err_input:
 	spin_unlock_irq(&file->lock);
@@ -865,23 +864,23 @@ static ssize_t hpre_ctrl_debug_read(struct file *filp, char __user *buf,
 	return -EINVAL;
 }
 
-static ssize_t hpre_ctrl_debug_write(struct file *filp, const char __user *buf,
-				     size_t count, loff_t *pos)
+static ssize_t hpre_ctrl_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hpre_debugfs_file *file = filp->private_data;
+	struct hpre_debugfs_file *file = iocb->ki_filp->private_data;
 	struct hisi_qm *qm = hpre_file_to_qm(file);
+	size_t count = iov_iter_count(from);
 	char tbuf[HPRE_DBGFS_VAL_MAX_LEN];
 	unsigned long val;
 	int len, ret;
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= HPRE_DBGFS_VAL_MAX_LEN)
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(tbuf, HPRE_DBGFS_VAL_MAX_LEN - 1,
-				     pos, buf, count);
+	len = simple_copy_from_iter(tbuf, &iocb->ki_pos,
+					HPRE_DBGFS_VAL_MAX_LEN - 1, from);
 	if (len < 0)
 		return len;
 
@@ -919,8 +918,8 @@ static ssize_t hpre_ctrl_debug_write(struct file *filp, const char __user *buf,
 static const struct file_operations hpre_ctrl_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = hpre_ctrl_debug_read,
-	.write = hpre_ctrl_debug_write,
+	.read_iter = hpre_ctrl_debug_read,
+	.write_iter = hpre_ctrl_debug_write,
 };
 
 static int hpre_debugfs_atomic64_get(void *data, u64 *val)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 92f0a1d9b4a6..604cff89f0c8 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -3591,10 +3591,9 @@ static int qm_vf_read_qos(struct hisi_qm *qm)
 	return ret;
 }
 
-static ssize_t qm_algqos_read(struct file *filp, char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t qm_algqos_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hisi_qm *qm = filp->private_data;
+	struct hisi_qm *qm = iocb->ki_filp->private_data;
 	char tbuf[QM_DBG_READ_LEN];
 	u32 qos_val, ir;
 	int ret;
@@ -3622,7 +3621,7 @@ static ssize_t qm_algqos_read(struct file *filp, char __user *buf,
 	qos_val = ir / QM_QOS_RATE;
 	ret = scnprintf(tbuf, QM_DBG_READ_LEN, "%u\n", qos_val);
 
-	ret = simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	ret = simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 
 err_get_status:
 	clear_bit(QM_RESETTING, &qm->misc_ctl);
@@ -3665,22 +3664,23 @@ static ssize_t qm_get_qos_value(struct hisi_qm *qm, const char *buf,
 	return 0;
 }
 
-static ssize_t qm_algqos_write(struct file *filp, const char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t qm_algqos_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hisi_qm *qm = filp->private_data;
+	struct hisi_qm *qm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char tbuf[QM_DBG_READ_LEN];
 	unsigned int fun_index;
 	unsigned long val;
 	int len, ret;
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= QM_DBG_READ_LEN)
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(tbuf, QM_DBG_READ_LEN - 1, pos, buf, count);
+	len = simple_copy_from_iter(tbuf, &iocb->ki_pos, QM_DBG_READ_LEN - 1,
+					from);
 	if (len < 0)
 		return len;
 
@@ -3722,8 +3722,8 @@ static ssize_t qm_algqos_write(struct file *filp, const char __user *buf,
 static const struct file_operations qm_algqos_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = qm_algqos_read,
-	.write = qm_algqos_write,
+	.read_iter = qm_algqos_read,
+	.write_iter = qm_algqos_write,
 };
 
 /**
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c
index c290d8937b19..bb168d97de30 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -718,10 +718,9 @@ static int sec_clear_enable_write(struct hisi_qm *qm, u32 val)
 	return 0;
 }
 
-static ssize_t sec_debug_read(struct file *filp, char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t sec_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct sec_debug_file *file = filp->private_data;
+	struct sec_debug_file *file = iocb->ki_filp->private_data;
 	char tbuf[SEC_DBGFS_VAL_MAX_LEN];
 	struct hisi_qm *qm = file->qm;
 	u32 val;
@@ -745,7 +744,7 @@ static ssize_t sec_debug_read(struct file *filp, char __user *buf,
 
 	hisi_qm_put_dfx_access(qm);
 	ret = snprintf(tbuf, SEC_DBGFS_VAL_MAX_LEN, "%u\n", val);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 
 err_input:
 	spin_unlock_irq(&file->lock);
@@ -753,23 +752,23 @@ static ssize_t sec_debug_read(struct file *filp, char __user *buf,
 	return -EINVAL;
 }
 
-static ssize_t sec_debug_write(struct file *filp, const char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t sec_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct sec_debug_file *file = filp->private_data;
+	struct sec_debug_file *file = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char tbuf[SEC_DBGFS_VAL_MAX_LEN];
 	struct hisi_qm *qm = file->qm;
 	unsigned long val;
 	int len, ret;
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= SEC_DBGFS_VAL_MAX_LEN)
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(tbuf, SEC_DBGFS_VAL_MAX_LEN - 1,
-				     pos, buf, count);
+	len = simple_copy_from_iter(tbuf, &iocb->ki_pos,
+					SEC_DBGFS_VAL_MAX_LEN - 1, from);
 	if (len < 0)
 		return len;
 
@@ -805,8 +804,8 @@ static ssize_t sec_debug_write(struct file *filp, const char __user *buf,
 static const struct file_operations sec_dbg_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = sec_debug_read,
-	.write = sec_debug_write,
+	.read_iter = sec_debug_read,
+	.write_iter = sec_debug_write,
 };
 
 static int sec_debugfs_atomic64_get(void *data, u64 *val)
diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c
index c065fd867161..47319ba13873 100644
--- a/drivers/crypto/hisilicon/zip/zip_main.c
+++ b/drivers/crypto/hisilicon/zip/zip_main.c
@@ -689,10 +689,9 @@ static int clear_enable_write(struct hisi_qm *qm, u32 val)
 	return  0;
 }
 
-static ssize_t hisi_zip_ctrl_debug_read(struct file *filp, char __user *buf,
-					size_t count, loff_t *pos)
+static ssize_t hisi_zip_ctrl_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ctrl_debug_file *file = filp->private_data;
+	struct ctrl_debug_file *file = iocb->ki_filp->private_data;
 	struct hisi_qm *qm = file_to_qm(file);
 	char tbuf[HZIP_BUF_SIZE];
 	u32 val;
@@ -714,7 +713,7 @@ static ssize_t hisi_zip_ctrl_debug_read(struct file *filp, char __user *buf,
 
 	hisi_qm_put_dfx_access(qm);
 	ret = scnprintf(tbuf, sizeof(tbuf), "%u\n", val);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 
 err_input:
 	spin_unlock_irq(&file->lock);
@@ -722,23 +721,23 @@ static ssize_t hisi_zip_ctrl_debug_read(struct file *filp, char __user *buf,
 	return -EINVAL;
 }
 
-static ssize_t hisi_zip_ctrl_debug_write(struct file *filp,
-					 const char __user *buf,
-					 size_t count, loff_t *pos)
+static ssize_t hisi_zip_ctrl_debug_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ctrl_debug_file *file = filp->private_data;
+	struct ctrl_debug_file *file = iocb->ki_filp->private_data;
 	struct hisi_qm *qm = file_to_qm(file);
+	size_t count = iov_iter_count(from);
 	char tbuf[HZIP_BUF_SIZE];
 	unsigned long val;
 	int len, ret;
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= HZIP_BUF_SIZE)
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(tbuf, HZIP_BUF_SIZE - 1, pos, buf, count);
+	len = simple_copy_from_iter(tbuf, &iocb->ki_pos, HZIP_BUF_SIZE - 1, from);
 	if (len < 0)
 		return len;
 
@@ -774,8 +773,8 @@ static ssize_t hisi_zip_ctrl_debug_write(struct file *filp,
 static const struct file_operations ctrl_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = hisi_zip_ctrl_debug_read,
-	.write = hisi_zip_ctrl_debug_write,
+	.read_iter = hisi_zip_ctrl_debug_read,
+	.write_iter = hisi_zip_ctrl_debug_write,
 };
 
 static int zip_debugfs_atomic64_set(void *data, u64 val)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 107/437] crypto: iaa: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (105 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 106/437] crypto: hisilicon: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 108/437] crypto: qat: " Jens Axboe
                   ` (330 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/crypto/intel/iaa/iaa_crypto_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/intel/iaa/iaa_crypto_stats.c b/drivers/crypto/intel/iaa/iaa_crypto_stats.c
index c9f83af4b307..8ae1cf87ddca 100644
--- a/drivers/crypto/intel/iaa/iaa_crypto_stats.c
+++ b/drivers/crypto/intel/iaa/iaa_crypto_stats.c
@@ -238,7 +238,7 @@ static int wq_stats_open(struct inode *inode, struct file *file)
 
 static const struct file_operations wq_stats_fops = {
 	.open = wq_stats_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 108/437] crypto: qat: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (106 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 107/437] crypto: iaa: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 109/437] crypto: cpp: " Jens Axboe
                   ` (329 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../intel/qat/qat_common/adf_cnv_dbgfs.c      | 10 ++--
 .../intel/qat/qat_common/adf_fw_counters.c    |  2 +-
 .../qat/qat_common/adf_heartbeat_dbgfs.c      | 60 +++++++++----------
 .../intel/qat/qat_common/adf_pm_dbgfs.c       |  3 +-
 .../intel/qat/qat_common/adf_tl_debugfs.c     | 18 +++---
 5 files changed, 44 insertions(+), 49 deletions(-)

diff --git a/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c b/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c
index 627953a72d47..3c6b7d0b2e9d 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_cnv_dbgfs.c
@@ -255,23 +255,21 @@ static int qat_cnv_errors_file_release(struct inode *inode, struct file *file)
 static const struct file_operations qat_cnv_fops = {
 	.owner = THIS_MODULE,
 	.open = qat_cnv_errors_file_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = qat_cnv_errors_file_release,
 };
 
-static ssize_t no_comp_file_read(struct file *f, char __user *buf, size_t count,
-				 loff_t *pos)
+static ssize_t no_comp_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *file_msg = "No engine configured for comp\n";
 
-	return simple_read_from_buffer(buf, count, pos, file_msg,
-				       strlen(file_msg));
+	return simple_copy_to_iter(file_msg, &iocb->ki_pos, strlen(file_msg), to);
 }
 
 static const struct file_operations qat_cnv_no_comp_fops = {
 	.owner = THIS_MODULE,
-	.read = no_comp_file_read,
+	.read_iter = no_comp_file_read,
 };
 
 void adf_cnv_dbgfs_add(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c b/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c
index 98fb7ccfed9f..f654d698efe9 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_fw_counters.c
@@ -224,7 +224,7 @@ static int qat_fw_counters_file_release(struct inode *inode, struct file *file)
 static const struct file_operations qat_fw_counters_fops = {
 	.owner = THIS_MODULE,
 	.open = qat_fw_counters_file_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = qat_fw_counters_file_release,
 };
diff --git a/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c b/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c
index cccdff24b48d..16f4dfdbb434 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c
@@ -19,30 +19,28 @@
 #define HB_STATUS_MAX_STRLEN 4
 #define HB_STATS_MAX_STRLEN 16
 
-static ssize_t adf_hb_stats_read(struct file *file, char __user *user_buffer,
-				 size_t count, loff_t *ppos)
+static ssize_t adf_hb_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[HB_STATS_MAX_STRLEN];
 	unsigned int *value;
 	int len;
 
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
-	value = file->private_data;
+	value = iocb->ki_filp->private_data;
 	len = scnprintf(buf, sizeof(buf), "%u\n", *value);
 
-	return simple_read_from_buffer(user_buffer, count, ppos, buf, len + 1);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len + 1, to);
 }
 
 static const struct file_operations adf_hb_stats_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = adf_hb_stats_read,
+	.read_iter = adf_hb_stats_read,
 };
 
-static ssize_t adf_hb_status_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t adf_hb_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	enum adf_device_heartbeat_status hb_status;
 	char ret_str[HB_STATUS_MAX_STRLEN];
@@ -50,10 +48,10 @@ static ssize_t adf_hb_status_read(struct file *file, char __user *user_buf,
 	int ret_code;
 	size_t len;
 
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
-	accel_dev = file->private_data;
+	accel_dev = iocb->ki_filp->private_data;
 	ret_code = HB_OK;
 
 	adf_heartbeat_status(accel_dev, &hb_status);
@@ -63,52 +61,50 @@ static ssize_t adf_hb_status_read(struct file *file, char __user *user_buf,
 
 	len = scnprintf(ret_str, sizeof(ret_str), "%d\n", ret_code);
 
-	return simple_read_from_buffer(user_buf, count, ppos, ret_str, len + 1);
+	return simple_copy_to_iter(ret_str, &iocb->ki_pos, len + 1, to);
 }
 
 static const struct file_operations adf_hb_status_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = adf_hb_status_read,
+	.read_iter = adf_hb_status_read,
 };
 
-static ssize_t adf_hb_cfg_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t adf_hb_cfg_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char timer_str[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
 	struct adf_accel_dev *accel_dev;
 	unsigned int timer_ms;
 	int len;
 
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
-	accel_dev = file->private_data;
+	accel_dev = iocb->ki_filp->private_data;
 	timer_ms = accel_dev->heartbeat->hb_timer;
 	len = scnprintf(timer_str, sizeof(timer_str), "%u\n", timer_ms);
 
-	return simple_read_from_buffer(user_buf, count, ppos, timer_str,
-				       len + 1);
+	return simple_copy_to_iter(timer_str, &iocb->ki_pos, len + 1, to);
 }
 
-static ssize_t adf_hb_cfg_write(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t adf_hb_cfg_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char input_str[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { };
+	size_t count = iov_iter_count(from);
 	struct adf_accel_dev *accel_dev;
 	int ret, written_chars;
 	unsigned int timer_ms;
 	u32 ticks;
 
-	accel_dev = file->private_data;
+	accel_dev = iocb->ki_filp->private_data;
 	timer_ms = ADF_CFG_HB_TIMER_DEFAULT_MS;
 
 	/* last byte left as string termination */
 	if (count > sizeof(input_str) - 1)
 		return -EINVAL;
 
-	written_chars = simple_write_to_buffer(input_str, sizeof(input_str) - 1,
-					       ppos, user_buf, count);
+	written_chars = simple_copy_from_iter(input_str, &iocb->ki_pos,
+						sizeof(input_str) - 1, from);
 	if (written_chars > 0) {
 		ret = kstrtouint(input_str, 10, &timer_ms);
 		if (ret) {
@@ -151,23 +147,23 @@ static ssize_t adf_hb_cfg_write(struct file *file, const char __user *user_buf,
 static const struct file_operations adf_hb_cfg_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = adf_hb_cfg_read,
-	.write = adf_hb_cfg_write,
+	.read_iter = adf_hb_cfg_read,
+	.write_iter = adf_hb_cfg_write,
 };
 
-static ssize_t adf_hb_error_inject_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t adf_hb_error_inject_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct adf_accel_dev *accel_dev = file->private_data;
+	struct adf_accel_dev *accel_dev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[3];
 	int ret;
 
 	/* last byte left as string termination */
-	if (*ppos != 0 || count != 2)
+	if (iocb->ki_pos != 0 || count != 2)
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 	buf[count] = '\0';
 
@@ -190,7 +186,7 @@ static ssize_t adf_hb_error_inject_write(struct file *file,
 static const struct file_operations adf_hb_error_inject_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = adf_hb_error_inject_write,
+	.write_iter = adf_hb_error_inject_write,
 };
 
 void adf_heartbeat_dbgfs_add(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/intel/qat/qat_common/adf_pm_dbgfs.c b/drivers/crypto/intel/qat/qat_common/adf_pm_dbgfs.c
index f0a13c190196..95105baa68d0 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_pm_dbgfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_pm_dbgfs.c
@@ -18,10 +18,11 @@ static ssize_t pm_status_read(struct file *f, char __user *buf, size_t count,
 
 	return count;
 }
+FOPS_READ_ITER_HELPER(pm_status_read);
 
 static const struct file_operations pm_status_fops = {
 	.owner = THIS_MODULE,
-	.read = pm_status_read,
+	.read_iter = pm_status_read_iter,
 };
 
 void adf_pm_dbgfs_add(struct adf_accel_dev *accel_dev)
diff --git a/drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c b/drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c
index c8241f5a0a26..d3704f41c406 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_tl_debugfs.c
@@ -413,10 +413,10 @@ static int tl_control_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t tl_control_write(struct file *file, const char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t tl_control_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq_f = file->private_data;
+	struct seq_file *seq_f = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct adf_accel_dev *accel_dev;
 	struct adf_telemetry *telemetry;
 	struct adf_tl_hw_data *tl_data;
@@ -434,7 +434,7 @@ static ssize_t tl_control_write(struct file *file, const char __user *userbuf,
 
 	mutex_lock(&telemetry->wr_lock);
 
-	ret = kstrtou32_from_user(userbuf, count, 10, &input);
+	ret = kstrtou32_from_iter(from, count, 10, &input);
 	if (ret)
 		goto unlock_and_exit;
 
@@ -627,10 +627,10 @@ static int tl_rp_data_show(struct seq_file *s, void *unused)
 	return tl_print_rp_data(accel_dev, s, rp_regs_index);
 }
 
-static ssize_t tl_rp_data_write(struct file *file, const char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t tl_rp_data_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq_f = file->private_data;
+	struct seq_file *seq_f = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct adf_accel_dev *accel_dev;
 	struct adf_telemetry *telemetry;
 	unsigned int new_rp_num;
@@ -647,13 +647,13 @@ static ssize_t tl_rp_data_write(struct file *file, const char __user *userbuf,
 
 	mutex_lock(&telemetry->wr_lock);
 
-	ret = get_rp_index_from_file(file, &rp_regs_index, max_rp);
+	ret = get_rp_index_from_file(iocb->ki_filp, &rp_regs_index, max_rp);
 	if (ret) {
 		dev_dbg(&GET_DEV(accel_dev), "invalid RP data file name\n");
 		goto unlock_and_exit;
 	}
 
-	ret = kstrtou32_from_user(userbuf, count, 10, &new_rp_num);
+	ret = kstrtou32_from_iter(from, count, 10, &new_rp_num);
 	if (ret)
 		goto unlock_and_exit;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 109/437] crypto: cpp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (107 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 108/437] crypto: qat: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 110/437] fs/pstore: " Jens Axboe
                   ` (328 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/crypto/ccp/ccp-debugfs.c | 51 ++++++++++++++------------------
 1 file changed, 22 insertions(+), 29 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-debugfs.c b/drivers/crypto/ccp/ccp-debugfs.c
index a1055554b47a..34bf31386994 100644
--- a/drivers/crypto/ccp/ccp-debugfs.c
+++ b/drivers/crypto/ccp/ccp-debugfs.c
@@ -39,10 +39,9 @@
 #define	RI_NLSB_SHIFT	19
 #define	RI_NLSB(r)	(((r) * RI_LSB_ENTRIES) >> RI_NLSB_SHIFT)
 
-static ssize_t ccp5_debugfs_info_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp)
+static ssize_t ccp5_debugfs_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ccp_device *ccp = filp->private_data;
+	struct ccp_device *ccp = iocb->ki_filp->private_data;
 	unsigned int oboff = 0;
 	unsigned int regval;
 	ssize_t ret;
@@ -85,7 +84,7 @@ static ssize_t ccp5_debugfs_info_read(struct file *filp, char __user *ubuf,
 	oboff += OSCNPRINTF("LSB Entries: %d\n",
 		   (regval & RI_LSB_ENTRIES) >> RI_NLSB_SHIFT);
 
-	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
+	ret = simple_copy_to_iter(obuf, &iocb->ki_pos, oboff, to);
 	kfree(obuf);
 
 	return ret;
@@ -94,10 +93,9 @@ static ssize_t ccp5_debugfs_info_read(struct file *filp, char __user *ubuf,
 /* Return a formatted buffer containing the current
  * statistics across all queues for a CCP.
  */
-static ssize_t ccp5_debugfs_stats_read(struct file *filp, char __user *ubuf,
-				       size_t count, loff_t *offp)
+static ssize_t ccp5_debugfs_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ccp_device *ccp = filp->private_data;
+	struct ccp_device *ccp = iocb->ki_filp->private_data;
 	unsigned long total_xts_aes_ops = 0;
 	unsigned long total_3des_ops = 0;
 	unsigned long total_aes_ops = 0;
@@ -147,7 +145,7 @@ static ssize_t ccp5_debugfs_stats_read(struct file *filp, char __user *ubuf,
 	oboff += OSCNPRINTF("                     ECC: %ld\n",
 			    total_ecc_ops);
 
-	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
+	ret = simple_copy_to_iter(obuf, &iocb->ki_pos, oboff, to);
 	kfree(obuf);
 
 	return ret;
@@ -171,27 +169,25 @@ static void ccp5_debugfs_reset_queue_stats(struct ccp_cmd_queue *cmd_q)
  * should be used to reset the queue counters across
  * that device.
  */
-static ssize_t ccp5_debugfs_stats_write(struct file *filp,
-					const char __user *ubuf,
-					size_t count, loff_t *offp)
+static ssize_t ccp5_debugfs_stats_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ccp_device *ccp = filp->private_data;
+	struct ccp_device *ccp = iocb->ki_filp->private_data;
 	int i;
 
 	for (i = 0; i < ccp->cmd_q_count; i++)
 		ccp5_debugfs_reset_queue_stats(&ccp->cmd_q[i]);
 	ccp->total_interrupts = 0L;
 
-	return count;
+	return iov_iter_count(from);
 }
 
 /* Return a formatted buffer containing the current information
  * for that queue
  */
-static ssize_t ccp5_debugfs_queue_read(struct file *filp, char __user *ubuf,
-				       size_t count, loff_t *offp)
+static ssize_t ccp5_debugfs_queue_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ccp_cmd_queue *cmd_q = filp->private_data;
+	struct ccp_cmd_queue *cmd_q = iocb->ki_filp->private_data;
 	unsigned int oboff = 0;
 	unsigned int regval;
 	ssize_t ret;
@@ -233,7 +229,7 @@ static ssize_t ccp5_debugfs_queue_read(struct file *filp, char __user *ubuf,
 		oboff += OSCNPRINTF(" COMPLETION");
 	oboff += OSCNPRINTF("\n");
 
-	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
+	ret = simple_copy_to_iter(obuf, &iocb->ki_pos, oboff, to);
 	kfree(obuf);
 
 	return ret;
@@ -242,36 +238,33 @@ static ssize_t ccp5_debugfs_queue_read(struct file *filp, char __user *ubuf,
 /* A value was written to the stats variable for a
  * queue. Reset the queue counters to this value.
  */
-static ssize_t ccp5_debugfs_queue_write(struct file *filp,
-					const char __user *ubuf,
-					size_t count, loff_t *offp)
+static ssize_t ccp5_debugfs_queue_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ccp_cmd_queue *cmd_q = filp->private_data;
+	struct ccp_cmd_queue *cmd_q = iocb->ki_filp->private_data;
 
 	ccp5_debugfs_reset_queue_stats(cmd_q);
-
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations ccp_debugfs_info_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ccp5_debugfs_info_read,
-	.write = NULL,
+	.read_iter = ccp5_debugfs_info_read,
 };
 
 static const struct file_operations ccp_debugfs_queue_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ccp5_debugfs_queue_read,
-	.write = ccp5_debugfs_queue_write,
+	.read_iter = ccp5_debugfs_queue_read,
+	.write_iter = ccp5_debugfs_queue_write,
 };
 
 static const struct file_operations ccp_debugfs_stats_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ccp5_debugfs_stats_read,
-	.write = ccp5_debugfs_stats_write,
+	.read_iter = ccp5_debugfs_stats_read,
+	.write_iter = ccp5_debugfs_stats_write,
 };
 
 static struct dentry *ccp_debugfs_dir;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 110/437] fs/pstore: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (108 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 109/437] crypto: cpp: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 111/437] drivers/gpio: convert to ->read_iter and ->write_iter Jens Axboe
                   ` (327 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/pstore/ftrace.c | 16 ++++++++--------
 fs/pstore/inode.c  | 13 ++++++-------
 fs/pstore/pmsg.c   |  3 ++-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
index 776cae20af4e..8c7244df7787 100644
--- a/fs/pstore/ftrace.c
+++ b/fs/pstore/ftrace.c
@@ -88,13 +88,14 @@ static int pstore_set_ftrace_enabled(bool on)
 	return ret;
 }
 
-static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t pstore_ftrace_knob_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u8 on;
 	ssize_t ret;
 
-	ret = kstrtou8_from_user(buf, count, 2, &on);
+	ret = kstrtou8_from_iter(from, count, 2, &on);
 	if (ret)
 		return ret;
 
@@ -108,18 +109,17 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
 	return ret;
 }
 
-static ssize_t pstore_ftrace_knob_read(struct file *f, char __user *buf,
-				       size_t count, loff_t *ppos)
+static ssize_t pstore_ftrace_knob_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char val[] = { '0' + pstore_ftrace_enabled, '\n' };
 
-	return simple_read_from_buffer(buf, count, ppos, val, sizeof(val));
+	return simple_copy_to_iter(val, &iocb->ki_pos, sizeof(val), to);
 }
 
 static const struct file_operations pstore_knob_fops = {
 	.open	= simple_open,
-	.read	= pstore_ftrace_knob_read,
-	.write	= pstore_ftrace_knob_write,
+	.read_iter	= pstore_ftrace_knob_read,
+	.write_iter	= pstore_ftrace_knob_write,
 };
 
 static struct dentry *pstore_ftrace_dir;
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 56815799ce79..581f014149a9 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -127,16 +127,15 @@ static const struct seq_operations pstore_ftrace_seq_ops = {
 	.show	= pstore_ftrace_seq_show,
 };
 
-static ssize_t pstore_file_read(struct file *file, char __user *userbuf,
-						size_t count, loff_t *ppos)
+static ssize_t pstore_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct seq_file *sf = file->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
 	struct pstore_private *ps = sf->private;
 
 	if (ps->record->type == PSTORE_TYPE_FTRACE)
-		return seq_read(file, userbuf, count, ppos);
-	return simple_read_from_buffer(userbuf, count, ppos,
-				       ps->record->buf, ps->total_size);
+		return seq_read_iter(iocb, to);
+	return simple_copy_to_iter(ps->record->buf, &iocb->ki_pos,
+					ps->total_size, to);
 }
 
 static int pstore_file_open(struct inode *inode, struct file *file)
@@ -170,7 +169,7 @@ static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence)
 
 static const struct file_operations pstore_file_operations = {
 	.open		= pstore_file_open,
-	.read		= pstore_file_read,
+	.read_iter	= pstore_file_read,
 	.llseek		= pstore_file_llseek,
 	.release	= seq_release,
 };
diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
index 55f139afa327..83fef50ecce5 100644
--- a/fs/pstore/pmsg.c
+++ b/fs/pstore/pmsg.c
@@ -33,11 +33,12 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,
 	mutex_unlock(&pmsg_lock);
 	return ret ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(write_pmsg);
 
 static const struct file_operations pmsg_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= noop_llseek,
-	.write		= write_pmsg,
+	.write_iter	= write_pmsg_iter,
 };
 
 static struct class *pmsg_class;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 111/437] drivers/gpio: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (109 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 110/437] fs/pstore: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 112/437] drivers/bluetooth: convert to read/write iterators Jens Axboe
                   ` (326 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpio/gpio-mockup.c  | 26 +++++++++++------------
 drivers/gpio/gpiolib-cdev.c | 41 ++++++++++++++++++-------------------
 2 files changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 455eecf6380e..34fc0f921284 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -265,9 +265,7 @@ static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset)
 	__gpio_mockup_set(chip, offset, chip->lines[offset].pull);
 }
 
-static ssize_t gpio_mockup_debugfs_read(struct file *file,
-					char __user *usr_buf,
-					size_t size, loff_t *ppos)
+static ssize_t gpio_mockup_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct gpio_mockup_dbgfs_private *priv;
 	struct gpio_mockup_chip *chip;
@@ -276,10 +274,10 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
 	int val, cnt;
 	char buf[3];
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
-	sfile = file->private_data;
+	sfile = iocb->ki_filp->private_data;
 	priv = sfile->private;
 	chip = priv->chip;
 	gc = &chip->gc;
@@ -287,27 +285,27 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file,
 	val = gpio_mockup_get(gc, priv->offset);
 	cnt = snprintf(buf, sizeof(buf), "%d\n", val);
 
-	return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, cnt, to);
 }
 
-static ssize_t gpio_mockup_debugfs_write(struct file *file,
-					 const char __user *usr_buf,
-					 size_t size, loff_t *ppos)
+static ssize_t gpio_mockup_debugfs_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 	struct gpio_mockup_dbgfs_private *priv;
+	size_t size = iov_iter_count(from);
 	int rv, val;
 	struct seq_file *sfile;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
-	rv = kstrtoint_from_user(usr_buf, size, 0, &val);
+	rv = kstrtoint_from_iter(from, size, 0, &val);
 	if (rv)
 		return rv;
 	if (val != 0 && val != 1)
 		return -EINVAL;
 
-	sfile = file->private_data;
+	sfile = iocb->ki_filp->private_data;
 	priv = sfile->private;
 	rv = gpio_mockup_apply_pull(priv->chip, priv->offset, val);
 	if (rv)
@@ -345,8 +343,8 @@ static int gpio_mockup_debugfs_open(struct inode *inode, struct file *file)
 static const struct file_operations gpio_mockup_debugfs_ops = {
 	.owner = THIS_MODULE,
 	.open = gpio_mockup_debugfs_open,
-	.read = gpio_mockup_debugfs_read,
-	.write = gpio_mockup_debugfs_write,
+	.read_iter = gpio_mockup_debugfs_read,
+	.write_iter = gpio_mockup_debugfs_write,
 	.llseek = no_llseek,
 	.release = single_release,
 };
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index d09c7d728365..25e054a42bb1 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -1597,10 +1597,10 @@ static __poll_t linereq_poll(struct file *file,
 	return events;
 }
 
-static ssize_t linereq_read(struct file *file, char __user *buf,
-			    size_t count, loff_t *f_ps)
+static ssize_t linereq_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct linereq *lr = file->private_data;
+	struct linereq *lr = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct gpio_v2_line_event le;
 	ssize_t bytes_read = 0;
 	int ret;
@@ -1619,7 +1619,7 @@ static ssize_t linereq_read(struct file *file, char __user *buf,
 				if (bytes_read)
 					return bytes_read;
 
-				if (file->f_flags & O_NONBLOCK)
+				if (iocb->ki_filp->f_flags & O_NONBLOCK)
 					return -EAGAIN;
 
 				ret = wait_event_interruptible_locked(lr->wait,
@@ -1640,7 +1640,7 @@ static ssize_t linereq_read(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (copy_to_user(buf + bytes_read, &le, sizeof(le)))
+		if (!copy_to_iter_full(&le, sizeof(le), to))
 			return -EFAULT;
 		bytes_read += sizeof(le);
 	} while (count >= bytes_read + sizeof(le));
@@ -1698,7 +1698,7 @@ static void linereq_show_fdinfo(struct seq_file *out, struct file *file)
 
 static const struct file_operations line_fileops = {
 	.release = linereq_release,
-	.read = linereq_read,
+	.read_iter = linereq_read,
 	.poll = linereq_poll,
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
@@ -1935,10 +1935,10 @@ struct compat_gpioeevent_data {
 	u32		id;
 };
 
-static ssize_t lineevent_read(struct file *file, char __user *buf,
-			      size_t count, loff_t *f_ps)
+static ssize_t lineevent_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lineevent_state *le = file->private_data;
+	struct lineevent_state *le = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct gpioevent_data ge;
 	ssize_t bytes_read = 0;
 	ssize_t ge_size;
@@ -1971,7 +1971,7 @@ static ssize_t lineevent_read(struct file *file, char __user *buf,
 				if (bytes_read)
 					return bytes_read;
 
-				if (file->f_flags & O_NONBLOCK)
+				if (iocb->ki_filp->f_flags & O_NONBLOCK)
 					return -EAGAIN;
 
 				ret = wait_event_interruptible_locked(le->wait,
@@ -1992,7 +1992,7 @@ static ssize_t lineevent_read(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (copy_to_user(buf + bytes_read, &ge, ge_size))
+		if (!copy_to_iter_full(&ge, ge_size, to))
 			return -EFAULT;
 		bytes_read += ge_size;
 	} while (count >= bytes_read + ge_size);
@@ -2064,7 +2064,7 @@ static long lineevent_ioctl_compat(struct file *file, unsigned int cmd,
 
 static const struct file_operations lineevent_fileops = {
 	.release = lineevent_release,
-	.read = lineevent_read,
+	.read_iter = lineevent_read,
 	.poll = lineevent_poll,
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
@@ -2649,11 +2649,11 @@ static __poll_t lineinfo_watch_poll(struct file *file,
 	return events;
 }
 
-static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,
-				   size_t count, loff_t *off)
+static ssize_t lineinfo_watch_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct gpio_chardev_data *cdev = file->private_data;
+	struct gpio_chardev_data *cdev = iocb->ki_filp->private_data;
 	struct gpio_v2_line_info_changed event;
+	size_t count = iov_iter_count(to);
 	ssize_t bytes_read = 0;
 	int ret;
 	size_t event_size;
@@ -2675,7 +2675,7 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,
 				if (bytes_read)
 					return bytes_read;
 
-				if (file->f_flags & O_NONBLOCK)
+				if (iocb->ki_filp->f_flags & O_NONBLOCK)
 					return -EAGAIN;
 
 				ret = wait_event_interruptible_locked(cdev->wait,
@@ -2702,18 +2702,17 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,
 
 #ifdef CONFIG_GPIO_CDEV_V1
 		if (event_size == sizeof(struct gpio_v2_line_info_changed)) {
-			if (copy_to_user(buf + bytes_read, &event, event_size))
+			if (!copy_to_iter_full(&event, event_size, to))
 				return -EFAULT;
 		} else {
 			struct gpioline_info_changed event_v1;
 
 			gpio_v2_line_info_changed_to_v1(&event, &event_v1);
-			if (copy_to_user(buf + bytes_read, &event_v1,
-					 event_size))
+			if (!copy_to_iter_full(&event_v1, event_size, to))
 				return -EFAULT;
 		}
 #else
-		if (copy_to_user(buf + bytes_read, &event, event_size))
+		if (!copy_to_iter_full(&event, event_size, to))
 			return -EFAULT;
 #endif
 		bytes_read += event_size;
@@ -2814,7 +2813,7 @@ static const struct file_operations gpio_fileops = {
 	.release = gpio_chrdev_release,
 	.open = gpio_chrdev_open,
 	.poll = lineinfo_watch_poll,
-	.read = lineinfo_watch_read,
+	.read_iter = lineinfo_watch_read,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 	.unlocked_ioctl = gpio_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 112/437] drivers/bluetooth: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (110 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 111/437] drivers/gpio: convert to ->read_iter and ->write_iter Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 113/437] drivers/ras: " Jens Axboe
                   ` (325 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/bluetooth/btmrvl_debugfs.c | 57 +++++++++++------------
 drivers/bluetooth/btusb.c          | 20 ++++----
 drivers/bluetooth/hci_vhci.c       | 73 ++++++++++++++----------------
 3 files changed, 70 insertions(+), 80 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 32329a2e526f..e78343575146 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -18,13 +18,13 @@ struct btmrvl_debugfs_data {
 	struct dentry *status_dir;
 };
 
-static ssize_t btmrvl_hscfgcmd_write(struct file *file,
-			const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t btmrvl_hscfgcmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	long result, ret;
 
-	ret = kstrtol_from_user(ubuf, count, 10, &result);
+	ret = kstrtol_from_iter(from, count, 10, &result);
 	if (ret)
 		return ret;
 
@@ -38,33 +38,32 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file,
 	return count;
 }
 
-static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
-						size_t count, loff_t *ppos)
+static ssize_t btmrvl_hscfgcmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
 	char buf[16];
 	int ret;
 
 	ret = snprintf(buf, sizeof(buf) - 1, "%d\n",
 						priv->btmrvl_dev.hscfgcmd);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations btmrvl_hscfgcmd_fops = {
-	.read	= btmrvl_hscfgcmd_read,
-	.write	= btmrvl_hscfgcmd_write,
+	.read_iter	= btmrvl_hscfgcmd_read,
+	.write_iter	= btmrvl_hscfgcmd_write,
 	.open	= simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
-						size_t count, loff_t *ppos)
+static ssize_t btmrvl_pscmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	long result, ret;
 
-	ret = kstrtol_from_user(ubuf, count, 10, &result);
+	ret = kstrtol_from_iter(from, count, 10, &result);
 	if (ret)
 		return ret;
 
@@ -79,32 +78,31 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
 
 }
 
-static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
-						size_t count, loff_t *ppos)
+static ssize_t btmrvl_pscmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
 	char buf[16];
 	int ret;
 
 	ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.pscmd);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations btmrvl_pscmd_fops = {
-	.read = btmrvl_pscmd_read,
-	.write = btmrvl_pscmd_write,
+	.read_iter = btmrvl_pscmd_read,
+	.write_iter = btmrvl_pscmd_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
-						size_t count, loff_t *ppos)
+static ssize_t btmrvl_hscmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	long result, ret;
 
-	ret = kstrtol_from_user(ubuf, count, 10, &result);
+	ret = kstrtol_from_iter(from, count, 10, &result);
 	if (ret)
 		return ret;
 
@@ -117,21 +115,20 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
 	return count;
 }
 
-static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
-						size_t count, loff_t *ppos)
+static ssize_t btmrvl_hscmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct btmrvl_private *priv = file->private_data;
+	struct btmrvl_private *priv = iocb->ki_filp->private_data;
 	char buf[16];
 	int ret;
 
 	ret = snprintf(buf, sizeof(buf) - 1, "%d\n", priv->btmrvl_dev.hscmd);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations btmrvl_hscmd_fops = {
-	.read	= btmrvl_hscmd_read,
-	.write	= btmrvl_hscmd_write,
+	.read_iter	= btmrvl_hscmd_read,
+	.write_iter	= btmrvl_hscmd_write,
 	.open	= simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 06e915b57283..7dbcd00ed4ed 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -4161,27 +4161,25 @@ static int btusb_shutdown_qca(struct hci_dev *hdev)
 	return 0;
 }
 
-static ssize_t force_poll_sync_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t force_poll_sync_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct btusb_data *data = file->private_data;
+	struct btusb_data *data = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = data->poll_sync ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t force_poll_sync_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t force_poll_sync_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct btusb_data *data = file->private_data;
+	struct btusb_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -4199,8 +4197,8 @@ static ssize_t force_poll_sync_write(struct file *file,
 
 static const struct file_operations force_poll_sync_fops = {
 	.open		= simple_open,
-	.read		= force_poll_sync_read,
-	.write		= force_poll_sync_write,
+	.read_iter	= force_poll_sync_read,
+	.write_iter	= force_poll_sync_write,
 	.llseek		= default_llseek,
 };
 
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 572d68d52965..0d310a7d78f4 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -109,16 +109,15 @@ static bool vhci_wakeup(struct hci_dev *hdev)
 	return data->wakeup;
 }
 
-static ssize_t force_suspend_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t force_suspend_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct vhci_data *data = file->private_data;
+	struct vhci_data *data = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = data->suspended ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static void vhci_suspend_work(struct work_struct *work)
@@ -132,15 +131,14 @@ static void vhci_suspend_work(struct work_struct *work)
 		hci_resume_dev(data->hdev);
 }
 
-static ssize_t force_suspend_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t force_suspend_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct vhci_data *data = file->private_data;
+	struct vhci_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -156,32 +154,30 @@ static ssize_t force_suspend_write(struct file *file,
 
 static const struct file_operations force_suspend_fops = {
 	.open		= simple_open,
-	.read		= force_suspend_read,
-	.write		= force_suspend_write,
+	.read_iter	= force_suspend_read,
+	.write_iter	= force_suspend_write,
 	.llseek		= default_llseek,
 };
 
-static ssize_t force_wakeup_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t force_wakeup_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct vhci_data *data = file->private_data;
+	struct vhci_data *data = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = data->wakeup ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t force_wakeup_write(struct file *file,
-				  const char __user *user_buf, size_t count,
-				  loff_t *ppos)
+static ssize_t force_wakeup_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct vhci_data *data = file->private_data;
+	struct vhci_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -195,8 +191,8 @@ static ssize_t force_wakeup_write(struct file *file,
 
 static const struct file_operations force_wakeup_fops = {
 	.open		= simple_open,
-	.read		= force_wakeup_read,
-	.write		= force_wakeup_write,
+	.read_iter	= force_wakeup_read,
+	.write_iter	= force_wakeup_write,
 	.llseek		= default_llseek,
 };
 
@@ -227,27 +223,25 @@ static int msft_opcode_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(msft_opcode_fops, msft_opcode_get, msft_opcode_set,
 			 "%llu\n");
 
-static ssize_t aosp_capable_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t aosp_capable_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct vhci_data *vhci = file->private_data;
+	struct vhci_data *vhci = iocb->ki_filp->private_data;
 	char buf[3];
 
 	buf[0] = vhci->aosp_capable ? 'Y' : 'N';
 	buf[1] = '\n';
 	buf[2] = '\0';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t aosp_capable_write(struct file *file,
-				  const char __user *user_buf, size_t count,
-				  loff_t *ppos)
+static ssize_t aosp_capable_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct vhci_data *vhci = file->private_data;
+	struct vhci_data *vhci = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -264,8 +258,8 @@ static ssize_t aosp_capable_write(struct file *file,
 
 static const struct file_operations aosp_capable_fops = {
 	.open		= simple_open,
-	.read		= aosp_capable_read,
-	.write		= aosp_capable_write,
+	.read_iter	= aosp_capable_read,
+	.write_iter	= aosp_capable_write,
 	.llseek		= default_llseek,
 };
 
@@ -320,10 +314,10 @@ static inline void force_devcd_timeout(struct hci_dev *hdev,
 #endif
 }
 
-static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t force_devcd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct vhci_data *data = file->private_data;
+	struct vhci_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct hci_dev *hdev = data->hdev;
 	struct sk_buff *skb = NULL;
 	struct devcoredump_test_data dump_data;
@@ -334,7 +328,7 @@ static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,
 	    count > sizeof(dump_data))
 		return -EINVAL;
 
-	if (copy_from_user(&dump_data, user_buf, count))
+	if (!copy_from_iter_full(&dump_data, count, from))
 		return -EFAULT;
 
 	data_size = count - offsetof(struct devcoredump_test_data, data);
@@ -377,7 +371,7 @@ static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,
 
 static const struct file_operations force_devcoredump_fops = {
 	.open		= simple_open,
-	.write		= force_devcd_write,
+	.write_iter	= force_devcd_write,
 };
 
 static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
@@ -608,6 +602,7 @@ static ssize_t vhci_read(struct file *file,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(vhci_read);
 
 static ssize_t vhci_write(struct kiocb *iocb, struct iov_iter *from)
 {
@@ -684,7 +679,7 @@ static int vhci_release(struct inode *inode, struct file *file)
 
 static const struct file_operations vhci_fops = {
 	.owner		= THIS_MODULE,
-	.read		= vhci_read,
+	.read_iter	= vhci_read_iter,
 	.write_iter	= vhci_write,
 	.poll		= vhci_poll,
 	.open		= vhci_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 113/437] drivers/ras: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (111 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 112/437] drivers/bluetooth: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 114/437] fs/efivars: " Jens Axboe
                   ` (324 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/ras/amd/fmpm.c | 2 +-
 drivers/ras/debugfs.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index 271dfad05d68..8e0a89491170 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -944,7 +944,7 @@ static int fmpm_open(struct inode *inode, struct file *file)
 static const struct file_operations fmpm_fops = {
 	.open		= fmpm_open,
 	.release	= seq_release,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 };
 
diff --git a/drivers/ras/debugfs.c b/drivers/ras/debugfs.c
index 42afd3de68b2..e71046472cea 100644
--- a/drivers/ras/debugfs.c
+++ b/drivers/ras/debugfs.c
@@ -38,7 +38,7 @@ static int trace_release(struct inode *inode, struct file *file)
 
 static const struct file_operations trace_fops = {
 	.open    = trace_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = trace_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 114/437] fs/efivars: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (112 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 113/437] drivers/ras: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 115/437] drivers/comedi: " Jens Axboe
                   ` (323 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/efivarfs/file.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index 7e9961639802..b53246e728a5 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -12,13 +12,13 @@
 
 #include "internal.h"
 
-static ssize_t efivarfs_file_write(struct file *file,
-		const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t efivarfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct efivar_entry *var = file->private_data;
+	struct efivar_entry *var = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	void *data;
 	u32 attributes;
-	struct inode *inode = file->f_mapping->host;
+	struct inode *inode = iocb->ki_filp->f_mapping->host;
 	unsigned long datasize = count - sizeof(attributes);
 	ssize_t bytes;
 	bool set = false;
@@ -26,13 +26,13 @@ static ssize_t efivarfs_file_write(struct file *file,
 	if (count < sizeof(attributes))
 		return -EINVAL;
 
-	if (copy_from_user(&attributes, userbuf, sizeof(attributes)))
+	if (!copy_from_iter_full(&attributes, sizeof(attributes), from))
 		return -EFAULT;
 
 	if (attributes & ~(EFI_VARIABLE_MASK))
 		return -EINVAL;
 
-	data = memdup_user(userbuf + sizeof(attributes), datasize);
+	data = iterdup(from, datasize);
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
@@ -46,8 +46,8 @@ static ssize_t efivarfs_file_write(struct file *file,
 
 	if (bytes == -ENOENT) {
 		drop_nlink(inode);
-		d_delete(file->f_path.dentry);
-		dput(file->f_path.dentry);
+		d_delete(iocb->ki_filp->f_path.dentry);
+		dput(iocb->ki_filp->f_path.dentry);
 	} else {
 		inode_lock(inode);
 		i_size_write(inode, datasize + sizeof(attributes));
@@ -63,17 +63,16 @@ static ssize_t efivarfs_file_write(struct file *file,
 	return bytes;
 }
 
-static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
-		size_t count, loff_t *ppos)
+static ssize_t efivarfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct efivar_entry *var = file->private_data;
+	struct efivar_entry *var = iocb->ki_filp->private_data;
 	unsigned long datasize = 0;
 	u32 attributes;
 	void *data;
 	ssize_t size = 0;
 	int err;
 
-	while (!__ratelimit(&file->f_cred->user->ratelimit))
+	while (!__ratelimit(&iocb->ki_filp->f_cred->user->ratelimit))
 		msleep(50);
 
 	err = efivar_entry_size(var, &datasize);
@@ -98,8 +97,8 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
 		goto out_free;
 
 	memcpy(data, &attributes, sizeof(attributes));
-	size = simple_read_from_buffer(userbuf, count, ppos,
-				       data, datasize + sizeof(attributes));
+	size = simple_copy_to_iter(data, &iocb->ki_pos,
+				   datasize + sizeof(attributes), to);
 out_free:
 	kfree(data);
 
@@ -108,7 +107,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
 
 const struct file_operations efivarfs_file_operations = {
 	.open	= simple_open,
-	.read	= efivarfs_file_read,
-	.write	= efivarfs_file_write,
+	.read_iter	= efivarfs_file_read,
+	.write_iter	= efivarfs_file_write,
 	.llseek	= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 115/437] drivers/comedi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (113 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 114/437] fs/efivars: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 116/437] drivers/counter: " Jens Axboe
                   ` (322 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/comedi/comedi_fops.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index 1b481731df96..0e18fac552d3 100644
--- a/drivers/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
@@ -2463,8 +2463,7 @@ static __poll_t comedi_poll(struct file *file, poll_table *wait)
 	return mask;
 }
 
-static ssize_t comedi_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *offset)
+static ssize_t comedi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct comedi_subdevice *s;
 	struct comedi_async *async;
@@ -2472,7 +2471,9 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
 	ssize_t count = 0;
 	int retval = 0;
 	DECLARE_WAITQUEUE(wait, current);
+	struct file *file = iocb->ki_filp;
 	struct comedi_file *cfp = file->private_data;
+	size_t nbytes = iov_iter_count(from);
 	struct comedi_device *dev = cfp->dev;
 	bool become_nonbusy = false;
 	bool attach_locked;
@@ -2546,11 +2547,11 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
 		wp = async->buf_write_ptr;
 		n1 = min(n, async->prealloc_bufsz - wp);
 		n2 = n - n1;
-		m = copy_from_user(async->prealloc_buf + wp, buf, n1);
+		m = copy_from_iter(async->prealloc_buf + wp, n1, from);
 		if (m)
 			m += n2;
 		else if (n2)
-			m = copy_from_user(async->prealloc_buf, buf + n1, n2);
+			m = copy_from_iter(async->prealloc_buf, n2, from);
 		if (m) {
 			n -= m;
 			retval = -EFAULT;
@@ -2559,8 +2560,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
 
 		count += n;
 		nbytes -= n;
-
-		buf += n;
 	}
 	remove_wait_queue(&async->wait_head, &wait);
 	set_current_state(TASK_RUNNING);
@@ -2599,8 +2598,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
 	return count ? count : retval;
 }
 
-static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
-			   loff_t *offset)
+static ssize_t comedi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct comedi_subdevice *s;
 	struct comedi_async *async;
@@ -2608,7 +2606,9 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
 	ssize_t count = 0;
 	int retval = 0;
 	DECLARE_WAITQUEUE(wait, current);
+	struct file *file = iocb->ki_filp;
 	struct comedi_file *cfp = file->private_data;
+	size_t nbytes = iov_iter_count(to);
 	struct comedi_device *dev = cfp->dev;
 	unsigned int old_detach_count;
 	bool become_nonbusy = false;
@@ -2680,11 +2680,11 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
 		rp = async->buf_read_ptr;
 		n1 = min(n, async->prealloc_bufsz - rp);
 		n2 = n - n1;
-		m = copy_to_user(buf, async->prealloc_buf + rp, n1);
+		m = copy_to_iter(async->prealloc_buf + rp, n1, to);
 		if (m)
 			m += n2;
 		else if (n2)
-			m = copy_to_user(buf + n1, async->prealloc_buf, n2);
+			m = copy_to_iter(async->prealloc_buf, n2, to);
 		if (m) {
 			n -= m;
 			retval = -EFAULT;
@@ -2695,8 +2695,6 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
 
 		count += n;
 		nbytes -= n;
-
-		buf += n;
 	}
 	remove_wait_queue(&async->wait_head, &wait);
 	set_current_state(TASK_RUNNING);
@@ -3179,8 +3177,8 @@ static const struct file_operations comedi_fops = {
 	.compat_ioctl = comedi_compat_ioctl,
 	.open = comedi_open,
 	.release = comedi_close,
-	.read = comedi_read,
-	.write = comedi_write,
+	.read_iter = comedi_read,
+	.write_iter = comedi_write,
 	.mmap = comedi_mmap,
 	.poll = comedi_poll,
 	.fasync = comedi_fasync,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 116/437] drivers/counter: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (114 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 115/437] drivers/comedi: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 117/437] drivers/hid: " Jens Axboe
                   ` (321 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/counter/counter-chrdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c
index afc94d0062b1..f2d513248120 100644
--- a/drivers/counter/counter-chrdev.c
+++ b/drivers/counter/counter-chrdev.c
@@ -99,6 +99,7 @@ static ssize_t counter_chrdev_read(struct file *filp, char __user *buf,
 
 	return copied;
 }
+FOPS_READ_ITER_HELPER(counter_chrdev_read);
 
 static __poll_t counter_chrdev_poll(struct file *filp,
 				    struct poll_table_struct *pollt)
@@ -455,7 +456,7 @@ static int counter_chrdev_release(struct inode *inode, struct file *filp)
 static const struct file_operations counter_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.read = counter_chrdev_read,
+	.read_iter = counter_chrdev_read_iter,
 	.poll = counter_chrdev_poll,
 	.unlocked_ioctl = counter_chrdev_ioctl,
 	.open = counter_chrdev_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 117/437] drivers/hid: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (115 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 116/437] drivers/counter: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 118/437] drivers/tty: convert to ->read_iter and ->write_iter Jens Axboe
                   ` (320 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hid/hid-debug.c           |  3 +-
 drivers/hid/hid-picolcd_debugfs.c | 65 +++++++++++++++++--------------
 drivers/hid/hid-roccat.c          | 12 +++---
 drivers/hid/hid-sensor-custom.c   |  3 +-
 drivers/hid/hid-wiimote-debug.c   | 15 +++----
 drivers/hid/hidraw.c              | 15 +++----
 drivers/hid/uhid.c                | 15 +++----
 7 files changed, 69 insertions(+), 59 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 7dd83ec74f8a..d5110cd9b440 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1206,6 +1206,7 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
 	mutex_unlock(&list->read_mutex);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(hid_debug_events_read);
 
 static __poll_t hid_debug_events_poll(struct file *file, poll_table *wait)
 {
@@ -1240,7 +1241,7 @@ DEFINE_SHOW_ATTRIBUTE(hid_debug_rdesc);
 static const struct file_operations hid_debug_events_fops = {
 	.owner =        THIS_MODULE,
 	.open           = hid_debug_events_open,
-	.read           = hid_debug_events_read,
+	.read_iter      = hid_debug_events_read_iter,
 	.poll		= hid_debug_events_poll,
 	.release        = hid_debug_events_release,
 	.llseek		= noop_llseek,
diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
index d01176da8896..63785cb6a8ac 100644
--- a/drivers/hid/hid-picolcd_debugfs.c
+++ b/drivers/hid/hid-picolcd_debugfs.c
@@ -34,13 +34,14 @@ static int picolcd_debug_reset_open(struct inode *inode, struct file *f)
 	return single_open(f, picolcd_debug_reset_show, inode->i_private);
 }
 
-static ssize_t picolcd_debug_reset_write(struct file *f, const char __user *user_buf,
-		size_t count, loff_t *ppos)
+static ssize_t picolcd_debug_reset_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct picolcd_data *data = ((struct seq_file *)f->private_data)->private;
+	struct picolcd_data *data = ((struct seq_file *)iocb->ki_filp->private_data)->private;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t cnt = min(count, sizeof(buf)-1);
-	if (copy_from_user(buf, user_buf, cnt))
+	if (!copy_from_iter_full(buf, cnt, from))
 		return -EFAULT;
 
 	while (cnt > 0 && (buf[cnt-1] == ' ' || buf[cnt-1] == '\n'))
@@ -60,34 +61,35 @@ static ssize_t picolcd_debug_reset_write(struct file *f, const char __user *user
 static const struct file_operations picolcd_debug_reset_fops = {
 	.owner    = THIS_MODULE,
 	.open     = picolcd_debug_reset_open,
-	.read     = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek   = seq_lseek,
-	.write    = picolcd_debug_reset_write,
+	.write_iter = picolcd_debug_reset_write,
 	.release  = single_release,
 };
 
 /*
  * The "eeprom" file
  */
-static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
-		size_t s, loff_t *off)
+static ssize_t picolcd_debug_eeprom_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct picolcd_data *data = f->private_data;
+	struct picolcd_data *data = iocb->ki_filp->private_data;
+	size_t s = iov_iter_count(to);
 	struct picolcd_pending *resp;
 	u8 raw_data[3];
 	ssize_t ret = -EIO;
 
 	if (s == 0)
 		return -EINVAL;
-	if (*off > 0x0ff)
+	if (iocb->ki_pos > 0x0ff)
 		return 0;
 
 	/* prepare buffer with info about what we want to read (addr & len) */
-	raw_data[0] = *off & 0xff;
-	raw_data[1] = (*off >> 8) & 0xff;
+	raw_data[0] = iocb->ki_pos & 0xff;
+	raw_data[1] = (iocb->ki_pos >> 8) & 0xff;
 	raw_data[2] = s < 20 ? s : 20;
-	if (*off + raw_data[2] > 0xff)
-		raw_data[2] = 0x100 - *off;
+	if (iocb->ki_pos + raw_data[2] > 0xff)
+		raw_data[2] = 0x100 - iocb->ki_pos;
 	resp = picolcd_send_and_wait(data->hdev, REPORT_EE_READ, raw_data,
 			sizeof(raw_data));
 	if (!resp)
@@ -98,37 +100,38 @@ static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
 		ret = resp->raw_data[2];
 		if (ret > s)
 			ret = s;
-		if (copy_to_user(u, resp->raw_data+3, ret))
+		if (!copy_to_iter_full(resp->raw_data+3, ret, to))
 			ret = -EFAULT;
 		else
-			*off += ret;
+			iocb->ki_pos += ret;
 	} /* anything else is some kind of IO error */
 
 	kfree(resp);
 	return ret;
 }
 
-static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u,
-		size_t s, loff_t *off)
+static ssize_t picolcd_debug_eeprom_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct picolcd_data *data = f->private_data;
+	struct picolcd_data *data = iocb->ki_filp->private_data;
+	size_t s = iov_iter_count(from);
 	struct picolcd_pending *resp;
 	ssize_t ret = -EIO;
 	u8 raw_data[23];
 
 	if (s == 0)
 		return -EINVAL;
-	if (*off > 0x0ff)
+	if (iocb->ki_pos > 0x0ff)
 		return -ENOSPC;
 
 	memset(raw_data, 0, sizeof(raw_data));
-	raw_data[0] = *off & 0xff;
-	raw_data[1] = (*off >> 8) & 0xff;
+	raw_data[0] = iocb->ki_pos & 0xff;
+	raw_data[1] = (iocb->ki_pos >> 8) & 0xff;
 	raw_data[2] = min_t(size_t, 20, s);
-	if (*off + raw_data[2] > 0xff)
-		raw_data[2] = 0x100 - *off;
+	if (iocb->ki_pos + raw_data[2] > 0xff)
+		raw_data[2] = 0x100 - iocb->ki_pos;
 
-	if (copy_from_user(raw_data+3, u, min((u8)20, raw_data[2])))
+	if (!copy_from_iter_full(raw_data+3, min((u8)20, raw_data[2]), from))
 		return -EFAULT;
 	resp = picolcd_send_and_wait(data->hdev, REPORT_EE_WRITE, raw_data,
 			sizeof(raw_data));
@@ -139,7 +142,7 @@ static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u,
 	if (resp->in_report && resp->in_report->id == REPORT_EE_DATA) {
 		/* check if written data matches */
 		if (memcmp(raw_data, resp->raw_data, 3+raw_data[2]) == 0) {
-			*off += raw_data[2];
+			iocb->ki_pos += raw_data[2];
 			ret = raw_data[2];
 		}
 	}
@@ -157,8 +160,8 @@ static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u,
 static const struct file_operations picolcd_debug_eeprom_fops = {
 	.owner    = THIS_MODULE,
 	.open     = simple_open,
-	.read     = picolcd_debug_eeprom_read,
-	.write    = picolcd_debug_eeprom_write,
+	.read_iter = picolcd_debug_eeprom_read,
+	.write_iter = picolcd_debug_eeprom_write,
 	.llseek   = generic_file_llseek,
 };
 
@@ -229,6 +232,7 @@ static ssize_t picolcd_debug_flash_read(struct file *f, char __user *u,
 	else
 		return _picolcd_flash_read(data, REPORT_READ_MEMORY, u, s, off);
 }
+FOPS_READ_ITER_HELPER(picolcd_debug_flash_read);
 
 /* erase block aligned to 64bytes boundary */
 static ssize_t _picolcd_flash_erase64(struct picolcd_data *data, int report_id,
@@ -335,6 +339,7 @@ static ssize_t picolcd_debug_flash_write(struct file *f, const char __user *u,
 	mutex_unlock(&data->mutex_flash);
 	return ret > 0 ? ret : err;
 }
+FOPS_WRITE_ITER_HELPER(picolcd_debug_flash_write);
 
 /*
  * Notes:
@@ -350,8 +355,8 @@ static ssize_t picolcd_debug_flash_write(struct file *f, const char __user *u,
 static const struct file_operations picolcd_debug_flash_fops = {
 	.owner    = THIS_MODULE,
 	.open     = simple_open,
-	.read     = picolcd_debug_flash_read,
-	.write    = picolcd_debug_flash_write,
+	.read_iter = picolcd_debug_flash_read_iter,
+	.write_iter = picolcd_debug_flash_write_iter,
 	.llseek   = generic_file_llseek,
 };
 
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index c7f7562e22e5..072da9cf04a9 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -70,14 +70,14 @@ static struct roccat_device *devices[ROCCAT_MAX_DEVICES];
 /* protects modifications of devices array */
 static DEFINE_MUTEX(devices_lock);
 
-static ssize_t roccat_read(struct file *file, char __user *buffer,
-		size_t count, loff_t *ppos)
+static ssize_t roccat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct roccat_reader *reader = file->private_data;
+	struct roccat_reader *reader = iocb->ki_filp->private_data;
 	struct roccat_device *device = reader->device;
 	struct roccat_report *report;
 	ssize_t retval = 0, len;
 	DECLARE_WAITQUEUE(wait, current);
+	size_t count = iov_iter_count(to);
 
 	mutex_lock(&device->cbuf_lock);
 
@@ -88,7 +88,7 @@ static ssize_t roccat_read(struct file *file, char __user *buffer,
 
 		/* wait for data */
 		while (reader->cbuf_start == device->cbuf_end) {
-			if (file->f_flags & O_NONBLOCK) {
+			if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 				retval = -EAGAIN;
 				break;
 			}
@@ -122,7 +122,7 @@ static ssize_t roccat_read(struct file *file, char __user *buffer,
 	 */
 	len = device->report_size > count ? count : device->report_size;
 
-	if (copy_to_user(buffer, report->value, len)) {
+	if (!copy_to_iter_full(report->value, len, to)) {
 		retval = -EFAULT;
 		goto exit_unlock;
 	}
@@ -407,7 +407,7 @@ static long roccat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations roccat_ops = {
 	.owner = THIS_MODULE,
-	.read = roccat_read,
+	.read_iter = roccat_read,
 	.poll = roccat_poll,
 	.open = roccat_open,
 	.release = roccat_release,
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index d85398721659..a4e58e82b3f1 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -669,6 +669,7 @@ static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
 
 	return copied;
 }
+FOPS_READ_ITER_HELPER(hid_sensor_custom_read);
 
 static int hid_sensor_custom_release(struct inode *inode, struct file *file)
 {
@@ -714,7 +715,7 @@ static __poll_t hid_sensor_custom_poll(struct file *file,
 
 static const struct file_operations hid_sensor_custom_fops = {
 	.open =  hid_sensor_custom_open,
-	.read =  hid_sensor_custom_read,
+	.read_iter =  hid_sensor_custom_read_iter,
 	.release = hid_sensor_custom_release,
 	.poll = hid_sensor_custom_poll,
 	.llseek = noop_llseek,
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index 00f9be55f148..5a7a0991a8f7 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -71,11 +71,12 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(wiidebug_eeprom_read);
 
 static const struct file_operations wiidebug_eeprom_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = wiidebug_eeprom_read,
+	.read_iter = wiidebug_eeprom_read_iter,
 	.llseek = generic_file_llseek,
 };
 
@@ -121,11 +122,11 @@ static int wiidebug_drm_open(struct inode *i, struct file *f)
 	return single_open(f, wiidebug_drm_show, i->i_private);
 }
 
-static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
-							size_t s, loff_t *off)
+static ssize_t wiidebug_drm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sf = f->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
 	struct wiimote_debug *dbg = sf->private;
+	size_t s = iov_iter_count(from);
 	unsigned long flags;
 	char buf[16];
 	ssize_t len;
@@ -135,7 +136,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
 		return -EINVAL;
 
 	len = min((size_t) 15, s);
-	if (copy_from_user(buf, u, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = 0;
@@ -163,9 +164,9 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u,
 static const struct file_operations wiidebug_drm_fops = {
 	.owner = THIS_MODULE,
 	.open = wiidebug_drm_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
-	.write = wiidebug_drm_write,
+	.write_iter = wiidebug_drm_write,
 	.release = single_release,
 };
 
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 2bc762d31ac7..54fab17f45a5 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -38,9 +38,10 @@ static const struct class hidraw_class = {
 static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES];
 static DECLARE_RWSEM(minors_rwsem);
 
-static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
+static ssize_t hidraw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hidraw_list *list = file->private_data;
+	struct hidraw_list *list = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int ret = 0, len;
 	DECLARE_WAITQUEUE(wait, current);
 
@@ -60,7 +61,7 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
 					ret = -EIO;
 					break;
 				}
-				if (file->f_flags & O_NONBLOCK) {
+				if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 					ret = -EAGAIN;
 					break;
 				}
@@ -83,7 +84,7 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
 			count : list->buffer[list->tail].len;
 
 		if (list->buffer[list->tail].value) {
-			if (copy_to_user(buffer, list->buffer[list->tail].value, len)) {
+			if (!copy_to_iter_full(list->buffer[list->tail].value, len, to)) {
 				ret = -EFAULT;
 				goto out;
 			}
@@ -167,7 +168,7 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
 	up_read(&minors_rwsem);
 	return ret;
 }
-
+FOPS_WRITE_ITER_HELPER(hidraw_write);
 
 /*
  * This function performs a Get_Report transfer over the control endpoint
@@ -505,8 +506,8 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
 
 static const struct file_operations hidraw_ops = {
 	.owner =        THIS_MODULE,
-	.read =         hidraw_read,
-	.write =        hidraw_write,
+	.read_iter =    hidraw_read,
+	.write_iter =   hidraw_write_iter,
 	.poll =         hidraw_poll,
 	.open =         hidraw_open,
 	.release =      hidraw_release,
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index a54c7995b9be..fb23cff65c92 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -669,10 +669,10 @@ static int uhid_char_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t uhid_char_read(struct file *file, char __user *buffer,
-				size_t count, loff_t *ppos)
+static ssize_t uhid_char_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uhid_device *uhid = file->private_data;
+	struct uhid_device *uhid = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int ret;
 	unsigned long flags;
 	size_t len;
@@ -682,7 +682,7 @@ static ssize_t uhid_char_read(struct file *file, char __user *buffer,
 		return -EINVAL;
 
 try_again:
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (uhid->head == uhid->tail)
 			return -EAGAIN;
 	} else {
@@ -701,7 +701,7 @@ static ssize_t uhid_char_read(struct file *file, char __user *buffer,
 		goto try_again;
 	} else {
 		len = min(count, sizeof(**uhid->outq));
-		if (copy_to_user(buffer, uhid->outq[uhid->tail], len)) {
+		if (!copy_to_iter_full(uhid->outq[uhid->tail], len, to)) {
 			ret = -EFAULT;
 		} else {
 			kfree(uhid->outq[uhid->tail]);
@@ -782,6 +782,7 @@ static ssize_t uhid_char_write(struct file *file, const char __user *buffer,
 	/* return "count" not "len" to not confuse the caller */
 	return ret ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(uhid_char_write);
 
 static __poll_t uhid_char_poll(struct file *file, poll_table *wait)
 {
@@ -800,8 +801,8 @@ static const struct file_operations uhid_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uhid_char_open,
 	.release	= uhid_char_release,
-	.read		= uhid_char_read,
-	.write		= uhid_char_write,
+	.read_iter	= uhid_char_read,
+	.write_iter	= uhid_char_write_iter,
 	.poll		= uhid_char_poll,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 118/437] drivers/tty: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (116 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 117/437] drivers/hid: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 119/437] drivers/auxdisplay: convert to read/write iterators Jens Axboe
                   ` (319 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/tty/serial/pch_uart.c |  9 ++++-----
 drivers/tty/vt/vc_screen.c    | 32 +++++++++++++++-----------------
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 89257cddf540..a61410eb67b1 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -290,10 +290,9 @@ static const int trigger_level_1[4] = { 1, 1, 1, 1 };
 #define PCH_REGS_BUFSIZE	1024
 
 
-static ssize_t port_show_regs(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t port_show_regs(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct eg20t_port *priv = file->private_data;
+	struct eg20t_port *priv = iocb->ki_filp->private_data;
 	char *buf;
 	u32 len = 0;
 	ssize_t ret;
@@ -335,7 +334,7 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf,
 	if (len > PCH_REGS_BUFSIZE)
 		len = PCH_REGS_BUFSIZE;
 
-	ret =  simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret =  simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret;
 }
@@ -343,7 +342,7 @@ static ssize_t port_show_regs(struct file *file, char __user *user_buf,
 static const struct file_operations port_regs_ops = {
 	.owner		= THIS_MODULE,
 	.open		= simple_open,
-	.read		= port_show_regs,
+	.read_iter	= port_show_regs,
 	.llseek		= default_llseek,
 };
 
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 67e2cb7c96ee..56daaa568866 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -361,10 +361,10 @@ static unsigned int vcs_read_buf(const struct vc_data *vc, char *con_buf,
 	return filled;
 }
 
-static ssize_t
-vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t vcs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	struct vc_data *vc;
 	struct vcs_poll_data *poll;
 	unsigned int read;
@@ -377,7 +377,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	if (!con_buf)
 		return -ENOMEM;
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 
 	/* Select the proper current console and verify
 	 * sanity of the situation under the console lock.
@@ -394,7 +394,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	if (uni_mode && (pos | count) & 3)
 		goto unlock_out;
 
-	poll = file->private_data;
+	poll = iocb->ki_filp->private_data;
 	if (count && poll)
 		poll->event = 0;
 	read = 0;
@@ -453,7 +453,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		 */
 
 		console_unlock();
-		ret = copy_to_user(buf, con_buf + skip, this_round);
+		ret = !copy_to_iter_full(con_buf + skip, this_round, to);
 		console_lock();
 
 		if (ret) {
@@ -461,12 +461,11 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			ret = -EFAULT;
 			break;
 		}
-		buf += this_round;
 		pos += this_round;
 		read += this_round;
 		count -= this_round;
 	}
-	*ppos += read;
+	iocb->ki_pos += read;
 	if (read)
 		ret = read;
 unlock_out:
@@ -586,10 +585,10 @@ static u16 *vcs_write_buf(struct vc_data *vc, const char *con_buf,
 	return org;
 }
 
-static ssize_t
-vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t vcs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct vc_data *vc;
 	char *con_buf;
 	u16 *org0, *org;
@@ -606,7 +605,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 	if (!con_buf)
 		return -ENOMEM;
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 
 	/* Select the proper current console and verify
 	 * sanity of the situation under the console lock.
@@ -640,7 +639,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 		 * in the write data from userspace safely.
 		 */
 		console_unlock();
-		ret = copy_from_user(con_buf, buf, this_round);
+		ret = !copy_from_iter_full(con_buf, this_round, from);
 		console_lock();
 
 		if (ret) {
@@ -692,12 +691,11 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 
 		count -= this_round;
 		written += this_round;
-		buf += this_round;
 		pos += this_round;
 		if (org)
 			update_region(vc, (unsigned long)(org0), org - org0);
 	}
-	*ppos += written;
+	iocb->ki_pos += written;
 	ret = written;
 	if (written)
 		vcs_scr_updated(vc);
@@ -778,8 +776,8 @@ static int vcs_release(struct inode *inode, struct file *file)
 
 static const struct file_operations vcs_fops = {
 	.llseek		= vcs_lseek,
-	.read		= vcs_read,
-	.write		= vcs_write,
+	.read_iter	= vcs_read,
+	.write_iter	= vcs_write,
 	.poll		= vcs_poll,
 	.fasync		= vcs_fasync,
 	.open		= vcs_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 119/437] drivers/auxdisplay: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (117 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 118/437] drivers/tty: convert to ->read_iter and ->write_iter Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 120/437] fs/eventfd: " Jens Axboe
                   ` (318 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/auxdisplay/charlcd.c | 3 ++-
 drivers/auxdisplay/panel.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 6d309e4971b6..b40af38d69b1 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -487,6 +487,7 @@ static ssize_t charlcd_write(struct file *file, const char __user *buf,
 
 	return tmp - buf;
 }
+FOPS_WRITE_ITER_HELPER(charlcd_write);
 
 static int charlcd_open(struct inode *inode, struct file *file)
 {
@@ -521,7 +522,7 @@ static int charlcd_release(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations charlcd_fops = {
-	.write   = charlcd_write,
+	.write_iter = charlcd_write_iter,
 	.open    = charlcd_open,
 	.release = charlcd_release,
 	.llseek  = no_llseek,
diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
index 049ff443e790..0e5d8d09b60f 100644
--- a/drivers/auxdisplay/panel.c
+++ b/drivers/auxdisplay/panel.c
@@ -1045,6 +1045,7 @@ static ssize_t keypad_read(struct file *file,
 
 	return tmp - buf;
 }
+FOPS_READ_ITER_HELPER(keypad_read);
 
 static int keypad_open(struct inode *inode, struct file *file)
 {
@@ -1072,7 +1073,7 @@ static int keypad_release(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations keypad_fops = {
-	.read    = keypad_read,		/* read */
+	.read_iter = keypad_read_iter,	/* read */
 	.open    = keypad_open,		/* open */
 	.release = keypad_release,	/* close */
 	.llseek  = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 120/437] fs/eventfd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (118 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 119/437] drivers/auxdisplay: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 121/437] drivers/input: " Jens Axboe
                   ` (317 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/eventfd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/eventfd.c b/fs/eventfd.c
index 9afdb722fa92..6995253a37f3 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -244,16 +244,16 @@ static ssize_t eventfd_read(struct kiocb *iocb, struct iov_iter *to)
 	return sizeof(ucnt);
 }
 
-static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t count,
-			     loff_t *ppos)
+static ssize_t eventfd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct eventfd_ctx *ctx = file->private_data;
+	struct eventfd_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	__u64 ucnt;
 
 	if (count != sizeof(ucnt))
 		return -EINVAL;
-	if (copy_from_user(&ucnt, buf, sizeof(ucnt)))
+	if (!copy_from_iter_full(&ucnt, sizeof(ucnt), from))
 		return -EFAULT;
 	if (ucnt == ULLONG_MAX)
 		return -EINVAL;
@@ -261,7 +261,7 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
 	res = -EAGAIN;
 	if (ULLONG_MAX - ctx->count > ucnt)
 		res = sizeof(ucnt);
-	else if (!(file->f_flags & O_NONBLOCK)) {
+	else if (!(iocb->ki_filp->f_flags & O_NONBLOCK)) {
 		res = wait_event_interruptible_locked_irq(ctx->wqh,
 				ULLONG_MAX - ctx->count > ucnt);
 		if (!res)
@@ -306,7 +306,7 @@ static const struct file_operations eventfd_fops = {
 	.release	= eventfd_release,
 	.poll		= eventfd_poll,
 	.read_iter	= eventfd_read,
-	.write		= eventfd_write,
+	.write_iter	= eventfd_write,
 	.llseek		= noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 121/437] drivers/input: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (119 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 120/437] fs/eventfd: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 122/437] drivers/pci: " Jens Axboe
                   ` (316 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/input/evdev.c                  |  6 ++++--
 drivers/input/joydev.c                 | 22 +++++++++++-----------
 drivers/input/keyboard/applespi.c      | 11 +++++------
 drivers/input/misc/uinput.c            |  6 ++++--
 drivers/input/mousedev.c               | 16 +++++++++-------
 drivers/input/serio/serio_raw.c        |  6 ++++--
 drivers/input/serio/userio.c           | 22 +++++++++++-----------
 drivers/input/touchscreen/edt-ft5x06.c | 19 ++++++++++---------
 8 files changed, 58 insertions(+), 50 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 51e0c4954600..9f41631df926 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -536,6 +536,7 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
 	mutex_unlock(&evdev->mutex);
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(evdev_write);
 
 static int evdev_fetch_next_event(struct evdev_client *client,
 				  struct input_event *event)
@@ -605,6 +606,7 @@ static ssize_t evdev_read(struct file *file, char __user *buffer,
 
 	return read;
 }
+FOPS_READ_ITER_HELPER(evdev_read);
 
 /* No kernel lock - fine */
 static __poll_t evdev_poll(struct file *file, poll_table *wait)
@@ -1291,8 +1293,8 @@ static long evdev_ioctl_compat(struct file *file,
 
 static const struct file_operations evdev_fops = {
 	.owner		= THIS_MODULE,
-	.read		= evdev_read,
-	.write		= evdev_write,
+	.read_iter	= evdev_read_iter,
+	.write_iter	= evdev_write_iter,
 	.poll		= evdev_poll,
 	.open		= evdev_open,
 	.release	= evdev_release,
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 5824bca02e5a..e84acc296aaa 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -23,6 +23,7 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/cdev.h>
+#include <linux/uio.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Joystick device interfaces");
@@ -338,8 +339,7 @@ static int joydev_fetch_next_event(struct joydev_client *client,
  * Old joystick interface
  */
 static ssize_t joydev_0x_read(struct joydev_client *client,
-			      struct input_dev *input,
-			      char __user *buf)
+			      struct input_dev *input, struct iov_iter *to)
 {
 	struct joydev *joydev = client->joydev;
 	struct JS_DATA_TYPE data;
@@ -366,7 +366,7 @@ static ssize_t joydev_0x_read(struct joydev_client *client,
 
 	spin_unlock_irq(&input->event_lock);
 
-	if (copy_to_user(buf, &data, sizeof(struct JS_DATA_TYPE)))
+	if (!copy_to_iter(&data, sizeof(struct JS_DATA_TYPE), to))
 		return -EFAULT;
 
 	return sizeof(struct JS_DATA_TYPE);
@@ -380,12 +380,12 @@ static inline int joydev_data_pending(struct joydev_client *client)
 		client->head != client->tail;
 }
 
-static ssize_t joydev_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t joydev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct joydev_client *client = file->private_data;
+	struct joydev_client *client = iocb->ki_filp->private_data;
 	struct joydev *joydev = client->joydev;
 	struct input_dev *input = joydev->handle.dev;
+	size_t count = iov_iter_count(to);
 	struct js_event event;
 	int retval;
 
@@ -396,9 +396,9 @@ static ssize_t joydev_read(struct file *file, char __user *buf,
 		return -EINVAL;
 
 	if (count == sizeof(struct JS_DATA_TYPE))
-		return joydev_0x_read(client, input, buf);
+		return joydev_0x_read(client, input, to);
 
-	if (!joydev_data_pending(client) && (file->f_flags & O_NONBLOCK))
+	if (!joydev_data_pending(client) && (iocb->ki_filp->f_flags & O_NONBLOCK))
 		return -EAGAIN;
 
 	retval = wait_event_interruptible(joydev->wait,
@@ -412,7 +412,7 @@ static ssize_t joydev_read(struct file *file, char __user *buf,
 	while (retval + sizeof(struct js_event) <= count &&
 	       joydev_generate_startup_event(client, input, &event)) {
 
-		if (copy_to_user(buf + retval, &event, sizeof(struct js_event)))
+		if (!copy_to_iter_full(&event, sizeof(struct js_event), to))
 			return -EFAULT;
 
 		retval += sizeof(struct js_event);
@@ -421,7 +421,7 @@ static ssize_t joydev_read(struct file *file, char __user *buf,
 	while (retval + sizeof(struct js_event) <= count &&
 	       joydev_fetch_next_event(client, &event)) {
 
-		if (copy_to_user(buf + retval, &event, sizeof(struct js_event)))
+		if (!copy_to_iter_full(&event, sizeof(struct js_event), to))
 			return -EFAULT;
 
 		retval += sizeof(struct js_event);
@@ -709,7 +709,7 @@ static long joydev_ioctl(struct file *file,
 
 static const struct file_operations joydev_fops = {
 	.owner		= THIS_MODULE,
-	.read		= joydev_read,
+	.read_iter	= joydev_read,
 	.poll		= joydev_poll,
 	.open		= joydev_open,
 	.release	= joydev_release,
diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c
index cf25177b4830..fa1ce0d23f14 100644
--- a/drivers/input/keyboard/applespi.c
+++ b/drivers/input/keyboard/applespi.c
@@ -994,19 +994,18 @@ static int applespi_tp_dim_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t applespi_tp_dim_read(struct file *file, char __user *buf,
-				    size_t len, loff_t *off)
+static ssize_t applespi_tp_dim_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct applespi_data *applespi = file->private_data;
+	struct applespi_data *applespi = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, len, off, applespi->tp_dim_val,
-				       strlen(applespi->tp_dim_val));
+	return simple_copy_to_iter(applespi->tp_dim_val, &iocb->ki_pos,
+				       strlen(applespi->tp_dim_val), to);
 }
 
 static const struct file_operations applespi_tp_dim_fops = {
 	.owner = THIS_MODULE,
 	.open = applespi_tp_dim_open,
-	.read = applespi_tp_dim_read,
+	.read_iter = applespi_tp_dim_read,
 	.llseek = no_llseek,
 };
 
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d98212d55108..960a0c729bc2 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -651,6 +651,7 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer,
 
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(uinput_write);
 
 static bool uinput_fetch_next_event(struct uinput_device *udev,
 				    struct input_event *event)
@@ -723,6 +724,7 @@ static ssize_t uinput_read(struct file *file, char __user *buffer,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(uinput_read);
 
 static __poll_t uinput_poll(struct file *file, poll_table *wait)
 {
@@ -1111,8 +1113,8 @@ static const struct file_operations uinput_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uinput_open,
 	.release	= uinput_release,
-	.read		= uinput_read,
-	.write		= uinput_write,
+	.read_iter	= uinput_read_iter,
+	.write_iter	= uinput_write_iter,
 	.poll		= uinput_poll,
 	.unlocked_ioctl	= uinput_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 505c562a5daa..5d1905f078d1 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -24,6 +24,7 @@
 #include <linux/device.h>
 #include <linux/cdev.h>
 #include <linux/kernel.h>
+#include <linux/uio.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
@@ -712,17 +713,18 @@ static ssize_t mousedev_write(struct file *file, const char __user *buffer,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(mousedev_write);
 
-static ssize_t mousedev_read(struct file *file, char __user *buffer,
-			     size_t count, loff_t *ppos)
+static ssize_t mousedev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mousedev_client *client = file->private_data;
+	struct mousedev_client *client = iocb->ki_filp->private_data;
 	struct mousedev *mousedev = client->mousedev;
+	size_t count = iov_iter_count(to);
 	u8 data[sizeof(client->ps2)];
 	int retval = 0;
 
 	if (!client->ready && !client->buffer && mousedev->exist &&
-	    (file->f_flags & O_NONBLOCK))
+	    (iocb->ki_filp->f_flags & O_NONBLOCK))
 		return -EAGAIN;
 
 	retval = wait_event_interruptible(mousedev->wait,
@@ -748,7 +750,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
 
 	spin_unlock_irq(&client->packet_lock);
 
-	if (copy_to_user(buffer, data, count))
+	if (!copy_to_iter_full(data, count, to))
 		return -EFAULT;
 
 	return count;
@@ -772,8 +774,8 @@ static __poll_t mousedev_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations mousedev_fops = {
 	.owner		= THIS_MODULE,
-	.read		= mousedev_read,
-	.write		= mousedev_write,
+	.read_iter	= mousedev_read,
+	.write_iter	= mousedev_write_iter,
 	.poll		= mousedev_poll,
 	.open		= mousedev_open,
 	.release	= mousedev_release,
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 1e4770094415..3b4e72fdcd4f 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -194,6 +194,7 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
 
 	return read;
 }
+FOPS_READ_ITER_HELPER(serio_raw_read);
 
 static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 			       size_t count, loff_t *ppos)
@@ -235,6 +236,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 	mutex_unlock(&serio_raw_mutex);
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(serio_raw_write);
 
 static __poll_t serio_raw_poll(struct file *file, poll_table *wait)
 {
@@ -255,8 +257,8 @@ static const struct file_operations serio_raw_fops = {
 	.owner		= THIS_MODULE,
 	.open		= serio_raw_open,
 	.release	= serio_raw_release,
-	.read		= serio_raw_read,
-	.write		= serio_raw_write,
+	.read_iter	= serio_raw_read_iter,
+	.write_iter	= serio_raw_write_iter,
 	.poll		= serio_raw_poll,
 	.fasync		= serio_raw_fasync,
 	.llseek		= noop_llseek,
diff --git a/drivers/input/serio/userio.c b/drivers/input/serio/userio.c
index 9ab5c45c3a9f..3688579d69d2 100644
--- a/drivers/input/serio/userio.c
+++ b/drivers/input/serio/userio.c
@@ -118,10 +118,10 @@ static int userio_char_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t userio_char_read(struct file *file, char __user *user_buffer,
-				size_t count, loff_t *ppos)
+static ssize_t userio_char_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct userio_device *userio = file->private_data;
+	struct userio_device *userio = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int error;
 	size_t nonwrap_len, copylen;
 	unsigned char buf[USERIO_BUFSIZE];
@@ -153,7 +153,7 @@ static ssize_t userio_char_read(struct file *file, char __user *user_buffer,
 			break;
 
 		/* buffer was/is empty */
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		/*
@@ -170,16 +170,16 @@ static ssize_t userio_char_read(struct file *file, char __user *user_buffer,
 	}
 
 	if (copylen)
-		if (copy_to_user(user_buffer, buf, copylen))
+		if (!copy_to_iter_full(buf, copylen, to))
 			return -EFAULT;
 
 	return copylen;
 }
 
-static ssize_t userio_char_write(struct file *file, const char __user *buffer,
-				 size_t count, loff_t *ppos)
+static ssize_t userio_char_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct userio_device *userio = file->private_data;
+	struct userio_device *userio = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct userio_cmd cmd;
 	int error;
 
@@ -188,7 +188,7 @@ static ssize_t userio_char_write(struct file *file, const char __user *buffer,
 		return -EINVAL;
 	}
 
-	if (copy_from_user(&cmd, buffer, sizeof(cmd)))
+	if (!copy_from_iter_full(&cmd, sizeof(cmd), from))
 		return -EFAULT;
 
 	error = mutex_lock_interruptible(&userio->mutex);
@@ -264,8 +264,8 @@ static const struct file_operations userio_fops = {
 	.owner		= THIS_MODULE,
 	.open		= userio_char_open,
 	.release	= userio_char_release,
-	.read		= userio_char_read,
-	.write		= userio_char_write,
+	.read_iter	= userio_char_read,
+	.write_iter	= userio_char_write,
 	.poll		= userio_char_poll,
 	.llseek		= no_llseek,
 };
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 2a1db1134476..fe1b0a2c0925 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -31,6 +31,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 
 #include <asm/unaligned.h>
 
@@ -735,20 +736,20 @@ static int edt_ft5x06_debugfs_mode_set(void *data, u64 mode)
 DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops, edt_ft5x06_debugfs_mode_get,
 			edt_ft5x06_debugfs_mode_set, "%llu\n");
 
-static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
-						char __user *buf, size_t count,
-						loff_t *off)
+static ssize_t edt_ft5x06_debugfs_raw_data_read(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct edt_ft5x06_ts_data *tsdata = file->private_data;
+	struct edt_ft5x06_ts_data *tsdata = iocb->ki_filp->private_data;
 	struct i2c_client *client = tsdata->client;
 	int retries  = EDT_RAW_DATA_RETRIES;
+	size_t count = iov_iter_count(to);
 	unsigned int val;
 	int i, error;
 	size_t read = 0;
 	int colbytes;
 	u8 *rdbuf;
 
-	if (*off < 0 || *off >= tsdata->raw_bufsize)
+	if (iocb->ki_pos < 0 || iocb->ki_pos >= tsdata->raw_bufsize)
 		return 0;
 
 	mutex_lock(&tsdata->mutex);
@@ -798,13 +799,13 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
 		rdbuf += colbytes;
 	}
 
-	read = min_t(size_t, count, tsdata->raw_bufsize - *off);
-	if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) {
+	read = min_t(size_t, count, tsdata->raw_bufsize - iocb->ki_pos);
+	if (!copy_to_iter_full(tsdata->raw_buffer + iocb->ki_pos, read, to)) {
 		error = -EFAULT;
 		goto out;
 	}
 
-	*off += read;
+	iocb->ki_pos += read;
 out:
 	mutex_unlock(&tsdata->mutex);
 	return error ?: read;
@@ -812,7 +813,7 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
 
 static const struct file_operations debugfs_raw_data_fops = {
 	.open = simple_open,
-	.read = edt_ft5x06_debugfs_raw_data_read,
+	.read_iter = edt_ft5x06_debugfs_raw_data_read,
 };
 
 static void edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 122/437] drivers/pci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (120 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 121/437] drivers/input: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 123/437] fs/fuse: " Jens Axboe
                   ` (315 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/pci/pcie/aer_inject.c  |  9 +++++----
 drivers/pci/switch/switchtec.c | 33 ++++++++++++++++-----------------
 drivers/pci/vgaarb.c           | 21 +++++++++++----------
 3 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/drivers/pci/pcie/aer_inject.c b/drivers/pci/pcie/aer_inject.c
index 2dab275d252f..869abe6a82ab 100644
--- a/drivers/pci/pcie/aer_inject.c
+++ b/drivers/pci/pcie/aer_inject.c
@@ -21,6 +21,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
+#include <linux/uio.h>
 #include <linux/uaccess.h>
 #include <linux/stddef.h>
 #include <linux/device.h>
@@ -483,9 +484,9 @@ static int aer_inject(struct aer_error_inj *einj)
 	return ret;
 }
 
-static ssize_t aer_inject_write(struct file *filp, const char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t aer_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t usize = iov_iter_count(from);
 	struct aer_error_inj einj;
 	int ret;
 
@@ -496,7 +497,7 @@ static ssize_t aer_inject_write(struct file *filp, const char __user *ubuf,
 		return -EINVAL;
 
 	memset(&einj, 0, sizeof(einj));
-	if (copy_from_user(&einj, ubuf, usize))
+	if (!copy_from_iter_full(&einj, usize, from))
 		return -EFAULT;
 
 	ret = aer_inject(&einj);
@@ -504,7 +505,7 @@ static ssize_t aer_inject_write(struct file *filp, const char __user *ubuf,
 }
 
 static const struct file_operations aer_inject_fops = {
-	.write = aer_inject_write,
+	.write_iter = aer_inject_write,
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
 };
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 5a4adf6c04cf..db6f578e854c 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -15,6 +15,7 @@
 #include <linux/wait.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/nospec.h>
+#include <linux/uio.h>
 
 MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver");
 MODULE_VERSION("0.1");
@@ -503,11 +504,11 @@ static int lock_mutex_and_test_alive(struct switchtec_dev *stdev)
 	return 0;
 }
 
-static ssize_t switchtec_dev_write(struct file *filp, const char __user *data,
-				   size_t size, loff_t *off)
+static ssize_t switchtec_dev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct switchtec_user *stuser = filp->private_data;
+	struct switchtec_user *stuser = iocb->ki_filp->private_data;
 	struct switchtec_dev *stdev = stuser->stdev;
+	size_t size = iov_iter_count(from);
 	int rc;
 
 	if (size < sizeof(stuser->cmd) ||
@@ -525,7 +526,7 @@ static ssize_t switchtec_dev_write(struct file *filp, const char __user *data,
 		goto out;
 	}
 
-	rc = copy_from_user(&stuser->cmd, data, sizeof(stuser->cmd));
+	rc = !copy_from_iter_full(&stuser->cmd, sizeof(stuser->cmd), from);
 	if (rc) {
 		rc = -EFAULT;
 		goto out;
@@ -537,8 +538,7 @@ static ssize_t switchtec_dev_write(struct file *filp, const char __user *data,
 		goto out;
 	}
 
-	data += sizeof(stuser->cmd);
-	rc = copy_from_user(&stuser->data, data, size - sizeof(stuser->cmd));
+	rc = !copy_from_iter_full(&stuser->data, size - sizeof(stuser->cmd), from);
 	if (rc) {
 		rc = -EFAULT;
 		goto out;
@@ -555,11 +555,11 @@ static ssize_t switchtec_dev_write(struct file *filp, const char __user *data,
 	return size;
 }
 
-static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
-				  size_t size, loff_t *off)
+static ssize_t switchtec_dev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct switchtec_user *stuser = filp->private_data;
+	struct switchtec_user *stuser = iocb->ki_filp->private_data;
 	struct switchtec_dev *stdev = stuser->stdev;
+	size_t size = iov_iter_count(to);
 	int rc;
 
 	if (size < sizeof(stuser->cmd) ||
@@ -579,7 +579,7 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
 
 	mutex_unlock(&stdev->mrpc_mutex);
 
-	if (filp->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (!stuser->cmd_done)
 			return -EAGAIN;
 	} else {
@@ -603,16 +603,15 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
 		return -EBADE;
 	}
 
-	rc = copy_to_user(data, &stuser->return_code,
-			  sizeof(stuser->return_code));
+	rc = !copy_to_iter_full(&stuser->return_code,
+				sizeof(stuser->return_code), to);
 	if (rc) {
 		mutex_unlock(&stdev->mrpc_mutex);
 		return -EFAULT;
 	}
 
-	data += sizeof(stuser->return_code);
-	rc = copy_to_user(data, &stuser->data,
-			  size - sizeof(stuser->return_code));
+	rc = !copy_to_iter_full(&stuser->data,
+				size - sizeof(stuser->return_code), to);
 	if (rc) {
 		mutex_unlock(&stdev->mrpc_mutex);
 		return -EFAULT;
@@ -1247,8 +1246,8 @@ static const struct file_operations switchtec_fops = {
 	.owner = THIS_MODULE,
 	.open = switchtec_dev_open,
 	.release = switchtec_dev_release,
-	.write = switchtec_dev_write,
-	.read = switchtec_dev_read,
+	.write_iter = switchtec_dev_write,
+	.read_iter = switchtec_dev_read,
 	.poll = switchtec_dev_poll,
 	.unlocked_ioctl = switchtec_dev_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
index 78748e8d2dba..a5051fae9bcb 100644
--- a/drivers/pci/vgaarb.c
+++ b/drivers/pci/vgaarb.c
@@ -31,6 +31,7 @@
 #include <linux/console.h>
 #include <linux/acpi.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <linux/vgaarb.h>
 
 static void vga_arbiter_notify_clients(void);
@@ -1088,10 +1089,10 @@ static int vga_pci_str_to_vars(char *buf, int count, unsigned int *domain,
 	return 1;
 }
 
-static ssize_t vga_arb_read(struct file *file, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t vga_arb_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct vga_arb_private *priv = file->private_data;
+	struct vga_arb_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct vga_device *vgadev;
 	struct pci_dev *pdev;
 	unsigned long flags;
@@ -1141,7 +1142,7 @@ static ssize_t vga_arb_read(struct file *file, char __user *buf,
 	/* Copy that to user */
 	if (len > count)
 		len = count;
-	rc = copy_to_user(buf, lbuf, len);
+	rc = !copy_to_iter_full(lbuf, len, to);
 	kfree(lbuf);
 	if (rc)
 		return -EFAULT;
@@ -1152,10 +1153,10 @@ static ssize_t vga_arb_read(struct file *file, char __user *buf,
  * TODO: To avoid parsing inside kernel and to improve the speed we may
  * consider use ioctl here
  */
-static ssize_t vga_arb_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t vga_arb_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct vga_arb_private *priv = file->private_data;
+	struct vga_arb_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct vga_arb_user_card *uc = NULL;
 	struct pci_dev *pdev;
 
@@ -1169,7 +1170,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf,
 
 	if (count >= sizeof(kbuf))
 		return -EINVAL;
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EFAULT;
 	curr_pos = kbuf;
 	kbuf[count] = '\0';
@@ -1523,8 +1524,8 @@ static struct notifier_block pci_notifier = {
 };
 
 static const struct file_operations vga_arb_device_fops = {
-	.read = vga_arb_read,
-	.write = vga_arb_write,
+	.read_iter = vga_arb_read,
+	.write_iter = vga_arb_write,
 	.poll = vga_arb_fpoll,
 	.open = vga_arb_open,
 	.release = vga_arb_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 123/437] fs/fuse: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (121 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 122/437] drivers/pci: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 124/437] firmware: arm_scmi: " Jens Axboe
                   ` (314 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/fuse/control.c | 70 ++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 40 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 0ca1d1f418c3..e572013d345e 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -43,8 +43,7 @@ static ssize_t fuse_conn_abort_write(struct kiocb *iocb, struct iov_iter *from)
 	return iov_iter_count(from);
 }
 
-static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
-					   struct iov_iter *to)
+static ssize_t fuse_conn_waiting_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char tmp[32];
 	size_t size;
@@ -63,27 +62,27 @@ static ssize_t fuse_conn_waiting_read_iter(struct kiocb *iocb,
 	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
-static ssize_t fuse_conn_limit_read(struct file *file, char __user *buf,
-				    size_t len, loff_t *ppos, unsigned val)
+static ssize_t fuse_conn_limit_read(struct kiocb *iocb, struct iov_iter *to,
+				    unsigned val)
 {
 	char tmp[32];
 	size_t size = sprintf(tmp, "%u\n", val);
 
-	return simple_read_from_buffer(buf, len, ppos, tmp, size);
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, size, to);
 }
 
-static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
-				     size_t count, loff_t *ppos, unsigned *val,
-				     unsigned global_limit)
+static ssize_t fuse_conn_limit_write(struct kiocb *iocb, struct iov_iter *from,
+				     unsigned *val, unsigned global_limit)
 {
 	unsigned long t;
 	unsigned limit = (1 << 16) - 1;
+	size_t count = iov_iter_count(from);
 	int err;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
-	err = kstrtoul_from_user(buf, count, 0, &t);
+	err = kstrtoul_from_iter(from, count, 0, &t);
 	if (err)
 		return err;
 
@@ -98,35 +97,31 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
 	return count;
 }
 
-static ssize_t fuse_conn_max_background_read(struct file *file,
-					     char __user *buf, size_t len,
-					     loff_t *ppos)
+static ssize_t fuse_conn_max_background_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	struct fuse_conn *fc;
 	unsigned val;
 
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		return 0;
 
 	val = READ_ONCE(fc->max_background);
 	fuse_conn_put(fc);
 
-	return fuse_conn_limit_read(file, buf, len, ppos, val);
+	return fuse_conn_limit_read(iocb, to, val);
 }
-FOPS_READ_ITER_HELPER(fuse_conn_max_background_read);
 
-static ssize_t fuse_conn_max_background_write(struct file *file,
-					      const char __user *buf,
-					      size_t count, loff_t *ppos)
+static ssize_t fuse_conn_max_background_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
 	unsigned val;
 	ssize_t ret;
 
-	ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
-				    max_user_bgreq);
+	ret = fuse_conn_limit_write(iocb, from, &val, max_user_bgreq);
 	if (ret > 0) {
-		struct fuse_conn *fc = fuse_ctl_file_conn_get(file);
+		struct fuse_conn *fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 		if (fc) {
 			spin_lock(&fc->bg_lock);
 			fc->max_background = val;
@@ -140,38 +135,34 @@ static ssize_t fuse_conn_max_background_write(struct file *file,
 
 	return ret;
 }
-FOPS_WRITE_ITER_HELPER(fuse_conn_max_background_write);
 
-static ssize_t fuse_conn_congestion_threshold_read(struct file *file,
-						   char __user *buf, size_t len,
-						   loff_t *ppos)
+static ssize_t fuse_conn_congestion_threshold_read(struct kiocb *iocb,
+						   struct iov_iter *to)
 {
 	struct fuse_conn *fc;
 	unsigned val;
 
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		return 0;
 
 	val = READ_ONCE(fc->congestion_threshold);
 	fuse_conn_put(fc);
 
-	return fuse_conn_limit_read(file, buf, len, ppos, val);
+	return fuse_conn_limit_read(iocb, to, val);
 }
 
-static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
-						    const char __user *buf,
-						    size_t count, loff_t *ppos)
+static ssize_t fuse_conn_congestion_threshold_write(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
 	unsigned val;
 	struct fuse_conn *fc;
 	ssize_t ret;
 
-	ret = fuse_conn_limit_write(file, buf, count, ppos, &val,
-				    max_user_congthresh);
+	ret = fuse_conn_limit_write(iocb, from, &val, max_user_congthresh);
 	if (ret <= 0)
 		goto out;
-	fc = fuse_ctl_file_conn_get(file);
+	fc = fuse_ctl_file_conn_get(iocb->ki_filp);
 	if (!fc)
 		goto out;
 
@@ -180,7 +171,6 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
 out:
 	return ret;
 }
-FOPS_WRITE_ITER_HELPER(fuse_conn_congestion_threshold_write);
 
 static const struct file_operations fuse_ctl_abort_ops = {
 	.open = nonseekable_open,
@@ -190,21 +180,21 @@ static const struct file_operations fuse_ctl_abort_ops = {
 
 static const struct file_operations fuse_ctl_waiting_ops = {
 	.open = nonseekable_open,
-	.read_iter = fuse_conn_waiting_read_iter,
+	.read_iter = fuse_conn_waiting_read,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_max_background_ops = {
 	.open = nonseekable_open,
-	.read_iter = fuse_conn_max_background_read_iter,
-	.write_iter = fuse_conn_max_background_write_iter,
+	.read_iter = fuse_conn_max_background_read,
+	.write_iter = fuse_conn_max_background_write,
 	.llseek = no_llseek,
 };
 
 static const struct file_operations fuse_conn_congestion_threshold_ops = {
 	.open = nonseekable_open,
-	.read = fuse_conn_congestion_threshold_read,
-	.write_iter = fuse_conn_congestion_threshold_write_iter,
+	.read_iter = fuse_conn_congestion_threshold_read,
+	.write_iter = fuse_conn_congestion_threshold_write,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 124/437] firmware: arm_scmi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (122 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 123/437] fs/fuse: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 125/437] firmware: cirrus: " Jens Axboe
                   ` (313 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/arm_scmi/raw_mode.c | 94 ++++++++++++----------------
 1 file changed, 40 insertions(+), 54 deletions(-)

diff --git a/drivers/firmware/arm_scmi/raw_mode.c b/drivers/firmware/arm_scmi/raw_mode.c
index 350573518503..95915540165a 100644
--- a/drivers/firmware/arm_scmi/raw_mode.c
+++ b/drivers/firmware/arm_scmi/raw_mode.c
@@ -765,46 +765,41 @@ static int scmi_raw_message_receive(struct scmi_raw_mode_info *raw,
 
 /* SCMI Raw debugfs helpers */
 
-static ssize_t scmi_dbg_raw_mode_common_read(struct file *filp,
-					     char __user *buf,
-					     size_t count, loff_t *ppos,
+static ssize_t scmi_dbg_raw_mode_common_read(struct kiocb *iocb,
+					     struct iov_iter *to,
 					     unsigned int idx)
 {
-	ssize_t cnt;
-	struct scmi_dbg_raw_data *rd = filp->private_data;
+	struct scmi_dbg_raw_data *rd = iocb->ki_filp->private_data;
 
 	if (!rd->rx_size) {
 		int ret;
 
 		ret = scmi_raw_message_receive(rd->raw, rd->rx.buf, rd->rx.len,
 					       &rd->rx_size, idx, rd->chan_id,
-					       filp->f_flags & O_NONBLOCK);
+					       iocb->ki_filp->f_flags & O_NONBLOCK);
 		if (ret) {
 			rd->rx_size = 0;
 			return ret;
 		}
 
 		/* Reset any previous filepos change, including writes */
-		*ppos = 0;
-	} else if (*ppos == rd->rx_size) {
+		iocb->ki_pos = 0;
+	} else if (iocb->ki_pos == rd->rx_size) {
 		/* Return EOF once all the message has been read-out */
 		rd->rx_size = 0;
 		return 0;
 	}
 
-	cnt = simple_read_from_buffer(buf, count, ppos,
-				      rd->rx.buf, rd->rx_size);
-
-	return cnt;
+	return simple_copy_to_iter(rd->rx.buf, &iocb->ki_pos, rd->rx_size, to);
 }
 
-static ssize_t scmi_dbg_raw_mode_common_write(struct file *filp,
-					      const char __user *buf,
-					      size_t count, loff_t *ppos,
+static ssize_t scmi_dbg_raw_mode_common_write(struct kiocb *iocb,
+					      struct iov_iter *from,
 					      bool async)
 {
 	int ret;
-	struct scmi_dbg_raw_data *rd = filp->private_data;
+	struct scmi_dbg_raw_data *rd = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (count > rd->tx.len - rd->tx_size)
 		return -ENOSPC;
@@ -820,8 +815,8 @@ static ssize_t scmi_dbg_raw_mode_common_write(struct file *filp,
 	if (rd->tx_size < rd->tx_req_size) {
 		ssize_t cnt;
 
-		cnt = simple_write_to_buffer(rd->tx.buf, rd->tx.len, ppos,
-					     buf, count);
+		cnt = simple_copy_from_iter(rd->tx.buf, &iocb->ki_pos,
+					     rd->tx.len, from);
 		if (cnt < 0)
 			return cnt;
 
@@ -835,7 +830,7 @@ static ssize_t scmi_dbg_raw_mode_common_write(struct file *filp,
 
 	/* Reset ppos for next message ... */
 	rd->tx_size = 0;
-	*ppos = 0;
+	iocb->ki_pos = 0;
 
 	return ret ?: count;
 }
@@ -863,19 +858,16 @@ static __poll_t scmi_test_dbg_raw_common_poll(struct file *filp,
 	return mask;
 }
 
-static ssize_t scmi_dbg_raw_mode_message_read(struct file *filp,
-					      char __user *buf,
-					      size_t count, loff_t *ppos)
+static ssize_t scmi_dbg_raw_mode_message_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	return scmi_dbg_raw_mode_common_read(filp, buf, count, ppos,
-					     SCMI_RAW_REPLY_QUEUE);
+	return scmi_dbg_raw_mode_common_read(iocb, to, SCMI_RAW_REPLY_QUEUE);
 }
 
-static ssize_t scmi_dbg_raw_mode_message_write(struct file *filp,
-					       const char __user *buf,
-					       size_t count, loff_t *ppos)
+static ssize_t scmi_dbg_raw_mode_message_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	return scmi_dbg_raw_mode_common_write(filp, buf, count, ppos, false);
+	return scmi_dbg_raw_mode_common_write(iocb, from, false);
 }
 
 static __poll_t scmi_dbg_raw_mode_message_poll(struct file *filp,
@@ -935,55 +927,51 @@ static int scmi_dbg_raw_mode_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t scmi_dbg_raw_mode_reset_write(struct file *filp,
-					     const char __user *buf,
-					     size_t count, loff_t *ppos)
+static ssize_t scmi_dbg_raw_mode_reset_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct scmi_dbg_raw_data *rd = filp->private_data;
+	struct scmi_dbg_raw_data *rd = iocb->ki_filp->private_data;
 
 	scmi_xfer_raw_reset(rd->raw);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations scmi_dbg_raw_mode_reset_fops = {
 	.open = scmi_dbg_raw_mode_open,
 	.release = scmi_dbg_raw_mode_release,
-	.write = scmi_dbg_raw_mode_reset_write,
+	.write_iter = scmi_dbg_raw_mode_reset_write,
 	.owner = THIS_MODULE,
 };
 
 static const struct file_operations scmi_dbg_raw_mode_message_fops = {
 	.open = scmi_dbg_raw_mode_open,
 	.release = scmi_dbg_raw_mode_release,
-	.read = scmi_dbg_raw_mode_message_read,
-	.write = scmi_dbg_raw_mode_message_write,
+	.read_iter = scmi_dbg_raw_mode_message_read,
+	.write_iter = scmi_dbg_raw_mode_message_write,
 	.poll = scmi_dbg_raw_mode_message_poll,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t scmi_dbg_raw_mode_message_async_write(struct file *filp,
-						     const char __user *buf,
-						     size_t count, loff_t *ppos)
+static ssize_t scmi_dbg_raw_mode_message_async_write(struct kiocb *iocb,
+						     struct iov_iter *from)
 {
-	return scmi_dbg_raw_mode_common_write(filp, buf, count, ppos, true);
+	return scmi_dbg_raw_mode_common_write(iocb, from, true);
 }
 
 static const struct file_operations scmi_dbg_raw_mode_message_async_fops = {
 	.open = scmi_dbg_raw_mode_open,
 	.release = scmi_dbg_raw_mode_release,
-	.read = scmi_dbg_raw_mode_message_read,
-	.write = scmi_dbg_raw_mode_message_async_write,
+	.read_iter = scmi_dbg_raw_mode_message_read,
+	.write_iter = scmi_dbg_raw_mode_message_async_write,
 	.poll = scmi_dbg_raw_mode_message_poll,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t scmi_test_dbg_raw_mode_notif_read(struct file *filp,
-						 char __user *buf,
-						 size_t count, loff_t *ppos)
+static ssize_t scmi_test_dbg_raw_mode_notif_read(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
-	return scmi_dbg_raw_mode_common_read(filp, buf, count, ppos,
-					     SCMI_RAW_NOTIF_QUEUE);
+	return scmi_dbg_raw_mode_common_read(iocb, to, SCMI_RAW_NOTIF_QUEUE);
 }
 
 static __poll_t
@@ -996,17 +984,15 @@ scmi_test_dbg_raw_mode_notif_poll(struct file *filp,
 static const struct file_operations scmi_dbg_raw_mode_notification_fops = {
 	.open = scmi_dbg_raw_mode_open,
 	.release = scmi_dbg_raw_mode_release,
-	.read = scmi_test_dbg_raw_mode_notif_read,
+	.read_iter = scmi_test_dbg_raw_mode_notif_read,
 	.poll = scmi_test_dbg_raw_mode_notif_poll,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t scmi_test_dbg_raw_mode_errors_read(struct file *filp,
-						  char __user *buf,
-						  size_t count, loff_t *ppos)
+static ssize_t scmi_test_dbg_raw_mode_errors_read(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	return scmi_dbg_raw_mode_common_read(filp, buf, count, ppos,
-					     SCMI_RAW_ERRS_QUEUE);
+	return scmi_dbg_raw_mode_common_read(iocb, to, SCMI_RAW_ERRS_QUEUE);
 }
 
 static __poll_t
@@ -1019,7 +1005,7 @@ scmi_test_dbg_raw_mode_errors_poll(struct file *filp,
 static const struct file_operations scmi_dbg_raw_mode_errors_fops = {
 	.open = scmi_dbg_raw_mode_open,
 	.release = scmi_dbg_raw_mode_release,
-	.read = scmi_test_dbg_raw_mode_errors_read,
+	.read_iter = scmi_test_dbg_raw_mode_errors_read,
 	.poll = scmi_test_dbg_raw_mode_errors_poll,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 125/437] firmware: cirrus: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (123 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 124/437] firmware: arm_scmi: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 126/437] firmware: efi: " Jens Axboe
                   ` (312 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/cirrus/cs_dsp.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index 9f3d665cfdcf..80a2cba021d1 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -398,11 +398,9 @@ static void cs_dsp_debugfs_clear(struct cs_dsp *dsp)
 	dsp->bin_file_name = NULL;
 }
 
-static ssize_t cs_dsp_debugfs_wmfw_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t cs_dsp_debugfs_wmfw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cs_dsp *dsp = file->private_data;
+	struct cs_dsp *dsp = iocb->ki_filp->private_data;
 	ssize_t ret;
 
 	mutex_lock(&dsp->pwr_lock);
@@ -410,19 +408,16 @@ static ssize_t cs_dsp_debugfs_wmfw_read(struct file *file,
 	if (!dsp->wmfw_file_name || !dsp->booted)
 		ret = 0;
 	else
-		ret = simple_read_from_buffer(user_buf, count, ppos,
-					      dsp->wmfw_file_name,
-					      strlen(dsp->wmfw_file_name));
+		ret = simple_copy_to_iter(dsp->wmfw_file_name, &iocb->ki_pos,
+					      strlen(dsp->wmfw_file_name), to);
 
 	mutex_unlock(&dsp->pwr_lock);
 	return ret;
 }
 
-static ssize_t cs_dsp_debugfs_bin_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t cs_dsp_debugfs_bin_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cs_dsp *dsp = file->private_data;
+	struct cs_dsp *dsp = iocb->ki_filp->private_data;
 	ssize_t ret;
 
 	mutex_lock(&dsp->pwr_lock);
@@ -430,9 +425,8 @@ static ssize_t cs_dsp_debugfs_bin_read(struct file *file,
 	if (!dsp->bin_file_name || !dsp->booted)
 		ret = 0;
 	else
-		ret = simple_read_from_buffer(user_buf, count, ppos,
-					      dsp->bin_file_name,
-					      strlen(dsp->bin_file_name));
+		ret = simple_copy_to_iter(dsp->bin_file_name, &iocb->ki_pos,
+					      strlen(dsp->bin_file_name), to);
 
 	mutex_unlock(&dsp->pwr_lock);
 	return ret;
@@ -446,14 +440,14 @@ static const struct {
 		.name = "wmfw_file_name",
 		.fops = {
 			.open = simple_open,
-			.read = cs_dsp_debugfs_wmfw_read,
+			.read_iter = cs_dsp_debugfs_wmfw_read,
 		},
 	},
 	{
 		.name = "bin_file_name",
 		.fops = {
 			.open = simple_open,
-			.read = cs_dsp_debugfs_bin_read,
+			.read_iter = cs_dsp_debugfs_bin_read,
 		},
 	},
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 126/437] firmware: efi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (124 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 125/437] firmware: cirrus: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 127/437] firmware: psci: " Jens Axboe
                   ` (311 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/efi/capsule-loader.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index 97bafb5f7038..9b1d143a64f6 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -149,10 +149,8 @@ static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info)
 /**
  * efi_capsule_write - store the capsule binary and pass it to
  *		       efi_capsule_update() API
- * @file: file pointer
- * @buff: buffer pointer
- * @count: number of bytes in @buff
- * @offp: not used
+ * @iocb: metadata for IO
+ * @from: buffer pointer
  *
  *	Expectation:
  *	- A user space tool should start at the beginning of capsule binary and
@@ -165,11 +163,11 @@ static ssize_t efi_capsule_submit_update(struct capsule_info *cap_info)
  *	- An EFI capsule header must be located at the beginning of capsule
  *	  binary file and passed in as first block data of write operation.
  **/
-static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
-				 size_t count, loff_t *offp)
+static ssize_t efi_capsule_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
-	struct capsule_info *cap_info = file->private_data;
+	struct capsule_info *cap_info = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct page *page;
 	void *kbuff = NULL;
 	size_t write_byte;
@@ -202,7 +200,7 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
 
 	/* Copy capsule binary data from user space to kernel space buffer */
 	write_byte = min_t(size_t, count, cap_info->page_bytes_remain);
-	if (copy_from_user(kbuff, buff, write_byte)) {
+	if (!copy_from_iter_full(kbuff, write_byte, from)) {
 		ret = -EFAULT;
 		goto fail_unmap;
 	}
@@ -307,7 +305,7 @@ static int efi_capsule_open(struct inode *inode, struct file *file)
 static const struct file_operations efi_capsule_fops = {
 	.owner = THIS_MODULE,
 	.open = efi_capsule_open,
-	.write = efi_capsule_write,
+	.write_iter = efi_capsule_write,
 	.release = efi_capsule_release,
 	.llseek = no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 127/437] firmware: psci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (125 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 126/437] firmware: efi: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 128/437] firmware: turris-mox-rwtm: " Jens Axboe
                   ` (310 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/psci/psci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index d9629ff87861..06a9aa74c1a5 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -440,7 +440,7 @@ static const struct file_operations psci_debugfs_ops = {
 	.owner = THIS_MODULE,
 	.open = psci_debugfs_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 128/437] firmware: turris-mox-rwtm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (126 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 127/437] firmware: psci: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 129/437] firmware: tegra: " Jens Axboe
                   ` (309 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/turris-mox-rwtm.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 31d962cdd6eb..c7733f4b9bd4 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -330,14 +330,14 @@ static int rwtm_debug_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t do_sign_read(struct file *file, char __user *buf, size_t len,
-			    loff_t *ppos)
+static ssize_t do_sign_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mox_rwtm *rwtm = file->private_data;
+	struct mox_rwtm *rwtm = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 
 	/* only allow one read, of 136 bytes, from position 0 */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (len < 136)
@@ -347,18 +347,18 @@ static ssize_t do_sign_read(struct file *file, char __user *buf, size_t len,
 		return -ENODATA;
 
 	/* 2 arrays of 17 32-bit words are 136 bytes */
-	ret = simple_read_from_buffer(buf, len, ppos, rwtm->last_sig, 136);
+	ret = simple_copy_to_iter(rwtm->last_sig, &iocb->ki_pos, 136, to);
 	rwtm->last_sig_done = 0;
 
 	return ret;
 }
 
-static ssize_t do_sign_write(struct file *file, const char __user *buf,
-			     size_t len, loff_t *ppos)
+static ssize_t do_sign_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mox_rwtm *rwtm = file->private_data;
+	struct mox_rwtm *rwtm = iocb->ki_filp->private_data;
 	struct armada_37xx_rwtm_rx_msg *reply = &rwtm->reply;
 	struct armada_37xx_rwtm_tx_msg msg;
+	size_t len = iov_iter_count(from);
 	loff_t dummy = 0;
 	ssize_t ret;
 
@@ -385,7 +385,7 @@ static ssize_t do_sign_write(struct file *file, const char __user *buf,
 	 *      stored by the rWTM firmware.
 	 */
 	memset(rwtm->buf, 0, 4);
-	ret = simple_write_to_buffer(rwtm->buf + 4, 64, &dummy, buf, len);
+	ret = simple_copy_from_iter(rwtm->buf + 4, &dummy, 64, from);
 	if (ret < 0)
 		goto unlock_mutex;
 	be32_to_cpu_array(rwtm->buf, rwtm->buf, 17);
@@ -426,8 +426,8 @@ static ssize_t do_sign_write(struct file *file, const char __user *buf,
 static const struct file_operations do_sign_fops = {
 	.owner	= THIS_MODULE,
 	.open	= rwtm_debug_open,
-	.read	= do_sign_read,
-	.write	= do_sign_write,
+	.read_iter	= do_sign_read,
+	.write_iter	= do_sign_write,
 	.llseek	= no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 129/437] firmware: tegra: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (127 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 128/437] firmware: turris-mox-rwtm: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 130/437] drivers/i2c: " Jens Axboe
                   ` (308 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/tegra/bpmp-debugfs.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 4221fed70ad4..6ef756a2d638 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -363,21 +363,21 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
 	return err;
 }
 
-static ssize_t bpmp_debug_store(struct file *file, const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t bpmp_debug_store(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct tegra_bpmp *bpmp = inode->i_private;
+	size_t count = iov_iter_count(from);
 	char *databuf = NULL;
 	char fnamebuf[256];
 	const char *filename;
 	ssize_t err;
 
-	filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
+	filename = get_filename(bpmp, iocb->ki_filp, fnamebuf, sizeof(fnamebuf));
 	if (!filename)
 		return -ENOENT;
 
-	databuf = memdup_user(buf, count);
+	databuf = iterdup(from);
 	if (IS_ERR(databuf))
 		return PTR_ERR(databuf);
 
@@ -394,9 +394,9 @@ static int bpmp_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations bpmp_debug_fops = {
 	.open		= bpmp_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
-	.write		= bpmp_debug_store,
+	.write_iter	= bpmp_debug_store,
 	.release	= single_release,
 };
 
@@ -630,11 +630,11 @@ static int debugfs_open(struct inode *inode, struct file *file)
 	return single_open_size(file, debugfs_show, file, SZ_128K);
 }
 
-static ssize_t debugfs_store(struct file *file, const char __user *buf,
-		size_t count, loff_t *f_pos)
+static ssize_t debugfs_store(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct tegra_bpmp *bpmp = inode->i_private;
+	size_t count = iov_iter_count(from);
 	const size_t datasize = count;
 	const size_t namesize = SZ_256;
 	void *datavirt, *namevirt;
@@ -644,7 +644,7 @@ static ssize_t debugfs_store(struct file *file, const char __user *buf,
 	size_t len;
 	int err;
 
-	filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
+	filename = get_filename(bpmp, iocb->ki_filp, fnamebuf, sizeof(fnamebuf));
 	if (!filename)
 		return -ENOENT;
 
@@ -681,9 +681,9 @@ static ssize_t debugfs_store(struct file *file, const char __user *buf,
 
 static const struct file_operations debugfs_fops = {
 	.open		= debugfs_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
-	.write		= debugfs_store,
+	.write_iter	= debugfs_store,
 	.release	= single_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 130/437] drivers/i2c: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (128 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 129/437] firmware: tegra: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 131/437] drivers/opp: " Jens Axboe
                   ` (307 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/i2c/i2c-dev.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 8b7e599f1674..4997e70499d5 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -131,14 +131,13 @@ ATTRIBUTE_GROUPS(i2c);
  * needed by those system calls and by this SMBus interface.
  */
 
-static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
-		loff_t *offset)
+static ssize_t i2cdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct i2c_client *client = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *tmp;
 	int ret;
 
-	struct i2c_client *client = file->private_data;
-
 	if (count > 8192)
 		count = 8192;
 
@@ -146,31 +145,31 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
 	if (tmp == NULL)
 		return -ENOMEM;
 
-	pr_debug("i2c-%d reading %zu bytes.\n", iminor(file_inode(file)), count);
+	pr_debug("i2c-%d reading %zu bytes.\n", iminor(file_inode(iocb->ki_filp)), count);
 
 	ret = i2c_master_recv(client, tmp, count);
 	if (ret >= 0)
-		if (copy_to_user(buf, tmp, ret))
+		if (!copy_to_iter_full(tmp, ret, to))
 			ret = -EFAULT;
 	kfree(tmp);
 	return ret;
 }
 
-static ssize_t i2cdev_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *offset)
+static ssize_t i2cdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	char *tmp;
-	struct i2c_client *client = file->private_data;
+	struct i2c_client *client = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (count > 8192)
 		count = 8192;
 
-	tmp = memdup_user(buf, count);
+	tmp = iterdup(from, count);
 	if (IS_ERR(tmp))
 		return PTR_ERR(tmp);
 
-	pr_debug("i2c-%d writing %zu bytes.\n", iminor(file_inode(file)), count);
+	pr_debug("i2c-%d writing %zu bytes.\n", iminor(file_inode(iocb->ki_filp)), count);
 
 	ret = i2c_master_send(client, tmp, count);
 	kfree(tmp);
@@ -626,8 +625,8 @@ static int i2cdev_release(struct inode *inode, struct file *file)
 static const struct file_operations i2cdev_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= i2cdev_read,
-	.write		= i2cdev_write,
+	.read_iter	= i2cdev_read,
+	.write_iter	= i2cdev_write,
 	.unlocked_ioctl	= i2cdev_ioctl,
 	.compat_ioctl	= compat_i2cdev_ioctl,
 	.open		= i2cdev_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 131/437] drivers/opp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (129 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 130/437] drivers/i2c: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 132/437] drivers/base: " Jens Axboe
                   ` (306 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/opp/debugfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index 105de7c3274a..a755dacb2c61 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -33,10 +33,9 @@ void opp_debug_remove_one(struct dev_pm_opp *opp)
 	debugfs_remove_recursive(opp->dentry);
 }
 
-static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t bw_name_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct icc_path *path = fp->private_data;
+	struct icc_path *path = iocb->ki_filp->private_data;
 	const char *name = icc_get_name(path);
 	char buf[64];
 	int i = 0;
@@ -44,12 +43,12 @@ static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
 	if (name)
 		i = scnprintf(buf, sizeof(buf), "%.62s\n", name);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, i);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, i, to);
 }
 
 static const struct file_operations bw_name_fops = {
 	.open = simple_open,
-	.read = bw_name_read,
+	.read_iter = bw_name_read,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 132/437] drivers/base: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (130 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 131/437] drivers/opp: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 133/437] drivers/bus: " Jens Axboe
                   ` (305 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/base/power/wakeup.c          |   2 +-
 drivers/base/regmap/regmap-debugfs.c | 119 ++++++++++++---------------
 2 files changed, 52 insertions(+), 69 deletions(-)

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index a917219feea6..b3ae10683a95 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -1168,7 +1168,7 @@ static int wakeup_sources_stats_open(struct inode *inode, struct file *file)
 static const struct file_operations wakeup_sources_stats_fops = {
 	.owner = THIS_MODULE,
 	.open = wakeup_sources_stats_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 571b5c00a28e..ab0458ec787c 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -10,6 +10,7 @@
 #include <linux/mutex.h>
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <linux/device.h>
 #include <linux/list.h>
 
@@ -31,11 +32,9 @@ static size_t regmap_calc_reg_len(int max_val)
 	return snprintf(NULL, 0, "%x", max_val);
 }
 
-static ssize_t regmap_name_read_file(struct file *file,
-				     char __user *user_buf, size_t count,
-				     loff_t *ppos)
+static ssize_t regmap_name_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct regmap *map = file->private_data;
+	struct regmap *map = iocb->ki_filp->private_data;
 	const char *name = "nodev";
 	int ret;
 	char *buf;
@@ -53,14 +52,14 @@ static ssize_t regmap_name_read_file(struct file *file,
 		return ret;
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations regmap_name_fops = {
 	.open = simple_open,
-	.read = regmap_name_read_file,
+	.read_iter = regmap_name_read_file,
 	.llseek = default_llseek,
 };
 
@@ -213,17 +212,18 @@ static int regmap_next_readable_reg(struct regmap *map, int reg)
 }
 
 static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
-				   unsigned int to, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+				   unsigned int to, struct kiocb *iocb,
+				   struct iov_iter *to_iov)
 {
 	size_t buf_pos = 0;
-	loff_t p = *ppos;
+	loff_t p = iocb->ki_pos;
 	ssize_t ret;
 	int i;
 	char *buf;
 	unsigned int val, start_reg;
+	size_t count = iov_iter_count(to_iov);
 
-	if (*ppos < 0 || !count)
+	if (iocb->ki_pos < 0 || !count)
 		return -EINVAL;
 
 	if (count > (PAGE_SIZE << MAX_PAGE_ORDER))
@@ -236,13 +236,13 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 	regmap_calc_tot_len(map, buf, count);
 
 	/* Work out which register we're starting at */
-	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
+	start_reg = regmap_debugfs_get_dump_start(map, from, iocb->ki_pos, &p);
 
 	for (i = start_reg; i >= 0 && i <= to;
 	     i = regmap_next_readable_reg(map, i)) {
 
 		/* If we're in the region the user is trying to read */
-		if (p >= *ppos) {
+		if (p >= iocb->ki_pos) {
 			/* ...but not beyond it */
 			if (buf_pos + map->debugfs_tot_len > count)
 				break;
@@ -269,25 +269,22 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 
 	ret = buf_pos;
 
-	if (copy_to_user(user_buf, buf, buf_pos)) {
+	if (!copy_to_iter_full(buf, buf_pos, to_iov)) {
 		ret = -EFAULT;
 		goto out;
 	}
 
-	*ppos += buf_pos;
-
+	iocb->ki_pos += buf_pos;
 out:
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t regmap_map_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct regmap *map = file->private_data;
+	struct regmap *map = iocb->ki_filp->private_data;
 
-	return regmap_read_debugfs(map, 0, map->max_register, user_buf,
-				   count, ppos);
+	return regmap_read_debugfs(map, 0, map->max_register, iocb, to);
 }
 
 #undef REGMAP_ALLOW_WRITE_DEBUGFS
@@ -298,19 +295,18 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
  * for this feature, people who want to use this will need to modify
  * the source code directly.
  */
-static ssize_t regmap_map_write_file(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t regmap_map_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[32];
 	size_t buf_size;
 	char *start = buf;
 	unsigned long reg, value;
-	struct regmap *map = file->private_data;
+	struct regmap *map = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	buf_size = min(count, (sizeof(buf)-1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	buf[buf_size] = 0;
 
@@ -336,33 +332,32 @@ static ssize_t regmap_map_write_file(struct file *file,
 
 static const struct file_operations regmap_map_fops = {
 	.open = simple_open,
-	.read = regmap_map_read_file,
-	.write = regmap_map_write_file,
+	.read_iter = regmap_map_read_file,
+	.write_iter = regmap_map_write_file,
 	.llseek = default_llseek,
 };
 
-static ssize_t regmap_range_read_file(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t regmap_range_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct regmap_range_node *range = file->private_data;
+	struct regmap_range_node *range = iocb->ki_filp->private_data;
 	struct regmap *map = range->map;
 
 	return regmap_read_debugfs(map, range->range_min, range->range_max,
-				   user_buf, count, ppos);
+				   iocb, to);
 }
 
 static const struct file_operations regmap_range_fops = {
 	.open = simple_open,
-	.read = regmap_range_read_file,
+	.read_iter = regmap_range_read_file,
 	.llseek = default_llseek,
 };
 
-static ssize_t regmap_reg_ranges_read_file(struct file *file,
-					   char __user *user_buf, size_t count,
-					   loff_t *ppos)
+static ssize_t regmap_reg_ranges_read_file(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct regmap *map = file->private_data;
+	struct regmap *map = iocb->ki_filp->private_data;
 	struct regmap_debugfs_off_cache *c;
+	size_t count = iov_iter_count(to);
 	loff_t p = 0;
 	size_t buf_pos = 0;
 	char *buf;
@@ -370,7 +365,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
 	int ret;
 	unsigned int entry_len;
 
-	if (*ppos < 0 || !count)
+	if (iocb->ki_pos < 0 || !count)
 		return -EINVAL;
 
 	if (count > (PAGE_SIZE << MAX_PAGE_ORDER))
@@ -392,7 +387,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
 	 * about the file position information that is contained
 	 * in the cache, just about the actual register blocks */
 	regmap_calc_tot_len(map, buf, count);
-	regmap_debugfs_get_dump_start(map, 0, *ppos, &p);
+	regmap_debugfs_get_dump_start(map, 0, iocb->ki_pos, &p);
 
 	/* Reset file pointer as the fixed-format of the `registers'
 	 * file is not compatible with the `range' file */
@@ -401,7 +396,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
 	list_for_each_entry(c, &map->debugfs_off_cache, list) {
 		entry_len = snprintf(entry, PAGE_SIZE, "%x-%x\n",
 				     c->base_reg, c->max_reg);
-		if (p >= *ppos) {
+		if (p >= iocb->ki_pos) {
 			if (buf_pos + entry_len > count)
 				break;
 			memcpy(buf + buf_pos, entry, entry_len);
@@ -414,12 +409,12 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
 	kfree(entry);
 	ret = buf_pos;
 
-	if (copy_to_user(user_buf, buf, buf_pos)) {
+	if (!copy_to_iter_full(buf, buf_pos, to)) {
 		ret = -EFAULT;
 		goto out_buf;
 	}
 
-	*ppos += buf_pos;
+	iocb->ki_pos += buf_pos;
 out_buf:
 	kfree(buf);
 	return ret;
@@ -427,7 +422,7 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
 
 static const struct file_operations regmap_reg_ranges_fops = {
 	.open = simple_open,
-	.read = regmap_reg_ranges_read_file,
+	.read_iter = regmap_reg_ranges_read_file,
 	.llseek = default_llseek,
 };
 
@@ -456,21 +451,21 @@ static int regmap_access_show(struct seq_file *s, void *ignored)
 
 DEFINE_SHOW_ATTRIBUTE(regmap_access);
 
-static ssize_t __regmap_cache_only_write_file(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t regmap_cache_only_write_file(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct regmap *map = container_of(file->private_data,
+	struct regmap *map = container_of(iocb->ki_filp->private_data,
 					  struct regmap, cache_only);
+	size_t count = iov_iter_count(from);
 	bool new_val, require_sync = false;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &new_val);
+	err = kstrtobool_from_iter(from, count, &new_val);
 	/* Ignore malforned data like debugfs_write_file_bool() */
 	if (err)
 		return count;
 
-	err = debugfs_file_get(file->f_path.dentry);
+	err = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 	if (err)
 		return err;
 
@@ -486,7 +481,7 @@ static ssize_t __regmap_cache_only_write_file(struct file *file,
 	map->cache_only = new_val;
 
 	map->unlock(map->lock_arg);
-	debugfs_file_put(file->f_path.dentry);
+	debugfs_file_put(iocb->ki_filp->f_path.dentry);
 
 	if (require_sync) {
 		err = regcache_sync(map);
@@ -497,33 +492,27 @@ static ssize_t __regmap_cache_only_write_file(struct file *file,
 	return count;
 }
 
-static ssize_t regmap_cache_only_write_file(struct kiocb *iocb,
-					    struct iov_iter *from)
-{
-	return vfs_write_iter(iocb, from, __regmap_cache_only_write_file);
-}
-
 static const struct file_operations regmap_cache_only_fops = {
 	.open = simple_open,
 	.read_iter = debugfs_read_file_bool,
 	.write_iter = regmap_cache_only_write_file,
 };
 
-static ssize_t __regmap_cache_bypass_write_file(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t regmap_cache_bypass_write_file(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct regmap *map = container_of(file->private_data,
+	struct regmap *map = container_of(iocb->ki_filp->private_data,
 					  struct regmap, cache_bypass);
+	size_t count = iov_iter_count(from);
 	bool new_val;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &new_val);
+	err = kstrtobool_from_iter(from, count, &new_val);
 	/* Ignore malforned data like debugfs_write_file_bool() */
 	if (err)
 		return count;
 
-	err = debugfs_file_get(file->f_path.dentry);
+	err = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 	if (err)
 		return err;
 
@@ -538,17 +527,11 @@ static ssize_t __regmap_cache_bypass_write_file(struct file *file,
 	map->cache_bypass = new_val;
 
 	map->unlock(map->lock_arg);
-	debugfs_file_put(file->f_path.dentry);
+	debugfs_file_put(iocb->ki_filp->f_path.dentry);
 
 	return count;
 }
 
-static ssize_t regmap_cache_bypass_write_file(struct kiocb *iocb,
-					      struct iov_iter *from)
-{
-	return vfs_write_iter(iocb, from, __regmap_cache_bypass_write_file);
-}
-
 static const struct file_operations regmap_cache_bypass_fops = {
 	.open = simple_open,
 	.read_iter = debugfs_read_file_bool,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 133/437] drivers/bus: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (131 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 132/437] drivers/base: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 134/437] drivers/regulator: " Jens Axboe
                   ` (304 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/bus/mhi/host/debugfs.c | 38 +++++++++++++++++-----------------
 drivers/bus/moxtet.c           | 30 +++++++++++++--------------
 2 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/drivers/bus/mhi/host/debugfs.c b/drivers/bus/mhi/host/debugfs.c
index cfec7811dfbb..14d7a1132fca 100644
--- a/drivers/bus/mhi/host/debugfs.c
+++ b/drivers/bus/mhi/host/debugfs.c
@@ -245,17 +245,17 @@ static int mhi_debugfs_device_wake_show(struct seq_file *m, void *d)
 	return 0;
 }
 
-static ssize_t mhi_debugfs_device_wake_write(struct file *file,
-					     const char __user *ubuf,
-					     size_t count, loff_t *ppos)
+static ssize_t mhi_debugfs_device_wake_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct seq_file	*m = file->private_data;
+	struct seq_file	*m = iocb->ki_filp->private_data;
 	struct mhi_controller *mhi_cntrl = m->private;
 	struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev;
+	size_t count = iov_iter_count(from);
 	char buf[16];
 	int ret = -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "get", 3)) {
@@ -277,15 +277,15 @@ static int mhi_debugfs_timeout_ms_show(struct seq_file *m, void *d)
 	return 0;
 }
 
-static ssize_t mhi_debugfs_timeout_ms_write(struct file *file,
-					    const char __user *ubuf,
-					    size_t count, loff_t *ppos)
+static ssize_t mhi_debugfs_timeout_ms_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file	*m = file->private_data;
+	struct seq_file	*m = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mhi_controller *mhi_cntrl = m->private;
 	u32 timeout_ms;
 
-	if (kstrtou32_from_user(ubuf, count, 0, &timeout_ms))
+	if (kstrtou32_from_iter(from, count, 0, &timeout_ms))
 		return -EINVAL;
 
 	mhi_cntrl->timeout_ms = timeout_ms;
@@ -331,45 +331,45 @@ static int mhi_debugfs_timeout_ms_open(struct inode *inode, struct file *fp)
 static const struct file_operations debugfs_states_fops = {
 	.open = mhi_debugfs_states_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_events_fops = {
 	.open = mhi_debugfs_events_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_channels_fops = {
 	.open = mhi_debugfs_channels_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_devices_fops = {
 	.open = mhi_debugfs_devices_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_regdump_fops = {
 	.open = mhi_debugfs_regdump_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_device_wake_fops = {
 	.open = mhi_debugfs_device_wake_open,
-	.write = mhi_debugfs_device_wake_write,
+	.write_iter = mhi_debugfs_device_wake_write,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static const struct file_operations debugfs_timeout_ms_fops = {
 	.open = mhi_debugfs_timeout_ms_open,
-	.write = mhi_debugfs_timeout_ms_write,
+	.write_iter = mhi_debugfs_timeout_ms_write,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 static struct dentry *mhi_debugfs_root;
diff --git a/drivers/bus/moxtet.c b/drivers/bus/moxtet.c
index 641c1a6adc8a..a6635cfc8490 100644
--- a/drivers/bus/moxtet.c
+++ b/drivers/bus/moxtet.c
@@ -15,6 +15,7 @@
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/spi/spi.h>
+#include <linux/uio.h>
 
 /*
  * @name:	module name for sysfs
@@ -460,10 +461,9 @@ static int moxtet_debug_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t input_read(struct file *file, char __user *buf, size_t len,
-			  loff_t *ppos)
+static ssize_t input_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct moxtet *moxtet = file->private_data;
+	struct moxtet *moxtet = iocb->ki_filp->private_data;
 	u8 bin[TURRIS_MOX_MAX_MODULES];
 	u8 hex[sizeof(bin) * 2 + 1];
 	int ret, n;
@@ -477,20 +477,19 @@ static ssize_t input_read(struct file *file, char __user *buf, size_t len,
 
 	hex[2*n] = '\n';
 
-	return simple_read_from_buffer(buf, len, ppos, hex, 2*n + 1);
+	return simple_copy_to_iter(hex, &iocb->ki_pos, 2*n + 1, to);
 }
 
 static const struct file_operations input_fops = {
 	.owner	= THIS_MODULE,
 	.open	= moxtet_debug_open,
-	.read	= input_read,
+	.read_iter	= input_read,
 	.llseek	= no_llseek,
 };
 
-static ssize_t output_read(struct file *file, char __user *buf, size_t len,
-			   loff_t *ppos)
+static ssize_t output_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct moxtet *moxtet = file->private_data;
+	struct moxtet *moxtet = iocb->ki_filp->private_data;
 	u8 hex[TURRIS_MOX_MAX_MODULES * 2 + 1];
 	u8 *p = hex;
 	int i;
@@ -504,23 +503,22 @@ static ssize_t output_read(struct file *file, char __user *buf, size_t len,
 
 	*p++ = '\n';
 
-	return simple_read_from_buffer(buf, len, ppos, hex, p - hex);
+	return simple_copy_to_iter(hex, &iocb->ki_pos, p - hex, to);
 }
 
-static ssize_t output_write(struct file *file, const char __user *buf,
-			    size_t len, loff_t *ppos)
+static ssize_t output_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct moxtet *moxtet = file->private_data;
+	struct moxtet *moxtet = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	u8 bin[TURRIS_MOX_MAX_MODULES];
 	u8 hex[sizeof(bin) * 2 + 1];
 	ssize_t res;
-	loff_t dummy = 0;
 	int err, i;
 
 	if (len > 2 * moxtet->count + 1 || len < 2 * moxtet->count)
 		return -EINVAL;
 
-	res = simple_write_to_buffer(hex, sizeof(hex), &dummy, buf, len);
+	res = simple_copy_from_iter(hex, &iocb->ki_pos, sizeof(hex), from);
 	if (res < 0)
 		return res;
 
@@ -547,8 +545,8 @@ static ssize_t output_write(struct file *file, const char __user *buf,
 static const struct file_operations output_fops = {
 	.owner	= THIS_MODULE,
 	.open	= moxtet_debug_open,
-	.read	= output_read,
-	.write	= output_write,
+	.read_iter	= output_read,
+	.write_iter	= output_write,
 	.llseek	= no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 134/437] drivers/regulator: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (132 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 133/437] drivers/bus: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 135/437] fs/notify: " Jens Axboe
                   ` (303 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/regulator/core.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dabac9772741..92fad0d0fb9c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1810,11 +1810,10 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t constraint_flags_read_file(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t constraint_flags_read_file(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	const struct regulator *regulator = file->private_data;
+	const struct regulator *regulator = iocb->ki_filp->private_data;
 	const struct regulation_constraints *c = regulator->rdev->constraints;
 	char *buf;
 	ssize_t ret;
@@ -1842,9 +1841,8 @@ static ssize_t constraint_flags_read_file(struct file *file,
 			c->pull_down,
 			c->over_current_protection);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
-
 	return ret;
 }
 
@@ -1853,7 +1851,7 @@ static ssize_t constraint_flags_read_file(struct file *file,
 static const struct file_operations constraint_flags_fops = {
 #ifdef CONFIG_DEBUG_FS
 	.open = simple_open,
-	.read = constraint_flags_read_file,
+	.read_iter = constraint_flags_read_file,
 	.llseek = default_llseek,
 #endif
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 135/437] fs/notify: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (133 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 134/437] drivers/regulator: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 136/437] drm: switch drm_read() to be iterator based Jens Axboe
                   ` (302 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/notify/fanotify/fanotify_user.c | 6 ++++--
 fs/notify/inotify/inotify_user.c   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index fbdc63cc10d9..52b97f6c2285 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -868,6 +868,7 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
 		ret = buf - start;
 	return ret;
 }
+FOPS_READ_ITER_HELPER(fanotify_read);
 
 static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
 {
@@ -900,6 +901,7 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(fanotify_write);
 
 static int fanotify_release(struct inode *ignored, struct file *file)
 {
@@ -984,8 +986,8 @@ static long fanotify_ioctl(struct file *file, unsigned int cmd, unsigned long ar
 static const struct file_operations fanotify_fops = {
 	.show_fdinfo	= fanotify_show_fdinfo,
 	.poll		= fanotify_poll,
-	.read		= fanotify_read,
-	.write		= fanotify_write,
+	.read_iter	= fanotify_read_iter,
+	.write_iter	= fanotify_write_iter,
 	.fasync		= NULL,
 	.release	= fanotify_release,
 	.unlocked_ioctl	= fanotify_ioctl,
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 85d8fdd55329..bdc424a79e3c 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -297,6 +297,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
 		ret = buf - start;
 	return ret;
 }
+FOPS_READ_ITER_HELPER(inotify_read);
 
 static int inotify_release(struct inode *ignored, struct file *file)
 {
@@ -357,7 +358,7 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations inotify_fops = {
 	.show_fdinfo	= inotify_show_fdinfo,
 	.poll		= inotify_poll,
-	.read		= inotify_read,
+	.read_iter	= inotify_read_iter,
 	.fasync		= fsnotify_fasync,
 	.release	= inotify_release,
 	.unlocked_ioctl	= inotify_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 136/437] drm: switch drm_read() to be iterator based
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (134 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 135/437] fs/notify: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 137/437] drm: convert debugfs helpers to be read/write " Jens Axboe
                   ` (301 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

First step of converting the GPU drivers to using read/write iterators,
convert the common file read helper to be iter based.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  2 +-
 drivers/gpu/drm/drm_file.c              | 22 ++++++++++------------
 drivers/gpu/drm/gma500/psb_drv.c        |  2 +-
 drivers/gpu/drm/i915/i915_driver.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_drm.c   |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c     |  2 +-
 drivers/gpu/drm/tegra/drm.c             |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c     |  2 +-
 drivers/gpu/drm/xe/xe_device.c          |  2 +-
 include/drm/drm_accel.h                 |  2 +-
 include/drm/drm_file.h                  |  3 +--
 include/drm/drm_gem.h                   |  2 +-
 include/drm/drm_gem_dma_helper.h        |  2 +-
 13 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 80b9642f2bc4..d2369e852702 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2863,7 +2863,7 @@ static const struct file_operations amdgpu_driver_kms_fops = {
 	.unlocked_ioctl = amdgpu_drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = amdgpu_kms_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index 638ffa4444f5..c5965b5a1afc 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -110,7 +110,7 @@ bool drm_dev_needs_global_mutex(struct drm_device *dev)
  *             .unlocked_ioctl = drm_ioctl,
  *             .compat_ioctl = drm_compat_ioctl, // NULL if CONFIG_COMPAT=n
  *             .poll = drm_poll,
- *             .read = drm_read,
+ *             .read_iter = drm_read,
  *             .llseek = no_llseek,
  *             .mmap = drm_gem_mmap,
  *     };
@@ -515,18 +515,16 @@ EXPORT_SYMBOL(drm_release_noglobal);
 
 /**
  * drm_read - read method for DRM file
- * @filp: file pointer
- * @buffer: userspace destination pointer for the read
- * @count: count in bytes to read
- * @offset: offset to read
+ * @iocb: metadata for IO
+ * @to: userspace destination pointer for the read
  *
  * This function must be used by drivers as their &file_operations.read
  * method if they use DRM events for asynchronous signalling to userspace.
  * Since events are used by the KMS API for vblank and page flip completion this
  * means all modern display drivers must use it.
  *
- * @offset is ignored, DRM events are read like a pipe. Polling support is
- * provided by drm_poll().
+ * offset in @iocb is ignored, DRM events are read like a pipe. Polling support
+ * is provided by drm_poll().
  *
  * This function will only ever read a full event. Therefore userspace must
  * supply a big enough buffer to fit any event to ensure forward progress. Since
@@ -538,11 +536,11 @@ EXPORT_SYMBOL(drm_release_noglobal);
  * Number of bytes read (always aligned to full events, and can be 0) or a
  * negative error code on failure.
  */
-ssize_t drm_read(struct file *filp, char __user *buffer,
-		 size_t count, loff_t *offset)
+ssize_t drm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct drm_file *file_priv = filp->private_data;
+	struct drm_file *file_priv = iocb->ki_filp->private_data;
 	struct drm_device *dev = file_priv->minor->dev;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 
 	ret = mutex_lock_interruptible(&file_priv->event_read_lock);
@@ -565,7 +563,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
 			if (ret)
 				break;
 
-			if (filp->f_flags & O_NONBLOCK) {
+			if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 				ret = -EAGAIN;
 				break;
 			}
@@ -591,7 +589,7 @@ ssize_t drm_read(struct file *filp, char __user *buffer,
 				break;
 			}
 
-			if (copy_to_user(buffer + ret, e->event, length)) {
+			if (!copy_to_iter_full(e->event, length, to)) {
 				if (ret == 0)
 					ret = -EFAULT;
 				goto put_back_event;
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 8b64f61ffaf9..7489d64bea98 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -497,7 +497,7 @@ static const struct file_operations psb_gem_fops = {
 	.compat_ioctl = drm_compat_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 };
 
 static const struct drm_driver driver = {
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 4b9233c07a22..a8328ee685e8 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1729,7 +1729,7 @@ static const struct file_operations i915_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = i915_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 	.compat_ioctl = i915_ioc32_compat_ioctl,
 	.llseek = noop_llseek,
 #ifdef CONFIG_PROC_FS
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index a947e1d5f309..6b626d62781c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1269,7 +1269,7 @@ nouveau_driver_fops = {
 	.unlocked_ioctl = nouveau_drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = nouveau_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 7bf08164140e..7011ef3475a7 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -516,7 +516,7 @@ static const struct file_operations radeon_driver_kms_fops = {
 	.unlocked_ioctl = radeon_drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = radeon_kms_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 03d1c76aec2d..f455aa8339a3 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -798,7 +798,7 @@ static const struct file_operations tegra_drm_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 	.compat_ioctl = drm_compat_ioctl,
 	.llseek = noop_llseek,
 };
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c7d90f96d16a..fb68d49cff51 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1605,7 +1605,7 @@ static const struct file_operations vmwgfx_driver_fops = {
 	.unlocked_ioctl = vmw_unlocked_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 #if defined(CONFIG_COMPAT)
 	.compat_ioctl = vmw_compat_ioctl,
 #endif
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index d32ff3857e65..98ae007febe9 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -143,7 +143,7 @@ static const struct file_operations xe_driver_fops = {
 	.unlocked_ioctl = drm_ioctl,
 	.mmap = drm_gem_mmap,
 	.poll = drm_poll,
-	.read = drm_read,
+	.read_iter = drm_read,
 	.compat_ioctl = drm_compat_ioctl,
 	.llseek = noop_llseek,
 #ifdef CONFIG_PROC_FS
diff --git a/include/drm/drm_accel.h b/include/drm/drm_accel.h
index f4d3784b1dce..c757e0b1db46 100644
--- a/include/drm/drm_accel.h
+++ b/include/drm/drm_accel.h
@@ -26,7 +26,7 @@
 	.unlocked_ioctl	= drm_ioctl,\
 	.compat_ioctl	= drm_compat_ioctl,\
 	.poll		= drm_poll,\
-	.read		= drm_read,\
+	.read_iter	= drm_read,\
 	.llseek		= noop_llseek, \
 	.mmap		= drm_gem_mmap
 
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index ab230d3af138..19917ff0090c 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -436,8 +436,7 @@ void drm_file_update_pid(struct drm_file *);
 
 int drm_open(struct inode *inode, struct file *filp);
 int drm_open_helper(struct file *filp, struct drm_minor *minor);
-ssize_t drm_read(struct file *filp, char __user *buffer,
-		 size_t count, loff_t *offset);
+ssize_t drm_read(struct kiocb *iocb, struct iov_iter *to);
 int drm_release(struct inode *inode, struct file *filp);
 int drm_release_noglobal(struct inode *inode, struct file *filp);
 __poll_t drm_poll(struct file *filp, struct poll_table_struct *wait);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 2ebec3984cd4..29fe86ce8266 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -445,7 +445,7 @@ struct drm_gem_object {
 	.unlocked_ioctl	= drm_ioctl,\
 	.compat_ioctl	= drm_compat_ioctl,\
 	.poll		= drm_poll,\
-	.read		= drm_read,\
+	.read_iter	= drm_read,\
 	.llseek		= noop_llseek,\
 	.mmap		= drm_gem_mmap
 
diff --git a/include/drm/drm_gem_dma_helper.h b/include/drm/drm_gem_dma_helper.h
index a827bde494f6..907acd2b89fa 100644
--- a/include/drm/drm_gem_dma_helper.h
+++ b/include/drm/drm_gem_dma_helper.h
@@ -264,7 +264,7 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
 		.unlocked_ioctl	= drm_ioctl,\
 		.compat_ioctl	= drm_compat_ioctl,\
 		.poll		= drm_poll,\
-		.read		= drm_read,\
+		.read_iter	= drm_read,\
 		.llseek		= noop_llseek,\
 		.mmap		= drm_gem_mmap,\
 		DRM_GEM_DMA_UNMAPPED_AREA_FOPS \
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 137/437] drm: convert debugfs helpers to be read/write iterator based
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (135 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 136/437] drm: switch drm_read() to be iterator based Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 138/437] drm/i915: convert to read/write iterators Jens Axboe
                   ` (300 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/drm_debugfs.c     | 28 ++++++++++++++--------------
 drivers/gpu/drm/drm_debugfs_crc.c | 26 +++++++++++++-------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 08fcefd804bc..e7d7cbd930ca 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -171,7 +171,7 @@ static int drm_debugfs_entry_open(struct inode *inode, struct file *file)
 static const struct file_operations drm_debugfs_entry_fops = {
 	.owner = THIS_MODULE,
 	.open = drm_debugfs_entry_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -179,7 +179,7 @@ static const struct file_operations drm_debugfs_entry_fops = {
 static const struct file_operations drm_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = drm_debugfs_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -403,17 +403,17 @@ static int connector_open(struct inode *inode, struct file *file)
 	return single_open(file, connector_show, dev);
 }
 
-static ssize_t connector_write(struct file *file, const char __user *ubuf,
-			       size_t len, loff_t *offp)
+static ssize_t connector_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_connector *connector = m->private;
+	size_t len = iov_iter_count(from);
 	char buf[12];
 
 	if (len > sizeof(buf) - 1)
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -444,15 +444,15 @@ static int edid_open(struct inode *inode, struct file *file)
 	return single_open(file, edid_show, dev);
 }
 
-static ssize_t edid_write(struct file *file, const char __user *ubuf,
-			  size_t len, loff_t *offp)
+static ssize_t edid_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_connector *connector = m->private;
+	size_t len = iov_iter_count(from);
 	char *buf;
 	int ret;
 
-	buf = memdup_user(ubuf, len);
+	buf = iterdup(from, len);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -504,20 +504,20 @@ DEFINE_SHOW_ATTRIBUTE(output_bpc);
 static const struct file_operations drm_edid_fops = {
 	.owner = THIS_MODULE,
 	.open = edid_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = edid_write
+	.write_iter = edid_write
 };
 
 
 static const struct file_operations drm_connector_fops = {
 	.owner = THIS_MODULE,
 	.open = connector_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = connector_write
+	.write_iter = connector_write
 };
 
 void drm_debugfs_connector_add(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c
index bbc3bc4ba844..85741f3eafee 100644
--- a/drivers/gpu/drm/drm_debugfs_crc.c
+++ b/drivers/gpu/drm/drm_debugfs_crc.c
@@ -117,12 +117,12 @@ static int crc_control_open(struct inode *inode, struct file *file)
 	return single_open(file, crc_control_show, crtc);
 }
 
-static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
-				 size_t len, loff_t *offp)
+static ssize_t crc_control_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_crtc *crtc = m->private;
 	struct drm_crtc_crc *crc = &crtc->crc;
+	size_t len = iov_iter_count(from);
 	char *source;
 	size_t values_cnt;
 	int ret;
@@ -136,7 +136,7 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
 		return -E2BIG;
 	}
 
-	source = memdup_user_nul(ubuf, len);
+	source = iterdup_nul(from, len);
 	if (IS_ERR(source))
 		return PTR_ERR(source);
 
@@ -162,17 +162,17 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,
 
 	spin_unlock_irq(&crc->lock);
 
-	*offp += len;
+	iocb->ki_pos += len;
 	return len;
 }
 
 static const struct file_operations drm_crtc_crc_control_fops = {
 	.owner = THIS_MODULE,
 	.open = crc_control_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = crc_control_write
+	.write_iter = crc_control_write,
 };
 
 static int crtc_crc_data_count(struct drm_crtc_crc *crc)
@@ -281,11 +281,11 @@ static int crtc_crc_release(struct inode *inode, struct file *filep)
 #define LINE_LEN(values_cnt)	(10 + 11 * values_cnt + 1 + 1)
 #define MAX_LINE_LEN		(LINE_LEN(DRM_MAX_CRC_NR))
 
-static ssize_t crtc_crc_read(struct file *filep, char __user *user_buf,
-			     size_t count, loff_t *pos)
+static ssize_t crtc_crc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct drm_crtc *crtc = filep->f_inode->i_private;
+	struct drm_crtc *crtc = iocb->ki_filp->f_inode->i_private;
 	struct drm_crtc_crc *crc = &crtc->crc;
+	size_t count = iov_iter_count(to);
 	struct drm_crtc_crc_entry *entry;
 	char buf[MAX_LINE_LEN];
 	int ret, i;
@@ -299,7 +299,7 @@ static ssize_t crtc_crc_read(struct file *filep, char __user *user_buf,
 
 	/* Nothing to read? */
 	while (crtc_crc_data_count(crc) == 0) {
-		if (filep->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			spin_unlock_irq(&crc->lock);
 			return -EAGAIN;
 		}
@@ -335,7 +335,7 @@ static ssize_t crtc_crc_read(struct file *filep, char __user *user_buf,
 		sprintf(buf + 10 + i * 11, " 0x%08x", entry->crcs[i]);
 	sprintf(buf + 10 + crc->values_cnt * 11, "\n");
 
-	if (copy_to_user(user_buf, buf, LINE_LEN(crc->values_cnt)))
+	if (!copy_to_iter_full(buf, LINE_LEN(crc->values_cnt), to))
 		return -EFAULT;
 
 	return LINE_LEN(crc->values_cnt);
@@ -360,7 +360,7 @@ static __poll_t crtc_crc_poll(struct file *file, poll_table *wait)
 static const struct file_operations drm_crtc_crc_data_fops = {
 	.owner = THIS_MODULE,
 	.open = crtc_crc_open,
-	.read = crtc_crc_read,
+	.read_iter = crtc_crc_read,
 	.poll = crtc_crc_poll,
 	.release = crtc_crc_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 138/437] drm/i915: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (136 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 137/437] drm: convert debugfs helpers to be read/write " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 139/437] drm: amd: " Jens Axboe
                   ` (299 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../drm/i915/display/intel_display_debugfs.c  | 114 +++++++++---------
 .../display/intel_display_debugfs_params.c    |  36 +++---
 drivers/gpu/drm/i915/display/intel_hotplug.c  |  28 ++---
 drivers/gpu/drm/i915/display/intel_wm.c       |  42 +++----
 drivers/gpu/drm/i915/display/skl_watermark.c  |  14 +--
 drivers/gpu/drm/i915/gt/intel_gt_debugfs.c    |   2 +-
 drivers/gpu/drm/i915/gt/intel_gt_debugfs.h    |   2 +-
 .../drm/i915/gt/uc/intel_guc_log_debugfs.c    |  13 +-
 drivers/gpu/drm/i915/i915_debugfs_params.c    |  43 ++++---
 drivers/gpu/drm/i915/i915_gpu_error.c         |  28 ++---
 drivers/gpu/drm/i915/i915_perf.c              |   3 +-
 11 files changed, 156 insertions(+), 169 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
index b99c024b0934..b8d03be584dd 100644
--- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c
+++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c
@@ -513,26 +513,24 @@ static int crtc_updates_open(struct inode *inode, struct file *file)
 	return single_open(file, crtc_updates_show, inode->i_private);
 }
 
-static ssize_t crtc_updates_write(struct file *file,
-				  const char __user *ubuf,
-				  size_t len, loff_t *offp)
+static ssize_t crtc_updates_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_crtc *crtc = m->private;
 
 	/* May race with an update. Meh. */
 	memset(&crtc->debug.vbl, 0, sizeof(crtc->debug.vbl));
 
-	return len;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations crtc_updates_fops = {
 	.owner = THIS_MODULE,
 	.open = crtc_updates_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = crtc_updates_write
+	.write_iter = crtc_updates_write
 };
 
 static void crtc_updates_add(struct intel_crtc *crtc)
@@ -801,24 +799,24 @@ static int i915_dp_mst_info(struct seq_file *m, void *unused)
 	return 0;
 }
 
-static ssize_t i915_displayport_test_active_write(struct file *file,
-						  const char __user *ubuf,
-						  size_t len, loff_t *offp)
+static ssize_t i915_displayport_test_active_write(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
 	char *input_buffer;
 	int status = 0;
 	struct drm_device *dev;
 	struct drm_connector *connector;
 	struct drm_connector_list_iter conn_iter;
+	size_t len = iov_iter_count(from);
 	struct intel_dp *intel_dp;
 	int val = 0;
 
-	dev = ((struct seq_file *)file->private_data)->private;
+	dev = ((struct seq_file *)iocb->ki_filp->private_data)->private;
 
 	if (len == 0)
 		return 0;
 
-	input_buffer = memdup_user_nul(ubuf, len);
+	input_buffer = iterdup_nul(from, len);
 	if (IS_ERR(input_buffer))
 		return PTR_ERR(input_buffer);
 
@@ -856,7 +854,7 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
 	if (status < 0)
 		return status;
 
-	*offp += len;
+	iocb->ki_pos += len;
 	return len;
 }
 
@@ -903,10 +901,10 @@ static int i915_displayport_test_active_open(struct inode *inode,
 static const struct file_operations i915_displayport_test_active_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_displayport_test_active_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_displayport_test_active_write
+	.write_iter = i915_displayport_test_active_write,
 };
 
 static int i915_displayport_test_data_show(struct seq_file *m, void *data)
@@ -994,16 +992,15 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
 DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type);
 
 static ssize_t
-i915_fifo_underrun_reset_write(struct file *filp,
-			       const char __user *ubuf,
-			       size_t cnt, loff_t *ppos)
+i915_fifo_underrun_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct drm_i915_private *dev_priv = filp->private_data;
+	struct drm_i915_private *dev_priv = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	struct intel_crtc *crtc;
 	int ret;
 	bool reset;
 
-	ret = kstrtobool_from_user(ubuf, cnt, &reset);
+	ret = kstrtobool_from_iter(from, cnt, &reset);
 	if (ret)
 		return ret;
 
@@ -1048,7 +1045,7 @@ i915_fifo_underrun_reset_write(struct file *filp,
 static const struct file_operations i915_fifo_underrun_reset_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = i915_fifo_underrun_reset_write,
+	.write_iter = i915_fifo_underrun_reset_write,
 	.llseek = default_llseek,
 };
 
@@ -1259,15 +1256,15 @@ static int i915_dsc_fec_support_show(struct seq_file *m, void *data)
 	return ret;
 }
 
-static ssize_t i915_dsc_fec_support_write(struct file *file,
-					  const char __user *ubuf,
-					  size_t len, loff_t *offp)
+static ssize_t i915_dsc_fec_support_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_connector *connector = m->private;
 	struct drm_i915_private *i915 = to_i915(connector->base.dev);
 	struct intel_encoder *encoder = intel_attached_encoder(connector);
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+	size_t len = iov_iter_count(from);
 	bool dsc_enable = false;
 	int ret;
 
@@ -1277,7 +1274,7 @@ static ssize_t i915_dsc_fec_support_write(struct file *file,
 	drm_dbg(&i915->drm,
 		"Copied %zu bytes from user to force DSC\n", len);
 
-	ret = kstrtobool_from_user(ubuf, len, &dsc_enable);
+	ret = kstrtobool_from_iter(from, len, &dsc_enable);
 	if (ret < 0)
 		return ret;
 
@@ -1285,7 +1282,7 @@ static ssize_t i915_dsc_fec_support_write(struct file *file,
 		(dsc_enable) ? "true" : "false");
 	intel_dp->force_dsc_en = dsc_enable;
 
-	*offp += len;
+	iocb->ki_pos += len;
 	return len;
 }
 
@@ -1299,10 +1296,10 @@ static int i915_dsc_fec_support_open(struct inode *inode,
 static const struct file_operations i915_dsc_fec_support_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_dsc_fec_support_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_dsc_fec_support_write
+	.write_iter = i915_dsc_fec_support_write
 };
 
 static int i915_dsc_bpc_show(struct seq_file *m, void *data)
@@ -1335,23 +1332,22 @@ out:	drm_modeset_unlock(&i915->drm.mode_config.connection_mutex);
 	return ret;
 }
 
-static ssize_t i915_dsc_bpc_write(struct file *file,
-				  const char __user *ubuf,
-				  size_t len, loff_t *offp)
+static ssize_t i915_dsc_bpc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_connector *connector = m->private;
 	struct intel_encoder *encoder = intel_attached_encoder(connector);
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+	size_t len = iov_iter_count(from);
 	int dsc_bpc = 0;
 	int ret;
 
-	ret = kstrtoint_from_user(ubuf, len, 0, &dsc_bpc);
+	ret = kstrtoint_from_iter(from, len, 0, &dsc_bpc);
 	if (ret < 0)
 		return ret;
 
 	intel_dp->force_dsc_bpc = dsc_bpc;
-	*offp += len;
+	iocb->ki_pos += len;
 
 	return len;
 }
@@ -1365,10 +1361,10 @@ static int i915_dsc_bpc_open(struct inode *inode,
 static const struct file_operations i915_dsc_bpc_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_dsc_bpc_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_dsc_bpc_write
+	.write_iter = i915_dsc_bpc_write
 };
 
 static int i915_dsc_output_format_show(struct seq_file *m, void *data)
@@ -1416,33 +1412,33 @@ static int i915_bigjoiner_enable_show(struct seq_file *m, void *data)
 	return 0;
 }
 
-static ssize_t i915_dsc_output_format_write(struct file *file,
-					    const char __user *ubuf,
-					    size_t len, loff_t *offp)
+static ssize_t i915_dsc_output_format_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_connector *connector = m->private;
 	struct intel_encoder *encoder = intel_attached_encoder(connector);
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+	size_t len = iov_iter_count(from);
 	int dsc_output_format = 0;
 	int ret;
 
-	ret = kstrtoint_from_user(ubuf, len, 0, &dsc_output_format);
+	ret = kstrtoint_from_iter(from, len, 0, &dsc_output_format);
 	if (ret < 0)
 		return ret;
 
 	intel_dp->force_dsc_output_format = dsc_output_format;
-	*offp += len;
+	iocb->ki_pos += len;
 
 	return len;
 }
 
-static ssize_t i915_bigjoiner_enable_write(struct file *file,
-					   const char __user *ubuf,
-					   size_t len, loff_t *offp)
+static ssize_t i915_bigjoiner_enable_write_iter(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_connector *connector = m->private;
+	size_t len = iov_iter_count(from);
 	struct drm_crtc *crtc;
 	bool bigjoiner_en = 0;
 	int ret;
@@ -1451,12 +1447,12 @@ static ssize_t i915_bigjoiner_enable_write(struct file *file,
 	if (connector->base.status != connector_status_connected || !crtc)
 		return -ENODEV;
 
-	ret = kstrtobool_from_user(ubuf, len, &bigjoiner_en);
+	ret = kstrtobool_from_iter(from, len, &bigjoiner_en);
 	if (ret < 0)
 		return ret;
 
 	connector->force_bigjoiner_enable = bigjoiner_en;
-	*offp += len;
+	iocb->ki_pos += len;
 
 	return len;
 }
@@ -1470,10 +1466,10 @@ static int i915_dsc_output_format_open(struct inode *inode,
 static const struct file_operations i915_dsc_output_format_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_dsc_output_format_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_dsc_output_format_write
+	.write_iter = i915_dsc_output_format_write
 };
 
 static int i915_dsc_fractional_bpp_show(struct seq_file *m, void *data)
@@ -1508,16 +1504,16 @@ static int i915_dsc_fractional_bpp_show(struct seq_file *m, void *data)
 	return ret;
 }
 
-static ssize_t i915_dsc_fractional_bpp_write(struct file *file,
-					     const char __user *ubuf,
-					     size_t len, loff_t *offp)
+static ssize_t i915_dsc_fractional_bpp_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_connector *connector = m->private;
 	struct intel_encoder *encoder = intel_attached_encoder(connector);
 	struct drm_i915_private *i915 = to_i915(connector->base.dev);
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 	bool dsc_fractional_bpp_enable = false;
+	size_t len = iov_iter_count(from);
 	int ret;
 
 	if (len == 0)
@@ -1526,7 +1522,7 @@ static ssize_t i915_dsc_fractional_bpp_write(struct file *file,
 	drm_dbg(&i915->drm,
 		"Copied %zu bytes from user to force fractional bpp for DSC\n", len);
 
-	ret = kstrtobool_from_user(ubuf, len, &dsc_fractional_bpp_enable);
+	ret = kstrtobool_from_iter(from, len, &dsc_fractional_bpp_enable);
 	if (ret < 0)
 		return ret;
 
@@ -1534,7 +1530,7 @@ static ssize_t i915_dsc_fractional_bpp_write(struct file *file,
 		(dsc_fractional_bpp_enable) ? "true" : "false");
 	intel_dp->force_dsc_fractional_bpp_en = dsc_fractional_bpp_enable;
 
-	*offp += len;
+	iocb->ki_pos += len;
 
 	return len;
 }
@@ -1548,10 +1544,10 @@ static int i915_dsc_fractional_bpp_open(struct inode *inode,
 static const struct file_operations i915_dsc_fractional_bpp_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_dsc_fractional_bpp_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_dsc_fractional_bpp_write
+	.write_iter = i915_dsc_fractional_bpp_write
 };
 
 DEFINE_SHOW_STORE_ATTRIBUTE(i915_bigjoiner_enable);
diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs_params.c b/drivers/gpu/drm/i915/display/intel_display_debugfs_params.c
index f35718748555..deb2a157a4f9 100644
--- a/drivers/gpu/drm/i915/display/intel_display_debugfs_params.c
+++ b/drivers/gpu/drm/i915/display/intel_display_debugfs_params.c
@@ -27,20 +27,20 @@ static int intel_display_param_int_open(struct inode *inode, struct file *file)
 	return single_open(file, intel_display_param_int_show, inode->i_private);
 }
 
-static ssize_t intel_display_param_int_write(struct file *file,
-					     const char __user *ubuf, size_t len,
-					     loff_t *offp)
+static ssize_t intel_display_param_int_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int *value = m->private;
 	int ret;
 
-	ret = kstrtoint_from_user(ubuf, len, 0, value);
+	ret = kstrtoint_from_iter(from, len, 0, value);
 	if (ret) {
 		/* support boolean values too */
 		bool b;
 
-		ret = kstrtobool_from_user(ubuf, len, &b);
+		ret = kstrtobool_from_iter(from, len, &b);
 		if (!ret)
 			*value = b;
 	}
@@ -51,8 +51,8 @@ static ssize_t intel_display_param_int_write(struct file *file,
 static const struct file_operations intel_display_param_int_fops = {
 	.owner = THIS_MODULE,
 	.open = intel_display_param_int_open,
-	.read = seq_read,
-	.write = intel_display_param_int_write,
+	.read_iter = seq_read_iter,
+	.write_iter = intel_display_param_int_write,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -60,7 +60,7 @@ static const struct file_operations intel_display_param_int_fops = {
 static const struct file_operations intel_display_param_int_fops_ro = {
 	.owner = THIS_MODULE,
 	.open = intel_display_param_int_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -80,20 +80,20 @@ static int intel_display_param_uint_open(struct inode *inode, struct file *file)
 	return single_open(file, intel_display_param_uint_show, inode->i_private);
 }
 
-static ssize_t intel_display_param_uint_write(struct file *file,
-					      const char __user *ubuf, size_t len,
-					      loff_t *offp)
+static ssize_t intel_display_param_uint_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	unsigned int *value = m->private;
 	int ret;
 
-	ret = kstrtouint_from_user(ubuf, len, 0, value);
+	ret = kstrtouint_from_iter(from, len, 0, value);
 	if (ret) {
 		/* support boolean values too */
 		bool b;
 
-		ret = kstrtobool_from_user(ubuf, len, &b);
+		ret = kstrtobool_from_iter(from, len, &b);
 		if (!ret)
 			*value = b;
 	}
@@ -104,8 +104,8 @@ static ssize_t intel_display_param_uint_write(struct file *file,
 static const struct file_operations intel_display_param_uint_fops = {
 	.owner = THIS_MODULE,
 	.open = intel_display_param_uint_open,
-	.read = seq_read,
-	.write = intel_display_param_uint_write,
+	.read_iter = seq_read_iter,
+	.write_iter = intel_display_param_uint_write,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -113,7 +113,7 @@ static const struct file_operations intel_display_param_uint_fops = {
 static const struct file_operations intel_display_param_uint_fops_ro = {
 	.owner = THIS_MODULE,
 	.open = intel_display_param_uint_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
diff --git a/drivers/gpu/drm/i915/display/intel_hotplug.c b/drivers/gpu/drm/i915/display/intel_hotplug.c
index d9ec349f3c8c..0a4a54fea1aa 100644
--- a/drivers/gpu/drm/i915/display/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/display/intel_hotplug.c
@@ -1019,13 +1019,13 @@ static int i915_hpd_storm_ctl_show(struct seq_file *m, void *data)
 	return 0;
 }
 
-static ssize_t i915_hpd_storm_ctl_write(struct file *file,
-					const char __user *ubuf, size_t len,
-					loff_t *offp)
+static ssize_t i915_hpd_storm_ctl_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
 	struct intel_hotplug *hotplug = &dev_priv->display.hotplug;
+	size_t len = iov_iter_count(from);
 	unsigned int new_threshold;
 	int i;
 	char *newline;
@@ -1034,7 +1034,7 @@ static ssize_t i915_hpd_storm_ctl_write(struct file *file,
 	if (len >= sizeof(tmp))
 		return -EINVAL;
 
-	if (copy_from_user(tmp, ubuf, len))
+	if (!copy_from_iter_full(tmp, len, from))
 		return -EFAULT;
 
 	tmp[len] = '\0';
@@ -1077,10 +1077,10 @@ static int i915_hpd_storm_ctl_open(struct inode *inode, struct file *file)
 static const struct file_operations i915_hpd_storm_ctl_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_hpd_storm_ctl_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_hpd_storm_ctl_write
+	.write_iter = i915_hpd_storm_ctl_write
 };
 
 static int i915_hpd_short_storm_ctl_show(struct seq_file *m, void *data)
@@ -1100,13 +1100,13 @@ i915_hpd_short_storm_ctl_open(struct inode *inode, struct file *file)
 			   inode->i_private);
 }
 
-static ssize_t i915_hpd_short_storm_ctl_write(struct file *file,
-					      const char __user *ubuf,
-					      size_t len, loff_t *offp)
+static ssize_t i915_hpd_short_storm_ctl_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
 	struct intel_hotplug *hotplug = &dev_priv->display.hotplug;
+	size_t len = iov_iter_count(from);
 	char *newline;
 	char tmp[16];
 	int i;
@@ -1115,7 +1115,7 @@ static ssize_t i915_hpd_short_storm_ctl_write(struct file *file,
 	if (len >= sizeof(tmp))
 		return -EINVAL;
 
-	if (copy_from_user(tmp, ubuf, len))
+	if (!copy_from_iter_full(tmp, len, from))
 		return -EFAULT;
 
 	tmp[len] = '\0';
@@ -1150,10 +1150,10 @@ static ssize_t i915_hpd_short_storm_ctl_write(struct file *file,
 static const struct file_operations i915_hpd_short_storm_ctl_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_hpd_short_storm_ctl_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = i915_hpd_short_storm_ctl_write,
+	.write_iter = i915_hpd_short_storm_ctl_write,
 };
 
 void intel_hpd_debugfs_register(struct drm_i915_private *i915)
diff --git a/drivers/gpu/drm/i915/display/intel_wm.c b/drivers/gpu/drm/i915/display/intel_wm.c
index 82c4933ad507..86be01bb69f3 100644
--- a/drivers/gpu/drm/i915/display/intel_wm.c
+++ b/drivers/gpu/drm/i915/display/intel_wm.c
@@ -285,11 +285,12 @@ static int cur_wm_latency_open(struct inode *inode, struct file *file)
 	return single_open(file, cur_wm_latency_show, dev_priv);
 }
 
-static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
-				size_t len, loff_t *offp, u16 wm[8])
+static ssize_t wm_latency_write(struct kiocb *iocb, struct iov_iter *from,
+				u16 wm[8])
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
+	size_t len = iov_iter_count(from);
 	u16 new[8] = {};
 	int level;
 	int ret;
@@ -298,7 +299,7 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
 	if (len >= sizeof(tmp))
 		return -EINVAL;
 
-	if (copy_from_user(tmp, ubuf, len))
+	if (!copy_from_iter_full(tmp, len, from))
 		return -EFAULT;
 
 	tmp[len] = '\0';
@@ -319,10 +320,9 @@ static ssize_t wm_latency_write(struct file *file, const char __user *ubuf,
 	return len;
 }
 
-static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
-				    size_t len, loff_t *offp)
+static ssize_t pri_wm_latency_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
 	u16 *latencies;
 
@@ -331,13 +331,12 @@ static ssize_t pri_wm_latency_write(struct file *file, const char __user *ubuf,
 	else
 		latencies = dev_priv->display.wm.pri_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, latencies);
+	return wm_latency_write(iocb, from, latencies);
 }
 
-static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
-				    size_t len, loff_t *offp)
+static ssize_t spr_wm_latency_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
 	u16 *latencies;
 
@@ -346,13 +345,12 @@ static ssize_t spr_wm_latency_write(struct file *file, const char __user *ubuf,
 	else
 		latencies = dev_priv->display.wm.spr_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, latencies);
+	return wm_latency_write(iocb, from, latencies);
 }
 
-static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
-				    size_t len, loff_t *offp)
+static ssize_t cur_wm_latency_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *dev_priv = m->private;
 	u16 *latencies;
 
@@ -361,34 +359,34 @@ static ssize_t cur_wm_latency_write(struct file *file, const char __user *ubuf,
 	else
 		latencies = dev_priv->display.wm.cur_latency;
 
-	return wm_latency_write(file, ubuf, len, offp, latencies);
+	return wm_latency_write(iocb, from, latencies);
 }
 
 static const struct file_operations i915_pri_wm_latency_fops = {
 	.owner = THIS_MODULE,
 	.open = pri_wm_latency_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = pri_wm_latency_write
+	.write_iter = pri_wm_latency_write
 };
 
 static const struct file_operations i915_spr_wm_latency_fops = {
 	.owner = THIS_MODULE,
 	.open = spr_wm_latency_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = spr_wm_latency_write
+	.write_iter = spr_wm_latency_write
 };
 
 static const struct file_operations i915_cur_wm_latency_fops = {
 	.owner = THIS_MODULE,
 	.open = cur_wm_latency_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = cur_wm_latency_write
+	.write_iter = cur_wm_latency_write
 };
 
 void intel_wm_debugfs_register(struct drm_i915_private *i915)
diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c b/drivers/gpu/drm/i915/display/skl_watermark.c
index c6b9be80d83c..9c87f0c1a0da 100644
--- a/drivers/gpu/drm/i915/display/skl_watermark.c
+++ b/drivers/gpu/drm/i915/display/skl_watermark.c
@@ -3713,17 +3713,17 @@ static int skl_watermark_ipc_status_open(struct inode *inode, struct file *file)
 	return single_open(file, skl_watermark_ipc_status_show, i915);
 }
 
-static ssize_t skl_watermark_ipc_status_write(struct file *file,
-					      const char __user *ubuf,
-					      size_t len, loff_t *offp)
+static ssize_t skl_watermark_ipc_status_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_i915_private *i915 = m->private;
+	size_t len = iov_iter_count(from);
 	intel_wakeref_t wakeref;
 	bool enable;
 	int ret;
 
-	ret = kstrtobool_from_user(ubuf, len, &enable);
+	ret = kstrtobool_from_iter(from, len, &enable);
 	if (ret < 0)
 		return ret;
 
@@ -3741,10 +3741,10 @@ static ssize_t skl_watermark_ipc_status_write(struct file *file,
 static const struct file_operations skl_watermark_ipc_status_fops = {
 	.owner = THIS_MODULE,
 	.open = skl_watermark_ipc_status_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = skl_watermark_ipc_status_write
+	.write_iter = skl_watermark_ipc_status_write
 };
 
 static int intel_sagv_status_show(struct seq_file *m, void *unused)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_debugfs.c b/drivers/gpu/drm/i915/gt/intel_gt_debugfs.c
index 4dc23b8d3aa2..ed8c47f3cc39 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_debugfs.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_debugfs.c
@@ -107,7 +107,7 @@ void intel_gt_debugfs_register_files(struct dentry *root,
 				     unsigned long count, void *data)
 {
 	while (count--) {
-		umode_t mode = files->fops->write ? 0644 : 0444;
+		umode_t mode = files->fops->write_iter ? 0644 : 0444;
 
 		if (!files->eval || files->eval(data))
 			debugfs_create_file(files->name,
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_debugfs.h b/drivers/gpu/drm/i915/gt/intel_gt_debugfs.h
index e4110eebf093..1753bebb6f70 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_debugfs.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_debugfs.h
@@ -14,7 +14,7 @@ struct intel_gt;
 static const struct file_operations __name ## _fops = {			\
 	.owner = THIS_MODULE,						\
 	.open = __name ## _open,					\
-	.read = seq_read,						\
+	.read_iter = seq_read_iter,					\
 	.llseek = seq_lseek,						\
 	.release = single_release,					\
 }
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
index ddfbe334689f..3284631a8c07 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
@@ -117,17 +117,14 @@ static int guc_log_relay_open(struct inode *inode, struct file *file)
 	return intel_guc_log_relay_open(log);
 }
 
-static ssize_t
-guc_log_relay_write(struct file *filp,
-		    const char __user *ubuf,
-		    size_t cnt,
-		    loff_t *ppos)
+static ssize_t guc_log_relay_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct intel_guc_log *log = filp->private_data;
+	struct intel_guc_log *log = iocb->ki_filp->private_data;
+	size_t cnt = iov_iter_count(from);
 	int val;
 	int ret;
 
-	ret = kstrtoint_from_user(ubuf, cnt, 0, &val);
+	ret = kstrtoint_from_iter(from, cnt, 0, &val);
 	if (ret < 0)
 		return ret;
 
@@ -154,7 +151,7 @@ static int guc_log_relay_release(struct inode *inode, struct file *file)
 static const struct file_operations guc_log_relay_fops = {
 	.owner = THIS_MODULE,
 	.open = guc_log_relay_open,
-	.write = guc_log_relay_write,
+	.write_iter = guc_log_relay_write,
 	.release = guc_log_relay_release,
 };
 
diff --git a/drivers/gpu/drm/i915/i915_debugfs_params.c b/drivers/gpu/drm/i915/i915_debugfs_params.c
index 8bca02025e09..5369d1e7f1b7 100644
--- a/drivers/gpu/drm/i915/i915_debugfs_params.c
+++ b/drivers/gpu/drm/i915/i915_debugfs_params.c
@@ -49,20 +49,19 @@ static int notify_guc(struct drm_i915_private *i915)
 	return ret;
 }
 
-static ssize_t i915_param_int_write(struct file *file,
-				    const char __user *ubuf, size_t len,
-				    loff_t *offp)
+static ssize_t i915_param_int_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int *value = m->private;
 	int ret;
 
-	ret = kstrtoint_from_user(ubuf, len, 0, value);
+	ret = kstrtoint_from_iter(from, len, 0, value);
 	if (ret) {
 		/* support boolean values too */
 		bool b;
 
-		ret = kstrtobool_from_user(ubuf, len, &b);
+		ret = kstrtobool_from_iter(from, len, &b);
 		if (!ret)
 			*value = b;
 	}
@@ -73,8 +72,8 @@ static ssize_t i915_param_int_write(struct file *file,
 static const struct file_operations i915_param_int_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_param_int_open,
-	.read = seq_read,
-	.write = i915_param_int_write,
+	.read_iter = seq_read_iter,
+	.write_iter = i915_param_int_write,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -82,7 +81,7 @@ static const struct file_operations i915_param_int_fops = {
 static const struct file_operations i915_param_int_fops_ro = {
 	.owner = THIS_MODULE,
 	.open = i915_param_int_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -102,27 +101,26 @@ static int i915_param_uint_open(struct inode *inode, struct file *file)
 	return single_open(file, i915_param_uint_show, inode->i_private);
 }
 
-static ssize_t i915_param_uint_write(struct file *file,
-				     const char __user *ubuf, size_t len,
-				     loff_t *offp)
+static ssize_t i915_param_uint_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct drm_i915_private *i915;
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	unsigned int *value = m->private;
 	unsigned int old = *value;
 	int ret;
 
-	ret = kstrtouint_from_user(ubuf, len, 0, value);
+	ret = kstrtouint_from_iter(from, len, 0, value);
 	if (ret) {
 		/* support boolean values too */
 		bool b;
 
-		ret = kstrtobool_from_user(ubuf, len, &b);
+		ret = kstrtobool_from_iter(from, len, &b);
 		if (!ret)
 			*value = b;
 	}
 
-	if (!ret && MATCH_DEBUGFS_NODE_NAME(file, "reset")) {
+	if (!ret && MATCH_DEBUGFS_NODE_NAME(iocb->ki_filp, "reset")) {
 		GET_I915(i915, reset, value);
 
 		ret = notify_guc(i915);
@@ -136,8 +134,8 @@ static ssize_t i915_param_uint_write(struct file *file,
 static const struct file_operations i915_param_uint_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_param_uint_open,
-	.read = seq_read,
-	.write = i915_param_uint_write,
+	.read_iter = seq_read_iter,
+	.write_iter = i915_param_uint_write,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -145,7 +143,7 @@ static const struct file_operations i915_param_uint_fops = {
 static const struct file_operations i915_param_uint_fops_ro = {
 	.owner = THIS_MODULE,
 	.open = i915_param_uint_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -186,12 +184,13 @@ static ssize_t i915_param_charp_write(struct file *file,
 out:
 	return len;
 }
+FOPS_WRITE_ITER_HELPER(i915_param_charp_write);
 
 static const struct file_operations i915_param_charp_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_param_charp_open,
-	.read = seq_read,
-	.write = i915_param_charp_write,
+	.read_iter = seq_read_iter,
+	.write_iter = i915_param_charp_write_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
@@ -199,7 +198,7 @@ static const struct file_operations i915_param_charp_fops = {
 static const struct file_operations i915_param_charp_fops_ro = {
 	.owner = THIS_MODULE,
 	.open = i915_param_charp_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = default_llseek,
 	.release = single_release,
 };
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index a0b784ebaddd..ca0851c07082 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -2380,14 +2380,14 @@ void intel_klog_error_capture(struct intel_gt *gt,
 }
 #endif
 
-static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
-			      size_t count, loff_t *pos)
+static ssize_t gpu_state_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct i915_gpu_coredump *error;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 	void *buf;
 
-	error = file->private_data;
+	error = iocb->ki_filp->private_data;
 	if (!error)
 		return 0;
 
@@ -2396,12 +2396,12 @@ static ssize_t gpu_state_read(struct file *file, char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	ret = i915_gpu_coredump_copy_to_buffer(error, buf, *pos, count);
+	ret = i915_gpu_coredump_copy_to_buffer(error, buf, iocb->ki_pos, count);
 	if (ret <= 0)
 		goto out;
 
-	if (!copy_to_user(ubuf, buf, ret))
-		*pos += ret;
+	if (copy_to_iter_full(buf, ret, to))
+		iocb->ki_pos += ret;
 	else
 		ret = -EFAULT;
 
@@ -2436,18 +2436,14 @@ static int i915_gpu_info_open(struct inode *inode, struct file *file)
 static const struct file_operations i915_gpu_info_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_gpu_info_open,
-	.read = gpu_state_read,
+	.read_iter = gpu_state_read,
 	.llseek = default_llseek,
 	.release = gpu_state_release,
 };
 
-static ssize_t
-i915_error_state_write(struct file *filp,
-		       const char __user *ubuf,
-		       size_t cnt,
-		       loff_t *ppos)
+static ssize_t i915_error_state_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct i915_gpu_coredump *error = filp->private_data;
+	struct i915_gpu_coredump *error = iocb->ki_filp->private_data;
 
 	if (!error)
 		return 0;
@@ -2455,7 +2451,7 @@ i915_error_state_write(struct file *filp,
 	drm_dbg(&error->i915->drm, "Resetting error state\n");
 	i915_reset_error_state(error->i915);
 
-	return cnt;
+	return iov_iter_count(from);
 }
 
 static int i915_error_state_open(struct inode *inode, struct file *file)
@@ -2473,8 +2469,8 @@ static int i915_error_state_open(struct inode *inode, struct file *file)
 static const struct file_operations i915_error_state_fops = {
 	.owner = THIS_MODULE,
 	.open = i915_error_state_open,
-	.read = gpu_state_read,
-	.write = i915_error_state_write,
+	.read_iter = gpu_state_read,
+	.write_iter = i915_error_state_write,
 	.llseek = default_llseek,
 	.release = gpu_state_release,
 };
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index bd9d812b1afa..8ff6d5b0b40a 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -3512,6 +3512,7 @@ static ssize_t i915_perf_read(struct file *file,
 	/* Possible values for ret are 0, -EFAULT, -ENOSPC, -EIO, ... */
 	return offset ?: (ret ?: -EAGAIN);
 }
+FOPS_READ_ITER_HELPER(i915_perf_read);
 
 static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer)
 {
@@ -3788,7 +3789,7 @@ static const struct file_operations fops = {
 	.llseek		= no_llseek,
 	.release	= i915_perf_release,
 	.poll		= i915_perf_poll,
-	.read		= i915_perf_read,
+	.read_iter	= i915_perf_read_iter,
 	.unlocked_ioctl	= i915_perf_ioctl,
 	/* Our ioctl have no arguments, so it's safe to use the same function
 	 * to handle 32bits compatibility.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 139/437] drm: amd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (137 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 138/437] drm/i915: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 140/437] drm: msm: " Jens Axboe
                   ` (298 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c       |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c   |  71 +++++++----
 .../drm/amd/amdgpu/amdgpu_fw_attestation.c    |  23 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c       |   4 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c    |  18 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c       |  14 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c       |  34 +++---
 .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c    |  22 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c      |   6 +-
 .../gpu/drm/amd/amdgpu/amdgpu_securedisplay.c |  14 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |  56 ++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c       |   3 +-
 drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c      |  13 +-
 drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c   |  19 ++-
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 111 ++++++++++--------
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |  11 +-
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     |  17 +--
 17 files changed, 231 insertions(+), 209 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
index 493982f94649..8fd471e72ae9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
@@ -840,7 +840,7 @@ static int aca_dump_ce_open(struct inode *inode, struct file *file)
 static const struct file_operations aca_ce_dump_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = aca_dump_ce_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -858,7 +858,7 @@ static int aca_dump_ue_open(struct inode *inode, struct file *file)
 static const struct file_operations aca_ue_dump_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = aca_dump_ue_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index f5d0fa207a88..f816d92430ff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -194,6 +194,7 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
 {
 	return amdgpu_debugfs_process_reg_op(true, f, buf, size, pos);
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_regs_read);
 
 /*
  * amdgpu_debugfs_regs_write - Callback for writing MMIO registers
@@ -203,6 +204,7 @@ static ssize_t amdgpu_debugfs_regs_write(struct file *f, const char __user *buf,
 {
 	return amdgpu_debugfs_process_reg_op(false, f, (char __user *)buf, size, pos);
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_regs_write);
 
 static int amdgpu_debugfs_regs2_open(struct inode *inode, struct file *file)
 {
@@ -365,11 +367,13 @@ static ssize_t amdgpu_debugfs_regs2_read(struct file *f, char __user *buf, size_
 {
 	return amdgpu_debugfs_regs2_op(f, buf, *pos, size, 0);
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_regs2_read);
 
 static ssize_t amdgpu_debugfs_regs2_write(struct file *f, const char __user *buf, size_t size, loff_t *pos)
 {
 	return amdgpu_debugfs_regs2_op(f, (char __user *)buf, *pos, size, 1);
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_regs2_write);
 
 static int amdgpu_debugfs_gprwave_open(struct inode *inode, struct file *file)
 {
@@ -475,6 +479,7 @@ static ssize_t amdgpu_debugfs_gprwave_read(struct file *f, char __user *buf, siz
 	kfree(data);
 	return result;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gprwave_read);
 
 static long amdgpu_debugfs_gprwave_ioctl(struct file *f, unsigned int cmd, unsigned long data)
 {
@@ -562,6 +567,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf,
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_regs_pcie_read);
 
 /**
  * amdgpu_debugfs_regs_pcie_write - Write to a PCIE register
@@ -622,6 +628,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_regs_pcie_write);
 
 /**
  * amdgpu_debugfs_regs_didt_read - Read from a DIDT register
@@ -681,6 +688,7 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf,
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_regs_didt_read);
 
 /**
  * amdgpu_debugfs_regs_didt_write - Write to a DIDT register
@@ -741,6 +749,7 @@ static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_regs_didt_write);
 
 /**
  * amdgpu_debugfs_regs_smc_read - Read from a SMC register
@@ -800,6 +809,7 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf,
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_regs_smc_read);
 
 /**
  * amdgpu_debugfs_regs_smc_write - Write to a SMC register
@@ -860,6 +870,7 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *
 	amdgpu_virt_disable_access_debugfs(adev);
 	return r;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_regs_smc_write);
 
 /**
  * amdgpu_debugfs_gca_config_read - Read from gfx config data
@@ -957,6 +968,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
 	kfree(config);
 	return result;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gca_config_read);
 
 /**
  * amdgpu_debugfs_sensor_read - Read from the powerplay sensors
@@ -1030,6 +1042,7 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf,
 	amdgpu_virt_disable_access_debugfs(adev);
 	return !r ? outsize : r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_sensor_read);
 
 /** amdgpu_debugfs_wave_read - Read WAVE STATUS data
  *
@@ -1121,6 +1134,7 @@ static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf,
 	amdgpu_virt_disable_access_debugfs(adev);
 	return result;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_wave_read);
 
 /** amdgpu_debugfs_gpr_read - Read wave gprs
  *
@@ -1219,6 +1233,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
 	kfree(data);
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gpr_read);
 
 /**
  * amdgpu_debugfs_gfxoff_residency_read - Read GFXOFF residency
@@ -1271,6 +1286,7 @@ static ssize_t amdgpu_debugfs_gfxoff_residency_read(struct file *f, char __user
 
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gfxoff_residency_read);
 
 /**
  * amdgpu_debugfs_gfxoff_residency_write - Log GFXOFF Residency
@@ -1320,7 +1336,7 @@ static ssize_t amdgpu_debugfs_gfxoff_residency_write(struct file *f, const char
 
 	return r;
 }
-
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_gfxoff_residency_write);
 
 /**
  * amdgpu_debugfs_gfxoff_count_read - Read GFXOFF entry count
@@ -1370,6 +1386,7 @@ static ssize_t amdgpu_debugfs_gfxoff_count_read(struct file *f, char __user *buf
 
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gfxoff_count_read);
 
 /**
  * amdgpu_debugfs_gfxoff_write - Enable/disable GFXOFF
@@ -1419,7 +1436,7 @@ static ssize_t amdgpu_debugfs_gfxoff_write(struct file *f, const char __user *bu
 
 	return r;
 }
-
+FOPS_WRITE_ITER_HELPER(amdgpu_debugfs_gfxoff_write);
 
 /**
  * amdgpu_debugfs_gfxoff_read - read gfxoff status
@@ -1465,6 +1482,7 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struct file *f, char __user *buf,
 
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gfxoff_read);
 
 static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char __user *buf,
 						 size_t size, loff_t *pos)
@@ -1506,12 +1524,13 @@ static ssize_t amdgpu_debugfs_gfxoff_status_read(struct file *f, char __user *bu
 
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_gfxoff_status_read);
 
 static const struct file_operations amdgpu_debugfs_regs2_fops = {
 	.owner = THIS_MODULE,
 	.unlocked_ioctl = amdgpu_debugfs_regs2_ioctl,
-	.read = amdgpu_debugfs_regs2_read,
-	.write = amdgpu_debugfs_regs2_write,
+	.read_iter = amdgpu_debugfs_regs2_read_iter,
+	.write_iter = amdgpu_debugfs_regs2_write_iter,
 	.open = amdgpu_debugfs_regs2_open,
 	.release = amdgpu_debugfs_regs2_release,
 	.llseek = default_llseek
@@ -1520,7 +1539,7 @@ static const struct file_operations amdgpu_debugfs_regs2_fops = {
 static const struct file_operations amdgpu_debugfs_gprwave_fops = {
 	.owner = THIS_MODULE,
 	.unlocked_ioctl = amdgpu_debugfs_gprwave_ioctl,
-	.read = amdgpu_debugfs_gprwave_read,
+	.read_iter = amdgpu_debugfs_gprwave_read_iter,
 	.open = amdgpu_debugfs_gprwave_open,
 	.release = amdgpu_debugfs_gprwave_release,
 	.llseek = default_llseek
@@ -1528,75 +1547,75 @@ static const struct file_operations amdgpu_debugfs_gprwave_fops = {
 
 static const struct file_operations amdgpu_debugfs_regs_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_regs_read,
-	.write = amdgpu_debugfs_regs_write,
+	.read_iter = amdgpu_debugfs_regs_read_iter,
+	.write_iter = amdgpu_debugfs_regs_write_iter,
 	.llseek = default_llseek
 };
 static const struct file_operations amdgpu_debugfs_regs_didt_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_regs_didt_read,
-	.write = amdgpu_debugfs_regs_didt_write,
+	.read_iter = amdgpu_debugfs_regs_didt_read_iter,
+	.write_iter = amdgpu_debugfs_regs_didt_write_iter,
 	.llseek = default_llseek
 };
 static const struct file_operations amdgpu_debugfs_regs_pcie_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_regs_pcie_read,
-	.write = amdgpu_debugfs_regs_pcie_write,
+	.read_iter = amdgpu_debugfs_regs_pcie_read_iter,
+	.write_iter = amdgpu_debugfs_regs_pcie_write_iter,
 	.llseek = default_llseek
 };
 static const struct file_operations amdgpu_debugfs_regs_smc_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_regs_smc_read,
-	.write = amdgpu_debugfs_regs_smc_write,
+	.read_iter = amdgpu_debugfs_regs_smc_read_iter,
+	.write_iter = amdgpu_debugfs_regs_smc_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_gca_config_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gca_config_read,
+	.read_iter = amdgpu_debugfs_gca_config_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_sensors_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_sensor_read,
+	.read_iter = amdgpu_debugfs_sensor_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_wave_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_wave_read,
+	.read_iter = amdgpu_debugfs_wave_read_iter,
 	.llseek = default_llseek
 };
 static const struct file_operations amdgpu_debugfs_gpr_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gpr_read,
+	.read_iter = amdgpu_debugfs_gpr_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_gfxoff_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gfxoff_read,
-	.write = amdgpu_debugfs_gfxoff_write,
+	.read_iter = amdgpu_debugfs_gfxoff_read_iter,
+	.write_iter = amdgpu_debugfs_gfxoff_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_gfxoff_status_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gfxoff_status_read,
+	.read_iter = amdgpu_debugfs_gfxoff_status_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_gfxoff_count_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gfxoff_count_read,
+	.read_iter = amdgpu_debugfs_gfxoff_count_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_debugfs_gfxoff_residency_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_gfxoff_residency_read,
-	.write = amdgpu_debugfs_gfxoff_residency_write,
+	.read_iter = amdgpu_debugfs_gfxoff_residency_read_iter,
+	.write_iter = amdgpu_debugfs_gfxoff_residency_write_iter,
 	.llseek = default_llseek
 };
 
@@ -2058,6 +2077,7 @@ static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,
 
 	return len;
 }
+FOPS_READ_ITER_HELPER(amdgpu_reset_dump_register_list_read);
 
 static ssize_t amdgpu_reset_dump_register_list_write(struct file *f,
 			const char __user *buf, size_t size, loff_t *pos)
@@ -2111,11 +2131,12 @@ static ssize_t amdgpu_reset_dump_register_list_write(struct file *f,
 	kfree(new);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_reset_dump_register_list_write);
 
 static const struct file_operations amdgpu_reset_dump_register_list = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_reset_dump_register_list_read,
-	.write = amdgpu_reset_dump_register_list_write,
+	.read_iter = amdgpu_reset_dump_register_list_read_iter,
+	.write_iter = amdgpu_reset_dump_register_list_write_iter,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.c
index 2d4b67175b55..a5edb6de1c10 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fw_attestation.c
@@ -50,23 +50,22 @@ struct FW_ATT_RECORD {
 	uint32_t AttFwTaId;              /* Ta ID (only in TA Attestation Table) */
 };
 
-static ssize_t amdgpu_fw_attestation_debugfs_read(struct file *f,
-						  char __user *buf,
-						  size_t size,
-						  loff_t *pos)
+static ssize_t amdgpu_fw_attestation_debugfs_read(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	uint64_t records_addr = 0;
 	uint64_t vram_pos = 0;
 	struct FW_ATT_DB_HEADER fw_att_hdr = {0};
 	struct FW_ATT_RECORD fw_att_record = {0};
+	size_t size = iov_iter_count(to);
 
 	if (size < sizeof(struct FW_ATT_RECORD)) {
 		DRM_WARN("FW attestation input buffer not enough memory");
 		return -EINVAL;
 	}
 
-	if ((*pos + sizeof(struct FW_ATT_DB_HEADER)) >= FW_ATTESTATION_MAX_SIZE) {
+	if ((iocb->ki_pos + sizeof(struct FW_ATT_DB_HEADER)) >= FW_ATTESTATION_MAX_SIZE) {
 		DRM_WARN("FW attestation out of bounds");
 		return 0;
 	}
@@ -78,7 +77,7 @@ static ssize_t amdgpu_fw_attestation_debugfs_read(struct file *f,
 
 	vram_pos =  records_addr - adev->gmc.vram_start;
 
-	if (*pos == 0) {
+	if (iocb->ki_pos == 0) {
 		amdgpu_device_vram_access(adev,
 					  vram_pos,
 					  (uint32_t *)&fw_att_hdr,
@@ -94,7 +93,7 @@ static ssize_t amdgpu_fw_attestation_debugfs_read(struct file *f,
 	}
 
 	amdgpu_device_vram_access(adev,
-				  vram_pos + sizeof(struct FW_ATT_DB_HEADER) + *pos,
+				  vram_pos + sizeof(struct FW_ATT_DB_HEADER) + iocb->ki_pos,
 				  (uint32_t *)&fw_att_record,
 				  sizeof(struct FW_ATT_RECORD),
 				  false);
@@ -102,18 +101,16 @@ static ssize_t amdgpu_fw_attestation_debugfs_read(struct file *f,
 	if (fw_att_record.RecordValid != FW_ATTESTATION_RECORD_VALID)
 		return 0;
 
-	if (copy_to_user(buf, (void *)&fw_att_record, sizeof(struct FW_ATT_RECORD)))
+	if (!copy_to_iter_full((void *)&fw_att_record, sizeof(struct FW_ATT_RECORD), to))
 		return -EINVAL;
 
-	*pos += sizeof(struct FW_ATT_RECORD);
-
+	iocb->ki_pos += sizeof(struct FW_ATT_RECORD);
 	return sizeof(struct FW_ATT_RECORD);
 }
 
 static const struct file_operations amdgpu_fw_attestation_debugfs_ops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_fw_attestation_debugfs_read,
-	.write = NULL,
+	.read_iter = amdgpu_fw_attestation_debugfs_read,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
index 24ad4b97177b..c6a971a260df 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
@@ -480,7 +480,7 @@ static int mca_dump_ce_open(struct inode *inode, struct file *file)
 static const struct file_operations mca_ce_dump_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = mca_dump_ce_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -498,7 +498,7 @@ static int mca_dump_ue_open(struct inode *inode, struct file *file)
 static const struct file_operations mca_ue_dump_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = mca_dump_ue_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
index ca5c86e5f7cd..f96fde084fc6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
@@ -26,12 +26,9 @@
 
 #if defined(CONFIG_DEBUG_FS)
 
-static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf,
-					    size_t len, loff_t *off);
-static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf,
-					    size_t len, loff_t *off);
-static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf,
-					    size_t len, loff_t *off);
+static ssize_t ta_if_load_debugfs_write_iter(struct kiocb *, struct iov_iter *);
+static ssize_t ta_if_unload_debugfs_write_iter(struct kiocb *, struct iov_iter *);
+static ssize_t ta_if_invoke_debugfs_write_iter(struct kiocb *, struct iov_iter *);
 
 static uint32_t get_bin_version(const uint8_t *bin)
 {
@@ -84,19 +81,19 @@ static void set_ta_context_funcs(struct psp_context *psp,
 }
 
 static const struct file_operations ta_load_debugfs_fops = {
-	.write  = ta_if_load_debugfs_write,
+	.write_iter  = ta_if_load_debugfs_write_iter,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
 
 static const struct file_operations ta_unload_debugfs_fops = {
-	.write  = ta_if_unload_debugfs_write,
+	.write_iter  = ta_if_unload_debugfs_write_iter,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
 
 static const struct file_operations ta_invoke_debugfs_fops = {
-	.write  = ta_if_invoke_debugfs_write,
+	.write_iter  = ta_if_invoke_debugfs_write_iter,
 	.llseek = default_llseek,
 	.owner  = THIS_MODULE
 };
@@ -240,6 +237,7 @@ static ssize_t ta_if_load_debugfs_write(struct file *fp, const char *buf, size_t
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ta_if_load_debugfs_write);
 
 static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf, size_t len, loff_t *off)
 {
@@ -286,6 +284,7 @@ static ssize_t ta_if_unload_debugfs_write(struct file *fp, const char *buf, size
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ta_if_unload_debugfs_write);
 
 static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size_t len, loff_t *off)
 {
@@ -370,6 +369,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ta_if_invoke_debugfs_write);
 
 void amdgpu_ta_if_debugfs_init(struct amdgpu_device *adev)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c
index 123bcf5c2bb1..b946c94972b2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c
@@ -40,21 +40,22 @@
  * from header file ta_rap_if.h
  *
  */
-static ssize_t amdgpu_rap_debugfs_write(struct file *f, const char __user *buf,
-		size_t size, loff_t *pos)
+static ssize_t amdgpu_rap_debugfs_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	struct ta_rap_shared_memory *rap_shared_mem;
 	struct ta_rap_cmd_output_data *rap_cmd_output;
 	struct drm_device *dev = adev_to_drm(adev);
+	size_t size = iov_iter_count(from);
 	uint32_t op;
 	enum ta_rap_status status;
 	int ret;
 
-	if (*pos || size != 2)
+	if (iocb->ki_pos || size != 2)
 		return -EINVAL;
 
-	ret = kstrtouint_from_user(buf, size, *pos, &op);
+	ret = kstrtouint_from_iter(from, size, iocb->ki_pos, &op);
 	if (ret)
 		return ret;
 
@@ -109,8 +110,7 @@ static ssize_t amdgpu_rap_debugfs_write(struct file *f, const char __user *buf,
 
 static const struct file_operations amdgpu_rap_debugfs_ops = {
 	.owner = THIS_MODULE,
-	.read = NULL,
-	.write = amdgpu_rap_debugfs_write,
+	.write_iter = amdgpu_rap_debugfs_write,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 8ebab6f22e5a..f8daf833f0c4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -201,13 +201,13 @@ static int amdgpu_reserve_page_direct(struct amdgpu_device *adev, uint64_t addre
 	return 0;
 }
 
-static ssize_t amdgpu_ras_debugfs_read(struct file *f, char __user *buf,
-					size_t size, loff_t *pos)
+static ssize_t amdgpu_ras_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ras_manager *obj = (struct ras_manager *)file_inode(f)->i_private;
+	struct ras_manager *obj = file_inode(iocb->ki_filp)->i_private;
 	struct ras_query_if info = {
 		.head = obj->head,
 	};
+	size_t size = iov_iter_count(to);
 	ssize_t s;
 	char val[128];
 
@@ -224,25 +224,23 @@ static ssize_t amdgpu_ras_debugfs_read(struct file *f, char __user *buf,
 	s = snprintf(val, sizeof(val), "%s: %lu\n%s: %lu\n",
 			"ue", info.ue_count,
 			"ce", info.ce_count);
-	if (*pos >= s)
+	if (iocb->ki_pos >= s)
 		return 0;
 
-	s -= *pos;
+	s -= iocb->ki_pos;
 	s = min_t(u64, s, size);
 
 
-	if (copy_to_user(buf, &val[*pos], s))
+	if (!copy_to_iter_full(&val[iocb->ki_pos], s, to))
 		return -EINVAL;
 
-	*pos += s;
-
+	iocb->ki_pos += s;
 	return s;
 }
 
 static const struct file_operations amdgpu_ras_debugfs_ops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_ras_debugfs_read,
-	.write = NULL,
+	.read_iter = amdgpu_ras_debugfs_read,
 	.llseek = default_llseek
 };
 
@@ -541,6 +539,7 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,
 
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_ras_debugfs_ctrl_write);
 
 /**
  * DOC: AMDGPU RAS debugfs EEPROM table reset interface
@@ -558,12 +557,11 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f,
  * will reset EEPROM table to 0 entries.
  *
  */
-static ssize_t amdgpu_ras_debugfs_eeprom_write(struct file *f,
-					       const char __user *buf,
-					       size_t size, loff_t *pos)
+static ssize_t amdgpu_ras_debugfs_eeprom_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct amdgpu_device *adev =
-		(struct amdgpu_device *)file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
+	size_t size = iov_iter_count(from);
 	int ret;
 
 	ret = amdgpu_ras_eeprom_reset_table(
@@ -581,15 +579,13 @@ static ssize_t amdgpu_ras_debugfs_eeprom_write(struct file *f,
 
 static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = {
 	.owner = THIS_MODULE,
-	.read = NULL,
-	.write = amdgpu_ras_debugfs_ctrl_write,
+	.write_iter = amdgpu_ras_debugfs_ctrl_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations amdgpu_ras_debugfs_eeprom_ops = {
 	.owner = THIS_MODULE,
-	.read = NULL,
-	.write = amdgpu_ras_debugfs_eeprom_write,
+	.write_iter = amdgpu_ras_debugfs_eeprom_write,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index b12808c0c331..4d62691e3804 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -1001,12 +1001,12 @@ uint32_t amdgpu_ras_eeprom_max_record_count(struct amdgpu_ras_eeprom_control *co
 }
 
 static ssize_t
-amdgpu_ras_debugfs_eeprom_size_read(struct file *f, char __user *buf,
-				    size_t size, loff_t *pos)
+amdgpu_ras_debugfs_eeprom_size_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 	struct amdgpu_ras_eeprom_control *control = ras ? &ras->eeprom_control : NULL;
+	size_t size = iov_iter_count(to);
 	u8 data[50];
 	int res;
 
@@ -1020,24 +1020,22 @@ amdgpu_ras_debugfs_eeprom_size_read(struct file *f, char __user *buf,
 			       RAS_TBL_SIZE_BYTES, control->ras_max_record_count);
 	}
 
-	if (*pos >= res)
+	if (iocb->ki_pos >= res)
 		return 0;
 
-	res -= *pos;
+	res -= iocb->ki_pos;
 	res = min_t(size_t, res, size);
 
-	if (copy_to_user(buf, &data[*pos], res))
+	if (!copy_to_iter_full(&data[iocb->ki_pos], res, to))
 		return -EFAULT;
 
-	*pos += res;
-
+	iocb->ki_pos += res;
 	return res;
 }
 
 const struct file_operations amdgpu_ras_debugfs_eeprom_size_ops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_ras_debugfs_eeprom_size_read,
-	.write = NULL,
+	.read_iter = amdgpu_ras_debugfs_eeprom_size_read,
 	.llseek = default_llseek,
 };
 
@@ -1215,11 +1213,11 @@ amdgpu_ras_debugfs_eeprom_table_read(struct file *f, char __user *buf,
 		return amdgpu_ras_debugfs_table_read(f, buf, size, pos);
 	}
 }
+FOPS_READ_ITER_HELPER(amdgpu_ras_debugfs_eeprom_table_read);
 
 const struct file_operations amdgpu_ras_debugfs_eeprom_table_ops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_ras_debugfs_eeprom_table_read,
-	.write = NULL,
+	.read_iter = amdgpu_ras_debugfs_eeprom_table_read_iter,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 06f0a6534a94..a03bc2765b88 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -512,10 +512,11 @@ static ssize_t amdgpu_debugfs_ring_read(struct file *f, char __user *buf,
 
 	return result;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_ring_read);
 
 static const struct file_operations amdgpu_debugfs_ring_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_ring_read,
+	.read_iter = amdgpu_debugfs_ring_read_iter,
 	.llseek = default_llseek
 };
 
@@ -577,10 +578,11 @@ static ssize_t amdgpu_debugfs_mqd_read(struct file *f, char __user *buf,
 	kfree(kbuf);
 	return r;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_mqd_read);
 
 static const struct file_operations amdgpu_debugfs_mqd_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_mqd_read,
+	.read_iter = amdgpu_debugfs_mqd_read_iter,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
index 8ed0e073656f..f7bfa470979f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c
@@ -88,23 +88,24 @@ void psp_prep_securedisplay_cmd_buf(struct psp_context *psp, struct ta_securedis
 
 #if defined(CONFIG_DEBUG_FS)
 
-static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __user *buf,
-		size_t size, loff_t *pos)
+static ssize_t amdgpu_securedisplay_debugfs_write(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
-	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	struct psp_context *psp = &adev->psp;
 	struct ta_securedisplay_cmd *securedisplay_cmd;
 	struct drm_device *dev = adev_to_drm(adev);
+	size_t size = iov_iter_count(from);
 	uint32_t phy_id;
 	uint32_t op;
 	char str[64];
 	int ret;
 
-	if (*pos || size > sizeof(str) - 1)
+	if (iocb->ki_pos || size > sizeof(str) - 1)
 		return -EINVAL;
 
 	memset(str,  0, sizeof(str));
-	ret = copy_from_user(str, buf, size);
+	ret = !copy_from_iter_full(str, size, from);
 	if (ret)
 		return -EFAULT;
 
@@ -163,8 +164,7 @@ static ssize_t amdgpu_securedisplay_debugfs_write(struct file *f, const char __u
 
 static const struct file_operations amdgpu_securedisplay_debugfs_ops = {
 	.owner = THIS_MODULE,
-	.read = NULL,
-	.write = amdgpu_securedisplay_debugfs_write,
+	.write_iter = amdgpu_securedisplay_debugfs_write,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fc418e670fda..dd5a73291d85 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2311,30 +2311,29 @@ DEFINE_SHOW_ATTRIBUTE(amdgpu_ttm_page_pool);
  *
  * Accesses VRAM via MMIO for debugging purposes.
  */
-static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
-				    size_t size, loff_t *pos)
+static ssize_t amdgpu_ttm_vram_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
+	size_t size = iov_iter_count(to);
 	ssize_t result = 0;
 
-	if (size & 0x3 || *pos & 0x3)
+	if (size & 0x3 || iocb->ki_pos & 0x3)
 		return -EINVAL;
 
-	if (*pos >= adev->gmc.mc_vram_size)
+	if (iocb->ki_pos >= adev->gmc.mc_vram_size)
 		return -ENXIO;
 
-	size = min(size, (size_t)(adev->gmc.mc_vram_size - *pos));
+	size = min(size, (size_t)(adev->gmc.mc_vram_size - iocb->ki_pos));
 	while (size) {
 		size_t bytes = min(size, AMDGPU_TTM_VRAM_MAX_DW_READ * 4);
 		uint32_t value[AMDGPU_TTM_VRAM_MAX_DW_READ];
 
-		amdgpu_device_vram_access(adev, *pos, value, bytes, false);
-		if (copy_to_user(buf, value, bytes))
+		amdgpu_device_vram_access(adev, iocb->ki_pos, value, bytes, false);
+		if (!copy_to_iter_full(value, bytes, to))
 			return -EFAULT;
 
 		result += bytes;
-		buf += bytes;
-		*pos += bytes;
+		iocb->ki_pos += bytes;
 		size -= bytes;
 	}
 
@@ -2379,11 +2378,12 @@ static ssize_t amdgpu_ttm_vram_write(struct file *f, const char __user *buf,
 
 	return result;
 }
+FOPS_WRITE_ITER_HELPER(amdgpu_ttm_vram_write);
 
 static const struct file_operations amdgpu_ttm_vram_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_ttm_vram_read,
-	.write = amdgpu_ttm_vram_write,
+	.read_iter = amdgpu_ttm_vram_read,
+	.write_iter = amdgpu_ttm_vram_write_iter,
 	.llseek = default_llseek,
 };
 
@@ -2394,10 +2394,10 @@ static const struct file_operations amdgpu_ttm_vram_fops = {
  * GPU and the known addresses are not physical addresses but instead
  * bus addresses (e.g., what you'd put in an IB or ring buffer).
  */
-static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
-				 size_t size, loff_t *pos)
+static ssize_t amdgpu_iomem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
+	size_t size = iov_iter_count(to);
 	struct iommu_domain *dom;
 	ssize_t result = 0;
 	int r;
@@ -2406,8 +2406,8 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
 	dom = iommu_get_domain_for_dev(adev->dev);
 
 	while (size) {
-		phys_addr_t addr = *pos & PAGE_MASK;
-		loff_t off = *pos & ~PAGE_MASK;
+		phys_addr_t addr = iocb->ki_pos & PAGE_MASK;
+		loff_t off = iocb->ki_pos & ~PAGE_MASK;
 		size_t bytes = PAGE_SIZE - off;
 		unsigned long pfn;
 		struct page *p;
@@ -2430,13 +2430,13 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
 			return -EPERM;
 
 		ptr = kmap_local_page(p);
-		r = copy_to_user(buf, ptr + off, bytes);
+		r = !copy_to_iter_full(ptr + off, bytes, to);
 		kunmap_local(ptr);
 		if (r)
 			return -EFAULT;
 
 		size -= bytes;
-		*pos += bytes;
+		iocb->ki_pos += bytes;
 		result += bytes;
 	}
 
@@ -2450,10 +2450,10 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
  * GPU and the known addresses are not physical addresses but instead
  * bus addresses (e.g., what you'd put in an IB or ring buffer).
  */
-static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
-				 size_t size, loff_t *pos)
+static ssize_t amdgpu_iomem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
+	size_t size = iov_iter_count(from);
 	struct iommu_domain *dom;
 	ssize_t result = 0;
 	int r;
@@ -2461,8 +2461,8 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
 	dom = iommu_get_domain_for_dev(adev->dev);
 
 	while (size) {
-		phys_addr_t addr = *pos & PAGE_MASK;
-		loff_t off = *pos & ~PAGE_MASK;
+		phys_addr_t addr = iocb->ki_pos & PAGE_MASK;
+		loff_t off = iocb->ki_pos & ~PAGE_MASK;
 		size_t bytes = PAGE_SIZE - off;
 		unsigned long pfn;
 		struct page *p;
@@ -2481,13 +2481,13 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
 			return -EPERM;
 
 		ptr = kmap_local_page(p);
-		r = copy_from_user(ptr + off, buf, bytes);
+		r = !copy_from_iter_full(ptr + off, bytes, from);
 		kunmap_local(ptr);
 		if (r)
 			return -EFAULT;
 
 		size -= bytes;
-		*pos += bytes;
+		iocb->ki_pos += bytes;
 		result += bytes;
 	}
 
@@ -2496,8 +2496,8 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
 
 static const struct file_operations amdgpu_ttm_iomem_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_iomem_read,
-	.write = amdgpu_iomem_write,
+	.read_iter = amdgpu_iomem_read,
+	.write_iter = amdgpu_iomem_write,
 	.llseek = default_llseek
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 9c514a606a2f..e2596f9fe6f0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -1142,10 +1142,11 @@ static ssize_t amdgpu_debugfs_vcn_fwlog_read(struct file *f, char __user *buf,
 	*pos += read_bytes;
 	return read_bytes;
 }
+FOPS_READ_ITER_HELPER(amdgpu_debugfs_vcn_fwlog_read);
 
 static const struct file_operations amdgpu_debugfs_vcnfwlog_fops = {
 	.owner = THIS_MODULE,
-	.read = amdgpu_debugfs_vcn_fwlog_read,
+	.read_iter = amdgpu_debugfs_vcn_fwlog_read_iter,
 	.llseek = default_llseek
 };
 #endif
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
index 4a5a0a4e00f2..1f03e7915b99 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debugfs.c
@@ -40,9 +40,10 @@ static int kfd_debugfs_hang_hws_read(struct seq_file *m, void *data)
 	return 0;
 }
 
-static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
-	const char __user *user_buf, size_t size, loff_t *ppos)
+static ssize_t kfd_debugfs_hang_hws_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
+	size_t size = iov_iter_count(from);
 	struct kfd_node *dev;
 	char tmp[16];
 	uint32_t gpu_id;
@@ -53,7 +54,7 @@ static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
 		pr_err("Invalid input for gpu id.\n");
 		goto out;
 	}
-	if (copy_from_user(tmp, user_buf, size)) {
+	if (!copy_from_iter_full(tmp, size, from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -75,7 +76,7 @@ static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
 static const struct file_operations kfd_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = kfd_debugfs_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -83,8 +84,8 @@ static const struct file_operations kfd_debugfs_fops = {
 static const struct file_operations kfd_debugfs_hang_hws_fops = {
 	.owner = THIS_MODULE,
 	.open = kfd_debugfs_open,
-	.read = seq_read,
-	.write = kfd_debugfs_hang_hws_write,
+	.read_iter = seq_read_iter,
+	.write_iter = kfd_debugfs_hang_hws_write,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
index 06ac835190f9..04eba7e9dfae 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c
@@ -46,9 +46,8 @@ struct kfd_smi_client {
 #define MAX_KFIFO_SIZE	1024
 
 static __poll_t kfd_smi_ev_poll(struct file *, struct poll_table_struct *);
-static ssize_t kfd_smi_ev_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t kfd_smi_ev_write(struct file *, const char __user *, size_t,
-				loff_t *);
+static ssize_t kfd_smi_ev_read_iter(struct kiocb *, struct iov_iter *);
+static ssize_t kfd_smi_ev_write(struct kiocb *, struct iov_iter *);
 static int kfd_smi_ev_release(struct inode *, struct file *);
 
 static const char kfd_smi_name[] = "kfd_smi_ev";
@@ -56,8 +55,8 @@ static const char kfd_smi_name[] = "kfd_smi_ev";
 static const struct file_operations kfd_smi_ev_fops = {
 	.owner = THIS_MODULE,
 	.poll = kfd_smi_ev_poll,
-	.read = kfd_smi_ev_read,
-	.write = kfd_smi_ev_write,
+	.read_iter = kfd_smi_ev_read_iter,
+	.write_iter = kfd_smi_ev_write,
 	.release = kfd_smi_ev_release
 };
 
@@ -121,16 +120,14 @@ static ssize_t kfd_smi_ev_read(struct file *filep, char __user *user,
 	kfree(buf);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(kfd_smi_ev_read);
 
-static ssize_t kfd_smi_ev_write(struct file *filep, const char __user *user,
-				size_t size, loff_t *offset)
+static ssize_t kfd_smi_ev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct kfd_smi_client *client = filep->private_data;
+	struct kfd_smi_client *client = iocb->ki_filp->private_data;
 	uint64_t events;
 
-	if (!access_ok(user, size) || size < sizeof(events))
-		return -EFAULT;
-	if (copy_from_user(&events, user, sizeof(events)))
+	if (!copy_from_iter_full(&events, sizeof(events), from))
 		return -EFAULT;
 
 	WRITE_ONCE(client->events, events);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index eee4945653e2..ee1bd4372074 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -249,6 +249,7 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_link_settings_read);
 
 static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
 				 size_t size, loff_t *pos)
@@ -336,6 +337,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_link_settings_write);
 
 static bool dp_mst_is_end_device(struct amdgpu_dm_connector *aconnector)
 {
@@ -483,6 +485,7 @@ static ssize_t dp_mst_link_setting(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_mst_link_setting);
 
 /* function: get current DP PHY settings: voltage swing, pre-emphasis,
  * post-cursor2 (defined by VESA DP specification)
@@ -566,6 +569,7 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_phy_settings_read);
 
 static int dp_lttpr_status_show(struct seq_file *m, void *unused)
 {
@@ -686,6 +690,7 @@ static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_phy_settings_write);
 
 /* function description
  *
@@ -892,6 +897,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us
 
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_phy_test_pattern_debugfs_write);
 
 /*
  * Returns the DMCUB tracebuffer contents.
@@ -1149,6 +1155,7 @@ static ssize_t dp_dsc_passthrough_set(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return 0;
 }
+FOPS_WRITE_ITER_HELPER(dp_dsc_passthrough_set);
 
 /*
  * Returns the HDCP capability of the Display (1.4 for now).
@@ -1270,6 +1277,7 @@ static ssize_t dp_sdp_message_debugfs_write(struct file *f, const char __user *b
 
 	return write_size;
 }
+FOPS_WRITE_ITER_HELPER(dp_sdp_message_debugfs_write);
 
 /* function: Read link's DSC & FEC capabilities
  *
@@ -1456,6 +1464,7 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
 
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(trigger_hotplug);
 
 /* function: read DSC status on the connector
  *
@@ -1527,6 +1536,7 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_clock_en_read);
 
 /* function: write force DSC on the connector
  *
@@ -1641,6 +1651,7 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_dsc_clock_en_write);
 
 /* function: read DSC slice width parameter on the connector
  *
@@ -1713,6 +1724,7 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_slice_width_read);
 
 /* function: write DSC slice width parameter
  *
@@ -1825,6 +1837,7 @@ static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_dsc_slice_width_write);
 
 /* function: read DSC slice height parameter on the connector
  *
@@ -1897,6 +1910,7 @@ static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_slice_height_read);
 
 /* function: write DSC slice height parameter
  *
@@ -2009,6 +2023,7 @@ static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_dsc_slice_height_write);
 
 /* function: read DSC target rate on the connector in bits per pixel
  *
@@ -2077,6 +2092,7 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_bits_per_pixel_read);
 
 /* function: write DSC target rate in bits per pixel
  *
@@ -2181,6 +2197,7 @@ static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *bu
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_dsc_bits_per_pixel_write);
 
 /* function: read DSC picture width parameter on the connector
  *
@@ -2252,6 +2269,7 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_pic_width_read);
 
 static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
 				    size_t size, loff_t *pos)
@@ -2308,6 +2326,7 @@ static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_pic_height_read);
 
 /* function: read DSC chunk size parameter on the connector
  *
@@ -2379,6 +2398,7 @@ static ssize_t dp_dsc_chunk_size_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dp_dsc_chunk_size_read);
 
 /* function: read DSC slice bpg offset on the connector
  *
@@ -2450,7 +2470,7 @@ static ssize_t dp_dsc_slice_bpg_offset_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
-
+FOPS_READ_ITER_HELPER(dp_dsc_slice_bpg_offset_read);
 
 /*
  * function description: Read max_requested_bpc property from the connector
@@ -2511,7 +2531,7 @@ static ssize_t dp_max_bpc_read(struct file *f, char __user *buf,
 	kfree(rd_buf);
 	return result;
 }
-
+FOPS_READ_ITER_HELPER(dp_max_bpc_read);
 
 /*
  * function description: Set max_requested_bpc property on the connector
@@ -2593,6 +2613,7 @@ static ssize_t dp_max_bpc_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(dp_max_bpc_write);
 
 /*
  * Backlight at this moment.  Read only.
@@ -2751,104 +2772,104 @@ DEFINE_SHOW_ATTRIBUTE(is_dpia_link);
 
 static const struct file_operations dp_dsc_clock_en_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_clock_en_read,
-	.write = dp_dsc_clock_en_write,
+	.read_iter = dp_dsc_clock_en_read_iter,
+	.write_iter = dp_dsc_clock_en_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_slice_width_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_slice_width_read,
-	.write = dp_dsc_slice_width_write,
+	.read_iter = dp_dsc_slice_width_read_iter,
+	.write_iter = dp_dsc_slice_width_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_slice_height_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_slice_height_read,
-	.write = dp_dsc_slice_height_write,
+	.read_iter = dp_dsc_slice_height_read_iter,
+	.write_iter = dp_dsc_slice_height_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_bits_per_pixel_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_bits_per_pixel_read,
-	.write = dp_dsc_bits_per_pixel_write,
+	.read_iter = dp_dsc_bits_per_pixel_read_iter,
+	.write_iter = dp_dsc_bits_per_pixel_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_pic_width_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_pic_width_read,
+	.read_iter = dp_dsc_pic_width_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_pic_height_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_pic_height_read,
+	.read_iter = dp_dsc_pic_height_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_chunk_size_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_chunk_size_read,
+	.read_iter = dp_dsc_chunk_size_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_dsc_slice_bpg_offset_read,
+	.read_iter = dp_dsc_slice_bpg_offset_read_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations trigger_hotplug_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.write = trigger_hotplug,
+	.write_iter = trigger_hotplug_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_link_settings_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_link_settings_read,
-	.write = dp_link_settings_write,
+	.read_iter = dp_link_settings_read_iter,
+	.write_iter = dp_link_settings_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_phy_settings_debugfs_fop = {
 	.owner = THIS_MODULE,
-	.read = dp_phy_settings_read,
-	.write = dp_phy_settings_write,
+	.read_iter = dp_phy_settings_read_iter,
+	.write_iter = dp_phy_settings_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_phy_test_pattern_fops = {
 	.owner = THIS_MODULE,
-	.write = dp_phy_test_pattern_debugfs_write,
+	.write_iter = dp_phy_test_pattern_debugfs_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations sdp_message_fops = {
 	.owner = THIS_MODULE,
-	.write = dp_sdp_message_debugfs_write,
+	.write_iter = dp_sdp_message_debugfs_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_max_bpc_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.read = dp_max_bpc_read,
-	.write = dp_max_bpc_write,
+	.read_iter = dp_max_bpc_read_iter,
+	.write_iter = dp_max_bpc_write_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_dsc_disable_passthrough_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.write = dp_dsc_passthrough_set,
+	.write_iter = dp_dsc_passthrough_set_iter,
 	.llseek = default_llseek
 };
 
 static const struct file_operations dp_mst_link_settings_debugfs_fops = {
 	.owner = THIS_MODULE,
-	.write = dp_mst_link_setting,
+	.write_iter = dp_mst_link_setting_iter,
 	.llseek = default_llseek
 };
 
@@ -3275,6 +3296,7 @@ static ssize_t edp_ilr_write(struct file *f, const char __user *buf,
 	kfree(wr_buf);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(edp_ilr_write);
 
 static int edp_ilr_open(struct inode *inode, struct file *file)
 {
@@ -3284,10 +3306,10 @@ static int edp_ilr_open(struct inode *inode, struct file *file)
 static const struct file_operations edp_ilr_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = edp_ilr_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = edp_ilr_write
+	.write_iter = edp_ilr_write_iter
 };
 
 void connector_debugfs_init(struct amdgpu_dm_connector *connector)
@@ -3552,18 +3574,15 @@ void crtc_debugfs_init(struct drm_crtc *crtc)
  * Writes DTN log state to the user supplied buffer.
  * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
  */
-static ssize_t dtn_log_read(
-	struct file *f,
-	char __user *buf,
-	size_t size,
-	loff_t *pos)
+static ssize_t dtn_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	struct dc *dc = adev->dm.dc;
 	struct dc_log_buffer_ctx log_ctx = { 0 };
+	size_t size = iov_iter_count(to);
 	ssize_t result = 0;
 
-	if (!buf || !size)
+	if (!size)
 		return -EINVAL;
 
 	if (!dc->hwss.log_hw_state)
@@ -3571,13 +3590,13 @@ static ssize_t dtn_log_read(
 
 	dc->hwss.log_hw_state(dc, &log_ctx);
 
-	if (*pos < log_ctx.pos) {
-		size_t to_copy = log_ctx.pos - *pos;
+	if (iocb->ki_pos < log_ctx.pos) {
+		size_t to_copy = log_ctx.pos - iocb->ki_pos;
 
 		to_copy = min(to_copy, size);
 
-		if (!copy_to_user(buf, log_ctx.buf + *pos, to_copy)) {
-			*pos += to_copy;
+		if (copy_to_iter_full(log_ctx.buf + iocb->ki_pos, to_copy, to)) {
+			iocb->ki_pos += to_copy;
 			result = to_copy;
 		}
 	}
@@ -3591,13 +3610,10 @@ static ssize_t dtn_log_read(
  * Writes DTN log state to dmesg when triggered via a write.
  * Example usage: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dtn_log
  */
-static ssize_t dtn_log_write(
-	struct file *f,
-	const char __user *buf,
-	size_t size,
-	loff_t *pos)
+static ssize_t dtn_log_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
+	size_t size = iov_iter_count(from);
 	struct dc *dc = adev->dm.dc;
 
 	/* Write triggers log output via dmesg. */
@@ -3972,18 +3988,19 @@ static ssize_t dcc_en_bits_read(
 	kfree(rd_buf);
 	return result;
 }
+FOPS_READ_ITER_HELPER(dcc_en_bits_read);
 
 void dtn_debugfs_init(struct amdgpu_device *adev)
 {
 	static const struct file_operations dtn_log_fops = {
 		.owner = THIS_MODULE,
-		.read = dtn_log_read,
-		.write = dtn_log_write,
+		.read_iter = dtn_log_read,
+		.write_iter = dtn_log_write,
 		.llseek = default_llseek
 	};
 	static const struct file_operations dcc_en_bits_fops = {
 		.owner = THIS_MODULE,
-		.read = dcc_en_bits_read,
+		.read_iter = dcc_en_bits_read_iter,
 		.llseek = default_llseek
 	};
 
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index f09b9d49297e..d78f7b351f7d 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -4572,10 +4572,9 @@ DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_pm_info);
  *
  * Reads debug memory region allocated to PMFW
  */
-static ssize_t amdgpu_pm_prv_buffer_read(struct file *f, char __user *buf,
-					 size_t size, loff_t *pos)
+static ssize_t amdgpu_pm_prv_buffer_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = file_inode(f)->i_private;
+	struct amdgpu_device *adev = file_inode(iocb->ki_filp)->i_private;
 	size_t smu_prv_buf_size;
 	void *smu_prv_buf;
 	int ret = 0;
@@ -4592,14 +4591,14 @@ static ssize_t amdgpu_pm_prv_buffer_read(struct file *f, char __user *buf,
 	if (!smu_prv_buf || !smu_prv_buf_size)
 		return -EINVAL;
 
-	return simple_read_from_buffer(buf, size, pos, smu_prv_buf,
-				       smu_prv_buf_size);
+	return simple_copy_to_iter(smu_prv_buf, &iocb->ki_pos,
+					smu_prv_buf_size, to);
 }
 
 static const struct file_operations amdgpu_debugfs_pm_prv_buffer_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = amdgpu_pm_prv_buffer_read,
+	.read_iter = amdgpu_pm_prv_buffer_read,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 246b211b1e85..04332432e57f 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -3603,20 +3603,13 @@ static int smu_stb_debugfs_open(struct inode *inode, struct file *filp)
 	return r;
 }
 
-static ssize_t smu_stb_debugfs_read(struct file *filp, char __user *buf, size_t size,
-				loff_t *pos)
+static ssize_t smu_stb_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct amdgpu_device *adev = filp->f_inode->i_private;
+	struct amdgpu_device *adev = iocb->ki_filp->f_inode->i_private;
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-
-	if (!filp->private_data)
-		return -EINVAL;
-
-	return simple_read_from_buffer(buf,
-				       size,
-				       pos, filp->private_data,
-				       smu->stb_context.stb_buf_size);
+	return simple_copy_to_iter(adev, &iocb->ki_pos,
+				       smu->stb_context.stb_buf_size, to);
 }
 
 static int smu_stb_debugfs_release(struct inode *inode, struct file *filp)
@@ -3637,7 +3630,7 @@ static int smu_stb_debugfs_release(struct inode *inode, struct file *filp)
 static const struct file_operations smu_stb_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = smu_stb_debugfs_open,
-	.read = smu_stb_debugfs_read,
+	.read_iter = smu_stb_debugfs_read,
 	.release = smu_stb_debugfs_release,
 	.llseek = default_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 140/437] drm: msm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (138 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 139/437] drm: amd: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 141/437] drm: nouveau: " Jens Axboe
                   ` (297 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 20 +++++++++----------
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c       | 20 +++++++++----------
 drivers/gpu/drm/msm/dp/dp_debug.c             | 15 +++++++-------
 drivers/gpu/drm/msm/msm_debugfs.c             |  4 ++--
 drivers/gpu/drm/msm/msm_perf.c                | 12 +++++------
 drivers/gpu/drm/msm/msm_rd.c                  | 12 +++++------
 6 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
index ef871239adb2..c8971ba26cd4 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c
@@ -398,14 +398,15 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,
 
 #ifdef CONFIG_DEBUG_FS
 
-static ssize_t _dpu_core_perf_mode_write(struct file *file,
-		    const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t _dpu_core_perf_mode_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct dpu_core_perf *perf = file->private_data;
+	struct dpu_core_perf *perf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 perf_mode = 0;
 	int ret;
 
-	ret = kstrtouint_from_user(user_buf, count, 0, &perf_mode);
+	ret = kstrtouint_from_iter(from, count, 0, &perf_mode);
 	if (ret)
 		return ret;
 
@@ -426,10 +427,9 @@ static ssize_t _dpu_core_perf_mode_write(struct file *file,
 	return count;
 }
 
-static ssize_t _dpu_core_perf_mode_read(struct file *file,
-			char __user *buff, size_t count, loff_t *ppos)
+static ssize_t _dpu_core_perf_mode_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dpu_core_perf *perf = file->private_data;
+	struct dpu_core_perf *perf = iocb->ki_filp->private_data;
 	int len;
 	char buf[128];
 
@@ -437,13 +437,13 @@ static ssize_t _dpu_core_perf_mode_read(struct file *file,
 			"mode %d\n",
 			perf->perf_tune.mode);
 
-	return simple_read_from_buffer(buff, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations dpu_core_perf_mode_fops = {
 	.open = simple_open,
-	.read = _dpu_core_perf_mode_read,
-	.write = _dpu_core_perf_mode_write,
+	.read_iter = _dpu_core_perf_mode_read,
+	.write_iter = _dpu_core_perf_mode_write,
 };
 
 int dpu_core_perf_debugfs_init(struct dpu_kms *dpu_kms, struct dentry *parent)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index a1f5d7c4ab91..0c1484439229 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -105,16 +105,15 @@ static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_safe_stats);
 
-static ssize_t _dpu_plane_danger_read(struct file *file,
-			char __user *buff, size_t count, loff_t *ppos)
+static ssize_t _dpu_plane_danger_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dpu_kms *kms = file->private_data;
+	struct dpu_kms *kms = iocb->ki_filp->private_data;
 	int len;
 	char buf[40];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", !kms->has_danger_ctrl);
 
-	return simple_read_from_buffer(buff, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static void _dpu_plane_set_danger_state(struct dpu_kms *kms, bool enable)
@@ -140,14 +139,15 @@ static void _dpu_plane_set_danger_state(struct dpu_kms *kms, bool enable)
 	}
 }
 
-static ssize_t _dpu_plane_danger_write(struct file *file,
-		    const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t _dpu_plane_danger_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct dpu_kms *kms = file->private_data;
+	struct dpu_kms *kms = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int disable_panic;
 	int ret;
 
-	ret = kstrtouint_from_user(user_buf, count, 0, &disable_panic);
+	ret = kstrtouint_from_iter(from, count, 0, &disable_panic);
 	if (ret)
 		return ret;
 
@@ -168,8 +168,8 @@ static ssize_t _dpu_plane_danger_write(struct file *file,
 
 static const struct file_operations dpu_plane_danger_enable = {
 	.open = simple_open,
-	.read = _dpu_plane_danger_read,
-	.write = _dpu_plane_danger_write,
+	.read_iter = _dpu_plane_danger_read,
+	.write_iter = _dpu_plane_danger_write,
 };
 
 static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c
index eca5a02f9003..7589f40309ff 100644
--- a/drivers/gpu/drm/msm/dp/dp_debug.c
+++ b/drivers/gpu/drm/msm/dp/dp_debug.c
@@ -123,23 +123,22 @@ static int dp_test_type_show(struct seq_file *m, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(dp_test_type);
 
-static ssize_t dp_test_active_write(struct file *file,
-		const char __user *ubuf,
-		size_t len, loff_t *offp)
+static ssize_t dp_test_active_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *input_buffer;
 	int status = 0;
 	const struct dp_debug_private *debug;
 	const struct drm_connector *connector;
+	size_t len = iov_iter_count(from);
 	int val = 0;
 
-	debug = ((struct seq_file *)file->private_data)->private;
+	debug = ((struct seq_file *)iocb->ki_filp->private_data)->private;
 	connector = debug->connector;
 
 	if (len == 0)
 		return 0;
 
-	input_buffer = memdup_user_nul(ubuf, len);
+	input_buffer = iterdup_nul(from, len);
 	if (IS_ERR(input_buffer))
 		return PTR_ERR(input_buffer);
 
@@ -162,7 +161,7 @@ static ssize_t dp_test_active_write(struct file *file,
 	}
 	kfree(input_buffer);
 
-	*offp += len;
+	iocb->ki_pos += len;
 	return len;
 }
 
@@ -193,10 +192,10 @@ static int dp_test_active_open(struct inode *inode,
 static const struct file_operations test_active_fops = {
 	.owner = THIS_MODULE,
 	.open = dp_test_active_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = dp_test_active_write
+	.write_iter = dp_test_active_write,
 };
 
 static void dp_debug_init(struct dp_debug *dp_debug, struct dentry *root, bool is_edp)
diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c
index 4494f6d1c7cb..237bb6dace46 100644
--- a/drivers/gpu/drm/msm/msm_debugfs.c
+++ b/drivers/gpu/drm/msm/msm_debugfs.c
@@ -112,7 +112,7 @@ static int msm_gpu_open(struct inode *inode, struct file *file)
 static const struct file_operations msm_gpu_fops = {
 	.owner = THIS_MODULE,
 	.open = msm_gpu_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = msm_gpu_release,
 };
@@ -175,7 +175,7 @@ static int msm_kms_open(struct inode *inode, struct file *file)
 static const struct file_operations msm_kms_fops = {
 	.owner = THIS_MODULE,
 	.open = msm_kms_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = msm_kms_release,
 };
diff --git a/drivers/gpu/drm/msm/msm_perf.c b/drivers/gpu/drm/msm/msm_perf.c
index 3d3da79fec2a..494d714ce6a2 100644
--- a/drivers/gpu/drm/msm/msm_perf.c
+++ b/drivers/gpu/drm/msm/msm_perf.c
@@ -117,10 +117,10 @@ static int refill_buf(struct msm_perf_state *perf)
 	return 0;
 }
 
-static ssize_t perf_read(struct file *file, char __user *buf,
-		size_t sz, loff_t *ppos)
+static ssize_t perf_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct msm_perf_state *perf = file->private_data;
+	struct msm_perf_state *perf = iocb->ki_filp->private_data;
+	size_t sz = iov_iter_count(to);
 	int n = 0, ret = 0;
 
 	mutex_lock(&perf->read_lock);
@@ -132,13 +132,13 @@ static ssize_t perf_read(struct file *file, char __user *buf,
 	}
 
 	n = min((int)sz, perf->buftot - perf->bufpos);
-	if (copy_to_user(buf, &perf->buf[perf->bufpos], n)) {
+	if (!copy_to_iter_full(&perf->buf[perf->bufpos], n, to)) {
 		ret = -EFAULT;
 		goto out;
 	}
 
 	perf->bufpos += n;
-	*ppos += n;
+	iocb->ki_pos += n;
 
 out:
 	mutex_unlock(&perf->read_lock);
@@ -191,7 +191,7 @@ static int perf_release(struct inode *inode, struct file *file)
 static const struct file_operations perf_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = perf_open,
-	.read = perf_read,
+	.read_iter = perf_read,
 	.llseek = no_llseek,
 	.release = perf_release,
 };
diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
index ca44fd291c5b..d5f65377ba65 100644
--- a/drivers/gpu/drm/msm/msm_rd.c
+++ b/drivers/gpu/drm/msm/msm_rd.c
@@ -130,12 +130,12 @@ static void rd_write_section(struct msm_rd_state *rd,
 	rd_write(rd, buf, sz);
 }
 
-static ssize_t rd_read(struct file *file, char __user *buf,
-		size_t sz, loff_t *ppos)
+static ssize_t rd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct msm_rd_state *rd = file->private_data;
+	struct msm_rd_state *rd = iocb->ki_filp->private_data;
 	struct circ_buf *fifo = &rd->fifo;
 	const char *fptr = &fifo->buf[fifo->tail];
+	size_t sz = iov_iter_count(to);
 	int n = 0, ret = 0;
 
 	mutex_lock(&rd->read_lock);
@@ -150,13 +150,13 @@ static ssize_t rd_read(struct file *file, char __user *buf,
 	 * once.
 	 */
 	n = min_t(int, sz, circ_count_to_end(&rd->fifo));
-	if (copy_to_user(buf, fptr, n)) {
+	if (!copy_to_iter_full(fptr, n, to)) {
 		ret = -EFAULT;
 		goto out;
 	}
 
 	smp_store_release(&fifo->tail, (fifo->tail + n) & (BUF_SZ - 1));
-	*ppos += n;
+	iocb->ki_pos += n;
 
 	wake_up_all(&rd->fifo_event);
 
@@ -226,7 +226,7 @@ static int rd_release(struct inode *inode, struct file *file)
 static const struct file_operations rd_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = rd_open,
-	.read = rd_read,
+	.read_iter = rd_read,
 	.llseek = no_llseek,
 	.release = rd_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 141/437] drm: nouveau: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (139 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 140/437] drm: msm: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 142/437] drm: mipi: " Jens Axboe
                   ` (296 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/nouveau/dispnv50/crc.c    | 13 ++++++-------
 drivers/gpu/drm/nouveau/nouveau_debugfs.c | 12 ++++++------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/crc.c b/drivers/gpu/drm/nouveau/dispnv50/crc.c
index 9c942fbd836d..a7859e3cb39d 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crc.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crc.c
@@ -648,11 +648,9 @@ nv50_crc_debugfs_flip_threshold_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-nv50_crc_debugfs_flip_threshold_set(struct file *file,
-				    const char __user *ubuf, size_t len,
-				    loff_t *offp)
+nv50_crc_debugfs_flip_threshold_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct nv50_head *head = m->private;
 	struct nv50_head_atom *armh;
 	struct drm_crtc *crtc = &head->base.base;
@@ -660,9 +658,10 @@ nv50_crc_debugfs_flip_threshold_set(struct file *file,
 	struct nv50_crc *crc = &head->crc;
 	const struct nv50_crc_func *func =
 		nv50_disp(crtc->dev)->core->func->crc;
+	size_t len = iov_iter_count(from);
 	int value, ret;
 
-	ret = kstrtoint_from_user(ubuf, len, 10, &value);
+	ret = kstrtoint_from_iter(from, len, 10, &value);
 	if (ret)
 		return ret;
 
@@ -697,8 +696,8 @@ nv50_crc_debugfs_flip_threshold_set(struct file *file,
 static const struct file_operations nv50_crc_flip_threshold_fops = {
 	.owner = THIS_MODULE,
 	.open = nv50_crc_debugfs_flip_threshold_open,
-	.read = seq_read,
-	.write = nv50_crc_debugfs_flip_threshold_set,
+	.read_iter = seq_read_iter,
+	.write_iter = nv50_crc_debugfs_flip_threshold_set,
 	.release = single_release,
 };
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index e83db051e851..02cfac6f6c39 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -139,14 +139,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
 }
 
 static ssize_t
-nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
-			   size_t len, loff_t *offp)
+nouveau_debugfs_pstate_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_device *drm = m->private;
 	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
 	struct nvif_control_pstate_user_v0 args = { .pwrsrc = -EINVAL };
 	char buf[32] = {}, *tmp, *cur = buf;
+	size_t len = iov_iter_count(from);
 	long value, ret;
 
 	if (!debugfs)
@@ -155,7 +155,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf,
 	if (len >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	if ((tmp = strchr(buf, '\n')))
@@ -244,8 +244,8 @@ nouveau_debugfs_gpuva(struct seq_file *m, void *data)
 static const struct file_operations nouveau_pstate_fops = {
 	.owner = THIS_MODULE,
 	.open = nouveau_debugfs_pstate_open,
-	.read = seq_read,
-	.write = nouveau_debugfs_pstate_set,
+	.read_iter = seq_read_iter,
+	.write_iter = nouveau_debugfs_pstate_set,
 	.release = single_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 142/437] drm: mipi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (140 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 141/437] drm: nouveau: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 143/437] drm: mali: " Jens Axboe
                   ` (295 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index daac649aabdb..43198c3b2eed 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -1332,12 +1332,12 @@ EXPORT_SYMBOL(mipi_dbi_spi_transfer);
 
 #ifdef CONFIG_DEBUG_FS
 
-static ssize_t mipi_dbi_debugfs_command_write(struct file *file,
-					      const char __user *ubuf,
-					      size_t count, loff_t *ppos)
+static ssize_t mipi_dbi_debugfs_command_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct mipi_dbi_dev *dbidev = m->private;
+	size_t count = iov_iter_count(from);
 	u8 val, cmd = 0, parameters[64];
 	char *buf, *pos, *token;
 	int i, ret, idx;
@@ -1345,7 +1345,7 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file,
 	if (!drm_dev_enter(&dbidev->drm, &idx))
 		return -ENODEV;
 
-	buf = memdup_user_nul(ubuf, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf)) {
 		ret = PTR_ERR(buf);
 		goto err_exit;
@@ -1446,10 +1446,10 @@ static int mipi_dbi_debugfs_command_open(struct inode *inode,
 static const struct file_operations mipi_dbi_debugfs_command_fops = {
 	.owner = THIS_MODULE,
 	.open = mipi_dbi_debugfs_command_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = mipi_dbi_debugfs_command_write,
+	.write_iter = mipi_dbi_debugfs_command_write,
 };
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 143/437] drm: mali: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (141 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 142/437] drm: mipi: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 144/437] drm/bridge: it6505: " Jens Axboe
                   ` (294 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/arm/malidp_drv.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 6682131d2910..cc0490e3ae4c 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -522,10 +522,9 @@ static int malidp_debugfs_open(struct inode *inode, struct file *file)
 	return single_open(file, malidp_show_stats, inode->i_private);
 }
 
-static ssize_t malidp_debugfs_write(struct file *file, const char __user *ubuf,
-				    size_t len, loff_t *offp)
+static ssize_t malidp_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct drm_device *drm = m->private;
 	struct malidp_drm *malidp = drm_to_malidp(drm);
 	unsigned long irqflags;
@@ -534,14 +533,14 @@ static ssize_t malidp_debugfs_write(struct file *file, const char __user *ubuf,
 	malidp_error_stats_init(&malidp->de_errors);
 	malidp_error_stats_init(&malidp->se_errors);
 	spin_unlock_irqrestore(&malidp->errors_lock, irqflags);
-	return len;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations malidp_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = malidp_debugfs_open,
-	.read = seq_read,
-	.write = malidp_debugfs_write,
+	.read_iter = seq_read_iter,
+	.write_iter = malidp_debugfs_write,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 144/437] drm/bridge: it6505: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (142 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 143/437] drm: mali: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 145/437] drm/imagination: " Jens Axboe
                   ` (293 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 27334173e911..3f280f85d49d 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -3208,14 +3208,14 @@ static void it6505_parse_dt(struct it6505 *it6505)
 			     it6505->max_dpi_pixel_clock);
 }
 
-static ssize_t receive_timing_debugfs_show(struct file *file, char __user *buf,
-					   size_t len, loff_t *ppos)
+static ssize_t receive_timing_debugfs_show(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct it6505 *it6505 = file->private_data;
+	struct it6505 *it6505 = iocb->ki_filp->private_data;
 	struct drm_display_mode *vid;
 	u8 read_buf[READ_BUFFER_SIZE];
 	u8 *str = read_buf, *end = read_buf + READ_BUFFER_SIZE;
-	ssize_t ret, count;
+	ssize_t count;
 
 	if (!it6505)
 		return -ENODEV;
@@ -3243,9 +3243,7 @@ static ssize_t receive_timing_debugfs_show(struct file *file, char __user *buf,
 			 vid->vtotal - vid->vsync_end);
 
 	count = str - read_buf;
-	ret = simple_read_from_buffer(buf, len, ppos, read_buf, count);
-
-	return ret;
+	return simple_copy_to_iter(read_buf, &iocb->ki_pos, count, to);
 }
 
 static int force_power_on_off_debugfs_write(void *data, u64 value)
@@ -3307,7 +3305,7 @@ static int enable_drv_hold_debugfs_write(void *data, u64 drv_hold)
 static const struct file_operations receive_timing_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = receive_timing_debugfs_show,
+	.read_iter = receive_timing_debugfs_show,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 145/437] drm/imagination: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (143 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 144/437] drm/bridge: it6505: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 146/437] drm/loongson: " Jens Axboe
                   ` (292 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/imagination/pvr_fw_trace.c | 2 +-
 drivers/gpu/drm/imagination/pvr_params.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c b/drivers/gpu/drm/imagination/pvr_fw_trace.c
index 31199e45b72e..ff5827dd6390 100644
--- a/drivers/gpu/drm/imagination/pvr_fw_trace.c
+++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c
@@ -438,7 +438,7 @@ static int fw_trace_release(struct inode *inode, struct file *file)
 static const struct file_operations pvr_fw_trace_fops = {
 	.owner = THIS_MODULE,
 	.open = fw_trace_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = fw_trace_release,
 };
diff --git a/drivers/gpu/drm/imagination/pvr_params.c b/drivers/gpu/drm/imagination/pvr_params.c
index b91759f362c5..4fe0105ca0c9 100644
--- a/drivers/gpu/drm/imagination/pvr_params.c
+++ b/drivers/gpu/drm/imagination/pvr_params.c
@@ -119,8 +119,8 @@ static struct {
 		.owner = THIS_MODULE,                      \
 		.open = __pvr_device_param_##name_##_open, \
 		.release = simple_attr_release,            \
-		.read = simple_attr_read,                  \
-		.write = simple_attr_write,                \
+		.read_iter = simple_attr_read_iter,        \
+		.write_iter = simple_attr_write_iter,      \
 		.llseek = generic_file_llseek,             \
 	},
 	PVR_DEVICE_PARAMS
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 146/437] drm/loongson: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (144 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 145/437] drm/imagination: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 147/437] drm/radeon/radeon_ttm: " Jens Axboe
                   ` (291 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/loongson/lsdc_crtc.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c b/drivers/gpu/drm/loongson/lsdc_crtc.c
index 827acab580fa..fde7c8d6cc3d 100644
--- a/drivers/gpu/drm/loongson/lsdc_crtc.c
+++ b/drivers/gpu/drm/loongson/lsdc_crtc.c
@@ -628,20 +628,18 @@ static int lsdc_crtc_man_op_open(struct inode *inode, struct file *file)
 	return single_open(file, lsdc_crtc_man_op_show, crtc);
 }
 
-static ssize_t lsdc_crtc_man_op_write(struct file *file,
-				      const char __user *ubuf,
-				      size_t len,
-				      loff_t *offp)
+static ssize_t lsdc_crtc_man_op_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct lsdc_crtc *lcrtc = m->private;
 	const struct lsdc_crtc_hw_ops *ops = lcrtc->hw_ops;
+	size_t len = iov_iter_count(from);
 	char buf[16];
 
 	if (len > sizeof(buf) - 1)
 		return -EINVAL;
 
-	if (copy_from_user(buf, ubuf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -663,10 +661,10 @@ static ssize_t lsdc_crtc_man_op_write(struct file *file,
 static const struct file_operations lsdc_crtc_man_op_fops = {
 	.owner = THIS_MODULE,
 	.open = lsdc_crtc_man_op_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = lsdc_crtc_man_op_write,
+	.write_iter = lsdc_crtc_man_op_write,
 };
 
 static int lsdc_crtc_late_register(struct drm_crtc *crtc)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 147/437] drm/radeon/radeon_ttm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (145 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 146/437] drm/loongson: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 148/437] drm: armada: " Jens Axboe
                   ` (290 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 40 ++++++++++++++---------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 2078b0000e22..2570babc690c 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -786,37 +786,36 @@ static int radeon_ttm_vram_open(struct inode *inode, struct file *filep)
 	return 0;
 }
 
-static ssize_t radeon_ttm_vram_read(struct file *f, char __user *buf,
-				    size_t size, loff_t *pos)
+static ssize_t radeon_ttm_vram_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct radeon_device *rdev = f->private_data;
+	struct radeon_device *rdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	ssize_t result = 0;
 	int r;
 
-	if (size & 0x3 || *pos & 0x3)
+	if (size & 0x3 || iocb->ki_pos & 0x3)
 		return -EINVAL;
 
 	while (size) {
 		unsigned long flags;
 		uint32_t value;
 
-		if (*pos >= rdev->mc.mc_vram_size)
+		if (iocb->ki_pos >= rdev->mc.mc_vram_size)
 			return result;
 
 		spin_lock_irqsave(&rdev->mmio_idx_lock, flags);
-		WREG32(RADEON_MM_INDEX, ((uint32_t)*pos) | 0x80000000);
+		WREG32(RADEON_MM_INDEX, ((uint32_t)iocb->ki_pos) | 0x80000000);
 		if (rdev->family >= CHIP_CEDAR)
-			WREG32(EVERGREEN_MM_INDEX_HI, *pos >> 31);
+			WREG32(EVERGREEN_MM_INDEX_HI, iocb->ki_pos >> 31);
 		value = RREG32(RADEON_MM_DATA);
 		spin_unlock_irqrestore(&rdev->mmio_idx_lock, flags);
 
-		r = put_user(value, (uint32_t __user *)buf);
+		r = put_iter(value, to);
 		if (r)
 			return r;
 
 		result += 4;
-		buf += 4;
-		*pos += 4;
+		iocb->ki_pos += 4;
 		size -= 4;
 	}
 
@@ -826,7 +825,7 @@ static ssize_t radeon_ttm_vram_read(struct file *f, char __user *buf,
 static const struct file_operations radeon_ttm_vram_fops = {
 	.owner = THIS_MODULE,
 	.open = radeon_ttm_vram_open,
-	.read = radeon_ttm_vram_read,
+	.read_iter = radeon_ttm_vram_read,
 	.llseek = default_llseek
 };
 
@@ -838,16 +837,16 @@ static int radeon_ttm_gtt_open(struct inode *inode, struct file *filep)
 	return 0;
 }
 
-static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
-				   size_t size, loff_t *pos)
+static ssize_t radeon_ttm_gtt_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct radeon_device *rdev = f->private_data;
+	struct radeon_device *rdev = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	ssize_t result = 0;
 	int r;
 
 	while (size) {
-		loff_t p = *pos / PAGE_SIZE;
-		unsigned off = *pos & ~PAGE_MASK;
+		loff_t p = iocb->ki_pos / PAGE_SIZE;
+		unsigned off = iocb->ki_pos & ~PAGE_MASK;
 		size_t cur_size = min_t(size_t, size, PAGE_SIZE - off);
 		struct page *page;
 		void *ptr;
@@ -860,17 +859,16 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
 			ptr = kmap_local_page(page);
 			ptr += off;
 
-			r = copy_to_user(buf, ptr, cur_size);
+			r = !copy_to_iter_full(ptr, cur_size, to);
 			kunmap_local(ptr);
 		} else
-			r = clear_user(buf, cur_size);
+			r = iov_iter_zero(cur_size, to) != cur_size;
 
 		if (r)
 			return -EFAULT;
 
 		result += cur_size;
-		buf += cur_size;
-		*pos += cur_size;
+		iocb->ki_pos += cur_size;
 		size -= cur_size;
 	}
 
@@ -880,7 +878,7 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
 static const struct file_operations radeon_ttm_gtt_fops = {
 	.owner = THIS_MODULE,
 	.open = radeon_ttm_gtt_open,
-	.read = radeon_ttm_gtt_read,
+	.read_iter = radeon_ttm_gtt_read,
 	.llseek = default_llseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 148/437] drm: armada: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (146 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 147/437] drm/radeon/radeon_ttm: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 149/437] drm: omap: " Jens Axboe
                   ` (289 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/armada/armada_debugfs.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_debugfs.c b/drivers/gpu/drm/armada/armada_debugfs.c
index 29f4b52e3c8d..eaa0384a3bd4 100644
--- a/drivers/gpu/drm/armada/armada_debugfs.c
+++ b/drivers/gpu/drm/armada/armada_debugfs.c
@@ -48,22 +48,23 @@ static int armada_debugfs_crtc_reg_open(struct inode *inode, struct file *file)
 			   inode->i_private);
 }
 
-static int armada_debugfs_crtc_reg_write(struct file *file,
-	const char __user *ptr, size_t len, loff_t *off)
+static int armada_debugfs_crtc_reg_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	struct armada_crtc *dcrtc;
 	unsigned long reg, mask, val;
 	char buf[32];
 	int ret;
 	u32 v;
 
-	if (*off != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (len > sizeof(buf) - 1)
 		len = sizeof(buf) - 1;
 
-	ret = strncpy_from_user(buf, ptr, len);
+	ret = strncpy_from_iter(from, ptr, len);
 	if (ret < 0)
 		return ret;
 	buf[len] = '\0';
@@ -85,8 +86,8 @@ static int armada_debugfs_crtc_reg_write(struct file *file,
 static const struct file_operations armada_debugfs_crtc_reg_fops = {
 	.owner = THIS_MODULE,
 	.open = armada_debugfs_crtc_reg_open,
-	.read = seq_read,
-	.write = armada_debugfs_crtc_reg_write,
+	.read_iter = seq_read_iter,
+	.write_iter = armada_debugfs_crtc_reg_write,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 149/437] drm: omap: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (147 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 148/437] drm: armada: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 150/437] vga_switcheroo: " Jens Axboe
                   ` (288 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 988888e164d7..2f0a3cda2c6c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -916,7 +916,7 @@ static int dss_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dss_debug_fops = {
 	.open		= dss_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 150/437] vga_switcheroo: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (148 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 149/437] drm: omap: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 151/437] drivers/clk: " Jens Axboe
                   ` (287 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gpu/vga/vga_switcheroo.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 365e6ddbe90f..b7afc48ab39c 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -772,8 +772,7 @@ static bool check_can_switch(void)
 }
 
 static ssize_t
-vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
-			     size_t cnt, loff_t *ppos)
+vga_switcheroo_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char usercmd[64];
 	int ret;
@@ -781,11 +780,12 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 	bool just_mux = false;
 	enum vga_switcheroo_client_id client_id = VGA_SWITCHEROO_UNKNOWN_ID;
 	struct vga_switcheroo_client *client = NULL;
+	size_t cnt = iov_iter_count(from);
 
 	if (cnt > 63)
 		cnt = 63;
 
-	if (copy_from_user(usercmd, ubuf, cnt))
+	if (!copy_from_iter_full(usercmd, cnt, from))
 		return -EFAULT;
 
 	mutex_lock(&vgasr_mutex);
@@ -899,8 +899,8 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 static const struct file_operations vga_switcheroo_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = vga_switcheroo_debugfs_open,
-	.write = vga_switcheroo_debugfs_write,
-	.read = seq_read,
+	.write_iter = vga_switcheroo_debugfs_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 151/437] drivers/clk: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (149 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 150/437] vga_switcheroo: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 152/437] drivers/rtc: " Jens Axboe
                   ` (286 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/clk/clk.c                              | 11 +++++------
 drivers/clk/starfive/clk-starfive-jh7110-pll.c |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 25371c91a58f..5a6371a9cad8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3539,16 +3539,15 @@ static int current_parent_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(current_parent);
 
 #ifdef CLOCK_ALLOW_WRITE_DEBUGFS
-static ssize_t current_parent_write(struct file *file, const char __user *ubuf,
-				    size_t count, loff_t *ppos)
+static ssize_t current_parent_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct clk_core *core = s->private;
 	struct clk_core *parent;
 	u8 idx;
 	int err;
 
-	err = kstrtou8_from_user(ubuf, count, 0, &idx);
+	err = kstrtou8_from_iter(from, count, 0, &idx);
 	if (err < 0)
 		return err;
 
@@ -3567,8 +3566,8 @@ static ssize_t current_parent_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations current_parent_rw_fops = {
 	.open		= current_parent_open,
-	.write		= current_parent_write,
-	.read		= seq_read,
+	.write_iter	= current_parent_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-pll.c b/drivers/clk/starfive/clk-starfive-jh7110-pll.c
index 3598390e8fd0..1b00fdc92b17 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-pll.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-pll.c
@@ -420,7 +420,7 @@ static const struct file_operations jh7110_pll_registers_ops = {
 	.owner = THIS_MODULE,
 	.open = jh7110_pll_registers_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 152/437] drivers/rtc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (150 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 151/437] drivers/clk: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 153/437] drivers/dma: " Jens Axboe
                   ` (285 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/rtc/dev.c        | 20 ++++++++------------
 drivers/rtc/rtc-m41t80.c | 18 +++++++-----------
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
index 4aad9bb99868..b37e6d448ee4 100644
--- a/drivers/rtc/dev.c
+++ b/drivers/rtc/dev.c
@@ -138,10 +138,10 @@ EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul);
 
 #endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */
 
-static ssize_t
-rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t rtc_dev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rtc_device *rtc = file->private_data;
+	struct rtc_device *rtc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	DECLARE_WAITQUEUE(wait, current);
 	unsigned long data;
@@ -163,7 +163,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			ret = 0;
 			break;
 		}
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			break;
 		}
@@ -177,13 +177,9 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	remove_wait_queue(&rtc->irq_queue, &wait);
 
 	if (ret == 0) {
-		if (sizeof(int) != sizeof(long) &&
-		    count == sizeof(unsigned int))
-			ret = put_user(data, (unsigned int __user *)buf) ?:
-				sizeof(unsigned int);
-		else
-			ret = put_user(data, (unsigned long __user *)buf) ?:
-				sizeof(unsigned long);
+		ret = sizeof(data);
+		if (put_iter(data, to))
+			ret = -EFAULT;
 	}
 	return ret;
 }
@@ -524,7 +520,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
 static const struct file_operations rtc_dev_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= rtc_dev_read,
+	.read_iter	= rtc_dev_read,
 	.poll		= rtc_dev_poll,
 	.unlocked_ioctl	= rtc_dev_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 0013bff0447d..2487aafd9698 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -686,26 +686,22 @@ static void wdt_disable(void)
 
 /**
  *	wdt_write - write to watchdog.
- *	@file: file handle to the watchdog
- *	@buf: buffer to write (unused as data does not matter here
- *	@count: count of bytes
- *	@ppos: pointer to the position to write. No seeks allowed
+ *	@iocb: metadata for IO
+ *	@from: buffer to write (unused as data does not matter here
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we don't define content meaning.
  */
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	if (count) {
+	if (iov_iter_count(from)) {
 		wdt_ping();
 		return 1;
 	}
 	return 0;
 }
 
-static ssize_t wdt_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t wdt_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -844,10 +840,10 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 
 static const struct file_operations wdt_fops = {
 	.owner	= THIS_MODULE,
-	.read	= wdt_read,
+	.read_iter	= wdt_read,
 	.unlocked_ioctl = wdt_unlocked_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
-	.write	= wdt_write,
+	.write_iter	= wdt_write,
 	.open	= wdt_open,
 	.release = wdt_release,
 	.llseek = no_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 153/437] drivers/dma: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (151 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 152/437] drivers/rtc: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 154/437] fs/debugfs: " Jens Axboe
                   ` (284 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/dma/xilinx/xilinx_dpdma.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
index b82815e64d24..8a443cd0cd44 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -354,14 +354,14 @@ static struct xilinx_dpdma_debugfs_request dpdma_debugfs_reqs[] = {
 	},
 };
 
-static ssize_t xilinx_dpdma_debugfs_read(struct file *f, char __user *buf,
-					 size_t size, loff_t *pos)
+static ssize_t xilinx_dpdma_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	enum xilinx_dpdma_testcases testcase;
+	size_t size = iov_iter_count(to);
 	char *kern_buff;
 	int ret = 0;
 
-	if (*pos != 0 || size <= 0)
+	if (iocb->ki_pos != 0 || size <= 0)
 		return -EINVAL;
 
 	kern_buff = kzalloc(XILINX_DPDMA_DEBUGFS_READ_MAX_SIZE, GFP_KERNEL);
@@ -381,7 +381,7 @@ static ssize_t xilinx_dpdma_debugfs_read(struct file *f, char __user *buf,
 	}
 
 	size = min(size, strlen(kern_buff));
-	if (copy_to_user(buf, kern_buff, size))
+	if (!copy_to_iter_full(kern_buff, size, to))
 		ret = -EFAULT;
 
 done:
@@ -389,7 +389,7 @@ static ssize_t xilinx_dpdma_debugfs_read(struct file *f, char __user *buf,
 	if (ret)
 		return ret;
 
-	*pos = size + 1;
+	iocb->ki_pos = size + 1;
 	return size;
 }
 
@@ -441,11 +441,12 @@ static ssize_t xilinx_dpdma_debugfs_write(struct file *f,
 	kfree(kern_buff_start);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(xilinx_dpdma_debugfs_write);
 
 static const struct file_operations fops_xilinx_dpdma_dbgfs = {
 	.owner = THIS_MODULE,
-	.read = xilinx_dpdma_debugfs_read,
-	.write = xilinx_dpdma_debugfs_write,
+	.read_iter = xilinx_dpdma_debugfs_read,
+	.write_iter = xilinx_dpdma_debugfs_write_iter,
 };
 
 static void xilinx_dpdma_debugfs_init(struct xilinx_dpdma_device *xdev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 154/437] fs/debugfs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (152 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 153/437] drivers/dma: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 155/437] HID: usbhid: " Jens Axboe
                   ` (283 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/debugfs/file.c | 54 +++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 35 deletions(-)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 31749d8c35f8..6463b4a274d4 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -318,15 +318,13 @@ FULL_PROXY_FUNC(llseek, loff_t, filp,
 		PROTO(struct file *filp, loff_t offset, int whence),
 		ARGS(filp, offset, whence));
 
-FULL_PROXY_FUNC(read, ssize_t, filp,
-		PROTO(struct file *filp, char __user *buf, size_t size,
-			loff_t *ppos),
-		ARGS(filp, buf, size, ppos));
+FULL_PROXY_FUNC(read_iter, ssize_t, iocb->ki_filp,
+		PROTO(struct kiocb *iocb, struct iov_iter *to),
+		ARGS(iocb, to));
 
-FULL_PROXY_FUNC(write, ssize_t, filp,
-		PROTO(struct file *filp, const char __user *buf, size_t size,
-			loff_t *ppos),
-		ARGS(filp, buf, size, ppos));
+FULL_PROXY_FUNC(write_iter, ssize_t, iocb->ki_filp,
+		PROTO(struct kiocb *iocb, struct iov_iter *from),
+		ARGS(iocb, from));
 
 FULL_PROXY_FUNC(unlocked_ioctl, long, filp,
 		PROTO(struct file *filp, unsigned int cmd, unsigned long arg),
@@ -376,10 +374,10 @@ static void __full_proxy_fops_init(struct file_operations *proxy_fops,
 	proxy_fops->release = full_proxy_release;
 	if (real_fops->llseek)
 		proxy_fops->llseek = full_proxy_llseek;
-	if (real_fops->read)
-		proxy_fops->read = full_proxy_read;
-	if (real_fops->write)
-		proxy_fops->write = full_proxy_write;
+	if (real_fops->read_iter)
+		proxy_fops->read_iter = full_proxy_read_iter;
+	if (real_fops->write_iter)
+		proxy_fops->write_iter = full_proxy_write_iter;
 	if (real_fops->poll)
 		proxy_fops->poll = full_proxy_poll;
 	if (real_fops->unlocked_ioctl)
@@ -914,19 +912,17 @@ void debugfs_create_atomic_t(const char *name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(debugfs_create_atomic_t);
 
-static ssize_t __debugfs_read_file_bool(struct file *file,
-					char __user *user_buf, size_t count,
-					loff_t *ppos)
+ssize_t debugfs_read_file_bool(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[2];
 	bool val;
 	int r;
-	struct dentry *dentry = F_DENTRY(file);
+	struct dentry *dentry = F_DENTRY(iocb->ki_filp);
 
 	r = debugfs_file_get(dentry);
 	if (unlikely(r))
 		return r;
-	val = *(bool *)file->private_data;
+	val = *(bool *)iocb->ki_filp->private_data;
 	debugfs_file_put(dentry);
 
 	if (val)
@@ -934,25 +930,19 @@ static ssize_t __debugfs_read_file_bool(struct file *file,
 	else
 		buf[0] = 'N';
 	buf[1] = '\n';
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
-}
-
-ssize_t debugfs_read_file_bool(struct kiocb *iocb, struct iov_iter *to)
-{
-	return vfs_read_iter(iocb, to, __debugfs_read_file_bool);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
 
-static ssize_t __debugfs_write_file_bool(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+ssize_t debugfs_write_file_bool(struct kiocb *iocb, struct iov_iter *from)
 {
 	bool bv;
 	int r;
-	bool *val = file->private_data;
-	struct dentry *dentry = F_DENTRY(file);
+	bool *val = iocb->ki_filp->private_data;
+	struct dentry *dentry = F_DENTRY(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 
-	r = kstrtobool_from_user(user_buf, count, &bv);
+	r = kstrtobool_from_iter(from, count, &bv);
 	if (!r) {
 		r = debugfs_file_get(dentry);
 		if (unlikely(r))
@@ -964,12 +954,6 @@ static ssize_t __debugfs_write_file_bool(struct file *file,
 	return count;
 }
 
-ssize_t debugfs_write_file_bool(struct kiocb *iocb, struct iov_iter *from)
-{
-	return vfs_write_iter(iocb, from, __debugfs_write_file_bool);
-}
-EXPORT_SYMBOL_GPL(debugfs_write_file_bool);
-
 static const struct file_operations fops_bool = {
 	.read_iter =	debugfs_read_file_bool,
 	.write_iter =	debugfs_write_file_bool,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 155/437] HID: usbhid: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (153 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 154/437] fs/debugfs: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 156/437] usb: chipidea: " Jens Axboe
                   ` (282 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hid/usbhid/hiddev.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 59cf3ddfdf78..19b3e663cf3d 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -308,7 +308,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
 /*
  * "write" file op
  */
-static ssize_t hiddev_write(struct file * file, const char __user * buffer, size_t count, loff_t *ppos)
+static ssize_t hiddev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EINVAL;
 }
@@ -316,10 +316,11 @@ static ssize_t hiddev_write(struct file * file, const char __user * buffer, size
 /*
  * "read" file op
  */
-static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos)
+static ssize_t hiddev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	DEFINE_WAIT(wait);
-	struct hiddev_list *list = file->private_data;
+	struct hiddev_list *list = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int event_size;
 	int retval;
 
@@ -347,7 +348,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
 					retval = -EIO;
 					break;
 				}
-				if (file->f_flags & O_NONBLOCK) {
+				if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 					retval = -EAGAIN;
 					break;
 				}
@@ -379,7 +380,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
 
 					event.hid = list->buffer[list->tail].usage_code;
 					event.value = list->buffer[list->tail].value;
-					if (copy_to_user(buffer + retval, &event, sizeof(struct hiddev_event))) {
+					if (!copy_to_iter_full(&event, sizeof(struct hiddev_event), to)) {
 						mutex_unlock(&list->thread_lock);
 						return -EFAULT;
 					}
@@ -389,7 +390,7 @@ static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t coun
 				if (list->buffer[list->tail].field_index != HID_FIELD_INDEX_NONE ||
 				    (list->flags & HIDDEV_FLAG_REPORT) != 0) {
 
-					if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct hiddev_usage_ref))) {
+					if (!copy_to_iter_full(list->buffer + list->tail, sizeof(struct hiddev_usage_ref), to)) {
 						mutex_unlock(&list->thread_lock);
 						return -EFAULT;
 					}
@@ -846,8 +847,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations hiddev_fops = {
 	.owner =	THIS_MODULE,
-	.read =		hiddev_read,
-	.write =	hiddev_write,
+	.read_iter =	hiddev_read,
+	.write_iter =	hiddev_write,
 	.poll =		hiddev_poll,
 	.open =		hiddev_open,
 	.release =	hiddev_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 156/437] usb: chipidea: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (154 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 155/437] HID: usbhid: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 157/437] usb: class: " Jens Axboe
                   ` (281 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/chipidea/debug.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index e72c43615d77..fa080c6dabf3 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -6,6 +6,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/phy.h>
@@ -70,10 +71,10 @@ static int ci_port_test_show(struct seq_file *s, void *data)
 /*
  * ci_port_test_write: writes port test mode
  */
-static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf,
-				  size_t count, loff_t *ppos)
+static ssize_t ci_port_test_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ci_hdrc *ci = s->private;
 	unsigned long flags;
 	unsigned mode;
@@ -81,7 +82,7 @@ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf,
 	int ret;
 
 	count = min_t(size_t, sizeof(buf) - 1, count);
-	if (copy_from_user(buf, ubuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	/* sscanf requires a zero terminated string */
@@ -109,8 +110,8 @@ static int ci_port_test_open(struct inode *inode, struct file *file)
 
 static const struct file_operations ci_port_test_fops = {
 	.open		= ci_port_test_open,
-	.write		= ci_port_test_write,
-	.read		= seq_read,
+	.write_iter	= ci_port_test_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 157/437] usb: class: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (155 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 156/437] usb: chipidea: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 158/437] usb: core: " Jens Axboe
                   ` (280 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/class/cdc-wdm.c | 18 +++++++++---------
 drivers/usb/class/usblp.c   |  6 ++++--
 drivers/usb/class/usbtmc.c  |  6 ++++--
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index c8262e2f2917..a811000b5eb2 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -476,6 +476,7 @@ static ssize_t wdm_write
 	kfree(buf);
 	return rv;
 }
+FOPS_WRITE_ITER_HELPER(wdm_write);
 
 /*
  * Submit the read urb if resp_count is non-zero.
@@ -520,13 +521,12 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
 	return rv;
 }
 
-static ssize_t wdm_read
-(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
+static ssize_t wdm_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rv, cntr;
 	int i = 0;
-	struct wdm_device *desc = file->private_data;
-
+	struct wdm_device *desc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
 	if (rv < 0)
@@ -546,7 +546,7 @@ static ssize_t wdm_read
 			goto err;
 		}
 		i++;
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			if (!test_bit(WDM_READ, &desc->flags)) {
 				rv = -EAGAIN;
 				goto err;
@@ -604,8 +604,8 @@ static ssize_t wdm_read
 
 	if (cntr > count)
 		cntr = count;
-	rv = copy_to_user(buffer, desc->ubuf, cntr);
-	if (rv > 0) {
+	rv = !copy_to_iter_full(desc->ubuf, cntr, to);
+	if (rv) {
 		rv = -EFAULT;
 		goto err;
 	}
@@ -810,8 +810,8 @@ static long wdm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations wdm_fops = {
 	.owner =	THIS_MODULE,
-	.read =		wdm_read,
-	.write =	wdm_write,
+	.read_iter =	wdm_read,
+	.write_iter =	wdm_write_iter,
 	.fsync =	wdm_fsync,
 	.open =		wdm_open,
 	.flush =	wdm_flush,
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 5a2e43331064..2f16b7916963 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -832,6 +832,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
 raise_biglock:
 	return writecount ? writecount : rv;
 }
+FOPS_WRITE_ITER_HELPER(usblp_write);
 
 /*
  * Notice that we fail to restart in a few cases: on EFAULT, on restart
@@ -885,6 +886,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
 	mutex_unlock(&usblp->mut);
 	return count;
 }
+FOPS_READ_ITER_HELPER(usblp_read);
 
 /*
  * Wait for the write path to come idle.
@@ -1080,8 +1082,8 @@ static unsigned int usblp_quirks(__u16 vendor, __u16 product)
 
 static const struct file_operations usblp_fops = {
 	.owner =	THIS_MODULE,
-	.read =		usblp_read,
-	.write =	usblp_write,
+	.read_iter =	usblp_read_iter,
+	.write_iter =	usblp_write_iter,
 	.poll =		usblp_poll,
 	.unlocked_ioctl =	usblp_ioctl,
 	.compat_ioctl =		usblp_ioctl,
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 311007b1d904..281eeb29cf7f 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1506,6 +1506,7 @@ static ssize_t usbtmc_read(struct file *filp, char __user *buf,
 	kfree(buffer);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(usbtmc_read);
 
 static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
 			    size_t count, loff_t *f_pos)
@@ -1644,6 +1645,7 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
 	mutex_unlock(&data->io_mutex);
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(usbtmc_write);
 
 static int usbtmc_ioctl_clear(struct usbtmc_device_data *data)
 {
@@ -2261,8 +2263,8 @@ static __poll_t usbtmc_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations fops = {
 	.owner		= THIS_MODULE,
-	.read		= usbtmc_read,
-	.write		= usbtmc_write,
+	.read_iter	= usbtmc_read_iter,
+	.write_iter	= usbtmc_write_iter,
 	.open		= usbtmc_open,
 	.release	= usbtmc_release,
 	.flush		= usbtmc_flush,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 158/437] usb: core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (156 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 157/437] usb: class: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:14 ` [PATCH 159/437] usb: dwc2: " Jens Axboe
                   ` (279 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/core/devices.c | 3 ++-
 drivers/usb/core/devio.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index a247da73f34d..f367132a6770 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -538,8 +538,9 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
 	mutex_unlock(&usb_bus_idr_lock);
 	return total_written;
 }
+FOPS_READ_ITER_HELPER(usb_device_read);
 
 const struct file_operations usbfs_devices_fops = {
 	.llseek =	no_seek_end_llseek,
-	.read =		usb_device_read,
+	.read_iter =	usb_device_read_iter,
 };
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 3beb6a862e80..bebfbebc1f69 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -390,6 +390,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
 	usb_unlock_device(dev);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(usbdev_read);
 
 /*
  * async list handling
@@ -2846,7 +2847,7 @@ static __poll_t usbdev_poll(struct file *file,
 const struct file_operations usbdev_file_operations = {
 	.owner =	  THIS_MODULE,
 	.llseek =	  no_seek_end_llseek,
-	.read =		  usbdev_read,
+	.read_iter =	  usbdev_read_iter,
 	.poll =		  usbdev_poll,
 	.unlocked_ioctl = usbdev_ioctl,
 	.compat_ioctl =   compat_ptr_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 159/437] usb: dwc2: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (157 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 158/437] usb: core: " Jens Axboe
@ 2024-04-11 15:14 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 160/437] usb: dwc3: " Jens Axboe
                   ` (278 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/dwc2/debugfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index 1d72ece9cfe4..b106744e13b5 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -24,16 +24,16 @@
  * @count: The ubuf size.
  * @ppos: Unused parameter.
  */
-static ssize_t testmode_write(struct file *file, const char __user *ubuf, size_t
-		count, loff_t *ppos)
+static ssize_t testmode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct dwc2_hsotg	*hsotg = s->private;
 	unsigned long		flags;
 	u32			testmode = 0;
 	char			buf[32];
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "test_j", 6))
@@ -108,8 +108,8 @@ static int testmode_open(struct inode *inode, struct file *file)
 static const struct file_operations testmode_fops = {
 	.owner		= THIS_MODULE,
 	.open		= testmode_open,
-	.write		= testmode_write,
-	.read		= seq_read,
+	.write_iter	= testmode_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 160/437] usb: dwc3: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (158 preceding siblings ...)
  2024-04-11 15:14 ` [PATCH 159/437] usb: dwc2: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 161/437] usb: fotg210-hcd: " Jens Axboe
                   ` (277 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/dwc3/debugfs.c | 48 +++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index ebf03468fac4..5af745ef00a0 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -365,17 +365,17 @@ static int dwc3_lsp_open(struct inode *inode, struct file *file)
 	return single_open(file, dwc3_lsp_show, inode->i_private);
 }
 
-static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf,
-			      size_t count, loff_t *ppos)
+static ssize_t dwc3_lsp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct dwc3		*dwc = s->private;
 	unsigned long		flags;
 	char			buf[32] = { 0 };
 	u32			sel;
 	int			ret;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	ret = kstrtouint(buf, 0, &sel);
@@ -391,8 +391,8 @@ static ssize_t dwc3_lsp_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations dwc3_lsp_fops = {
 	.open			= dwc3_lsp_open,
-	.write			= dwc3_lsp_write,
-	.read			= seq_read,
+	.write_iter		= dwc3_lsp_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -436,15 +436,15 @@ static int dwc3_mode_open(struct inode *inode, struct file *file)
 	return single_open(file, dwc3_mode_show, inode->i_private);
 }
 
-static ssize_t dwc3_mode_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t dwc3_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct dwc3		*dwc = s->private;
 	u32			mode = 0;
 	char			buf[32];
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (dwc->dr_mode != USB_DR_MODE_OTG)
@@ -466,8 +466,8 @@ static ssize_t dwc3_mode_write(struct file *file,
 
 static const struct file_operations dwc3_mode_fops = {
 	.open			= dwc3_mode_open,
-	.write			= dwc3_mode_write,
-	.read			= seq_read,
+	.write_iter		= dwc3_mode_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -522,17 +522,17 @@ static int dwc3_testmode_open(struct inode *inode, struct file *file)
 	return single_open(file, dwc3_testmode_show, inode->i_private);
 }
 
-static ssize_t dwc3_testmode_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t dwc3_testmode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct dwc3		*dwc = s->private;
 	unsigned long		flags;
 	u32			testmode = 0;
 	char			buf[32];
 	int			ret;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "test_j", 6))
@@ -563,8 +563,8 @@ static ssize_t dwc3_testmode_write(struct file *file,
 
 static const struct file_operations dwc3_testmode_fops = {
 	.open			= dwc3_testmode_open,
-	.write			= dwc3_testmode_write,
-	.read			= seq_read,
+	.write_iter		= dwc3_testmode_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -610,10 +610,10 @@ static int dwc3_link_state_open(struct inode *inode, struct file *file)
 	return single_open(file, dwc3_link_state_show, inode->i_private);
 }
 
-static ssize_t dwc3_link_state_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t dwc3_link_state_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct dwc3		*dwc = s->private;
 	unsigned long		flags;
 	enum dwc3_link_state	state = 0;
@@ -622,7 +622,7 @@ static ssize_t dwc3_link_state_write(struct file *file,
 	u8			speed;
 	int			ret;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "SS.Disabled", 11))
@@ -672,8 +672,8 @@ static ssize_t dwc3_link_state_write(struct file *file,
 
 static const struct file_operations dwc3_link_state_fops = {
 	.open			= dwc3_link_state_open,
-	.write			= dwc3_link_state_write,
-	.read			= seq_read,
+	.write_iter		= dwc3_link_state_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 161/437] usb: fotg210-hcd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (159 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 160/437] usb: dwc3: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 162/437] usb: gadget: " Jens Axboe
                   ` (276 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/fotg210/fotg210-hcd.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/fotg210/fotg210-hcd.c b/drivers/usb/fotg210/fotg210-hcd.c
index 8c5aaf860635..6a7334164ca7 100644
--- a/drivers/usb/fotg210/fotg210-hcd.c
+++ b/drivers/usb/fotg210/fotg210-hcd.c
@@ -283,27 +283,27 @@ static int debug_periodic_open(struct inode *, struct file *);
 static int debug_registers_open(struct inode *, struct file *);
 static int debug_async_open(struct inode *, struct file *);
 
-static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
+static ssize_t debug_output(struct kiocb *, struct iov_iter *);
 static int debug_close(struct inode *, struct file *);
 
 static const struct file_operations debug_async_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_async_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
 static const struct file_operations debug_periodic_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_periodic_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
 static const struct file_operations debug_registers_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_registers_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -773,10 +773,9 @@ static int fill_buffer(struct debug_buffer *buf)
 	return ret;
 }
 
-static ssize_t debug_output(struct file *file, char __user *user_buf,
-		size_t len, loff_t *offset)
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debug_buffer *buf = file->private_data;
+	struct debug_buffer *buf = iocb->ki_filp->private_data;
 	int ret = 0;
 
 	mutex_lock(&buf->mutex);
@@ -789,9 +788,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
 	}
 	mutex_unlock(&buf->mutex);
 
-	ret = simple_read_from_buffer(user_buf, len, offset,
-			buf->output_buf, buf->count);
-
+	ret = simple_copy_to_iter(buf->output_buf, &iocb->ki_pos, buf->count, to);
 out:
 	return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 162/437] usb: gadget: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (160 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 161/437] usb: fotg210-hcd: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 163/437] usb: host: ehci: " Jens Axboe
                   ` (275 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/gadget/function/f_fs.c      |  6 ++++--
 drivers/usb/gadget/function/f_hid.c     | 17 ++++++++--------
 drivers/usb/gadget/function/f_printer.c | 26 ++++++++++++-------------
 drivers/usb/gadget/legacy/inode.c       |  6 ++++--
 drivers/usb/gadget/udc/renesas_usb3.c   | 14 ++++++-------
 5 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index bffbc1dc651f..e3514d295e55 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -495,6 +495,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf,
 	mutex_unlock(&ffs->mutex);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ffs_ep0_write);
 
 /* Called with ffs->ev.waitq.lock and ffs->mutex held, both released on exit. */
 static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf,
@@ -632,6 +633,7 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,
 	kfree(data);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(ffs_ep0_read);
 
 static int ffs_ep0_open(struct inode *inode, struct file *file)
 {
@@ -720,8 +722,8 @@ static const struct file_operations ffs_ep0_operations = {
 	.llseek =	no_llseek,
 
 	.open =		ffs_ep0_open,
-	.write =	ffs_ep0_write,
-	.read =		ffs_ep0_read,
+	.write_iter =	ffs_ep0_write_iter,
+	.read_iter =	ffs_ep0_read_iter,
 	.release =	ffs_ep0_release,
 	.unlocked_ioctl =	ffs_ep0_ioctl,
 	.poll =		ffs_ep0_poll,
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 3c8a9dd585c0..13e5bab6e1b2 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -414,6 +414,7 @@ static ssize_t f_hidg_read(struct file *file, char __user *buffer,
 	else
 		return f_hidg_ssreport_read(file, buffer, count, ptr);
 }
+FOPS_READ_ITER_HELPER(f_hidg_read);
 
 static void f_hidg_req_complete(struct usb_ep *ep, struct usb_request *req)
 {
@@ -431,10 +432,10 @@ static void f_hidg_req_complete(struct usb_ep *ep, struct usb_request *req)
 	wake_up(&hidg->write_queue);
 }
 
-static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
-			    size_t count, loff_t *offp)
+static ssize_t f_hidg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct f_hidg *hidg  = file->private_data;
+	struct f_hidg *hidg  = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct usb_request *req;
 	unsigned long flags;
 	ssize_t status = -ENOMEM;
@@ -451,7 +452,7 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
 	/* write queue */
 	while (!WRITE_COND) {
 		spin_unlock_irqrestore(&hidg->write_spinlock, flags);
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		if (wait_event_interruptible_exclusive(
@@ -473,8 +474,8 @@ static ssize_t f_hidg_write(struct file *file, const char __user *buffer,
 		goto release_write_pending;
 	}
 
-	status = copy_from_user(req->buf, buffer, count);
-	if (status != 0) {
+	status = copy_from_iter_full(req->buf, count, from);
+	if (!status) {
 		ERROR(hidg->func.config->cdev,
 			"copy_from_user error\n");
 		status = -EINVAL;
@@ -906,8 +907,8 @@ static const struct file_operations f_hidg_fops = {
 	.owner		= THIS_MODULE,
 	.open		= f_hidg_open,
 	.release	= f_hidg_release,
-	.write		= f_hidg_write,
-	.read		= f_hidg_read,
+	.write_iter	= f_hidg_write,
+	.read_iter	= f_hidg_read_iter,
 	.poll		= f_hidg_poll,
 	.llseek		= noop_llseek,
 };
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 076dd4c1be96..de3863f0bfb6 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -426,10 +426,10 @@ setup_rx_reqs(struct printer_dev *dev)
 	}
 }
 
-static ssize_t
-printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
+static ssize_t printer_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct printer_dev		*dev = fd->private_data;
+	struct printer_dev		*dev = iocb->ki_filp->private_data;
+	size_t				len = iov_iter_count(to);
 	unsigned long			flags;
 	size_t				size;
 	size_t				bytes_copied;
@@ -485,7 +485,7 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
 		 * If no data is available check if this is a NON-Blocking
 		 * call or not.
 		 */
-		if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
+		if (iocb->ki_filp->f_flags & (O_NONBLOCK|O_NDELAY)) {
 			mutex_unlock(&dev->lock_printer_io);
 			return -EAGAIN;
 		}
@@ -522,10 +522,9 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
 		else
 			size = len;
 
-		size -= copy_to_user(buf, current_rx_buf, size);
+		size -= copy_to_iter(current_rx_buf, size, to);
 		bytes_copied += size;
 		len -= size;
-		buf += size;
 
 		spin_lock_irqsave(&dev->lock, flags);
 
@@ -568,10 +567,10 @@ printer_read(struct file *fd, char __user *buf, size_t len, loff_t *ptr)
 		return -EAGAIN;
 }
 
-static ssize_t
-printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
+static ssize_t printer_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct printer_dev	*dev = fd->private_data;
+	struct printer_dev	*dev = iocb->ki_filp->private_data;
+	size_t			len = iov_iter_count(from);
 	unsigned long		flags;
 	size_t			size;	/* Amount of data in a TX request. */
 	size_t			bytes_copied = 0;
@@ -604,7 +603,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 		 * If write buffers are available check if this is
 		 * a NON-Blocking call or not.
 		 */
-		if (fd->f_flags & (O_NONBLOCK|O_NDELAY)) {
+		if (iocb->ki_filp->f_flags & (O_NONBLOCK|O_NDELAY)) {
 			mutex_unlock(&dev->lock_printer_io);
 			return -EAGAIN;
 		}
@@ -642,7 +641,7 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 		/* Don't leave irqs off while doing memory copies */
 		spin_unlock_irqrestore(&dev->lock, flags);
 
-		if (copy_from_user(req->buf, buf, size)) {
+		if (!copy_from_iter_full(req->buf, size, from)) {
 			list_add(&req->list, &dev->tx_reqs);
 			mutex_unlock(&dev->lock_printer_io);
 			return bytes_copied;
@@ -650,7 +649,6 @@ printer_write(struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 
 		bytes_copied += size;
 		len -= size;
-		buf += size;
 
 		spin_lock_irqsave(&dev->lock, flags);
 
@@ -794,8 +792,8 @@ printer_ioctl(struct file *fd, unsigned int code, unsigned long arg)
 static const struct file_operations printer_io_operations = {
 	.owner =	THIS_MODULE,
 	.open =		printer_open,
-	.read =		printer_read,
-	.write =	printer_write,
+	.read_iter =	printer_read,
+	.write_iter =	printer_write,
 	.fsync =	printer_fsync,
 	.poll =		printer_poll,
 	.unlocked_ioctl = printer_ioctl,
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index 03179b1880fd..2898840a7a41 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1080,6 +1080,7 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
 	spin_unlock_irq (&dev->lock);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(ep0_read);
 
 static struct usb_gadgetfs_event *
 next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type)
@@ -1919,6 +1920,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
 	dev->buf = NULL;
 	return value;
 }
+FOPS_WRITE_ITER_HELPER(dev_config);
 
 static int
 gadget_dev_open (struct inode *inode, struct file *fd)
@@ -1942,8 +1944,8 @@ static const struct file_operations ep0_operations = {
 	.llseek =	no_llseek,
 
 	.open =		gadget_dev_open,
-	.read =		ep0_read,
-	.write =	dev_config,
+	.read_iter =	ep0_read_iter,
+	.write_iter =	dev_config_iter,
 	.fasync =	ep0_fasync,
 	.poll =		ep0_poll,
 	.unlocked_ioctl = gadget_dev_ioctl,
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 3b01734ce1b7..61f5d7ac47ee 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2603,18 +2603,18 @@ static int renesas_usb3_b_device_open(struct inode *inode, struct file *file)
 	return single_open(file, renesas_usb3_b_device_show, inode->i_private);
 }
 
-static ssize_t renesas_usb3_b_device_write(struct file *file,
-					   const char __user *ubuf,
-					   size_t count, loff_t *ppos)
+static ssize_t renesas_usb3_b_device_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct renesas_usb3 *usb3 = s->private;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 
 	if (!usb3->driver)
 		return -ENODEV;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	usb3->start_to_connect = false;
@@ -2637,8 +2637,8 @@ static ssize_t renesas_usb3_b_device_write(struct file *file,
 
 static const struct file_operations renesas_usb3_b_device_fops = {
 	.open = renesas_usb3_b_device_open,
-	.write = renesas_usb3_b_device_write,
-	.read = seq_read,
+	.write_iter = renesas_usb3_b_device_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 163/437] usb: host: ehci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (161 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 162/437] usb: gadget: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 164/437] usb: host: ohci: " Jens Axboe
                   ` (274 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/host/ehci-dbg.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index c063fb042926..c9390a17c432 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -293,13 +293,13 @@ static int debug_bandwidth_open(struct inode *, struct file *);
 static int debug_periodic_open(struct inode *, struct file *);
 static int debug_registers_open(struct inode *, struct file *);
 
-static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
+static ssize_t debug_output(struct kiocb *, struct iov_iter *);
 static int debug_close(struct inode *, struct file *);
 
 static const struct file_operations debug_async_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_async_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -307,7 +307,7 @@ static const struct file_operations debug_async_fops = {
 static const struct file_operations debug_bandwidth_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_bandwidth_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -315,7 +315,7 @@ static const struct file_operations debug_bandwidth_fops = {
 static const struct file_operations debug_periodic_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_periodic_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -323,7 +323,7 @@ static const struct file_operations debug_periodic_fops = {
 static const struct file_operations debug_registers_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_registers_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -952,10 +952,9 @@ static int fill_buffer(struct debug_buffer *buf)
 	return ret;
 }
 
-static ssize_t debug_output(struct file *file, char __user *user_buf,
-		size_t len, loff_t *offset)
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debug_buffer *buf = file->private_data;
+	struct debug_buffer *buf = iocb->ki_filp->private_data;
 	int ret;
 
 	mutex_lock(&buf->mutex);
@@ -968,9 +967,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
 	}
 	mutex_unlock(&buf->mutex);
 
-	ret = simple_read_from_buffer(user_buf, len, offset,
-				      buf->output_buf, buf->count);
-
+	ret = simple_copy_to_iter(buf->output_buf, &iocb->ki_pos, buf->count, to);
 out:
 	return ret;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 164/437] usb: host: ohci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (162 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 163/437] usb: host: ehci: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 165/437] usb: host: uhci: " Jens Axboe
                   ` (273 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/host/ohci-dbg.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 76bc8d56325d..dc40e655f824 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -361,27 +361,27 @@ static int debug_async_open(struct inode *, struct file *);
 static int debug_periodic_open(struct inode *, struct file *);
 static int debug_registers_open(struct inode *, struct file *);
 static int debug_async_open(struct inode *, struct file *);
-static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
+static ssize_t debug_output(struct kiocb *, struct iov_iter *);
 static int debug_close(struct inode *, struct file *);
 
 static const struct file_operations debug_async_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_async_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
 static const struct file_operations debug_periodic_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_periodic_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
 static const struct file_operations debug_registers_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debug_registers_open,
-	.read		= debug_output,
+	.read_iter	= debug_output,
 	.release	= debug_close,
 	.llseek		= default_llseek,
 };
@@ -701,10 +701,9 @@ static int fill_buffer(struct debug_buffer *buf)
 	return ret;
 }
 
-static ssize_t debug_output(struct file *file, char __user *user_buf,
-			size_t len, loff_t *offset)
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debug_buffer *buf = file->private_data;
+	struct debug_buffer *buf = iocb->ki_filp->private_data;
 	int ret;
 
 	mutex_lock(&buf->mutex);
@@ -717,9 +716,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
 	}
 	mutex_unlock(&buf->mutex);
 
-	ret = simple_read_from_buffer(user_buf, len, offset,
-				      buf->page, buf->count);
-
+	ret = simple_copy_to_iter(buf->page, &iocb->ki_pos, buf->count, to);
 out:
 	return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 165/437] usb: host: uhci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (163 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 164/437] usb: host: ohci: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 166/437] usb: host: xhci: " Jens Axboe
                   ` (272 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/host/uhci-debug.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index c4e67c4b51f6..e8329c44db59 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -589,11 +589,10 @@ static loff_t uhci_debug_lseek(struct file *file, loff_t off, int whence)
 	return no_seek_end_llseek_size(file, off, whence, up->size);
 }
 
-static ssize_t uhci_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t uhci_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uhci_debug *up = file->private_data;
-	return simple_read_from_buffer(buf, nbytes, ppos, up->data, up->size);
+	struct uhci_debug *up = iocb->ki_filp->private_data;
+	return simple_copy_to_iter(up->data, &iocb->ki_pos, up->size, to);
 }
 
 static int uhci_debug_release(struct inode *inode, struct file *file)
@@ -610,7 +609,7 @@ static const struct file_operations uhci_debug_operations = {
 	.owner =	THIS_MODULE,
 	.open =		uhci_debug_open,
 	.llseek =	uhci_debug_lseek,
-	.read =		uhci_debug_read,
+	.read_iter =	uhci_debug_read,
 	.release =	uhci_debug_release,
 };
 #define UHCI_DEBUG_OPS
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 166/437] usb: host: xhci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (164 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 165/437] usb: host: uhci: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 167/437] usb: image: mdc800: " Jens Axboe
                   ` (271 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/host/xhci-debugfs.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index f8ba15e7c225..751e48d0b555 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -251,7 +251,7 @@ static int xhci_ring_open(struct inode *inode, struct file *file)
 
 static const struct file_operations xhci_ring_fops = {
 	.open			= xhci_ring_open,
-	.read			= seq_read,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -336,7 +336,7 @@ static int xhci_context_open(struct inode *inode, struct file *file)
 
 static const struct file_operations xhci_context_fops = {
 	.open			= xhci_context_open,
-	.read			= seq_read,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -360,17 +360,17 @@ static int xhci_port_open(struct inode *inode, struct file *file)
 	return single_open(file, xhci_portsc_show, inode->i_private);
 }
 
-static ssize_t xhci_port_write(struct file *file,  const char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t xhci_port_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file         *s = file->private_data;
+	struct seq_file         *s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct xhci_port	*port = s->private;
 	struct xhci_hcd		*xhci = hcd_to_xhci(port->rhub->hcd);
 	char                    buf[32];
 	u32			portsc;
 	unsigned long		flags;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "compliance", 10)) {
@@ -397,8 +397,8 @@ static ssize_t xhci_port_write(struct file *file,  const char __user *ubuf,
 
 static const struct file_operations port_fops = {
 	.open			= xhci_port_open,
-	.write                  = xhci_port_write,
-	.read			= seq_read,
+	.write_iter             = xhci_port_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -502,10 +502,10 @@ static int xhci_stream_id_open(struct inode *inode, struct file *file)
 	return single_open(file, xhci_stream_id_show, inode->i_private);
 }
 
-static ssize_t xhci_stream_id_write(struct file *file,  const char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t xhci_stream_id_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file         *s = file->private_data;
+	struct seq_file         *s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct xhci_ep_priv	*epriv = s->private;
 	int			ret;
 	u16			stream_id; /* MaxPStreams + 1 <= 16 */
@@ -514,7 +514,7 @@ static ssize_t xhci_stream_id_write(struct file *file,  const char __user *ubuf,
 		return -EPERM;
 
 	/* Decimal number */
-	ret = kstrtou16_from_user(ubuf, count, 10, &stream_id);
+	ret = kstrtou16_from_iter(from, count, 10, &stream_id);
 	if (ret)
 		return ret;
 
@@ -529,8 +529,8 @@ static ssize_t xhci_stream_id_write(struct file *file,  const char __user *ubuf,
 
 static const struct file_operations stream_id_fops = {
 	.open			= xhci_stream_id_open,
-	.write                  = xhci_stream_id_write,
-	.read			= seq_read,
+	.write_iter             = xhci_stream_id_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 167/437] usb: image: mdc800: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (165 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 166/437] usb: host: xhci: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 168/437] usb: misc: " Jens Axboe
                   ` (270 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/image/mdc800.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 7b7e1554ea20..ec52a144f8d7 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -677,10 +677,10 @@ static int mdc800_device_release (struct inode* inode, struct file *file)
 /*
  * The Device read callback Function
  */
-static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t len, loff_t *pos)
+static ssize_t mdc800_device_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	size_t left=len, sts=len; /* single transfer size */
-	char __user *ptr = buf;
 	int retval;
 
 	mutex_lock(&mdc800->io_lock);
@@ -754,12 +754,11 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
 		else
 		{
 			/* Copy Bytes */
-			if (copy_to_user(ptr, &mdc800->out [mdc800->out_ptr],
-						sts)) {
+			if (!copy_to_iter_full(&mdc800->out [mdc800->out_ptr],
+						sts, to)) {
 				mutex_unlock(&mdc800->io_lock);
 				return -EFAULT;
 			}
-			ptr+=sts;
 			left-=sts;
 			mdc800->out_ptr+=sts;
 		}
@@ -936,7 +935,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s
 	mutex_unlock(&mdc800->io_lock);
 	return i;
 }
-
+FOPS_WRITE_ITER_HELPER(mdc800_device_write);
 
 /***************************************************************************
 	Init and Cleanup this driver (Structs and types)
@@ -946,8 +945,8 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s
 static const struct file_operations mdc800_device_ops =
 {
 	.owner =	THIS_MODULE,
-	.read =		mdc800_device_read,
-	.write =	mdc800_device_write,
+	.read_iter =	mdc800_device_read,
+	.write_iter =	mdc800_device_write_iter,
 	.open =		mdc800_device_open,
 	.release =	mdc800_device_release,
 	.llseek =	noop_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 168/437] usb: misc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (166 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 167/437] usb: image: mdc800: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 169/437] usb: mon: " Jens Axboe
                   ` (269 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/misc/adutux.c              |  6 ++++--
 drivers/usb/misc/chaoskey.c            | 13 +++++--------
 drivers/usb/misc/idmouse.c             | 15 ++++++---------
 drivers/usb/misc/iowarrior.c           |  6 ++++--
 drivers/usb/misc/ldusb.c               | 24 ++++++++++++------------
 drivers/usb/misc/legousbtower.c        | 26 ++++++++++++++------------
 drivers/usb/misc/sisusbvga/sisusbvga.c |  6 ++++--
 drivers/usb/misc/usblcd.c              | 20 ++++++++++----------
 drivers/usb/misc/yurex.c               | 19 +++++++++----------
 9 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index ed6a19254d2f..20d6107682c2 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -499,6 +499,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(adu_read);
 
 static ssize_t adu_write(struct file *file, const __user char *buffer,
 			 size_t count, loff_t *ppos)
@@ -619,12 +620,13 @@ static ssize_t adu_write(struct file *file, const __user char *buffer,
 	remove_wait_queue(&dev->write_wait, &waita);
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(adu_write);
 
 /* file operations needed when we register this driver */
 static const struct file_operations adu_fops = {
 	.owner = THIS_MODULE,
-	.read  = adu_read,
-	.write = adu_write,
+	.read_iter  = adu_read_iter,
+	.write_iter = adu_write_iter,
 	.open = adu_open,
 	.release = adu_release,
 	.llseek = noop_llseek,
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index 6fb5140e29b9..400b19bb1ee6 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -403,18 +403,16 @@ static int _chaoskey_fill(struct chaoskey *dev)
 	return result;
 }
 
-static ssize_t chaoskey_read(struct file *file,
-			     char __user *buffer,
-			     size_t count,
-			     loff_t *ppos)
+static ssize_t chaoskey_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct chaoskey *dev;
 	ssize_t read_count = 0;
 	int this_time;
 	int result = 0;
 	unsigned long remain;
+	size_t count = iov_iter_count(to);
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	if (dev == NULL || !dev->present)
 		return -ENODEV;
@@ -446,7 +444,7 @@ static ssize_t chaoskey_read(struct file *file,
 		if (this_time > count)
 			this_time = count;
 
-		remain = copy_to_user(buffer, dev->buf + dev->used, this_time);
+		remain = !copy_to_iter_full(dev->buf + dev->used, this_time, to);
 		if (remain) {
 			result = -EFAULT;
 
@@ -460,7 +458,6 @@ static ssize_t chaoskey_read(struct file *file,
 
 		count -= this_time;
 		read_count += this_time;
-		buffer += this_time;
 		dev->used += this_time;
 		mutex_unlock(&dev->lock);
 	}
@@ -554,7 +551,7 @@ static int chaoskey_resume(struct usb_interface *interface)
 /* file operation pointers */
 static const struct file_operations chaoskey_fops = {
 	.owner = THIS_MODULE,
-	.read = chaoskey_read,
+	.read_iter = chaoskey_read,
 	.open = chaoskey_open,
 	.release = chaoskey_release,
 	.llseek = default_llseek,
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index ea39243efee3..91534f0982ea 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -79,9 +79,7 @@ struct usb_idmouse {
 };
 
 /* local function prototypes */
-static ssize_t idmouse_read(struct file *file, char __user *buffer,
-				size_t count, loff_t * ppos);
-
+static ssize_t idmouse_read(struct kiocb *iocb, struct iov_iter *to);
 static int idmouse_open(struct inode *inode, struct file *file);
 static int idmouse_release(struct inode *inode, struct file *file);
 
@@ -95,7 +93,7 @@ static int idmouse_resume(struct usb_interface *intf);
 /* file operation pointers */
 static const struct file_operations idmouse_fops = {
 	.owner = THIS_MODULE,
-	.read = idmouse_read,
+	.read_iter = idmouse_read,
 	.open = idmouse_open,
 	.release = idmouse_release,
 	.llseek = default_llseek,
@@ -290,10 +288,9 @@ static int idmouse_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count,
-				loff_t * ppos)
+static ssize_t idmouse_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct usb_idmouse *dev = file->private_data;
+	struct usb_idmouse *dev = iocb->ki_filp->private_data;
 	int result;
 
 	/* lock this object */
@@ -305,8 +302,8 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count
 		return -ENODEV;
 	}
 
-	result = simple_read_from_buffer(buffer, count, ppos,
-					dev->bulk_in_buffer, IMGSIZE);
+	result = simple_copy_to_iter(dev->bulk_in_buffer, &iocb->ki_pos,
+					IMGSIZE, to);
 	/* unlock the device */
 	mutex_unlock(&dev->lock);
 	return result;
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 6d28467ce352..bb0f28e1cdca 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -332,6 +332,7 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
 	atomic_set(&dev->read_idx, read_idx);
 	return count;
 }
+FOPS_READ_ITER_HELPER(iowarrior_read);
 
 /*
  * iowarrior_write
@@ -468,6 +469,7 @@ static ssize_t iowarrior_write(struct file *file,
 	mutex_unlock(&dev->mutex);
 	return retval;
 }
+FOPS_WRITE_ITER_HELPER(iowarrior_write);
 
 /*
  *	iowarrior_ioctl
@@ -707,8 +709,8 @@ static __poll_t iowarrior_poll(struct file *file, poll_table * wait)
  */
 static const struct file_operations iowarrior_fops = {
 	.owner = THIS_MODULE,
-	.write = iowarrior_write,
-	.read = iowarrior_read,
+	.write_iter = iowarrior_write_iter,
+	.read_iter = iowarrior_read_iter,
 	.unlocked_ioctl = iowarrior_ioctl,
 	.open = iowarrior_open,
 	.release = iowarrior_release,
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7cbef74dfc9a..7fef44f35b45 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -433,16 +433,16 @@ static __poll_t ld_usb_poll(struct file *file, poll_table *wait)
 /*
  *	ld_usb_read
  */
-static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
-			   loff_t *ppos)
+static ssize_t ld_usb_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct ld_usb *dev;
 	size_t *actual_buffer;
 	size_t bytes_to_read;
 	int retval = 0;
 	int rv;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* verify that we actually have some data to read */
 	if (count == 0)
@@ -466,7 +466,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
 	while (dev->ring_head == dev->ring_tail) {
 		dev->interrupt_in_done = 0;
 		spin_unlock_irq(&dev->rbsl);
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto unlock_exit;
 		}
@@ -490,7 +490,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
 			 *actual_buffer-bytes_to_read);
 
 	/* copy one interrupt_in_buffer from ring_buffer into userspace */
-	if (copy_to_user(buffer, actual_buffer+1, bytes_to_read)) {
+	if (!copy_to_iter_full(actual_buffer+1, bytes_to_read, to)) {
 		retval = -EFAULT;
 		goto unlock_exit;
 	}
@@ -520,14 +520,14 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
 /*
  *	ld_usb_write
  */
-static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
-			    size_t count, loff_t *ppos)
+static ssize_t ld_usb_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct ld_usb *dev;
 	size_t bytes_to_write;
 	int retval = 0;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* verify that we actually have some data to write */
 	if (count == 0)
@@ -548,7 +548,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
 
 	/* wait until previous transfer is finished */
 	if (dev->interrupt_out_busy) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto unlock_exit;
 		}
@@ -566,7 +566,7 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
 	dev_dbg(&dev->intf->dev, "%s: count = %zu, bytes_to_write = %zu\n",
 		__func__, count, bytes_to_write);
 
-	if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
+	if (!copy_from_iter_full(dev->interrupt_out_buffer, bytes_to_write, from)) {
 		retval = -EFAULT;
 		goto unlock_exit;
 	}
@@ -622,8 +622,8 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
 /* file operations needed when we register this driver */
 static const struct file_operations ld_usb_fops = {
 	.owner =	THIS_MODULE,
-	.read  =	ld_usb_read,
-	.write =	ld_usb_write,
+	.read_iter  =	ld_usb_read,
+	.write_iter =	ld_usb_write,
 	.open =		ld_usb_open,
 	.release =	ld_usb_release,
 	.poll =		ld_usb_poll,
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 379cf01a6e96..57dcb5612734 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -218,8 +218,8 @@ struct lego_usb_tower {
 
 
 /* local function prototypes */
-static ssize_t tower_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos);
-static ssize_t tower_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos);
+static ssize_t tower_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t tower_write(struct kiocb *iocb, struct iov_iter *from);
 static inline void tower_delete(struct lego_usb_tower *dev);
 static int tower_open(struct inode *inode, struct file *file);
 static int tower_release(struct inode *inode, struct file *file);
@@ -237,8 +237,8 @@ static void tower_disconnect(struct usb_interface *interface);
 /* file operations needed when we register this driver */
 static const struct file_operations tower_fops = {
 	.owner =	THIS_MODULE,
-	.read  =	tower_read,
-	.write =	tower_write,
+	.read_iter  =	tower_read,
+	.write_iter =	tower_write,
 	.open =		tower_open,
 	.release =	tower_release,
 	.poll =		tower_poll,
@@ -489,15 +489,16 @@ static loff_t tower_llseek(struct file *file, loff_t off, int whence)
 /*
  *	tower_read
  */
-static ssize_t tower_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
+static ssize_t tower_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct lego_usb_tower *dev;
 	size_t bytes_to_read;
 	int i;
 	int retval = 0;
 	unsigned long timeout = 0;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* lock this object */
 	if (mutex_lock_interruptible(&dev->lock)) {
@@ -523,7 +524,7 @@ static ssize_t tower_read(struct file *file, char __user *buffer, size_t count,
 	/* wait for data */
 	tower_check_for_read_packet(dev);
 	while (dev->read_packet_length == 0) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto unlock_exit;
 		}
@@ -547,7 +548,7 @@ static ssize_t tower_read(struct file *file, char __user *buffer, size_t count,
 	/* copy the data from read_buffer into userspace */
 	bytes_to_read = min(count, dev->read_packet_length);
 
-	if (copy_to_user(buffer, dev->read_buffer, bytes_to_read)) {
+	if (!copy_to_iter_full(dev->read_buffer, bytes_to_read, to)) {
 		retval = -EFAULT;
 		goto unlock_exit;
 	}
@@ -573,13 +574,14 @@ static ssize_t tower_read(struct file *file, char __user *buffer, size_t count,
 /*
  *	tower_write
  */
-static ssize_t tower_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
+static ssize_t tower_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct lego_usb_tower *dev;
 	size_t bytes_to_write;
 	int retval = 0;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* lock this object */
 	if (mutex_lock_interruptible(&dev->lock)) {
@@ -601,7 +603,7 @@ static ssize_t tower_write(struct file *file, const char __user *buffer, size_t
 
 	/* wait until previous transfer is finished */
 	while (dev->interrupt_out_busy) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto unlock_exit;
 		}
@@ -616,7 +618,7 @@ static ssize_t tower_write(struct file *file, const char __user *buffer, size_t
 	dev_dbg(&dev->udev->dev, "%s: count = %zd, bytes_to_write = %zd\n",
 		__func__, count, bytes_to_write);
 
-	if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
+	if (!copy_from_iter_full(dev->interrupt_out_buffer, bytes_to_write, from)) {
 		retval = -EFAULT;
 		goto unlock_exit;
 	}
diff --git a/drivers/usb/misc/sisusbvga/sisusbvga.c b/drivers/usb/misc/sisusbvga/sisusbvga.c
index febf34f9f049..88a94fafe594 100644
--- a/drivers/usb/misc/sisusbvga/sisusbvga.c
+++ b/drivers/usb/misc/sisusbvga/sisusbvga.c
@@ -2428,6 +2428,7 @@ static ssize_t sisusb_read(struct file *file, char __user *buffer,
 
 	return errno ? errno : bytes_read;
 }
+FOPS_READ_ITER_HELPER(sisusb_read);
 
 static ssize_t sisusb_write(struct file *file, const char __user *buffer,
 		size_t count, loff_t *ppos)
@@ -2572,6 +2573,7 @@ static ssize_t sisusb_write(struct file *file, const char __user *buffer,
 
 	return errno ? errno : bytes_written;
 }
+FOPS_WRITE_ITER_HELPER(sisusb_write);
 
 static loff_t sisusb_lseek(struct file *file, loff_t offset, int orig)
 {
@@ -2757,8 +2759,8 @@ static const struct file_operations usb_sisusb_fops = {
 	.owner =	THIS_MODULE,
 	.open =		sisusb_open,
 	.release =	sisusb_release,
-	.read =		sisusb_read,
-	.write =	sisusb_write,
+	.read_iter =	sisusb_read_iter,
+	.write_iter =	sisusb_write_iter,
 	.llseek =	sisusb_lseek,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = sisusb_compat_ioctl,
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index bb546f624a45..8d826e648b84 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -121,14 +121,14 @@ static int lcd_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t lcd_read(struct file *file, char __user * buffer,
-			size_t count, loff_t *ppos)
+static ssize_t lcd_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct usb_lcd *dev;
 	int retval = 0;
 	int bytes_read;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	down_read(&dev->io_rwsem);
 
@@ -147,7 +147,7 @@ static ssize_t lcd_read(struct file *file, char __user * buffer,
 
 	/* if the read was successful, copy the data to userspace */
 	if (!retval) {
-		if (copy_to_user(buffer, dev->bulk_in_buffer, bytes_read))
+		if (!copy_to_iter_full(dev->bulk_in_buffer, bytes_read, to))
 			retval = -EFAULT;
 		else
 			retval = bytes_read;
@@ -214,15 +214,15 @@ static void lcd_write_bulk_callback(struct urb *urb)
 	up(&dev->limit_sem);
 }
 
-static ssize_t lcd_write(struct file *file, const char __user * user_buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct usb_lcd *dev;
 	int retval = 0, r;
 	struct urb *urb = NULL;
 	char *buf = NULL;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* verify that we actually have some data to write */
 	if (count == 0)
@@ -253,7 +253,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer,
 		goto error;
 	}
 
-	if (copy_from_user(buf, user_buffer, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		retval = -EFAULT;
 		goto error;
 	}
@@ -296,8 +296,8 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer,
 
 static const struct file_operations lcd_fops = {
 	.owner =        THIS_MODULE,
-	.read =         lcd_read,
-	.write =        lcd_write,
+	.read_iter =    lcd_read,
+	.write_iter =   lcd_write,
 	.open =         lcd_open,
 	.unlocked_ioctl = lcd_ioctl,
 	.release =      lcd_release,
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 9a0649d23693..b3dd24aeae23 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -398,15 +398,14 @@ static int yurex_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
-			  loff_t *ppos)
+static ssize_t yurex_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct usb_yurex *dev;
 	int len = 0;
 	char in_buffer[MAX_S64_STRLEN];
 	unsigned long flags;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	mutex_lock(&dev->io_mutex);
 	if (dev->disconnected) {		/* already disconnected */
@@ -424,11 +423,10 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
 	spin_unlock_irqrestore(&dev->lock, flags);
 	mutex_unlock(&dev->io_mutex);
 
-	return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
+	return simple_copy_to_iter(in_buffer, &iocb->ki_pos, len, to);
 }
 
-static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
-			   size_t count, loff_t *ppos)
+static ssize_t yurex_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct usb_yurex *dev;
 	int i, set = 0, retval = 0;
@@ -436,10 +434,11 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 	char *data = buffer;
 	unsigned long long c, c2 = 0;
 	signed long timeout = 0;
+	size_t count = iov_iter_count(from);
 	DEFINE_WAIT(wait);
 
 	count = min(sizeof(buffer) - 1, count);
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* verify that we actually have some data to write */
 	if (count == 0)
@@ -452,7 +451,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 		goto error;
 	}
 
-	if (copy_from_user(buffer, user_buffer, count)) {
+	if (!copy_from_iter_full(buffer, count, from)) {
 		mutex_unlock(&dev->io_mutex);
 		retval = -EFAULT;
 		goto error;
@@ -521,8 +520,8 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 
 static const struct file_operations yurex_fops = {
 	.owner =	THIS_MODULE,
-	.read =		yurex_read,
-	.write =	yurex_write,
+	.read_iter =	yurex_read,
+	.write_iter =	yurex_write,
 	.open =		yurex_open,
 	.release =	yurex_release,
 	.fasync	=	yurex_fasync,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 169/437] usb: mon: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (167 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 168/437] usb: misc: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 170/437] usb: mtu3: " Jens Axboe
                   ` (268 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/mon/mon_bin.c  | 3 ++-
 drivers/usb/mon/mon_stat.c | 9 ++++-----
 drivers/usb/mon/mon_text.c | 6 ++++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 4e30de4db1c0..af88dd18eafe 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -867,6 +867,7 @@ static ssize_t mon_bin_read(struct file *file, char __user *buf,
 	mutex_unlock(&rp->fetch_lock);
 	return done;
 }
+FOPS_READ_ITER_HELPER(mon_bin_read);
 
 /*
  * Remove at most nevents from chunked buffer.
@@ -1290,7 +1291,7 @@ static const struct file_operations mon_fops_binary = {
 	.owner =	THIS_MODULE,
 	.open =		mon_bin_open,
 	.llseek =	no_llseek,
-	.read =		mon_bin_read,
+	.read_iter =	mon_bin_read_iter,
 	/* .write =	mon_text_write, */
 	.poll =		mon_bin_poll,
 	.unlocked_ioctl = mon_bin_ioctl,
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 3c23805ab1a4..e13a81ade7cf 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -43,12 +43,11 @@ static int mon_stat_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t mon_stat_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t mon_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snap *sp = file->private_data;
+	struct snap *sp = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, sp->str, sp->slen);
+	return simple_copy_to_iter(sp->str, &iocb->ki_pos, sp->slen, to);
 }
 
 static int mon_stat_release(struct inode *inode, struct file *file)
@@ -63,7 +62,7 @@ const struct file_operations mon_fops_stat = {
 	.owner =	THIS_MODULE,
 	.open =		mon_stat_open,
 	.llseek =	no_llseek,
-	.read =		mon_stat_read,
+	.read_iter =	mon_stat_read,
 	/* .write =	mon_stat_write, */
 	/* .poll =		mon_stat_poll, */
 	/* .unlocked_ioctl =	mon_stat_ioctl, */
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 2fe9b95bac1d..ec50a0e23117 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -428,6 +428,7 @@ static ssize_t mon_text_read_t(struct file *file, char __user *buf,
 	mutex_unlock(&rp->printf_lock);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(mon_text_read_t);
 
 /* ppos is not advanced since the llseek operation is not permitted. */
 static ssize_t mon_text_read_u(struct file *file, char __user *buf,
@@ -476,6 +477,7 @@ static ssize_t mon_text_read_u(struct file *file, char __user *buf,
 	mutex_unlock(&rp->printf_lock);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(mon_text_read_u);
 
 static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp,
     struct file *file)
@@ -686,7 +688,7 @@ static const struct file_operations mon_fops_text_t = {
 	.owner =	THIS_MODULE,
 	.open =		mon_text_open,
 	.llseek =	no_llseek,
-	.read =		mon_text_read_t,
+	.read_iter =	mon_text_read_t_iter,
 	.release =	mon_text_release,
 };
 
@@ -694,7 +696,7 @@ static const struct file_operations mon_fops_text_u = {
 	.owner =	THIS_MODULE,
 	.open =		mon_text_open,
 	.llseek =	no_llseek,
-	.read =		mon_text_read_u,
+	.read_iter =	mon_text_read_u_iter,
 	.release =	mon_text_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 170/437] usb: mtu3: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (168 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 169/437] usb: mon: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 171/437] usb: musb: " Jens Axboe
                   ` (267 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/mtu3/mtu3_debugfs.c | 40 ++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_debugfs.c b/drivers/usb/mtu3/mtu3_debugfs.c
index f0de99858353..da73f486bfea 100644
--- a/drivers/usb/mtu3/mtu3_debugfs.c
+++ b/drivers/usb/mtu3/mtu3_debugfs.c
@@ -272,7 +272,7 @@ static int mtu3_ep_open(struct inode *inode, struct file *file)
 
 static const struct file_operations mtu3_ep_fops = {
 	.open = mtu3_ep_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -311,18 +311,18 @@ static int mtu3_probe_open(struct inode *inode, struct file *file)
 	return single_open(file, mtu3_probe_show, inode->i_private);
 }
 
-static ssize_t mtu3_probe_write(struct file *file, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t mtu3_probe_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const char *file_name = file_dentry(file)->d_iname;
-	struct seq_file *sf = file->private_data;
+	const char *file_name = file_dentry(iocb->ki_filp)->d_iname;
+	struct seq_file *sf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mtu3 *mtu = sf->private;
 	const struct debugfs_reg32 *regs;
 	char buf[32];
 	u32 val;
 	int i;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (kstrtou32(buf, 0, &val))
@@ -341,8 +341,8 @@ static ssize_t mtu3_probe_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations mtu3_probe_fops = {
 	.open = mtu3_probe_open,
-	.write = mtu3_probe_write,
-	.read = seq_read,
+	.write_iter = mtu3_probe_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -443,14 +443,14 @@ static int ssusb_mode_open(struct inode *inode, struct file *file)
 	return single_open(file, ssusb_mode_show, inode->i_private);
 }
 
-static ssize_t ssusb_mode_write(struct file *file, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t ssusb_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sf = file->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ssusb_mtk *ssusb = sf->private;
 	char buf[16];
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (!strncmp(buf, "host", 4) && !ssusb->is_host) {
@@ -467,8 +467,8 @@ static ssize_t ssusb_mode_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations ssusb_mode_fops = {
 	.open = ssusb_mode_open,
-	.write = ssusb_mode_write,
-	.read = seq_read,
+	.write_iter = ssusb_mode_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -489,16 +489,16 @@ static int ssusb_vbus_open(struct inode *inode, struct file *file)
 	return single_open(file, ssusb_vbus_show, inode->i_private);
 }
 
-static ssize_t ssusb_vbus_write(struct file *file, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t ssusb_vbus_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sf = file->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ssusb_mtk *ssusb = sf->private;
 	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
 	char buf[16];
 	bool enable;
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	if (kstrtobool(buf, &enable)) {
@@ -513,8 +513,8 @@ static ssize_t ssusb_vbus_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations ssusb_vbus_fops = {
 	.open = ssusb_vbus_open,
-	.write = ssusb_vbus_write,
-	.read = seq_read,
+	.write_iter = ssusb_vbus_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 171/437] usb: musb: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (169 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 170/437] usb: mtu3: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 172/437] usb: skeleton: " Jens Axboe
                   ` (266 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/musb/musb_debugfs.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 2d623284edf6..7123057d12f7 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -160,17 +160,17 @@ static int musb_test_mode_open(struct inode *inode, struct file *file)
 	return single_open(file, musb_test_mode_show, inode->i_private);
 }
 
-static ssize_t musb_test_mode_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t musb_test_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct musb		*musb = s->private;
 	u8			test;
 	char			buf[24];
 
 	memset(buf, 0x00, sizeof(buf));
 
-	if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	pm_runtime_get_sync(musb->controller);
@@ -223,8 +223,8 @@ static ssize_t musb_test_mode_write(struct file *file,
 
 static const struct file_operations musb_test_mode_fops = {
 	.open			= musb_test_mode_open,
-	.write			= musb_test_mode_write,
-	.read			= seq_read,
+	.write_iter		= musb_test_mode_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -260,17 +260,17 @@ static int musb_softconnect_open(struct inode *inode, struct file *file)
 	return single_open(file, musb_softconnect_show, inode->i_private);
 }
 
-static ssize_t musb_softconnect_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t musb_softconnect_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file		*s = file->private_data;
+	struct seq_file		*s = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	struct musb		*musb = s->private;
 	char			buf[2];
 	u8			reg;
 
 	memset(buf, 0x00, sizeof(buf));
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (!copy_from_iter_full(&buf, min_t(size_t, sizeof(buf) - 1, count), from))
 		return -EFAULT;
 
 	pm_runtime_get_sync(musb->controller);
@@ -315,8 +315,8 @@ static ssize_t musb_softconnect_write(struct file *file,
  */
 static const struct file_operations musb_softconnect_fops = {
 	.open			= musb_softconnect_open,
-	.write			= musb_softconnect_write,
-	.read			= seq_read,
+	.write_iter		= musb_softconnect_write,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 172/437] usb: skeleton: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (170 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 171/437] usb: musb: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 173/437] usb: gadget: atmel_usba_udc: " Jens Axboe
                   ` (265 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/usb-skeleton.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 900a64ad25e4..f039a13382c1 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -221,14 +221,14 @@ static int skel_do_read_io(struct usb_skel *dev, size_t count)
 	return rv;
 }
 
-static ssize_t skel_read(struct file *file, char *buffer, size_t count,
-			 loff_t *ppos)
+static ssize_t skel_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct usb_skel *dev;
 	int rv;
 	bool ongoing_io;
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	if (!count)
 		return 0;
@@ -251,7 +251,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count,
 
 	if (ongoing_io) {
 		/* nonblocking IO shall not wait */
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			rv = -EAGAIN;
 			goto exit;
 		}
@@ -301,9 +301,9 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count,
 		 * chunk tells us how much shall be copied
 		 */
 
-		if (copy_to_user(buffer,
+		if (!copy_to_iter_full(
 				 dev->bulk_in_buffer + dev->bulk_in_copied,
-				 chunk))
+				 chunk, to))
 			rv = -EFAULT;
 		else
 			rv = chunk;
@@ -356,16 +356,16 @@ static void skel_write_bulk_callback(struct urb *urb)
 	up(&dev->limit_sem);
 }
 
-static ssize_t skel_write(struct file *file, const char *user_buffer,
-			  size_t count, loff_t *ppos)
+static ssize_t skel_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct usb_skel *dev;
 	int retval = 0;
 	struct urb *urb = NULL;
 	char *buf = NULL;
 	size_t writesize = min_t(size_t, count, MAX_TRANSFER);
 
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 
 	/* verify that we actually have some data to write */
 	if (count == 0)
@@ -375,7 +375,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer,
 	 * limit the number of URBs in flight to stop a user from using up all
 	 * RAM
 	 */
-	if (!(file->f_flags & O_NONBLOCK)) {
+	if (!(iocb->ki_filp->f_flags & O_NONBLOCK)) {
 		if (down_interruptible(&dev->limit_sem)) {
 			retval = -ERESTARTSYS;
 			goto exit;
@@ -413,7 +413,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer,
 		goto error;
 	}
 
-	if (copy_from_user(buf, user_buffer, writesize)) {
+	if (!copy_from_iter_full(buf, writesize, from)) {
 		retval = -EFAULT;
 		goto error;
 	}
@@ -467,8 +467,8 @@ static ssize_t skel_write(struct file *file, const char *user_buffer,
 
 static const struct file_operations skel_fops = {
 	.owner =	THIS_MODULE,
-	.read =		skel_read,
-	.write =	skel_write,
+	.read_iter =	skel_read,
+	.write_iter =	skel_write,
 	.open =		skel_open,
 	.release =	skel_release,
 	.flush =	skel_flush,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 173/437] usb: gadget: atmel_usba_udc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (171 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 172/437] usb: skeleton: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 174/437] soc: qcom: " Jens Axboe
                   ` (264 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index b76885d78e8a..318e9152f295 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -122,6 +122,7 @@ static ssize_t queue_dbg_read(struct file *file, char __user *buf,
 
 	return actual;
 }
+FOPS_READ_ITER_HELPER(queue_dbg_read);
 
 static int queue_dbg_release(struct inode *inode, struct file *file)
 {
@@ -163,16 +164,14 @@ static int regs_dbg_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t regs_dbg_read(struct file *file, char __user *buf,
-		size_t nbytes, loff_t *ppos)
+static ssize_t regs_dbg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	int ret;
 
 	inode_lock(inode);
-	ret = simple_read_from_buffer(buf, nbytes, ppos,
-			file->private_data,
-			file_inode(file)->i_size);
+	ret = simple_copy_to_iter(iocb->ki_filp->private_data, &iocb->ki_pos,
+			file_inode(iocb->ki_filp)->i_size, to);
 	inode_unlock(inode);
 
 	return ret;
@@ -188,7 +187,7 @@ static const struct file_operations queue_dbg_fops = {
 	.owner		= THIS_MODULE,
 	.open		= queue_dbg_open,
 	.llseek		= no_llseek,
-	.read		= queue_dbg_read,
+	.read_iter	= queue_dbg_read_iter,
 	.release	= queue_dbg_release,
 };
 
@@ -196,7 +195,7 @@ static const struct file_operations regs_dbg_fops = {
 	.owner		= THIS_MODULE,
 	.open		= regs_dbg_open,
 	.llseek		= generic_file_llseek,
-	.read		= regs_dbg_read,
+	.read_iter	= regs_dbg_read,
 	.release	= regs_dbg_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 174/437] soc: qcom: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (172 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 173/437] usb: gadget: atmel_usba_udc: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 175/437] soc: aspeed: " Jens Axboe
                   ` (263 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/soc/qcom/cmd-db.c    |  2 +-
 drivers/soc/qcom/qcom_aoss.c | 14 ++++++-------
 drivers/soc/qcom/rmtfs_mem.c | 38 ++++++++++++++++++------------------
 drivers/soc/qcom/socinfo.c   |  4 ++--
 4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index a5fd68411bed..0589e63fdb0d 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -308,7 +308,7 @@ static const struct file_operations cmd_db_debugfs_ops = {
 #ifdef CONFIG_DEBUG_FS
 	.open = open_cmd_db_debugfs,
 #endif
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
index ca2f6b7629ce..6ce5fdf96432 100644
--- a/drivers/soc/qcom/qcom_aoss.c
+++ b/drivers/soc/qcom/qcom_aoss.c
@@ -504,11 +504,11 @@ static const struct qmp_debugfs_entry qmp_debugfs_entries[QMP_DEBUGFS_FILES] = {
 	{ "prevent_ddr_collapse", "{class: ddr_mol, res: ddr, val: %s}", true, "mol", "off" },
 };
 
-static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
-				 size_t count, loff_t *pos)
+static ssize_t qmp_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	const struct qmp_debugfs_entry *entry = NULL;
-	struct qmp *qmp = file->private_data;
+	struct qmp *qmp = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[QMP_MSG_LEN];
 	unsigned int uint_val;
 	const char *str_val;
@@ -517,7 +517,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(qmp->debugfs_files); i++) {
-		if (qmp->debugfs_files[i] == file->f_path.dentry) {
+		if (qmp->debugfs_files[i] == iocb->ki_filp->f_path.dentry) {
 			entry = &qmp_debugfs_entries[i];
 			break;
 		}
@@ -526,7 +526,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
 		return -EFAULT;
 
 	if (entry->is_bool) {
-		ret = kstrtobool_from_user(user_buf, count, &bool_val);
+		ret = kstrtobool_from_iter(from, count, &bool_val);
 		if (ret)
 			return ret;
 
@@ -536,7 +536,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
 		if (ret >= sizeof(buf))
 			return -EINVAL;
 	} else {
-		ret = kstrtou32_from_user(user_buf, count, 0, &uint_val);
+		ret = kstrtou32_from_iter(from, count, 0, &uint_val);
 		if (ret)
 			return ret;
 
@@ -554,7 +554,7 @@ static ssize_t qmp_debugfs_write(struct file *file, const char __user *user_buf,
 
 static const struct file_operations qmp_debugfs_fops = {
 	.open = simple_open,
-	.write = qmp_debugfs_write,
+	.write_iter = qmp_debugfs_write,
 };
 
 static void qmp_debugfs_create(struct qmp *qmp)
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index df850d073102..065faa808f49 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -15,6 +15,7 @@
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/firmware/qcom/qcom_scm.h>
+#include <linux/uio.h>
 
 #define QCOM_RMTFS_MEM_DEV_MAX	(MINORMASK + 1)
 #define NUM_MAX_VMIDS		2
@@ -79,40 +80,39 @@ static int qcom_rmtfs_mem_open(struct inode *inode, struct file *filp)
 
 	return 0;
 }
-static ssize_t qcom_rmtfs_mem_read(struct file *filp,
-			      char __user *buf, size_t count, loff_t *f_pos)
+static ssize_t qcom_rmtfs_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+	struct qcom_rmtfs_mem *rmtfs_mem = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
-	if (*f_pos >= rmtfs_mem->size)
+	if (iocb->ki_pos >= rmtfs_mem->size)
 		return 0;
 
-	if (*f_pos + count >= rmtfs_mem->size)
-		count = rmtfs_mem->size - *f_pos;
+	if (iocb->ki_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - iocb->ki_pos;
 
-	if (copy_to_user(buf, rmtfs_mem->base + *f_pos, count))
+	if (!copy_to_iter_full(rmtfs_mem->base + iocb->ki_pos, count, to))
 		return -EFAULT;
 
-	*f_pos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
-static ssize_t qcom_rmtfs_mem_write(struct file *filp,
-			       const char __user *buf, size_t count,
-			       loff_t *f_pos)
+static ssize_t qcom_rmtfs_mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct qcom_rmtfs_mem *rmtfs_mem = filp->private_data;
+	struct qcom_rmtfs_mem *rmtfs_mem = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*f_pos >= rmtfs_mem->size)
+	if (iocb->ki_pos >= rmtfs_mem->size)
 		return 0;
 
-	if (*f_pos + count >= rmtfs_mem->size)
-		count = rmtfs_mem->size - *f_pos;
+	if (iocb->ki_pos + count >= rmtfs_mem->size)
+		count = rmtfs_mem->size - iocb->ki_pos;
 
-	if (copy_from_user(rmtfs_mem->base + *f_pos, buf, count))
+	if (!copy_from_iter_full(rmtfs_mem->base + iocb->ki_pos, count, from))
 		return -EFAULT;
 
-	*f_pos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
@@ -152,8 +152,8 @@ static int qcom_rmtfs_mem_mmap(struct file *filep, struct vm_area_struct *vma)
 static const struct file_operations qcom_rmtfs_mem_fops = {
 	.owner = THIS_MODULE,
 	.open = qcom_rmtfs_mem_open,
-	.read = qcom_rmtfs_mem_read,
-	.write = qcom_rmtfs_mem_write,
+	.read_iter = qcom_rmtfs_mem_read,
+	.write_iter = qcom_rmtfs_mem_write,
 	.release = qcom_rmtfs_mem_release,
 	.llseek = default_llseek,
 	.mmap = qcom_rmtfs_mem_mmap,
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index e8ff9819ac47..fbee271d4646 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -467,7 +467,7 @@ static int qcom_open_##name(struct inode *inode, struct file *file)	\
 									\
 static const struct file_operations qcom_ ##name## _ops = {		\
 	.open = qcom_open_##name,					\
-	.read = seq_read,						\
+	.read_iter = seq_read_iter,					\
 	.llseek = seq_lseek,						\
 	.release = single_release,					\
 }
@@ -570,7 +570,7 @@ static int open_image_##type(struct inode *inode, struct file *file)	  \
 									  \
 static const struct file_operations qcom_image_##type##_ops = {	  \
 	.open = open_image_##type,					  \
-	.read = seq_read,						  \
+	.read_iter = seq_read_iter,					  \
 	.llseek = seq_lseek,						  \
 	.release = single_release,					  \
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 175/437] soc: aspeed: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (173 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 174/437] soc: qcom: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 176/437] soc: fsl: " Jens Axboe
                   ` (262 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/soc/aspeed/aspeed-lpc-snoop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c
index 888b5840c015..e807893b1624 100644
--- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
+++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
@@ -98,6 +98,7 @@ static ssize_t snoop_file_read(struct file *file, char __user *buffer,
 
 	return copied;
 }
+FOPS_READ_ITER_HELPER(snoop_file_read);
 
 static __poll_t snoop_file_poll(struct file *file,
 				    struct poll_table_struct *pt)
@@ -110,7 +111,7 @@ static __poll_t snoop_file_poll(struct file *file,
 
 static const struct file_operations snoop_fops = {
 	.owner  = THIS_MODULE,
-	.read   = snoop_file_read,
+	.read_iter   = snoop_file_read_iter,
 	.poll   = snoop_file_poll,
 	.llseek = noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 176/437] soc: fsl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (174 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 175/437] soc: aspeed: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 177/437] soc: mediatek: " Jens Axboe
                   ` (261 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/soc/fsl/dpaa2-console.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/fsl/dpaa2-console.c b/drivers/soc/fsl/dpaa2-console.c
index 6dbc77db7718..c0ababa17763 100644
--- a/drivers/soc/fsl/dpaa2-console.c
+++ b/drivers/soc/fsl/dpaa2-console.c
@@ -189,12 +189,12 @@ static int dpaa2_console_close(struct inode *node, struct file *fp)
 	return 0;
 }
 
-static ssize_t dpaa2_console_read(struct file *fp, char __user *buf,
-				  size_t count, loff_t *f_pos)
+static ssize_t dpaa2_console_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct console_data *cd = fp->private_data;
+	struct console_data *cd = iocb->ki_filp->private_data;
 	size_t bytes = dpaa2_console_size(cd);
 	size_t bytes_end = cd->end_addr - cd->cur_ptr;
+	size_t count = iov_iter_count(to);
 	size_t written = 0;
 	void *kbuf;
 	int err;
@@ -214,18 +214,17 @@ static ssize_t dpaa2_console_read(struct file *fp, char __user *buf,
 
 	if (bytes > bytes_end) {
 		memcpy_fromio(kbuf, cd->cur_ptr, bytes_end);
-		if (copy_to_user(buf, kbuf, bytes_end)) {
+		if (!copy_to_iter_full(kbuf, bytes_end, to)) {
 			err = -EFAULT;
 			goto err_free_buf;
 		}
-		buf += bytes_end;
 		cd->cur_ptr = cd->start_addr;
 		bytes -= bytes_end;
 		written += bytes_end;
 	}
 
 	memcpy_fromio(kbuf, cd->cur_ptr, bytes);
-	if (copy_to_user(buf, kbuf, bytes)) {
+	if (!copy_to_iter_full(kbuf, bytes, to)) {
 		err = -EFAULT;
 		goto err_free_buf;
 	}
@@ -245,7 +244,7 @@ static const struct file_operations dpaa2_mc_console_fops = {
 	.owner          = THIS_MODULE,
 	.open           = dpaa2_mc_console_open,
 	.release        = dpaa2_console_close,
-	.read           = dpaa2_console_read,
+	.read_iter      = dpaa2_console_read,
 };
 
 static struct miscdevice dpaa2_mc_console_dev = {
@@ -258,7 +257,7 @@ static const struct file_operations dpaa2_aiop_console_fops = {
 	.owner          = THIS_MODULE,
 	.open           = dpaa2_aiop_console_open,
 	.release        = dpaa2_console_close,
-	.read           = dpaa2_console_read,
+	.read_iter      = dpaa2_console_read,
 };
 
 static struct miscdevice dpaa2_aiop_console_dev = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 177/437] soc: mediatek: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (175 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 176/437] soc: fsl: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 178/437] soc: sifive: ccache: " Jens Axboe
                   ` (260 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/soc/mediatek/mtk-svs.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c
index c832f5c670bc..49e687a96aa0 100644
--- a/drivers/soc/mediatek/mtk-svs.c
+++ b/drivers/soc/mediatek/mtk-svs.c
@@ -149,7 +149,7 @@ static DEFINE_SPINLOCK(svs_lock);
 	static const struct file_operations svs_##name##_debug_fops = {	\
 		.owner = THIS_MODULE,					\
 		.open = svs_##name##_debug_open,			\
-		.read = seq_read,					\
+		.read_iter = seq_read_iter,				\
 		.llseek = seq_lseek,					\
 		.release = single_release,				\
 	}
@@ -164,8 +164,8 @@ static DEFINE_SPINLOCK(svs_lock);
 	static const struct file_operations svs_##name##_debug_fops = {	\
 		.owner = THIS_MODULE,					\
 		.open = svs_##name##_debug_open,			\
-		.read = seq_read,					\
-		.write = svs_##name##_debug_write,			\
+		.read_iter = seq_read_iter,				\
+		.write_iter = svs_##name##_debug_write,			\
 		.llseek = seq_lseek,					\
 		.release = single_release,				\
 	}
@@ -782,19 +782,18 @@ static int svs_enable_debug_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t svs_enable_debug_write(struct file *filp,
-				      const char __user *buffer,
-				      size_t count, loff_t *pos)
+static ssize_t svs_enable_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct svs_bank *svsb = file_inode(filp)->i_private;
+	struct svs_bank *svsb = file_inode(iocb->ki_filp)->i_private;
 	struct svs_platform *svsp = dev_get_drvdata(svsb->dev);
+	size_t count = iov_iter_count(from);
 	int enabled, ret;
 	char *buf = NULL;
 
 	if (count >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = (char *)memdup_user_nul(buffer, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 178/437] soc: sifive: ccache: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (176 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 177/437] soc: mediatek: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 179/437] drivers/pinctrl: convert to ->read_iter and ->write_iter Jens Axboe
                   ` (259 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/cache/sifive_ccache.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c
index 89ed6cd6b059..bcb6691f8f7c 100644
--- a/drivers/cache/sifive_ccache.c
+++ b/drivers/cache/sifive_ccache.c
@@ -71,12 +71,12 @@ enum {
 #ifdef CONFIG_DEBUG_FS
 static struct dentry *sifive_test;
 
-static ssize_t ccache_write(struct file *file, const char __user *data,
-			    size_t count, loff_t *ppos)
+static ssize_t ccache_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	unsigned int val;
 
-	if (kstrtouint_from_user(data, count, 0, &val))
+	if (kstrtouint_from_iter(from, count, 0, &val))
 		return -EINVAL;
 	if ((val < 0xFF) || (val >= 0x10000 && val < 0x100FF))
 		writel(val, ccache_base + SIFIVE_CCACHE_ECCINJECTERR);
@@ -88,7 +88,7 @@ static ssize_t ccache_write(struct file *file, const char __user *data,
 static const struct file_operations ccache_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = ccache_write
+	.write_iter = ccache_write
 };
 
 static void setup_sifive_debug(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 179/437] drivers/pinctrl: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (177 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 178/437] soc: sifive: ccache: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 180/437] drivers/phy: " Jens Axboe
                   ` (258 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/pinctrl/pinmux.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index d924207d629b..c7b229d76d7b 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -675,18 +675,18 @@ void pinmux_show_setting(struct seq_file *s,
 DEFINE_SHOW_ATTRIBUTE(pinmux_functions);
 DEFINE_SHOW_ATTRIBUTE(pinmux_pins);
 
-static ssize_t pinmux_select(struct file *file, const char __user *user_buf,
-				   size_t len, loff_t *ppos)
+static ssize_t pinmux_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sfile = file->private_data;
+	struct seq_file *sfile = iocb->ki_filp->private_data;
 	struct pinctrl_dev *pctldev = sfile->private;
 	const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
+	size_t len = iov_iter_count(from);
 	const char *const *groups;
 	char *buf, *gname, *fname;
 	unsigned int num_groups;
 	int fsel, gsel, ret;
 
-	buf = memdup_user_nul(user_buf, len);
+	buf = iterdup_nul(from, len);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -758,7 +758,7 @@ static int pinmux_select_open(struct inode *inode, struct file *file)
 static const struct file_operations pinmux_select_ops = {
 	.owner = THIS_MODULE,
 	.open = pinmux_select_open,
-	.write = pinmux_select,
+	.write_iter = pinmux_select,
 	.llseek = no_llseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 180/437] drivers/phy: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (178 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 179/437] drivers/pinctrl: convert to ->read_iter and ->write_iter Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 181/437] drivers/ufs: " Jens Axboe
                   ` (257 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index 25b86bbb9cec..8c57e2d89415 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -448,19 +448,19 @@ static int u2_phy_params_open(struct inode *inode, struct file *file)
 	return single_open(file, u2_phy_params_show, inode->i_private);
 }
 
-static ssize_t u2_phy_params_write(struct file *file, const char __user *ubuf,
-				   size_t count, loff_t *ppos)
+static ssize_t u2_phy_params_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const char *fname = file_dentry(file)->d_iname;
-	struct seq_file *sf = file->private_data;
+	const char *fname = file_dentry(iocb->ki_filp)->d_iname;
+	struct seq_file *sf = iocb->ki_filp->private_data;
 	struct mtk_phy_instance *inst = sf->private;
 	struct u2phy_banks *u2_banks = &inst->u2_banks;
+	size_t count = iov_iter_count(from);
 	void __iomem *com = u2_banks->com;
 	ssize_t rc;
 	u32 val;
 	int ret;
 
-	rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val);
+	rc = kstrtouint_from_iter(from, USER_BUF_LEN(count), 0, &val);
 	if (rc)
 		return rc;
 
@@ -504,8 +504,8 @@ static ssize_t u2_phy_params_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations u2_phy_fops = {
 	.open = u2_phy_params_open,
-	.write = u2_phy_params_write,
-	.read = seq_read,
+	.write_iter = u2_phy_params_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -574,19 +574,19 @@ static int u3_phy_params_open(struct inode *inode, struct file *file)
 	return single_open(file, u3_phy_params_show, inode->i_private);
 }
 
-static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf,
-				   size_t count, loff_t *ppos)
+static ssize_t u3_phy_params_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const char *fname = file_dentry(file)->d_iname;
-	struct seq_file *sf = file->private_data;
+	const char *fname = file_dentry(iocb->ki_filp)->d_iname;
+	struct seq_file *sf = iocb->ki_filp->private_data;
 	struct mtk_phy_instance *inst = sf->private;
 	struct u3phy_banks *u3_banks = &inst->u3_banks;
 	void __iomem *phyd = u3_banks->phyd;
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 	u32 val;
 	int ret;
 
-	rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val);
+	rc = kstrtouint_from_iter(from, USER_BUF_LEN(count), 0, &val);
 	if (rc)
 		return rc;
 
@@ -624,8 +624,8 @@ static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations u3_phy_fops = {
 	.open = u3_phy_params_open,
-	.write = u3_phy_params_write,
-	.read = seq_read,
+	.write_iter = u3_phy_params_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 181/437] drivers/ufs: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (179 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 180/437] drivers/phy: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 182/437] drivers/uio: " Jens Axboe
                   ` (256 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/ufs/core/ufs-debugfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/ufs/core/ufs-debugfs.c b/drivers/ufs/core/ufs-debugfs.c
index e3baed6c70bd..6f5116d024f3 100644
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -157,17 +157,17 @@ static int ufs_saved_err_show(struct seq_file *s, void *data)
 	return 0;
 }
 
-static ssize_t ufs_saved_err_write(struct file *file, const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t ufs_saved_err_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ufs_debugfs_attr *attr = file->f_inode->i_private;
-	struct ufs_hba *hba = hba_from_file(file);
+	struct ufs_debugfs_attr *attr = iocb->ki_filp->f_inode->i_private;
+	struct ufs_hba *hba = hba_from_file(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	char val_str[16] = { };
 	int val, ret;
 
 	if (count > sizeof(val_str))
 		return -EINVAL;
-	if (copy_from_user(val_str, buf, count))
+	if (!copy_from_iter_full(val_str, count, from))
 		return -EFAULT;
 	ret = kstrtoint(val_str, 0, &val);
 	if (ret < 0)
@@ -196,8 +196,8 @@ static int ufs_saved_err_open(struct inode *inode, struct file *file)
 static const struct file_operations ufs_saved_err_fops = {
 	.owner		= THIS_MODULE,
 	.open		= ufs_saved_err_open,
-	.read		= seq_read,
-	.write		= ufs_saved_err_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= ufs_saved_err_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 182/437] drivers/uio: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (180 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 181/437] drivers/ufs: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 183/437] drivers/platform: " Jens Axboe
                   ` (255 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/uio/uio.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 009158fef2a8..510d3707e694 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -563,10 +563,10 @@ static __poll_t uio_poll(struct file *filep, poll_table *wait)
 	return 0;
 }
 
-static ssize_t uio_read(struct file *filep, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t uio_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uio_listener *listener = filep->private_data;
+	struct uio_listener *listener = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct uio_device *idev = listener->dev;
 	DECLARE_WAITQUEUE(wait, current);
 	ssize_t retval = 0;
@@ -591,7 +591,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
 		event_count = atomic_read(&idev->event);
 		if (event_count != listener->event_count) {
 			__set_current_state(TASK_RUNNING);
-			if (copy_to_user(buf, &event_count, count))
+			if (!copy_to_iter_full(&event_count, count, to))
 				retval = -EFAULT;
 			else {
 				listener->event_count = event_count;
@@ -600,7 +600,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
 			break;
 		}
 
-		if (filep->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			break;
 		}
@@ -618,18 +618,18 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
 	return retval;
 }
 
-static ssize_t uio_write(struct file *filep, const char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t uio_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct uio_listener *listener = filep->private_data;
+	struct uio_listener *listener = iocb->ki_filp->private_data;
 	struct uio_device *idev = listener->dev;
+	size_t count = iov_iter_count(from);
 	ssize_t retval;
 	s32 irq_on;
 
 	if (count != sizeof(s32))
 		return -EINVAL;
 
-	if (copy_from_user(&irq_on, buf, count))
+	if (!copy_from_iter_full(&irq_on, count, from))
 		return -EFAULT;
 
 	mutex_lock(&idev->info_lock);
@@ -866,8 +866,8 @@ static const struct file_operations uio_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uio_open,
 	.release	= uio_release,
-	.read		= uio_read,
-	.write		= uio_write,
+	.read_iter	= uio_read,
+	.write_iter	= uio_write,
 	.mmap		= uio_mmap,
 	.poll		= uio_poll,
 	.fasync		= uio_fasync,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 183/437] drivers/platform: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (181 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 182/437] drivers/uio: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 184/437] drivers/mtd: " Jens Axboe
                   ` (254 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/platform/chrome/cros_ec_chardev.c     | 20 +++++------
 drivers/platform/chrome/cros_ec_debugfs.c     | 33 ++++++++-----------
 drivers/platform/chrome/wilco_ec/debugfs.c    | 19 +++++------
 drivers/platform/chrome/wilco_ec/event.c      | 18 +++++-----
 drivers/platform/chrome/wilco_ec/telemetry.c  | 20 +++++------
 drivers/platform/goldfish/goldfish_pipe.c     |  6 ++--
 drivers/platform/olpc/olpc-ec.c               | 15 ++++-----
 .../surface/surface_aggregator_cdev.c         |  3 +-
 drivers/platform/surface/surface_dtx.c        |  3 +-
 drivers/platform/x86/amd/pmc/pmc.c            | 21 ++++++------
 drivers/platform/x86/amd/pmf/tee-if.c         | 10 +++---
 drivers/platform/x86/apple-gmux.c             | 25 +++++++-------
 drivers/platform/x86/asus-wmi.c               |  2 +-
 drivers/platform/x86/dell/dell-smbios-wmi.c   | 11 +++----
 drivers/platform/x86/dell/dell-smo8800.c      |  3 +-
 drivers/platform/x86/intel/pmc/core.c         | 24 +++++++-------
 drivers/platform/x86/intel/pmc/core.h         |  4 +--
 .../platform/x86/intel/telemetry/debugfs.c    | 24 +++++++-------
 drivers/platform/x86/intel/tpmi.c             | 11 ++++---
 drivers/platform/x86/sony-laptop.c            |  3 +-
 20 files changed, 136 insertions(+), 139 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index 81950bb2c6da..527588147a2f 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -197,13 +197,13 @@ static __poll_t cros_ec_chardev_poll(struct file *filp, poll_table *wait)
 	return EPOLLIN | EPOLLRDNORM;
 }
 
-static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
-				     size_t length, loff_t *offset)
+static ssize_t cros_ec_chardev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char msg[sizeof(struct ec_response_get_version) +
 		 sizeof(CROS_EC_DEV_VERSION)];
-	struct chardev_priv *priv = filp->private_data;
+	struct chardev_priv *priv = iocb->ki_filp->private_data;
 	struct cros_ec_dev *ec_dev = priv->ec_dev;
+	size_t length = iov_iter_count(to);
 	size_t count;
 	int ret;
 
@@ -211,7 +211,7 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 		struct ec_event *event;
 
 		event = cros_ec_chardev_fetch_event(priv, length != 0,
-						!(filp->f_flags & O_NONBLOCK));
+					!(iocb->ki_filp->f_flags & O_NONBLOCK));
 		if (IS_ERR(event))
 			return PTR_ERR(event);
 		/*
@@ -223,18 +223,18 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 
 		/* The event is 1 byte of type plus the payload */
 		count = min(length, event->size + 1);
-		ret = copy_to_user(buffer, &event->event_type, count);
+		ret = !copy_to_iter_full(&event->event_type, count, to);
 		kfree(event);
 		if (ret) /* the copy failed */
 			return -EFAULT;
-		*offset = count;
+		iocb->ki_pos = count;
 		return count;
 	}
 
 	/*
 	 * Legacy behavior if no event mask is defined
 	 */
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	ret = ec_get_version(ec_dev, msg, sizeof(msg));
@@ -243,10 +243,10 @@ static ssize_t cros_ec_chardev_read(struct file *filp, char __user *buffer,
 
 	count = min(length, strlen(msg));
 
-	if (copy_to_user(buffer, msg, count))
+	if (!copy_to_iter_full(msg, count, to))
 		return -EFAULT;
 
-	*offset = count;
+	iocb->ki_pos = count;
 	return count;
 }
 
@@ -366,7 +366,7 @@ static long cros_ec_chardev_ioctl(struct file *filp, unsigned int cmd,
 static const struct file_operations chardev_fops = {
 	.open		= cros_ec_chardev_open,
 	.poll		= cros_ec_chardev_poll,
-	.read		= cros_ec_chardev_read,
+	.read_iter	= cros_ec_chardev_read,
 	.release	= cros_ec_chardev_release,
 	.unlocked_ioctl	= cros_ec_chardev_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c
index 6bf6f0e7b597..d4a00fc8f958 100644
--- a/drivers/platform/chrome/cros_ec_debugfs.c
+++ b/drivers/platform/chrome/cros_ec_debugfs.c
@@ -128,17 +128,17 @@ static int cros_ec_console_log_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t cros_ec_console_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct circ_buf *cb = &debug_info->log_buffer;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 
 	mutex_lock(&debug_info->log_mutex);
 
 	while (!CIRC_CNT(cb->head, cb->tail, LOG_SIZE)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto error;
 		}
@@ -159,7 +159,7 @@ static ssize_t cros_ec_console_log_read(struct file *file, char __user *buf,
 	ret = min_t(size_t, CIRC_CNT_TO_END(cb->head, cb->tail, LOG_SIZE),
 		    count);
 
-	if (copy_to_user(buf, cb->buf + cb->tail, ret)) {
+	if (!copy_to_iter_full(cb->buf + cb->tail, ret, to)) {
 		ret = -EFAULT;
 		goto error;
 	}
@@ -194,13 +194,10 @@ static int cros_ec_console_log_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t cros_ec_pdinfo_read(struct file *file,
-				   char __user *user_buf,
-				   size_t count,
-				   loff_t *ppos)
+static ssize_t cros_ec_pdinfo_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char read_buf[EC_USB_PD_MAX_PORTS * 40], *p = read_buf;
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
 	struct {
 		struct cros_ec_command msg;
@@ -242,8 +239,7 @@ static ssize_t cros_ec_pdinfo_read(struct file *file,
 			       resp->polarity);
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       read_buf, p - read_buf);
+	return simple_copy_to_iter(read_buf, &iocb->ki_pos, p - read_buf, to);
 }
 
 static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
@@ -265,10 +261,9 @@ static bool cros_ec_uptime_is_supported(struct cros_ec_device *ec_dev)
 	return true;
 }
 
-static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t cros_ec_uptime_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cros_ec_debugfs *debug_info = file->private_data;
+	struct cros_ec_debugfs *debug_info = iocb->ki_filp->private_data;
 	struct cros_ec_device *ec_dev = debug_info->ec->ec_dev;
 	struct {
 		struct cros_ec_command cmd;
@@ -290,13 +285,13 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf,
 	ret = scnprintf(read_buf, sizeof(read_buf), "%u\n",
 			resp->time_since_ec_boot_ms);
 
-	return simple_read_from_buffer(user_buf, count, ppos, read_buf, ret);
+	return simple_copy_to_iter(read_buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations cros_ec_console_log_fops = {
 	.owner = THIS_MODULE,
 	.open = cros_ec_console_log_open,
-	.read = cros_ec_console_log_read,
+	.read_iter = cros_ec_console_log_read,
 	.llseek = no_llseek,
 	.poll = cros_ec_console_log_poll,
 	.release = cros_ec_console_log_release,
@@ -305,14 +300,14 @@ static const struct file_operations cros_ec_console_log_fops = {
 static const struct file_operations cros_ec_pdinfo_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = cros_ec_pdinfo_read,
+	.read_iter = cros_ec_pdinfo_read,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations cros_ec_uptime_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = cros_ec_uptime_read,
+	.read_iter = cros_ec_uptime_read,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
index 93c11f81ca45..b3e1850a1dbc 100644
--- a/drivers/platform/chrome/wilco_ec/debugfs.c
+++ b/drivers/platform/chrome/wilco_ec/debugfs.c
@@ -92,10 +92,10 @@ static int parse_hex_sentence(const char *in, int isize, u8 *out, int osize)
 /* The message type takes up two bytes*/
 #define TYPE_AND_DATA_SIZE ((EC_MAILBOX_DATA_SIZE) + 2)
 
-static ssize_t raw_write(struct file *file, const char __user *user_buf,
-			 size_t count, loff_t *ppos)
+static ssize_t raw_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf = debug_info->formatted_data;
+	size_t count = iov_iter_count(from);
 	struct wilco_ec_message msg;
 	u8 request_data[TYPE_AND_DATA_SIZE];
 	ssize_t kcount;
@@ -104,8 +104,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 	if (count > FORMATTED_BUFFER_SIZE)
 		return -EINVAL;
 
-	kcount = simple_write_to_buffer(buf, FORMATTED_BUFFER_SIZE, ppos,
-					user_buf, count);
+	kcount = simple_copy_from_iter(buf, &iocb->ki_pos, FORMATTED_BUFFER_SIZE,
+					from);
 	if (kcount < 0)
 		return kcount;
 
@@ -132,8 +132,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t raw_read(struct file *file, char __user *user_buf, size_t count,
-			loff_t *ppos)
+static ssize_t raw_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int fmt_len = 0;
 
@@ -147,14 +146,14 @@ static ssize_t raw_read(struct file *file, char __user *user_buf, size_t count,
 		debug_info->response_size = 0;
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       debug_info->formatted_data, fmt_len);
+	return simple_copy_to_iter(debug_info->formatted_data, &iocb->ki_pos,
+					fmt_len, to);
 }
 
 static const struct file_operations fops_raw = {
 	.owner = THIS_MODULE,
-	.read = raw_read,
-	.write = raw_write,
+	.read_iter = raw_read,
+	.write_iter = raw_write,
 	.llseek = no_llseek,
 };
 
diff --git a/drivers/platform/chrome/wilco_ec/event.c b/drivers/platform/chrome/wilco_ec/event.c
index 13291fb4214e..581a4c13847c 100644
--- a/drivers/platform/chrome/wilco_ec/event.c
+++ b/drivers/platform/chrome/wilco_ec/event.c
@@ -335,10 +335,8 @@ static __poll_t event_poll(struct file *filp, poll_table *wait)
 
 /**
  * event_read() - Callback for passing event data to userspace via read().
- * @filp: The file we are reading from.
- * @buf: Pointer to userspace buffer to fill with one event.
- * @count: Number of bytes requested. Must be at least EC_ACPI_MAX_EVENT_SIZE.
- * @pos: File position pointer, irrelevant since we don't support seeking.
+ * @iocb: Metadata for IO
+ * @to: Pointer to userspace buffer to fill with one event.
  *
  * Removes the first event from the queue, places it in the passed buffer.
  *
@@ -349,10 +347,10 @@ static __poll_t event_poll(struct file *filp, poll_table *wait)
  *
  * Return: Number of bytes placed in buffer, negative error code on failure.
  */
-static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t event_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct event_device_data *dev_data = filp->private_data;
+	struct event_device_data *dev_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct ec_event *event;
 	ssize_t n_bytes_written = 0;
 	int err;
@@ -364,7 +362,7 @@ static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
 	spin_lock(&dev_data->queue_lock);
 	while (event_queue_empty(dev_data->events)) {
 		spin_unlock(&dev_data->queue_lock);
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		err = wait_event_interruptible(dev_data->wq,
@@ -381,7 +379,7 @@ static ssize_t event_read(struct file *filp, char __user *buf, size_t count,
 	event = event_queue_pop(dev_data->events);
 	spin_unlock(&dev_data->queue_lock);
 	n_bytes_written = ec_event_size(event);
-	if (copy_to_user(buf, event, n_bytes_written))
+	if (!copy_to_iter_full(event, n_bytes_written, to))
 		n_bytes_written = -EFAULT;
 	kfree(event);
 
@@ -401,7 +399,7 @@ static int event_release(struct inode *inode, struct file *filp)
 static const struct file_operations event_fops = {
 	.open = event_open,
 	.poll  = event_poll,
-	.read = event_read,
+	.read_iter = event_read,
 	.release = event_release,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
diff --git a/drivers/platform/chrome/wilco_ec/telemetry.c b/drivers/platform/chrome/wilco_ec/telemetry.c
index b7c616f3d179..dbb937382cef 100644
--- a/drivers/platform/chrome/wilco_ec/telemetry.c
+++ b/drivers/platform/chrome/wilco_ec/telemetry.c
@@ -261,17 +261,17 @@ static int telem_open(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t telem_write(struct file *filp, const char __user *buf,
-			   size_t count, loff_t *pos)
+static ssize_t telem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct telem_session_data *sess_data = filp->private_data;
+	struct telem_session_data *sess_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wilco_ec_message msg = {};
 	int ret;
 
 	if (count > sizeof(sess_data->request))
 		return -EMSGSIZE;
 	memset(&sess_data->request, 0, sizeof(sess_data->request));
-	if (copy_from_user(&sess_data->request, buf, count))
+	if (!copy_from_iter_full(&sess_data->request, count, from))
 		return -EFAULT;
 	ret = check_telem_request(&sess_data->request, count);
 	if (ret < 0)
@@ -295,17 +295,17 @@ static ssize_t telem_write(struct file *filp, const char __user *buf,
 	return count;
 }
 
-static ssize_t telem_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t telem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct telem_session_data *sess_data = filp->private_data;
+	struct telem_session_data *sess_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (!sess_data->has_msg)
 		return -ENODATA;
 	if (count > sizeof(sess_data->response))
 		return -EINVAL;
 
-	if (copy_to_user(buf, sess_data->response, count))
+	if (!copy_to_iter_full(sess_data->response, count, to))
 		return -EFAULT;
 
 	sess_data->has_msg = false;
@@ -326,8 +326,8 @@ static int telem_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations telem_fops = {
 	.open = telem_open,
-	.write = telem_write,
-	.read = telem_read,
+	.write_iter = telem_write,
+	.read_iter = telem_read,
 	.release = telem_release,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index 061aa9647c19..8a75fa0b139b 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -475,6 +475,7 @@ static ssize_t goldfish_pipe_read(struct file *filp, char __user *buffer,
 	return goldfish_pipe_read_write(filp, buffer, bufflen,
 					/* is_write */ 0);
 }
+FOPS_READ_ITER_HELPER(goldfish_pipe_read);
 
 static ssize_t goldfish_pipe_write(struct file *filp,
 				   const char __user *buffer, size_t bufflen,
@@ -486,6 +487,7 @@ static ssize_t goldfish_pipe_write(struct file *filp,
 	return goldfish_pipe_read_write(filp, no_const_buffer, bufflen,
 					/* is_write */ 1);
 }
+FOPS_WRITE_ITER_HELPER(goldfish_pipe_write);
 
 static __poll_t goldfish_pipe_poll(struct file *filp, poll_table *wait)
 {
@@ -779,8 +781,8 @@ static int goldfish_pipe_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations goldfish_pipe_fops = {
 	.owner = THIS_MODULE,
-	.read = goldfish_pipe_read,
-	.write = goldfish_pipe_write,
+	.read_iter = goldfish_pipe_read_iter,
+	.write_iter = goldfish_pipe_write_iter,
 	.poll = goldfish_pipe_poll,
 	.open = goldfish_pipe_open,
 	.release = goldfish_pipe_release,
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 921520475ff6..89cf016e0767 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -258,10 +258,10 @@ static DEFINE_MUTEX(ec_dbgfs_lock);
 static unsigned char ec_dbgfs_resp[EC_MAX_CMD_REPLY];
 static unsigned int ec_dbgfs_resp_bytes;
 
-static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
-		size_t size, loff_t *ppos)
+static ssize_t ec_dbgfs_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, m;
+	size_t size = iov_iter_count(from);
 	unsigned char ec_cmd[EC_MAX_CMD_ARGS];
 	unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
 	char cmdbuf[64] = "";
@@ -269,7 +269,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 
 	mutex_lock(&ec_dbgfs_lock);
 
-	size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size);
+	size = simple_copy_from_iter(cmdbuf, &iocb->ki_pos, sizeof(cmdbuf), from);
 
 	m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0],
 			&ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
@@ -303,8 +303,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
 	return size;
 }
 
-static ssize_t ec_dbgfs_cmd_read(struct file *file, char __user *buf,
-		size_t size, loff_t *ppos)
+static ssize_t ec_dbgfs_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	unsigned int i, r;
 	char *rp;
@@ -319,12 +318,12 @@ static ssize_t ec_dbgfs_cmd_read(struct file *file, char __user *buf,
 	rp += sprintf(rp, "\n");
 
 	r = rp - respbuf;
-	return simple_read_from_buffer(buf, size, ppos, respbuf, r);
+	return simple_copy_to_iter(respbuf, &iocb->ki_pos, r, to);
 }
 
 static const struct file_operations ec_dbgfs_ops = {
-	.write = ec_dbgfs_cmd_write,
-	.read = ec_dbgfs_cmd_read,
+	.write_iter = ec_dbgfs_cmd_write,
+	.read_iter = ec_dbgfs_cmd_read,
 };
 
 static struct dentry *olpc_ec_setup_debugfs(void)
diff --git a/drivers/platform/surface/surface_aggregator_cdev.c b/drivers/platform/surface/surface_aggregator_cdev.c
index 07e065b9159f..232f487c3eaf 100644
--- a/drivers/platform/surface/surface_aggregator_cdev.c
+++ b/drivers/platform/surface/surface_aggregator_cdev.c
@@ -637,6 +637,7 @@ static ssize_t ssam_cdev_read(struct file *file, char __user *buf, size_t count,
 	up_read(&cdev->lock);
 	return copied;
 }
+FOPS_READ_ITER_HELPER(ssam_cdev_read);
 
 static __poll_t ssam_cdev_poll(struct file *file, struct poll_table_struct *pt)
 {
@@ -665,7 +666,7 @@ static const struct file_operations ssam_controller_fops = {
 	.owner          = THIS_MODULE,
 	.open           = ssam_cdev_device_open,
 	.release        = ssam_cdev_device_release,
-	.read           = ssam_cdev_read,
+	.read_iter      = ssam_cdev_read_iter,
 	.poll           = ssam_cdev_poll,
 	.fasync         = ssam_cdev_fasync,
 	.unlocked_ioctl = ssam_cdev_device_ioctl,
diff --git a/drivers/platform/surface/surface_dtx.c b/drivers/platform/surface/surface_dtx.c
index 2de843b7ea70..f2b3fe8dcd72 100644
--- a/drivers/platform/surface/surface_dtx.c
+++ b/drivers/platform/surface/surface_dtx.c
@@ -522,6 +522,7 @@ static ssize_t surface_dtx_read(struct file *file, char __user *buf, size_t coun
 	up_read(&ddev->lock);
 	return copied;
 }
+FOPS_READ_ITER_HELPER(surface_dtx_read);
 
 static __poll_t surface_dtx_poll(struct file *file, struct poll_table_struct *pt)
 {
@@ -550,7 +551,7 @@ static const struct file_operations surface_dtx_fops = {
 	.owner          = THIS_MODULE,
 	.open           = surface_dtx_open,
 	.release        = surface_dtx_release,
-	.read           = surface_dtx_read,
+	.read_iter      = surface_dtx_read_iter,
 	.poll           = surface_dtx_poll,
 	.fasync         = surface_dtx_fasync,
 	.unlocked_ioctl = surface_dtx_ioctl,
diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index 108e12fd580f..c4342280e43d 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -214,14 +214,13 @@ static int amd_pmc_stb_debugfs_open(struct inode *inode, struct file *filp)
 	return rc;
 }
 
-static ssize_t amd_pmc_stb_debugfs_read(struct file *filp, char __user *buf, size_t size,
-					loff_t *pos)
+static ssize_t amd_pmc_stb_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	if (!filp->private_data)
+	if (!iocb->ki_filp->private_data)
 		return -EINVAL;
 
-	return simple_read_from_buffer(buf, size, pos, filp->private_data,
-				       FIFO_SIZE * sizeof(u32));
+	return simple_copy_to_iter(iocb->ki_filp->private_data, &iocb->ki_pos,
+				   FIFO_SIZE * sizeof(u32), to);
 }
 
 static int amd_pmc_stb_debugfs_release(struct inode *inode, struct file *filp)
@@ -233,7 +232,7 @@ static int amd_pmc_stb_debugfs_release(struct inode *inode, struct file *filp)
 static const struct file_operations amd_pmc_stb_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = amd_pmc_stb_debugfs_open,
-	.read = amd_pmc_stb_debugfs_read,
+	.read_iter = amd_pmc_stb_debugfs_read,
 	.release = amd_pmc_stb_debugfs_release,
 };
 
@@ -321,12 +320,12 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t amd_pmc_stb_debugfs_read_v2(struct file *filp, char __user *buf, size_t size,
-					   loff_t *pos)
+static ssize_t amd_pmc_stb_debugfs_read_v2(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct amd_pmc_stb_v2_data *data = filp->private_data;
+	struct amd_pmc_stb_v2_data *data = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, size, pos, data->data, data->size);
+	return simple_copy_to_iter(data->data, &iocb->ki_pos, data->size, to);
 }
 
 static int amd_pmc_stb_debugfs_release_v2(struct inode *inode, struct file *filp)
@@ -338,7 +337,7 @@ static int amd_pmc_stb_debugfs_release_v2(struct inode *inode, struct file *filp
 static const struct file_operations amd_pmc_stb_debugfs_fops_v2 = {
 	.owner = THIS_MODULE,
 	.open = amd_pmc_stb_debugfs_open_v2,
-	.read = amd_pmc_stb_debugfs_read_v2,
+	.read_iter = amd_pmc_stb_debugfs_read_v2,
 	.release = amd_pmc_stb_debugfs_release_v2,
 };
 
diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index b438de4d6bfc..3b6bf12a31c4 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -289,10 +289,10 @@ static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev)
 			     dev->policy_sz, false);
 }
 
-static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
-				   size_t length, loff_t *pos)
+static ssize_t amd_pmf_get_pb_data(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct amd_pmf_dev *dev = filp->private_data;
+	struct amd_pmf_dev *dev = iocb->ki_filp->private_data;
+	size_t length = iov_iter_count(from);
 	unsigned char *new_policy_buf;
 	int ret;
 
@@ -305,7 +305,7 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
 	if (!new_policy_buf)
 		return -ENOMEM;
 
-	if (copy_from_user(new_policy_buf, buf, length)) {
+	if (!copy_from_iter_full(new_policy_buf, length, from)) {
 		kfree(new_policy_buf);
 		return -EFAULT;
 	}
@@ -323,7 +323,7 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
 }
 
 static const struct file_operations pb_fops = {
-	.write = amd_pmf_get_pb_data,
+	.write_iter = amd_pmf_get_pb_data,
 	.open = simple_open,
 };
 
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index 1417e230edbd..7c078a27c67b 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -691,25 +691,26 @@ static void gmux_notify_handler(acpi_handle device, u32 value, void *context)
  * 1 and 4 byte writes are also allowed.
  */
 
-static ssize_t gmux_selected_port_data_write(struct file *file,
-		const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t gmux_selected_port_data_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct apple_gmux_data *gmux_data = file->private_data;
+	struct apple_gmux_data *gmux_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -EINVAL;
 
 	if (count == 1) {
 		u8 data;
 
-		if (copy_from_user(&data, userbuf, 1))
+		if (!copy_from_iter_full(&data, 1, from))
 			return -EFAULT;
 
 		gmux_write8(gmux_data, gmux_data->selected_port, data);
 	} else if (count == 4) {
 		u32 data;
 
-		if (copy_from_user(&data, userbuf, 4))
+		if (!copy_from_iter_full(&data, 4, from))
 			return -EFAULT;
 
 		gmux_write32(gmux_data, gmux_data->selected_port, data);
@@ -719,21 +720,21 @@ static ssize_t gmux_selected_port_data_write(struct file *file,
 	return count;
 }
 
-static ssize_t gmux_selected_port_data_read(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t gmux_selected_port_data_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct apple_gmux_data *gmux_data = file->private_data;
+	struct apple_gmux_data *gmux_data = iocb->ki_filp->private_data;
 	u32 data;
 
 	data = gmux_read32(gmux_data, gmux_data->selected_port);
 
-	return simple_read_from_buffer(userbuf, count, ppos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations gmux_port_data_ops = {
 	.open = simple_open,
-	.write = gmux_selected_port_data_write,
-	.read = gmux_selected_port_data_read
+	.write_iter = gmux_selected_port_data_write,
+	.read_iter = gmux_selected_port_data_read
 };
 
 static void gmux_init_debugfs(struct apple_gmux_data *gmux_data)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3f07bbf809ef..02d874c4d30c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4367,7 +4367,7 @@ static int asus_wmi_debugfs_open(struct inode *inode, struct file *file)
 static const struct file_operations asus_wmi_debugfs_io_ops = {
 	.owner = THIS_MODULE,
 	.open = asus_wmi_debugfs_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
diff --git a/drivers/platform/x86/dell/dell-smbios-wmi.c b/drivers/platform/x86/dell/dell-smbios-wmi.c
index ae9012549560..89deb76c0d5e 100644
--- a/drivers/platform/x86/dell/dell-smbios-wmi.c
+++ b/drivers/platform/x86/dell/dell-smbios-wmi.c
@@ -123,13 +123,12 @@ static int dell_smbios_wmi_open(struct inode *inode, struct file *filp)
 	return nonseekable_open(inode, filp);
 }
 
-static ssize_t dell_smbios_wmi_read(struct file *filp, char __user *buffer, size_t length,
-				    loff_t *offset)
+static ssize_t dell_smbios_wmi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wmi_smbios_priv *priv = filp->private_data;
+	struct wmi_smbios_priv *priv = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buffer, length, offset, &priv->req_buf_size,
-				       sizeof(priv->req_buf_size));
+	return simple_copy_to_iter(&priv->req_buf_size, &iocb->ki_pos,
+				   sizeof(priv->req_buf_size), to);
 }
 
 static long dell_smbios_wmi_do_ioctl(struct wmi_smbios_priv *priv,
@@ -189,7 +188,7 @@ static long dell_smbios_wmi_ioctl(struct file *filp, unsigned int cmd, unsigned
 static const struct file_operations dell_smbios_wmi_fops = {
 	.owner		= THIS_MODULE,
 	.open		= dell_smbios_wmi_open,
-	.read		= dell_smbios_wmi_read,
+	.read_iter	= dell_smbios_wmi_read,
 	.unlocked_ioctl	= dell_smbios_wmi_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 };
diff --git a/drivers/platform/x86/dell/dell-smo8800.c b/drivers/platform/x86/dell/dell-smo8800.c
index f7ec17c56833..b8fa22b0b6bd 100644
--- a/drivers/platform/x86/dell/dell-smo8800.c
+++ b/drivers/platform/x86/dell/dell-smo8800.c
@@ -74,6 +74,7 @@ static ssize_t smo8800_misc_read(struct file *file, char __user *buf,
 
 	return retval;
 }
+FOPS_READ_ITER_HELPER(smo8800_misc_read);
 
 static int smo8800_misc_open(struct inode *inode, struct file *file)
 {
@@ -98,7 +99,7 @@ static int smo8800_misc_release(struct inode *inode, struct file *file)
 
 static const struct file_operations smo8800_misc_fops = {
 	.owner = THIS_MODULE,
-	.read = smo8800_misc_read,
+	.read_iter = smo8800_misc_read_iter,
 	.open = smo8800_misc_open,
 	.release = smo8800_misc_release,
 };
diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
index 10c96c1a850a..f419cc485411 100644
--- a/drivers/platform/x86/intel/pmc/core.c
+++ b/drivers/platform/x86/intel/pmc/core.c
@@ -525,18 +525,18 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore)
 	return 0;
 }
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static ssize_t pmc_core_ltr_ignore_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct pmc_dev *pmcdev = s->private;
+	size_t count = iov_iter_count(from);
 	u32 buf_size, value;
 	int err;
 
 	buf_size = min_t(u32, count, 64);
 
-	err = kstrtou32_from_user(userbuf, buf_size, 10, &value);
+	err = kstrtou32_from_iter(from, buf_size, 10, &value);
 	if (err)
 		return err;
 
@@ -557,8 +557,8 @@ static int pmc_core_ltr_ignore_open(struct inode *inode, struct file *file)
 
 static const struct file_operations pmc_core_ltr_ignore_ops = {
 	.open           = pmc_core_ltr_ignore_open,
-	.read           = seq_read,
-	.write          = pmc_core_ltr_ignore_write,
+	.read_iter      = seq_read_iter,
+	.write_iter     = pmc_core_ltr_ignore_write,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
@@ -911,11 +911,11 @@ static int pmc_core_lpm_latch_mode_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
-					     const char __user *userbuf,
-					     size_t count, loff_t *ppos)
+static ssize_t pmc_core_lpm_latch_mode_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct pmc_dev *pmcdev = s->private;
 	struct pmc *pmc = pmcdev->pmcs[PMC_IDX_MAIN];
 	bool clear = false, c10 = false;
@@ -925,7 +925,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,
 
 	if (count > sizeof(buf) - 1)
 		return -EINVAL;
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 	buf[count] = '\0';
 
diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h
index 83504c49a0e3..5e4d1bef58e8 100644
--- a/drivers/platform/x86/intel/pmc/core.h
+++ b/drivers/platform/x86/intel/pmc/core.h
@@ -609,8 +609,8 @@ static int __name ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __name ## _fops = {			\
 	.owner		= THIS_MODULE,					\
 	.open		= __name ## _open,				\
-	.read		= seq_read,					\
-	.write		= __name ## _write,				\
+	.read_iter	= seq_read_iter,				\
+	.write_iter	= __name ## _write,				\
 	.release	= single_release,				\
 }
 
diff --git a/drivers/platform/x86/intel/telemetry/debugfs.c b/drivers/platform/x86/intel/telemetry/debugfs.c
index 1d4d0fbfd63c..1c2b05418345 100644
--- a/drivers/platform/x86/intel/telemetry/debugfs.c
+++ b/drivers/platform/x86/intel/telemetry/debugfs.c
@@ -679,14 +679,14 @@ static int telem_pss_trc_verb_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t telem_pss_trc_verb_write(struct file *file,
-					const char __user *userbuf,
-					size_t count, loff_t *ppos)
+static ssize_t telem_pss_trc_verb_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u32 verbosity;
 	int err;
 
-	err = kstrtou32_from_user(userbuf, count, 0, &verbosity);
+	err = kstrtou32_from_iter(from, count, 0, &verbosity);
 	if (err)
 		return err;
 
@@ -706,8 +706,8 @@ static int telem_pss_trc_verb_open(struct inode *inode, struct file *file)
 
 static const struct file_operations telem_pss_trc_verb_ops = {
 	.open		= telem_pss_trc_verb_open,
-	.read		= seq_read,
-	.write		= telem_pss_trc_verb_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= telem_pss_trc_verb_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -727,14 +727,14 @@ static int telem_ioss_trc_verb_show(struct seq_file *s, void *unused)
 	return 0;
 }
 
-static ssize_t telem_ioss_trc_verb_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static ssize_t telem_ioss_trc_verb_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u32 verbosity;
 	int err;
 
-	err = kstrtou32_from_user(userbuf, count, 0, &verbosity);
+	err = kstrtou32_from_iter(from, count, 0, &verbosity);
 	if (err)
 		return err;
 
@@ -754,8 +754,8 @@ static int telem_ioss_trc_verb_open(struct inode *inode, struct file *file)
 
 static const struct file_operations telem_ioss_trc_verb_ops = {
 	.open		= telem_ioss_trc_verb_open,
-	.read		= seq_read,
-	.write		= telem_ioss_trc_verb_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= telem_ioss_trc_verb_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/drivers/platform/x86/intel/tpmi.c b/drivers/platform/x86/intel/tpmi.c
index 910df7c654f4..1de0ecfcf1e7 100644
--- a/drivers/platform/x86/intel/tpmi.c
+++ b/drivers/platform/x86/intel/tpmi.c
@@ -438,10 +438,11 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(tpmi_mem_dump);
 
-static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t len, loff_t *ppos)
+static ssize_t mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = file->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct intel_tpmi_pm_feature *pfs = m->private;
+	size_t len = iov_iter_count(from);
 	u32 addr, value, punit, size;
 	u32 num_elems, *array;
 	void __iomem *mem;
@@ -451,7 +452,7 @@ static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t l
 	if (!size)
 		return -EIO;
 
-	ret = parse_int_array_user(userbuf, len, (int **)&array);
+	ret = parse_int_array_iter(from, (int **)&array);
 	if (ret < 0)
 		return ret;
 
@@ -510,8 +511,8 @@ static int mem_write_open(struct inode *inode, struct file *file)
 
 static const struct file_operations mem_write_ops = {
 	.open           = mem_write_open,
-	.read           = seq_read,
-	.write          = mem_write,
+	.read_iter      = seq_read_iter,
+	.write_iter     = mem_write,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 40878e327afd..6308feb23665 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -4097,6 +4097,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(sonypi_misc_read);
 
 static __poll_t sonypi_misc_poll(struct file *file, poll_table *wait)
 {
@@ -4249,7 +4250,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
 
 static const struct file_operations sonypi_misc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= sonypi_misc_read,
+	.read_iter	= sonypi_misc_read_iter,
 	.poll		= sonypi_misc_poll,
 	.open		= sonypi_misc_open,
 	.release	= sonypi_misc_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 184/437] drivers/mtd: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (182 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 183/437] drivers/platform: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 185/437] scsi: bfa: convert to read/write iterators Jens Axboe
                   ` (253 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/mtd/mtdchar.c   | 52 ++++++++++++++++++------------------
 drivers/mtd/ubi/cdev.c  | 58 ++++++++++++++++++++---------------------
 drivers/mtd/ubi/debug.c | 38 ++++++++++++---------------
 drivers/mtd/ubi/ubi.h   |  4 +--
 drivers/mtd/ubi/upd.c   | 24 ++++++++---------
 5 files changed, 83 insertions(+), 93 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 8dc4f5c493fc..0e3b6674f081 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -124,10 +124,10 @@ static int mtdchar_close(struct inode *inode, struct file *file)
  * alignment requirements are not met in the NAND subdriver.
  */
 
-static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mtdchar_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mtd_file_info *mfi = file->private_data;
+	struct mtd_file_info *mfi = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct mtd_info *mtd = mfi->mtd;
 	size_t retlen;
 	size_t total_retlen=0;
@@ -138,9 +138,9 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 
 	pr_debug("MTD_read\n");
 
-	if (*ppos + count > mtd->size) {
-		if (*ppos < mtd->size)
-			count = mtd->size - *ppos;
+	if (iocb->ki_pos + count > mtd->size) {
+		if (iocb->ki_pos < mtd->size)
+			count = mtd->size - iocb->ki_pos;
 		else
 			count = 0;
 	}
@@ -157,11 +157,11 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 
 		switch (mfi->mode) {
 		case MTD_FILE_MODE_OTP_FACTORY:
-			ret = mtd_read_fact_prot_reg(mtd, *ppos, len,
+			ret = mtd_read_fact_prot_reg(mtd, iocb->ki_pos, len,
 						     &retlen, kbuf);
 			break;
 		case MTD_FILE_MODE_OTP_USER:
-			ret = mtd_read_user_prot_reg(mtd, *ppos, len,
+			ret = mtd_read_user_prot_reg(mtd, iocb->ki_pos, len,
 						     &retlen, kbuf);
 			break;
 		case MTD_FILE_MODE_RAW:
@@ -173,12 +173,12 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 			ops.oobbuf = NULL;
 			ops.len = len;
 
-			ret = mtd_read_oob(mtd, *ppos, &ops);
+			ret = mtd_read_oob(mtd, iocb->ki_pos, &ops);
 			retlen = ops.retlen;
 			break;
 		}
 		default:
-			ret = mtd_read(mtd, *ppos, len, &retlen, kbuf);
+			ret = mtd_read(mtd, iocb->ki_pos, len, &retlen, kbuf);
 		}
 		/* Nand returns -EBADMSG on ECC errors, but it returns
 		 * the data. For our userspace tools it is important
@@ -190,8 +190,8 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 		 * must be aware of the fact that it deals with NAND
 		 */
 		if (!ret || mtd_is_bitflip_or_eccerr(ret)) {
-			*ppos += retlen;
-			if (copy_to_user(buf, kbuf, retlen)) {
+			iocb->ki_pos += retlen;
+			if (!copy_to_iter_full(kbuf, retlen, to)) {
 				kfree(kbuf);
 				return -EFAULT;
 			}
@@ -199,7 +199,6 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 				total_retlen += retlen;
 
 			count -= retlen;
-			buf += retlen;
 			if (retlen == 0)
 				count = 0;
 		}
@@ -214,10 +213,10 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
 	return total_retlen;
 } /* mtdchar_read */
 
-static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mtdchar_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mtd_file_info *mfi = file->private_data;
+	struct mtd_file_info *mfi = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mtd_info *mtd = mfi->mtd;
 	size_t size = count;
 	char *kbuf;
@@ -228,11 +227,11 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 
 	pr_debug("MTD_write\n");
 
-	if (*ppos >= mtd->size)
+	if (iocb->ki_pos >= mtd->size)
 		return -ENOSPC;
 
-	if (*ppos + count > mtd->size)
-		count = mtd->size - *ppos;
+	if (iocb->ki_pos + count > mtd->size)
+		count = mtd->size - iocb->ki_pos;
 
 	if (!count)
 		return 0;
@@ -244,7 +243,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 	while (count) {
 		len = min_t(size_t, count, size);
 
-		if (copy_from_user(kbuf, buf, len)) {
+		if (!copy_from_iter_full(kbuf, len, from)) {
 			kfree(kbuf);
 			return -EFAULT;
 		}
@@ -254,7 +253,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			ret = -EROFS;
 			break;
 		case MTD_FILE_MODE_OTP_USER:
-			ret = mtd_write_user_prot_reg(mtd, *ppos, len,
+			ret = mtd_write_user_prot_reg(mtd, iocb->ki_pos, len,
 						      &retlen, kbuf);
 			break;
 
@@ -268,13 +267,13 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			ops.ooboffs = 0;
 			ops.len = len;
 
-			ret = mtd_write_oob(mtd, *ppos, &ops);
+			ret = mtd_write_oob(mtd, iocb->ki_pos, &ops);
 			retlen = ops.retlen;
 			break;
 		}
 
 		default:
-			ret = mtd_write(mtd, *ppos, len, &retlen, kbuf);
+			ret = mtd_write(mtd, iocb->ki_pos, len, &retlen, kbuf);
 		}
 
 		/*
@@ -286,10 +285,9 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
 			break;
 
 		if (!ret) {
-			*ppos += retlen;
+			iocb->ki_pos += retlen;
 			total_retlen += retlen;
 			count -= retlen;
-			buf += retlen;
 		}
 		else {
 			kfree(kbuf);
@@ -1401,8 +1399,8 @@ static int mtdchar_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations mtd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= mtdchar_lseek,
-	.read		= mtdchar_read,
-	.write		= mtdchar_write,
+	.read_iter	= mtdchar_read,
+	.write_iter	= mtdchar_write,
 	.unlocked_ioctl	= mtdchar_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= mtdchar_compat_ioctl,
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 0d8f04cf03c5..ab99cfff211c 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -168,10 +168,10 @@ static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end,
 }
 
 
-static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
-			     loff_t *offp)
+static ssize_t vol_cdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ubi_volume_desc *desc = file->private_data;
+	struct ubi_volume_desc *desc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct ubi_volume *vol = desc->vol;
 	struct ubi_device *ubi = vol->ubi;
 	int err, lnum, off, len,  tbuf_size;
@@ -179,7 +179,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
 	void *tbuf;
 
 	dbg_gen("read %zd bytes from offset %lld of volume %d",
-		count, *offp, vol->vol_id);
+		count, iocb->ki_pos, vol->vol_id);
 
 	if (vol->updating) {
 		ubi_err(vol->ubi, "updating");
@@ -189,14 +189,14 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
 		ubi_err(vol->ubi, "damaged volume, update marker is set");
 		return -EBADF;
 	}
-	if (*offp == vol->used_bytes || count == 0)
+	if (iocb->ki_pos == vol->used_bytes || count == 0)
 		return 0;
 
 	if (vol->corrupted)
 		dbg_gen("read from corrupted volume %d", vol->vol_id);
 
-	if (*offp + count > vol->used_bytes)
-		count_save = count = vol->used_bytes - *offp;
+	if (iocb->ki_pos + count > vol->used_bytes)
+		count_save = count = vol->used_bytes - iocb->ki_pos;
 
 	tbuf_size = vol->usable_leb_size;
 	if (count < tbuf_size)
@@ -206,7 +206,7 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
 		return -ENOMEM;
 
 	len = count > tbuf_size ? tbuf_size : count;
-	lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
+	lnum = div_u64_rem(iocb->ki_pos, vol->usable_leb_size, &off);
 
 	do {
 		cond_resched();
@@ -225,15 +225,14 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
 		}
 
 		count -= len;
-		*offp += len;
+		iocb->ki_pos += len;
 
-		err = copy_to_user(buf, tbuf, len);
+		err = !copy_to_iter_full(tbuf, len, to);
 		if (err) {
 			err = -EFAULT;
 			break;
 		}
 
-		buf += len;
 		len = count > tbuf_size ? tbuf_size : count;
 	} while (count);
 
@@ -245,10 +244,10 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
  * This function allows to directly write to dynamic UBI volumes, without
  * issuing the volume update operation.
  */
-static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
-				     size_t count, loff_t *offp)
+static ssize_t vol_cdev_direct_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ubi_volume_desc *desc = file->private_data;
+	struct ubi_volume_desc *desc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ubi_volume *vol = desc->vol;
 	struct ubi_device *ubi = vol->ubi;
 	int lnum, off, len, tbuf_size, err = 0;
@@ -259,19 +258,19 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
 		return -EPERM;
 
 	dbg_gen("requested: write %zd bytes to offset %lld of volume %u",
-		count, *offp, vol->vol_id);
+		count, iocb->ki_pos, vol->vol_id);
 
 	if (vol->vol_type == UBI_STATIC_VOLUME)
 		return -EROFS;
 
-	lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
+	lnum = div_u64_rem(iocb->ki_pos, vol->usable_leb_size, &off);
 	if (off & (ubi->min_io_size - 1)) {
 		ubi_err(ubi, "unaligned position");
 		return -EINVAL;
 	}
 
-	if (*offp + count > vol->used_bytes)
-		count_save = count = vol->used_bytes - *offp;
+	if (iocb->ki_pos + count > vol->used_bytes)
+		count_save = count = vol->used_bytes - iocb->ki_pos;
 
 	/* We can write only in fractions of the minimum I/O unit */
 	if (count & (ubi->min_io_size - 1)) {
@@ -294,7 +293,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
 		if (off + len >= vol->usable_leb_size)
 			len = vol->usable_leb_size - off;
 
-		err = copy_from_user(tbuf, buf, len);
+		err = !copy_from_iter_full(tbuf, len, from);
 		if (err) {
 			err = -EFAULT;
 			break;
@@ -311,8 +310,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
 		}
 
 		count -= len;
-		*offp += len;
-		buf += len;
+		iocb->ki_pos += len;
 		len = count > tbuf_size ? tbuf_size : count;
 	}
 
@@ -320,25 +318,25 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
 	return err ? err : count_save - count;
 }
 
-static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
-			      size_t count, loff_t *offp)
+static ssize_t vol_cdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err = 0;
-	struct ubi_volume_desc *desc = file->private_data;
+	struct ubi_volume_desc *desc = iocb->ki_filp->private_data;
 	struct ubi_volume *vol = desc->vol;
 	struct ubi_device *ubi = vol->ubi;
+	size_t count = iov_iter_count(from);
 
 	if (!vol->updating && !vol->changing_leb)
-		return vol_cdev_direct_write(file, buf, count, offp);
+		return vol_cdev_direct_write(iocb, from);
 
 	if (vol->updating)
-		err = ubi_more_update_data(ubi, vol, buf, count);
+		err = ubi_more_update_data(ubi, vol, from);
 	else
-		err = ubi_more_leb_change_data(ubi, vol, buf, count);
+		err = ubi_more_leb_change_data(ubi, vol, from);
 
 	if (err < 0) {
 		ubi_err(ubi, "cannot accept more %zd bytes of data, error %d",
-			count, err);
+			iov_iter_count(from), err);
 		return err;
 	}
 
@@ -1085,8 +1083,8 @@ const struct file_operations ubi_vol_cdev_operations = {
 	.open           = vol_cdev_open,
 	.release        = vol_cdev_release,
 	.llseek         = vol_cdev_llseek,
-	.read           = vol_cdev_read,
-	.write          = vol_cdev_write,
+	.read_iter      = vol_cdev_read,
+	.write_iter     = vol_cdev_write,
 	.fsync		= vol_cdev_fsync,
 	.unlocked_ioctl = vol_cdev_ioctl,
 	.compat_ioctl   = compat_ptr_ioctl,
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index d57f52bd2ff3..2b364dd8e92e 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -325,11 +325,11 @@ void ubi_debugfs_exit(void)
 }
 
 /* Read an UBI debugfs file */
-static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t dfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long ubi_num = (unsigned long)file->private_data;
-	struct dentry *dent = file->f_path.dentry;
+	unsigned long ubi_num = (unsigned long)iocb->ki_filp->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(to);
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
 	char buf[16];
@@ -354,23 +354,19 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 		val = d->emulate_io_failures;
 	else if (dent == d->dfs_emulate_failures) {
 		snprintf(buf, sizeof(buf), "0x%04x\n", d->emulate_failures);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_emulate_power_cut) {
 		snprintf(buf, sizeof(buf), "%u\n", d->emulate_power_cut);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_power_cut_min) {
 		snprintf(buf, sizeof(buf), "%u\n", d->power_cut_min);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else if (dent == d->dfs_power_cut_max) {
 		snprintf(buf, sizeof(buf), "%u\n", d->power_cut_max);
-		count = simple_read_from_buffer(user_buf, count, ppos,
-						buf, strlen(buf));
+		count = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 		goto out;
 	} else {
 		count = -EINVAL;
@@ -384,7 +380,7 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	count = simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	count = simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 
 out:
 	ubi_put_device(ubi);
@@ -392,11 +388,11 @@ static ssize_t dfs_file_read(struct file *file, char __user *user_buf,
 }
 
 /* Write an UBI debugfs file */
-static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t dfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	unsigned long ubi_num = (unsigned long)file->private_data;
-	struct dentry *dent = file->f_path.dentry;
+	unsigned long ubi_num = (unsigned long)iocb->ki_filp->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	struct ubi_device *ubi;
 	struct ubi_debug_info *d;
 	size_t buf_size;
@@ -409,7 +405,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
 	d = &ubi->dbg;
 
 	buf_size = min_t(size_t, count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size)) {
+	if (!copy_from_iter_full(buf, buf_size, from)) {
 		count = -EFAULT;
 		goto out;
 	}
@@ -467,8 +463,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
  * detailed_erase_block_info
  */
 static const struct file_operations dfs_fops = {
-	.read   = dfs_file_read,
-	.write  = dfs_file_write,
+	.read_iter   = dfs_file_read,
+	.write_iter  = dfs_file_write,
 	.open	= simple_open,
 	.llseek = no_llseek,
 	.owner  = THIS_MODULE,
@@ -576,7 +572,7 @@ static int eraseblk_count_release(struct inode *inode, struct file *f)
 static const struct file_operations eraseblk_count_fops = {
 	.owner = THIS_MODULE,
 	.open = eraseblk_count_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = eraseblk_count_release,
 };
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 32009a24869e..c932b1d31e6b 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -852,11 +852,11 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol);
 int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
 		     long long bytes);
 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			 const void __user *buf, int count);
+			 struct iov_iter *from);
 int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
 			 const struct ubi_leb_change_req *req);
 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			     const void __user *buf, int count);
+			     struct iov_iter *from);
 
 /* misc.c */
 int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 962f693cf882..6fa6e5b67631 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -253,8 +253,7 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
  * ubi_more_update_data - write more update data.
  * @ubi: UBI device description object
  * @vol: volume description object
- * @buf: write data (user-space memory buffer)
- * @count: how much bytes to write
+ * @from: write data (user-space memory buffer)
  *
  * This function writes more data to the volume which is being updated. It may
  * be called arbitrary number of times until all the update data arriveis. This
@@ -263,11 +262,12 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
  * negative error code in case of failure.
  */
 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			 const void __user *buf, int count)
+			 struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int lnum, offs, err = 0, len, to_write = count;
 
-	dbg_gen("write %d of %lld bytes, %lld already passed",
+	dbg_gen("write %zd of %lld bytes, %lld already passed",
 		count, vol->upd_bytes, vol->upd_received);
 
 	if (ubi->ro_mode)
@@ -293,7 +293,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		if (len > count)
 			len = count;
 
-		err = copy_from_user(vol->upd_buf + offs, buf, len);
+		err = !copy_from_iter_full(vol->upd_buf + offs, len, from);
 		if (err)
 			return -EFAULT;
 
@@ -314,7 +314,6 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 
 		vol->upd_received += len;
 		count -= len;
-		buf += len;
 		lnum += 1;
 	}
 
@@ -328,7 +327,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		else
 			len = count;
 
-		err = copy_from_user(vol->upd_buf, buf, len);
+		err = !copy_from_iter_full(vol->upd_buf, len, from);
 		if (err)
 			return -EFAULT;
 
@@ -343,7 +342,6 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
 		vol->upd_received += len;
 		count -= len;
 		lnum += 1;
-		buf += len;
 	}
 
 	ubi_assert(vol->upd_received <= vol->upd_bytes);
@@ -367,8 +365,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
  * ubi_more_leb_change_data - accept more data for atomic LEB change.
  * @ubi: UBI device description object
  * @vol: volume description object
- * @buf: write data (user-space memory buffer)
- * @count: how much bytes to write
+ * @from: write data (user-space memory buffer)
  *
  * This function accepts more data to the volume which is being under the
  * "atomic LEB change" operation. It may be called arbitrary number of times
@@ -378,11 +375,12 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
  * of failure.
  */
 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
-			     const void __user *buf, int count)
+			     struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int err;
 
-	dbg_gen("write %d of %lld bytes, %lld already passed",
+	dbg_gen("write %zd of %lld bytes, %lld already passed",
 		count, vol->upd_bytes, vol->upd_received);
 
 	if (ubi->ro_mode)
@@ -391,7 +389,7 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
 	if (vol->upd_received + count > vol->upd_bytes)
 		count = vol->upd_bytes - vol->upd_received;
 
-	err = copy_from_user(vol->upd_buf + vol->upd_received, buf, count);
+	err = !copy_from_iter_full(vol->upd_buf + vol->upd_received, count, from);
 	if (err)
 		return -EFAULT;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 185/437] scsi: bfa: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (183 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 184/437] drivers/mtd: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 186/437] scsi: csiostor: " Jens Axboe
                   ` (252 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/bfa/bfad_debugfs.c | 51 ++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 52db147d9979..f9e1842e3a59 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -167,17 +167,15 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 				debug->buffer_len);
 }
 
-static ssize_t
-bfad_debugfs_read(struct file *file, char __user *buf,
-			size_t nbytes, loff_t *pos)
+static ssize_t bfad_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bfad_debug_info *debug = file->private_data;
+	struct bfad_debug_info *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->debug_buffer)
 		return 0;
 
-	return simple_read_from_buffer(buf, nbytes, pos,
-				debug->debug_buffer, debug->buffer_len);
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+					debug->buffer_len, to);
 }
 
 #define BFA_REG_CT_ADDRSZ	(0x40000)
@@ -210,22 +208,21 @@ bfad_reg_offset_check(struct bfa_s *bfa, u32 offset, u32 len)
 	return BFA_STATUS_OK;
 }
 
-static ssize_t
-bfad_debugfs_read_regrd(struct file *file, char __user *buf,
-		size_t nbytes, loff_t *pos)
+static ssize_t bfad_debugfs_read_regrd(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bfad_debug_info *regrd_debug = file->private_data;
+	struct bfad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)regrd_debug->i_private;
+	size_t nbytes = iov_iter_count(to);
 	struct bfad_s *bfad = port->bfad;
 	ssize_t rc;
 
 	if (!bfad->regdata)
 		return 0;
 
-	rc = simple_read_from_buffer(buf, nbytes, pos,
-			bfad->regdata, bfad->reglen);
+	rc = simple_copy_to_iter(bfad->regdata, &iocb->ki_pos, bfad->reglen,
+					to);
 
-	if ((*pos + nbytes) >= bfad->reglen) {
+	if ((iocb->ki_pos + nbytes) >= bfad->reglen) {
 		kfree(bfad->regdata);
 		bfad->regdata = NULL;
 		bfad->reglen = 0;
@@ -235,11 +232,11 @@ bfad_debugfs_read_regrd(struct file *file, char __user *buf,
 }
 
 static ssize_t
-bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bfad_debugfs_write_regrd(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bfad_debug_info *regrd_debug = file->private_data;
+	struct bfad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)regrd_debug->i_private;
+	size_t nbytes  = iov_iter_count(from);
 	struct bfad_s *bfad = port->bfad;
 	struct bfa_s *bfa = &bfad->bfa;
 	struct bfa_ioc_s *ioc = &bfa->ioc;
@@ -250,7 +247,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	unsigned long flags;
 	void *kern_buf;
 
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = iterdup(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -304,11 +301,11 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 }
 
 static ssize_t
-bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bfad_debugfs_write_regwr(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bfad_debug_info *debug = file->private_data;
+	struct bfad_debug_info *debug = iocb->ki_filp->private_data;
 	struct bfad_port_s *port = (struct bfad_port_s *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct bfad_s *bfad = port->bfad;
 	struct bfa_s *bfa = &bfad->bfa;
 	struct bfa_ioc_s *ioc = &bfa->ioc;
@@ -317,7 +314,7 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	unsigned long flags;
 	void *kern_buf;
 
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = iterdup(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -382,7 +379,7 @@ static const struct file_operations bfad_debugfs_op_drvtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_drvtrc,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release,
 };
 
@@ -390,7 +387,7 @@ static const struct file_operations bfad_debugfs_op_fwtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_fwtrc,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release_fwtrc,
 };
 
@@ -398,7 +395,7 @@ static const struct file_operations bfad_debugfs_op_fwsave = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_fwsave,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read,
+	.read_iter	=	bfad_debugfs_read,
 	.release	=	bfad_debugfs_release_fwtrc,
 };
 
@@ -406,8 +403,8 @@ static const struct file_operations bfad_debugfs_op_regrd = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_reg,
 	.llseek		=	bfad_debugfs_lseek,
-	.read		=	bfad_debugfs_read_regrd,
-	.write		=	bfad_debugfs_write_regrd,
+	.read_iter	=	bfad_debugfs_read_regrd,
+	.write_iter	=	bfad_debugfs_write_regrd,
 	.release	=	bfad_debugfs_release,
 };
 
@@ -415,7 +412,7 @@ static const struct file_operations bfad_debugfs_op_regwr = {
 	.owner		=	THIS_MODULE,
 	.open		=	bfad_debugfs_open_reg,
 	.llseek		=	bfad_debugfs_lseek,
-	.write		=	bfad_debugfs_write_regwr,
+	.write_iter	=	bfad_debugfs_write_regwr,
 	.release	=	bfad_debugfs_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 186/437] scsi: csiostor: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (184 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 185/437] scsi: bfa: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 187/437] scsi: fnic: " Jens Axboe
                   ` (251 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/csiostor/csio_init.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index d649b7a2a879..177d485975e1 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -59,13 +59,14 @@ static struct scsi_transport_template *csio_fcoe_transport_vport;
 /*
  * debugfs support
  */
-static ssize_t
-csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t csio_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
+	struct file *file = iocb->ki_filp;
 	loff_t avail = file_inode(file)->i_size;
 	unsigned int mem = (uintptr_t)file->private_data & 3;
 	struct csio_hw *hw = file->private_data - mem;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -90,22 +91,21 @@ csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 		ofst = pos % sizeof(data);
 		len = min(count, sizeof(data) - ofst);
-		if (copy_to_user(buf, (u8 *)data + ofst, len))
+		if (!copy_to_iter_full((u8 *)data + ofst, len, to))
 			return -EFAULT;
 
-		buf += len;
 		pos += len;
 		count -= len;
 	}
-	count = pos - *ppos;
-	*ppos = pos;
+	count = pos - iocb->ki_pos;
+	iocb->ki_pos = pos;
 	return count;
 }
 
 static const struct file_operations csio_mem_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = simple_open,
-	.read    = csio_mem_read,
+	.read_iter = csio_mem_read,
 	.llseek  = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 187/437] scsi: fnic: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (185 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 186/437] scsi: csiostor: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 188/437] scsi: hisi_sas: " Jens Axboe
                   ` (250 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/fnic/fnic_debugfs.c | 82 +++++++++++++-------------------
 1 file changed, 33 insertions(+), 49 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 2619a2d4f5f1..2b2315e239f6 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -95,15 +95,13 @@ void fnic_debugfs_terminate(void)
  * Returns:
  * This function returns the amount of data that was read.
  */
-static ssize_t fnic_trace_ctrl_read(struct file *filp,
-				  char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+static ssize_t fnic_trace_ctrl_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[64];
 	int len;
 	u8 *trace_type;
 	len = 0;
-	trace_type = (u8 *)filp->private_data;
+	trace_type = (u8 *)iocb->ki_filp->private_data;
 	if (*trace_type == fc_trc_flag->fnic_trace)
 		len = sprintf(buf, "%d\n", fnic_tracing_enabled);
 	else if (*trace_type == fc_trc_flag->fc_trace)
@@ -113,7 +111,7 @@ static ssize_t fnic_trace_ctrl_read(struct file *filp,
 	else
 		pr_err("fnic: Cannot read to any debugfs file\n");
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -133,20 +131,19 @@ static ssize_t fnic_trace_ctrl_read(struct file *filp,
  * Returns:
  * This function returns the amount of data that was written.
  */
-static ssize_t fnic_trace_ctrl_write(struct file *filp,
-				  const char __user *ubuf,
-				  size_t cnt, loff_t *ppos)
+static ssize_t fnic_trace_ctrl_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[64];
 	unsigned long val;
 	int ret;
 	u8 *trace_type;
-	trace_type = (u8 *)filp->private_data;
+	size_t cnt = iov_iter_count(from);
+	trace_type = (u8 *)iocb->ki_filp->private_data;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -164,16 +161,15 @@ static ssize_t fnic_trace_ctrl_write(struct file *filp,
 	else
 		pr_err("fnic: cannot write to any debugfs file\n");
 
-	(*ppos)++;
-
+	iocb->ki_pos++;
 	return cnt;
 }
 
 static const struct file_operations fnic_trace_ctrl_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = fnic_trace_ctrl_read,
-	.write = fnic_trace_ctrl_write,
+	.read_iter = fnic_trace_ctrl_read,
+	.write_iter = fnic_trace_ctrl_write,
 };
 
 /*
@@ -267,17 +263,12 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
  * This function returns the amount of data that was read (this could be
  * less than @nbytes if the end of the file was reached).
  */
-static ssize_t fnic_trace_debugfs_read(struct file *file,
-					char __user *ubuf,
-					size_t nbytes,
-					loff_t *pos)
+static ssize_t fnic_trace_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	fnic_dbgfs_t *fnic_dbg_prt = file->private_data;
-	int rc = 0;
-	rc = simple_read_from_buffer(ubuf, nbytes, pos,
-				  fnic_dbg_prt->buffer,
-				  fnic_dbg_prt->buffer_len);
-	return rc;
+	fnic_dbgfs_t *fnic_dbg_prt = iocb->ki_filp->private_data;
+
+	return simple_copy_to_iter(fnic_dbg_prt->buffer, &iocb->ki_pos,
+					fnic_dbg_prt->buffer_len, to);
 }
 
 /*
@@ -307,7 +298,7 @@ static const struct file_operations fnic_trace_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_trace_debugfs_open,
 	.llseek = fnic_trace_debugfs_lseek,
-	.read = fnic_trace_debugfs_read,
+	.read_iter = fnic_trace_debugfs_read,
 	.release = fnic_trace_debugfs_release,
 };
 
@@ -459,18 +450,16 @@ static int fnic_reset_stats_open(struct inode *inode, struct file *file)
  * Returns:
  * This function returns the amount of data that was read.
  */
-static ssize_t fnic_reset_stats_read(struct file *file,
-					char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t fnic_reset_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct stats_debug_info *debug = file->private_data;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
 	struct fnic *fnic = (struct fnic *)debug->i_private;
 	char buf[64];
 	int len;
 
 	len = sprintf(buf, "%u\n", fnic->reset_stats);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -487,15 +476,15 @@ static ssize_t fnic_reset_stats_read(struct file *file,
  * Returns:
  * This function returns the amount of data that was written.
  */
-static ssize_t fnic_reset_stats_write(struct file *file,
-					const char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t fnic_reset_stats_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct stats_debug_info *debug = file->private_data;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
 	struct fnic *fnic = (struct fnic *)debug->i_private;
 	struct fnic_stats *stats = &fnic->fnic_stats;
 	u64 *io_stats_p = (u64 *)&stats->io_stats;
 	u64 *fw_stats_p = (u64 *)&stats->fw_stats;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	unsigned long val;
 	int ret;
@@ -503,7 +492,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -534,7 +523,7 @@ static ssize_t fnic_reset_stats_write(struct file *file,
 		ktime_get_real_ts64(&stats->stats_timestamps.last_reset_time);
 	}
 
-	(*ppos)++;
+	iocb->ki_pos++;
 	return cnt;
 }
 
@@ -615,17 +604,12 @@ static int fnic_stats_debugfs_open(struct inode *inode,
  * This function returns the amount of data that was read (this could be
  * less than @nbytes if the end of the file was reached).
  */
-static ssize_t fnic_stats_debugfs_read(struct file *file,
-					char __user *ubuf,
-					size_t nbytes,
-					loff_t *pos)
+static ssize_t fnic_stats_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct stats_debug_info *debug = file->private_data;
-	int rc = 0;
-	rc = simple_read_from_buffer(ubuf, nbytes, pos,
-					debug->debug_buffer,
-					debug->buffer_len);
-	return rc;
+	struct stats_debug_info *debug = iocb->ki_filp->private_data;
+
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+					debug->buffer_len, to);
 }
 
 /*
@@ -653,15 +637,15 @@ static int fnic_stats_debugfs_release(struct inode *inode,
 static const struct file_operations fnic_stats_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_stats_debugfs_open,
-	.read = fnic_stats_debugfs_read,
+	.read_iter = fnic_stats_debugfs_read,
 	.release = fnic_stats_debugfs_release,
 };
 
 static const struct file_operations fnic_reset_debugfs_fops = {
 	.owner = THIS_MODULE,
 	.open = fnic_reset_stats_open,
-	.read = fnic_reset_stats_read,
-	.write = fnic_reset_stats_write,
+	.read_iter = fnic_reset_stats_read,
+	.write_iter = fnic_reset_stats_write,
 	.release = fnic_reset_stats_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 188/437] scsi: hisi_sas: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (186 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 187/437] scsi: fnic: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 189/437] scsi: lpfc: " Jens Axboe
                   ` (249 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 105 ++++++++++++-------------
 1 file changed, 52 insertions(+), 53 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 7d2a33514538..79ad1662f601 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -3858,17 +3858,17 @@ static void debugfs_create_files_v3_hw(struct hisi_hba *hisi_hba)
 			    &debugfs_ras_v3_hw_fops);
 }
 
-static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t debugfs_trigger_dump_v3_hw_write(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct hisi_hba *hisi_hba = file->f_inode->i_private;
+	struct hisi_hba *hisi_hba = iocb->ki_filp->f_inode->i_private;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 
 	if (count > 8)
 		return -EFAULT;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (buf[0] != '1')
@@ -3885,7 +3885,7 @@ static ssize_t debugfs_trigger_dump_v3_hw_write(struct file *file,
 }
 
 static const struct file_operations debugfs_trigger_dump_v3_hw_fops = {
-	.write = &debugfs_trigger_dump_v3_hw_write,
+	.write_iter = debugfs_trigger_dump_v3_hw_write,
 	.owner = THIS_MODULE,
 };
 
@@ -3923,12 +3923,12 @@ static int debugfs_bist_linkrate_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
-						 const char __user *buf,
-						 size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_linkrate_v3_hw_write_iter(struct kiocb *iocb,
+						      struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
 	int i;
@@ -3939,7 +3939,7 @@ static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EOVERFLOW;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EINVAL;
 
 	pkbuf = strstrip(kbuf);
@@ -3997,12 +3997,11 @@ static int debugfs_bist_code_mode_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
-						  const char __user *buf,
-						  size_t count,
-						  loff_t *ppos)
+static ssize_t debugfs_bist_code_mode_v3_hw_write_iter(struct kiocb *iocb,
+						       struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct hisi_hba *hisi_hba = m->private;
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
@@ -4014,7 +4013,7 @@ static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EINVAL;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EOVERFLOW;
 
 	pkbuf = strstrip(kbuf);
@@ -4036,19 +4035,19 @@ static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp,
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_code_mode_v3_hw);
 
-static ssize_t debugfs_bist_phy_v3_hw_write(struct file *filp,
-					    const char __user *buf,
-					    size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_phy_v3_hw_write_iter(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int phy_no;
 	int val;
 
 	if (hisi_hba->debugfs_bist_enable)
 		return -EPERM;
 
-	val = kstrtouint_from_user(buf, count, 0, &phy_no);
+	val = kstrtouint_from_iter(from, count, 0, &phy_no);
 	if (val)
 		return val;
 
@@ -4070,19 +4069,19 @@ static int debugfs_bist_phy_v3_hw_show(struct seq_file *s, void *p)
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_phy_v3_hw);
 
-static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp,
-					const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_cnt_v3_hw_write_iter(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int cnt;
 	int val;
 
 	if (hisi_hba->debugfs_bist_enable)
 		return -EPERM;
 
-	val = kstrtouint_from_user(buf, count, 0, &cnt);
+	val = kstrtouint_from_iter(from, count, 0, &cnt);
 	if (val)
 		return val;
 
@@ -4130,12 +4129,12 @@ static int debugfs_bist_mode_v3_hw_show(struct seq_file *s, void *p)
 	return 0;
 }
 
-static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
-					     const char __user *buf,
-					     size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_mode_v3_hw_write_iter(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[16] = {}, *pkbuf;
 	bool found = false;
 	int i;
@@ -4146,7 +4145,7 @@ static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
 	if (count >= sizeof(kbuf))
 		return -EINVAL;
 
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		return -EOVERFLOW;
 
 	pkbuf = strstrip(kbuf);
@@ -4167,16 +4166,16 @@ static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp,
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_mode_v3_hw);
 
-static ssize_t debugfs_bist_enable_v3_hw_write(struct file *filp,
-					       const char __user *buf,
-					       size_t count, loff_t *ppos)
+static ssize_t debugfs_bist_enable_v3_hw_write_iter(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct hisi_hba *hisi_hba = m->private;
+	size_t count = iov_iter_count(from);
 	unsigned int enable;
 	int val;
 
-	val = kstrtouint_from_user(buf, count, 0, &enable);
+	val = kstrtouint_from_iter(from, count, 0, &enable);
 	if (val)
 		return val;
 
@@ -4218,15 +4217,15 @@ static const struct {
 	{ "SATA_6_0_GBPS" },
 };
 
-static ssize_t debugfs_v3_hw_write(struct file *filp,
-				   const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t debugfs_v3_hw_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 *val = m->private;
 	int res;
 
-	res = kstrtouint_from_user(buf, count, 0, val);
+	res = kstrtouint_from_iter(from, count, 0, val);
 	if (res)
 		return res;
 
@@ -4243,16 +4242,16 @@ static int debugfs_v3_hw_show(struct seq_file *s, void *p)
 }
 DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_v3_hw);
 
-static ssize_t debugfs_phy_down_cnt_v3_hw_write(struct file *filp,
-						const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t debugfs_phy_down_cnt_v3_hw_write_iter(struct kiocb *iocb,
+						     struct iov_iter *from)
 {
-	struct seq_file *s = filp->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct hisi_sas_phy *phy = s->private;
+	size_t count = iov_iter_count(from);
 	unsigned int set_val;
 	int res;
 
-	res = kstrtouint_from_user(buf, count, 0, &set_val);
+	res = kstrtouint_from_iter(from, count, 0, &set_val);
 	if (res)
 		return res;
 
@@ -4370,15 +4369,15 @@ static int debugfs_update_fifo_config_v3_hw(struct hisi_sas_phy *phy)
 	return 0;
 }
 
-static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct file *filp,
-						   const char __user *buf,
-						   size_t count, loff_t *ppos)
+static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct hisi_sas_phy *phy = filp->private_data;
+	struct hisi_sas_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool update;
 	int val;
 
-	val = kstrtobool_from_user(buf, count, &update);
+	val = kstrtobool_from_iter(from, count, &update);
 	if (val)
 		return val;
 
@@ -4394,7 +4393,7 @@ static ssize_t debugfs_fifo_update_cfg_v3_hw_write(struct file *filp,
 
 static const struct file_operations debugfs_fifo_update_cfg_v3_hw_fops = {
 	.open = simple_open,
-	.write = debugfs_fifo_update_cfg_v3_hw_write,
+	.write_iter = debugfs_fifo_update_cfg_v3_hw_write,
 	.owner = THIS_MODULE,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 189/437] scsi: lpfc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (187 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 188/437] scsi: hisi_sas: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 190/437] scsi: megaraid: " Jens Axboe
                   ` (248 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 427 ++++++++++++++-----------------
 1 file changed, 187 insertions(+), 240 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index a2d2b02b3418..bc75753d6c4a 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -2146,11 +2146,11 @@ lpfc_debugfs_lockstat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_lockstat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_sli4_hdw_queue *qp;
 	char mybuf[64];
 	char *pbuf;
@@ -2161,7 +2161,7 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
 
 	bsize = min(nbytes, (sizeof(mybuf) - 1));
 
-	if (copy_from_user(mybuf, buf, bsize))
+	if (!copy_from_iter_full(mybuf, bsize, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2371,12 +2371,10 @@ lpfc_debugfs_dumpHostSlim_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static ssize_t
-lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
-	size_t nbytes, loff_t *ppos)
+static ssize_t lpfc_debugfs_dif_err_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct lpfc_hba *phba = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct lpfc_hba *phba = iocb->ki_filp->private_data;
 	char cbuf[32];
 	uint64_t tmp = 0;
 	int cnt = 0;
@@ -2410,22 +2408,22 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
 		lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
 			 "0547 Unknown debugfs error injection entry\n");
 
-	return simple_read_from_buffer(buf, nbytes, ppos, &cbuf, cnt);
+	return simple_copy_to_iter(&cbuf, &iocb->ki_pos, cnt, to);
 }
 
 static ssize_t
-lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
-	size_t nbytes, loff_t *ppos)
+lpfc_debugfs_dif_err_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct lpfc_hba *phba = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct lpfc_hba *phba = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	char dstbuf[33];
 	uint64_t tmp = 0;
 	int size;
 
 	memset(dstbuf, 0, 33);
 	size = (nbytes < 32) ? nbytes : 32;
-	if (copy_from_user(dstbuf, buf, size))
+	if (!copy_from_iter_full(dstbuf, size, from))
 		return -EFAULT;
 
 	if (dent == phba->debug_InjErrLBA) {
@@ -2537,10 +2535,8 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
 
 /**
  * lpfc_debugfs_read - Read a debugfs file
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from from the buffer indicated in the private_data
@@ -2552,13 +2548,12 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
 static ssize_t
-lpfc_debugfs_read(struct file *file, char __user *buf,
-		  size_t nbytes, loff_t *ppos)
+lpfc_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer,
-				       debug->len);
+	return simple_copy_to_iter(debug->buffer, &iocb->ki_pos, debug->len,
+					to);
 }
 
 /**
@@ -2586,10 +2581,8 @@ lpfc_debugfs_release(struct inode *inode, struct file *file)
 
 /**
  * lpfc_debugfs_multixripools_write - Clear multi-XRI pools statistics
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * Description:
  * This routine clears multi-XRI pools statistics when buf contains "clear".
@@ -2600,10 +2593,10 @@ lpfc_debugfs_release(struct inode *inode, struct file *file)
  * space.
  **/
 static ssize_t
-lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
-				 size_t nbytes, loff_t *ppos)
+lpfc_debugfs_multixripools_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char mybuf[64];
 	char *pbuf;
@@ -2617,7 +2610,7 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2680,12 +2673,12 @@ lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_nvmestat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_nvmet_tgtport *tgtp;
 	char mybuf[64];
 	char *pbuf;
@@ -2698,7 +2691,7 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2768,17 +2761,17 @@ lpfc_debugfs_scsistat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_scsistat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_scsistat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hba *phba = vport->phba;
 	char mybuf[6] = {0};
 	int i;
 
-	if (copy_from_user(mybuf, buf, (nbytes >= sizeof(mybuf)) ?
-				       (sizeof(mybuf) - 1) : nbytes))
+	if (!copy_from_iter_full(mybuf, (nbytes >= sizeof(mybuf)) ?
+				       (sizeof(mybuf) - 1) : nbytes, from))
 		return -EFAULT;
 
 	if ((strncmp(&mybuf[0], "reset", strlen("reset")) == 0) ||
@@ -2822,12 +2815,12 @@ lpfc_debugfs_ioktime_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
-			   size_t nbytes, loff_t *ppos)
+lpfc_debugfs_ioktime_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	char mybuf[64];
 	char *pbuf;
 
@@ -2836,7 +2829,7 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -2949,11 +2942,11 @@ lpfc_debugfs_nvmeio_trc_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
-			      size_t nbytes, loff_t *ppos)
+lpfc_debugfs_nvmeio_trc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	int i;
 	unsigned long sz;
 	char mybuf[64];
@@ -2964,7 +2957,7 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -3054,12 +3047,12 @@ lpfc_debugfs_hdwqstat_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
-			    size_t nbytes, loff_t *ppos)
+lpfc_debugfs_hdwqstat_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_vport *vport = (struct lpfc_vport *)debug->i_private;
 	struct lpfc_hba   *phba = vport->phba;
+	size_t nbytes = iov_iter_count(from);
 	struct lpfc_hdwq_stat *c_stat;
 	char mybuf[64];
 	char *pbuf;
@@ -3070,7 +3063,7 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
 
 	memset(mybuf, 0, sizeof(mybuf));
 
-	if (copy_from_user(mybuf, buf, nbytes))
+	if (!copy_from_iter_full(mybuf, nbytes, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 
@@ -3139,9 +3132,10 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
  * This routine returns 0 when successful, it returns proper error code
  * back to the user space in error conditions.
  */
-static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
+static int lpfc_idiag_cmd_get(struct iov_iter *from,
 			      struct lpfc_idiag_cmd *idiag_cmd)
 {
+	size_t nbytes = iov_iter_count(from);
 	char mybuf[64];
 	char *pbuf, *step_str;
 	int i;
@@ -3151,7 +3145,7 @@ static int lpfc_idiag_cmd_get(const char __user *buf, size_t nbytes,
 	memset(idiag_cmd, 0, sizeof(*idiag_cmd));
 	bsize = min(nbytes, (sizeof(mybuf)-1));
 
-	if (copy_from_user(mybuf, buf, bsize))
+	if (!copy_from_iter_full(mybuf, bsize, from))
 		return -EFAULT;
 	pbuf = &mybuf[0];
 	step_str = strsep(&pbuf, "\t ");
@@ -3273,10 +3267,8 @@ lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
 
 /**
  * lpfc_idiag_pcicfg_read - idiag debugfs read pcicfg
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba pci config space according to the
@@ -3289,11 +3281,9 @@ lpfc_idiag_cmd_release(struct inode *inode, struct file *file)
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_pcicfg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	int offset_label, offset, len = 0, index = LPFC_PCI_CFG_RD_SIZE;
 	int where, count;
@@ -3316,7 +3306,7 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_PCICFG_RD) {
@@ -3349,7 +3339,7 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 		len = 0;
 		break;
 	}
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 pcicfg_browse:
 
@@ -3389,15 +3379,13 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
 	} else
 		idiag.offset.last_rd = 0;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_pcicfg_write - Syntax check and set up idiag pcicfg commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and
  * then perform the syntax check for PCI config space read or write command
@@ -3411,11 +3399,11 @@ lpfc_idiag_pcicfg_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  */
 static ssize_t
-lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_pcicfg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t where, value, count;
 	uint32_t u32val;
 	uint16_t u16val;
@@ -3430,7 +3418,7 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -3571,10 +3559,8 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
 
 /**
  * lpfc_idiag_baracc_read - idiag debugfs pci bar access read
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba pci bar memory mapped space
@@ -3584,11 +3570,9 @@ lpfc_idiag_pcicfg_write(struct file *file, const char __user *buf,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_baracc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	int offset_label, offset, offset_run, len = 0, index;
 	int bar_num, acc_range, bar_size;
@@ -3611,7 +3595,7 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_BARACC_RD) {
@@ -3652,7 +3636,7 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 	} else
 		goto baracc_browse;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 baracc_browse:
 
@@ -3713,15 +3697,13 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
 			idiag.offset.last_rd = offset;
 	}
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_baracc_write - Syntax check and set up idiag bar access commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and
  * then perform the syntax check for PCI bar memory mapped space read or
@@ -3736,12 +3718,12 @@ lpfc_idiag_baracc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  */
 static ssize_t
-lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_baracc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t bar_num, bar_size, offset, value, acc_range;
+	size_t nbytes = iov_iter_count(from);
 	struct pci_dev *pdev;
 	void __iomem *mem_mapped_bar;
 	uint32_t if_type;
@@ -3755,7 +3737,7 @@ lpfc_idiag_baracc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4024,10 +4006,8 @@ __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
 
 /**
  * lpfc_idiag_queinfo_read - idiag debugfs read queue information
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba SLI4 PCI function queue information,
@@ -4040,11 +4020,9 @@ __lpfc_idiag_print_eq(struct lpfc_queue *qp, char *eqtype,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
-			loff_t *ppos)
+static ssize_t lpfc_idiag_queinfo_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	int max_cnt, rc, x, len = 0;
@@ -4057,7 +4035,7 @@ lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
 	pbuffer = debug->buffer;
 	max_cnt = LPFC_QUE_INFO_GET_BUF_SIZE - 256;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	spin_lock_irq(&phba->hbalock);
@@ -4152,14 +4130,14 @@ lpfc_idiag_queinfo_read(struct file *file, char __user *buf, size_t nbytes,
 	}
 
 	spin_unlock_irq(&phba->hbalock);
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 too_big:
 	len +=  scnprintf(pbuffer + len,
 		LPFC_QUE_INFO_GET_BUF_SIZE - len, "Truncated ...\n");
 out:
 	spin_unlock_irq(&phba->hbalock);
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
@@ -4249,11 +4227,9 @@ lpfc_idiag_queacc_read_qe(char *pbuffer, int len, struct lpfc_queue *pque,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_queacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	uint32_t last_index, index, count;
 	struct lpfc_queue *pque = NULL;
 	char *pbuffer;
@@ -4268,7 +4244,7 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_QUEACC_RD) {
@@ -4285,7 +4261,7 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 	/* Read a single entry from the queue */
 	len = lpfc_idiag_queacc_read_qe(pbuffer, len, pque, index);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 
 que_browse:
 
@@ -4305,15 +4281,13 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
 		index = 0;
 	idiag.offset.last_rd = index;
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_queacc_write - Syntax check and set up idiag queacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port queue read (dump) or write (set) command
@@ -4327,12 +4301,12 @@ lpfc_idiag_queacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_queacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t qidx, quetp, queid, index, count, offset, value;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t *pentry;
 	struct lpfc_queue *pque, *qp;
 	int rc;
@@ -4340,7 +4314,7 @@ lpfc_idiag_queacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4608,10 +4582,8 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
 
 /**
  * lpfc_idiag_drbacc_read - idiag debugfs read port doorbell
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: the buffer to write to
  *
  * Description:
  * This routine reads data from the @phba device doorbell register according
@@ -4623,11 +4595,9 @@ lpfc_idiag_drbacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_drbacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t drb_reg_id, i;
 	char *pbuffer;
@@ -4642,7 +4612,7 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_DRBACC_RD)
@@ -4658,15 +4628,13 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
 		len = lpfc_idiag_drbacc_read_reg(phba,
 						 pbuffer, len, drb_reg_id);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_drbacc_write - Syntax check and set up idiag drbacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port doorbell register read (dump) or write
@@ -4680,11 +4648,11 @@ lpfc_idiag_drbacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_drbacc_write( struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t drb_reg_id, value, reg_val = 0;
 	void __iomem *drb_reg;
 	int rc;
@@ -4692,7 +4660,7 @@ lpfc_idiag_drbacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -4828,10 +4796,8 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
 
 /**
  * lpfc_idiag_ctlacc_read - idiag debugfs read port and device control register
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the data to.
  *
  * Description:
  * This routine reads data from the @phba port and device registers according
@@ -4842,10 +4808,9 @@ lpfc_idiag_ctlacc_read_reg(struct lpfc_hba *phba, char *pbuffer,
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
 static ssize_t
-lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+lpfc_idiag_ctlacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	uint32_t ctl_reg_id, i;
 	char *pbuffer;
@@ -4860,7 +4825,7 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if (idiag.cmd.opcode == LPFC_IDIAG_CMD_CTLACC_RD)
@@ -4876,15 +4841,13 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
 		len = lpfc_idiag_ctlacc_read_reg(phba,
 						 pbuffer, len, ctl_reg_id);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_ctlacc_write - Syntax check and set up idiag ctlacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for port and device control register read (dump)
@@ -4895,11 +4858,11 @@ lpfc_idiag_ctlacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_ctlacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t ctl_reg_id, value, reg_val = 0;
 	void __iomem *ctl_reg;
 	int rc;
@@ -4907,7 +4870,7 @@ lpfc_idiag_ctlacc_write(struct file *file, const char __user *buf,
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5022,10 +4985,8 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
 
 /**
  * lpfc_idiag_mbxacc_read - idiag debugfs read on mailbox access
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the user data to.
  *
  * Description:
  * This routine reads data from the @phba driver mailbox access debugfs setup
@@ -5035,11 +4996,9 @@ lpfc_idiag_mbxacc_get_setup(struct lpfc_hba *phba, char *pbuffer)
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_mbxacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	int len = 0;
@@ -5053,7 +5012,7 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
 		return 0;
 	pbuffer = debug->buffer;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 
 	if ((idiag.cmd.opcode != LPFC_IDIAG_CMD_MBXACC_DP) &&
@@ -5062,15 +5021,13 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
 
 	len = lpfc_idiag_mbxacc_get_setup(phba, pbuffer);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 /**
  * lpfc_idiag_mbxacc_write - Syntax check and set up idiag mbxacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for driver mailbox command (dump) and sets up the
@@ -5081,17 +5038,17 @@ lpfc_idiag_mbxacc_read(struct file *file, char __user *buf, size_t nbytes,
  * space.
  **/
 static ssize_t
-lpfc_idiag_mbxacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_mbxacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	uint32_t mbx_dump_map, mbx_dump_cnt, mbx_word_cnt, mbx_mbox_cmd;
+	size_t nbytes = iov_iter_count(from);
 	int rc;
 
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5341,10 +5298,8 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
 
 /**
  * lpfc_idiag_extacc_write - Syntax check and set up idiag extacc commands
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the user data from.
- * @nbytes: The number of bytes to get.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @from: The buffer to copy the user data from.
  *
  * This routine get the debugfs idiag command struct from user space and then
  * perform the syntax check for extent information access commands and sets
@@ -5355,17 +5310,17 @@ lpfc_idiag_extacc_drivr_get(struct lpfc_hba *phba, char *pbuffer, int len)
  * space.
  **/
 static ssize_t
-lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
-			size_t nbytes, loff_t *ppos)
+lpfc_idiag_extacc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(from);
 	uint32_t ext_map;
 	int rc;
 
 	/* This is a user write operation */
 	debug->op = LPFC_IDIAG_OP_WR;
 
-	rc = lpfc_idiag_cmd_get(buf, nbytes, &idiag.cmd);
+	rc = lpfc_idiag_cmd_get(from, &idiag.cmd);
 	if (rc < 0)
 		return rc;
 
@@ -5387,10 +5342,8 @@ lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
 
 /**
  * lpfc_idiag_extacc_read - idiag debugfs read access to extent information
- * @file: The file pointer to read from.
- * @buf: The buffer to copy the data to.
- * @nbytes: The number of bytes to read.
- * @ppos: The position in the file to start reading from.
+ * @iocb: Metadata for IO
+ * @to: The buffer to copy the user data to.
  *
  * Description:
  * This routine reads data from the proper extent information according to
@@ -5400,11 +5353,9 @@ lpfc_idiag_extacc_write(struct file *file, const char __user *buf,
  * This function returns the amount of data that was read (this could be less
  * than @nbytes if the end of the file was reached) or a negative error value.
  **/
-static ssize_t
-lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
-		       loff_t *ppos)
+static ssize_t lpfc_idiag_extacc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *pbuffer;
 	uint32_t ext_map;
@@ -5418,7 +5369,7 @@ lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
 	if (!debug->buffer)
 		return 0;
 	pbuffer = debug->buffer;
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 	if (idiag.cmd.opcode != LPFC_IDIAG_CMD_EXTACC_RD)
 		return 0;
@@ -5431,7 +5382,7 @@ lpfc_idiag_extacc_read(struct file *file, char __user *buf, size_t nbytes,
 	if (ext_map & LPFC_EXT_ACC_DRIVR)
 		len = lpfc_idiag_extacc_drivr_get(phba, pbuffer, len);
 
-	return simple_read_from_buffer(buf, nbytes, ppos, pbuffer, len);
+	return simple_copy_to_iter(pbuffer, &iocb->ki_pos, len, to);
 }
 
 static int
@@ -5458,11 +5409,9 @@ lpfc_cgn_buffer_open(struct inode *inode, struct file *file)
 	return rc;
 }
 
-static ssize_t
-lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
-		     loff_t *ppos)
+static ssize_t lpfc_cgn_buffer_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_debug *debug = file->private_data;
+	struct lpfc_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *buffer = debug->buffer;
 	uint32_t *ptr;
@@ -5512,7 +5461,7 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes,
 			 "%08x %08x %08x %08x\n",
 			 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3));
 out:
-	return simple_read_from_buffer(buf, nbytes, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
 static int
@@ -5551,10 +5500,9 @@ lpfc_rx_monitor_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes,
-		     loff_t *ppos)
+lpfc_rx_monitor_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lpfc_rx_monitor_debug *debug = file->private_data;
+	struct lpfc_rx_monitor_debug *debug = iocb->ki_filp->private_data;
 	struct lpfc_hba *phba = (struct lpfc_hba *)debug->i_private;
 	char *buffer = debug->buffer;
 
@@ -5567,8 +5515,7 @@ lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes,
 				       LPFC_MAX_RXMONITOR_ENTRY);
 	}
 
-	return simple_read_from_buffer(buf, nbytes, ppos, buffer,
-				       strlen(buffer));
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, strlen(buffer), to);
 }
 
 static int
@@ -5587,7 +5534,7 @@ static const struct file_operations lpfc_debugfs_op_disc_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_disc_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5596,7 +5543,7 @@ static const struct file_operations lpfc_debugfs_op_nodelist = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nodelist_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5605,8 +5552,8 @@ static const struct file_operations lpfc_debugfs_op_multixripools = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_multixripools_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_multixripools_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_multixripools_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5615,7 +5562,7 @@ static const struct file_operations lpfc_debugfs_op_hbqinfo = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_hbqinfo_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5625,8 +5572,8 @@ static const struct file_operations lpfc_debugfs_op_lockstat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_lockstat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =        lpfc_debugfs_lockstat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =   lpfc_debugfs_lockstat_iter,
 	.release =      lpfc_debugfs_release,
 };
 #endif
@@ -5636,7 +5583,7 @@ static const struct file_operations lpfc_debugfs_ras_log = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_ras_log_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_ras_log_release,
 };
 
@@ -5645,7 +5592,7 @@ static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_dumpHBASlim_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5654,7 +5601,7 @@ static const struct file_operations lpfc_debugfs_op_dumpHostSlim = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_dumpHostSlim_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5663,8 +5610,8 @@ static const struct file_operations lpfc_debugfs_op_nvmestat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nvmestat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_nvmestat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_nvmestat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5673,8 +5620,8 @@ static const struct file_operations lpfc_debugfs_op_scsistat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_scsistat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_scsistat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_scsistat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5683,8 +5630,8 @@ static const struct file_operations lpfc_debugfs_op_ioktime = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_ioktime_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_ioktime_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_ioktime_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5693,8 +5640,8 @@ static const struct file_operations lpfc_debugfs_op_nvmeio_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_nvmeio_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_nvmeio_trc_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_nvmeio_trc_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5703,8 +5650,8 @@ static const struct file_operations lpfc_debugfs_op_hdwqstat = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_hdwqstat_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
-	.write =	lpfc_debugfs_hdwqstat_write,
+	.read_iter =    lpfc_debugfs_read,
+	.write_iter =	lpfc_debugfs_hdwqstat_write,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5713,8 +5660,8 @@ static const struct file_operations lpfc_debugfs_op_dif_err = {
 	.owner =	THIS_MODULE,
 	.open =		simple_open,
 	.llseek =	lpfc_debugfs_lseek,
-	.read =		lpfc_debugfs_dif_err_read,
-	.write =	lpfc_debugfs_dif_err_write,
+	.read_iter =	lpfc_debugfs_dif_err_read,
+	.write_iter =	lpfc_debugfs_dif_err_write,
 	.release =	lpfc_debugfs_dif_err_release,
 };
 
@@ -5723,7 +5670,7 @@ static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_debugfs_slow_ring_trc_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_debugfs_read,
+	.read_iter =    lpfc_debugfs_read,
 	.release =      lpfc_debugfs_release,
 };
 
@@ -5738,8 +5685,8 @@ static const struct file_operations lpfc_idiag_op_pciCfg = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_pcicfg_read,
-	.write =        lpfc_idiag_pcicfg_write,
+	.read_iter =    lpfc_idiag_pcicfg_read,
+	.write_iter =   lpfc_idiag_pcicfg_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5748,8 +5695,8 @@ static const struct file_operations lpfc_idiag_op_barAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_baracc_read,
-	.write =        lpfc_idiag_baracc_write,
+	.read_iter =    lpfc_idiag_baracc_read,
+	.write_iter =   lpfc_idiag_baracc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5757,7 +5704,7 @@ static const struct file_operations lpfc_idiag_op_barAcc = {
 static const struct file_operations lpfc_idiag_op_queInfo = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
-	.read =         lpfc_idiag_queinfo_read,
+	.read_iter =    lpfc_idiag_queinfo_read,
 	.release =      lpfc_idiag_release,
 };
 
@@ -5766,8 +5713,8 @@ static const struct file_operations lpfc_idiag_op_queAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_queacc_read,
-	.write =        lpfc_idiag_queacc_write,
+	.read_iter =    lpfc_idiag_queacc_read,
+	.write_iter =   lpfc_idiag_queacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5776,8 +5723,8 @@ static const struct file_operations lpfc_idiag_op_drbAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_drbacc_read,
-	.write =        lpfc_idiag_drbacc_write,
+	.read_iter =    lpfc_idiag_drbacc_read,
+	.write_iter =   lpfc_idiag_drbacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5786,8 +5733,8 @@ static const struct file_operations lpfc_idiag_op_ctlAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_ctlacc_read,
-	.write =        lpfc_idiag_ctlacc_write,
+	.read_iter =    lpfc_idiag_ctlacc_read,
+	.write_iter =   lpfc_idiag_ctlacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5796,8 +5743,8 @@ static const struct file_operations lpfc_idiag_op_mbxAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_mbxacc_read,
-	.write =        lpfc_idiag_mbxacc_write,
+	.read_iter =    lpfc_idiag_mbxacc_read,
+	.write_iter =   lpfc_idiag_mbxacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 
@@ -5806,8 +5753,8 @@ static const struct file_operations lpfc_idiag_op_extAcc = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_idiag_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_idiag_extacc_read,
-	.write =        lpfc_idiag_extacc_write,
+	.read_iter =    lpfc_idiag_extacc_read,
+	.write_iter =   lpfc_idiag_extacc_write,
 	.release =      lpfc_idiag_cmd_release,
 };
 #undef lpfc_cgn_buffer_op
@@ -5815,7 +5762,7 @@ static const struct file_operations lpfc_cgn_buffer_op = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_cgn_buffer_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_cgn_buffer_read,
+	.read_iter =    lpfc_cgn_buffer_read,
 	.release =      lpfc_cgn_buffer_release,
 };
 
@@ -5824,7 +5771,7 @@ static const struct file_operations lpfc_rx_monitor_op = {
 	.owner =        THIS_MODULE,
 	.open =         lpfc_rx_monitor_open,
 	.llseek =       lpfc_debugfs_lseek,
-	.read =         lpfc_rx_monitor_read,
+	.read_iter =    lpfc_rx_monitor_read,
 	.release =      lpfc_rx_monitor_release,
 };
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 190/437] scsi: megaraid: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (188 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 189/437] scsi: lpfc: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 191/437] scsi: mpt3sas: " Jens Axboe
                   ` (247 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/megaraid/megaraid_sas_debugfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_debugfs.c b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
index c69760775efa..d0b8626eebd8 100644
--- a/drivers/scsi/megaraid/megaraid_sas_debugfs.c
+++ b/drivers/scsi/megaraid/megaraid_sas_debugfs.c
@@ -45,15 +45,14 @@
 struct dentry *megasas_debugfs_root;
 
 static ssize_t
-megasas_debugfs_read(struct file *filp, char __user *ubuf, size_t cnt,
-		      loff_t *ppos)
+megasas_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct megasas_debugfs_buffer *debug = filp->private_data;
+	struct megasas_debugfs_buffer *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->buf)
 		return 0;
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, debug->buf, debug->len);
+	return simple_copy_to_iter(debug->buf, &iocb->ki_pos, debug->len, to);
 }
 
 static int
@@ -92,7 +91,7 @@ megasas_debugfs_release(struct inode *inode, struct file *file)
 static const struct file_operations megasas_debugfs_raidmap_fops = {
 	.owner		= THIS_MODULE,
 	.open           = megasas_debugfs_raidmap_open,
-	.read           = megasas_debugfs_read,
+	.read_iter      = megasas_debugfs_read,
 	.release        = megasas_debugfs_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 191/437] scsi: mpt3sas: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (189 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 190/437] scsi: megaraid: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 192/437] scsi: qedf: " Jens Axboe
                   ` (246 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/mpt3sas/mpt3sas_debugfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
index a6ab1db81167..2cb768bcf5c2 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
@@ -36,17 +36,15 @@ static struct dentry *mpt3sas_debugfs_root;
  * @ppos:	Offset in the file
  */
 
-static ssize_t
-_debugfs_iocdump_read(struct file *filp, char __user *ubuf, size_t cnt,
-	loff_t *ppos)
+static ssize_t _debugfs_iocdump_read(struct kiocb *iocb, struct iov_iter *to)
 
 {
-	struct mpt3sas_debugfs_buffer *debug = filp->private_data;
+	struct mpt3sas_debugfs_buffer *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->buf)
 		return 0;
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, debug->buf, debug->len);
+	return simple_copy_to_iter(debug->buf, &iocb->ki_pos, debug->len, to);
 }
 
 /*
@@ -89,7 +87,7 @@ _debugfs_iocdump_release(struct inode *inode, struct file *file)
 static const struct file_operations mpt3sas_debugfs_iocdump_fops = {
 	.owner		= THIS_MODULE,
 	.open           = _debugfs_iocdump_open,
-	.read           = _debugfs_iocdump_read,
+	.read_iter      = _debugfs_iocdump_read,
 	.release        = _debugfs_iocdump_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 192/437] scsi: qedf: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (190 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 191/437] scsi: mpt3sas: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 193/437] scsi: qedi: " Jens Axboe
                   ` (245 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/qedf/qedf_dbg.h     |  6 +--
 drivers/scsi/qedf/qedf_debugfs.c | 76 +++++++++++++-------------------
 2 files changed, 34 insertions(+), 48 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_dbg.h b/drivers/scsi/qedf/qedf_dbg.h
index 5ec2b817c694..802cbb5353f7 100644
--- a/drivers/scsi/qedf/qedf_dbg.h
+++ b/drivers/scsi/qedf/qedf_dbg.h
@@ -133,8 +133,8 @@ struct qedf_list_of_funcs {
 { \
 	.owner  = THIS_MODULE, \
 	.open   = simple_open, \
-	.read   = drv##_dbg_##ops##_cmd_read, \
-	.write  = drv##_dbg_##ops##_cmd_write \
+	.read_iter   = drv##_dbg_##ops##_cmd_read, \
+	.write_iter  = drv##_dbg_##ops##_cmd_write \
 }
 
 /* Used for debugfs sequential files */
@@ -142,7 +142,7 @@ struct qedf_list_of_funcs {
 { \
 	.owner = THIS_MODULE, \
 	.open = drv##_dbg_##ops##_open, \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 	.release = single_release, \
 }
diff --git a/drivers/scsi/qedf/qedf_debugfs.c b/drivers/scsi/qedf/qedf_debugfs.c
index 451fd236bfd0..53ae21f14a11 100644
--- a/drivers/scsi/qedf/qedf_debugfs.c
+++ b/drivers/scsi/qedf/qedf_debugfs.c
@@ -95,17 +95,14 @@ const struct qedf_debugfs_ops qedf_debugfs_ops[] = {
 
 DECLARE_PER_CPU(struct qedf_percpu_iothread_s, qedf_percpu_iothreads);
 
-static ssize_t
-qedf_dbg_fp_int_cmd_read(struct file *filp, char __user *buffer, size_t count,
-			 loff_t *ppos)
+static ssize_t qedf_dbg_fp_int_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	size_t cnt = 0;
 	char *cbuf;
 	int id;
 	struct qedf_fastpath *fp = NULL;
-	struct qedf_dbg_ctx *qedf_dbg =
-				(struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
 	struct qedf_ctx *qedf = container_of(qedf_dbg,
 	    struct qedf_ctx, dbg_ctx);
 
@@ -125,52 +122,47 @@ qedf_dbg_fp_int_cmd_read(struct file *filp, char __user *buffer, size_t count,
 				 "#%d: %lu\n", id, fp->completions);
 	}
 
-	ret = simple_read_from_buffer(buffer, count, ppos, cbuf, cnt);
-
+	ret = simple_copy_to_iter(cbuf, &iocb->ki_pos, cnt, to);
 	vfree(cbuf);
-
 	return ret;
 }
 
 static ssize_t
-qedf_dbg_fp_int_cmd_write(struct file *filp, const char __user *buffer,
-			  size_t count, loff_t *ppos)
+qedf_dbg_fp_int_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	if (!count || *ppos)
+	size_t count = iov_iter_count(from);
+
+	if (!count || iocb->ki_pos)
 		return 0;
 
 	return count;
 }
 
-static ssize_t
-qedf_dbg_debug_cmd_read(struct file *filp, char __user *buffer, size_t count,
-			loff_t *ppos)
+static ssize_t qedf_dbg_debug_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int cnt;
 	char cbuf[32];
-	struct qedf_dbg_ctx *qedf_dbg =
-				(struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
 
 	QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "debug mask=0x%x\n", qedf_debug);
 	cnt = scnprintf(cbuf, sizeof(cbuf), "debug mask = 0x%x\n", qedf_debug);
 
-	return simple_read_from_buffer(buffer, count, ppos, cbuf, cnt);
+	return simple_copy_to_iter(cbuf, &iocb->ki_pos, cnt, to);
 }
 
 static ssize_t
-qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer,
-			 size_t count, loff_t *ppos)
+qedf_dbg_debug_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	uint32_t val;
 	void *kern_buf;
 	int rval;
-	struct qedf_dbg_ctx *qedf_dbg =
-	    (struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (!count || *ppos)
+	if (!count || iocb->ki_pos)
 		return 0;
 
-	kern_buf = memdup_user(buffer, count);
+	kern_buf = iterdup(from, count);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -189,13 +181,11 @@ qedf_dbg_debug_cmd_write(struct file *filp, const char __user *buffer,
 }
 
 static ssize_t
-qedf_dbg_stop_io_on_error_cmd_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+qedf_dbg_stop_io_on_error_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int cnt;
 	char cbuf[7];
-	struct qedf_dbg_ctx *qedf_dbg =
-				(struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
 	struct qedf_ctx *qedf = container_of(qedf_dbg,
 	    struct qedf_ctx, dbg_ctx);
 
@@ -203,26 +193,24 @@ qedf_dbg_stop_io_on_error_cmd_read(struct file *filp, char __user *buffer,
 	cnt = scnprintf(cbuf, sizeof(cbuf), "%s\n",
 	    qedf->stop_io_on_error ? "true" : "false");
 
-	return simple_read_from_buffer(buffer, count, ppos, cbuf, cnt);
+	return simple_copy_to_iter(cbuf, &iocb->ki_pos, cnt, to);
 }
 
 static ssize_t
-qedf_dbg_stop_io_on_error_cmd_write(struct file *filp,
-				    const char __user *buffer, size_t count,
-				    loff_t *ppos)
+qedf_dbg_stop_io_on_error_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	void *kern_buf;
-	struct qedf_dbg_ctx *qedf_dbg =
-				(struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
 	struct qedf_ctx *qedf = container_of(qedf_dbg, struct qedf_ctx,
 	    dbg_ctx);
+	size_t count = iov_iter_count(from);
 
 	QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "entered\n");
 
-	if (!count || *ppos)
+	if (!count || iocb->ki_pos)
 		return 0;
 
-	kern_buf = memdup_user(buffer, 6);
+	kern_buf = iterdup(from, 6);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -383,30 +371,28 @@ qedf_dbg_driver_stats_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-qedf_dbg_clear_stats_cmd_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+qedf_dbg_clear_stats_cmd_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int cnt = 0;
 
 	/* Essentially a read stub */
-	cnt = min_t(int, count, cnt - *ppos);
-	*ppos += cnt;
+	cnt = min_t(int, count, cnt - iocb->ki_pos);
+	iocb->ki_pos += cnt;
 	return cnt;
 }
 
 static ssize_t
-qedf_dbg_clear_stats_cmd_write(struct file *filp,
-				    const char __user *buffer, size_t count,
-				    loff_t *ppos)
+qedf_dbg_clear_stats_cmd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct qedf_dbg_ctx *qedf_dbg =
-				(struct qedf_dbg_ctx *)filp->private_data;
+	struct qedf_dbg_ctx *qedf_dbg = iocb->ki_filp->private_data;
 	struct qedf_ctx *qedf = container_of(qedf_dbg, struct qedf_ctx,
 	    dbg_ctx);
+	size_t count = iov_iter_count(from);
 
 	QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Clearing stat counters.\n");
 
-	if (!count || *ppos)
+	if (!count || iocb->ki_pos)
 		return 0;
 
 	/* Clear stat counters exposed by 'stats' node */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 193/437] scsi: qedi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (191 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 192/437] scsi: qedf: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 194/437] scsi: qla2xxx: " Jens Axboe
                   ` (244 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/qedi/qedi_dbg.h     |  6 +++---
 drivers/scsi/qedi/qedi_debugfs.c | 20 ++++++++++++++++----
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qedi/qedi_dbg.h b/drivers/scsi/qedi/qedi_dbg.h
index fdda12ef13b0..2b05de656aa8 100644
--- a/drivers/scsi/qedi/qedi_dbg.h
+++ b/drivers/scsi/qedi/qedi_dbg.h
@@ -114,8 +114,8 @@ struct qedi_debugfs_ops {
 { \
 	.owner  = THIS_MODULE, \
 	.open   = simple_open, \
-	.read   = drv##_dbg_##ops##_cmd_read, \
-	.write  = drv##_dbg_##ops##_cmd_write \
+	.read_iter   = drv##_dbg_##ops##_cmd_read, \
+	.write_iter  = drv##_dbg_##ops##_cmd_write \
 }
 
 /* Used for debugfs sequential files */
@@ -123,7 +123,7 @@ struct qedi_debugfs_ops {
 { \
 	.owner = THIS_MODULE, \
 	.open = drv##_dbg_##ops##_open, \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 	.release = single_release, \
 }
diff --git a/drivers/scsi/qedi/qedi_debugfs.c b/drivers/scsi/qedi/qedi_debugfs.c
index 8deb2001dc2f..28fbbea694d5 100644
--- a/drivers/scsi/qedi/qedi_debugfs.c
+++ b/drivers/scsi/qedi/qedi_debugfs.c
@@ -91,8 +91,8 @@ const struct qedi_debugfs_ops qedi_debugfs_ops[] = {
 };
 
 static ssize_t
-qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
-				  size_t count, loff_t *ppos)
+__qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
+				    size_t count, loff_t *ppos)
 {
 	size_t cnt = 0;
 	struct qedi_dbg_ctx *qedi_dbg =
@@ -117,8 +117,14 @@ qedi_dbg_do_not_recover_cmd_write(struct file *filp, const char __user *buffer,
 }
 
 static ssize_t
-qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
-				 size_t count, loff_t *ppos)
+qedi_dbg_do_not_recover_cmd_write(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, __qedi_dbg_do_not_recover_cmd_write);
+}
+
+static ssize_t
+__qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
+				   size_t count, loff_t *ppos)
 {
 	size_t cnt = 0;
 
@@ -131,6 +137,12 @@ qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
 	return cnt;
 }
 
+static ssize_t
+qedi_dbg_do_not_recover_cmd_read(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __qedi_dbg_do_not_recover_cmd_read);
+}
+
 static int
 qedi_gbl_ctx_show(struct seq_file *s, void *unused)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 194/437] scsi: qla2xxx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (192 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 193/437] scsi: qedi: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 195/437] scsi: snic: " Jens Axboe
                   ` (243 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/qla2xxx/qla_dfs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index 55ff3d7482b3..6aacdb5c65aa 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -490,7 +490,7 @@ qla2x00_dfs_fce_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_fce_ops = {
 	.open		= qla2x00_dfs_fce_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= qla2x00_dfs_fce_release,
 };
@@ -569,13 +569,13 @@ qla_dfs_naqp_show(struct seq_file *s, void *unused)
 		}							\
 	} while (0)
 
-static ssize_t
-qla_dfs_naqp_write(struct file *file, const char __user *buffer,
-    size_t count, loff_t *pos)
+static ssize_t qla_dfs_naqp_write_iter(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct scsi_qla_host *vha = s->private;
 	struct qla_hw_data *ha = vha->hw;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int rc = 0;
 	unsigned long num_act_qp;
@@ -591,7 +591,7 @@ qla_dfs_naqp_write(struct file *file, const char __user *buffer,
 		    vha->host_no);
 		return -EINVAL;
 	}
-	buf = memdup_user_nul(buffer, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf)) {
 		pr_err("host%ld: fail to copy user buffer.",
 		    vha->host_no);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 195/437] scsi: snic: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (193 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 194/437] scsi: qla2xxx: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 196/437] scsi: cxlflash: " Jens Axboe
                   ` (242 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/snic/snic_debugfs.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
index 9dd975b36b5b..0e81688746f1 100644
--- a/drivers/scsi/snic/snic_debugfs.c
+++ b/drivers/scsi/snic/snic_debugfs.c
@@ -69,18 +69,15 @@ snic_reset_stats_open(struct inode *inode, struct file *filp)
  * This function returns the amount of data that was read.
  */
 static ssize_t
-snic_reset_stats_read(struct file *filp,
-		      char __user *ubuf,
-		      size_t cnt,
-		      loff_t *ppos)
+snic_reset_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct snic *snic = (struct snic *) filp->private_data;
+	struct snic *snic = iocb->ki_filp->private_data;
 	char buf[64];
 	int len;
 
 	len = sprintf(buf, "%u\n", snic->reset_stats);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -98,15 +95,13 @@ snic_reset_stats_read(struct file *filp,
  * This function returns the amount of data that was written.
  */
 static ssize_t
-snic_reset_stats_write(struct file *filp,
-		       const char __user *ubuf,
-		       size_t cnt,
-		       loff_t *ppos)
+snic_reset_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct snic *snic = (struct snic *) filp->private_data;
+	struct snic *snic = iocb->ki_filp->private_data;
 	struct snic_stats *stats = &snic->s_stats;
 	u64 *io_stats_p = (u64 *) &stats->io;
 	u64 *fw_stats_p = (u64 *) &stats->fw;
+	size_t cnt = iov_iter_count(from);
 	char buf[64];
 	unsigned long val;
 	int ret;
@@ -114,7 +109,7 @@ snic_reset_stats_write(struct file *filp,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = '\0';
@@ -143,7 +138,7 @@ snic_reset_stats_write(struct file *filp,
 			sizeof(struct snic_fw_stats) - sizeof(u64));
 	}
 
-	(*ppos)++;
+	iocb->ki_pos++;
 
 	SNIC_HOST_INFO(snic->shost, "Reset Op: Driver statistics.\n");
 
@@ -325,8 +320,8 @@ DEFINE_SHOW_ATTRIBUTE(snic_stats);
 static const struct file_operations snic_reset_stats_fops = {
 	.owner = THIS_MODULE,
 	.open = snic_reset_stats_open,
-	.read = snic_reset_stats_read,
-	.write = snic_reset_stats_write,
+	.read_iter = snic_reset_stats_read,
+	.write_iter = snic_reset_stats_write,
 	.release = snic_reset_stats_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 196/437] scsi: cxlflash: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (194 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 195/437] scsi: snic: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 197/437] scsi: scsi_debug: " Jens Axboe
                   ` (241 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/cxlflash/ocxl_hw.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 6542818e595a..40fef6f919db 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -1010,10 +1010,9 @@ static unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
  *
  * Return: size of the data read on success, -errno on failure
  */
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+static ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ocxlflash_context *ctx = file->private_data;
+	struct ocxlflash_context *ctx = iocb->ki_filp->private_data;
 	struct device *dev = ctx->hw_afu->dev;
 	struct cxl_event event;
 	ulong lock_flags;
@@ -1022,9 +1021,9 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	int bit;
 	DEFINE_WAIT(event_wait);
 
-	if (*off != 0) {
+	if (iocb->ki_pos != 0) {
 		dev_err(dev, "%s: Non-zero offset not supported, off=%lld\n",
-			__func__, *off);
+			__func__, iocb->ki_pos);
 		rc = -EINVAL;
 		goto out;
 	}
@@ -1037,7 +1036,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 		if (ctx_event_pending(ctx) || (ctx->state == CLOSED))
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			dev_err(dev, "%s: File cannot be blocked on I/O\n",
 				__func__);
 			rc = -EAGAIN;
@@ -1081,7 +1080,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 
 	spin_unlock_irqrestore(&ctx->slock, lock_flags);
 
-	if (copy_to_user(buf, &event, event.header.size)) {
+	if (!copy_to_iter_full(&event, event.header.size, to)) {
 		dev_err(dev, "%s: copy_to_user failed\n", __func__);
 		rc = -EFAULT;
 		goto out;
@@ -1176,7 +1175,7 @@ static int afu_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations ocxl_afu_fops = {
 	.owner		= THIS_MODULE,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release	= afu_release,
 	.mmap		= afu_mmap,
 };
@@ -1224,7 +1223,7 @@ static struct file *ocxlflash_get_fd(void *ctx_cookie,
 	/* Patch the file ops that are not defined */
 	if (fops) {
 		PATCH_FOPS(poll);
-		PATCH_FOPS(read);
+		PATCH_FOPS(read_iter);
 		PATCH_FOPS(release);
 		PATCH_FOPS(mmap);
 	} else /* Use default ops */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 197/437] scsi: scsi_debug: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (195 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 196/437] scsi: cxlflash: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 198/437] scsi: sg: " Jens Axboe
                   ` (240 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/scsi_debug.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index acf0592d63da..0ce291a5e8fa 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1022,19 +1022,19 @@ static int sdebug_error_open(struct inode *inode, struct file *file)
 	return single_open(file, sdebug_error_show, inode->i_private);
 }
 
-static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
-		size_t count, loff_t *ppos)
+static ssize_t sdebug_error_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf;
 	unsigned int inject_type;
 	struct sdebug_err_inject *inject;
-	struct scsi_device *sdev = (struct scsi_device *)file->f_inode->i_private;
+	struct scsi_device *sdev = iocb->ki_filp->f_inode->i_private;
+	size_t count = iov_iter_count(from);
 
 	buf = kzalloc(count + 1, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, ubuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		kfree(buf);
 		return -EFAULT;
 	}
@@ -1095,8 +1095,8 @@ static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
 
 static const struct file_operations sdebug_error_fops = {
 	.open	= sdebug_error_open,
-	.read	= seq_read,
-	.write	= sdebug_error_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sdebug_error_write,
 	.release = single_release,
 };
 
@@ -1117,17 +1117,17 @@ static int sdebug_target_reset_fail_open(struct inode *inode, struct file *file)
 	return single_open(file, sdebug_target_reset_fail_show, inode->i_private);
 }
 
-static ssize_t sdebug_target_reset_fail_write(struct file *file,
-		const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t sdebug_target_reset_fail_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
 	int ret;
-	struct scsi_target *starget =
-		(struct scsi_target *)file->f_inode->i_private;
+	struct scsi_target *starget = iocb->ki_filp->f_inode->i_private;
 	struct sdebug_target_info *targetip =
 		(struct sdebug_target_info *)starget->hostdata;
+	size_t count = iov_iter_count(from);
 
 	if (targetip) {
-		ret = kstrtobool_from_user(ubuf, count, &targetip->reset_fail);
+		ret = kstrtobool_from_iter(from, count, &targetip->reset_fail);
 		return ret < 0 ? ret : count;
 	}
 	return -ENODEV;
@@ -1135,8 +1135,8 @@ static ssize_t sdebug_target_reset_fail_write(struct file *file,
 
 static const struct file_operations sdebug_target_reset_fail_fops = {
 	.open	= sdebug_target_reset_fail_open,
-	.read	= seq_read,
-	.write	= sdebug_target_reset_fail_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sdebug_target_reset_fail_write,
 	.release = single_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 198/437] scsi: sg: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (196 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 197/437] scsi: scsi_debug: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 199/437] scsi: st: " Jens Axboe
                   ` (239 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/sg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 386981c6976a..c8047981eb9e 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -553,6 +553,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
 	kfree(old_hdr);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(sg_read);
 
 static ssize_t
 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
@@ -707,6 +708,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 	k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
 	return (k < 0) ? k : count;
 }
+FOPS_WRITE_ITER_HELPER(sg_write);
 
 static ssize_t
 sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf,
@@ -1412,8 +1414,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status)
 
 static const struct file_operations sg_fops = {
 	.owner = THIS_MODULE,
-	.read = sg_read,
-	.write = sg_write,
+	.read_iter = sg_read_iter,
+	.write_iter = sg_write_iter,
 	.poll = sg_poll,
 	.unlocked_ioctl = sg_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 199/437] scsi: st: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (197 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 198/437] scsi: sg: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 200/437] staging: axis: " Jens Axboe
                   ` (238 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/scsi/st.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 5a9bcf8e0792..e96eb3607a82 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1891,7 +1891,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 
 	return retval;
 }
-\f
+FOPS_WRITE_ITER_HELPER(st_write);
+
 /* Read data from the tape. Returns zero in the normal case, one if the
    eof status has changed, and the negative error code in case of a
    fatal error. Otherwise updates the buffer and the eof state.
@@ -2238,8 +2239,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
 
 	return retval;
 }
-\f
-
+FOPS_READ_ITER_HELPER(st_read);
 
 DEB(
 /* Set the driver options */
@@ -4146,8 +4146,8 @@ __setup("st=", st_setup);
 static const struct file_operations st_fops =
 {
 	.owner =	THIS_MODULE,
-	.read =		st_read,
-	.write =	st_write,
+	.read_iter =	st_read_iter,
+	.write_iter =	st_write_iter,
 	.unlocked_ioctl = st_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = st_compat_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 200/437] staging: axis: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (198 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 199/437] scsi: st: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 201/437] staging: fieldbus: " Jens Axboe
                   ` (237 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/staging/axis-fifo/axis-fifo.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index ba8e08be0daf..9c9f0716e5f7 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -33,6 +33,7 @@
 #include <linux/uaccess.h>
 #include <linux/jiffies.h>
 #include <linux/miscdevice.h>
+#include <linux/uio.h>
 
 /* ----------------------------
  *       driver parameters
@@ -332,10 +333,8 @@ static void reset_ip_core(struct axis_fifo *fifo)
 
 /**
  * axis_fifo_read() - Read a packet from AXIS-FIFO character device.
- * @f: Open file.
- * @buf: User space buffer to read to.
- * @len: User space buffer length.
- * @off: Buffer offset.
+ * @iocb: Metadata for IO.
+ * @to: User space buffer to read to.
  *
  * As defined by the device's documentation, we need to check the device's
  * occupancy before reading the length register and then the data. All these
@@ -451,10 +450,8 @@ static ssize_t axis_fifo_read(struct kiocb *iocb, struct iov_iter *to)
 
 /**
  * axis_fifo_write() - Write buffer to AXIS-FIFO character device.
- * @f: Open file.
- * @buf: User space buffer to write to the device.
- * @len: User space buffer length.
- * @off: Buffer offset.
+ * @iocb: Metadata for IO.
+ * @from: User space buffer to write to the device.
  *
  * As defined by the device's documentation, we need to write to the device's
  * data buffer then to the device's packet length register atomically. Also,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 201/437] staging: fieldbus: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (199 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 200/437] staging: axis: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 202/437] staging: greybus: " Jens Axboe
                   ` (236 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/staging/fieldbus/dev_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c
index 0053ebd91442..4a9e211640db 100644
--- a/drivers/staging/fieldbus/dev_core.c
+++ b/drivers/staging/fieldbus/dev_core.c
@@ -194,6 +194,7 @@ static ssize_t fieldbus_read(struct file *filp, char __user *buf, size_t size,
 	of->dc_event = fbdev->dc_event;
 	return fbdev->read_area(fbdev, buf, size, offset);
 }
+FOPS_READ_ITER_HELPER(fieldbus_read);
 
 static ssize_t fieldbus_write(struct file *filp, const char __user *buf,
 			      size_t size, loff_t *offset)
@@ -203,6 +204,7 @@ static ssize_t fieldbus_write(struct file *filp, const char __user *buf,
 
 	return fbdev->write_area(fbdev, buf, size, offset);
 }
+FOPS_WRITE_ITER_HELPER(fieldbus_write);
 
 static __poll_t fieldbus_poll(struct file *filp, poll_table *wait)
 {
@@ -220,8 +222,8 @@ static __poll_t fieldbus_poll(struct file *filp, poll_table *wait)
 static const struct file_operations fieldbus_fops = {
 	.open		= fieldbus_open,
 	.release	= fieldbus_release,
-	.read		= fieldbus_read,
-	.write		= fieldbus_write,
+	.read_iter	= fieldbus_read_iter,
+	.write_iter	= fieldbus_write_iter,
 	.poll		= fieldbus_poll,
 	.llseek		= generic_file_llseek,
 	.owner		= THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 202/437] staging: greybus: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (200 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 201/437] staging: fieldbus: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 203/437] staging: av7110: " Jens Axboe
                   ` (235 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/greybus/es2.c            | 29 ++++++++++++++---------------
 drivers/greybus/svc.c            | 27 ++++++++++++---------------
 drivers/staging/greybus/camera.c | 22 ++++++++++------------
 drivers/staging/greybus/raw.c    |  6 ++++--
 4 files changed, 40 insertions(+), 44 deletions(-)

diff --git a/drivers/greybus/es2.c b/drivers/greybus/es2.c
index 1ee78d0d90b4..ef9c68ef8632 100644
--- a/drivers/greybus/es2.c
+++ b/drivers/greybus/es2.c
@@ -1109,10 +1109,10 @@ static int apb_log_poll(void *data)
 	return 0;
 }
 
-static ssize_t apb_log_read(struct file *f, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t apb_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(to);
 	ssize_t ret;
 	size_t copied;
 	char *tmp_buf;
@@ -1125,7 +1125,7 @@ static ssize_t apb_log_read(struct file *f, char __user *buf,
 		return -ENOMEM;
 
 	copied = kfifo_out(&es2->apb_log_fifo, tmp_buf, count);
-	ret = simple_read_from_buffer(buf, count, ppos, tmp_buf, copied);
+	ret = simple_copy_to_iter(tmp_buf, &iocb->ki_pos, copied, to);
 
 	kfree(tmp_buf);
 
@@ -1133,7 +1133,7 @@ static ssize_t apb_log_read(struct file *f, char __user *buf,
 }
 
 static const struct file_operations apb_log_fops = {
-	.read	= apb_log_read,
+	.read_iter	= apb_log_read,
 };
 
 static void usb_log_enable(struct es2_ap_dev *es2)
@@ -1163,25 +1163,24 @@ static void usb_log_disable(struct es2_ap_dev *es2)
 	es2->apb_log_task = NULL;
 }
 
-static ssize_t apb_log_enable_read(struct file *f, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t apb_log_enable_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
 	int enable = !IS_ERR_OR_NULL(es2->apb_log_task);
 	char tmp_buf[3];
 
 	sprintf(tmp_buf, "%d\n", enable);
-	return simple_read_from_buffer(buf, count, ppos, tmp_buf, 2);
+	return simple_copy_to_iter(tmp_buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t apb_log_enable_write(struct file *f, const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t apb_log_enable_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int enable;
 	ssize_t retval;
-	struct es2_ap_dev *es2 = file_inode(f)->i_private;
+	struct es2_ap_dev *es2 = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 
-	retval = kstrtoint_from_user(buf, count, 10, &enable);
+	retval = kstrtoint_from_iter(from, count, 10, &enable);
 	if (retval)
 		return retval;
 
@@ -1194,8 +1193,8 @@ static ssize_t apb_log_enable_write(struct file *f, const char __user *buf,
 }
 
 static const struct file_operations apb_log_enable_fops = {
-	.read	= apb_log_enable_read,
-	.write	= apb_log_enable_write,
+	.read_iter	= apb_log_enable_read,
+	.write_iter	= apb_log_enable_write,
 };
 
 static int apb_get_cport_count(struct usb_device *udev)
diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
index 4256467fcd35..989ee7a3ac17 100644
--- a/drivers/greybus/svc.c
+++ b/drivers/greybus/svc.c
@@ -673,11 +673,10 @@ static int gb_svc_version_request(struct gb_operation *op)
 	return 0;
 }
 
-static ssize_t pwr_debugfs_voltage_read(struct file *file, char __user *buf,
-					size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_voltage_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -694,14 +693,13 @@ static ssize_t pwr_debugfs_voltage_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
-static ssize_t pwr_debugfs_current_read(struct file *file, char __user *buf,
-					size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_current_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -718,14 +716,13 @@ static ssize_t pwr_debugfs_current_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
-static ssize_t pwr_debugfs_power_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *offset)
+static ssize_t pwr_debugfs_power_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct svc_debugfs_pwrmon_rail *pwrmon_rails =
-		file_inode(file)->i_private;
+		file_inode(iocb->ki_filp)->i_private;
 	struct gb_svc *svc = pwrmon_rails->svc;
 	int ret, desc;
 	u32 value;
@@ -741,19 +738,19 @@ static ssize_t pwr_debugfs_power_read(struct file *file, char __user *buf,
 
 	desc = scnprintf(buff, sizeof(buff), "%u\n", value);
 
-	return simple_read_from_buffer(buf, len, offset, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
 static const struct file_operations pwrmon_debugfs_voltage_fops = {
-	.read		= pwr_debugfs_voltage_read,
+	.read_iter	= pwr_debugfs_voltage_read,
 };
 
 static const struct file_operations pwrmon_debugfs_current_fops = {
-	.read		= pwr_debugfs_current_read,
+	.read_iter	= pwr_debugfs_current_read,
 };
 
 static const struct file_operations pwrmon_debugfs_power_fops = {
-	.read		= pwr_debugfs_power_read,
+	.read_iter	= pwr_debugfs_power_read,
 };
 
 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc)
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index a8173aa3a995..f18f690a31ee 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -1086,10 +1086,9 @@ static const struct gb_camera_debugfs_entry gb_camera_debugfs_entries[] = {
 	},
 };
 
-static ssize_t gb_camera_debugfs_read(struct file *file, char __user *buf,
-				      size_t len, loff_t *offset)
+static ssize_t gb_camera_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const struct gb_camera_debugfs_entry *op = file->private_data;
+	const struct gb_camera_debugfs_entry *op = iocb->ki_filp->private_data;
 	struct gb_camera *gcam = file_inode(file)->i_private;
 	struct gb_camera_debugfs_buffer *buffer;
 	ssize_t ret;
@@ -1103,23 +1102,22 @@ static ssize_t gb_camera_debugfs_read(struct file *file, char __user *buf,
 
 	buffer = &gcam->debugfs.buffers[op->buffer];
 
-	return simple_read_from_buffer(buf, len, offset, buffer->data,
-				       buffer->length);
+	return simple_copy_to_iter(buffer->data, &iocb->ki_pos, buffer->length,
+					to);
 }
 
-static ssize_t gb_camera_debugfs_write(struct file *file,
-				       const char __user *buf, size_t len,
-				       loff_t *offset)
+static ssize_t gb_camera_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const struct gb_camera_debugfs_entry *op = file->private_data;
+	const struct gb_camera_debugfs_entry *op = iocb->ki_filp->private_data;
 	struct gb_camera *gcam = file_inode(file)->i_private;
+	size_t len = iov_iter_count(from);
 	ssize_t ret;
 	char *kbuf;
 
 	if (len > 1024)
 		return -EINVAL;
 
-	kbuf = memdup_user_nul(buf, len);
+	kbuf = iterdup_nul(buf, len);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
@@ -1149,8 +1147,8 @@ static int gb_camera_debugfs_open(struct inode *inode, struct file *file)
 
 static const struct file_operations gb_camera_debugfs_ops = {
 	.open = gb_camera_debugfs_open,
-	.read = gb_camera_debugfs_read,
-	.write = gb_camera_debugfs_write,
+	.read_iter = gb_camera_debugfs_read,
+	.write_iter = gb_camera_debugfs_write,
 };
 
 static int gb_camera_debugfs_init(struct gb_camera *gcam)
diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
index 836d35e5fa85..44b85032b755 100644
--- a/drivers/staging/greybus/raw.c
+++ b/drivers/staging/greybus/raw.c
@@ -284,6 +284,7 @@ static ssize_t raw_write(struct file *file, const char __user *buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(raw_write);
 
 static ssize_t raw_read(struct file *file, char __user *buf, size_t count,
 			loff_t *ppos)
@@ -316,11 +317,12 @@ static ssize_t raw_read(struct file *file, char __user *buf, size_t count,
 	mutex_unlock(&raw->list_lock);
 	return retval;
 }
+FOPS_READ_ITER_HELPER(raw_read);
 
 static const struct file_operations raw_fops = {
 	.owner		= THIS_MODULE,
-	.write		= raw_write,
-	.read		= raw_read,
+	.write_iter	= raw_write_iter,
+	.read_iter	= raw_read_iter,
 	.open		= raw_open,
 	.llseek		= noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 203/437] staging: av7110: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (201 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 202/437] staging: greybus: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 204/437] staging: vc04_services: " Jens Axboe
                   ` (234 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/staging/media/av7110/av7110_av.c | 6 ++++--
 drivers/staging/media/av7110/av7110_ca.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/av7110/av7110_av.c b/drivers/staging/media/av7110/av7110_av.c
index 00dd6a7fea64..eb3ad2eae2d0 100644
--- a/drivers/staging/media/av7110/av7110_av.c
+++ b/drivers/staging/media/av7110/av7110_av.c
@@ -974,6 +974,7 @@ static ssize_t dvb_video_write(struct file *file, const char __user *buf,
 	else
 		return dvb_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 1);
 }
+FOPS_WRITE_ITER_HELPER(dvb_video_write);
 
 static __poll_t dvb_audio_poll(struct file *file, poll_table *wait)
 {
@@ -1015,6 +1016,7 @@ static ssize_t dvb_audio_write(struct file *file, const char __user *buf,
 	else
 		return dvb_aplay(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
 }
+FOPS_WRITE_ITER_HELPER(dvb_audio_write);
 
 static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
 
@@ -1572,7 +1574,7 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dvb_video_fops = {
 	.owner		= THIS_MODULE,
-	.write		= dvb_video_write,
+	.write_iter	= dvb_video_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.compat_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_video_open,
@@ -1592,7 +1594,7 @@ static struct dvb_device dvbdev_video = {
 
 static const struct file_operations dvb_audio_fops = {
 	.owner		= THIS_MODULE,
-	.write		= dvb_audio_write,
+	.write_iter	= dvb_audio_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.compat_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_audio_open,
diff --git a/drivers/staging/media/av7110/av7110_ca.c b/drivers/staging/media/av7110/av7110_ca.c
index c1338e074a3d..6b9c90562228 100644
--- a/drivers/staging/media/av7110/av7110_ca.c
+++ b/drivers/staging/media/av7110/av7110_ca.c
@@ -327,6 +327,7 @@ static ssize_t dvb_ca_write(struct file *file, const char __user *buf,
 	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_write(&av7110->ci_wbuffer, file, buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(dvb_ca_write);
 
 static ssize_t dvb_ca_read(struct file *file, char __user *buf,
 			   size_t count, loff_t *ppos)
@@ -337,11 +338,12 @@ static ssize_t dvb_ca_read(struct file *file, char __user *buf,
 	dprintk(8, "av7110:%p\n",av7110);
 	return ci_ll_read(&av7110->ci_rbuffer, file, buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(dvb_ca_read);
 
 static const struct file_operations dvb_ca_fops = {
 	.owner		= THIS_MODULE,
-	.read		= dvb_ca_read,
-	.write		= dvb_ca_write,
+	.read_iter	= dvb_ca_read_iter,
+	.write_iter	= dvb_ca_write_iter,
 	.unlocked_ioctl	= dvb_generic_ioctl,
 	.open		= dvb_ca_open,
 	.release	= dvb_generic_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 204/437] staging: vc04_services: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (202 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 203/437] staging: av7110: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 205/437] drivers/xen: convert to ->read_iter and ->write_iter Jens Axboe
                   ` (233 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../interface/vchiq_arm/vchiq_debugfs.c          | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index d833e4e2973a..0e18e2020654 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -52,15 +52,14 @@ static int debugfs_trace_open(struct inode *inode, struct file *file)
 	return single_open(file, debugfs_trace_show, inode->i_private);
 }
 
-static ssize_t debugfs_trace_write(struct file *file,
-	const char __user *buffer,
-	size_t count, loff_t *ppos)
+static ssize_t debugfs_trace_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *f = (struct seq_file *)file->private_data;
+	struct seq_file *f = iocb->ki_filp->private_data;
 	struct vchiq_instance *instance = f->private;
+	size_t count = iov_iter_count(from);
 	char firstchar;
 
-	if (copy_from_user(&firstchar, buffer, 1))
+	if (!copy_from_iter_full(&firstchar, 1, from))
 		return -EFAULT;
 
 	switch (firstchar) {
@@ -78,16 +77,15 @@ static ssize_t debugfs_trace_write(struct file *file,
 		break;
 	}
 
-	*ppos += count;
-
+	iocb->ki_pos += count;
 	return count;
 }
 
 static const struct file_operations debugfs_trace_fops = {
 	.owner		= THIS_MODULE,
 	.open		= debugfs_trace_open,
-	.write		= debugfs_trace_write,
-	.read		= seq_read,
+	.write_iter	= debugfs_trace_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 205/437] drivers/xen: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (203 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 204/437] staging: vc04_services: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 206/437] virt: " Jens Axboe
                   ` (232 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/xen/evtchn.c                     | 25 ++++++++++++------------
 drivers/xen/mcelog.c                     | 17 ++++++++--------
 drivers/xen/xenbus/xenbus_dev_frontend.c | 24 +++++++++++------------
 drivers/xen/xenfs/super.c                |  7 +++----
 drivers/xen/xenfs/xenstored.c            | 11 +++++------
 drivers/xen/xenfs/xensyms.c              |  2 +-
 6 files changed, 42 insertions(+), 44 deletions(-)

diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index f6a2216c2c87..06af1a458e44 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -51,6 +51,7 @@
 #include <linux/cpu.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
+#include <linux/uio.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -197,12 +198,12 @@ static irqreturn_t evtchn_interrupt(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static ssize_t evtchn_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t evtchn_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rc;
 	unsigned int c, p, bytes1 = 0, bytes2 = 0;
-	struct per_user_data *u = file->private_data;
+	struct per_user_data *u = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	/* Whole number of ports. */
 	count &= ~(sizeof(evtchn_port_t)-1);
@@ -227,7 +228,7 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 
 		mutex_unlock(&u->ring_cons_mutex);
 
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		rc = wait_event_interruptible(u->evtchn_wait,
@@ -256,9 +257,9 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 
 	rc = -EFAULT;
 	smp_rmb(); /* Ensure that we see the port before we copy it. */
-	if (copy_to_user(buf, evtchn_ring_entry(u, c), bytes1) ||
+	if (!copy_to_iter_full(evtchn_ring_entry(u, c), bytes1, to) ||
 	    ((bytes2 != 0) &&
-	     copy_to_user(&buf[bytes1], &u->ring[0], bytes2)))
+	     !copy_to_iter_full(&u->ring[0], bytes2, to)))
 		goto unlock_out;
 
 	WRITE_ONCE(u->ring_cons, c + (bytes1 + bytes2) / sizeof(evtchn_port_t));
@@ -269,12 +270,12 @@ static ssize_t evtchn_read(struct file *file, char __user *buf,
 	return rc;
 }
 
-static ssize_t evtchn_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t evtchn_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int rc, i;
 	evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
-	struct per_user_data *u = file->private_data;
+	struct per_user_data *u = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (kbuf == NULL)
 		return -ENOMEM;
@@ -290,7 +291,7 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf,
 		count = PAGE_SIZE;
 
 	rc = -EFAULT;
-	if (copy_from_user(kbuf, buf, count) != 0)
+	if (!copy_from_iter_full(kbuf, count, from) != 0)
 		goto out;
 
 	mutex_lock(&u->bind_mutex);
@@ -687,8 +688,8 @@ static int evtchn_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations evtchn_fops = {
 	.owner   = THIS_MODULE,
-	.read    = evtchn_read,
-	.write   = evtchn_write,
+	.read_iter    = evtchn_read,
+	.write_iter   = evtchn_write,
 	.unlocked_ioctl = evtchn_ioctl,
 	.poll    = evtchn_poll,
 	.fasync  = evtchn_fasync,
diff --git a/drivers/xen/mcelog.c b/drivers/xen/mcelog.c
index e9ac3b8c4167..610b5f746ca4 100644
--- a/drivers/xen/mcelog.c
+++ b/drivers/xen/mcelog.c
@@ -103,10 +103,10 @@ static int xen_mce_chrdev_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t xen_mce_chrdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *buf = ubuf;
+	size_t usize = iov_iter_count(to);
+	ssize_t copied;
 	unsigned num;
 	int i, err;
 
@@ -116,15 +116,16 @@ static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
 
 	/* Only supports full reads right now */
 	err = -EINVAL;
-	if (*off != 0 || usize < XEN_MCE_LOG_LEN*sizeof(struct xen_mce))
+	if (iocb->ki_pos != 0 || usize < XEN_MCE_LOG_LEN*sizeof(struct xen_mce))
 		goto out;
 
 	err = 0;
+	copied = 0;
 	for (i = 0; i < num; i++) {
 		struct xen_mce *m = &xen_mcelog.entry[i];
 
-		err |= copy_to_user(buf, m, sizeof(*m));
-		buf += sizeof(*m);
+		err |= !copy_to_iter_full(m, sizeof(*m), to);
+		copied += sizeof(*m);
 	}
 
 	memset(xen_mcelog.entry, 0, num * sizeof(struct xen_mce));
@@ -136,7 +137,7 @@ static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
 out:
 	mutex_unlock(&mcelog_lock);
 
-	return err ? err : buf - ubuf;
+	return err ? err : copied;
 }
 
 static __poll_t xen_mce_chrdev_poll(struct file *file, poll_table *wait)
@@ -179,7 +180,7 @@ static long xen_mce_chrdev_ioctl(struct file *f, unsigned int cmd,
 static const struct file_operations xen_mce_chrdev_ops = {
 	.open			= xen_mce_chrdev_open,
 	.release		= xen_mce_chrdev_release,
-	.read			= xen_mce_chrdev_read,
+	.read_iter		= xen_mce_chrdev_read,
 	.poll			= xen_mce_chrdev_poll,
 	.unlocked_ioctl		= xen_mce_chrdev_ioctl,
 	.llseek			= no_llseek,
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 6f56640092a9..3da823abfdc0 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -122,11 +122,10 @@ struct xenbus_file_priv {
 };
 
 /* Read out any raw xenbus messages queued up. */
-static ssize_t xenbus_file_read(struct file *filp,
-			       char __user *ubuf,
-			       size_t len, loff_t *ppos)
+static ssize_t xenbus_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct xenbus_file_priv *u = filp->private_data;
+	struct xenbus_file_priv *u = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct read_buffer *rb;
 	ssize_t i;
 	int ret;
@@ -135,7 +134,7 @@ static ssize_t xenbus_file_read(struct file *filp,
 again:
 	while (list_empty(&u->read_buffers)) {
 		mutex_unlock(&u->reply_mutex);
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		ret = wait_event_interruptible(u->read_waitq,
@@ -150,7 +149,7 @@ static ssize_t xenbus_file_read(struct file *filp,
 	while (i < len) {
 		size_t sz = min_t(size_t, len - i, rb->len - rb->cons);
 
-		ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);
+		ret = !copy_to_iter_full(&rb->msg[rb->cons], sz, to);
 
 		i += sz - ret;
 		rb->cons += sz - ret;
@@ -547,11 +546,10 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
 	return rc;
 }
 
-static ssize_t xenbus_file_write(struct file *filp,
-				const char __user *ubuf,
-				size_t len, loff_t *ppos)
+static ssize_t xenbus_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct xenbus_file_priv *u = filp->private_data;
+	struct xenbus_file_priv *u = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	uint32_t msg_type;
 	int rc = len;
 	int ret;
@@ -585,7 +583,7 @@ static ssize_t xenbus_file_write(struct file *filp,
 		goto out;
 	}
 
-	ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
+	ret = !copy_from_iter_full(u->u.buffer + u->len, len, from);
 
 	if (ret != 0) {
 		rc = -EFAULT;
@@ -695,8 +693,8 @@ static __poll_t xenbus_file_poll(struct file *file, poll_table *wait)
 }
 
 const struct file_operations xen_xenbus_fops = {
-	.read = xenbus_file_read,
-	.write = xenbus_file_write,
+	.read_iter = xenbus_file_read,
+	.write_iter = xenbus_file_write,
 	.open = xenbus_file_open,
 	.release = xenbus_file_release,
 	.poll = xenbus_file_poll,
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index d7d64235010d..54e4e4702572 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -28,19 +28,18 @@
 MODULE_DESCRIPTION("Xen filesystem");
 MODULE_LICENSE("GPL");
 
-static ssize_t capabilities_read(struct file *file, char __user *buf,
-				 size_t size, loff_t *off)
+static ssize_t capabilities_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *tmp = "";
 
 	if (xen_initial_domain())
 		tmp = "control_d\n";
 
-	return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
+	return simple_copy_to_iter(tmp, &iocb->ki_pos, strlen(tmp), to);
 }
 
 static const struct file_operations capabilities_file_ops = {
-	.read = capabilities_read,
+	.read_iter = capabilities_read,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
index f59235f9f8a2..c4e8692deac2 100644
--- a/drivers/xen/xenfs/xenstored.c
+++ b/drivers/xen/xenfs/xenstored.c
@@ -9,11 +9,10 @@
 
 #include "xenfs.h"
 
-static ssize_t xsd_read(struct file *file, char __user *buf,
-			    size_t size, loff_t *off)
+static ssize_t xsd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *str = (const char *)file->private_data;
-	return simple_read_from_buffer(buf, size, off, str, strlen(str));
+	const char *str = (const char *)iocb->ki_filp->private_data;
+	return simple_copy_to_iter(str, &iocb->ki_pos, strlen(str), to);
 }
 
 static int xsd_release(struct inode *inode, struct file *file)
@@ -49,7 +48,7 @@ static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
 const struct file_operations xsd_kva_file_ops = {
 	.open = xsd_kva_open,
 	.mmap = xsd_kva_mmap,
-	.read = xsd_read,
+	.read_iter = xsd_read,
 	.release = xsd_release,
 };
 
@@ -64,6 +63,6 @@ static int xsd_port_open(struct inode *inode, struct file *file)
 
 const struct file_operations xsd_port_file_ops = {
 	.open = xsd_port_open,
-	.read = xsd_read,
+	.read_iter = xsd_read,
 	.release = xsd_release,
 };
diff --git a/drivers/xen/xenfs/xensyms.c b/drivers/xen/xenfs/xensyms.c
index b799bc759c15..ec30aa09620f 100644
--- a/drivers/xen/xenfs/xensyms.c
+++ b/drivers/xen/xenfs/xensyms.c
@@ -146,7 +146,7 @@ static int xensyms_release(struct inode *inode, struct file *file)
 
 const struct file_operations xensyms_ops = {
 	.open = xensyms_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = xensyms_release
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 206/437] virt: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (204 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 205/437] drivers/xen: convert to ->read_iter and ->write_iter Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 207/437] virt: fsl_hypervisor: convert to read/write iterators Jens Axboe
                   ` (231 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 virt/kvm/kvm_main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index fb49c2a60200..9530584af843 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4373,6 +4373,7 @@ static ssize_t kvm_vcpu_stats_read(struct file *file, char __user *user_buffer,
 			&kvm_vcpu_stats_desc[0], &vcpu->stat,
 			sizeof(vcpu->stat), user_buffer, size, offset);
 }
+FOPS_READ_ITER_HELPER(kvm_vcpu_stats_read);
 
 static int kvm_vcpu_stats_release(struct inode *inode, struct file *file)
 {
@@ -4384,7 +4385,7 @@ static int kvm_vcpu_stats_release(struct inode *inode, struct file *file)
 
 static const struct file_operations kvm_vcpu_stats_fops = {
 	.owner = THIS_MODULE,
-	.read = kvm_vcpu_stats_read,
+	.read_iter = kvm_vcpu_stats_read_iter,
 	.release = kvm_vcpu_stats_release,
 	.llseek = noop_llseek,
 };
@@ -5064,6 +5065,7 @@ static ssize_t kvm_vm_stats_read(struct file *file, char __user *user_buffer,
 				&kvm_vm_stats_desc[0], &kvm->stat,
 				sizeof(kvm->stat), user_buffer, size, offset);
 }
+FOPS_READ_ITER_HELPER(kvm_vm_stats_read);
 
 static int kvm_vm_stats_release(struct inode *inode, struct file *file)
 {
@@ -5075,7 +5077,7 @@ static int kvm_vm_stats_release(struct inode *inode, struct file *file)
 
 static const struct file_operations kvm_vm_stats_fops = {
 	.owner = THIS_MODULE,
-	.read = kvm_vm_stats_read,
+	.read_iter = kvm_vm_stats_read_iter,
 	.release = kvm_vm_stats_release,
 	.llseek = noop_llseek,
 };
@@ -6153,8 +6155,8 @@ static const struct file_operations stat_fops_per_vm = {
 	.owner = THIS_MODULE,
 	.open = kvm_stat_data_open,
 	.release = kvm_debugfs_release,
-	.read = simple_attr_read,
-	.write = simple_attr_write,
+	.read_iter = simple_attr_read_iter,
+	.write_iter = simple_attr_write_iter,
 	.llseek = no_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 207/437] virt: fsl_hypervisor: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (205 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 206/437] virt: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 208/437] drivers/video: convert to ->read_iter and ->write_iter Jens Axboe
                   ` (230 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/virt/fsl_hypervisor.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index e92e2ceb12a4..dc84e0006201 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -590,11 +590,10 @@ static __poll_t fsl_hv_poll(struct file *filp, struct poll_table_struct *p)
  * return them to the caller as an array of 32-bit integers.  Otherwise,
  * block until there is at least one handle to return.
  */
-static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
-			   loff_t *off)
+static ssize_t fsl_hv_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct doorbell_queue *dbq = filp->private_data;
-	uint32_t __user *p = (uint32_t __user *) buf; /* for put_user() */
+	struct doorbell_queue *dbq = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	unsigned long flags;
 	ssize_t count = 0;
 
@@ -613,7 +612,7 @@ static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
 			spin_unlock_irqrestore(&dbq->lock, flags);
 			if (count)
 				break;
-			if (filp->f_flags & O_NONBLOCK)
+			if (iocb->ki_filp->f_flags & O_NONBLOCK)
 				return -EAGAIN;
 			if (wait_event_interruptible(dbq->wait,
 						     dbq->head != dbq->tail))
@@ -639,9 +638,8 @@ static ssize_t fsl_hv_read(struct file *filp, char __user *buf, size_t len,
 
 		spin_unlock_irqrestore(&dbq->lock, flags);
 
-		if (put_user(dbell, p))
+		if (put_iter(dbell, to))
 			return -EFAULT;
-		p++;
 		count += sizeof(uint32_t);
 		len -= sizeof(uint32_t);
 	}
@@ -700,7 +698,7 @@ static const struct file_operations fsl_hv_fops = {
 	.open = fsl_hv_open,
 	.release = fsl_hv_close,
 	.poll = fsl_hv_poll,
-	.read = fsl_hv_read,
+	.read_iter = fsl_hv_read,
 	.unlocked_ioctl = fsl_hv_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 208/437] drivers/video: convert to ->read_iter and ->write_iter
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (206 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 207/437] virt: fsl_hypervisor: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 209/437] video: fbdev: pxa3xx-gcu: convert to read/write iterators Jens Axboe
                   ` (229 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/video/fbdev/core/fb_chrdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/core/fb_chrdev.c b/drivers/video/fbdev/core/fb_chrdev.c
index 4ebd16b7e3b8..161f781912c3 100644
--- a/drivers/video/fbdev/core/fb_chrdev.c
+++ b/drivers/video/fbdev/core/fb_chrdev.c
@@ -42,6 +42,7 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
 
 	return info->fbops->fb_read(info, buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(fb_read);
 
 static ssize_t fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
@@ -58,6 +59,7 @@ static ssize_t fb_write(struct file *file, const char __user *buf, size_t count,
 
 	return info->fbops->fb_write(info, buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(fb_write);
 
 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 			unsigned long arg)
@@ -405,8 +407,8 @@ static unsigned long get_fb_unmapped_area(struct file *filp,
 
 static const struct file_operations fb_fops = {
 	.owner = THIS_MODULE,
-	.read = fb_read,
-	.write = fb_write,
+	.read_iter = fb_read_iter,
+	.write_iter = fb_write_iter,
 	.unlocked_ioctl = fb_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = fb_compat_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 209/437] video: fbdev: pxa3xx-gcu: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (207 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 208/437] drivers/video: convert to ->read_iter and ->write_iter Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 210/437] drivers/iommu: convert intel iommu " Jens Axboe
                   ` (228 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/video/fbdev/pxa3xx-gcu.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c
index 43c80316d84b..0890cea32df4 100644
--- a/drivers/video/fbdev/pxa3xx-gcu.c
+++ b/drivers/video/fbdev/pxa3xx-gcu.c
@@ -372,15 +372,13 @@ static int pxa3xx_gcu_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-pxa3xx_gcu_write(struct file *file, const char *buff,
-		 size_t count, loff_t *offp)
+static ssize_t pxa3xx_gcu_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	unsigned long flags;
 	struct pxa3xx_gcu_batch	*buffer;
-	struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(file);
-
+	struct pxa3xx_gcu_priv *priv = to_pxa3xx_gcu_priv(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	size_t words = count / 4;
 
 	/* Does not need to be atomic. There's a lock in user space,
@@ -409,7 +407,7 @@ pxa3xx_gcu_write(struct file *file, const char *buff,
 
 
 	/* Copy data from user into buffer */
-	ret = copy_from_user(buffer->ptr, buff, words * 4);
+	ret = !copy_from_iter_full(buffer->ptr, words * 4, from);
 	if (ret) {
 		spin_lock_irqsave(&priv->spinlock, flags);
 		buffer->next = priv->free;
@@ -569,7 +567,7 @@ pxa3xx_gcu_free_buffers(struct device *dev,
 static const struct file_operations pxa3xx_gcu_miscdev_fops = {
 	.owner =		THIS_MODULE,
 	.open =			pxa3xx_gcu_open,
-	.write =		pxa3xx_gcu_write,
+	.write_iter =		pxa3xx_gcu_write,
 	.unlocked_ioctl =	pxa3xx_gcu_ioctl,
 	.mmap =			pxa3xx_gcu_mmap,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 210/437] drivers/iommu: convert intel iommu to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (208 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 209/437] video: fbdev: pxa3xx-gcu: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 211/437] drivers/iommu: convert omap " Jens Axboe
                   ` (227 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iommu/intel/debugfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/intel/debugfs.c b/drivers/iommu/intel/debugfs.c
index 86b506af7daa..8655098a3a17 100644
--- a/drivers/iommu/intel/debugfs.c
+++ b/drivers/iommu/intel/debugfs.c
@@ -679,19 +679,19 @@ static int dmar_perf_latency_open(struct inode *inode, struct file *filp)
 	return single_open(filp, latency_show, NULL);
 }
 
-static ssize_t dmar_perf_latency_write(struct file *filp,
-				       const char __user *ubuf,
-				       size_t cnt, loff_t *ppos)
+static ssize_t dmar_perf_latency_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	struct dmar_drhd_unit *drhd;
 	struct intel_iommu *iommu;
+	size_t cnt = iov_iter_count(from);
 	int counting;
 	char buf[64];
 
 	if (cnt > 63)
 		cnt = 63;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -738,14 +738,14 @@ static ssize_t dmar_perf_latency_write(struct file *filp,
 		return -EINVAL;
 	}
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 	return cnt;
 }
 
 static const struct file_operations dmar_perf_latency_fops = {
 	.open		= dmar_perf_latency_open,
-	.write		= dmar_perf_latency_write,
-	.read		= seq_read,
+	.write_iter	= dmar_perf_latency_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 211/437] drivers/iommu: convert omap to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (209 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 210/437] drivers/iommu: convert intel iommu " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 212/437] misc: bcm_vk: convert to iterators Jens Axboe
                   ` (226 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iommu/omap-iommu-debug.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 259f65291d90..46798b7584b5 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -11,6 +11,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/uio.h>
 #include <linux/pm_runtime.h>
 #include <linux/debugfs.h>
 #include <linux/platform_data/iommu-omap.h>
@@ -80,10 +81,10 @@ static ssize_t omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf,
 	return bytes;
 }
 
-static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
-			       size_t count, loff_t *ppos)
+static ssize_t debug_read_regs(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct omap_iommu *obj = file->private_data;
+	struct omap_iommu *obj = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	char *p, *buf;
 	ssize_t bytes;
 
@@ -100,7 +101,7 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
 	bytes = omap_iommu_dump_ctx(obj, p, count);
 	if (bytes < 0)
 		goto err;
-	bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes);
+	bytes = simple_copy_to_iter(buf, &iocb->ki_pos, bytes, to);
 
 err:
 	mutex_unlock(&iommu_debug_lock);
@@ -231,7 +232,7 @@ static int pagetable_show(struct seq_file *s, void *data)
 #define DEBUG_FOPS_RO(name)						\
 	static const struct file_operations name##_fops = {	        \
 		.open = simple_open,					\
-		.read = debug_read_##name,				\
+		.read_iter = debug_read_##name,				\
 		.llseek = generic_file_llseek,				\
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 212/437] misc: bcm_vk: convert to iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (210 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 211/437] drivers/iommu: convert omap " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 213/437] misc: lis3lv02d: " Jens Axboe
                   ` (225 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/bcm-vk/bcm_vk.h     |  6 ++----
 drivers/misc/bcm-vk/bcm_vk_dev.c |  4 ++--
 drivers/misc/bcm-vk/bcm_vk_msg.c | 23 ++++++++++-------------
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/bcm-vk/bcm_vk.h b/drivers/misc/bcm-vk/bcm_vk.h
index 386884c2a263..efc91635fa42 100644
--- a/drivers/misc/bcm-vk/bcm_vk.h
+++ b/drivers/misc/bcm-vk/bcm_vk.h
@@ -487,10 +487,8 @@ static inline bool bcm_vk_msgq_marker_valid(struct bcm_vk *vk)
 }
 
 int bcm_vk_open(struct inode *inode, struct file *p_file);
-ssize_t bcm_vk_read(struct file *p_file, char __user *buf, size_t count,
-		    loff_t *f_pos);
-ssize_t bcm_vk_write(struct file *p_file, const char __user *buf,
-		     size_t count, loff_t *f_pos);
+ssize_t bcm_vk_read(struct kiocb *iocb, struct iov_iter *to);
+ssize_t bcm_vk_write(struct kiocb *iocb, struct iov_iter *from);
 __poll_t bcm_vk_poll(struct file *p_file, struct poll_table_struct *wait);
 int bcm_vk_release(struct inode *inode, struct file *p_file);
 void bcm_vk_release_data(struct kref *kref);
diff --git a/drivers/misc/bcm-vk/bcm_vk_dev.c b/drivers/misc/bcm-vk/bcm_vk_dev.c
index d4a96137728d..1fadb7b2dec1 100644
--- a/drivers/misc/bcm-vk/bcm_vk_dev.c
+++ b/drivers/misc/bcm-vk/bcm_vk_dev.c
@@ -1258,8 +1258,8 @@ static long bcm_vk_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations bcm_vk_fops = {
 	.owner = THIS_MODULE,
 	.open = bcm_vk_open,
-	.read = bcm_vk_read,
-	.write = bcm_vk_write,
+	.read_iter = bcm_vk_read,
+	.write_iter = bcm_vk_write,
 	.poll = bcm_vk_poll,
 	.release = bcm_vk_release,
 	.mmap = bcm_vk_mmap,
diff --git a/drivers/misc/bcm-vk/bcm_vk_msg.c b/drivers/misc/bcm-vk/bcm_vk_msg.c
index 1f42d1d5a630..31418a677ecd 100644
--- a/drivers/misc/bcm-vk/bcm_vk_msg.c
+++ b/drivers/misc/bcm-vk/bcm_vk_msg.c
@@ -13,6 +13,7 @@
 #include <linux/sizes.h>
 #include <linux/spinlock.h>
 #include <linux/timer.h>
+#include <linux/uio.h>
 
 #include "bcm_vk.h"
 #include "bcm_vk_msg.h"
@@ -998,18 +999,16 @@ int bcm_vk_open(struct inode *inode, struct file *p_file)
 	return rc;
 }
 
-ssize_t bcm_vk_read(struct file *p_file,
-		    char __user *buf,
-		    size_t count,
-		    loff_t *f_pos)
+ssize_t bcm_vk_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t rc = -ENOMSG;
-	struct bcm_vk_ctx *ctx = p_file->private_data;
+	struct bcm_vk_ctx *ctx = iocb->ki_filp->private_data;
 	struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
 					 miscdev);
 	struct device *dev = &vk->pdev->dev;
 	struct bcm_vk_msg_chan *chan = &vk->to_h_msg_chan;
 	struct bcm_vk_wkent *entry = NULL, *iter;
+	size_t count = iov_iter_count(to);
 	u32 q_num;
 	u32 rsp_length;
 
@@ -1047,7 +1046,7 @@ ssize_t bcm_vk_read(struct file *p_file,
 		/* retrieve the passed down msg_id */
 		set_msg_id(&entry->to_h_msg[0], entry->usr_msg_id);
 		rsp_length = entry->to_h_blks * VK_MSGQ_BLK_SIZE;
-		if (copy_to_user(buf, entry->to_h_msg, rsp_length) == 0)
+		if (!copy_to_iter_full(entry->to_h_msg, rsp_length, to))
 			rc = rsp_length;
 
 		bcm_vk_free_wkent(dev, entry);
@@ -1060,7 +1059,7 @@ ssize_t bcm_vk_read(struct file *p_file,
 		 */
 		set_msg_id(&tmp_msg, entry->usr_msg_id);
 		tmp_msg.size = entry->to_h_blks - 1;
-		if (copy_to_user(buf, &tmp_msg, VK_MSGQ_BLK_SIZE) != 0) {
+		if (!copy_to_iter_full(&tmp_msg, VK_MSGQ_BLK_SIZE, to)) {
 			dev_err(dev, "Error return 1st block in -EMSGSIZE\n");
 			rc = -EFAULT;
 		}
@@ -1068,17 +1067,15 @@ ssize_t bcm_vk_read(struct file *p_file,
 	return rc;
 }
 
-ssize_t bcm_vk_write(struct file *p_file,
-		     const char __user *buf,
-		     size_t count,
-		     loff_t *f_pos)
+ssize_t bcm_vk_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	ssize_t rc;
-	struct bcm_vk_ctx *ctx = p_file->private_data;
+	struct bcm_vk_ctx *ctx = iocb->ki_filp->private_data;
 	struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
 					 miscdev);
 	struct bcm_vk_msgq __iomem *msgq;
 	struct device *dev = &vk->pdev->dev;
+	size_t count = iov_iter_count(from);
 	struct bcm_vk_wkent *entry;
 	u32 sgl_extra_blks;
 	u32 q_num;
@@ -1107,7 +1104,7 @@ ssize_t bcm_vk_write(struct file *p_file,
 	}
 
 	/* now copy msg from user space, and then formulate the work entry */
-	if (copy_from_user(&entry->to_v_msg[0], buf, count)) {
+	if (!copy_from_iter_full(&entry->to_v_msg[0], count, from)) {
 		rc = -EFAULT;
 		goto write_free_ent;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 213/437] misc: lis3lv02d: convert to iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (211 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 212/437] misc: bcm_vk: convert to iterators Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 214/437] misc: eeprom/idt_89hpesx: convert to read/write iterators Jens Axboe
                   ` (224 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/lis3lv02d/lis3lv02d.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 49868a45c0ad..e12677611146 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/atomic.h>
 #include <linux/of.h>
+#include <linux/uio.h>
 #include "lis3lv02d.h"
 
 #define DRIVER_NAME     "lis3lv02d"
@@ -596,12 +597,12 @@ static int lis3lv02d_misc_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
-				size_t count, loff_t *pos)
+static ssize_t lis3lv02d_misc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lis3lv02d *lis3 = container_of(file->private_data,
+	struct lis3lv02d *lis3 = container_of(iocb->ki_filp->private_data,
 					      struct lis3lv02d, miscdev);
 
+	size_t count = iov_iter_count(to);
 	DECLARE_WAITQUEUE(wait, current);
 	u32 data;
 	unsigned char byte_data;
@@ -617,7 +618,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
 		if (data)
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto out;
 		}
@@ -638,7 +639,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
 	/* make sure we are not going into copy_to_user() with
 	 * TASK_INTERRUPTIBLE state */
 	set_current_state(TASK_RUNNING);
-	if (copy_to_user(buf, &byte_data, sizeof(byte_data)))
+	if (!copy_to_iter_full(&byte_data, sizeof(byte_data), to))
 		retval = -EFAULT;
 
 out:
@@ -670,7 +671,7 @@ static int lis3lv02d_misc_fasync(int fd, struct file *file, int on)
 static const struct file_operations lis3lv02d_misc_fops = {
 	.owner   = THIS_MODULE,
 	.llseek  = no_llseek,
-	.read    = lis3lv02d_misc_read,
+	.read_iter    = lis3lv02d_misc_read,
 	.open    = lis3lv02d_misc_open,
 	.release = lis3lv02d_misc_release,
 	.poll    = lis3lv02d_misc_poll,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 214/437] misc: eeprom/idt_89hpesx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (212 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 213/437] misc: lis3lv02d: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 215/437] misc: hpilo: " Jens Axboe
                   ` (223 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/eeprom/idt_89hpesx.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c
index 327afb866b21..dfb68c0cc999 100644
--- a/drivers/misc/eeprom/idt_89hpesx.c
+++ b/drivers/misc/eeprom/idt_89hpesx.c
@@ -900,20 +900,20 @@ static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
  * "<reg addr>:<value>". Register address must be aligned within 4 bytes
  * (one DWORD).
  */
-static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
-				   size_t count, loff_t *offp)
+static ssize_t idt_dbgfs_csr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct idt_89hpesx_dev *pdev = filep->private_data;
+	struct idt_89hpesx_dev *pdev = iocb->ki_filp->private_data;
 	char *colon_ch, *csraddr_str, *csrval_str;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u32 csraddr, csrval;
 	char *buf;
 
-	if (*offp)
+	if (iocb->ki_pos)
 		return 0;
 
 	/* Copy data from User-space */
-	buf = memdup_user_nul(ubuf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -987,10 +987,9 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
  * It just prints the pair "0x<reg addr>:0x<value>" to passed buffer.
  */
 #define CSRBUF_SIZE	((size_t)32)
-static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
-				  size_t count, loff_t *offp)
+static ssize_t idt_dbgfs_csr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct idt_89hpesx_dev *pdev = filep->private_data;
+	struct idt_89hpesx_dev *pdev = iocb->ki_filp->private_data;
 	u32 csraddr, csrval;
 	char buf[CSRBUF_SIZE];
 	int ret, size;
@@ -1008,7 +1007,7 @@ static ssize_t idt_dbgfs_csr_read(struct file *filep, char __user *ubuf,
 		(unsigned int)csraddr, (unsigned int)csrval);
 
 	/* Copy data to User-space */
-	return simple_read_from_buffer(ubuf, count, offp, buf, size);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, size, to);
 }
 
 /*
@@ -1025,8 +1024,8 @@ static BIN_ATTR_RW(eeprom, EEPROM_DEF_SIZE);
 static const struct file_operations csr_dbgfs_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = idt_dbgfs_csr_write,
-	.read = idt_dbgfs_csr_read
+	.write_iter = idt_dbgfs_csr_write,
+	.read_iter = idt_dbgfs_csr_read
 };
 
 /*===========================================================================
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 215/437] misc: hpilo: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (213 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 214/437] misc: eeprom/idt_89hpesx: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 216/437] misc: lkdtm: " Jens Axboe
                   ` (222 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/hpilo.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 04bd34c8c506..27282629e383 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -23,6 +23,7 @@
 #include <linux/wait.h>
 #include <linux/poll.h>
 #include <linux/slab.h>
+#include <linux/uio.h>
 #include "hpilo.h"
 
 static const struct class ilo_class = {
@@ -431,13 +432,13 @@ static void ilo_set_reset(struct ilo_hwinfo *hw)
 	}
 }
 
-static ssize_t ilo_read(struct file *fp, char __user *buf,
-			size_t len, loff_t *off)
+static ssize_t ilo_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int err, found, cnt, pkt_id, pkt_len;
-	struct ccb_data *data = fp->private_data;
+	struct ccb_data *data = iocb->ki_filp->private_data;
 	struct ccb *driver_ccb = &data->driver_ccb;
 	struct ilo_hwinfo *hw = data->ilo_hw;
+	size_t len = iov_iter_count(to);
 	void *pkt;
 
 	if (is_channel_reset(driver_ccb)) {
@@ -473,7 +474,7 @@ static ssize_t ilo_read(struct file *fp, char __user *buf,
 	if (pkt_len < len)
 		len = pkt_len;
 
-	err = copy_to_user(buf, pkt, len);
+	err = !copy_to_iter_full(pkt, len, to);
 
 	/* return the received packet to the queue */
 	ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1));
@@ -481,13 +482,13 @@ static ssize_t ilo_read(struct file *fp, char __user *buf,
 	return err ? -EFAULT : len;
 }
 
-static ssize_t ilo_write(struct file *fp, const char __user *buf,
-			 size_t len, loff_t *off)
+static ssize_t ilo_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err, pkt_id, pkt_len;
-	struct ccb_data *data = fp->private_data;
+	struct ccb_data *data = iocb->ki_filp->private_data;
 	struct ccb *driver_ccb = &data->driver_ccb;
 	struct ilo_hwinfo *hw = data->ilo_hw;
+	size_t len = iov_iter_count(from);
 	void *pkt;
 
 	if (is_channel_reset(driver_ccb))
@@ -502,7 +503,7 @@ static ssize_t ilo_write(struct file *fp, const char __user *buf,
 		len = pkt_len;
 
 	/* on failure, set the len to 0 to return empty packet to the device */
-	err = copy_from_user(pkt, buf, len);
+	err = !copy_from_iter_full(pkt, len, from);
 	if (err)
 		len = 0;
 
@@ -635,8 +636,8 @@ static int ilo_open(struct inode *ip, struct file *fp)
 
 static const struct file_operations ilo_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ilo_read,
-	.write		= ilo_write,
+	.read_iter	= ilo_read,
+	.write_iter	= ilo_write,
 	.poll		= ilo_poll,
 	.open 		= ilo_open,
 	.release 	= ilo_close,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 216/437] misc: lkdtm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (214 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 215/437] misc: hpilo: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 217/437] misc: open-dice: " Jens Axboe
                   ` (221 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/lkdtm/core.c | 40 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c
index 5732fd59a227..12f02713f39c 100644
--- a/drivers/misc/lkdtm/core.c
+++ b/drivers/misc/lkdtm/core.c
@@ -27,20 +27,17 @@
 #include <linux/slab.h>
 #include <linux/debugfs.h>
 #include <linux/utsname.h>
+#include <linux/uio.h>
 
 #define DEFAULT_COUNT 10
 
 static int lkdtm_debugfs_open(struct inode *inode, struct file *file);
-static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
-		size_t count, loff_t *off);
-static ssize_t direct_entry(struct file *f, const char __user *user_buf,
-			    size_t count, loff_t *off);
+static ssize_t lkdtm_debugfs_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t direct_entry(struct kiocb *iocb, struct iov_iter *from);
 
 #ifdef CONFIG_KPROBES
 static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
-static ssize_t lkdtm_debugfs_entry(struct file *f,
-				   const char __user *user_buf,
-				   size_t count, loff_t *off);
+static ssize_t lkdtm_debugfs_entry(struct kiocb *iocb, struct iov_iter *from);
 # define CRASHPOINT_KPROBE(_symbol)				\
 		.kprobe = {					\
 			.symbol_name = (_symbol),		\
@@ -64,10 +61,10 @@ struct crashpoint {
 	{							\
 		.name = _name,					\
 		.fops = {					\
-			.read	= lkdtm_debugfs_read,		\
+			.read_iter= lkdtm_debugfs_read,		\
 			.llseek	= generic_file_llseek,		\
 			.open	= lkdtm_debugfs_open,		\
-			.write	= CRASHPOINT_WRITE(_symbol)	\
+			.write_iter = CRASHPOINT_WRITE(_symbol)	\
 		},						\
 		CRASHPOINT_KPROBE(_symbol)			\
 	}
@@ -224,12 +221,11 @@ static int lkdtm_kprobe_handler(struct kprobe *kp, struct pt_regs *regs)
 	return 0;
 }
 
-static ssize_t lkdtm_debugfs_entry(struct file *f,
-				   const char __user *user_buf,
-				   size_t count, loff_t *off)
+static ssize_t lkdtm_debugfs_entry(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct crashpoint *crashpoint = file_inode(f)->i_private;
+	struct crashpoint *crashpoint = file_inode(iocb->ki_filp)->i_private;
 	const struct crashtype *crashtype = NULL;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err;
 
@@ -239,7 +235,7 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
 	buf = (char *)__get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
-	if (copy_from_user(buf, user_buf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		free_page((unsigned long) buf);
 		return -EFAULT;
 	}
@@ -257,15 +253,14 @@ static ssize_t lkdtm_debugfs_entry(struct file *f,
 	if (err < 0)
 		return err;
 
-	*off += count;
+	iocb->ki_pos += count;
 
 	return count;
 }
 #endif
 
 /* Generic read callback that just prints out the available crash types */
-static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
-		size_t count, loff_t *off)
+static ssize_t lkdtm_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int n, cat, idx;
 	ssize_t out;
@@ -288,8 +283,7 @@ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
 	}
 	buf[n] = '\0';
 
-	out = simple_read_from_buffer(user_buf, count, off,
-				      buf, n);
+	out = simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 	free_page((unsigned long) buf);
 
 	return out;
@@ -301,10 +295,10 @@ static int lkdtm_debugfs_open(struct inode *inode, struct file *file)
 }
 
 /* Special entry to just crash directly. Available without KPROBEs */
-static ssize_t direct_entry(struct file *f, const char __user *user_buf,
-		size_t count, loff_t *off)
+static ssize_t direct_entry(struct kiocb *iocb, struct iov_iter *from)
 {
 	const struct crashtype *crashtype;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err;
 
@@ -316,7 +310,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
 	buf = (char *)__get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
-	if (copy_from_user(buf, user_buf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		free_page((unsigned long) buf);
 		return -EFAULT;
 	}
@@ -331,7 +325,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
 
 	pr_info("Performing direct entry %s\n", crashtype->name);
 	err = lkdtm_do_action(crashtype);
-	*off += count;
+	iocb->ki_pos += count;
 
 	if (err)
 		return err;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 217/437] misc: open-dice: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (215 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 216/437] misc: lkdtm: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 218/437] misc: tps6594-pfsm: " Jens Axboe
                   ` (220 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/open-dice.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c
index 1e3eb2aa44d9..0fe66a17f27d 100644
--- a/drivers/misc/open-dice.c
+++ b/drivers/misc/open-dice.c
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
+#include <linux/uio.h>
 
 #define DRIVER_NAME "open-dice"
 
@@ -61,26 +62,24 @@ static int open_dice_wipe(struct open_dice_drvdata *drvdata)
 /*
  * Copies the size of the reserved memory region to the user-provided buffer.
  */
-static ssize_t open_dice_read(struct file *filp, char __user *ptr, size_t len,
-			      loff_t *off)
+static ssize_t open_dice_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	unsigned long val = to_open_dice_drvdata(filp)->rmem->size;
+	unsigned long val = to_open_dice_drvdata(iocb->ki_filp)->rmem->size;
 
-	return simple_read_from_buffer(ptr, len, off, &val, sizeof(val));
+	return simple_copy_to_iter(&val, &iocb->ki_pos, sizeof(val), to);
 }
 
 /*
  * Triggers a wipe of the reserved memory region. The user-provided pointer
  * is never dereferenced.
  */
-static ssize_t open_dice_write(struct file *filp, const char __user *ptr,
-			       size_t len, loff_t *off)
+static ssize_t open_dice_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	if (open_dice_wipe(to_open_dice_drvdata(filp)))
+	if (open_dice_wipe(to_open_dice_drvdata(iocb->ki_filp)))
 		return -EIO;
 
 	/* Consume the input buffer. */
-	return len;
+	return iov_iter_count(from);
 }
 
 /*
@@ -106,8 +105,8 @@ static int open_dice_mmap(struct file *filp, struct vm_area_struct *vma)
 
 static const struct file_operations open_dice_fops = {
 	.owner = THIS_MODULE,
-	.read = open_dice_read,
-	.write = open_dice_write,
+	.read_iter = open_dice_read,
+	.write_iter = open_dice_write,
 	.mmap = open_dice_mmap,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 218/437] misc: tps6594-pfsm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (216 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 217/437] misc: open-dice: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:15 ` [PATCH 219/437] misc: ibmvmc: " Jens Axboe
                   ` (219 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/tps6594-pfsm.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
index 88dcac814892..3e3da7b4bb7e 100644
--- a/drivers/misc/tps6594-pfsm.c
+++ b/drivers/misc/tps6594-pfsm.c
@@ -45,11 +45,11 @@ struct tps6594_pfsm {
 	struct regmap *regmap;
 };
 
-static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t tps6594_pfsm_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(f);
-	loff_t pos = *ppos;
+	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
+	loff_t pos = iocb->ki_pos;
 	unsigned int val;
 	int ret;
 	int i;
@@ -66,20 +66,19 @@ static ssize_t tps6594_pfsm_read(struct file *f, char __user *buf,
 		if (ret)
 			return ret;
 
-		if (put_user(val, buf + i))
+		if (put_iter(val, to))
 			return -EFAULT;
 	}
 
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
-static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t tps6594_pfsm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(f);
-	loff_t pos = *ppos;
+	struct tps6594_pfsm *pfsm = TPS6594_FILE_TO_PFSM(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
+	loff_t pos = iocb->ki_pos;
 	char val;
 	int ret;
 	int i;
@@ -92,7 +91,7 @@ static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
 		count = TPS6594_PMIC_MAX_POS - pos;
 
 	for (i = 0 ; i < count ; i++) {
-		if (get_user(val, buf + i))
+		if (get_iter(val, from))
 			return -EFAULT;
 
 		ret = regmap_write(pfsm->regmap, pos + i, val);
@@ -100,8 +99,7 @@ static ssize_t tps6594_pfsm_write(struct file *f, const char __user *buf,
 			return ret;
 	}
 
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
@@ -221,8 +219,8 @@ static long tps6594_pfsm_ioctl(struct file *f, unsigned int cmd, unsigned long a
 static const struct file_operations tps6594_pfsm_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= generic_file_llseek,
-	.read		= tps6594_pfsm_read,
-	.write		= tps6594_pfsm_write,
+	.read_iter	= tps6594_pfsm_read,
+	.write_iter	= tps6594_pfsm_write,
 	.unlocked_ioctl	= tps6594_pfsm_ioctl,
 	.compat_ioctl   = compat_ptr_ioctl,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 219/437] misc: ibmvmc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (217 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 218/437] misc: tps6594-pfsm: " Jens Axboe
@ 2024-04-11 15:15 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 220/437] misc: cxl: " Jens Axboe
                   ` (218 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/ibmvmc.c | 40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
index e5f935b5249d..545739f1f342 100644
--- a/drivers/misc/ibmvmc.c
+++ b/drivers/misc/ibmvmc.c
@@ -900,21 +900,20 @@ static int ibmvmc_close(struct inode *inode, struct file *file)
  *	0 - Success
  *	Non-zero - Failure
  */
-static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
-			   loff_t *ppos)
+static ssize_t ibmvmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct ibmvmc_file_session *session;
 	struct ibmvmc_hmc *hmc;
 	struct crq_server_adapter *adapter;
 	struct ibmvmc_buffer *buffer;
+	size_t nbytes = iov_iter_count(to);
 	ssize_t n;
 	ssize_t retval = 0;
 	unsigned long flags;
 	DEFINE_WAIT(wait);
 
-	pr_debug("ibmvmc: read: file = 0x%lx, buf = 0x%lx, nbytes = 0x%lx\n",
-		 (unsigned long)file, (unsigned long)buf,
-		 (unsigned long)nbytes);
+	pr_debug("ibmvmc: read: file = 0x%lx, nbytes = 0x%lx\n",
+		 (unsigned long)iocb->ki_filp, (unsigned long)nbytes);
 
 	if (nbytes == 0)
 		return 0;
@@ -925,7 +924,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 		return -EINVAL;
 	}
 
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (!session) {
 		pr_warn("ibmvmc: read: no session\n");
 		return -EIO;
@@ -957,7 +956,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 			retval = -EBADFD;
 			goto out;
 		}
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto out;
 		}
@@ -977,7 +976,7 @@ static ssize_t ibmvmc_read(struct file *file, char *buf, size_t nbytes,
 	spin_unlock_irqrestore(&hmc->lock, flags);
 
 	nbytes = min_t(size_t, nbytes, buffer->msg_len);
-	n = copy_to_user((void *)buf, buffer->real_addr_local, nbytes);
+	n = !copy_to_iter_full(buffer->real_addr_local, nbytes, to);
 	dev_dbg(adapter->dev, "read: copy to user nbytes = 0x%lx.\n", nbytes);
 	ibmvmc_free_hmc_buffer(hmc, buffer);
 	retval = nbytes;
@@ -1027,27 +1026,25 @@ static unsigned int ibmvmc_poll(struct file *file, poll_table *wait)
 /**
  * ibmvmc_write - Write
  *
- * @file:	file struct
- * @buffer:	Character buffer
- * @count:	Count field
- * @ppos:	Offset
+ * @iocb:	metadata for IO
+ * @from:	Character buffer
  *
  * Return:
  *	0 - Success
  *	Non-zero - Failure
  */
-static ssize_t ibmvmc_write(struct file *file, const char *buffer,
-			    size_t count, loff_t *ppos)
+static ssize_t ibmvmc_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct inode *inode;
 	struct ibmvmc_buffer *vmc_buffer;
 	struct ibmvmc_file_session *session;
 	struct crq_server_adapter *adapter;
+	size_t count = iov_iter_count(from);
 	struct ibmvmc_hmc *hmc;
 	unsigned char *buf;
 	unsigned long flags;
 	size_t bytes;
-	const char *p = buffer;
 	size_t c = count;
 	int ret = 0;
 
@@ -1109,19 +1106,17 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 	}
 	buf = vmc_buffer->real_addr_local;
 
+	ret = 0;
 	while (c > 0) {
 		bytes = min_t(size_t, c, vmc_buffer->size);
 
-		bytes -= copy_from_user(buf, p, bytes);
-		if (!bytes) {
+		if (!copy_from_iter_full(buf, bytes, from)) {
 			ret = -EFAULT;
 			goto out;
 		}
 		c -= bytes;
-		p += bytes;
+		ret += bytes;
 	}
-	if (p == buffer)
-		goto out;
 
 	inode = file_inode(file);
 	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
@@ -1131,7 +1126,6 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
 		(unsigned long)file, (unsigned long)count);
 
 	ibmvmc_send_msg(adapter, vmc_buffer, hmc, count);
-	ret = p - buffer;
  out:
 	spin_unlock_irqrestore(&hmc->lock, flags);
 	return (ssize_t)(ret);
@@ -1387,8 +1381,8 @@ static long ibmvmc_ioctl(struct file *file,
 
 static const struct file_operations ibmvmc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ibmvmc_read,
-	.write		= ibmvmc_write,
+	.read_iter	= ibmvmc_read,
+	.write_iter	= ibmvmc_write,
 	.poll		= ibmvmc_poll,
 	.unlocked_ioctl	= ibmvmc_ioctl,
 	.open           = ibmvmc_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 220/437] misc: cxl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (218 preceding siblings ...)
  2024-04-11 15:15 ` [PATCH 219/437] misc: ibmvmc: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 221/437] misc: ocxl: " Jens Axboe
                   ` (217 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/cxl/api.c  |  7 +++----
 drivers/misc/cxl/cxl.h  |  2 +-
 drivers/misc/cxl/file.c | 23 +++++++++++------------
 include/misc/cxl.h      |  3 +--
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index d85c56530863..54e1f5b917e2 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -375,10 +375,9 @@ __poll_t cxl_fd_poll(struct file *file, struct poll_table_struct *poll)
 	return afu_poll(file, poll);
 }
 EXPORT_SYMBOL_GPL(cxl_fd_poll);
-ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+ssize_t cxl_fd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return afu_read(file, buf, count, off);
+	return afu_read(iocb, to);
 }
 EXPORT_SYMBOL_GPL(cxl_fd_read);
 
@@ -410,7 +409,7 @@ struct file *cxl_get_fd(struct cxl_context *ctx, struct file_operations *fops,
 	if (fops) {
 		PATCH_FOPS(open);
 		PATCH_FOPS(poll);
-		PATCH_FOPS(read);
+		PATCH_FOPS(read_iter);
 		PATCH_FOPS(release);
 		PATCH_FOPS(unlocked_ioctl);
 		PATCH_FOPS(compat_ioctl);
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 6ad0ab892675..6b6738b28f69 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -1045,7 +1045,7 @@ int afu_release(struct inode *inode, struct file *file);
 long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int afu_mmap(struct file *file, struct vm_area_struct *vm);
 __poll_t afu_poll(struct file *file, struct poll_table_struct *poll);
-ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t *off);
+ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to);
 extern const struct file_operations afu_fops;
 
 struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_device *dev);
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index 012e11b959bc..c911bd785f26 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -385,7 +385,7 @@ __poll_t afu_poll(struct file *file, struct poll_table_struct *poll)
 }
 
 static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
-				     char __user *buf,
+				     struct iov_iter *to,
 				     struct cxl_event *event,
 				     struct cxl_event_afu_driver_reserved *pl)
 {
@@ -403,14 +403,13 @@ static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
 	}
 
 	/* Copy event header */
-	if (copy_to_user(buf, event, sizeof(struct cxl_event_header))) {
+	if (!copy_to_iter_full(event, sizeof(struct cxl_event_header), to)) {
 		ctx->afu_driver_ops->event_delivered(ctx, pl, -EFAULT);
 		return -EFAULT;
 	}
 
 	/* Copy event data */
-	buf += sizeof(struct cxl_event_header);
-	if (copy_to_user(buf, &pl->data, pl->data_size)) {
+	if (!copy_to_iter_full(&pl->data, pl->data_size, to)) {
 		ctx->afu_driver_ops->event_delivered(ctx, pl, -EFAULT);
 		return -EFAULT;
 	}
@@ -419,11 +418,11 @@ static ssize_t afu_driver_event_copy(struct cxl_context *ctx,
 	return event->header.size;
 }
 
-ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cxl_context *ctx = file->private_data;
+	struct cxl_context *ctx = iocb->ki_filp->private_data;
 	struct cxl_event_afu_driver_reserved *pl = NULL;
+	size_t count = iov_iter_count(to);
 	struct cxl_event event;
 	unsigned long flags;
 	int rc;
@@ -447,7 +446,7 @@ ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 			goto out;
 		}
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			rc = -EAGAIN;
 			goto out;
 		}
@@ -505,9 +504,9 @@ ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	spin_unlock_irqrestore(&ctx->lock, flags);
 
 	if (event.header.type == CXL_EVENT_AFU_DRIVER)
-		return afu_driver_event_copy(ctx, buf, &event, pl);
+		return afu_driver_event_copy(ctx, to, &event, pl);
 
-	if (copy_to_user(buf, &event, event.header.size))
+	if (!copy_to_iter_full(&event, event.header.size, to))
 		return -EFAULT;
 	return event.header.size;
 
@@ -525,7 +524,7 @@ const struct file_operations afu_fops = {
 	.owner		= THIS_MODULE,
 	.open           = afu_open,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release        = afu_release,
 	.unlocked_ioctl = afu_ioctl,
 	.compat_ioctl   = afu_compat_ioctl,
@@ -536,7 +535,7 @@ static const struct file_operations afu_master_fops = {
 	.owner		= THIS_MODULE,
 	.open           = afu_master_open,
 	.poll		= afu_poll,
-	.read		= afu_read,
+	.read_iter	= afu_read,
 	.release        = afu_release,
 	.unlocked_ioctl = afu_ioctl,
 	.compat_ioctl   = afu_compat_ioctl,
diff --git a/include/misc/cxl.h b/include/misc/cxl.h
index d8044299d654..3758f9c8f83f 100644
--- a/include/misc/cxl.h
+++ b/include/misc/cxl.h
@@ -196,8 +196,7 @@ int cxl_fd_release(struct inode *inode, struct file *file);
 long cxl_fd_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 int cxl_fd_mmap(struct file *file, struct vm_area_struct *vm);
 __poll_t cxl_fd_poll(struct file *file, struct poll_table_struct *poll);
-ssize_t cxl_fd_read(struct file *file, char __user *buf, size_t count,
-			   loff_t *off);
+ssize_t cxl_fd_read(struct kiocb *iocb, struct iov_iter *to);
 
 /*
  * For EEH, a driver may want to assert a PERST will reload the same image
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 221/437] misc: ocxl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (219 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 220/437] misc: cxl: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 222/437] drivers/isdn: " Jens Axboe
                   ` (216 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/ocxl/file.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 7eb74711ac96..09ed5f0eee8a 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -352,7 +352,7 @@ static unsigned int afu_poll(struct file *file, struct poll_table_struct *wait)
  */
 static ssize_t append_xsl_error(struct ocxl_context *ctx,
 				struct ocxl_kernel_event_header *header,
-				char __user *buf)
+				struct iov_iter *to)
 {
 	struct ocxl_kernel_event_xsl_fault_error body;
 
@@ -376,7 +376,7 @@ static ssize_t append_xsl_error(struct ocxl_context *ctx,
 
 	header->type = OCXL_AFU_EVENT_XSL_FAULT_ERROR;
 
-	if (copy_to_user(buf, &body, sizeof(body)))
+	if (!copy_to_iter(&body, sizeof(body), to))
 		return -EFAULT;
 
 	return sizeof(body);
@@ -391,11 +391,11 @@ static ssize_t append_xsl_error(struct ocxl_context *ctx,
  *	Body (struct ocxl_kernel_event_*)
  *	Header...
  */
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
-			loff_t *off)
+static ssize_t afu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ocxl_context *ctx = file->private_data;
+	struct ocxl_context *ctx = iocb->ki_filp->private_data;
 	struct ocxl_kernel_event_header header;
+	size_t count = iov_iter_count(to);
 	ssize_t rc;
 	ssize_t used = 0;
 	DEFINE_WAIT(event_wait);
@@ -403,7 +403,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	memset(&header, 0, sizeof(header));
 
 	/* Require offset to be 0 */
-	if (*off != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
 	if (count < (sizeof(struct ocxl_kernel_event_header) +
@@ -420,7 +420,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 		if (ctx->status == CLOSED)
 			break;
 
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			finish_wait(&ctx->events_wq, &event_wait);
 			return -EAGAIN;
 		}
@@ -436,7 +436,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	finish_wait(&ctx->events_wq, &event_wait);
 
 	if (has_xsl_error(ctx)) {
-		used = append_xsl_error(ctx, &header, buf + sizeof(header));
+		used = append_xsl_error(ctx, &header, to);
 		if (used < 0)
 			return used;
 	}
@@ -444,7 +444,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	if (!afu_events_pending(ctx))
 		header.flags |= OCXL_KERNEL_EVENT_FLAG_LAST;
 
-	if (copy_to_user(buf, &header, sizeof(header)))
+	if (!copy_to_iter_full(&header, sizeof(header), to))
 		return -EFAULT;
 
 	used += sizeof(header);
@@ -476,7 +476,7 @@ static const struct file_operations ocxl_afu_fops = {
 	.compat_ioctl   = afu_compat_ioctl,
 	.mmap           = afu_mmap,
 	.poll           = afu_poll,
-	.read           = afu_read,
+	.read_iter      = afu_read,
 	.release        = afu_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 222/437] drivers/isdn: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (220 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 221/437] misc: ocxl: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 223/437] drivers/leds: " Jens Axboe
                   ` (215 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/isdn/capi/capi.c      | 22 +++++++++++-----------
 drivers/isdn/mISDN/timerdev.c | 16 ++++++++--------
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 3ed257334562..6b613e03d85b 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -648,10 +648,10 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
 
 /* -------- file_operations for capidev ----------------------------- */
 
-static ssize_t
-capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct capidev *cdev = file->private_data;
+	struct capidev *cdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t copied;
 	int err;
@@ -661,7 +661,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 	skb = skb_dequeue(&cdev->recvqueue);
 	if (!skb) {
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		err = wait_event_interruptible(cdev->recvwait,
 					       (skb = skb_dequeue(&cdev->recvqueue)));
@@ -672,7 +672,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		skb_queue_head(&cdev->recvqueue, skb);
 		return -EMSGSIZE;
 	}
-	if (copy_to_user(buf, skb->data, skb->len)) {
+	if (!copy_to_iter_full(skb->data, skb->len, to)) {
 		skb_queue_head(&cdev->recvqueue, skb);
 		return -EFAULT;
 	}
@@ -683,10 +683,10 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	return copied;
 }
 
-static ssize_t
-capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t capi_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct capidev *cdev = file->private_data;
+	struct capidev *cdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 	u16 mlen;
 
@@ -700,7 +700,7 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos
 	if (!skb)
 		return -ENOMEM;
 
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -1025,8 +1025,8 @@ static const struct file_operations capi_fops =
 {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= capi_read,
-	.write		= capi_write,
+	.read_iter	= capi_read,
+	.write_iter	= capi_write,
 	.poll		= capi_poll,
 	.unlocked_ioctl	= capi_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 83d6b484d3c6..cf52b08e2fad 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -89,17 +89,17 @@ mISDN_close(struct inode *ino, struct file *filep)
 	return 0;
 }
 
-static ssize_t
-mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
+static ssize_t mISDN_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mISDNtimerdev	*dev = filep->private_data;
+	struct mISDNtimerdev	*dev = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(to);
 	struct list_head *list = &dev->expired;
 	struct mISDNtimer	*timer;
 	int	ret = 0;
 
 	if (*debug & DEBUG_TIMER)
-		printk(KERN_DEBUG "%s(%p, %p, %d, %p)\n", __func__,
-		       filep, buf, (int)count, off);
+		printk(KERN_DEBUG "%s(%p, %d)\n", __func__,
+		       iocb->ki_filp, (int)count);
 
 	if (count < sizeof(int))
 		return -ENOSPC;
@@ -107,7 +107,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
 	spin_lock_irq(&dev->lock);
 	while (list_empty(list) && (dev->work == 0)) {
 		spin_unlock_irq(&dev->lock);
-		if (filep->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		wait_event_interruptible(dev->wait, (dev->work ||
 						     !list_empty(list)));
@@ -121,7 +121,7 @@ mISDN_read(struct file *filep, char __user *buf, size_t count, loff_t *off)
 		timer = list_first_entry(list, struct mISDNtimer, list);
 		list_del(&timer->list);
 		spin_unlock_irq(&dev->lock);
-		if (put_user(timer->id, (int __user *)buf))
+		if (put_iter(timer->id, to))
 			ret = -EFAULT;
 		else
 			ret = sizeof(int);
@@ -261,7 +261,7 @@ mISDN_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations mISDN_fops = {
 	.owner		= THIS_MODULE,
-	.read		= mISDN_read,
+	.read_iter	= mISDN_read,
 	.poll		= mISDN_poll,
 	.unlocked_ioctl	= mISDN_ioctl,
 	.open		= mISDN_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 223/437] drivers/leds: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (221 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 222/437] drivers/isdn: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 224/437] drivers/mailbox: " Jens Axboe
                   ` (214 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/leds/uleds.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/leds/uleds.c b/drivers/leds/uleds.c
index 3d361c920030..b1fa00407364 100644
--- a/drivers/leds/uleds.c
+++ b/drivers/leds/uleds.c
@@ -70,10 +70,10 @@ static int uleds_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t uleds_write(struct file *file, const char __user *buffer,
-			   size_t count, loff_t *ppos)
+static ssize_t uleds_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct uleds_device *udev = file->private_data;
+	struct uleds_device *udev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	const char *name;
 	int ret;
 
@@ -94,8 +94,8 @@ static ssize_t uleds_write(struct file *file, const char __user *buffer,
 		goto out;
 	}
 
-	if (copy_from_user(&udev->user_dev, buffer,
-			   sizeof(struct uleds_user_dev))) {
+	if (!copy_from_iter_full(&udev->user_dev, sizeof(struct uleds_user_dev),
+				 from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -128,10 +128,10 @@ static ssize_t uleds_write(struct file *file, const char __user *buffer,
 	return ret;
 }
 
-static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
-			  loff_t *ppos)
+static ssize_t uleds_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uleds_device *udev = file->private_data;
+	struct uleds_device *udev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	ssize_t retval;
 
 	if (count < sizeof(udev->brightness))
@@ -144,13 +144,16 @@ static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
 
 		if (udev->state != ULEDS_STATE_REGISTERED) {
 			retval = -ENODEV;
-		} else if (!udev->new_data && (file->f_flags & O_NONBLOCK)) {
+		} else if (!udev->new_data && (iocb->ki_filp->f_flags & O_NONBLOCK)) {
 			retval = -EAGAIN;
 		} else if (udev->new_data) {
-			retval = copy_to_user(buffer, &udev->brightness,
-					      sizeof(udev->brightness));
+			retval = !copy_to_iter_full(&udev->brightness,
+					      sizeof(udev->brightness), to);
 			udev->new_data = false;
-			retval = sizeof(udev->brightness);
+			if (retval)
+				retval = -EFAULT;
+			else
+				retval = sizeof(udev->brightness);
 		}
 
 		mutex_unlock(&udev->mutex);
@@ -158,7 +161,7 @@ static ssize_t uleds_read(struct file *file, char __user *buffer, size_t count,
 		if (retval)
 			break;
 
-		if (!(file->f_flags & O_NONBLOCK))
+		if (!(iocb->ki_filp->f_flags & O_NONBLOCK))
 			retval = wait_event_interruptible(udev->waitq,
 					udev->new_data ||
 					udev->state != ULEDS_STATE_REGISTERED);
@@ -197,8 +200,8 @@ static const struct file_operations uleds_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uleds_open,
 	.release	= uleds_release,
-	.read		= uleds_read,
-	.write		= uleds_write,
+	.read_iter	= uleds_read,
+	.write_iter	= uleds_write,
 	.poll		= uleds_poll,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 224/437] drivers/mailbox: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (222 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 223/437] drivers/leds: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 225/437] drivers/mfd: " Jens Axboe
                   ` (213 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/mailbox/bcm-pdc-mailbox.c |  9 ++++----
 drivers/mailbox/mailbox-test.c    | 37 ++++++++++++++-----------------
 2 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c
index 1768d3d5aaa0..4fd840cd7193 100644
--- a/drivers/mailbox/bcm-pdc-mailbox.c
+++ b/drivers/mailbox/bcm-pdc-mailbox.c
@@ -420,8 +420,7 @@ static struct pdc_globals pdcg;
 /* top level debug FS directory for PDC driver */
 static struct dentry *debugfs_dir;
 
-static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
-				size_t count, loff_t *offp)
+static ssize_t pdc_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct pdc_state *pdcs;
 	char *buf;
@@ -433,7 +432,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	pdcs = filp->private_data;
+	pdcs = iocb->ki_filp->private_data;
 	out_offset = 0;
 	out_offset += scnprintf(buf + out_offset, out_count - out_offset,
 			       "SPU %u stats:\n", pdcs->pdc_idx);
@@ -469,7 +468,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 	if (out_offset > out_count)
 		out_offset = out_count;
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, out_offset, to);
 	kfree(buf);
 	return ret;
 }
@@ -477,7 +476,7 @@ static ssize_t pdc_debugfs_read(struct file *filp, char __user *ubuf,
 static const struct file_operations pdc_debugfs_stats = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = pdc_debugfs_read,
+	.read_iter = pdc_debugfs_read,
 };
 
 /**
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 3386b4e72551..27176797770b 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -46,11 +46,10 @@ struct mbox_test_device {
 	struct dentry		*root_debugfs_dir;
 };
 
-static ssize_t mbox_test_signal_write(struct file *filp,
-				       const char __user *userbuf,
-				       size_t count, loff_t *ppos)
+static ssize_t mbox_test_signal_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (!tdev->tx_channel) {
 		dev_err(tdev->dev, "Channel cannot do Tx\n");
@@ -71,7 +70,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 			return -ENOMEM;
 	}
 
-	if (copy_from_user(tdev->signal, userbuf, count)) {
+	if (!copy_from_iter_full(tdev->signal, count, from)) {
 		kfree(tdev->signal);
 		tdev->signal = NULL;
 		return -EFAULT;
@@ -81,7 +80,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
 }
 
 static const struct file_operations mbox_test_signal_ops = {
-	.write	= mbox_test_signal_write,
+	.write_iter	= mbox_test_signal_write,
 	.open	= simple_open,
 	.llseek	= generic_file_llseek,
 };
@@ -93,11 +92,11 @@ static int mbox_test_message_fasync(int fd, struct file *filp, int on)
 	return fasync_helper(fd, filp, on, &tdev->async_queue);
 }
 
-static ssize_t mbox_test_message_write(struct file *filp,
-				       const char __user *userbuf,
-				       size_t count, loff_t *ppos)
+static ssize_t mbox_test_message_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *message;
 	void *data;
 	int ret;
@@ -121,7 +120,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
 	mutex_lock(&tdev->mutex);
 
 	tdev->message = message;
-	ret = copy_from_user(tdev->message, userbuf, count);
+	ret = !copy_from_iter_full(tdev->message, count, from);
 	if (ret) {
 		ret = -EFAULT;
 		goto out;
@@ -168,10 +167,9 @@ static bool mbox_test_message_data_ready(struct mbox_test_device *tdev)
 	return data_ready;
 }
 
-static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t mbox_test_message_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mbox_test_device *tdev = filp->private_data;
+	struct mbox_test_device *tdev = iocb->ki_filp->private_data;
 	unsigned long flags;
 	char *touser, *ptr;
 	int l = 0;
@@ -185,8 +183,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 
 	if (!tdev->rx_channel) {
 		ret = snprintf(touser, 20, "<NO RX CAPABILITY>\n");
-		ret = simple_read_from_buffer(userbuf, count, ppos,
-					      touser, ret);
+		ret = simple_copy_to_iter(touser, &iocb->ki_pos, ret, to);
 		goto kfree_err;
 	}
 
@@ -198,7 +195,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 		if (mbox_test_message_data_ready(tdev))
 			break;
 
-		if (filp->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			goto waitq_err;
 		}
@@ -231,7 +228,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
 
 	spin_unlock_irqrestore(&tdev->lock, flags);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, touser, MBOX_HEXDUMP_MAX_LEN);
+	ret = simple_copy_to_iter(touser, &iocb->ki_pos, MBOX_HEXDUMP_MAX_LEN, to);
 waitq_err:
 	__set_current_state(TASK_RUNNING);
 	remove_wait_queue(&tdev->waitq, &wait);
@@ -253,8 +250,8 @@ mbox_test_message_poll(struct file *filp, struct poll_table_struct *wait)
 }
 
 static const struct file_operations mbox_test_message_ops = {
-	.write	= mbox_test_message_write,
-	.read	= mbox_test_message_read,
+	.write_iter	= mbox_test_message_write,
+	.read_iter	= mbox_test_message_read,
 	.fasync	= mbox_test_message_fasync,
 	.poll	= mbox_test_message_poll,
 	.open	= simple_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 225/437] drivers/mfd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (223 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 224/437] drivers/mailbox: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 226/437] drivers/misc/mei: " Jens Axboe
                   ` (212 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/mfd/aat2870-core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/aat2870-core.c b/drivers/mfd/aat2870-core.c
index 2fee62f1016c..78a8809908ff 100644
--- a/drivers/mfd/aat2870-core.c
+++ b/drivers/mfd/aat2870-core.c
@@ -248,10 +248,9 @@ static ssize_t aat2870_dump_reg(struct aat2870_data *aat2870, char *buf)
 	return count;
 }
 
-static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t aat2870_reg_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct aat2870_data *aat2870 = file->private_data;
+	struct aat2870_data *aat2870 = iocb->ki_filp->private_data;
 	char *buf;
 	ssize_t ret;
 
@@ -261,18 +260,17 @@ static ssize_t aat2870_reg_read_file(struct file *file, char __user *user_buf,
 
 	ret = aat2870_dump_reg(aat2870, buf);
 	if (ret >= 0)
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+		ret = simple_copy_from_iter(buf, &iocb->ki_pos, ret, to);
 
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t aat2870_reg_write_file(struct file *file,
-				      const char __user *user_buf, size_t count,
-				      loff_t *ppos)
+static ssize_t aat2870_reg_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct aat2870_data *aat2870 = file->private_data;
+	struct aat2870_data *aat2870 = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t buf_size;
 	char *start = buf;
@@ -280,7 +278,7 @@ static ssize_t aat2870_reg_write_file(struct file *file,
 	int ret;
 
 	buf_size = min(count, (size_t)(sizeof(buf)-1));
-	if (copy_from_user(buf, user_buf, buf_size)) {
+	if (!copy_from_iter_full(buf, buf_size, from)) {
 		dev_err(aat2870->dev, "Failed to copy from user\n");
 		return -EFAULT;
 	}
@@ -314,8 +312,8 @@ static ssize_t aat2870_reg_write_file(struct file *file,
 
 static const struct file_operations aat2870_reg_fops = {
 	.open = simple_open,
-	.read = aat2870_reg_read_file,
-	.write = aat2870_reg_write_file,
+	.read_iter = aat2870_reg_read_file,
+	.write_iter = aat2870_reg_write_file,
 };
 
 static void aat2870_init_debugfs(struct aat2870_data *aat2870)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 226/437] drivers/misc/mei: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (224 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 225/437] drivers/mfd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 227/437] misc: ibmasm: " Jens Axboe
                   ` (211 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/mei/main.c | 53 ++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 79e6f3c1341f..2bab5b317b99 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -159,20 +159,19 @@ static int mei_release(struct inode *inode, struct file *file)
 /**
  * mei_read - the read function.
  *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
+ * @iocb: metadata for IO
+ * @to: pointer to user buffer
  *
  * Return: >=0 data length on success , <0 on error
  */
-static ssize_t mei_read(struct file *file, char __user *ubuf,
-			size_t length, loff_t *offset)
+static ssize_t mei_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	struct file *file = iocb->ki_filp;
 	struct mei_cl *cl = file->private_data;
 	struct mei_device *dev;
 	struct mei_cl_cb *cb = NULL;
-	bool nonblock = !!(file->f_flags & O_NONBLOCK);
+	bool nonblock = !!(iocb->ki_filp->f_flags & O_NONBLOCK);
+	size_t length = iov_iter_count(to);
 	ssize_t rets;
 
 	if (WARN_ON(!cl || !cl->dev))
@@ -192,17 +191,12 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 		goto out;
 	}
 
-	if (ubuf == NULL) {
-		rets = -EMSGSIZE;
-		goto out;
-	}
-
 	cb = mei_cl_read_cb(cl, file);
 	if (cb)
 		goto copy_buffer;
 
-	if (*offset > 0)
-		*offset = 0;
+	if (iocb->ki_pos > 0)
+		iocb->ki_pos = 0;
 
 	rets = mei_cl_read_start(cl, length, file);
 	if (rets && rets != -EBUSY) {
@@ -245,31 +239,31 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 	}
 
 	cl_dbg(dev, cl, "buf.size = %zu buf.idx = %zu offset = %lld\n",
-	       cb->buf.size, cb->buf_idx, *offset);
-	if (*offset >= cb->buf_idx) {
+	       cb->buf.size, cb->buf_idx, iocb->ki_pos);
+	if (iocb->ki_pos  >= cb->buf_idx) {
 		rets = 0;
 		goto free;
 	}
 
 	/* length is being truncated to PAGE_SIZE,
 	 * however buf_idx may point beyond that */
-	length = min_t(size_t, length, cb->buf_idx - *offset);
+	length = min_t(size_t, length, cb->buf_idx - iocb->ki_pos);
 
-	if (copy_to_user(ubuf, cb->buf.data + *offset, length)) {
+	if (!copy_to_iter(cb->buf.data + iocb->ki_pos, length, to)) {
 		dev_dbg(dev->dev, "failed to copy data to userland\n");
 		rets = -EFAULT;
 		goto free;
 	}
 
 	rets = length;
-	*offset += length;
+	iocb->ki_pos += length;
 	/* not all data was read, keep the cb */
-	if (*offset < cb->buf_idx)
+	if (iocb->ki_pos < cb->buf_idx)
 		goto out;
 
 free:
 	mei_cl_del_rd_completed(cl, cb);
-	*offset = 0;
+	iocb->ki_pos = 0;
 
 out:
 	cl_dbg(dev, cl, "end mei read rets = %zd\n", rets);
@@ -301,17 +295,16 @@ static u8 mei_cl_vtag_by_fp(const struct mei_cl *cl, const struct file *fp)
 /**
  * mei_write - the write function.
  *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
+ * @iocb: metadata for IO
+ * @from: pointer to user buffer
  *
  * Return: >=0 data length on success , <0 on error
  */
-static ssize_t mei_write(struct file *file, const char __user *ubuf,
-			 size_t length, loff_t *offset)
+static ssize_t mei_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct mei_cl *cl = file->private_data;
+	size_t length = iov_iter_count(from);
 	struct mei_cl_cb *cb;
 	struct mei_device *dev;
 	ssize_t rets;
@@ -377,7 +370,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 	}
 	cb->vtag = mei_cl_vtag_by_fp(cl, file);
 
-	rets = copy_from_user(cb->buf.data, ubuf, length);
+	rets = !copy_from_iter_full(cb->buf.data, length, from);
 	if (rets) {
 		dev_dbg(dev->dev, "failed to copy data from userland\n");
 		rets = -EFAULT;
@@ -1167,12 +1160,12 @@ ATTRIBUTE_GROUPS(mei);
  */
 static const struct file_operations mei_fops = {
 	.owner = THIS_MODULE,
-	.read = mei_read,
+	.read_iter = mei_read,
 	.unlocked_ioctl = mei_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open = mei_open,
 	.release = mei_release,
-	.write = mei_write,
+	.write_iter = mei_write,
 	.poll = mei_poll,
 	.fsync = mei_fsync,
 	.fasync = mei_fasync,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 227/437] misc: ibmasm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (225 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 226/437] drivers/misc/mei: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 228/437] drivers/spi: " Jens Axboe
                   ` (210 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/misc/ibmasm/ibmasmfs.c | 94 ++++++++++++++++++----------------
 1 file changed, 50 insertions(+), 44 deletions(-)

diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index c44de892a61e..8f7ea4214d20 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -256,18 +256,19 @@ static int command_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t command_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t command_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_command_data *command_data = file->private_data;
+	struct ibmasmfs_command_data *command_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct command *cmd;
 	int len;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	spin_lock_irqsave(&command_data->sp->lock, flags);
@@ -284,7 +285,7 @@ static ssize_t command_file_read(struct file *file, char __user *buf, size_t cou
 		return -EIO;
 	}
 	len = min(count, cmd->buffer_size);
-	if (copy_to_user(buf, cmd->buffer, len)) {
+	if (!copy_to_iter_full(cmd->buffer, len, to)) {
 		command_put(cmd);
 		return -EFAULT;
 	}
@@ -293,17 +294,18 @@ static ssize_t command_file_read(struct file *file, char __user *buf, size_t cou
 	return len;
 }
 
-static ssize_t command_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
+static ssize_t command_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_command_data *command_data = file->private_data;
+	struct ibmasmfs_command_data *command_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct command *cmd;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	/* commands are executed sequentially, only one command at a time */
@@ -314,7 +316,7 @@ static ssize_t command_file_write(struct file *file, const char __user *ubuff, s
 	if (!cmd)
 		return -ENOMEM;
 
-	if (copy_from_user(cmd->buffer, ubuff, count)) {
+	if (!copy_from_iter_full(cmd->buffer, count, from)) {
 		command_put(cmd);
 		return -EFAULT;
 	}
@@ -365,19 +367,20 @@ static int event_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t event_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_event_data *event_data = file->private_data;
+	struct ibmasmfs_event_data *event_data = iocb->ki_filp->private_data;
 	struct event_reader *reader = &event_data->reader;
 	struct service_processor *sp = event_data->sp;
+	size_t count = iov_iter_count(to);
 	int ret;
 	unsigned long flags;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > IBMASM_EVENT_MAX_SIZE)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	spin_lock_irqsave(&sp->lock, flags);
@@ -397,7 +400,7 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
 		goto out;
 	}
 
-        if (copy_to_user(buf, reader->data, reader->data_size)) {
+        if (!copy_to_iter_full(reader->data, reader->data_size, to)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -408,15 +411,16 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
 	return ret;
 }
 
-static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
+static ssize_t event_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_event_data *event_data = file->private_data;
+	struct ibmasmfs_event_data *event_data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count != 1)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	ibmasm_cancel_next_event(&event_data->reader);
@@ -449,17 +453,18 @@ static int r_heartbeat_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t r_heartbeat_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
+	struct ibmasmfs_heartbeat_data *rhbeat = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	unsigned long flags;
 	int result;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > 1024)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	/* allow only one reverse heartbeat per process */
@@ -477,15 +482,16 @@ static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t
 	return result;
 }
 
-static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
+static ssize_t r_heartbeat_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
+	struct ibmasmfs_heartbeat_data *rhbeat = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count != 1)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (rhbeat->active)
@@ -499,9 +505,9 @@ static int remote_settings_file_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
+static ssize_t remote_settings_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	void __iomem *address = (void __iomem *)file->private_data;
+	void __iomem *address = (void __iomem *)iocb->ki_filp->private_data;
 	int len = 0;
 	unsigned int value;
 	char lbuf[20];
@@ -509,28 +515,28 @@ static ssize_t remote_settings_file_read(struct file *file, char __user *buf, si
 	value = readl(address);
 	len = snprintf(lbuf, sizeof(lbuf), "%d\n", value);
 
-	return simple_read_from_buffer(buf, count, offset, lbuf, len);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
+static ssize_t remote_settings_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	void __iomem *address = (void __iomem *)file->private_data;
+	void __iomem *address = (void __iomem *)iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buff;
 	unsigned int value;
 
-	if (*offset < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	if (count == 0 || count > 1024)
 		return 0;
-	if (*offset != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buff = kzalloc (count + 1, GFP_KERNEL);
 	if (!buff)
 		return -ENOMEM;
 
-
-	if (copy_from_user(buff, ubuff, count)) {
+	if (!copy_from_iter_full(buff, count, from)) {
 		kfree(buff);
 		return -EFAULT;
 	}
@@ -545,32 +551,32 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
 static const struct file_operations command_fops = {
 	.open =		command_file_open,
 	.release =	command_file_close,
-	.read =		command_file_read,
-	.write =	command_file_write,
+	.read_iter =	command_file_read,
+	.write_iter =	command_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations event_fops = {
 	.open =		event_file_open,
 	.release =	event_file_close,
-	.read =		event_file_read,
-	.write =	event_file_write,
+	.read_iter =	event_file_read,
+	.write_iter =	event_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations r_heartbeat_fops = {
 	.open =		r_heartbeat_file_open,
 	.release =	r_heartbeat_file_close,
-	.read =		r_heartbeat_file_read,
-	.write =	r_heartbeat_file_write,
+	.read_iter =	r_heartbeat_file_read,
+	.write_iter =	r_heartbeat_file_write,
 	.llseek =	generic_file_llseek,
 };
 
 static const struct file_operations remote_settings_fops = {
 	.open =		simple_open,
 	.release =	remote_settings_file_close,
-	.read =		remote_settings_file_read,
-	.write =	remote_settings_file_write,
+	.read_iter =	remote_settings_file_read,
+	.write_iter =	remote_settings_file_write,
 	.llseek =	generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 228/437] drivers/spi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (226 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 227/437] misc: ibmasm: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 229/437] drivers/nfc: " Jens Axboe
                   ` (209 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/spi/spidev.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 95fb5f1c91c1..1b5e13492b4d 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -154,27 +154,28 @@ spidev_sync_read(struct spidev_data *spidev, size_t len)
 
 /* Read-only message with current device setup */
 static ssize_t
-spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
+spidev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct spidev_data	*spidev;
 	ssize_t			status;
+	size_t			count = iov_iter_count(to);
 
 	/* chipselect only toggles at start or end of operation */
 	if (count > bufsiz)
 		return -EMSGSIZE;
 
-	spidev = filp->private_data;
+	spidev = iocb->ki_filp->private_data;
 
 	mutex_lock(&spidev->buf_lock);
 	status = spidev_sync_read(spidev, count);
 	if (status > 0) {
-		unsigned long	missing;
+		unsigned long	copied;
 
-		missing = copy_to_user(buf, spidev->rx_buffer, status);
-		if (missing == status)
+		copied = copy_to_iter(spidev->rx_buffer, status, to);
+		if (!copied)
 			status = -EFAULT;
 		else
-			status = status - missing;
+			status = status - copied;
 	}
 	mutex_unlock(&spidev->buf_lock);
 
@@ -183,25 +184,25 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
 
 /* Write-only message with current device setup */
 static ssize_t
-spidev_write(struct file *filp, const char __user *buf,
-		size_t count, loff_t *f_pos)
+spidev_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct spidev_data	*spidev;
 	ssize_t			status;
-	unsigned long		missing;
+	unsigned long		copied;
+	size_t			count = iov_iter_count(from);
 
 	/* chipselect only toggles at start or end of operation */
 	if (count > bufsiz)
 		return -EMSGSIZE;
 
-	spidev = filp->private_data;
+	spidev = iocb->ki_filp->private_data;
 
 	mutex_lock(&spidev->buf_lock);
-	missing = copy_from_user(spidev->tx_buffer, buf, count);
-	if (missing == 0)
-		status = spidev_sync_write(spidev, count);
-	else
+	copied = copy_from_iter(spidev->tx_buffer, count, from);
+	if (copied == 0)
 		status = -EFAULT;
+	else
+		status = spidev_sync_write(spidev, count);
 	mutex_unlock(&spidev->buf_lock);
 
 	return status;
@@ -679,8 +680,8 @@ static const struct file_operations spidev_fops = {
 	 * gets more complete API coverage.  It'll simplify things
 	 * too, except for the locking.
 	 */
-	.write =	spidev_write,
-	.read =		spidev_read,
+	.write_iter =	spidev_write,
+	.read_iter =	spidev_read,
 	.unlocked_ioctl = spidev_ioctl,
 	.compat_ioctl = spidev_compat_ioctl,
 	.open =		spidev_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 229/437] drivers/nfc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (227 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 228/437] drivers/spi: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 230/437] drivers/nvme: " Jens Axboe
                   ` (208 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/nfc/virtual_ncidev.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c
index 590b038e449e..59c75de758d7 100644
--- a/drivers/nfc/virtual_ncidev.c
+++ b/drivers/nfc/virtual_ncidev.c
@@ -79,10 +79,10 @@ static const struct nci_ops virtual_nci_ops = {
 	.send = virtual_nci_send
 };
 
-static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t virtual_ncidev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct virtual_nci_dev *vdev = file->private_data;
+	struct virtual_nci_dev *vdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	size_t actual_len;
 
 	mutex_lock(&vdev->mtx);
@@ -95,7 +95,7 @@ static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
 
 	actual_len = min_t(size_t, count, vdev->send_buff->len);
 
-	if (copy_to_user(buf, vdev->send_buff->data, actual_len)) {
+	if (!copy_to_iter_full(vdev->send_buff->data, actual_len, to)) {
 		mutex_unlock(&vdev->mtx);
 		return -EFAULT;
 	}
@@ -110,18 +110,17 @@ static ssize_t virtual_ncidev_read(struct file *file, char __user *buf,
 	return actual_len;
 }
 
-static ssize_t virtual_ncidev_write(struct file *file,
-				    const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t virtual_ncidev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct virtual_nci_dev *vdev = file->private_data;
+	struct virtual_nci_dev *vdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 
 	skb = alloc_skb(count, GFP_KERNEL);
 	if (!skb)
 		return -ENOMEM;
 
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -191,8 +190,8 @@ static long virtual_ncidev_ioctl(struct file *file, unsigned int cmd,
 
 static const struct file_operations virtual_ncidev_fops = {
 	.owner = THIS_MODULE,
-	.read = virtual_ncidev_read,
-	.write = virtual_ncidev_write,
+	.read_iter = virtual_ncidev_read,
+	.write_iter = virtual_ncidev_write,
 	.open = virtual_ncidev_open,
 	.release = virtual_ncidev_close,
 	.unlocked_ioctl = virtual_ncidev_ioctl
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 230/437] drivers/nvme: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (228 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 229/437] drivers/nfc: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 231/437] drivers/firewire: " Jens Axboe
                   ` (207 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/nvme/host/fabrics.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 1f0ea1f32d22..6d0251cc4bf3 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -1326,10 +1326,10 @@ static const struct class nvmf_class = {
 static struct device *nvmf_device;
 static DEFINE_MUTEX(nvmf_dev_mutex);
 
-static ssize_t nvmf_dev_write(struct file *file, const char __user *ubuf,
-		size_t count, loff_t *pos)
+static ssize_t nvmf_dev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq_file = file->private_data;
+	struct seq_file *seq_file = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct nvme_ctrl *ctrl;
 	const char *buf;
 	int ret = 0;
@@ -1337,7 +1337,7 @@ static ssize_t nvmf_dev_write(struct file *file, const char __user *ubuf,
 	if (count > PAGE_SIZE)
 		return -ENOMEM;
 
-	buf = memdup_user_nul(ubuf, count);
+	buf = iterdup_nul(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -1422,8 +1422,8 @@ static int nvmf_dev_release(struct inode *inode, struct file *file)
 
 static const struct file_operations nvmf_dev_fops = {
 	.owner		= THIS_MODULE,
-	.write		= nvmf_dev_write,
-	.read		= seq_read,
+	.write_iter	= nvmf_dev_write,
+	.read_iter	= seq_read_iter,
 	.open		= nvmf_dev_open,
 	.release	= nvmf_dev_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 231/437] drivers/firewire: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (229 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 230/437] drivers/nvme: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 232/437] drivers/mfd: " Jens Axboe
                   ` (206 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firewire/core-cdev.c | 15 +++++++--------
 drivers/firewire/nosy.c      | 18 ++++++++----------
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 6274b86eb943..ded5873c444b 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -301,9 +301,9 @@ static void queue_event(struct client *client, struct event *event,
 	wake_up_interruptible(&client->wait);
 }
 
-static int dequeue_event(struct client *client,
-			 char __user *buffer, size_t count)
+static int dequeue_event(struct client *client, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct event *event;
 	size_t size, total;
 	int i, ret;
@@ -326,7 +326,7 @@ static int dequeue_event(struct client *client,
 	total = 0;
 	for (i = 0; i < ARRAY_SIZE(event->v) && total < count; i++) {
 		size = min(event->v[i].size, count - total);
-		if (copy_to_user(buffer + total, event->v[i].data, size)) {
+		if (!copy_to_iter_full(event->v[i].data, size, to)) {
 			ret = -EFAULT;
 			goto out;
 		}
@@ -340,12 +340,11 @@ static int dequeue_event(struct client *client,
 	return ret;
 }
 
-static ssize_t fw_device_op_read(struct file *file, char __user *buffer,
-				 size_t count, loff_t *offset)
+static ssize_t fw_device_op_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct client *client = file->private_data;
+	struct client *client = iocb->ki_filp->private_data;
 
-	return dequeue_event(client, buffer, count);
+	return dequeue_event(client, to);
 }
 
 static void fill_bus_reset_event(struct fw_cdev_event_bus_reset *event,
@@ -1922,7 +1921,7 @@ const struct file_operations fw_device_ops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
 	.open		= fw_device_op_open,
-	.read		= fw_device_op_read,
+	.read_iter	= fw_device_op_read,
 	.unlocked_ioctl	= fw_device_op_ioctl,
 	.mmap		= fw_device_op_mmap,
 	.release	= fw_device_op_release,
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index b0d671db178a..d4e7f465afc4 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -133,8 +133,7 @@ packet_buffer_destroy(struct packet_buffer *buffer)
 	kfree(buffer->data);
 }
 
-static int
-packet_buffer_get(struct client *client, char __user *data, size_t user_length)
+static int packet_buffer_get(struct client *client, struct iov_iter *to)
 {
 	struct packet_buffer *buffer = &client->buffer;
 	size_t length;
@@ -154,15 +153,15 @@ packet_buffer_get(struct client *client, char __user *data, size_t user_length)
 	length = buffer->head->length;
 
 	if (&buffer->head->data[length] < end) {
-		if (copy_to_user(data, buffer->head->data, length))
+		if (!copy_to_iter_full(buffer->head->data, length, to))
 			return -EFAULT;
 		buffer->head = (struct packet *) &buffer->head->data[length];
 	} else {
 		size_t split = end - buffer->head->data;
 
-		if (copy_to_user(data, buffer->head->data, split))
+		if (!copy_to_iter_full(buffer->head->data, split, to))
 			return -EFAULT;
-		if (copy_to_user(data + split, buffer->data, length - split))
+		if (!copy_to_iter_full(buffer->data, length - split, to))
 			return -EFAULT;
 		buffer->head = (struct packet *) &buffer->data[length - split];
 	}
@@ -332,12 +331,11 @@ nosy_poll(struct file *file, poll_table *pt)
 	return ret;
 }
 
-static ssize_t
-nosy_read(struct file *file, char __user *buffer, size_t count, loff_t *offset)
+static ssize_t nosy_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct client *client = file->private_data;
+	struct client *client = iocb->ki_filp->private_data;
 
-	return packet_buffer_get(client, buffer, count);
+	return packet_buffer_get(client, to);
 }
 
 static long
@@ -393,7 +391,7 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations nosy_ops = {
 	.owner =		THIS_MODULE,
-	.read =			nosy_read,
+	.read_iter =		nosy_read,
 	.unlocked_ioctl =	nosy_ioctl,
 	.poll =			nosy_poll,
 	.open =			nosy_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 232/437] drivers/mfd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (230 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 231/437] drivers/firewire: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 233/437] watchdog: acquirewdt: " Jens Axboe
                   ` (205 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/mfd/tps65010.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index 2b9105295f30..74272a534020 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -290,7 +290,7 @@ static int dbg_tps_open(struct inode *inode, struct file *file)
 
 static const struct file_operations debug_fops = {
 	.open		= dbg_tps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 233/437] watchdog: acquirewdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (231 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 232/437] drivers/mfd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 234/437] watchdog: advantechwdt: " Jens Axboe
                   ` (204 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/acquirewdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/acquirewdt.c b/drivers/watchdog/acquirewdt.c
index 53b04abd55b0..cdc27fc68f4a 100644
--- a/drivers/watchdog/acquirewdt.c
+++ b/drivers/watchdog/acquirewdt.c
@@ -114,9 +114,9 @@ static void acq_stop(void)
  *	/dev/watchdog handling
  */
 
-static ssize_t acq_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t acq_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -128,7 +128,7 @@ static ssize_t acq_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -219,7 +219,7 @@ static int acq_close(struct inode *inode, struct file *file)
 static const struct file_operations acq_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= acq_write,
+	.write_iter	= acq_write,
 	.unlocked_ioctl	= acq_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= acq_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 234/437] watchdog: advantechwdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (232 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 233/437] watchdog: acquirewdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 235/437] watchdog: alim1535_wdt: " Jens Axboe
                   ` (203 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/advantechwdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/advantechwdt.c b/drivers/watchdog/advantechwdt.c
index 7a0acbc3e4dd..95c1b90abedc 100644
--- a/drivers/watchdog/advantechwdt.c
+++ b/drivers/watchdog/advantechwdt.c
@@ -106,9 +106,9 @@ static int advwdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t advwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t advwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -117,7 +117,7 @@ static ssize_t advwdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					adv_expect_close = 42;
@@ -218,7 +218,7 @@ static int advwdt_close(struct inode *inode, struct file *file)
 static const struct file_operations advwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= advwdt_write,
+	.write_iter	= advwdt_write,
 	.unlocked_ioctl	= advwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= advwdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 235/437] watchdog: alim1535_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (233 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 234/437] watchdog: advantechwdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 236/437] watchdog: alim7101_wdt: " Jens Axboe
                   ` (202 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/alim1535_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/alim1535_wdt.c b/drivers/watchdog/alim1535_wdt.c
index bfb9a91ca1df..9a12706d9cdf 100644
--- a/drivers/watchdog/alim1535_wdt.c
+++ b/drivers/watchdog/alim1535_wdt.c
@@ -134,9 +134,9 @@ static int ali_settimer(int t)
  *	the next close to turn off the watchdog.
  */
 
-static ssize_t ali_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t ali_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -150,7 +150,7 @@ static ssize_t ali_write(struct file *file, const char __user *data,
 			   the magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					ali_expect_release = 42;
@@ -360,7 +360,7 @@ static int __init ali_find_watchdog(void)
 static const struct file_operations ali_fops = {
 	.owner		=	THIS_MODULE,
 	.llseek		=	no_llseek,
-	.write		=	ali_write,
+	.write_iter	=	ali_write,
 	.unlocked_ioctl =	ali_ioctl,
 	.compat_ioctl	= 	compat_ptr_ioctl,
 	.open		=	ali_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 236/437] watchdog: alim7101_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (234 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 235/437] watchdog: alim1535_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 237/437] watchdog: at91rm9200_wdt: " Jens Axboe
                   ` (201 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/alim7101_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c
index 4ff7f5afb7aa..5a85f53542d9 100644
--- a/drivers/watchdog/alim7101_wdt.c
+++ b/drivers/watchdog/alim7101_wdt.c
@@ -181,9 +181,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -196,7 +196,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -290,7 +290,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		=	THIS_MODULE,
 	.llseek		=	no_llseek,
-	.write		=	fop_write,
+	.write_iter	=	fop_write,
 	.open		=	fop_open,
 	.release	=	fop_close,
 	.unlocked_ioctl	=	fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 237/437] watchdog: at91rm9200_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (235 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 236/437] watchdog: alim7101_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 238/437] watchdog: cpu5wdt: " Jens Axboe
                   ` (200 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/at91rm9200_wdt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index 558015f08c7a..1860fbeb6e57 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -199,11 +199,10 @@ static long at91_wdt_ioctl(struct file *file,
 /*
  * Pat the watchdog whenever device is written to.
  */
-static ssize_t at91_wdt_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t at91_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	at91_wdt_reload();		/* pat the watchdog */
-	return len;
+	return iov_iter_count(from);
 }
 
 /* ......................................................................... */
@@ -215,7 +214,7 @@ static const struct file_operations at91wdt_fops = {
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= at91_wdt_open,
 	.release	= at91_wdt_close,
-	.write		= at91_wdt_write,
+	.write_iter	= at91_wdt_write,
 };
 
 static struct miscdevice at91wdt_miscdev = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 238/437] watchdog: cpu5wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (236 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 237/437] watchdog: at91rm9200_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 239/437] watchdog: eurotechwdt: " Jens Axboe
                   ` (199 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/cpu5wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/cpu5wdt.c b/drivers/watchdog/cpu5wdt.c
index 688b112e712b..cef1d6ba6ecf 100644
--- a/drivers/watchdog/cpu5wdt.c
+++ b/drivers/watchdog/cpu5wdt.c
@@ -174,9 +174,9 @@ static long cpu5wdt_ioctl(struct file *file, unsigned int cmd,
 	return 0;
 }
 
-static ssize_t cpu5wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t cpu5wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 	cpu5wdt_reset();
@@ -189,7 +189,7 @@ static const struct file_operations cpu5wdt_fops = {
 	.unlocked_ioctl	= cpu5wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= cpu5wdt_open,
-	.write		= cpu5wdt_write,
+	.write_iter	= cpu5wdt_write,
 	.release	= cpu5wdt_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 239/437] watchdog: eurotechwdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (237 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 238/437] watchdog: cpu5wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 240/437] watchdog: geodewdt: " Jens Axboe
                   ` (198 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/eurotechwdt.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/eurotechwdt.c b/drivers/watchdog/eurotechwdt.c
index e26609ad4c17..e11b4acfa8ed 100644
--- a/drivers/watchdog/eurotechwdt.c
+++ b/drivers/watchdog/eurotechwdt.c
@@ -186,18 +186,16 @@ static void eurwdt_ping(void)
 
 /**
  * eurwdt_write:
- * @file: file handle to the watchdog
- * @buf: buffer to write (unused as data does not matter here
- * @count: count of bytes
- * @ppos: pointer to the position to write. No seeks allowed
+ * @iocb: metadata for IO
+ * @from: buffer to write (unused as data does not matter here
  *
  * A write to a watchdog device is defined as a keepalive signal. Any
  * write of data will do, as we don't define content meaning.
  */
 
-static ssize_t eurwdt_write(struct file *file, const char __user *buf,
-size_t count, loff_t *ppos)
+static ssize_t eurwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -206,7 +204,7 @@ size_t count, loff_t *ppos)
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					eur_expect_close = 42;
@@ -369,7 +367,7 @@ static int eurwdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations eurwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= eurwdt_write,
+	.write_iter	= eurwdt_write,
 	.unlocked_ioctl	= eurwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= eurwdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 240/437] watchdog: geodewdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (238 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 239/437] watchdog: eurotechwdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 241/437] watchdog: ib700wdt: " Jens Axboe
                   ` (197 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/geodewdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/geodewdt.c b/drivers/watchdog/geodewdt.c
index 5186c37ad451..2a0c904536d9 100644
--- a/drivers/watchdog/geodewdt.c
+++ b/drivers/watchdog/geodewdt.c
@@ -108,9 +108,9 @@ static int geodewdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t geodewdt_write(struct file *file, const char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t geodewdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -119,7 +119,7 @@ static ssize_t geodewdt_write(struct file *file, const char __user *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 
 				if (c == 'V')
@@ -197,7 +197,7 @@ static long geodewdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations geodewdt_fops = {
 	.owner          = THIS_MODULE,
 	.llseek         = no_llseek,
-	.write          = geodewdt_write,
+	.write_iter     = geodewdt_write,
 	.unlocked_ioctl = geodewdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open           = geodewdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 241/437] watchdog: ib700wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (239 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 240/437] watchdog: geodewdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 242/437] watchdog: ibmasr: " Jens Axboe
                   ` (196 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/ib700wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c
index 39ea97009abd..e5daeed9cd5c 100644
--- a/drivers/watchdog/ib700wdt.c
+++ b/drivers/watchdog/ib700wdt.c
@@ -141,9 +141,9 @@ static int ibwdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t ibwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t ibwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -153,7 +153,7 @@ static ssize_t ibwdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -257,7 +257,7 @@ static int ibwdt_close(struct inode *inode, struct file *file)
 static const struct file_operations ibwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= ibwdt_write,
+	.write_iter	= ibwdt_write,
 	.unlocked_ioctl	= ibwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= ibwdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 242/437] watchdog: ibmasr: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (240 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 241/437] watchdog: ib700wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 243/437] watchdog: it8712f_wdt: " Jens Axboe
                   ` (195 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/ibmasr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/ibmasr.c b/drivers/watchdog/ibmasr.c
index 6955c693b5fd..6f0931f33a6d 100644
--- a/drivers/watchdog/ibmasr.c
+++ b/drivers/watchdog/ibmasr.c
@@ -243,9 +243,9 @@ static int __init asr_get_base_address(void)
 }
 
 
-static ssize_t asr_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t asr_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -255,7 +255,7 @@ static ssize_t asr_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					asr_expect_close = 42;
@@ -341,7 +341,7 @@ static int asr_release(struct inode *inode, struct file *file)
 static const struct file_operations asr_fops = {
 	.owner =		THIS_MODULE,
 	.llseek =		no_llseek,
-	.write =		asr_write,
+	.write_iter =		asr_write,
 	.unlocked_ioctl =	asr_ioctl,
 	.compat_ioctl =		compat_ptr_ioctl,
 	.open =			asr_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 243/437] watchdog: it8712f_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (241 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 242/437] watchdog: ibmasr: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 244/437] watchdog: machzwd: " Jens Axboe
                   ` (194 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/it8712f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
index 3ce6a58bd81e..897f312eb5c9 100644
--- a/drivers/watchdog/it8712f_wdt.c
+++ b/drivers/watchdog/it8712f_wdt.c
@@ -228,9 +228,9 @@ static struct notifier_block it8712f_wdt_notifier = {
 	.notifier_call = it8712f_wdt_notify,
 };
 
-static ssize_t it8712f_wdt_write(struct file *file, const char __user *data,
-					size_t len, loff_t *ppos)
+static ssize_t it8712f_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* check for a magic close character */
 	if (len) {
 		size_t i;
@@ -240,7 +240,7 @@ static ssize_t it8712f_wdt_write(struct file *file, const char __user *data,
 		expect_close = 0;
 		for (i = 0; i < len; ++i) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -342,7 +342,7 @@ static int it8712f_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations it8712f_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = it8712f_wdt_write,
+	.write_iter = it8712f_wdt_write,
 	.unlocked_ioctl = it8712f_wdt_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open = it8712f_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 244/437] watchdog: machzwd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (242 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 243/437] watchdog: it8712f_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 245/437] watchdog: mei_wdt: " Jens Axboe
                   ` (193 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/machzwd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c
index 73f2221f6222..c36a0a441c2c 100644
--- a/drivers/watchdog/machzwd.c
+++ b/drivers/watchdog/machzwd.c
@@ -262,9 +262,9 @@ static void zf_ping(struct timer_list *unused)
 		pr_crit("I will reset your machine\n");
 }
 
-static ssize_t zf_write(struct file *file, const char __user *buf, size_t count,
-								loff_t *ppos)
+static ssize_t zf_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character */
 	if (count) {
 		/*
@@ -282,7 +282,7 @@ static ssize_t zf_write(struct file *file, const char __user *buf, size_t count,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V') {
 					zf_expect_close = 42;
@@ -360,7 +360,7 @@ static int zf_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations zf_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= zf_write,
+	.write_iter	= zf_write,
 	.unlocked_ioctl = zf_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= zf_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 245/437] watchdog: mei_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (243 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 244/437] watchdog: machzwd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 246/437] watchdog: nv_tco: " Jens Axboe
                   ` (192 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/mei_wdt.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c
index c7a7235e6224..c930fb5b8fe1 100644
--- a/drivers/watchdog/mei_wdt.c
+++ b/drivers/watchdog/mei_wdt.c
@@ -491,10 +491,9 @@ static void mei_wdt_notif(struct mei_cl_device *cldev)
 
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 
-static ssize_t mei_dbgfs_read_activation(struct file *file, char __user *ubuf,
-					size_t cnt, loff_t *ppos)
+static ssize_t mei_dbgfs_read_activation(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mei_wdt *wdt = file->private_data;
+	struct mei_wdt *wdt = iocb->ki_filp->private_data;
 	const size_t bufsz = 32;
 	char buf[32];
 	ssize_t pos;
@@ -504,31 +503,30 @@ static ssize_t mei_dbgfs_read_activation(struct file *file, char __user *ubuf,
 		__mei_wdt_is_registered(wdt) ? "activated" : "deactivated");
 	mutex_unlock(&wdt->reg_lock);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static const struct file_operations dbgfs_fops_activation = {
 	.open    = simple_open,
-	.read    = mei_dbgfs_read_activation,
+	.read_iter = mei_dbgfs_read_activation,
 	.llseek  = generic_file_llseek,
 };
 
-static ssize_t mei_dbgfs_read_state(struct file *file, char __user *ubuf,
-				    size_t cnt, loff_t *ppos)
+static ssize_t mei_dbgfs_read_state(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mei_wdt *wdt = file->private_data;
+	struct mei_wdt *wdt = iocb->ki_filp->private_data;
 	char buf[32];
 	ssize_t pos;
 
 	pos = scnprintf(buf, sizeof(buf), "state: %s\n",
 			mei_wdt_state_str(wdt->state));
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static const struct file_operations dbgfs_fops_state = {
 	.open = simple_open,
-	.read = mei_dbgfs_read_state,
+	.read_iter = mei_dbgfs_read_state,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 246/437] watchdog: nv_tco: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (244 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 245/437] watchdog: mei_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 247/437] watchdog: pc87413_wdt: " Jens Axboe
                   ` (191 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/nv_tco.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/nv_tco.c b/drivers/watchdog/nv_tco.c
index ac4a9c16341d..e9535ba7eba7 100644
--- a/drivers/watchdog/nv_tco.c
+++ b/drivers/watchdog/nv_tco.c
@@ -174,9 +174,9 @@ static int nv_tco_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t nv_tco_write(struct file *file, const char __user *data,
-			    size_t len, loff_t *ppos)
+static ssize_t nv_tco_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -194,7 +194,7 @@ static ssize_t nv_tco_write(struct file *file, const char __user *data,
 			 */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					tco_expect_close = 42;
@@ -265,7 +265,7 @@ static long nv_tco_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations nv_tco_fops = {
 	.owner =		THIS_MODULE,
 	.llseek =		no_llseek,
-	.write =		nv_tco_write,
+	.write_iter =		nv_tco_write,
 	.unlocked_ioctl =	nv_tco_ioctl,
 	.compat_ioctl =		compat_ptr_ioctl,
 	.open =			nv_tco_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 247/437] watchdog: pc87413_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (245 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 246/437] watchdog: nv_tco: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 248/437] watchdog: pcwd_pci: " Jens Axboe
                   ` (190 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/pc87413_wdt.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c
index c7f745caf203..7ccc5aa4bd25 100644
--- a/drivers/watchdog/pc87413_wdt.c
+++ b/drivers/watchdog/pc87413_wdt.c
@@ -327,18 +327,16 @@ static int pc87413_status(void)
 
 /**
  *	pc87413_write:
- *	@file: file handle to the watchdog
- *	@data: data buffer to write
- *	@len: length in bytes
- *	@ppos: pointer to the position to write. No seeks allowed
+ *	@iocb: metadata for IO
+ *	@from: data buffer to write
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t pc87413_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pc87413_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -351,7 +349,7 @@ static ssize_t pc87413_write(struct file *file, const char __user *data,
 			   magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -471,7 +469,7 @@ static int pc87413_notify_sys(struct notifier_block *this,
 static const struct file_operations pc87413_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= pc87413_write,
+	.write_iter	= pc87413_write,
 	.unlocked_ioctl	= pc87413_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= pc87413_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 248/437] watchdog: pcwd_pci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (246 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 247/437] watchdog: pc87413_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 249/437] watchdog: pcwd_usb: " Jens Axboe
                   ` (189 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/pcwd_pci.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c
index 54d86fcb1837..6b7b3bd2ed83 100644
--- a/drivers/watchdog/pcwd_pci.c
+++ b/drivers/watchdog/pcwd_pci.c
@@ -431,9 +431,9 @@ static int pcipcwd_get_timeleft(int *time_left)
  *	/dev/watchdog handling
  */
 
-static ssize_t pcipcwd_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pcipcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -447,7 +447,7 @@ static ssize_t pcipcwd_write(struct file *file, const char __user *data,
 			 * magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_release = 42;
@@ -597,15 +597,14 @@ static int pcipcwd_release(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t pcipcwd_temp_read(struct file *file, char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t pcipcwd_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (pcipcwd_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(data, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -644,7 +643,7 @@ static int pcipcwd_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations pcipcwd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.write =	pcipcwd_write,
+	.write_iter =	pcipcwd_write,
 	.unlocked_ioctl = pcipcwd_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open =		pcipcwd_open,
@@ -660,7 +659,7 @@ static struct miscdevice pcipcwd_miscdev = {
 static const struct file_operations pcipcwd_temp_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		pcipcwd_temp_read,
+	.read_iter =	pcipcwd_temp_read,
 	.open =		pcipcwd_temp_open,
 	.release =	pcipcwd_temp_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 249/437] watchdog: pcwd_usb: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (247 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 248/437] watchdog: pcwd_pci: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 250/437] watchdog: rdc321x_wdt: " Jens Axboe
                   ` (188 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/pcwd_usb.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index 8202f0a6b093..5fd830c0fdf3 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -358,9 +358,9 @@ static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd,
  *	/dev/watchdog handling
  */
 
-static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t usb_pcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -374,7 +374,7 @@ static ssize_t usb_pcwd_write(struct file *file, const char __user *data,
 			 * magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_release = 42;
@@ -506,15 +506,15 @@ static int usb_pcwd_release(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t usb_pcwd_temperature_read(struct file *file, char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t usb_pcwd_temperature_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
 	int temperature;
 
 	if (usb_pcwd_get_temperature(usb_pcwd_device, &temperature))
 		return -EFAULT;
 
-	if (copy_to_user(data, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -550,7 +550,7 @@ static int usb_pcwd_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations usb_pcwd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.write =	usb_pcwd_write,
+	.write_iter =	usb_pcwd_write,
 	.unlocked_ioctl = usb_pcwd_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.open =		usb_pcwd_open,
@@ -566,7 +566,7 @@ static struct miscdevice usb_pcwd_miscdev = {
 static const struct file_operations usb_pcwd_temperature_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		usb_pcwd_temperature_read,
+	.read_iter =	usb_pcwd_temperature_read,
 	.open =		usb_pcwd_temperature_open,
 	.release =	usb_pcwd_temperature_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 250/437] watchdog: rdc321x_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (248 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 249/437] watchdog: pcwd_usb: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 251/437] watchdog: sa1100_wdt: " Jens Axboe
                   ` (187 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/rdc321x_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
index 6176f4343fc5..de3210a342ff 100644
--- a/drivers/watchdog/rdc321x_wdt.c
+++ b/drivers/watchdog/rdc321x_wdt.c
@@ -184,9 +184,9 @@ static long rdc321x_wdt_ioctl(struct file *file, unsigned int cmd,
 	return 0;
 }
 
-static ssize_t rdc321x_wdt_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t rdc321x_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 
@@ -201,7 +201,7 @@ static const struct file_operations rdc321x_wdt_fops = {
 	.unlocked_ioctl	= rdc321x_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= rdc321x_wdt_open,
-	.write		= rdc321x_wdt_write,
+	.write_iter	= rdc321x_wdt_write,
 	.release	= rdc321x_wdt_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 251/437] watchdog: sa1100_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (249 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 250/437] watchdog: rdc321x_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 252/437] watchdog: sbc60xxwdt: " Jens Axboe
                   ` (186 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sa1100_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c
index 5d2df008b92a..f994b52565ec 100644
--- a/drivers/watchdog/sa1100_wdt.c
+++ b/drivers/watchdog/sa1100_wdt.c
@@ -98,9 +98,9 @@ static int sa1100dog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t sa1100dog_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t sa1100dog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len)
 		/* Refresh OSMR3 timer. */
 		sa1100_wr(sa1100_rd(REG_OSCR) + pre_margin, REG_OSMR3);
@@ -165,7 +165,7 @@ static long sa1100dog_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations sa1100dog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sa1100dog_write,
+	.write_iter	= sa1100dog_write,
 	.unlocked_ioctl	= sa1100dog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sa1100dog_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 252/437] watchdog: sbc60xxwdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (250 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 251/437] watchdog: sa1100_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 253/437] watchdog: sbc_epx_c3: " Jens Axboe
                   ` (185 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sbc60xxwdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
index 7b974802dfc7..ce727f42b88e 100644
--- a/drivers/watchdog/sbc60xxwdt.c
+++ b/drivers/watchdog/sbc60xxwdt.c
@@ -161,9 +161,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -177,7 +177,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -276,7 +276,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 253/437] watchdog: sbc_epx_c3: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (251 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 252/437] watchdog: sbc60xxwdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 254/437] watchdog: sbc_fitpc2_wdt: " Jens Axboe
                   ` (184 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sbc_epx_c3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/sbc_epx_c3.c b/drivers/watchdog/sbc_epx_c3.c
index 5e3a9ddb952e..6bbb9db5e57e 100644
--- a/drivers/watchdog/sbc_epx_c3.c
+++ b/drivers/watchdog/sbc_epx_c3.c
@@ -89,9 +89,9 @@ static int epx_c3_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t epx_c3_write(struct file *file, const char __user *data,
-			size_t len, loff_t *ppos)
+static ssize_t epx_c3_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* Refresh the timer. */
 	if (len)
 		epx_c3_pet();
@@ -154,7 +154,7 @@ static int epx_c3_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations epx_c3_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= epx_c3_write,
+	.write_iter	= epx_c3_write,
 	.unlocked_ioctl	= epx_c3_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= epx_c3_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 254/437] watchdog: sbc_fitpc2_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (252 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 253/437] watchdog: sbc_epx_c3: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 255/437] watchdog: sc1200wdt: " Jens Axboe
                   ` (183 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sbc_fitpc2_wdt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/sbc_fitpc2_wdt.c b/drivers/watchdog/sbc_fitpc2_wdt.c
index b8eb8d5ca1af..1619f92814cf 100644
--- a/drivers/watchdog/sbc_fitpc2_wdt.c
+++ b/drivers/watchdog/sbc_fitpc2_wdt.c
@@ -76,9 +76,9 @@ static int fitpc2_wdt_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t fitpc2_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	size_t i;
 
 	if (!len)
@@ -94,7 +94,7 @@ static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
 	for (i = 0; i != len; i++) {
 		char c;
 
-		if (get_user(c, data + i))
+		if (get_iter(c, from))
 			return -EFAULT;
 
 		if (c == 'V')
@@ -107,7 +107,6 @@ static ssize_t fitpc2_wdt_write(struct file *file, const char __user *data,
 	return len;
 }
 
-
 static const struct watchdog_info ident = {
 	.options	= WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT |
 				WDIOF_KEEPALIVEPING,
@@ -182,7 +181,7 @@ static int fitpc2_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations fitpc2_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fitpc2_wdt_write,
+	.write_iter	= fitpc2_wdt_write,
 	.unlocked_ioctl	= fitpc2_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= fitpc2_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 255/437] watchdog: sc1200wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (253 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 254/437] watchdog: sbc_fitpc2_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 256/437] watchdog: sc520_wdt: " Jens Axboe
                   ` (182 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sc1200wdt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index f22ebe89fe13..d8d8bee1d6d4 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -261,9 +261,9 @@ static int sc1200wdt_release(struct inode *inode, struct file *file)
 }
 
 
-static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t sc1200wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -273,7 +273,7 @@ static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -287,7 +287,6 @@ static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
 	return 0;
 }
 
-
 static int sc1200wdt_notify_sys(struct notifier_block *this,
 					unsigned long code, void *unused)
 {
@@ -305,7 +304,7 @@ static struct notifier_block sc1200wdt_notifier = {
 static const struct file_operations sc1200wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sc1200wdt_write,
+	.write_iter	= sc1200wdt_write,
 	.unlocked_ioctl = sc1200wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sc1200wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 256/437] watchdog: sc520_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (254 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 255/437] watchdog: sc1200wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 257/437] watchdog: sch311x_wdt: " Jens Axboe
                   ` (181 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sc520_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c
index ca65468f4b9c..a428f1e28fbd 100644
--- a/drivers/watchdog/sc520_wdt.c
+++ b/drivers/watchdog/sc520_wdt.c
@@ -215,9 +215,9 @@ static int wdt_set_heartbeat(int t)
  *	/dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -230,7 +230,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			/* now scan */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -332,7 +332,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 257/437] watchdog: sch311x_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (255 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 256/437] watchdog: sc520_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 258/437] watchdog: smsc37b787_wdt: " Jens Axboe
                   ` (180 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sch311x_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sch311x_wdt.c b/drivers/watchdog/sch311x_wdt.c
index 409d49880170..2d93a0353e79 100644
--- a/drivers/watchdog/sch311x_wdt.c
+++ b/drivers/watchdog/sch311x_wdt.c
@@ -218,9 +218,9 @@ static void sch311x_wdt_get_status(int *status)
  *	/dev/watchdog handling
  */
 
-static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t sch311x_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -229,7 +229,7 @@ static ssize_t sch311x_wdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					sch311x_wdt_expect_close = 42;
@@ -335,7 +335,7 @@ static int sch311x_wdt_close(struct inode *inode, struct file *file)
 static const struct file_operations sch311x_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sch311x_wdt_write,
+	.write_iter	= sch311x_wdt_write,
 	.unlocked_ioctl	= sch311x_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sch311x_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 258/437] watchdog: smsc37b787_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (256 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 257/437] watchdog: sch311x_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 259/437] watchdog: w83877f_wdt: " Jens Axboe
                   ` (179 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/smsc37b787_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/smsc37b787_wdt.c b/drivers/watchdog/smsc37b787_wdt.c
index 7463df479d11..e1a0c1b4ca90 100644
--- a/drivers/watchdog/smsc37b787_wdt.c
+++ b/drivers/watchdog/smsc37b787_wdt.c
@@ -386,9 +386,9 @@ static int wb_smsc_wdt_release(struct inode *inode, struct file *file)
 
 /* write => update the timer to keep the machine alive */
 
-static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t wb_smsc_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (len) {
 		if (!nowayout) {
@@ -401,7 +401,7 @@ static ssize_t wb_smsc_wdt_write(struct file *file, const char __user *data,
 			   magic character */
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -503,7 +503,7 @@ static int wb_smsc_wdt_notify_sys(struct notifier_block *this,
 static const struct file_operations wb_smsc_wdt_fops = {
 	.owner	  = THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wb_smsc_wdt_write,
+	.write_iter	= wb_smsc_wdt_write,
 	.unlocked_ioctl	= wb_smsc_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wb_smsc_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 259/437] watchdog: w83877f_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (257 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 258/437] watchdog: smsc37b787_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 260/437] watchdog: w83977f_wdt: " Jens Axboe
                   ` (178 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/w83877f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/w83877f_wdt.c b/drivers/watchdog/w83877f_wdt.c
index f2650863fd02..5c55951f9d5b 100644
--- a/drivers/watchdog/w83877f_wdt.c
+++ b/drivers/watchdog/w83877f_wdt.c
@@ -183,9 +183,9 @@ static void wdt_keepalive(void)
  * /dev/watchdog handling
  */
 
-static ssize_t fop_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -199,7 +199,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					wdt_expect_close = 42;
@@ -300,7 +300,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= fop_write,
+	.write_iter	= fop_write,
 	.open		= fop_open,
 	.release	= fop_close,
 	.unlocked_ioctl	= fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 260/437] watchdog: w83977f_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (258 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 259/437] watchdog: w83877f_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 261/437] watchdog: wafer5823wdt: " Jens Axboe
                   ` (177 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/w83977f_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/w83977f_wdt.c b/drivers/watchdog/w83977f_wdt.c
index 31bf21ceaf48..2b9a8920ac2c 100644
--- a/drivers/watchdog/w83977f_wdt.c
+++ b/drivers/watchdog/w83977f_wdt.c
@@ -324,9 +324,9 @@ static int wdt_release(struct inode *inode, struct file *file)
  *      write of data will do, as we don't define content meaning.
  */
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -340,7 +340,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf,
 			   magic character */
 			for (ofs = 0; ofs != count; ofs++) {
 				char c;
-				if (get_user(c, buf + ofs))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -444,7 +444,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt_write,
+	.write_iter	= wdt_write,
 	.unlocked_ioctl	= wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 261/437] watchdog: wafer5823wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (259 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 260/437] watchdog: w83977f_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 262/437] watchdog: watchdog_dev: " Jens Axboe
                   ` (176 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wafer5823wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/wafer5823wdt.c b/drivers/watchdog/wafer5823wdt.c
index a8a1ed215e1e..64d6317f058f 100644
--- a/drivers/watchdog/wafer5823wdt.c
+++ b/drivers/watchdog/wafer5823wdt.c
@@ -91,9 +91,9 @@ static void wafwdt_stop(void)
 	inb_p(wdt_stop);
 }
 
-static ssize_t wafwdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wafwdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	/* See if we got the magic character 'V' and reload the timer */
 	if (count) {
 		if (!nowayout) {
@@ -106,7 +106,7 @@ static ssize_t wafwdt_write(struct file *file, const char __user *buf,
 			   character */
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -228,7 +228,7 @@ static int wafwdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wafwdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wafwdt_write,
+	.write_iter	= wafwdt_write,
 	.unlocked_ioctl	= wafwdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wafwdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 262/437] watchdog: watchdog_dev: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (260 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 261/437] watchdog: wafer5823wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 263/437] watchdog: wdt_pci: " Jens Axboe
                   ` (175 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/watchdog_dev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index e2bd266b1b5b..828141d16264 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -694,10 +694,10 @@ static int watchdog_ioctl_op(struct watchdog_device *wdd, unsigned int cmd,
  *
  * Return: @len if successful, error otherwise.
  */
-static ssize_t watchdog_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct watchdog_core_data *wd_data = file->private_data;
+	struct watchdog_core_data *wd_data = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct watchdog_device *wdd;
 	int err;
 	size_t i;
@@ -714,7 +714,7 @@ static ssize_t watchdog_write(struct file *file, const char __user *data,
 
 	/* scan to see whether or not we got the magic character */
 	for (i = 0; i != len; i++) {
-		if (get_user(c, data + i))
+		if (get_iter(c, from))
 			return -EFAULT;
 		if (c == 'V')
 			set_bit(_WDOG_ALLOW_RELEASE, &wd_data->status);
@@ -991,7 +991,7 @@ static int watchdog_release(struct inode *inode, struct file *file)
 
 static const struct file_operations watchdog_fops = {
 	.owner		= THIS_MODULE,
-	.write		= watchdog_write,
+	.write_iter	= watchdog_write,
 	.unlocked_ioctl	= watchdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= watchdog_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 263/437] watchdog: wdt_pci: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (261 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 262/437] watchdog: watchdog_dev: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 264/437] watchdog: ath79_wdt: " Jens Axboe
                   ` (174 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wdt_pci.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c
index d5e56b601351..21efe34c9fd6 100644
--- a/drivers/watchdog/wdt_pci.c
+++ b/drivers/watchdog/wdt_pci.c
@@ -350,9 +350,9 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdtpci_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wdtpci_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -362,7 +362,7 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -487,24 +487,21 @@ static int wdtpci_release(struct inode *inode, struct file *file)
 
 /**
  *	wdtpci_temp_read:
- *	@file: file handle to the watchdog board
- *	@buf: buffer to write 1 byte into
- *	@count: length of buffer
- *	@ptr: offset (no seek allowed)
+ *	@iocb: metadata for IO
+ *	@to: buffer to write 1 byte into
  *
  *	Read reports the temperature in degrees Fahrenheit. The API is in
  *	fahrenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
-						size_t count, loff_t *ptr)
+static ssize_t wdtpci_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (wdtpci_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -564,7 +561,7 @@ static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdtpci_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdtpci_write,
+	.write_iter	= wdtpci_write,
 	.unlocked_ioctl	= wdtpci_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdtpci_open,
@@ -580,7 +577,7 @@ static struct miscdevice wdtpci_miscdev = {
 static const struct file_operations wdtpci_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdtpci_temp_read,
+	.read_iter	= wdtpci_temp_read,
 	.open		= wdtpci_temp_open,
 	.release	= wdtpci_temp_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 264/437] watchdog: ath79_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (262 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 263/437] watchdog: wdt_pci: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 265/437] watchdog: cpwd: " Jens Axboe
                   ` (173 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/ath79_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c
index e5cc30622b12..33320f83c190 100644
--- a/drivers/watchdog/ath79_wdt.c
+++ b/drivers/watchdog/ath79_wdt.c
@@ -146,9 +146,10 @@ static int ath79_wdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath79_wdt_write(struct file *file, const char *data,
-				size_t len, loff_t *ppos)
+static ssize_t ath79_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -158,7 +159,7 @@ static ssize_t ath79_wdt_write(struct file *file, const char *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 
 				if (c == 'V')
@@ -232,7 +233,7 @@ static long ath79_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations ath79_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= ath79_wdt_write,
+	.write_iter	= ath79_wdt_write,
 	.unlocked_ioctl	= ath79_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= ath79_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 265/437] watchdog: cpwd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (263 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 264/437] watchdog: ath79_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 266/437] watchdog: gef_wdt: " Jens Axboe
                   ` (172 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/cpwd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 901b94d456db..ca6d08107043 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -478,10 +478,10 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long
 	return cpwd_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
 }
 
-static ssize_t cpwd_write(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t cpwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct cpwd *p = cpwd_device;
 	int index = iminor(inode);
 
@@ -493,8 +493,7 @@ static ssize_t cpwd_write(struct file *file, const char __user *buf,
 	return 0;
 }
 
-static ssize_t cpwd_read(struct file *file, char __user *buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t cpwd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EINVAL;
 }
@@ -504,8 +503,8 @@ static const struct file_operations cpwd_fops = {
 	.unlocked_ioctl =	cpwd_ioctl,
 	.compat_ioctl =		cpwd_compat_ioctl,
 	.open =			cpwd_open,
-	.write =		cpwd_write,
-	.read =			cpwd_read,
+	.write_iter =		cpwd_write,
+	.read_iter =		cpwd_read,
 	.release =		cpwd_release,
 	.llseek =		no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 266/437] watchdog: gef_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (264 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 265/437] watchdog: cpwd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 267/437] watchdog: indydog: " Jens Axboe
                   ` (171 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/gef_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
index 6a1db1c783fa..c946fd169966 100644
--- a/drivers/watchdog/gef_wdt.c
+++ b/drivers/watchdog/gef_wdt.c
@@ -132,9 +132,10 @@ static void gef_wdt_set_timeout(unsigned int timeout)
 }
 
 
-static ssize_t gef_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t gef_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -143,7 +144,7 @@ static ssize_t gef_wdt_write(struct file *file, const char __user *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -246,7 +247,7 @@ static int gef_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations gef_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = gef_wdt_write,
+	.write_iter = gef_wdt_write,
 	.unlocked_ioctl = gef_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open = gef_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 267/437] watchdog: indydog: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (265 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 266/437] watchdog: gef_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 268/437] watchdog: m54xx_wdt: " Jens Axboe
                   ` (170 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/indydog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/indydog.c b/drivers/watchdog/indydog.c
index 9857bb74a723..967a95a886a4 100644
--- a/drivers/watchdog/indydog.c
+++ b/drivers/watchdog/indydog.c
@@ -86,9 +86,9 @@ static int indydog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t indydog_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t indydog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/* Refresh the timer. */
 	if (len)
 		indydog_ping();
@@ -150,7 +150,7 @@ static int indydog_notify_sys(struct notifier_block *this,
 static const struct file_operations indydog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= indydog_write,
+	.write_iter	= indydog_write,
 	.unlocked_ioctl	= indydog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= indydog_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 268/437] watchdog: m54xx_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (266 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 267/437] watchdog: indydog: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 269/437] watchdog: mixcomwd: " Jens Axboe
                   ` (169 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/m54xx_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/m54xx_wdt.c b/drivers/watchdog/m54xx_wdt.c
index 062ea3e6497e..1421e305ca12 100644
--- a/drivers/watchdog/m54xx_wdt.c
+++ b/drivers/watchdog/m54xx_wdt.c
@@ -87,9 +87,10 @@ static int m54xx_wdt_open(struct inode *inode, struct file *file)
 	return stream_open(inode, file);
 }
 
-static ssize_t m54xx_wdt_write(struct file *file, const char *data,
-						size_t len, loff_t *ppos)
+static ssize_t m54xx_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -99,7 +100,7 @@ static ssize_t m54xx_wdt_write(struct file *file, const char *data,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					set_bit(WDT_OK_TO_CLOSE, &wdt_status);
@@ -180,7 +181,7 @@ static int m54xx_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations m54xx_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= m54xx_wdt_write,
+	.write_iter	= m54xx_wdt_write,
 	.unlocked_ioctl	= m54xx_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= m54xx_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 269/437] watchdog: mixcomwd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (267 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 268/437] watchdog: m54xx_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 270/437] watchdog: mtx-1_wdt: " Jens Axboe
                   ` (168 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/mixcomwd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/mixcomwd.c b/drivers/watchdog/mixcomwd.c
index d387bad377c4..c980e542c31b 100644
--- a/drivers/watchdog/mixcomwd.c
+++ b/drivers/watchdog/mixcomwd.c
@@ -166,9 +166,10 @@ static int mixcomwd_release(struct inode *inode, struct file *file)
 }
 
 
-static ssize_t mixcomwd_write(struct file *file, const char __user *data,
-						size_t len, loff_t *ppos)
+static ssize_t mixcomwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -178,7 +179,7 @@ static ssize_t mixcomwd_write(struct file *file, const char __user *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -225,7 +226,7 @@ static long mixcomwd_ioctl(struct file *file,
 static const struct file_operations mixcomwd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= mixcomwd_write,
+	.write_iter	= mixcomwd_write,
 	.unlocked_ioctl	= mixcomwd_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mixcomwd_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 270/437] watchdog: mtx-1_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (268 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 269/437] watchdog: mixcomwd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 271/437] watchdog: pcwd: " Jens Axboe
                   ` (167 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/mtx-1_wdt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 152e41ecbb14..1d7f5154c144 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -166,9 +166,9 @@ static long mtx1_wdt_ioctl(struct file *file, unsigned int cmd,
 }
 
 
-static ssize_t mtx1_wdt_write(struct file *file, const char *buf,
-						size_t count, loff_t *ppos)
+static ssize_t mtx1_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	if (!count)
 		return -EIO;
 	mtx1_wdt_reset();
@@ -181,7 +181,7 @@ static const struct file_operations mtx1_wdt_fops = {
 	.unlocked_ioctl	= mtx1_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mtx1_wdt_open,
-	.write		= mtx1_wdt_write,
+	.write_iter	= mtx1_wdt_write,
 	.release	= mtx1_wdt_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 271/437] watchdog: pcwd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (269 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 270/437] watchdog: mtx-1_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 272/437] watchdog: pika_wdt: " Jens Axboe
                   ` (166 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/pcwd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c
index a793b03a785d..9515f87c0b9e 100644
--- a/drivers/watchdog/pcwd.c
+++ b/drivers/watchdog/pcwd.c
@@ -663,9 +663,9 @@ static long pcwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
-static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len,
-			  loff_t *ppos)
+static ssize_t pcwd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -676,7 +676,7 @@ static ssize_t pcwd_write(struct file *file, const char __user *buf, size_t len,
 			for (i = 0; i != len; i++) {
 				char c;
 
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -716,15 +716,14 @@ static int pcwd_close(struct inode *inode, struct file *file)
  *	/dev/temperature handling
  */
 
-static ssize_t pcwd_temp_read(struct file *file, char __user *buf, size_t count,
-			 loff_t *ppos)
+static ssize_t pcwd_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature;
 
 	if (pcwd_get_temperature(&temperature))
 		return -EFAULT;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -750,7 +749,7 @@ static int pcwd_temp_close(struct inode *inode, struct file *file)
 static const struct file_operations pcwd_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= pcwd_write,
+	.write_iter	= pcwd_write,
 	.unlocked_ioctl	= pcwd_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= pcwd_open,
@@ -766,7 +765,7 @@ static struct miscdevice pcwd_miscdev = {
 static const struct file_operations pcwd_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= pcwd_temp_read,
+	.read_iter	= pcwd_temp_read,
 	.open		= pcwd_temp_open,
 	.release	= pcwd_temp_close,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 272/437] watchdog: pika_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (270 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 271/437] watchdog: pcwd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 273/437] watchdog: rc32434_wdt: " Jens Axboe
                   ` (165 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/pika_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
index 782b8c23d99c..bf1ac356df69 100644
--- a/drivers/watchdog/pika_wdt.c
+++ b/drivers/watchdog/pika_wdt.c
@@ -139,9 +139,10 @@ static int pikawdt_release(struct inode *inode, struct file *file)
 /*
  * Pat the watchdog whenever device is written to.
  */
-static ssize_t pikawdt_write(struct file *file, const char __user *data,
-			     size_t len, loff_t *ppos)
+static ssize_t pikawdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	if (!len)
 		return 0;
 
@@ -153,7 +154,7 @@ static ssize_t pikawdt_write(struct file *file, const char __user *data,
 
 		for (i = 0; i < len; i++) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V') {
 				pikawdt_private.expect_close = 42;
@@ -212,7 +213,7 @@ static const struct file_operations pikawdt_fops = {
 	.llseek		= no_llseek,
 	.open		= pikawdt_open,
 	.release	= pikawdt_release,
-	.write		= pikawdt_write,
+	.write_iter	= pikawdt_write,
 	.unlocked_ioctl	= pikawdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 273/437] watchdog: rc32434_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (271 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 272/437] watchdog: pika_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 274/437] watchdog: riowd: " Jens Axboe
                   ` (164 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/rc32434_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c
index 417f9b75679c..76c046c9beb9 100644
--- a/drivers/watchdog/rc32434_wdt.c
+++ b/drivers/watchdog/rc32434_wdt.c
@@ -161,9 +161,9 @@ static int rc32434_wdt_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t rc32434_wdt_write(struct file *file, const char *data,
-				size_t len, loff_t *ppos)
+static ssize_t rc32434_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	if (len) {
 		if (!nowayout) {
 			size_t i;
@@ -173,7 +173,7 @@ static ssize_t rc32434_wdt_write(struct file *file, const char *data,
 
 			for (i = 0; i != len; i++) {
 				char c;
-				if (get_user(c, data + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -243,7 +243,7 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations rc32434_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= rc32434_wdt_write,
+	.write_iter	= rc32434_wdt_write,
 	.unlocked_ioctl	= rc32434_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= rc32434_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 274/437] watchdog: riowd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (272 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 273/437] watchdog: rc32434_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 275/437] watchdog: sb_wdog: " Jens Axboe
                   ` (163 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/riowd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index b293792a292a..d9a85b4c1de2 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -145,10 +145,10 @@ static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	return 0;
 }
 
-static ssize_t riowd_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t riowd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct riowd *p = riowd_device;
+	size_t count = iov_iter_count(from);
 
 	if (count) {
 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
@@ -164,7 +164,7 @@ static const struct file_operations riowd_fops = {
 	.unlocked_ioctl =	riowd_ioctl,
 	.compat_ioctl	=	compat_ptr_ioctl,
 	.open =			riowd_open,
-	.write =		riowd_write,
+	.write_iter =		riowd_write,
 	.release =		riowd_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 275/437] watchdog: sb_wdog: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (273 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 274/437] watchdog: riowd: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 276/437] watchdog: sbc7240_wdt: " Jens Axboe
                   ` (162 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sb_wdog.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c
index 504be461f992..cb1123b7bdbf 100644
--- a/drivers/watchdog/sb_wdog.c
+++ b/drivers/watchdog/sb_wdog.c
@@ -141,9 +141,9 @@ static int sbwdog_release(struct inode *inode, struct file *file)
 /*
  * 42 - the answer
  */
-static ssize_t sbwdog_write(struct file *file, const char __user *data,
-			size_t len, loff_t *ppos)
+static ssize_t sbwdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	int i;
 
 	if (len) {
@@ -155,7 +155,7 @@ static ssize_t sbwdog_write(struct file *file, const char __user *data,
 		for (i = 0; i != len; i++) {
 			char c;
 
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -235,7 +235,7 @@ static int sbwdog_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations sbwdog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= sbwdog_write,
+	.write_iter	= sbwdog_write,
 	.unlocked_ioctl	= sbwdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= sbwdog_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 276/437] watchdog: sbc7240_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (274 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 275/437] watchdog: sb_wdog: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 277/437] watchdog: sbc8360: " Jens Axboe
                   ` (161 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sbc7240_wdt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sbc7240_wdt.c b/drivers/watchdog/sbc7240_wdt.c
index d640b26e18a6..3e31a047bb91 100644
--- a/drivers/watchdog/sbc7240_wdt.c
+++ b/drivers/watchdog/sbc7240_wdt.c
@@ -91,9 +91,9 @@ static inline void wdt_keepalive(void)
 /*
  * /dev/watchdog handling
  */
-static ssize_t fop_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t fop_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t i;
 	char c;
 
@@ -104,7 +104,7 @@ static ssize_t fop_write(struct file *file, const char __user *buf,
 
 			/* is there a magic char ? */
 			for (i = 0; i != count; i++) {
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == SBC7240_MAGIC_CHAR) {
 					set_bit(SBC7240_EXPECT_CLOSE_STATUS_BIT,
@@ -206,7 +206,7 @@ static long fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = fop_write,
+	.write_iter = fop_write,
 	.open = fop_open,
 	.release = fop_close,
 	.unlocked_ioctl = fop_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 277/437] watchdog: sbc8360: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (275 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 276/437] watchdog: sbc7240_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 278/437] watchdog: scx200_wdt: " Jens Axboe
                   ` (160 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/sbc8360.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/sbc8360.c b/drivers/watchdog/sbc8360.c
index 4f8b9912fc51..5d7042c85988 100644
--- a/drivers/watchdog/sbc8360.c
+++ b/drivers/watchdog/sbc8360.c
@@ -234,9 +234,10 @@ static void sbc8360_stop(void)
 }
 
 /* Userspace pings kernel driver, or requests clean close */
-static ssize_t sbc8360_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t sbc8360_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -246,7 +247,7 @@ static ssize_t sbc8360_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -302,7 +303,7 @@ static int sbc8360_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations sbc8360_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = sbc8360_write,
+	.write_iter = sbc8360_write,
 	.open = sbc8360_open,
 	.release = sbc8360_close,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 278/437] watchdog: scx200_wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (276 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 277/437] watchdog: sbc8360: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:16 ` [PATCH 279/437] watchdog: wdrtas: " Jens Axboe
                   ` (159 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/scx200_wdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/scx200_wdt.c b/drivers/watchdog/scx200_wdt.c
index 7b5e18323f3f..a9b6a4734805 100644
--- a/drivers/watchdog/scx200_wdt.c
+++ b/drivers/watchdog/scx200_wdt.c
@@ -128,9 +128,10 @@ static struct notifier_block scx200_wdt_notifier = {
 	.notifier_call = scx200_wdt_notify_sys,
 };
 
-static ssize_t scx200_wdt_write(struct file *file, const char __user *data,
-				     size_t len, loff_t *ppos)
+static ssize_t scx200_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	/* check for a magic close character */
 	if (len) {
 		size_t i;
@@ -140,7 +141,7 @@ static ssize_t scx200_wdt_write(struct file *file, const char __user *data,
 		expect_close = 0;
 		for (i = 0; i < len; ++i) {
 			char c;
-			if (get_user(c, data + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			if (c == 'V')
 				expect_close = 42;
@@ -199,7 +200,7 @@ static long scx200_wdt_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations scx200_wdt_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
-	.write = scx200_wdt_write,
+	.write_iter = scx200_wdt_write,
 	.unlocked_ioctl = scx200_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open = scx200_wdt_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 279/437] watchdog: wdrtas: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (277 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 278/437] watchdog: scx200_wdt: " Jens Axboe
@ 2024-04-11 15:16 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 280/437] watchdog: wdt: " Jens Axboe
                   ` (158 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wdrtas.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c
index c00627825de8..591e5dcc8383 100644
--- a/drivers/watchdog/wdrtas.c
+++ b/drivers/watchdog/wdrtas.c
@@ -231,9 +231,9 @@ static int wdrtas_get_boot_status(void)
  * character 'V'. This character allows the watchdog device to be closed
  * properly.
  */
-static ssize_t wdrtas_write(struct file *file, const char __user *buf,
-	     size_t len, loff_t *ppos)
+static ssize_t wdrtas_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	int i;
 	char c;
 
@@ -244,7 +244,7 @@ static ssize_t wdrtas_write(struct file *file, const char __user *buf,
 		wdrtas_expect_close = 0;
 		/* look for 'V' */
 		for (i = 0; i < len; i++) {
-			if (get_user(c, buf + i))
+			if (get_iter(c, from))
 				return -EFAULT;
 			/* allow to close device */
 			if (c == 'V')
@@ -392,10 +392,8 @@ static int wdrtas_close(struct inode *inode, struct file *file)
 
 /**
  * wdrtas_temp_read - gives back the temperature in fahrenheit
- * @file: file structure
- * @buf: user buffer
- * @count: number of bytes to be read
- * @ppos: position in file
+ * @iocb: metadata for IO
+ * @to: user buffer
  *
  * returns always 1 or -EFAULT in case of user space copy failures, <0 on
  * other failures
@@ -403,8 +401,7 @@ static int wdrtas_close(struct inode *inode, struct file *file)
  * wdrtas_temp_read gives the temperature to the users by copying this
  * value as one byte into the user space buffer. The unit is Fahrenheit...
  */
-static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
-		 size_t count, loff_t *ppos)
+static ssize_t wdrtas_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature = 0;
 
@@ -412,7 +409,7 @@ static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
 	if (temperature < 0)
 		return temperature;
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -470,7 +467,7 @@ static int wdrtas_reboot(struct notifier_block *this,
 static const struct file_operations wdrtas_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdrtas_write,
+	.write_iter	= wdrtas_write,
 	.unlocked_ioctl	= wdrtas_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdrtas_open,
@@ -486,7 +483,7 @@ static struct miscdevice wdrtas_miscdev = {
 static const struct file_operations wdrtas_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdrtas_temp_read,
+	.read_iter	= wdrtas_temp_read,
 	.open		= wdrtas_temp_open,
 	.release	= wdrtas_temp_close,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 280/437] watchdog: wdt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (278 preceding siblings ...)
  2024-04-11 15:16 ` [PATCH 279/437] watchdog: wdrtas: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 281/437] watchdog: wdt285: " Jens Axboe
                   ` (157 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wdt.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/watchdog/wdt.c b/drivers/watchdog/wdt.c
index 183876156243..4f942a82271b 100644
--- a/drivers/watchdog/wdt.c
+++ b/drivers/watchdog/wdt.c
@@ -305,18 +305,17 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
 
 /**
  *	wdt_write:
- *	@file: file handle to the watchdog
- *	@buf: buffer to write (unused as data does not matter here
- *	@count: count of bytes
- *	@ppos: pointer to the position to write. No seeks allowed
+ *	@iocb: metadata for the request
+ *	@from: iov_iter to read from
  *
  *	A write to a watchdog device is defined as a keepalive signal. Any
  *	write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdt_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -326,7 +325,7 @@ static ssize_t wdt_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -447,21 +446,18 @@ static int wdt_release(struct inode *inode, struct file *file)
 
 /**
  *	wdt_temp_read:
- *	@file: file handle to the watchdog board
- *	@buf: buffer to write 1 byte into
- *	@count: length of buffer
- *	@ptr: offset (no seek allowed)
+ *	@iocb: metadata for the request
+ *	@to: iov_iter to write to
  *
  *	Temp_read reports the temperature in degrees Fahrenheit. The API is in
  *	farenheit. It was designed by an imperial measurement luddite.
  */
 
-static ssize_t wdt_temp_read(struct file *file, char __user *buf,
-						size_t count, loff_t *ptr)
+static ssize_t wdt_temp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int temperature = wdt_get_temperature();
 
-	if (copy_to_user(buf, &temperature, 1))
+	if (!copy_to_iter_full(&temperature, 1, to))
 		return -EFAULT;
 
 	return 1;
@@ -521,7 +517,7 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt_write,
+	.write_iter	= wdt_write,
 	.unlocked_ioctl	= wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt_open,
@@ -537,7 +533,7 @@ static struct miscdevice wdt_miscdev = {
 static const struct file_operations wdt_temp_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= wdt_temp_read,
+	.read_iter	= wdt_temp_read,
 	.open		= wdt_temp_open,
 	.release	= wdt_temp_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 281/437] watchdog: wdt285: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (279 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 280/437] watchdog: wdt: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 282/437] watchdog: wdt977: " Jens Axboe
                   ` (156 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wdt285.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/wdt285.c b/drivers/watchdog/wdt285.c
index 5b7be7a62d54..eee5aada2ddd 100644
--- a/drivers/watchdog/wdt285.c
+++ b/drivers/watchdog/wdt285.c
@@ -114,9 +114,10 @@ static int watchdog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t watchdog_write(struct file *file, const char __user *data,
-			      size_t len, loff_t *ppos)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
+
 	/*
 	 *	Refresh the timer.
 	 */
@@ -179,7 +180,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
 static const struct file_operations watchdog_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= watchdog_write,
+	.write_iter	= watchdog_write,
 	.unlocked_ioctl	= watchdog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= watchdog_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 282/437] watchdog: wdt977: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (280 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 281/437] watchdog: wdt285: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 283/437] fs/binfmt_misc: " Jens Axboe
                   ` (155 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/watchdog/wdt977.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/wdt977.c b/drivers/watchdog/wdt977.c
index c9b8e863f70f..e50a7374ceb1 100644
--- a/drivers/watchdog/wdt977.c
+++ b/drivers/watchdog/wdt977.c
@@ -301,9 +301,10 @@ static int wdt977_release(struct inode *inode, struct file *file)
  *      write of data will do, as we we don't define content meaning.
  */
 
-static ssize_t wdt977_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t wdt977_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
+
 	if (count) {
 		if (!nowayout) {
 			size_t i;
@@ -313,7 +314,7 @@ static ssize_t wdt977_write(struct file *file, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					expect_close = 42;
@@ -420,7 +421,7 @@ static int wdt977_notify_sys(struct notifier_block *this, unsigned long code,
 static const struct file_operations wdt977_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= wdt977_write,
+	.write_iter	= wdt977_write,
 	.unlocked_ioctl	= wdt977_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= wdt977_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 283/437] fs/binfmt_misc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (281 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 282/437] watchdog: wdt977: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 284/437] fs/coda: " Jens Axboe
                   ` (154 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/binfmt_misc.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 68fa225f89e5..f44b626c4df7 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -734,10 +734,9 @@ static void remove_binfmt_handler(struct binfmt_misc *misc, Node *e)
 
 /* /<entry> */
 
-static ssize_t
-bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t bm_entry_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	Node *e = file_inode(file)->i_private;
+	Node *e = file_inode(iocb->ki_filp)->i_private;
 	ssize_t res;
 	char *page;
 
@@ -747,7 +746,7 @@ bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 
 	entry_status(e, page);
 
-	res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page));
+	res = simple_copy_to_iter(page, &iocb->ki_pos, strlen(page), to);
 
 	free_page((unsigned long) page);
 	return res;
@@ -794,10 +793,11 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_entry_write);
 
 static const struct file_operations bm_entry_operations = {
-	.read		= bm_entry_read,
-	.write		= bm_entry_write,
+	.read_iter	= bm_entry_read,
+	.write_iter	= bm_entry_write_iter,
 	.llseek		= default_llseek,
 };
 
@@ -882,23 +882,23 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
 	}
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_register_write);
 
 static const struct file_operations bm_register_operations = {
-	.write		= bm_register_write,
+	.write_iter	= bm_register_write_iter,
 	.llseek		= noop_llseek,
 };
 
 /* /status */
 
-static ssize_t
-bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t bm_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct binfmt_misc *misc;
 	char *s;
 
-	misc = i_binfmt_misc(file_inode(file));
+	misc = i_binfmt_misc(file_inode(iocb->ki_filp));
 	s = misc->enabled ? "enabled\n" : "disabled\n";
-	return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
+	return simple_copy_to_iter(s, &iocb->ki_pos, strlen(s), to);
 }
 
 static ssize_t bm_status_write(struct file *file, const char __user *buffer,
@@ -944,10 +944,11 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(bm_status_write);
 
 static const struct file_operations bm_status_operations = {
-	.read		= bm_status_read,
-	.write		= bm_status_write,
+	.read_iter	= bm_status_read,
+	.write_iter	= bm_status_write_iter,
 	.llseek		= default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 284/437] fs/coda: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (282 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 283/437] fs/binfmt_misc: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 285/437] fs/nfsd: " Jens Axboe
                   ` (153 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/coda/psdev.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 3c3148588491..1c7f1c5c4941 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -196,16 +196,17 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 out:
         return(count ? count : retval);  
 }
+FOPS_WRITE_ITER_HELPER(coda_psdev_write);
 
 /*
  *	Read a message from the kernel to Venus
  */
 
-static ssize_t coda_psdev_read(struct file * file, char __user * buf, 
-			       size_t nbytes, loff_t *off)
+static ssize_t coda_psdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	DECLARE_WAITQUEUE(wait, current);
-        struct venus_comm *vcp = (struct venus_comm *) file->private_data;
+	struct venus_comm *vcp = iocb->ki_filp->private_data;
+	size_t nbytes = iov_iter_count(to);
         struct upc_req *req;
 	ssize_t retval = 0, count = 0;
 
@@ -218,7 +219,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
 	set_current_state(TASK_INTERRUPTIBLE);
 
 	while (list_empty(&vcp->vc_pending)) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			break;
 		}
@@ -248,9 +249,9 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
 		count = nbytes;
         }
 
-	if (copy_to_user(buf, req->uc_data, count))
+	if (!copy_to_iter_full(req->uc_data, count, to))
 	        retval = -EFAULT;
-        
+
 	/* If request was not a signal, enqueue and don't free */
 	if (!(req->uc_flags & CODA_REQ_ASYNC)) {
 		req->uc_flags |= CODA_REQ_READ;
@@ -344,8 +345,8 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
 
 static const struct file_operations coda_psdev_fops = {
 	.owner		= THIS_MODULE,
-	.read		= coda_psdev_read,
-	.write		= coda_psdev_write,
+	.read_iter	= coda_psdev_read,
+	.write_iter	= coda_psdev_write_iter,
 	.poll		= coda_psdev_poll,
 	.unlocked_ioctl	= coda_psdev_ioctl,
 	.open		= coda_psdev_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 285/437] fs/nfsd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (283 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 284/437] fs/coda: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 286/437] ubifs: " Jens Axboe
                   ` (152 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/nfsd/nfs4state.c |  5 +++--
 fs/nfsd/nfsctl.c    | 10 ++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 84d4093ca713..cbe82431633a 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2958,7 +2958,7 @@ static int client_opens_release(struct inode *inode, struct file *file)
 
 static const struct file_operations client_states_fops = {
 	.open		= client_states_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= client_opens_release,
 };
@@ -3011,9 +3011,10 @@ static ssize_t client_ctl_write(struct file *file, const char __user *buf,
 	drop_client(clp);
 	return 7;
 }
+FOPS_WRITE_ITER_HELPER(client_ctl_write);
 
 static const struct file_operations client_ctl_fops = {
-	.write		= client_ctl_write,
+	.write_iter	= client_ctl_write_iter,
 	.release	= simple_transaction_release,
 };
 
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index ecd18bffeebc..788194ac663d 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -118,6 +118,7 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu
 	simple_transaction_set(file, rv);
 	return size;
 }
+FOPS_WRITE_ITER_HELPER(nfsctl_transaction_write);
 
 static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
 {
@@ -132,10 +133,11 @@ static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size
 	}
 	return simple_transaction_read(file, buf, size, pos);
 }
+FOPS_READ_ITER_HELPER(nfsctl_transaction_read);
 
 static const struct file_operations transaction_ops = {
-	.write		= nfsctl_transaction_write,
-	.read		= nfsctl_transaction_read,
+	.write_iter	= nfsctl_transaction_write_iter,
+	.read_iter	= nfsctl_transaction_read_iter,
 	.release	= simple_transaction_release,
 	.llseek		= default_llseek,
 };
@@ -162,7 +164,7 @@ static int exports_nfsd_open(struct inode *inode, struct file *file)
 
 static const struct file_operations exports_nfsd_operations = {
 	.open		= exports_nfsd_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
@@ -177,7 +179,7 @@ DEFINE_SHOW_ATTRIBUTE(export_features);
 
 static const struct file_operations pool_stats_operations = {
 	.open		= nfsd_pool_stats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 286/437] ubifs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (284 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 285/437] fs/nfsd: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 287/437] cachefiles: " Jens Axboe
                   ` (151 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ubifs/debug.c | 59 ++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 2d63f57aca6f..52f93ea1ac7f 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2677,17 +2677,15 @@ static int dfs_file_open(struct inode *inode, struct file *file)
 /**
  * provide_user_output - provide output to the user reading a debugfs file.
  * @val: boolean value for the answer
- * @u: the buffer to store the answer at
- * @count: size of the buffer
- * @ppos: position in the @u output buffer
+ * @iocb: metadata for IO
+ * @to: the buffer to store the answer at
  *
  * This is a simple helper function which stores @val boolean value in the user
  * buffer when the user reads one of UBIFS debugfs files. Returns amount of
  * bytes written to @u in case of success and a negative error code in case of
  * failure.
  */
-static int provide_user_output(int val, char __user *u, size_t count,
-			       loff_t *ppos)
+static int provide_user_output(int val, struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[3];
 
@@ -2698,14 +2696,13 @@ static int provide_user_output(int val, char __user *u, size_t count,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	return simple_read_from_buffer(u, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
-			     loff_t *ppos)
+static ssize_t dfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
-	struct ubifs_info *c = file->private_data;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	struct ubifs_info *c = iocb->ki_filp->private_data;
 	struct ubifs_debug_info *d = c->dbg;
 	int val;
 
@@ -2726,26 +2723,25 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
 	else
 		return -EINVAL;
 
-	return provide_user_output(val, u, count, ppos);
+	return provide_user_output(val, iocb, to);
 }
-FOPS_READ_ITER_HELPER(dfs_file_read);
 
 /**
  * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
+ * @from: user-provided buffer with the input
  *
  * This is a helper function which interpret user input to a boolean UBIFS
  * debugfs file. Returns %0 or %1 in case of success and a negative error code
  * in case of failure.
  */
-static int interpret_user_input(const char __user *u, size_t count)
+static int interpret_user_input(struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t buf_size;
 	char buf[8];
 
 	buf_size = min_t(size_t, count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, u, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (buf[0] == '1')
@@ -2756,12 +2752,13 @@ static int interpret_user_input(const char __user *u, size_t count)
 	return -EINVAL;
 }
 
-static ssize_t dfs_file_write(struct file *file, const char __user *u,
-			      size_t count, loff_t *ppos)
+static ssize_t dfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	struct file *file = iocb->ki_filp;
 	struct ubifs_info *c = file->private_data;
 	struct ubifs_debug_info *d = c->dbg;
 	struct dentry *dent = file->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	int val;
 
 	if (file->f_path.dentry == d->dfs_dump_lprops) {
@@ -2779,7 +2776,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
 		return count;
 	}
 
-	val = interpret_user_input(u, count);
+	val = interpret_user_input(from);
 	if (val < 0)
 		return val;
 
@@ -2802,12 +2799,11 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
 
 	return count;
 }
-FOPS_WRITE_ITER_HELPER(dfs_file_write);
 
 static const struct file_operations dfs_fops = {
 	.open = dfs_file_open,
-	.read_iter = dfs_file_read_iter,
-	.write_iter = dfs_file_write_iter,
+	.read_iter = dfs_file_read,
+	.write_iter = dfs_file_write,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 };
@@ -2898,10 +2894,9 @@ static struct dentry *dfs_chk_lprops;
 static struct dentry *dfs_chk_fs;
 static struct dentry *dfs_tst_rcvry;
 
-static ssize_t dfs_global_file_read(struct file *file, char __user *u,
-				    size_t count, loff_t *ppos)
+static ssize_t dfs_global_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *dent = file->f_path.dentry;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
 	int val;
 
 	if (dent == dfs_chk_gen)
@@ -2919,16 +2914,16 @@ static ssize_t dfs_global_file_read(struct file *file, char __user *u,
 	else
 		return -EINVAL;
 
-	return provide_user_output(val, u, count, ppos);
+	return provide_user_output(val, iocb, to);
 }
 
-static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
-				     size_t count, loff_t *ppos)
+static ssize_t dfs_global_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dentry *dent = file->f_path.dentry;
+	struct dentry *dent = iocb->ki_filp->f_path.dentry;
+	size_t count = iov_iter_count(from);
 	int val;
 
-	val = interpret_user_input(u, count);
+	val = interpret_user_input(from);
 	if (val < 0)
 		return val;
 
@@ -2951,8 +2946,8 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
 }
 
 static const struct file_operations dfs_global_fops = {
-	.read = dfs_global_file_read,
-	.write = dfs_global_file_write,
+	.read_iter = dfs_global_file_read,
+	.write_iter = dfs_global_file_write,
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 287/437] cachefiles: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (285 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 286/437] ubifs: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 288/437] fs/xfs: " Jens Axboe
                   ` (150 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/cachefiles/daemon.c   | 35 ++++++++++++++++-------------------
 fs/cachefiles/internal.h |  4 ++--
 fs/cachefiles/ondemand.c |  5 +++--
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 6465e2574230..4a6a31a76d35 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -23,10 +23,8 @@
 
 static int cachefiles_daemon_open(struct inode *, struct file *);
 static int cachefiles_daemon_release(struct inode *, struct file *);
-static ssize_t cachefiles_daemon_read(struct file *, char __user *, size_t,
-				      loff_t *);
-static ssize_t cachefiles_daemon_write(struct file *, const char __user *,
-				       size_t, loff_t *);
+static ssize_t cachefiles_daemon_read(struct kiocb *, struct iov_iter *);
+static ssize_t cachefiles_daemon_write(struct kiocb *, struct iov_iter *);
 static __poll_t cachefiles_daemon_poll(struct file *,
 					   struct poll_table_struct *);
 static int cachefiles_daemon_frun(struct cachefiles_cache *, char *);
@@ -50,8 +48,8 @@ const struct file_operations cachefiles_daemon_fops = {
 	.owner		= THIS_MODULE,
 	.open		= cachefiles_daemon_open,
 	.release	= cachefiles_daemon_release,
-	.read		= cachefiles_daemon_read,
-	.write		= cachefiles_daemon_write,
+	.read_iter	= cachefiles_daemon_read,
+	.write_iter	= cachefiles_daemon_write,
 	.poll		= cachefiles_daemon_poll,
 	.llseek		= noop_llseek,
 };
@@ -207,8 +205,9 @@ static int cachefiles_daemon_release(struct inode *inode, struct file *file)
 }
 
 static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
-					 char __user *_buffer, size_t buflen)
+					 struct iov_iter *to)
 {
+	size_t buflen = iov_iter_count(to);
 	unsigned long long b_released;
 	unsigned f_released;
 	char buffer[256];
@@ -245,7 +244,7 @@ static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
 	if (n > buflen)
 		return -EMSGSIZE;
 
-	if (copy_to_user(_buffer, buffer, n) != 0)
+	if (!copy_to_iter_full(buffer, n, to) != 0)
 		return -EFAULT;
 
 	return n;
@@ -254,10 +253,9 @@ static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache,
 /*
  * Read the cache state.
  */
-static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
-				      size_t buflen, loff_t *pos)
+static ssize_t cachefiles_daemon_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cachefiles_cache *cache = file->private_data;
+	struct cachefiles_cache *cache = iocb->ki_filp->private_data;
 
 	//_enter(",,%zu,", buflen);
 
@@ -265,21 +263,20 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
 		return 0;
 
 	if (cachefiles_in_ondemand_mode(cache))
-		return cachefiles_ondemand_daemon_read(cache, _buffer, buflen);
+		return cachefiles_ondemand_daemon_read(cache, to);
 	else
-		return cachefiles_do_daemon_read(cache, _buffer, buflen);
+		return cachefiles_do_daemon_read(cache, to);
 }
 
 /*
  * Take a command from cachefilesd, parse it and act on it.
  */
-static ssize_t cachefiles_daemon_write(struct file *file,
-				       const char __user *_data,
-				       size_t datalen,
-				       loff_t *pos)
+static ssize_t cachefiles_daemon_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	const struct cachefiles_daemon_cmd *cmd;
-	struct cachefiles_cache *cache = file->private_data;
+	struct cachefiles_cache *cache = iocb->ki_filp->private_data;
+	size_t datalen = iov_iter_count(from);
 	ssize_t ret;
 	char *data, *args, *cp;
 
@@ -294,7 +291,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
 		return -EOPNOTSUPP;
 
 	/* drag the command string into the kernel so we can parse it */
-	data = memdup_user_nul(_data, datalen);
+	data = iterdup_nul(from, datalen);
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index d33169f0018b..2b5565d38cb3 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -298,7 +298,7 @@ extern bool cachefiles_commit_tmpfile(struct cachefiles_cache *cache,
  */
 #ifdef CONFIG_CACHEFILES_ONDEMAND
 extern ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen);
+					struct iov_iter *to);
 
 extern int cachefiles_ondemand_copen(struct cachefiles_cache *cache,
 				     char *args);
@@ -341,7 +341,7 @@ static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *
 
 #else
 static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen)
+					struct iov_iter *to)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c
index 4ba42f1fa3b4..e27144ff2050 100644
--- a/fs/cachefiles/ondemand.c
+++ b/fs/cachefiles/ondemand.c
@@ -295,8 +295,9 @@ static struct cachefiles_req *cachefiles_ondemand_select_req(struct xa_state *xa
 }
 
 ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
-					char __user *_buffer, size_t buflen)
+					struct iov_iter *to)
 {
+	size_t buflen = iov_iter_count(to);
 	struct cachefiles_req *req;
 	struct cachefiles_msg *msg;
 	unsigned long id = 0;
@@ -345,7 +346,7 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
 	msg->msg_id = id;
 	msg->object_id = req->object->ondemand->ondemand_id;
 
-	if (copy_to_user(_buffer, msg, n) != 0) {
+	if (!copy_to_iter_full(msg, n, to) != 0) {
 		ret = -EFAULT;
 		goto err_put_fd;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 288/437] fs/xfs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (286 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 287/437] cachefiles: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 289/437] fs/bcachefs: " Jens Axboe
                   ` (149 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/xfs/scrub/stats.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/fs/xfs/scrub/stats.c b/fs/xfs/scrub/stats.c
index 42cafbed94ac..bd546b61334d 100644
--- a/fs/xfs/scrub/stats.c
+++ b/fs/xfs/scrub/stats.c
@@ -235,12 +235,10 @@ xchk_stats_merge(
 
 static ssize_t
 xchk_scrub_stats_read(
-	struct file		*file,
-	char __user		*ubuf,
-	size_t			count,
-	loff_t			*ppos)
+	struct kiocb		*iocb,
+	struct iov_iter		*to)
 {
-	struct xchk_stats	*cs = file->private_data;
+	struct xchk_stats	*cs = iocb->ki_filp->private_data;
 	char			*buf;
 	size_t			bufsize;
 	ssize_t			avail, ret;
@@ -250,7 +248,7 @@ xchk_scrub_stats_read(
 	 * do not want userspace to receive garbled text from multiple calls.
 	 * If the file position is greater than 0, return a short read.
 	 */
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
 	bufsize = xchk_stats_estimate_bufsize(cs);
@@ -265,7 +263,7 @@ xchk_scrub_stats_read(
 		goto out;
 	}
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, avail);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, avail, to);
 out:
 	kvfree(buf);
 	return ret;
@@ -273,21 +271,20 @@ xchk_scrub_stats_read(
 
 static const struct file_operations scrub_stats_fops = {
 	.open			= simple_open,
-	.read			= xchk_scrub_stats_read,
+	.read_iter		= xchk_scrub_stats_read,
 };
 
 static ssize_t
 xchk_clear_scrub_stats_write(
-	struct file		*file,
-	const char __user	*ubuf,
-	size_t			count,
-	loff_t			*ppos)
+	struct kiocb 		*iocb,
+	struct iov_iter		*from)
 {
-	struct xchk_stats	*cs = file->private_data;
+	struct xchk_stats	*cs = iocb->ki_filp->private_data;
+	size_t			count = iov_iter_count(from);
 	unsigned int		val;
 	int			ret;
 
-	ret = kstrtouint_from_user(ubuf, count, 0, &val);
+	ret = kstrtouint_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -300,7 +297,7 @@ xchk_clear_scrub_stats_write(
 
 static const struct file_operations clear_scrub_stats_fops = {
 	.open			= simple_open,
-	.write			= xchk_clear_scrub_stats_write,
+	.write_iter		= xchk_clear_scrub_stats_write,
 };
 
 /* Initialize the stats object. */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 289/437] fs/bcachefs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (287 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 288/437] fs/xfs: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 290/437] fs/ocfs2: " Jens Axboe
                   ` (148 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/bcachefs/chardev.c          | 10 +++++-----
 fs/bcachefs/debug.c            | 24 ++++++++++++++++--------
 fs/bcachefs/thread_with_file.c | 14 ++++++++------
 3 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index cbfa6459bdbc..9f27c3f4b960 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -438,10 +438,9 @@ static int bch2_data_job_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t bch2_data_job_read(struct file *file, char __user *buf,
-				  size_t len, loff_t *ppos)
+static ssize_t bch2_data_job_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bch_data_ctx *ctx = container_of(file->private_data, struct bch_data_ctx, thr);
+	struct bch_data_ctx *ctx = container_of(iocb->ki_filp->private_data, struct bch_data_ctx, thr);
 	struct bch_fs *c = ctx->c;
 	struct bch_ioctl_data_event e = {
 		.type			= BCH_DATA_EVENT_PROGRESS,
@@ -451,16 +450,17 @@ static ssize_t bch2_data_job_read(struct file *file, char __user *buf,
 		.p.sectors_done		= atomic64_read(&ctx->stats.sectors_seen),
 		.p.sectors_total	= bch2_fs_usage_read_short(c).used,
 	};
+	size_t len = iov_iter_count(to);
 
 	if (len < sizeof(e))
 		return -EINVAL;
 
-	return copy_to_user_errcode(buf, &e, sizeof(e)) ?: sizeof(e);
+	return copy_to_iter(&e, sizeof(e), to);
 }
 
 static const struct file_operations bcachefs_data_ops = {
 	.release	= bch2_data_job_release,
-	.read		= bch2_data_job_read,
+	.read_iter	= bch2_data_job_read,
 	.llseek		= no_llseek,
 };
 
diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c
index 208ce6f0fc43..9b5c7aa57fda 100644
--- a/fs/bcachefs/debug.c
+++ b/fs/bcachefs/debug.c
@@ -384,12 +384,13 @@ static ssize_t bch2_read_btree(struct file *file, char __user *buf,
 			}))) ?:
 		i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_btree);
 
 static const struct file_operations btree_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_btree,
+	.read_iter	= bch2_read_btree_iter,
 };
 
 static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
@@ -438,12 +439,13 @@ static ssize_t bch2_read_btree_formats(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_btree_formats);
 
 static const struct file_operations btree_format_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_btree_formats,
+	.read_iter	= bch2_read_btree_formats_iter,
 };
 
 static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
@@ -477,12 +479,13 @@ static ssize_t bch2_read_bfloat_failed(struct file *file, char __user *buf,
 			}))) ?:
 		i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_read_bfloat_failed);
 
 static const struct file_operations bfloat_failed_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_read_bfloat_failed,
+	.read_iter	= bch2_read_bfloat_failed_iter,
 };
 
 static void bch2_cached_btree_node_to_text(struct printbuf *out, struct bch_fs *c,
@@ -584,12 +587,13 @@ static ssize_t bch2_cached_btree_nodes_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_cached_btree_nodes_read);
 
 static const struct file_operations cached_btree_nodes_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_cached_btree_nodes_read,
+	.read_iter	= bch2_cached_btree_nodes_read_iter,
 };
 
 static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
@@ -648,12 +652,13 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_btree_transactions_read);
 
 static const struct file_operations btree_transactions_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_btree_transactions_read,
+	.read_iter	= bch2_btree_transactions_read_iter,
 };
 
 static ssize_t bch2_journal_pins_read(struct file *file, char __user *buf,
@@ -685,12 +690,13 @@ static ssize_t bch2_journal_pins_read(struct file *file, char __user *buf,
 
 	return i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_journal_pins_read);
 
 static const struct file_operations journal_pins_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_journal_pins_read,
+	.read_iter	= bch2_journal_pins_read_iter,
 };
 
 static int btree_transaction_stats_open(struct inode *inode, struct file *file)
@@ -792,12 +798,13 @@ static ssize_t btree_transaction_stats_read(struct file *file, char __user *buf,
 
 	return i->ret;
 }
+FOPS_READ_ITER_HELPER(btree_transaction_stats_read);
 
 static const struct file_operations btree_transaction_stats_op = {
 	.owner		= THIS_MODULE,
 	.open		= btree_transaction_stats_open,
 	.release	= btree_transaction_stats_release,
-	.read		= btree_transaction_stats_read,
+	.read_iter	= btree_transaction_stats_read_iter,
 };
 
 static ssize_t bch2_btree_deadlock_read(struct file *file, char __user *buf,
@@ -852,12 +859,13 @@ static ssize_t bch2_btree_deadlock_read(struct file *file, char __user *buf,
 
 	return ret ?: i->ret;
 }
+FOPS_READ_ITER_HELPER(bch2_btree_deadlock_read);
 
 static const struct file_operations btree_deadlock_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch2_dump_open,
 	.release	= bch2_dump_release,
-	.read		= bch2_btree_deadlock_read,
+	.read_iter	= bch2_btree_deadlock_read_iter,
 };
 
 void bch2_fs_debug_exit(struct bch_fs *c)
diff --git a/fs/bcachefs/thread_with_file.c b/fs/bcachefs/thread_with_file.c
index 940db15d6a93..fa6f333605da 100644
--- a/fs/bcachefs/thread_with_file.c
+++ b/fs/bcachefs/thread_with_file.c
@@ -27,11 +27,11 @@ int bch2_run_thread_with_file(struct thread_with_file *thr,
 	int ret, fd = -1;
 	unsigned fd_flags = O_CLOEXEC;
 
-	if (fops->read && fops->write)
+	if (fops->read_iter && fops->write_iter)
 		fd_flags |= O_RDWR;
-	else if (fops->read)
+	else if (fops->read_iter)
 		fd_flags |= O_RDONLY;
-	else if (fops->write)
+	else if (fops->write_iter)
 		fd_flags |= O_WRONLY;
 
 	char name[TASK_COMM_LEN];
@@ -145,6 +145,7 @@ static ssize_t thread_with_stdio_read(struct file *file, char __user *ubuf,
 
 	return copied ?: ret;
 }
+FOPS_READ_ITER_HELPER(thread_with_stdio_read);
 
 static int thread_with_stdio_release(struct inode *inode, struct file *file)
 {
@@ -211,6 +212,7 @@ static ssize_t thread_with_stdio_write(struct file *file, const char __user *ubu
 
 	return copied ?: ret;
 }
+FOPS_WRITE_ITER_HELPER(thread_with_stdio_write);
 
 static __poll_t thread_with_stdio_poll(struct file *file, struct poll_table_struct *wait)
 {
@@ -267,8 +269,8 @@ static long thread_with_stdio_ioctl(struct file *file, unsigned int cmd, unsigne
 
 static const struct file_operations thread_with_stdio_fops = {
 	.llseek		= no_llseek,
-	.read		= thread_with_stdio_read,
-	.write		= thread_with_stdio_write,
+	.read_iter	= thread_with_stdio_read_iter,
+	.write_iter	= thread_with_stdio_write_iter,
 	.poll		= thread_with_stdio_poll,
 	.flush		= thread_with_stdio_flush,
 	.release	= thread_with_stdio_release,
@@ -277,7 +279,7 @@ static const struct file_operations thread_with_stdio_fops = {
 
 static const struct file_operations thread_with_stdout_fops = {
 	.llseek		= no_llseek,
-	.read		= thread_with_stdio_read,
+	.read_iter	= thread_with_stdio_read_iter,
 	.poll		= thread_with_stdout_poll,
 	.flush		= thread_with_stdio_flush,
 	.release	= thread_with_stdio_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 290/437] fs/ocfs2: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (288 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 289/437] fs/bcachefs: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 291/437] drivers/net/wireless/marvell: " Jens Axboe
                   ` (147 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/ocfs2/cluster/netdebug.c | 11 ++++++-----
 fs/ocfs2/dlmfs/dlmfs.c      | 38 +++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
index fde10358c8ee..877955f35aef 100644
--- a/fs/ocfs2/cluster/netdebug.c
+++ b/fs/ocfs2/cluster/netdebug.c
@@ -468,17 +468,18 @@ static int o2net_debug_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t o2net_debug_read(struct file *file, char __user *buf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t o2net_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, nbytes, ppos, file->private_data,
-				       i_size_read(file->f_mapping->host));
+	struct file *file = iocb->ki_filp;
+
+	return simple_copy_to_iter(file->private_data, &iocb->ki_pos,
+				       i_size_read(file->f_mapping->host), to);
 }
 
 static const struct file_operations nodes_fops = {
 	.open		= nodes_fop_open,
 	.release	= o2net_debug_release,
-	.read		= o2net_debug_read,
+	.read_iter	= o2net_debug_read,
 	.llseek		= generic_file_llseek,
 };
 
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 7fc0e920eda7..a13b80cb11f1 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -28,6 +28,7 @@
 #include <linux/string.h>
 #include <linux/backing-dev.h>
 #include <linux/poll.h>
+#include <linux/uio.h>
 
 #include <linux/uaccess.h>
 
@@ -219,47 +220,42 @@ static __poll_t dlmfs_file_poll(struct file *file, poll_table *wait)
 	return event;
 }
 
-static ssize_t dlmfs_file_read(struct file *file,
-			       char __user *buf,
-			       size_t count,
-			       loff_t *ppos)
+static ssize_t dlmfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char lvb[DLM_LVB_LEN];
 
-	if (!user_dlm_read_lvb(file_inode(file), lvb))
+	if (!user_dlm_read_lvb(file_inode(iocb->ki_filp), lvb))
 		return 0;
 
-	return simple_read_from_buffer(buf, count, ppos, lvb, sizeof(lvb));
+	return simple_copy_to_iter(lvb, &iocb->ki_pos, sizeof(lvb), to);
 }
 
-static ssize_t dlmfs_file_write(struct file *filp,
-				const char __user *buf,
-				size_t count,
-				loff_t *ppos)
+static ssize_t dlmfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char lvb_buf[DLM_LVB_LEN];
-	int bytes_left;
-	struct inode *inode = file_inode(filp);
+	int copied;
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 
 	mlog(0, "inode %lu, count = %zu, *ppos = %llu\n",
-		inode->i_ino, count, *ppos);
+		inode->i_ino, count, iocb->ki_pos);
 
-	if (*ppos >= DLM_LVB_LEN)
+	if (iocb->ki_pos >= DLM_LVB_LEN)
 		return -ENOSPC;
 
 	/* don't write past the lvb */
-	if (count > DLM_LVB_LEN - *ppos)
-		count = DLM_LVB_LEN - *ppos;
+	if (count > DLM_LVB_LEN - iocb->ki_pos)
+		count = DLM_LVB_LEN - iocb->ki_pos;
 
 	if (!count)
 		return 0;
 
-	bytes_left = copy_from_user(lvb_buf, buf, count);
-	count -= bytes_left;
+	copied = copy_from_iter(lvb_buf, count, from);
+	count -= copied;
 	if (count)
 		user_dlm_write_lvb(inode, lvb_buf, count);
 
-	*ppos = *ppos + count;
+	iocb->ki_pos += count;
 	mlog(0, "wrote %zu bytes\n", count);
 	return count;
 }
@@ -525,8 +521,8 @@ static const struct file_operations dlmfs_file_operations = {
 	.open		= dlmfs_file_open,
 	.release	= dlmfs_file_release,
 	.poll		= dlmfs_file_poll,
-	.read		= dlmfs_file_read,
-	.write		= dlmfs_file_write,
+	.read_iter	= dlmfs_file_read,
+	.write_iter	= dlmfs_file_write,
 	.llseek		= default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 291/437] drivers/net/wireless/marvell: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (289 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 290/437] fs/ocfs2: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 292/437] fs/proc: " Jens Axboe
                   ` (146 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../net/wireless/marvell/libertas/debugfs.c   | 242 +++++++-----------
 .../net/wireless/marvell/mwifiex/debugfs.c    | 183 ++++++-------
 2 files changed, 172 insertions(+), 253 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas/debugfs.c b/drivers/net/wireless/marvell/libertas/debugfs.c
index c604613ab506..0a5a2084b0d6 100644
--- a/drivers/net/wireless/marvell/libertas/debugfs.c
+++ b/drivers/net/wireless/marvell/libertas/debugfs.c
@@ -22,18 +22,16 @@ static char *szStates[] = {
 static void lbs_debug_init(struct lbs_private *priv);
 #endif
 
-static ssize_t write_file_dummy(struct file *file, const char __user *buf,
-                                size_t count, loff_t *ppos)
+static ssize_t write_file_dummy(struct kiocb *iocb, struct iov_iter *from)
 {
         return -EINVAL;
 }
 
 static const size_t len = PAGE_SIZE;
 
-static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_dev_info(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	size_t pos = 0;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *)addr;
@@ -46,23 +44,22 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
 	pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
 				(u32) priv->regioncode);
 
-	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	res = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return res;
 }
 
-static ssize_t lbs_sleepparams_write(struct file *file,
-				const char __user *user_buf, size_t count,
-				loff_t *ppos)
+static ssize_t lbs_sleepparams_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	struct sleep_params sp;
 	int p1, p2, p3, p4, p5, p6;
 	char *buf;
 
-	buf = memdup_user_nul(user_buf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -89,10 +86,9 @@ static ssize_t lbs_sleepparams_write(struct file *file,
 	return ret;
 }
 
-static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_sleepparams_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret;
 	size_t pos = 0;
 	struct sleep_params sp;
@@ -110,23 +106,22 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
 			sp.sp_calcontrol, sp.sp_extsleepclk,
 			sp.sp_reserved);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 out_unlock:
 	free_page(addr);
 	return ret;
 }
 
-static ssize_t lbs_host_sleep_write(struct file *file,
-				const char __user *user_buf, size_t count,
-				loff_t *ppos)
+static ssize_t lbs_host_sleep_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	int host_sleep;
 	char *buf;
 
-	buf = memdup_user_nul(user_buf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -159,10 +154,9 @@ static ssize_t lbs_host_sleep_write(struct file *file,
 	return ret;
 }
 
-static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_host_sleep_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret;
 	size_t pos = 0;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -172,7 +166,7 @@ static ssize_t lbs_host_sleep_read(struct file *file, char __user *userbuf,
 
 	pos += snprintf(buf, len, "%d\n", priv->is_host_sleep_activated);
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return ret;
@@ -215,12 +209,11 @@ static void *lbs_tlv_find(uint16_t tlv_type, const uint8_t *tlv, uint16_t size)
 
 
 static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
-				  struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+				  struct kiocb *iocb, struct iov_iter *to)
 {
 	struct cmd_ds_802_11_subscribe_event *subscribed;
 	struct mrvl_ie_thresholds *got;
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret = 0;
 	size_t pos = 0;
 	char *buf;
@@ -255,7 +248,7 @@ static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
 				!!(events & event_mask));
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
  out_cmd:
 	kfree(subscribed);
@@ -267,19 +260,18 @@ static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
 
 
 static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
-				   struct file *file,
-				   const char __user *userbuf, size_t count,
-				   loff_t *ppos)
+				   struct kiocb *iocb, struct iov_iter *from)
 {
 	struct cmd_ds_802_11_subscribe_event *events;
 	struct mrvl_ie_thresholds *tlv;
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int value, freq, new_mask;
 	uint16_t curr_mask;
 	char *buf;
 	int ret;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -335,105 +327,81 @@ static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
 }
 
 
-static ssize_t lbs_lowrssi_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_lowrssi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_lowrssi_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_lowrssi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_RSSI_LOW, CMD_SUBSCRIBE_RSSI_LOW,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_lowsnr_read(struct file *file, char __user *userbuf,
-			       size_t count, loff_t *ppos)
+static ssize_t lbs_lowsnr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_lowsnr_write(struct file *file, const char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_lowsnr_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_SNR_LOW, CMD_SUBSCRIBE_SNR_LOW,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_failcount_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_failcount_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_failcount_write(struct file *file, const char __user *userbuf,
-				   size_t count, loff_t *ppos)
+static ssize_t lbs_failcount_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_FAILCOUNT, CMD_SUBSCRIBE_FAILCOUNT,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_highrssi_read(struct file *file, char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_highrssi_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_highrssi_write(struct file *file, const char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_highrssi_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_RSSI_HIGH, CMD_SUBSCRIBE_RSSI_HIGH,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_highsnr_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_highsnr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_highsnr_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_highsnr_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_SNR_HIGH, CMD_SUBSCRIBE_SNR_HIGH,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-static ssize_t lbs_bcnmiss_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t lbs_bcnmiss_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return lbs_threshold_read(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
-				  file, userbuf, count, ppos);
+				  iocb, to);
 }
 
-
-static ssize_t lbs_bcnmiss_write(struct file *file, const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t lbs_bcnmiss_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return lbs_threshold_write(TLV_TYPE_BCNMISS, CMD_SUBSCRIBE_BCNMISS,
-				   file, userbuf, count, ppos);
+				   iocb, from);
 }
 
-
-static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdmac_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -448,20 +416,19 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "MAC[0x%x] = 0x%08x\n",
 				priv->mac_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 	return ret;
 }
 
-static ssize_t lbs_rdmac_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdmac_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -470,17 +437,15 @@ static ssize_t lbs_rdmac_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrmac_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrmac_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -500,10 +465,9 @@ static ssize_t lbs_wrmac_write(struct file *file,
 	return res;
 }
 
-static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdbbp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -518,21 +482,20 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "BBP[0x%x] = 0x%08x\n",
 				priv->bbp_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 
 	return ret;
 }
 
-static ssize_t lbs_rdbbp_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdbbp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -542,17 +505,15 @@ static ssize_t lbs_rdbbp_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrbbp_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrbbp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -572,10 +533,9 @@ static ssize_t lbs_wrbbp_write(struct file *file,
 	return res;
 }
 
-static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
-				  size_t count, loff_t *ppos)
+static ssize_t lbs_rdrf_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
 	ssize_t pos = 0;
 	int ret;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -590,21 +550,20 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
 	if (!ret) {
 		pos = snprintf(buf, len, "RF[0x%x] = 0x%08x\n",
 				priv->rf_offset, val);
-		ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	free_page(addr);
 
 	return ret;
 }
 
-static ssize_t lbs_rdrf_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_rdrf_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -613,17 +572,15 @@ static ssize_t lbs_rdrf_write(struct file *file,
 	return count;
 }
 
-static ssize_t lbs_wrrf_write(struct file *file,
-				    const char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t lbs_wrrf_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct lbs_private *priv = file->private_data;
+	struct lbs_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t res;
 	u32 offset, value;
 	char *buf;
 
-	buf = memdup_user_nul(userbuf, min(count, len - 1));
+	buf = iterdup_nul(from, min(count, len - 1));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -646,8 +603,8 @@ static ssize_t lbs_wrrf_write(struct file *file,
 #define FOPS(fread, fwrite) { \
 	.owner = THIS_MODULE, \
 	.open = simple_open, \
-	.read = (fread), \
-	.write = (fwrite), \
+	.read_iter = (fread), \
+	.write_iter = (fwrite), \
 	.llseek = generic_file_llseek, \
 }
 
@@ -796,15 +753,12 @@ static int num_of_items = ARRAY_SIZE(items);
 /**
  * lbs_debugfs_read - proc read function
  *
- * @file:	file to read
- * @userbuf:	pointer to buffer
- * @count:	number of bytes to read
- * @ppos:	read data starting position
+ * @iocb:	metadata for IO
+ * @to:		iov_iter to copy to
  *
  * returns:	amount of data read or negative error code
  */
-static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
-			size_t count, loff_t *ppos)
+static ssize_t lbs_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int val = 0;
 	size_t pos = 0;
@@ -819,7 +773,7 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 
 	p = buf;
 
-	d = file->private_data;
+	d = iocb->ki_filp->private_data;
 
 	for (i = 0; i < num_of_items; i++) {
 		if (d[i].size == 1)
@@ -834,7 +788,7 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 		pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
 	}
 
-	res = simple_read_from_buffer(userbuf, count, ppos, p, pos);
+	res = simple_copy_to_iter(p, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return res;
@@ -843,28 +797,26 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
 /**
  * lbs_debugfs_write - proc write function
  *
- * @f:		file pointer
- * @buf:	pointer to data buffer
- * @cnt:	data number to write
- * @ppos:	file position
+ * @iocb:	metadata for IO
+ * @from:	iov_iter to cooy from
  *
  * returns:	amount of data written
  */
-static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
-			    size_t cnt, loff_t *ppos)
+static ssize_t lbs_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t cnt = iov_iter_count(from);
 	int r, i;
 	char *pdata;
 	char *p;
 	char *p0;
 	char *p1;
 	char *p2;
-	struct debug_data *d = f->private_data;
+	struct debug_data *d = iocb->ki_filp->private_data;
 
 	if (cnt == 0)
 		return 0;
 
-	pdata = memdup_user_nul(buf, cnt);
+	pdata = iterdup_nul(from, cnt);
 	if (IS_ERR(pdata))
 		return PTR_ERR(pdata);
 
@@ -902,8 +854,8 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
 static const struct file_operations lbs_debug_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.write = lbs_debugfs_write,
-	.read = lbs_debugfs_read,
+	.write_iter = lbs_debugfs_write,
+	.read_iter = lbs_debugfs_read,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index 9deaf59dcb62..ad94780582e2 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -58,12 +58,9 @@ static char *bss_modes[] = {
  *      - Multicast count
  *      - Multicast addresses
  */
-static ssize_t
-mwifiex_info_read(struct file *file, char __user *ubuf,
-		  size_t count, loff_t *ppos)
+static ssize_t mwifiex_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *) file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	struct net_device *netdev = priv->netdev;
 	struct netdev_hw_addr *ha;
 	struct netdev_queue *txq;
@@ -133,8 +130,8 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
 	}
 	p += sprintf(p, "\n");
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
-				      (unsigned long) p - page);
+	ret = simple_copy_to_iter((char *) page, &iocb->ki_pos,
+				      (unsigned long) p - page, to);
 
 free_and_exit:
 	free_page(page);
@@ -162,12 +159,9 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
  *      - Number of received beacons
  *      - Number of missed beacons
  */
-static ssize_t
-mwifiex_getlog_read(struct file *file, char __user *ubuf,
-		    size_t count, loff_t *ppos)
+static ssize_t mwifiex_getlog_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *) file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long page = get_zeroed_page(GFP_KERNEL);
 	char *p = (char *) page;
 	ssize_t ret;
@@ -220,8 +214,8 @@ mwifiex_getlog_read(struct file *file, char __user *ubuf,
 		     stats.bcn_miss_cnt);
 
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
-				      (unsigned long) p - page);
+	ret = simple_copy_to_iter((char *) page, &iocb->ki_pos,
+				      (unsigned long) p - page, to);
 
 free_and_exit:
 	free_page(page);
@@ -238,12 +232,9 @@ mwifiex_getlog_read(struct file *file, char __user *ubuf,
  *      - Receive packet number of each nosie_flr
  *      - Receive packet number of each signal streath
  */
-static ssize_t
-mwifiex_histogram_read(struct file *file, char __user *ubuf,
-		       size_t count, loff_t *ppos)
+static ssize_t mwifiex_histogram_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	ssize_t ret;
 	struct mwifiex_histogram_data *phist_data;
 	int i, value;
@@ -309,8 +300,8 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
 				i, value);
 	}
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, (char *)page,
-				      (unsigned long)p - page);
+	ret = simple_copy_to_iter((char *)page, &iocb->ki_pos,
+				      (unsigned long)p - page, to);
 
 free_and_exit:
 	free_page(page);
@@ -318,10 +309,9 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
 }
 
 static ssize_t
-mwifiex_histogram_write(struct file *file, const char __user *ubuf,
-			size_t count, loff_t *ppos)
+mwifiex_histogram_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 
 	if (priv && priv->hist_data)
 		mwifiex_hist_data_reset(priv);
@@ -377,12 +367,9 @@ static struct mwifiex_debug_info info;
  *      - Tx BA stream table (TID, RA)
  *      - Rx reorder table (TID, TA, Start window, Window size, Buffer)
  */
-static ssize_t
-mwifiex_debug_read(struct file *file, char __user *ubuf,
-		   size_t count, loff_t *ppos)
+static ssize_t mwifiex_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *) file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long page = get_zeroed_page(GFP_KERNEL);
 	char *p = (char *) page;
 	ssize_t ret;
@@ -396,8 +383,8 @@ mwifiex_debug_read(struct file *file, char __user *ubuf,
 
 	p += mwifiex_debug_info_to_buffer(priv, p, &info);
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
-				      (unsigned long) p - page);
+	ret = simple_copy_to_iter((char *) page, &iocb->ki_pos,
+				      (unsigned long) p - page, to);
 
 free_and_exit:
 	free_page(page);
@@ -414,14 +401,14 @@ static u32 saved_reg_type, saved_reg_offset, saved_reg_value;
  * This function can be used to write to a register.
  */
 static ssize_t
-mwifiex_regrdwr_write(struct file *file,
-		      const char __user *ubuf, size_t count, loff_t *ppos)
+mwifiex_regrdwr_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf;
 	int ret;
 	u32 reg_type = 0, reg_offset = 0, reg_value = UINT_MAX;
+	size_t count = iov_iter_count(from);
 
-	buf = memdup_user_nul(ubuf, min(count, (size_t)(PAGE_SIZE - 1)));
+	buf = iterdup_nul(from, min(count, (size_t)(PAGE_SIZE - 1)));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -451,12 +438,9 @@ mwifiex_regrdwr_write(struct file *file,
  *
  * This function can be used to read from a register.
  */
-static ssize_t
-mwifiex_regrdwr_read(struct file *file, char __user *ubuf,
-		     size_t count, loff_t *ppos)
+static ssize_t mwifiex_regrdwr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *) file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *) addr;
 	int pos = 0, ret = 0;
@@ -479,7 +463,7 @@ mwifiex_regrdwr_read(struct file *file, char __user *ubuf,
 				saved_reg_type, saved_reg_offset,
 				saved_reg_value);
 
-		ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 		goto done;
 	}
@@ -494,7 +478,7 @@ mwifiex_regrdwr_read(struct file *file, char __user *ubuf,
 	pos += snprintf(buf, PAGE_SIZE, "%u 0x%x 0x%x\n", saved_reg_type,
 			saved_reg_offset, reg_value);
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 done:
 	free_page(addr);
@@ -506,11 +490,9 @@ mwifiex_regrdwr_read(struct file *file, char __user *ubuf,
  * This function can be used read driver debugging mask value.
  */
 static ssize_t
-mwifiex_debug_mask_read(struct file *file, char __user *ubuf,
-			size_t count, loff_t *ppos)
+mwifiex_debug_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long page = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *)page;
 	size_t ret = 0;
@@ -521,7 +503,7 @@ mwifiex_debug_mask_read(struct file *file, char __user *ubuf,
 
 	pos += snprintf(buf, PAGE_SIZE, "debug mask=0x%08x\n",
 			priv->adapter->debug_mask);
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(page);
 	return ret;
@@ -532,15 +514,15 @@ mwifiex_debug_mask_read(struct file *file, char __user *ubuf,
  * This function can be used read driver debugging mask value.
  */
 static ssize_t
-mwifiex_debug_mask_write(struct file *file, const char __user *ubuf,
-			 size_t count, loff_t *ppos)
+mwifiex_debug_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	unsigned long debug_mask;
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(ubuf, min(count, (size_t)(PAGE_SIZE - 1)));
+	buf = iterdup_nul(from, min(count, (size_t)(PAGE_SIZE - 1)));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -559,15 +541,14 @@ mwifiex_debug_mask_write(struct file *file, const char __user *ubuf,
 /* debugfs verext file write handler.
  * This function is called when the 'verext' file is opened for write
  */
-static ssize_t
-mwifiex_verext_write(struct file *file, const char __user *ubuf,
-		     size_t count, loff_t *ppos)
+static ssize_t mwifiex_verext_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	u32 versionstrsel;
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
-	ret = kstrtou32_from_user(ubuf, count, 10, &versionstrsel);
+	ret = kstrtou32_from_iter(from, count, 10, &versionstrsel);
 	if (ret)
 		return ret;
 
@@ -581,11 +562,9 @@ mwifiex_verext_write(struct file *file, const char __user *ubuf,
  * This function can be used read driver exteneed verion string.
  */
 static ssize_t
-mwifiex_verext_read(struct file *file, char __user *ubuf,
-		    size_t count, loff_t *ppos)
+mwifiex_verext_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	char buf[256];
 	int ret;
 
@@ -593,25 +572,24 @@ mwifiex_verext_read(struct file *file, char __user *ubuf,
 	ret = snprintf(buf, sizeof(buf), "version string: %s\n",
 		       priv->version_str);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, ret);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 }
 
 /* Proc memrw file write handler.
  * This function is called when the 'memrw' file is opened for writing
  * This function can be used to write to a memory location.
  */
-static ssize_t
-mwifiex_memrw_write(struct file *file, const char __user *ubuf, size_t count,
-		    loff_t *ppos)
+static ssize_t mwifiex_memrw_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
 	char cmd;
 	struct mwifiex_ds_mem_rw mem_rw;
 	u16 cmd_action;
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 
-	buf = memdup_user_nul(ubuf, min(count, (size_t)(PAGE_SIZE - 1)));
+	buf = iterdup_nul(from, min(count, (size_t)(PAGE_SIZE - 1)));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -647,11 +625,9 @@ mwifiex_memrw_write(struct file *file, const char __user *ubuf, size_t count,
  * This function is called when the 'memrw' file is opened for reading
  * This function can be used to read from a memory location.
  */
-static ssize_t
-mwifiex_memrw_read(struct file *file, char __user *ubuf,
-		   size_t count, loff_t *ppos)
+static ssize_t mwifiex_memrw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *)addr;
 	int ret, pos = 0;
@@ -661,7 +637,7 @@ mwifiex_memrw_read(struct file *file, char __user *ubuf,
 
 	pos += snprintf(buf, PAGE_SIZE, "0x%x 0x%x\n", priv->mem_rw.addr,
 			priv->mem_rw.value);
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return ret;
@@ -676,15 +652,14 @@ static u32 saved_offset = -1, saved_bytes = -1;
  *
  * This function can be used to write to a RDEEPROM location.
  */
-static ssize_t
-mwifiex_rdeeprom_write(struct file *file,
-		       const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t mwifiex_rdeeprom_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *buf;
 	int ret = 0;
 	int offset = -1, bytes = -1;
+	size_t count = iov_iter_count(from);
 
-	buf = memdup_user_nul(ubuf, min(count, (size_t)(PAGE_SIZE - 1)));
+	buf = iterdup_nul(from, min(count, (size_t)(PAGE_SIZE - 1)));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -713,12 +688,9 @@ mwifiex_rdeeprom_write(struct file *file,
  *
  * This function can be used to read from a RDEEPROM location.
  */
-static ssize_t
-mwifiex_rdeeprom_read(struct file *file, char __user *ubuf,
-		      size_t count, loff_t *ppos)
+static ssize_t mwifiex_rdeeprom_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv =
-		(struct mwifiex_private *) file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *) addr;
 	int pos, ret, i;
@@ -747,7 +719,7 @@ mwifiex_rdeeprom_read(struct file *file, char __user *ubuf,
 		pos += scnprintf(buf + pos, PAGE_SIZE - pos, "%d ", value[i]);
 
 done:
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 out_free:
 	free_page(addr);
 	return ret;
@@ -756,18 +728,17 @@ mwifiex_rdeeprom_read(struct file *file, char __user *ubuf,
 /* Proc hscfg file write handler
  * This function can be used to configure the host sleep parameters.
  */
-static ssize_t
-mwifiex_hscfg_write(struct file *file, const char __user *ubuf,
-		    size_t count, loff_t *ppos)
+static ssize_t mwifiex_hscfg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int ret, arg_num;
 	struct mwifiex_ds_hs_cfg hscfg;
 	int conditions = HS_CFG_COND_DEF;
 	u32 gpio = HS_CFG_GPIO_DEF, gap = HS_CFG_GAP_DEF;
 
-	buf = memdup_user_nul(ubuf, min(count, (size_t)(PAGE_SIZE - 1)));
+	buf = iterdup_nul(from, min(count, (size_t)(PAGE_SIZE - 1)));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -815,11 +786,9 @@ mwifiex_hscfg_write(struct file *file, const char __user *ubuf,
  * This function can be used to read host sleep configuration
  * parameters from driver.
  */
-static ssize_t
-mwifiex_hscfg_read(struct file *file, char __user *ubuf,
-		   size_t count, loff_t *ppos)
+static ssize_t mwifiex_hscfg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mwifiex_private *priv = (void *)file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	unsigned long addr = get_zeroed_page(GFP_KERNEL);
 	char *buf = (char *)addr;
 	int pos, ret;
@@ -834,17 +803,16 @@ mwifiex_hscfg_read(struct file *file, char __user *ubuf,
 	pos = snprintf(buf, PAGE_SIZE, "%u 0x%x 0x%x\n", hscfg.conditions,
 		       hscfg.gpio, hscfg.gap);
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	free_page(addr);
 	return ret;
 }
 
-static ssize_t
-mwifiex_timeshare_coex_read(struct file *file, char __user *ubuf,
-			    size_t count, loff_t *ppos)
+static ssize_t mwifiex_timeshare_coex_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct mwifiex_private *priv = file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
 	char buf[3];
 	bool timeshare_coex;
 	int ret;
@@ -859,21 +827,21 @@ mwifiex_timeshare_coex_read(struct file *file, char __user *ubuf,
 		return ret;
 
 	len = sprintf(buf, "%d\n", timeshare_coex);
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t
-mwifiex_timeshare_coex_write(struct file *file, const char __user *ubuf,
-			     size_t count, loff_t *ppos)
+mwifiex_timeshare_coex_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	bool timeshare_coex;
-	struct mwifiex_private *priv = file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	if (priv->adapter->fw_api_ver != MWIFIEX_FW_V15)
 		return -EOPNOTSUPP;
 
-	ret = kstrtobool_from_user(ubuf, count, &timeshare_coex);
+	ret = kstrtobool_from_iter(from, count, &timeshare_coex);
 	if (ret)
 		return ret;
 
@@ -885,16 +853,15 @@ mwifiex_timeshare_coex_write(struct file *file, const char __user *ubuf,
 		return count;
 }
 
-static ssize_t
-mwifiex_reset_write(struct file *file,
-		    const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t mwifiex_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mwifiex_private *priv = file->private_data;
+	struct mwifiex_private *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mwifiex_adapter *adapter = priv->adapter;
 	bool result;
 	int rc;
 
-	rc = kstrtobool_from_user(ubuf, count, &result);
+	rc = kstrtobool_from_iter(from, count, &result);
 	if (rc)
 		return rc;
 
@@ -916,20 +883,20 @@ mwifiex_reset_write(struct file *file,
 
 #define MWIFIEX_DFS_FILE_OPS(name)                                      \
 static const struct file_operations mwifiex_dfs_##name##_fops = {       \
-	.read = mwifiex_##name##_read,                                  \
-	.write = mwifiex_##name##_write,                                \
+	.read_iter = mwifiex_##name##_read,                             \
+	.write_iter = mwifiex_##name##_write,                           \
 	.open = simple_open,                                            \
 };
 
 #define MWIFIEX_DFS_FILE_READ_OPS(name)                                 \
 static const struct file_operations mwifiex_dfs_##name##_fops = {       \
-	.read = mwifiex_##name##_read,                                  \
+	.read_iter = mwifiex_##name##_read,                             \
 	.open = simple_open,                                            \
 };
 
 #define MWIFIEX_DFS_FILE_WRITE_OPS(name)                                \
 static const struct file_operations mwifiex_dfs_##name##_fops = {       \
-	.write = mwifiex_##name##_write,                                \
+	.write_iter = mwifiex_##name##_write,                           \
 	.open = simple_open,                                            \
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 292/437] fs/proc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (290 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 291/437] drivers/net/wireless/marvell: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 293/437] fs: convert fs_open " Jens Axboe
                   ` (145 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/proc/base.c                 | 316 ++++++++++++++++-----------------
 fs/proc/fd.c                   |   2 +-
 fs/proc/inode.c                |  18 +-
 fs/proc/task_mmu.c             |  37 ++--
 fs/proc/task_nommu.c           |   2 +-
 include/linux/user_namespace.h |  10 +-
 kernel/user_namespace.c        |  39 ++--
 7 files changed, 214 insertions(+), 210 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 4c6a7aafe66a..d810ede0e399 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -373,9 +373,10 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
 		*pos += ret;
 	return ret;
 }
+FOPS_READ_ITER_HELPER(proc_pid_cmdline_read);
 
 static const struct file_operations proc_pid_cmdline_ops = {
-	.read	= proc_pid_cmdline_read,
+	.read_iter = proc_pid_cmdline_read_iter,
 	.llseek	= generic_file_llseek,
 };
 
@@ -525,23 +526,22 @@ static int lstats_open(struct inode *inode, struct file *file)
 	return single_open(file, lstats_show_proc, inode);
 }
 
-static ssize_t lstats_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *offs)
+static ssize_t lstats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 
 	if (!task)
 		return -ESRCH;
 	clear_tsk_latency_tracing(task);
 	put_task_struct(task);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations proc_lstats_operations = {
 	.open		= lstats_open,
-	.read		= seq_read,
-	.write		= lstats_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= lstats_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -788,7 +788,7 @@ static int proc_single_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_single_file_operations = {
 	.open		= proc_single_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -835,11 +835,11 @@ static int mem_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static ssize_t mem_rw(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos, int write)
+static ssize_t mem_rw(struct kiocb *iocb, struct iov_iter *iov, int write)
 {
-	struct mm_struct *mm = file->private_data;
-	unsigned long addr = *ppos;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(iov);
+	unsigned long addr = iocb->ki_pos;
 	ssize_t copied;
 	char *page;
 	unsigned int flags;
@@ -860,7 +860,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 	while (count > 0) {
 		size_t this_len = min_t(size_t, count, PAGE_SIZE);
 
-		if (write && copy_from_user(page, buf, this_len)) {
+		if (write && !copy_from_iter_full(page, this_len, iov)) {
 			copied = -EFAULT;
 			break;
 		}
@@ -872,17 +872,16 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (!write && copy_to_user(buf, page, this_len)) {
+		if (!write && !copy_to_iter_full(page, this_len, iov)) {
 			copied = -EFAULT;
 			break;
 		}
 
-		buf += this_len;
 		addr += this_len;
 		copied += this_len;
 		count -= this_len;
 	}
-	*ppos = addr;
+	iocb->ki_pos = addr;
 
 	mmput(mm);
 free:
@@ -890,16 +889,14 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 	return copied;
 }
 
-static ssize_t mem_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return mem_rw(file, buf, count, ppos, 0);
+	return mem_rw(iocb, to, 0);
 }
 
-static ssize_t mem_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	return mem_rw(file, (char __user*)buf, count, ppos, 1);
+	return mem_rw(iocb, from, 1);
 }
 
 loff_t mem_lseek(struct file *file, loff_t offset, int orig)
@@ -928,8 +925,8 @@ static int mem_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_mem_operations = {
 	.llseek		= mem_lseek,
-	.read		= mem_read,
-	.write		= mem_write,
+	.read_iter	= mem_read,
+	.write_iter	= mem_write,
 	.open		= mem_open,
 	.release	= mem_release,
 };
@@ -939,13 +936,13 @@ static int environ_open(struct inode *inode, struct file *file)
 	return __mem_open(inode, file, PTRACE_MODE_READ);
 }
 
-static ssize_t environ_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t environ_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	char *page;
-	unsigned long src = *ppos;
+	unsigned long src = iocb->ki_pos;
 	int ret = 0;
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
 	unsigned long env_start, env_end;
 
 	/* Ensure the process spawned far enough to have an environment. */
@@ -984,17 +981,16 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 			break;
 		}
 
-		if (copy_to_user(buf, page, retval)) {
+		if (!copy_to_iter_full(page, retval, to)) {
 			ret = -EFAULT;
 			break;
 		}
 
 		ret += retval;
 		src += retval;
-		buf += retval;
 		count -= retval;
 	}
-	*ppos = src;
+	iocb->ki_pos = src;
 	mmput(mm);
 
 free:
@@ -1004,7 +1000,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 
 static const struct file_operations proc_environ_operations = {
 	.open		= environ_open,
-	.read		= environ_read,
+	.read_iter	= environ_read,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
@@ -1014,10 +1010,9 @@ static int auxv_open(struct inode *inode, struct file *file)
 	return __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS);
 }
 
-static ssize_t auxv_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t auxv_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
 	unsigned int nwords = 0;
 
 	if (!mm)
@@ -1025,21 +1020,20 @@ static ssize_t auxv_read(struct file *file, char __user *buf,
 	do {
 		nwords += 2;
 	} while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
-	return simple_read_from_buffer(buf, count, ppos, mm->saved_auxv,
-				       nwords * sizeof(mm->saved_auxv[0]));
+	return simple_copy_to_iter(mm->saved_auxv, &iocb->ki_pos,
+				   nwords * sizeof(mm->saved_auxv[0]), to);
 }
 
 static const struct file_operations proc_auxv_operations = {
 	.open		= auxv_open,
-	.read		= auxv_read,
+	.read_iter	= auxv_read,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
 
-static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *ppos)
+static ssize_t oom_adj_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	int oom_adj = OOM_ADJUST_MIN;
 	size_t len;
@@ -1055,7 +1049,7 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
 	if (oom_adj > OOM_ADJUST_MAX)
 		oom_adj = OOM_ADJUST_MAX;
 	len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
 static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
@@ -1151,16 +1145,16 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
  *
  * oom_adj cannot be removed since existing userspace binaries use it.
  */
-static ssize_t oom_adj_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t oom_adj_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buffer[PROC_NUMBUF] = {};
 	int oom_adj;
 	int err;
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count)) {
+	if (!copy_from_iter_full(buffer, count, from)) {
 		err = -EFAULT;
 		goto out;
 	}
@@ -1183,21 +1177,20 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
 	else
 		oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
 
-	err = __set_oom_adj(file, oom_adj, true);
+	err = __set_oom_adj(iocb->ki_filp, oom_adj, true);
 out:
 	return err < 0 ? err : count;
 }
 
 static const struct file_operations proc_oom_adj_operations = {
-	.read		= oom_adj_read,
-	.write		= oom_adj_write,
+	.read_iter	= oom_adj_read,
+	.write_iter	= oom_adj_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t oom_score_adj_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	short oom_score_adj = OOM_SCORE_ADJ_MIN;
 	size_t len;
@@ -1207,19 +1200,19 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
 	oom_score_adj = task->signal->oom_score_adj;
 	put_task_struct(task);
 	len = snprintf(buffer, sizeof(buffer), "%hd\n", oom_score_adj);
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
-static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t oom_score_adj_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buffer[PROC_NUMBUF] = {};
 	int oom_score_adj;
 	int err;
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count)) {
+	if (!copy_from_iter_full(buffer, count, from)) {
 		err = -EFAULT;
 		goto out;
 	}
@@ -1233,23 +1226,22 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 		goto out;
 	}
 
-	err = __set_oom_adj(file, oom_score_adj, false);
+	err = __set_oom_adj(iocb->ki_filp, oom_score_adj, false);
 out:
 	return err < 0 ? err : count;
 }
 
 static const struct file_operations proc_oom_score_adj_operations = {
-	.read		= oom_score_adj_read,
-	.write		= oom_score_adj_write,
+	.read_iter	= oom_score_adj_read,
+	.write_iter	= oom_score_adj_write,
 	.llseek		= default_llseek,
 };
 
 #ifdef CONFIG_AUDIT
 #define TMPBUFLEN 11
-static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_loginuid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	struct task_struct *task = get_proc_task(inode);
 	ssize_t length;
 	char tmpbuf[TMPBUFLEN];
@@ -1257,16 +1249,16 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
 	if (!task)
 		return -ESRCH;
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
-			   from_kuid(file->f_cred->user_ns,
+			   from_kuid(iocb->ki_filp->f_cred->user_ns,
 				     audit_get_loginuid(task)));
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
-static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_loginuid_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	uid_t loginuid;
 	kuid_t kloginuid;
 	int rv;
@@ -1282,12 +1274,12 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 	}
 	rcu_read_unlock();
 
-	if (*ppos != 0) {
+	if (iocb->ki_pos != 0) {
 		/* No partial writes. */
 		return -EINVAL;
 	}
 
-	rv = kstrtou32_from_user(buf, count, 10, &loginuid);
+	rv = kstrtou32_from_iter(from, count, 10, &loginuid);
 	if (rv < 0)
 		return rv;
 
@@ -1295,7 +1287,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 	if (loginuid == AUDIT_UID_UNSET) {
 		kloginuid = INVALID_UID;
 	} else {
-		kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
+		kloginuid = make_kuid(iocb->ki_filp->f_cred->user_ns, loginuid);
 		if (!uid_valid(kloginuid))
 			return -EINVAL;
 	}
@@ -1307,15 +1299,14 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
 }
 
 static const struct file_operations proc_loginuid_operations = {
-	.read		= proc_loginuid_read,
-	.write		= proc_loginuid_write,
+	.read_iter	= proc_loginuid_read,
+	.write_iter	= proc_loginuid_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_sessionid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	struct task_struct *task = get_proc_task(inode);
 	ssize_t length;
 	char tmpbuf[TMPBUFLEN];
@@ -1325,20 +1316,19 @@ static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
 	length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
 				audit_get_sessionid(task));
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+	return simple_copy_to_iter(tmpbuf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations proc_sessionid_operations = {
-	.read		= proc_sessionid_read,
+	.read_iter	= proc_sessionid_read,
 	.llseek		= generic_file_llseek,
 };
 #endif
 
 #ifdef CONFIG_FAULT_INJECTION
-static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
-				      size_t count, loff_t *ppos)
+static ssize_t proc_fault_inject_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	char buffer[PROC_NUMBUF];
 	size_t len;
 	int make_it_fail;
@@ -1349,13 +1339,12 @@ static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
 	put_task_struct(task);
 
 	len = snprintf(buffer, sizeof(buffer), "%i\n", make_it_fail);
-
-	return simple_read_from_buffer(buf, count, ppos, buffer, len);
+	return simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 }
 
-static ssize_t proc_fault_inject_write(struct file * file,
-			const char __user * buf, size_t count, loff_t *ppos)
+static ssize_t proc_fault_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF] = {};
 	int make_it_fail;
@@ -1366,7 +1355,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 	rv = kstrtoint(strstrip(buffer), 0, &make_it_fail);
 	if (rv < 0)
@@ -1374,7 +1363,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
 	if (make_it_fail < 0 || make_it_fail > 1)
 		return -EINVAL;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	task->make_it_fail = make_it_fail;
@@ -1384,23 +1373,23 @@ static ssize_t proc_fault_inject_write(struct file * file,
 }
 
 static const struct file_operations proc_fault_inject_operations = {
-	.read		= proc_fault_inject_read,
-	.write		= proc_fault_inject_write,
+	.read_iter	= proc_fault_inject_read,
+	.write_iter	= proc_fault_inject_write,
 	.llseek		= generic_file_llseek,
 };
 
-static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_fail_nth_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	int err;
 	unsigned int n;
 
-	err = kstrtouint_from_user(buf, count, 0, &n);
+	err = kstrtouint_from_iter(from, count, 0, &n);
 	if (err)
 		return err;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	task->fail_nth = n;
@@ -1409,24 +1398,23 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
 	return count;
 }
 
-static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_fail_nth_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct task_struct *task;
 	char numbuf[PROC_NUMBUF];
 	ssize_t len;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth);
 	put_task_struct(task);
-	return simple_read_from_buffer(buf, count, ppos, numbuf, len);
+	return simple_copy_to_iter(numbuf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations proc_fail_nth_operations = {
-	.read		= proc_fail_nth_read,
-	.write		= proc_fail_nth_write,
+	.read_iter	= proc_fail_nth_read,
+	.write_iter	= proc_fail_nth_write,
 };
 #endif
 
@@ -1451,11 +1439,9 @@ static int sched_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t
-sched_write(struct file *file, const char __user *buf,
-	    size_t count, loff_t *offset)
+static ssize_t sched_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct task_struct *p;
 
 	p = get_proc_task(inode);
@@ -1465,7 +1451,7 @@ sched_write(struct file *file, const char __user *buf,
 
 	put_task_struct(p);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static int sched_open(struct inode *inode, struct file *filp)
@@ -1475,8 +1461,8 @@ static int sched_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_sched_operations = {
 	.open		= sched_open,
-	.read		= seq_read,
-	.write		= sched_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sched_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1502,11 +1488,10 @@ static int sched_autogroup_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t
-sched_autogroup_write(struct file *file, const char __user *buf,
-	    size_t count, loff_t *offset)
+static ssize_t sched_autogroup_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	char buffer[PROC_NUMBUF] = {};
 	int nice;
@@ -1514,7 +1499,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 
 	err = kstrtoint(strstrip(buffer), 0, &nice);
@@ -1549,8 +1534,8 @@ static int sched_autogroup_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_sched_autogroup_operations = {
 	.open		= sched_autogroup_open,
-	.read		= seq_read,
-	.write		= sched_autogroup_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= sched_autogroup_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1572,21 +1557,21 @@ static int timens_offsets_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
-				    size_t count, loff_t *ppos)
+static ssize_t timens_offsets_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct proc_timens_offset offsets[2];
 	char *kbuf = NULL, *pos, *next_line;
 	struct task_struct *p;
 	int ret, noffsets;
 
 	/* Only allow < page size writes at the beginning of the file */
-	if ((*ppos != 0) || (count >= PAGE_SIZE))
+	if ((iocb->ki_pos != 0) || (count >= PAGE_SIZE))
 		return -EINVAL;
 
 	/* Slurp in the user data */
-	kbuf = memdup_user_nul(buf, count);
+	kbuf = iterdup_nul(from, count);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
@@ -1634,7 +1619,7 @@ static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
 	p = get_proc_task(inode);
 	if (!p)
 		goto out;
-	ret = proc_timens_set_offset(file, p, offsets, noffsets);
+	ret = proc_timens_set_offset(iocb->ki_filp, p, offsets, noffsets);
 	put_task_struct(p);
 	if (ret)
 		goto out;
@@ -1652,22 +1637,22 @@ static int timens_offsets_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_timens_offsets_operations = {
 	.open		= timens_offsets_open,
-	.read		= seq_read,
-	.write		= timens_offsets_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= timens_offsets_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
 #endif /* CONFIG_TIME_NS */
 
-static ssize_t comm_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *offset)
+static ssize_t comm_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	char buffer[TASK_COMM_LEN] = {};
 	const size_t maxlen = sizeof(buffer) - 1;
 
-	if (copy_from_user(buffer, buf, count > maxlen ? maxlen : count))
+	if (!copy_from_iter_full(buffer, count > maxlen ? maxlen : count, from))
 		return -EFAULT;
 
 	p = get_proc_task(inode);
@@ -1710,8 +1695,8 @@ static int comm_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_set_comm_operations = {
 	.open		= comm_open,
-	.read		= seq_read,
-	.write		= comm_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= comm_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2530,21 +2515,21 @@ static int proc_timers_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_timers_operations = {
 	.open		= proc_timers_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release_private,
 };
 #endif
 
-static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *offset)
+static ssize_t timerslack_ns_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *p;
 	u64 slack_ns;
 	int err;
 
-	err = kstrtoull_from_user(buf, count, 10, &slack_ns);
+	err = kstrtoull_from_iter(from, count, 10, &slack_ns);
 	if (err < 0)
 		return err;
 
@@ -2622,8 +2607,8 @@ static int timerslack_ns_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations proc_pid_set_timerslack_ns_operations = {
 	.open		= timerslack_ns_open,
-	.read		= seq_read,
-	.write		= timerslack_ns_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= timerslack_ns_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2714,10 +2699,9 @@ static int proc_pid_attr_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
-				  size_t count, loff_t *ppos)
+static ssize_t proc_pid_attr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
 	char *p = NULL;
 	ssize_t length;
 	struct task_struct *task = get_proc_task(inode);
@@ -2726,25 +2710,25 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
 		return -ESRCH;
 
 	length = security_getprocattr(task, PROC_I(inode)->op.lsmid,
-				      file->f_path.dentry->d_name.name,
+				      iocb->ki_filp->f_path.dentry->d_name.name,
 				      &p);
 	put_task_struct(task);
 	if (length > 0)
-		length = simple_read_from_buffer(buf, count, ppos, p, length);
+		length = simple_copy_to_iter(p, &iocb->ki_pos, length, to);
 	kfree(p);
 	return length;
 }
 
-static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
-				   size_t count, loff_t *ppos)
+static ssize_t proc_pid_attr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct inode * inode = file_inode(file);
+	struct inode * inode = file_inode(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	void *page;
 	int rv;
 
 	/* A task may only write when it was the opener. */
-	if (file->private_data != current->mm)
+	if (iocb->ki_filp->private_data != current->mm)
 		return -EPERM;
 
 	rcu_read_lock();
@@ -2769,10 +2753,10 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 		count = PAGE_SIZE;
 
 	/* No partial writes. */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
-	page = memdup_user(buf, count);
+	page = iterdup(from, count);
 	if (IS_ERR(page)) {
 		rv = PTR_ERR(page);
 		goto out;
@@ -2784,8 +2768,8 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 		goto out_free;
 
 	rv = security_setprocattr(PROC_I(inode)->op.lsmid,
-				  file->f_path.dentry->d_name.name, page,
-				  count);
+				  iocb->ki_filp->f_path.dentry->d_name.name,
+				  page, count);
 	mutex_unlock(&current->signal->cred_guard_mutex);
 out_free:
 	kfree(page);
@@ -2795,8 +2779,8 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 
 static const struct file_operations proc_pid_attr_operations = {
 	.open		= proc_pid_attr_open,
-	.read		= proc_pid_attr_read,
-	.write		= proc_pid_attr_write,
+	.read_iter	= proc_pid_attr_read,
+	.write_iter	= proc_pid_attr_write,
 	.llseek		= generic_file_llseek,
 	.release	= mem_release,
 };
@@ -2892,10 +2876,9 @@ static const struct inode_operations proc_attr_dir_inode_operations = {
 #endif
 
 #ifdef CONFIG_ELF_CORE
-static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
-					 size_t count, loff_t *ppos)
+static ssize_t proc_coredump_filter_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct task_struct *task = get_proc_task(file_inode(file));
+	struct task_struct *task = get_proc_task(file_inode(iocb->ki_filp));
 	struct mm_struct *mm;
 	char buffer[PROC_NUMBUF];
 	size_t len;
@@ -2911,7 +2894,7 @@ static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
 			       ((mm->flags & MMF_DUMP_FILTER_MASK) >>
 				MMF_DUMP_FILTER_SHIFT));
 		mmput(mm);
-		ret = simple_read_from_buffer(buf, count, ppos, buffer, len);
+		ret = simple_copy_to_iter(buffer, &iocb->ki_pos, len, to);
 	}
 
 	put_task_struct(task);
@@ -2919,11 +2902,10 @@ static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t proc_coredump_filter_write(struct file *file,
-					  const char __user *buf,
-					  size_t count,
-					  loff_t *ppos)
+static ssize_t proc_coredump_filter_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	struct mm_struct *mm;
 	unsigned int val;
@@ -2931,12 +2913,12 @@ static ssize_t proc_coredump_filter_write(struct file *file,
 	int i;
 	unsigned long mask;
 
-	ret = kstrtouint_from_user(buf, count, 0, &val);
+	ret = kstrtouint_from_iter(from, count, 0, &val);
 	if (ret < 0)
 		return ret;
 
 	ret = -ESRCH;
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		goto out_no_task;
 
@@ -2962,8 +2944,8 @@ static ssize_t proc_coredump_filter_write(struct file *file,
 }
 
 static const struct file_operations proc_coredump_filter_operations = {
-	.read		= proc_coredump_filter_read,
-	.write		= proc_coredump_filter_write,
+	.read_iter	= proc_coredump_filter_read,
+	.write_iter	= proc_coredump_filter_write,
 	.llseek		= generic_file_llseek,
 };
 #endif
@@ -3098,24 +3080,24 @@ static int proc_projid_map_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_uid_map_operations = {
 	.open		= proc_uid_map_open,
-	.write		= proc_uid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_uid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
 
 static const struct file_operations proc_gid_map_operations = {
 	.open		= proc_gid_map_open,
-	.write		= proc_gid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_gid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
 
 static const struct file_operations proc_projid_map_operations = {
 	.open		= proc_projid_map_open,
-	.write		= proc_projid_map_write,
-	.read		= seq_read,
+	.write_iter	= proc_projid_map_write_iter,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_id_map_release,
 };
@@ -3165,8 +3147,8 @@ static int proc_setgroups_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_setgroups_operations = {
 	.open		= proc_setgroups_open,
-	.write		= proc_setgroups_write,
-	.read		= seq_read,
+	.write_iter	= proc_setgroups_write,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_setgroups_release,
 };
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 63a3aebdf223..ee3f608559e5 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -103,7 +103,7 @@ static int seq_fdinfo_open(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_fdinfo_file_operations = {
 	.open		= seq_fdinfo_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index dcd513dccf55..092164889e74 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -325,6 +325,11 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count,
 	return rv;
 }
 
+static ssize_t __proc_reg_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, proc_reg_read);
+}
+
 static ssize_t pde_write(struct proc_dir_entry *pde, struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
 	typeof_member(struct proc_ops, proc_write) write;
@@ -348,6 +353,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t
 	}
 	return rv;
 }
+FOPS_WRITE_ITER_HELPER(proc_reg_write);
 
 static __poll_t pde_poll(struct proc_dir_entry *pde, struct file *file, struct poll_table_struct *pts)
 {
@@ -571,8 +577,8 @@ static int proc_reg_release(struct inode *inode, struct file *file)
 
 static const struct file_operations proc_reg_file_ops = {
 	.llseek		= proc_reg_llseek,
-	.read		= proc_reg_read,
-	.write		= proc_reg_write,
+	.read_iter	= __proc_reg_read_iter,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.mmap		= proc_reg_mmap,
@@ -584,7 +590,7 @@ static const struct file_operations proc_reg_file_ops = {
 static const struct file_operations proc_iter_file_ops = {
 	.llseek		= proc_reg_llseek,
 	.read_iter	= proc_reg_read_iter,
-	.write		= proc_reg_write,
+	.write_iter	= proc_reg_write_iter,
 	.splice_read	= copy_splice_read,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
@@ -597,8 +603,8 @@ static const struct file_operations proc_iter_file_ops = {
 #ifdef CONFIG_COMPAT
 static const struct file_operations proc_reg_file_ops_compat = {
 	.llseek		= proc_reg_llseek,
-	.read		= proc_reg_read,
-	.write		= proc_reg_write,
+	.read_iter	= proc_reg_read_iter,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.compat_ioctl	= proc_reg_compat_ioctl,
@@ -612,7 +618,7 @@ static const struct file_operations proc_iter_file_ops_compat = {
 	.llseek		= proc_reg_llseek,
 	.read_iter	= proc_reg_read_iter,
 	.splice_read	= copy_splice_read,
-	.write		= proc_reg_write,
+	.write_iter	= proc_reg_write_iter,
 	.poll		= proc_reg_poll,
 	.unlocked_ioctl	= proc_reg_unlocked_ioctl,
 	.compat_ioctl	= proc_reg_compat_ioctl,
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 23fbab954c20..ff86fe94fcba 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -360,7 +360,7 @@ static int pid_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_maps_operations = {
 	.open		= pid_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
@@ -1049,14 +1049,14 @@ static int smaps_rollup_release(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_smaps_operations = {
 	.open		= pid_smaps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
 
 const struct file_operations proc_pid_smaps_rollup_operations = {
 	.open		= smaps_rollup_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= smaps_rollup_release,
 };
@@ -1242,9 +1242,9 @@ static const struct mm_walk_ops clear_refs_walk_ops = {
 	.walk_lock		= PGWALK_WRLOCK,
 };
 
-static ssize_t clear_refs_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t clear_refs_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF] = {};
 	struct mm_struct *mm;
@@ -1255,7 +1255,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
-	if (copy_from_user(buffer, buf, count))
+	if (!copy_from_iter_full(buffer, count, from))
 		return -EFAULT;
 	rv = kstrtoint(strstrip(buffer), 10, &itype);
 	if (rv < 0)
@@ -1264,7 +1264,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 	if (type < CLEAR_REFS_ALL || type >= CLEAR_REFS_LAST)
 		return -EINVAL;
 
-	task = get_proc_task(file_inode(file));
+	task = get_proc_task(file_inode(iocb->ki_filp));
 	if (!task)
 		return -ESRCH;
 	mm = get_task_mm(task);
@@ -1318,7 +1318,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 }
 
 const struct file_operations proc_clear_refs_operations = {
-	.write		= clear_refs_write,
+	.write_iter	= clear_refs_write,
 	.llseek		= noop_llseek,
 };
 
@@ -1645,10 +1645,10 @@ static const struct mm_walk_ops pagemap_ops = {
  * determine which areas of memory are actually mapped and llseek to
  * skip over unmapped regions.
  */
-static ssize_t pagemap_read(struct file *file, char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t pagemap_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mm_struct *mm = file->private_data;
+	struct mm_struct *mm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct pagemapread pm;
 	unsigned long src;
 	unsigned long svpfn;
@@ -1661,7 +1661,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 
 	ret = -EINVAL;
 	/* file position must be aligned */
-	if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
+	if ((iocb->ki_pos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
 		goto out_mm;
 
 	ret = 0;
@@ -1669,7 +1669,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		goto out_mm;
 
 	/* do not disclose physical addresses: attack vector */
-	pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN);
+	pm.show_pfn = file_ns_capable(iocb->ki_filp, &init_user_ns, CAP_SYS_ADMIN);
 
 	pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
 	pm.buffer = kmalloc_array(pm.len, PM_ENTRY_BYTES, GFP_KERNEL);
@@ -1677,7 +1677,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 	if (!pm.buffer)
 		goto out_mm;
 
-	src = *ppos;
+	src = iocb->ki_pos;
 	svpfn = src / PM_ENTRY_BYTES;
 	end_vaddr = mm->task_size;
 
@@ -1719,15 +1719,14 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 		start_vaddr = end;
 
 		len = min(count, PM_ENTRY_BYTES * pm.pos);
-		if (copy_to_user(buf, pm.buffer, len)) {
+		if (!copy_to_iter_full(pm.buffer, len, to)) {
 			ret = -EFAULT;
 			goto out_free;
 		}
 		copied += len;
-		buf += len;
 		count -= len;
 	}
-	*ppos += copied;
+	iocb->ki_pos += copied;
 	if (!ret || ret == PM_END_OF_BUFFER)
 		ret = copied;
 
@@ -2518,7 +2517,7 @@ static long do_pagemap_cmd(struct file *file, unsigned int cmd,
 
 const struct file_operations proc_pagemap_operations = {
 	.llseek		= mem_lseek, /* borrow this */
-	.read		= pagemap_read,
+	.read_iter	= pagemap_read,
 	.open		= pagemap_open,
 	.release	= pagemap_release,
 	.unlocked_ioctl = do_pagemap_cmd,
@@ -2787,7 +2786,7 @@ static int pid_numa_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_numa_maps_operations = {
 	.open		= pid_numa_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= proc_map_release,
 };
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index bce674533000..b1385bf8dd05 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -289,7 +289,7 @@ static int pid_maps_open(struct inode *inode, struct file *file)
 
 const struct file_operations proc_pid_maps_operations = {
 	.open		= pid_maps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= map_release,
 };
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 6030a8235617..181ba788a56b 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -174,13 +174,15 @@ static inline void put_user_ns(struct user_namespace *ns)
 }
 
 struct seq_operations;
+struct kiocb;
+struct iov_iter;
 extern const struct seq_operations proc_uid_seq_operations;
 extern const struct seq_operations proc_gid_seq_operations;
 extern const struct seq_operations proc_projid_seq_operations;
-extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
-extern ssize_t proc_setgroups_write(struct file *, const char __user *, size_t, loff_t *);
+ssize_t proc_uid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_gid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_projid_map_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t proc_setgroups_write(struct kiocb *iocb, struct iov_iter *from);
 extern int proc_setgroups_show(struct seq_file *m, void *v);
 extern bool userns_may_setgroups(const struct user_namespace *ns);
 extern bool in_userns(const struct user_namespace *ancestor,
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 0b0b95418b16..05ec5be1c2d7 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -1108,8 +1108,8 @@ static ssize_t map_write(struct file *file, const char __user *buf,
 	return ret;
 }
 
-ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
-			   size_t size, loff_t *ppos)
+static ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
+				  size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1125,8 +1125,13 @@ ssize_t proc_uid_map_write(struct file *file, const char __user *buf,
 			 &ns->uid_map, &ns->parent->uid_map);
 }
 
-ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
-			   size_t size, loff_t *ppos)
+ssize_t proc_uid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_uid_map_write);
+}
+
+static ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
+				  size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1142,8 +1147,13 @@ ssize_t proc_gid_map_write(struct file *file, const char __user *buf,
 			 &ns->gid_map, &ns->parent->gid_map);
 }
 
-ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
-			      size_t size, loff_t *ppos)
+ssize_t proc_gid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_gid_map_write);
+}
+
+static ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
+				     size_t size, loff_t *ppos)
 {
 	struct seq_file *seq = file->private_data;
 	struct user_namespace *ns = seq->private;
@@ -1160,6 +1170,11 @@ ssize_t proc_projid_map_write(struct file *file, const char __user *buf,
 			 &ns->projid_map, &ns->parent->projid_map);
 }
 
+ssize_t proc_projid_map_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	return vfs_write_iter(iocb, from, proc_projid_map_write);
+}
+
 static bool new_idmap_permitted(const struct file *file,
 				struct user_namespace *ns, int cap_setid,
 				struct uid_gid_map *new_map)
@@ -1213,23 +1228,23 @@ int proc_setgroups_show(struct seq_file *seq, void *v)
 	return 0;
 }
 
-ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+ssize_t proc_setgroups_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
 	struct user_namespace *ns = seq->private;
+	size_t count = iov_iter_count(from);
 	char kbuf[8], *pos;
 	bool setgroups_allowed;
 	ssize_t ret;
 
 	/* Only allow a very narrow range of strings to be written */
 	ret = -EINVAL;
-	if ((*ppos != 0) || (count >= sizeof(kbuf)))
+	if ((iocb->ki_pos != 0) || (count >= sizeof(kbuf)))
 		goto out;
 
 	/* What was written? */
 	ret = -EFAULT;
-	if (copy_from_user(kbuf, buf, count))
+	if (!copy_from_iter_full(kbuf, count, from))
 		goto out;
 	kbuf[count] = '\0';
 	pos = kbuf;
@@ -1271,7 +1286,7 @@ ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
 	mutex_unlock(&userns_state_mutex);
 
 	/* Report a successful write */
-	*ppos = count;
+	iocb->ki_pos = count;
 	ret = count;
 out:
 	return ret;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 293/437] fs: convert fs_open to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (291 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 292/437] fs/proc: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 294/437] openpromfs: convert " Jens Axboe
                   ` (144 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/fsopen.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/fsopen.c b/fs/fsopen.c
index 6593ae518115..a68b7d4071b1 100644
--- a/fs/fsopen.c
+++ b/fs/fsopen.c
@@ -14,6 +14,7 @@
 #include <linux/anon_inodes.h>
 #include <linux/namei.h>
 #include <linux/file.h>
+#include <linux/uio.h>
 #include <uapi/linux/mount.h>
 #include "internal.h"
 #include "mount.h"
@@ -21,12 +22,12 @@
 /*
  * Allow the user to read back any error, warning or informational messages.
  */
-static ssize_t fscontext_read(struct file *file,
-			      char __user *_buf, size_t len, loff_t *pos)
+static ssize_t fscontext_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct fs_context *fc = file->private_data;
+	struct fs_context *fc = iocb->ki_filp->private_data;
 	struct fc_log *log = fc->log.log;
 	unsigned int logsize = ARRAY_SIZE(log->buffer);
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	char *p;
 	bool need_free;
@@ -54,7 +55,7 @@ static ssize_t fscontext_read(struct file *file,
 	if (n > len)
 		goto err_free;
 	ret = -EFAULT;
-	if (copy_to_user(_buf, p, n) != 0)
+	if (!copy_to_iter_full(p, n, to) != 0)
 		goto err_free;
 	ret = n;
 
@@ -76,7 +77,7 @@ static int fscontext_release(struct inode *inode, struct file *file)
 }
 
 const struct file_operations fscontext_fops = {
-	.read		= fscontext_read,
+	.read_iter	= fscontext_read,
 	.release	= fscontext_release,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 294/437] openpromfs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (292 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 293/437] fs: convert fs_open " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 295/437] drivers/net/wireless/ti: " Jens Axboe
                   ` (143 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/openpromfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index e25eceac86f4..66667b55562b 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -159,7 +159,7 @@ static int property_open(struct inode *inode, struct file *file)
 
 static const struct file_operations openpromfs_prop_ops = {
 	.open		= property_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 295/437] drivers/net/wireless/ti: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (293 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 294/437] openpromfs: convert " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 296/437] drivers/net/wireless/intel: " Jens Axboe
                   ` (142 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ti/wl1251/debugfs.c |  38 ++-
 drivers/net/wireless/ti/wl18xx/debugfs.c |  73 ++---
 drivers/net/wireless/ti/wlcore/debugfs.c | 373 ++++++++++-------------
 drivers/net/wireless/ti/wlcore/debugfs.h |  37 +--
 4 files changed, 231 insertions(+), 290 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/debugfs.c b/drivers/net/wireless/ti/wl1251/debugfs.c
index a1b778a0fda0..66e57dd0add4 100644
--- a/drivers/net/wireless/ti/wl1251/debugfs.c
+++ b/drivers/net/wireless/ti/wl1251/debugfs.c
@@ -20,19 +20,18 @@
 /* debugfs macros idea from mac80211 */
 
 #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...)		\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct wl1251 *wl = file->private_data;				\
+	struct wl1251 *wl = iocb->ki_filp->private_data;			\
 	char buf[buflen];						\
 	int res;							\
 									\
 	res = scnprintf(buf, buflen, fmt "\n", ##value);		\
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);	\
 }									\
 									\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -48,11 +47,10 @@ static const struct file_operations name## _ops = {			\
 	} while (0)
 
 #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt)			\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1251 *wl = file->private_data;				\
+	struct wl1251 *wl = iocb->ki_filp->private_data;		\
 	char buf[buflen];						\
 	int res;							\
 									\
@@ -60,11 +58,11 @@ static ssize_t sub## _ ##name## _read(struct file *file,		\
 									\
 	res = scnprintf(buf, buflen, fmt "\n",				\
 			wl->stats.fw_stats->sub.name);			\
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);	\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -194,10 +192,9 @@ DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
 DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
 		      wl->stats.excessive_retries);
 
-static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t tx_queue_len_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1251 *wl = file->private_data;
+	struct wl1251 *wl = iocb->ki_filp->private_data;
 	u32 queue_len;
 	char buf[20];
 	int res;
@@ -205,19 +202,18 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
 	queue_len = skb_queue_len(&wl->tx_queue);
 
 	res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 static const struct file_operations tx_queue_len_ops = {
-	.read = tx_queue_len_read,
+	.read_iter = tx_queue_len_read,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
 
-static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t tx_queue_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1251 *wl = file->private_data;
+	struct wl1251 *wl = iocb->ki_filp->private_data;
 	char buf[3], status;
 	int len;
 
@@ -227,11 +223,11 @@ static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
 		status = 'r';
 
 	len = scnprintf(buf, sizeof(buf), "%c\n", status);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations tx_queue_status_ops = {
-	.read = tx_queue_status_read,
+	.read_iter = tx_queue_status_read,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
diff --git a/drivers/net/wireless/ti/wl18xx/debugfs.c b/drivers/net/wireless/ti/wl18xx/debugfs.c
index 80fbf740fe6d..629838b1a959 100644
--- a/drivers/net/wireless/ti/wl18xx/debugfs.c
+++ b/drivers/net/wireless/ti/wl18xx/debugfs.c
@@ -175,10 +175,9 @@ WL18XX_DEBUGFS_FWSTATS_FILE(roaming, rssi_level, "%d");
 
 WL18XX_DEBUGFS_FWSTATS_FILE(dfs, num_of_radar_detections, "%d");
 
-static ssize_t conf_read(struct file *file, char __user *user_buf,
-			 size_t count, loff_t *ppos)
+static ssize_t conf_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	struct wl18xx_priv *priv = wl->priv;
 	struct wlcore_conf_header header;
 	char *buf, *pos;
@@ -205,23 +204,22 @@ static ssize_t conf_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&wl->mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations conf_ops = {
-	.read = conf_read,
+	.read_iter = conf_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t clear_fw_stats_write(struct file *file,
-			      const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t clear_fw_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	mutex_lock(&wl->mutex);
@@ -240,20 +238,19 @@ static ssize_t clear_fw_stats_write(struct file *file,
 }
 
 static const struct file_operations clear_fw_stats_ops = {
-	.write = clear_fw_stats_write,
+	.write_iter = clear_fw_stats_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t radar_detection_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t radar_detection_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 channel;
 
-	ret = kstrtou8_from_user(user_buf, count, 10, &channel);
+	ret = kstrtou8_from_iter(from, count, 10, &channel);
 	if (ret < 0) {
 		wl1271_warning("illegal channel");
 		return -EINVAL;
@@ -280,20 +277,19 @@ static ssize_t radar_detection_write(struct file *file,
 }
 
 static const struct file_operations radar_detection_ops = {
-	.write = radar_detection_write,
+	.write_iter = radar_detection_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t dynamic_fw_traces_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t dynamic_fw_traces_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &value);
+	ret = kstrtoul_from_iter(from, count, 0, &value);
 	if (ret < 0)
 		return ret;
 
@@ -319,33 +315,29 @@ static ssize_t dynamic_fw_traces_write(struct file *file,
 	return count;
 }
 
-static ssize_t dynamic_fw_traces_read(struct file *file,
-					char __user *userbuf,
-					size_t count, loff_t *ppos)
+static ssize_t dynamic_fw_traces_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
-	return wl1271_format_buffer(userbuf, count, ppos,
-				    "%d\n", wl->dynamic_fw_traces);
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	return wl1271_format_buffer(iocb, to, "%d\n", wl->dynamic_fw_traces);
 }
 
 static const struct file_operations dynamic_fw_traces_ops = {
-	.read = dynamic_fw_traces_read,
-	.write = dynamic_fw_traces_write,
+	.read_iter = dynamic_fw_traces_read,
+	.write_iter = dynamic_fw_traces_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 #ifdef CONFIG_CFG80211_CERTIFICATION_ONUS
-static ssize_t radar_debug_mode_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t radar_debug_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal radar_debug_mode value!");
 		return -EINVAL;
@@ -381,19 +373,16 @@ static ssize_t radar_debug_mode_write(struct file *file,
 	return count;
 }
 
-static ssize_t radar_debug_mode_read(struct file *file,
-				     char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t radar_debug_mode_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(userbuf, count, ppos,
-				    "%d\n", wl->radar_debug_mode);
+	return wl1271_format_buffer(iocb, to, "%d\n", wl->radar_debug_mode);
 }
 
 static const struct file_operations radar_debug_mode_ops = {
-	.write = radar_debug_mode_write,
-	.read = radar_debug_mode_read,
+	.write_iter = radar_debug_mode_write,
+	.read_iter = radar_debug_mode_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/ti/wlcore/debugfs.c b/drivers/net/wireless/ti/wlcore/debugfs.c
index eb3d3f0e0b4d..1834cc60aab7 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.c
+++ b/drivers/net/wireless/ti/wlcore/debugfs.c
@@ -28,8 +28,7 @@
 #define WLCORE_MAX_BLOCK_SIZE ((size_t)(4*PAGE_SIZE))
 
 /* debugfs macros idea from mac80211 */
-int wl1271_format_buffer(char __user *userbuf, size_t count,
-			 loff_t *ppos, char *fmt, ...)
+int wl1271_format_buffer(struct kiocb *iocb, struct iov_iter *to, char *fmt, ...)
 {
 	va_list args;
 	char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
@@ -39,7 +38,7 @@ int wl1271_format_buffer(char __user *userbuf, size_t count,
 	res = vscnprintf(buf, sizeof(buf), fmt, args);
 	va_end(args);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 EXPORT_SYMBOL_GPL(wl1271_format_buffer);
 
@@ -75,10 +74,9 @@ DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count);
 DEBUGFS_READONLY_FILE(excessive_retries, "%u",
 		      wl->stats.excessive_retries);
 
-static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t tx_queue_len_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	u32 queue_len;
 	char buf[20];
 	int res;
@@ -86,11 +84,11 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
 	queue_len = wl1271_tx_total_queue_count(wl);
 
 	res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 static const struct file_operations tx_queue_len_ops = {
-	.read = tx_queue_len_read,
+	.read_iter = tx_queue_len_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -120,25 +118,23 @@ static void chip_op_handler(struct wl1271 *wl, unsigned long value,
 #define WL12XX_CONF_DEBUGFS(param, conf_sub_struct,			\
 			    min_val, max_val, write_handler_locked,	\
 			    write_handler_arg)				\
-	static ssize_t param##_read(struct file *file,			\
-				      char __user *user_buf,		\
-				      size_t count, loff_t *ppos)	\
+	static ssize_t param##_read(struct kiocb *iocb,			\
+				      struct iov_iter *to)		\
 	{								\
-	struct wl1271 *wl = file->private_data;				\
-	return wl1271_format_buffer(user_buf, count,			\
-				    ppos, "%d\n",			\
-				    wl->conf.conf_sub_struct.param);	\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
+	return wl1271_format_buffer(iocb, to, "%d\n",			\
+				wl->conf.conf_sub_struct.param);	\
 	}								\
 									\
-	static ssize_t param##_write(struct file *file,			\
-				     const char __user *user_buf,	\
-				     size_t count, loff_t *ppos)	\
+	static ssize_t param##_write(struct kiocb *iocb,		\
+				     struct iov_iter *from)		\
 	{								\
-	struct wl1271 *wl = file->private_data;				\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
+	size_t count = iov_iter_count(from);				\
 	unsigned long value;						\
 	int ret;							\
 									\
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);		\
+	ret = kstrtoul_from_iter(from, count, 10, &value);		\
 	if (ret < 0) {							\
 		wl1271_warning("illegal value for " #param);		\
 		return -EINVAL;						\
@@ -159,8 +155,8 @@ static void chip_op_handler(struct wl1271 *wl, unsigned long value,
 	}								\
 									\
 	static const struct file_operations param##_ops = {		\
-		.read = param##_read,					\
-		.write = param##_write,					\
+		.read_iter = param##_read,				\
+		.write_iter = param##_write,				\
 		.open = simple_open,					\
 		.llseek = default_llseek,				\
 	};
@@ -172,10 +168,9 @@ WL12XX_CONF_DEBUGFS(irq_blk_threshold, rx, 0, 65535,
 WL12XX_CONF_DEBUGFS(irq_timeout, rx, 0, 100,
 		    chip_op_handler, wl1271_acx_init_rx_interrupt)
 
-static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t gpio_power_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
 
 	int res;
@@ -183,18 +178,17 @@ static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
 
 	res = scnprintf(buf, sizeof(buf), "%d\n", state);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
-static ssize_t gpio_power_write(struct file *file,
-			   const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t gpio_power_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in gpio_power");
 		return -EINVAL;
@@ -212,51 +206,47 @@ static ssize_t gpio_power_write(struct file *file,
 }
 
 static const struct file_operations gpio_power_ops = {
-	.read = gpio_power_read,
-	.write = gpio_power_write,
+	.read_iter = gpio_power_read,
+	.write_iter = gpio_power_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t start_recovery_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t start_recovery_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
 	mutex_lock(&wl->mutex);
 	wl12xx_queue_recovery_work(wl);
 	mutex_unlock(&wl->mutex);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations start_recovery_ops = {
-	.write = start_recovery_write,
+	.write_iter = start_recovery_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t dynamic_ps_timeout_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t dynamic_ps_timeout_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(user_buf, count,
-				    ppos, "%d\n",
+	return wl1271_format_buffer(iocb, to, "%d\n",
 				    wl->conf.conn.dynamic_ps_timeout);
 }
 
-static ssize_t dynamic_ps_timeout_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t dynamic_ps_timeout_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in dynamic_ps");
 		return -EINVAL;
@@ -296,32 +286,29 @@ static ssize_t dynamic_ps_timeout_write(struct file *file,
 }
 
 static const struct file_operations dynamic_ps_timeout_ops = {
-	.read = dynamic_ps_timeout_read,
-	.write = dynamic_ps_timeout_write,
+	.read_iter = dynamic_ps_timeout_read,
+	.write_iter = dynamic_ps_timeout_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t forced_ps_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t forced_ps_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(user_buf, count,
-				    ppos, "%d\n",
+	return wl1271_format_buffer(iocb, to, "%d\n",
 				    wl->conf.conn.forced_ps);
 }
 
-static ssize_t forced_ps_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t forced_ps_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret, ps_mode;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in forced_ps");
 		return -EINVAL;
@@ -366,31 +353,29 @@ static ssize_t forced_ps_write(struct file *file,
 }
 
 static const struct file_operations forced_ps_ops = {
-	.read = forced_ps_read,
-	.write = forced_ps_write,
+	.read_iter = forced_ps_read,
+	.write_iter = forced_ps_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t split_scan_timeout_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t split_scan_timeout_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(user_buf, count,
-				    ppos, "%d\n",
+	return wl1271_format_buffer(iocb, to, "%d\n",
 				    wl->conf.scan.split_scan_timeout / 1000);
 }
 
-static ssize_t split_scan_timeout_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t split_scan_timeout_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in split_scan_timeout");
 		return -EINVAL;
@@ -408,16 +393,15 @@ static ssize_t split_scan_timeout_write(struct file *file,
 }
 
 static const struct file_operations split_scan_timeout_ops = {
-	.read = split_scan_timeout_read,
-	.write = split_scan_timeout_write,
+	.read_iter = split_scan_timeout_read,
+	.write_iter = split_scan_timeout_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t driver_state_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t driver_state_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	int res = 0;
 	ssize_t ret;
 	char *buf;
@@ -502,21 +486,20 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&wl->mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations driver_state_ops = {
-	.read = driver_state_read,
+	.read_iter = driver_state_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t vifs_state_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t vifs_state_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	struct wl12xx_vif *wlvif;
 	int ret, res = 0;
 	const int buf_size = 4096;
@@ -612,21 +595,20 @@ static ssize_t vifs_state_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&wl->mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, res);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations vifs_state_ops = {
-	.read = vifs_state_read,
+	.read_iter = vifs_state_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t dtim_interval_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t dtim_interval_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	u8 value;
 
 	if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
@@ -635,18 +617,17 @@ static ssize_t dtim_interval_read(struct file *file, char __user *user_buf,
 	else
 		value = 0;
 
-	return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
+	return wl1271_format_buffer(iocb, to, "%d\n", value);
 }
 
-static ssize_t dtim_interval_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t dtim_interval_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value for dtim_interval");
 		return -EINVAL;
@@ -675,19 +656,18 @@ static ssize_t dtim_interval_write(struct file *file,
 }
 
 static const struct file_operations dtim_interval_ops = {
-	.read = dtim_interval_read,
-	.write = dtim_interval_write,
+	.read_iter = dtim_interval_read,
+	.write_iter = dtim_interval_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 
 
-static ssize_t suspend_dtim_interval_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t suspend_dtim_interval_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	u8 value;
 
 	if (wl->conf.conn.suspend_wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
@@ -696,18 +676,18 @@ static ssize_t suspend_dtim_interval_read(struct file *file,
 	else
 		value = 0;
 
-	return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
+	return wl1271_format_buffer(iocb, to, "%d\n", value);
 }
 
-static ssize_t suspend_dtim_interval_write(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t suspend_dtim_interval_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value for suspend_dtim_interval");
 		return -EINVAL;
@@ -731,18 +711,16 @@ static ssize_t suspend_dtim_interval_write(struct file *file,
 	return count;
 }
 
-
 static const struct file_operations suspend_dtim_interval_ops = {
-	.read = suspend_dtim_interval_read,
-	.write = suspend_dtim_interval_write,
+	.read_iter = suspend_dtim_interval_read,
+	.write_iter = suspend_dtim_interval_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t beacon_interval_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t beacon_interval_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	u8 value;
 
 	if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_BEACON ||
@@ -751,18 +729,17 @@ static ssize_t beacon_interval_read(struct file *file, char __user *user_buf,
 	else
 		value = 0;
 
-	return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
+	return wl1271_format_buffer(iocb, to, "%d\n", value);
 }
 
-static ssize_t beacon_interval_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t beacon_interval_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value for beacon_interval");
 		return -EINVAL;
@@ -791,22 +768,22 @@ static ssize_t beacon_interval_write(struct file *file,
 }
 
 static const struct file_operations beacon_interval_ops = {
-	.read = beacon_interval_read,
-	.write = beacon_interval_write,
+	.read_iter = beacon_interval_read,
+	.write_iter = beacon_interval_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t rx_streaming_interval_write(struct file *file,
-			   const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t rx_streaming_interval_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in rx_streaming_interval!");
 		return -EINVAL;
@@ -837,32 +814,31 @@ static ssize_t rx_streaming_interval_write(struct file *file,
 	return count;
 }
 
-static ssize_t rx_streaming_interval_read(struct file *file,
-			    char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t rx_streaming_interval_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
-	return wl1271_format_buffer(userbuf, count, ppos,
-				    "%d\n", wl->conf.rx_streaming.interval);
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	return wl1271_format_buffer(iocb, to, "%d\n",
+				    wl->conf.rx_streaming.interval);
 }
 
 static const struct file_operations rx_streaming_interval_ops = {
-	.read = rx_streaming_interval_read,
-	.write = rx_streaming_interval_write,
+	.read_iter = rx_streaming_interval_read,
+	.write_iter = rx_streaming_interval_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t rx_streaming_always_write(struct file *file,
-			   const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t rx_streaming_always_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 10, &value);
+	ret = kstrtoul_from_iter(from, count, 10, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in rx_streaming_write!");
 		return -EINVAL;
@@ -893,32 +869,29 @@ static ssize_t rx_streaming_always_write(struct file *file,
 	return count;
 }
 
-static ssize_t rx_streaming_always_read(struct file *file,
-			    char __user *userbuf,
-			    size_t count, loff_t *ppos)
+static ssize_t rx_streaming_always_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
-	return wl1271_format_buffer(userbuf, count, ppos,
-				    "%d\n", wl->conf.rx_streaming.always);
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	return wl1271_format_buffer(iocb, to, "%d\n",
+				    wl->conf.rx_streaming.always);
 }
 
 static const struct file_operations rx_streaming_always_ops = {
-	.read = rx_streaming_always_read,
-	.write = rx_streaming_always_write,
+	.read_iter = rx_streaming_always_read,
+	.write_iter = rx_streaming_always_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t beacon_filtering_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t beacon_filtering_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wl12xx_vif *wlvif;
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &value);
+	ret = kstrtoul_from_iter(from, count, 0, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value for beacon_filtering!");
 		return -EINVAL;
@@ -942,49 +915,42 @@ static ssize_t beacon_filtering_write(struct file *file,
 }
 
 static const struct file_operations beacon_filtering_ops = {
-	.write = beacon_filtering_write,
+	.write_iter = beacon_filtering_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t fw_stats_raw_read(struct file *file,
-				 char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t fw_stats_raw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
 	wl1271_debugfs_update_stats(wl);
 
-	return simple_read_from_buffer(userbuf, count, ppos,
-				       wl->stats.fw_stats,
-				       wl->stats.fw_stats_len);
+	return simple_copy_to_iter(wl->stats.fw_stats, &iocb->ki_pos,
+				       wl->stats.fw_stats_len, to);
 }
 
 static const struct file_operations fw_stats_raw_ops = {
-	.read = fw_stats_raw_read,
+	.read_iter = fw_stats_raw_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t sleep_auth_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t sleep_auth_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(user_buf, count,
-				    ppos, "%d\n",
-				    wl->sleep_auth);
+	return wl1271_format_buffer(iocb, to, "%d\n", wl->sleep_auth);
 }
 
-static ssize_t sleep_auth_write(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t sleep_auth_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &value);
+	ret = kstrtoul_from_iter(from, count, 0, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in sleep_auth");
 		return -EINVAL;
@@ -1023,18 +989,17 @@ static ssize_t sleep_auth_write(struct file *file,
 }
 
 static const struct file_operations sleep_auth_ops = {
-	.read = sleep_auth_read,
-	.write = sleep_auth_write,
+	.read_iter = sleep_auth_read,
+	.write_iter = sleep_auth_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t dev_mem_read(struct file *file,
-	     char __user *user_buf, size_t count,
-	     loff_t *ppos)
+static ssize_t dev_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 	struct wlcore_partition_set part, old_part;
+	size_t count = iov_iter_count(to);
 	size_t bytes = count;
 	int ret;
 	char *buf;
@@ -1043,7 +1008,7 @@ static ssize_t dev_mem_read(struct file *file,
 	if (bytes % 4)
 		return -EINVAL;
 
-	if (*ppos % 4)
+	if (iocb->ki_pos % 4)
 		return -EINVAL;
 
 	/* function should return in reasonable time */
@@ -1053,7 +1018,7 @@ static ssize_t dev_mem_read(struct file *file,
 		return -EINVAL;
 
 	memset(&part, 0, sizeof(part));
-	part.mem.start = *ppos;
+	part.mem.start = iocb->ki_pos;
 	part.mem.size = bytes;
 
 	buf = kmalloc(bytes, GFP_KERNEL);
@@ -1097,13 +1062,13 @@ static ssize_t dev_mem_read(struct file *file,
 	mutex_unlock(&wl->mutex);
 
 	if (ret == 0) {
-		ret = copy_to_user(user_buf, buf, bytes);
-		if (ret < bytes) {
+		ret = copy_to_iter(buf, bytes, to);
+		if (!ret) {
+			ret = -EFAULT;
+		} else {
 			bytes -= ret;
-			*ppos += bytes;
+			iocb->ki_pos += bytes;
 			ret = 0;
-		} else {
-			ret = -EFAULT;
 		}
 	}
 
@@ -1112,10 +1077,10 @@ static ssize_t dev_mem_read(struct file *file,
 	return ((ret == 0) ? bytes : ret);
 }
 
-static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
-		size_t count, loff_t *ppos)
+static ssize_t dev_mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wlcore_partition_set part, old_part;
 	size_t bytes = count;
 	int ret;
@@ -1125,7 +1090,7 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 	if (bytes % 4)
 		return -EINVAL;
 
-	if (*ppos % 4)
+	if (iocb->ki_pos % 4)
 		return -EINVAL;
 
 	/* function should return in reasonable time */
@@ -1135,10 +1100,10 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 		return -EINVAL;
 
 	memset(&part, 0, sizeof(part));
-	part.mem.start = *ppos;
+	part.mem.start = iocb->ki_pos;
 	part.mem.size = bytes;
 
-	buf = memdup_user(user_buf, bytes);
+	buf = iterdup(from, bytes);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -1179,7 +1144,7 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 	mutex_unlock(&wl->mutex);
 
 	if (ret == 0)
-		*ppos += bytes;
+		iocb->ki_pos += bytes;
 
 	kfree(buf);
 
@@ -1197,30 +1162,26 @@ static loff_t dev_mem_seek(struct file *file, loff_t offset, int orig)
 
 static const struct file_operations dev_mem_ops = {
 	.open = simple_open,
-	.read = dev_mem_read,
-	.write = dev_mem_write,
+	.read_iter = dev_mem_read,
+	.write_iter = dev_mem_write,
 	.llseek = dev_mem_seek,
 };
 
-static ssize_t fw_logger_read(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t fw_logger_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
 
-	return wl1271_format_buffer(user_buf, count,
-					ppos, "%d\n",
-					wl->conf.fwlog.output);
+	return wl1271_format_buffer(iocb, to, "%d\n", wl->conf.fwlog.output);
 }
 
-static ssize_t fw_logger_write(struct file *file,
-			       const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t fw_logger_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wl1271 *wl = file->private_data;
+	struct wl1271 *wl = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long value;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &value);
+	ret = kstrtoul_from_iter(from, count, 0, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in fw_logger");
 		return -EINVAL;
@@ -1257,8 +1218,8 @@ static ssize_t fw_logger_write(struct file *file,
 
 static const struct file_operations fw_logger_ops = {
 	.open = simple_open,
-	.read = fw_logger_read,
-	.write = fw_logger_write,
+	.read_iter = fw_logger_read,
+	.write_iter = fw_logger_write,
 	.llseek = default_llseek,
 };
 
diff --git a/drivers/net/wireless/ti/wlcore/debugfs.h b/drivers/net/wireless/ti/wlcore/debugfs.h
index a9e13e6d65c5..294ac6e29c5f 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.h
+++ b/drivers/net/wireless/ti/wlcore/debugfs.h
@@ -12,8 +12,8 @@
 
 #include "wlcore.h"
 
-__printf(4, 5) int wl1271_format_buffer(char __user *userbuf, size_t count,
-					loff_t *ppos, char *fmt, ...);
+__printf(3, 4) int wl1271_format_buffer(struct kiocb *iocb, struct iov_iter *to,
+					char *fmt, ...);
 
 int wl1271_debugfs_init(struct wl1271 *wl);
 void wl1271_debugfs_exit(struct wl1271 *wl);
@@ -23,16 +23,14 @@ void wl1271_debugfs_update_stats(struct wl1271 *wl);
 #define DEBUGFS_FORMAT_BUFFER_SIZE 256
 
 #define DEBUGFS_READONLY_FILE(name, fmt, value...)			\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct wl1271 *wl = file->private_data;				\
-	return wl1271_format_buffer(userbuf, count, ppos,		\
-				    fmt "\n", ##value);			\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
+	return wl1271_format_buffer(iocb, to, fmt "\n", ##value);	\
 }									\
 									\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -51,31 +49,28 @@ static const struct file_operations name## _ops = {			\
 	} while (0)
 
 #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type)		\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1271 *wl = file->private_data;				\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
 	struct struct_type *stats = wl->stats.fw_stats;			\
 									\
 	wl1271_debugfs_update_stats(wl);				\
 									\
-	return wl1271_format_buffer(userbuf, count, ppos, fmt "\n",	\
-				    stats->sub.name);			\
+	return wl1271_format_buffer(iocb, to, fmt "\n", stats->sub.name);\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
 
 #define DEBUGFS_FWSTATS_FILE_ARRAY(sub, name, len, struct_type)		\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1271 *wl = file->private_data;				\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
 	struct struct_type *stats = wl->stats.fw_stats;			\
 	char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = "";			\
 	int pos = 0;							\
@@ -87,11 +82,11 @@ static ssize_t sub## _ ##name## _read(struct file *file,		\
 		pos += snprintf(buf + pos, sizeof(buf) - pos,		\
 			 "[%d] = %d\n", i, stats->sub.name[i]);		\
 									\
-	return wl1271_format_buffer(userbuf, count, ppos, "%s", buf);	\
+	return wl1271_format_buffer(iocb, to, "%s", buf);		\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 296/437] drivers/net/wireless/intel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (294 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 295/437] drivers/net/wireless/ti: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 297/437] drivers/net/wireless/mediatek: " Jens Axboe
                   ` (141 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/intel/iwlegacy/3945-rs.c |   9 +-
 drivers/net/wireless/intel/iwlegacy/4965-rs.c |  39 +-
 drivers/net/wireless/intel/iwlegacy/debug.c   | 280 +++++------
 .../net/wireless/intel/iwlwifi/dvm/debugfs.c  | 455 ++++++++----------
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c   |  42 +-
 .../net/wireless/intel/iwlwifi/fw/debugfs.c   |  23 +-
 drivers/net/wireless/intel/iwlwifi/mei/main.c |  18 +-
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   7 +-
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  81 ++--
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  | 227 ++++-----
 .../net/wireless/intel/iwlwifi/mvm/debugfs.h  |   9 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c   |  62 ++-
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  85 ++--
 13 files changed, 609 insertions(+), 728 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/3945-rs.c b/drivers/net/wireless/intel/iwlegacy/3945-rs.c
index 0eaad980c85c..1a14dce71bff 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945-rs.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-rs.c
@@ -801,14 +801,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
 #ifdef CONFIG_MAC80211_DEBUGFS
 
 static ssize_t
-il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+il3945_sta_dbgfs_stats_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
 	int j;
 	ssize_t ret;
-	struct il3945_rs_sta *lq_sta = file->private_data;
+	struct il3945_rs_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -827,13 +826,13 @@ il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
 			    lq_sta->win[j].success_counter,
 			    lq_sta->win[j].success_ratio);
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = il3945_sta_dbgfs_stats_table_read,
+	.read_iter = il3945_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-rs.c b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
index 718efb1aa1b0..958d7e8e26d6 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-rs.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
@@ -2527,11 +2527,10 @@ il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx)
 }
 
 static ssize_t
-il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_scale_table_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct il_priv *il;
 	char buf[64];
 	size_t buf_size;
@@ -2540,7 +2539,7 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
 	il = lq_sta->drv;
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x", &parsed_rate) == 1)
@@ -2564,8 +2563,7 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
 }
 
 static ssize_t
-il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_scale_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
@@ -2573,7 +2571,7 @@ il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
 	int idx = 0;
 	ssize_t ret;
 
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct il_priv *il;
 	struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
 
@@ -2659,28 +2657,27 @@ il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
 		}
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
-	.write = il4965_rs_sta_dbgfs_scale_table_write,
-	.read = il4965_rs_sta_dbgfs_scale_table_read,
+	.write_iter = il4965_rs_sta_dbgfs_scale_table_write,
+	.read_iter = il4965_rs_sta_dbgfs_scale_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 static ssize_t
-il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_stats_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
 	int i, j;
 	ssize_t ret;
 
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -2705,25 +2702,23 @@ il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
 				    lq_sta->lq_info[i].win[j].success_ratio);
 		}
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = il4965_rs_sta_dbgfs_stats_table_read,
+	.read_iter = il4965_rs_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 static ssize_t
-il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file,
-					 char __user *user_buf, size_t count,
-					 loff_t *ppos)
+il4965_rs_sta_dbgfs_rate_scale_data_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buff[120];
 	int desc = 0;
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl];
 
 	if (is_Ht(tbl->lq_type))
@@ -2735,11 +2730,11 @@ il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file,
 		    sprintf(buff + desc, "Bit Rate= %d Mb/s\n",
 			    il_rates[lq_sta->last_txrate_idx].ieee >> 1);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
 static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
-	.read = il4965_rs_sta_dbgfs_rate_scale_data_read,
+	.read_iter = il4965_rs_sta_dbgfs_rate_scale_data_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/intel/iwlegacy/debug.c b/drivers/net/wireless/intel/iwlegacy/debug.c
index d998a3f1b056..c824c1db8186 100644
--- a/drivers/net/wireless/intel/iwlegacy/debug.c
+++ b/drivers/net/wireless/intel/iwlegacy/debug.c
@@ -120,20 +120,18 @@ EXPORT_SYMBOL(il_update_stats);
 
 /* file operation */
 #define DEBUGFS_READ_FUNC(name)                                         \
-static ssize_t il_dbgfs_##name##_read(struct file *file,               \
-					char __user *user_buf,          \
-					size_t count, loff_t *ppos);
+static ssize_t il_dbgfs_##name##_read(struct kiocb *iocb,               \
+					struct iov_iter *to);           \
 
 #define DEBUGFS_WRITE_FUNC(name)                                        \
-static ssize_t il_dbgfs_##name##_write(struct file *file,              \
-					const char __user *user_buf,    \
-					size_t count, loff_t *ppos);
+static ssize_t il_dbgfs_##name##_write(struct kiocb *iocb,              \
+					struct iov_iter *from);         \
 
 
 #define DEBUGFS_READ_FILE_OPS(name)				\
 	DEBUGFS_READ_FUNC(name);				\
 static const struct file_operations il_dbgfs_##name##_ops = {	\
-	.read = il_dbgfs_##name##_read,				\
+	.read_iter = il_dbgfs_##name##_read,			\
 	.open = simple_open,					\
 	.llseek = generic_file_llseek,				\
 };
@@ -141,7 +139,7 @@ static const struct file_operations il_dbgfs_##name##_ops = {	\
 #define DEBUGFS_WRITE_FILE_OPS(name)				\
 	DEBUGFS_WRITE_FUNC(name);				\
 static const struct file_operations il_dbgfs_##name##_ops = {	\
-	.write = il_dbgfs_##name##_write,			\
+	.write_iter = il_dbgfs_##name##_write,			\
 	.open = simple_open,					\
 	.llseek = generic_file_llseek,				\
 };
@@ -150,8 +148,8 @@ static const struct file_operations il_dbgfs_##name##_ops = {	\
 	DEBUGFS_READ_FUNC(name);				\
 	DEBUGFS_WRITE_FUNC(name);				\
 static const struct file_operations il_dbgfs_##name##_ops = {	\
-	.write = il_dbgfs_##name##_write,			\
-	.read = il_dbgfs_##name##_read,				\
+	.write_iter = il_dbgfs_##name##_write,			\
+	.read_iter = il_dbgfs_##name##_read,			\
 	.open = simple_open,					\
 	.llseek = generic_file_llseek,				\
 };
@@ -196,12 +194,10 @@ il_get_ctrl_string(int cmd)
 	}
 }
 
-static ssize_t
-il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_tx_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char *buf;
 	int pos = 0;
 
@@ -231,24 +227,23 @@ il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count,
 	pos +=
 	    scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
 		      il->tx_stats.data_bytes);
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
 static ssize_t
-il_dbgfs_clear_traffic_stats_write(struct file *file,
-				   const char __user *user_buf, size_t count,
-				   loff_t *ppos)
+il_dbgfs_clear_traffic_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 clear_flag;
 	char buf[8];
 	int buf_size;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%x", &clear_flag) != 1)
 		return -EFAULT;
@@ -257,12 +252,10 @@ il_dbgfs_clear_traffic_stats_write(struct file *file,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_rx_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char *buf;
 	int pos = 0;
 	int cnt;
@@ -293,7 +286,7 @@ il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count,
 	    scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n",
 		      il->rx_stats.data_bytes);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
@@ -301,16 +294,14 @@ il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count,
 #define BYTE1_MASK 0x000000ff;
 #define BYTE2_MASK 0x0000ffff;
 #define BYTE3_MASK 0x00ffffff;
-static ssize_t
-il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count,
-		   loff_t *ppos)
+static ssize_t il_dbgfs_sram_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u32 val;
 	char *buf;
 	ssize_t ret;
 	int i;
 	int pos = 0;
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	size_t bufsz;
 
 	/* default is to dump the entire data segment */
@@ -355,23 +346,22 @@ il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count,
 	}
 	pos += scnprintf(buf + pos, bufsz - pos, "\n");
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_sram_write(struct file *file, const char __user *user_buf,
-		    size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_sram_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[64];
 	int buf_size;
 	u32 offset, len;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
@@ -385,11 +375,9 @@ il_dbgfs_sram_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_stations_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	struct il_station_entry *station;
 	int max_sta = il->hw_params.max_stations;
 	char *buf;
@@ -444,17 +432,15 @@ il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count,
 		pos += scnprintf(buf + pos, bufsz - pos, "\n");
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count,
-		  loff_t *ppos)
+static ssize_t il_dbgfs_nvm_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0, ofs = 0, buf_size = 0;
 	const u8 *ptr;
 	char *buf;
@@ -488,16 +474,14 @@ il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count,
 				 ofs, ptr + ofs);
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_channels_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	struct ieee80211_channel *channels = NULL;
 	const struct ieee80211_supported_band *supp_band = NULL;
 	int pos = 0, i, bufsz = PAGE_SIZE;
@@ -567,17 +551,15 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count,
 				      flags & IEEE80211_CHAN_NO_IR ?
 				      "passive only" : "active/passive");
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count,
-		     loff_t *ppos)
+static ssize_t il_dbgfs_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char buf[512];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -630,15 +612,13 @@ il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count,
 	pos +=
 	    scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n",
 		      test_bit(S_FW_ERROR, &il->status));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t
-il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count,
-			loff_t *ppos)
+static ssize_t il_dbgfs_interrupt_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0;
 	int cnt = 0;
 	char *buf;
@@ -707,23 +687,23 @@ il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count,
 	    scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
 		      il->isr_stats.unhandled);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
 static ssize_t
-il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf,
-			 size_t count, loff_t *ppos)
+il_dbgfs_interrupt_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	u32 reset_flag;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%x", &reset_flag) != 1)
 		return -EFAULT;
@@ -733,11 +713,9 @@ il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count,
-		  loff_t *ppos)
+static ssize_t il_dbgfs_qos_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0, i;
 	char buf[256];
 	const size_t bufsz = sizeof(buf);
@@ -755,21 +733,21 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count,
 			      il->qos_data.def_qos_parm.ac[i].edca_txop);
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
-il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf,
-			    size_t count, loff_t *ppos)
+il_dbgfs_disable_ht40_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int ht40;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &ht40) != 1)
 		return -EFAULT;
@@ -784,11 +762,9 @@ il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf,
-			   size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_disable_ht40_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char buf[100];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -796,7 +772,7 @@ il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf,
 	pos +=
 	    scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n",
 		      il->disable_ht40 ? "Disabled" : "Enabled");
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 DEBUGFS_READ_WRITE_FILE_OPS(sram);
@@ -808,12 +784,10 @@ DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
 DEBUGFS_READ_FILE_OPS(qos);
 DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
 
-static ssize_t
-il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_tx_queue_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	struct il_tx_queue *txq;
 	struct il_queue *q;
 	char *buf;
@@ -850,17 +824,15 @@ il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count,
 			      "        stop-count: %d\n",
 			      atomic_read(&il->queue_stop_count[cnt]));
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count,
-		       loff_t *ppos)
+static ssize_t il_dbgfs_rx_queue_read(struct kiocb *iocb, struct iov_iter *to)
 {
 
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	struct il_rx_queue *rxq = &il->rxq;
 	char buf[256];
 	int pos = 0;
@@ -881,11 +853,11 @@ il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count,
 		    scnprintf(buf + pos, bufsz - pos,
 			      "closed_rb_num: Not Allocated\n");
 	}
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
-il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf,
+__il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf,
 			     size_t count, loff_t *ppos)
 {
 	struct il_priv *il = file->private_data;
@@ -893,30 +865,47 @@ il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf,
 	return il->debugfs_ops->rx_stats_read(file, user_buf, count, ppos);
 }
 
+static ssize_t il_dbgfs_ucode_rx_stats_read(struct kiocb *iocb,
+					    struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __il_dbgfs_ucode_rx_stats_read);
+}
+
 static ssize_t
-il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+__il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf,
+			       size_t count, loff_t *ppos)
 {
 	struct il_priv *il = file->private_data;
 
 	return il->debugfs_ops->tx_stats_read(file, user_buf, count, ppos);
 }
 
+static ssize_t il_dbgfs_ucode_tx_stats_read(struct kiocb *iocb,
+					    struct iov_iter *to)
+{
+	return vfs_read_iter(iocb, to, __il_dbgfs_ucode_tx_stats_read);
+}
+
 static ssize_t
-il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+__il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf,
+				    size_t count, loff_t *ppos)
 {
 	struct il_priv *il = file->private_data;
 
 	return il->debugfs_ops->general_stats_read(file, user_buf, count, ppos);
 }
 
-static ssize_t
-il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_ucode_general_stats_read(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
+	return vfs_read_iter(iocb, to, __il_dbgfs_ucode_general_stats_read);
+}
 
-	struct il_priv *il = file->private_data;
+
+static ssize_t il_dbgfs_sensitivity_read(struct kiocb *iocb, struct iov_iter *to)
+{
+
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0;
 	int cnt = 0;
 	char *buf;
@@ -1005,17 +994,14 @@ il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf,
 	    scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
 		      data->nrg_th_ofdm);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_chain_noise_read(struct kiocb *iocb, struct iov_iter *to)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0;
 	int cnt = 0;
 	char *buf;
@@ -1076,16 +1062,15 @@ il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf,
 	    scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
 		      data->state);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t
-il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_power_save_status_read(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char buf[60];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -1102,22 +1087,21 @@ il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf,
 		      (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
 		      "error");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
-il_dbgfs_clear_ucode_stats_write(struct file *file,
-				 const char __user *user_buf, size_t count,
-				 loff_t *ppos)
+il_dbgfs_clear_ucode_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int clear;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &clear) != 1)
 		return -EFAULT;
@@ -1130,38 +1114,31 @@ il_dbgfs_clear_ucode_stats_write(struct file *file,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf,
-			 size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_rxon_flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[20];
 
 	len = sprintf(buf, "0x%04X\n", le32_to_cpu(il->active.flags));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t
-il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+il_dbgfs_rxon_filter_flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[20];
 
 	len =
 	    sprintf(buf, "0x%04X\n", le32_to_cpu(il->active.filter_flags));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t
-il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count,
-		     loff_t *ppos)
+static ssize_t il_dbgfs_fh_reg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	char *buf;
 	int pos = 0;
 	ssize_t ret = -EFAULT;
@@ -1170,8 +1147,7 @@ il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count,
 		ret = pos = il->ops->dump_fh(il, &buf, true);
 		if (buf) {
 			ret =
-			    simple_read_from_buffer(user_buf, count, ppos, buf,
-						    pos);
+			    simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 			kfree(buf);
 		}
 	}
@@ -1180,11 +1156,9 @@ il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count,
 }
 
 static ssize_t
-il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf,
-			    size_t count, loff_t *ppos)
+il_dbgfs_missed_beacon_read(struct kiocb *iocb, struct iov_iter *to)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[12];
 	const size_t bufsz = sizeof(buf);
@@ -1193,21 +1167,21 @@ il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf,
 	    scnprintf(buf + pos, bufsz - pos, "%d\n",
 		      il->missed_beacon_threshold);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
-il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf,
-			     size_t count, loff_t *ppos)
+il_dbgfs_missed_beacon_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int missed;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &missed) != 1)
 		return -EINVAL;
@@ -1221,12 +1195,9 @@ il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t
-il_dbgfs_force_reset_read(struct file *file, char __user *user_buf,
-			  size_t count, loff_t *ppos)
+static ssize_t il_dbgfs_force_reset_read(struct kiocb *iocb, struct iov_iter *to)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[300];
 	const size_t bufsz = sizeof(buf);
@@ -1249,35 +1220,32 @@ il_dbgfs_force_reset_read(struct file *file, char __user *user_buf,
 	    scnprintf(buf + pos, bufsz - pos, "\treset duration: %lu\n",
 		      force_reset->reset_duration);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
-il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+il_dbgfs_force_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
 	int ret;
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
 
 	ret = il_force_reset(il, true);
 
-	return ret ? ret : count;
+	return ret ? ret : iov_iter_count(from);
 }
 
 static ssize_t
-il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf,
-			  size_t count, loff_t *ppos)
+il_dbgfs_wd_timeout_write(struct kiocb *iocb, struct iov_iter *from)
 {
-
-	struct il_priv *il = file->private_data;
+	struct il_priv *il = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int timeout;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &timeout) != 1)
 		return -EINVAL;
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
index b246dbd371b3..b2ff6164fbcb 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
@@ -27,14 +27,14 @@
 /* file operation */
 #define DEBUGFS_READ_FILE_OPS(name)                                     \
 static const struct file_operations iwl_dbgfs_##name##_ops = {          \
-	.read = iwl_dbgfs_##name##_read,				\
+	.read_iter = iwl_dbgfs_##name##_read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
 
 #define DEBUGFS_WRITE_FILE_OPS(name)                                    \
 static const struct file_operations iwl_dbgfs_##name##_ops = {          \
-	.write = iwl_dbgfs_##name##_write,                              \
+	.write_iter = iwl_dbgfs_##name##_write,                         \
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
@@ -42,15 +42,13 @@ static const struct file_operations iwl_dbgfs_##name##_ops = {          \
 
 #define DEBUGFS_READ_WRITE_FILE_OPS(name)                               \
 static const struct file_operations iwl_dbgfs_##name##_ops = {          \
-	.write = iwl_dbgfs_##name##_write,                              \
-	.read = iwl_dbgfs_##name##_read,                                \
+	.write_iter = iwl_dbgfs_##name##_write,                         \
+	.read_iter = iwl_dbgfs_##name##_read,                           \
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
 
-static ssize_t iwl_dbgfs_sram_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sram_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u32 val = 0;
 	char *buf;
@@ -61,7 +59,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
 	int len = 0;
 	int pos = 0;
 	int sram;
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	const struct fw_img *img;
 	size_t bufsz;
 
@@ -133,23 +131,22 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
 	if (i)
 		pos += scnprintf(buf + pos, bufsz - pos, "\n");
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_sram_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sram_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[64];
 	int buf_size;
 	u32 offset, len;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x,%x", &offset, &len) == 2) {
@@ -166,24 +163,21 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_wowlan_sram_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_wowlan_sram_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	const struct fw_img *img = &priv->fw->img[IWL_UCODE_WOWLAN];
 
 	if (!priv->wowlan_sram)
 		return -ENODATA;
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       priv->wowlan_sram,
-				       img->sec[IWL_UCODE_SECTION_DATA].len);
+	return simple_copy_to_iter(priv->wowlan_sram, &iocb->ki_pos,
+				   img->sec[IWL_UCODE_SECTION_DATA].len, to);
 }
-static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_stations_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	struct iwl_station_entry *station;
 	struct iwl_tid_data *tid_data;
 	char *buf;
@@ -231,18 +225,15 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
 		pos += scnprintf(buf + pos, bufsz - pos, "\n");
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_nvm_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count,
-				       loff_t *ppos)
+static ssize_t iwl_dbgfs_nvm_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0, ofs = 0, buf_size = 0;
 	const u8 *ptr;
 	char *buf;
@@ -270,15 +261,14 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
 				 ofs, ptr + ofs);
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_channels_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	struct ieee80211_channel *channels = NULL;
 	const struct ieee80211_supported_band *supp_band = NULL;
 	int pos = 0, i, bufsz = PAGE_SIZE;
@@ -335,16 +325,14 @@ static ssize_t iwl_dbgfs_channels_read(struct file *file, char __user *user_buf,
 					IEEE80211_CHAN_NO_IR ?
 					"passive only" : "active/passive");
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_status_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_status_read(struct kiocb *iocb, struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[512];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -371,14 +359,13 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
 		test_bit(STATUS_POWER_PMI, &priv->status));
 	pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
 		test_bit(STATUS_FW_ERROR, &priv->status));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_rx_handlers_read(struct kiocb *iocb,
+					  struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 
 	int pos = 0;
 	int cnt = 0;
@@ -398,24 +385,23 @@ static ssize_t iwl_dbgfs_rx_handlers_read(struct file *file,
 				priv->rx_handlers_stats[cnt]);
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rx_handlers_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
-
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	u32 reset_flag;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%x", &reset_flag) != 1)
 		return -EFAULT;
@@ -426,10 +412,9 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_qos_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	struct iwl_rxon_context *ctx;
 	int pos = 0, i;
 	char buf[256 * NUM_IWL_RXON_CTX];
@@ -450,14 +435,13 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
 		}
 		pos += scnprintf(buf + pos, bufsz - pos, "\n");
 	}
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
-				char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_thermal_throttling_read(struct kiocb *iocb,
+				struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
 	struct iwl_tt_restriction *restriction;
 	char buf[100];
@@ -482,21 +466,21 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
 				"HT mode: %d\n",
 				restriction->is_ht);
 	}
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_disable_ht40_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int ht40;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &ht40) != 1)
 		return -EFAULT;
@@ -508,11 +492,10 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_disable_ht40_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[100];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -520,35 +503,34 @@ static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos,
 			"11n 40MHz Mode: %s\n",
 			priv->disable_ht40 ? "Disabled" : "Enabled");
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_temperature_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_temperature_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[8];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
 
 	pos += scnprintf(buf + pos, bufsz - pos, "%d\n", priv->temperature);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 
-static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
-						    const char __user *user_buf,
-						    size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sleep_level_override_write(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int value;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%d", &value) != 1)
@@ -579,11 +561,10 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
-						   char __user *user_buf,
-						   size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sleep_level_override_read(struct kiocb *iocb,
+						   struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[10];
 	int pos, value;
 	const size_t bufsz = sizeof(buf);
@@ -594,14 +575,13 @@ static ssize_t iwl_dbgfs_sleep_level_override_read(struct file *file,
 		value += 1;
 
 	pos = scnprintf(buf, bufsz, "%d\n", value);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
-						    char __user *user_buf,
-						    size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_current_sleep_command_read(struct kiocb *iocb,
+						    struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[200];
 	int pos = 0, i;
 	const size_t bufsz = sizeof(buf);
@@ -618,7 +598,7 @@ static ssize_t iwl_dbgfs_current_sleep_command_read(struct file *file,
 				 "sleep_interval[%d]: %d\n", i,
 				 le32_to_cpu(cmd->sleep_interval[i]));
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 DEBUGFS_READ_WRITE_FILE_OPS(sram);
@@ -663,11 +643,10 @@ static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
 	return p;
 }
 
-static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char *buf;
 	int bufsz = sizeof(struct statistics_rx_phy) * 40 +
@@ -1091,16 +1070,15 @@ static ssize_t iwl_dbgfs_ucode_rx_stats_read(struct file *file,
 
 	spin_unlock_bh(&priv->statistics.lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char *buf;
 	int bufsz = (sizeof(struct statistics_tx) * 48) + 250;
@@ -1288,16 +1266,15 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
 
 	spin_unlock_bh(&priv->statistics.lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ucode_general_stats_read(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char *buf;
 	int bufsz = sizeof(struct statistics_general) * 10 + 300;
@@ -1408,16 +1385,15 @@ static ssize_t iwl_dbgfs_ucode_general_stats_read(struct file *file,
 
 	spin_unlock_bh(&priv->statistics.lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char *buf;
 	int bufsz = (sizeof(struct statistics_bt_activity) * 24) + 200;
@@ -1496,16 +1472,15 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
 
 	spin_unlock_bh(&priv->statistics.lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_reply_tx_error_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char *buf;
 	int bufsz = (sizeof(struct reply_tx_error_statistics) * 24) +
@@ -1638,16 +1613,15 @@ static ssize_t iwl_dbgfs_reply_tx_error_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "UNKNOWN:\t\t\t%u\n",
 			 priv->reply_agg_tx_stats.unknown);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_sensitivity_read(struct kiocb *iocb,
+					  struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	int cnt = 0;
 	char *buf;
@@ -1716,17 +1690,16 @@ static ssize_t iwl_dbgfs_sensitivity_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n",
 			data->nrg_th_ofdm);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
 
-static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_chain_noise_read(struct kiocb *iocb,
+					  struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	int cnt = 0;
 	char *buf;
@@ -1773,16 +1746,15 @@ static ssize_t iwl_dbgfs_chain_noise_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n",
 			data->state);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
-						    char __user *user_buf,
-						    size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_power_save_status_read(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[60];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -1798,21 +1770,21 @@ static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
 		(pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" :
 		"error");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct kiocb *iocb,
+						      struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int clear;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &clear) != 1)
 		return -EFAULT;
@@ -1825,11 +1797,10 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_ucode_tracing_read(struct kiocb *iocb,
+					    struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[128];
 	const size_t bufsz = sizeof(buf);
@@ -1843,21 +1814,21 @@ static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
 			priv->event_log.wraps_more_count);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ucode_tracing_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int trace;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &trace) != 1)
 		return -EFAULT;
@@ -1876,37 +1847,34 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_rxon_flags_read(struct kiocb *iocb,
+					 struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[20];
 
 	len = sprintf(buf, "0x%04X\n",
 		le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct kiocb *iocb,
+						struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[20];
 
 	len = sprintf(buf, "0x%04X\n",
 		le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_missed_beacon_read(struct kiocb *iocb,
+					    struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[12];
 	const size_t bufsz = sizeof(buf);
@@ -1914,21 +1882,21 @@ static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
 			priv->missed_beacon_threshold);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_missed_beacon_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int missed;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &missed) != 1)
 		return -EINVAL;
@@ -1943,11 +1911,10 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_plcp_delta_read(struct kiocb *iocb,
+					 struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[12];
 	const size_t bufsz = sizeof(buf);
@@ -1955,21 +1922,21 @@ static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
 			priv->plcp_delta_threshold);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_plcp_delta_write(struct kiocb *iocb,
+					  struct iov_iter *from)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int plcp;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &plcp) != 1)
 		return -EINVAL;
@@ -1982,11 +1949,9 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rf_reset_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[300];
 	const size_t bufsz = sizeof(buf);
@@ -2004,32 +1969,32 @@ static ssize_t iwl_dbgfs_rf_reset_read(struct file *file,
 			"\tnumber of reset request reject: %d\n",
 			rf_reset->reset_reject_count);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_rf_reset_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_rf_reset_write(struct kiocb *iocb,
+					struct iov_iter *from)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	ret = iwl_force_rf_reset(priv, true);
 	return ret ? ret : count;
 }
 
-static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_txfifo_flush_write(struct kiocb *iocb,
+					    struct iov_iter *from)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int flush;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &flush) != 1)
 		return -EINVAL;
@@ -2042,18 +2007,16 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+static ssize_t iwl_dbgfs_bt_traffic_read(struct kiocb *iocb, struct iov_iter *to)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[200];
 	const size_t bufsz = sizeof(buf);
 
 	if (!priv->bt_enable_flag) {
 		pos += scnprintf(buf + pos, bufsz - pos, "BT coex disabled\n");
-		return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+		return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	}
 	pos += scnprintf(buf + pos, bufsz - pos, "BT enable flag: 0x%x\n",
 		priv->bt_enable_flag);
@@ -2084,14 +2047,13 @@ static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
 		break;
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_protection_mode_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 
 	int pos = 0;
 	char buf[40];
@@ -2105,14 +2067,14 @@ static ssize_t iwl_dbgfs_protection_mode_read(struct file *file,
 	else
 		pos += scnprintf(buf + pos, bufsz - pos, "N/A");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos) {
-
-	struct iwl_priv *priv = file->private_data;
+static ssize_t iwl_dbgfs_protection_mode_write(struct kiocb *iocb,
+					       struct iov_iter *from)
+{
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 	int rts;
@@ -2122,7 +2084,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%d", &rts) != 1)
 		return -EINVAL;
@@ -2149,17 +2111,17 @@ static int iwl_cmd_echo_test(struct iwl_priv *priv)
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_echo_test_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	int buf_size;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	iwl_cmd_echo_test(priv);
@@ -2167,26 +2129,24 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
 }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-static ssize_t iwl_dbgfs_log_event_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_log_event_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char *buf = NULL;
 	ssize_t ret;
 
 	ret = iwl_dump_nic_event_log(priv, true, &buf);
 	if (ret > 0)
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+		ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_log_event_write(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_log_event_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 event_log_flag;
 	char buf[8];
 	int buf_size;
@@ -2197,7 +2157,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%u", &event_log_flag) != 1)
 		return -EFAULT;
@@ -2208,11 +2168,10 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
 }
 #endif
 
-static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_calib_disabled_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
 	char buf[120];
 	int pos = 0;
 	const size_t bufsz = sizeof(buf);
@@ -2233,21 +2192,21 @@ static ssize_t iwl_dbgfs_calib_disabled_read(struct file *file,
 					IWL_TX_POWER_CALIB_DISABLED) ?
 			 "DISABLED" : "ENABLED");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_calib_disabled_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[8];
 	u32 calib_disabled;
 	int buf_size;
 
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%x", &calib_disabled) != 1)
 		return -EFAULT;
@@ -2257,11 +2216,11 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_fw_restart_write(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_fw_restart_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct iwl_priv *priv = file->private_data;
+	struct iwl_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool fw_restart = iwlwifi_mod_params.fw_restart;
 	int __maybe_unused ret;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
index f4a6f76cf193..64ef58cc2bc0 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/rs.c
@@ -3037,20 +3037,20 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
 	}
 }
 
-static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
-			const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_scale_table_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct iwl_priv *priv;
 	char buf[64];
 	size_t buf_size;
 	u32 parsed_rate;
 
-
 	priv = lq_sta->drv;
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x", &parsed_rate) == 1)
@@ -3063,8 +3063,8 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
 	return count;
 }
 
-static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
-			char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_scale_table_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
@@ -3089,7 +3089,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
 		{ "60", "64QAM 5/6"},
 	};
 
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct iwl_priv *priv;
 	struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
 
@@ -3160,26 +3160,26 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
 		}
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
-	.write = rs_sta_dbgfs_scale_table_write,
-	.read = rs_sta_dbgfs_scale_table_read,
+	.write_iter = rs_sta_dbgfs_scale_table_write,
+	.read_iter = rs_sta_dbgfs_scale_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
-static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
-			char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_stats_table_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
 	int i, j;
 	ssize_t ret;
 
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -3204,21 +3204,21 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
 				lq_sta->lq_info[i].win[j].success_ratio);
 		}
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = rs_sta_dbgfs_stats_table_read,
+	.read_iter = rs_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
-			char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl];
 	char buff[120];
 	int desc = 0;
@@ -3232,11 +3232,11 @@ static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
 				"Bit Rate= %d Mb/s\n",
 				iwl_rates[lq_sta->last_txrate_idx].ieee >> 1);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
 static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
-	.read = rs_sta_dbgfs_rate_scale_data_read,
+	.read_iter = rs_sta_dbgfs_rate_scale_data_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
index 751a125a1566..7378c6fed447 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c
@@ -33,10 +33,10 @@ static int _iwl_dbgfs_##name##_open(struct inode *inode,		\
 }
 
 #define FWRT_DEBUGFS_READ_WRAPPER(name)					\
-static ssize_t _iwl_dbgfs_##name##_read(struct file *file,		\
-					char __user *user_buf,		\
-					size_t count, loff_t *ppos)	\
+static ssize_t _iwl_dbgfs_##name##_read(struct kiocb *iocb,		\
+					struct iov_iter *to)		\
 {									\
+	struct file *file = iocb->ki_filp;				\
 	struct dbgfs_##name##_data *data = file->private_data;		\
 									\
 	if (!data->read_done) {						\
@@ -48,8 +48,8 @@ static ssize_t _iwl_dbgfs_##name##_read(struct file *file,		\
 									\
 	if (data->rlen < 0)						\
 		return data->rlen;					\
-	return simple_read_from_buffer(user_buf, count, ppos,		\
-				       data->rbuf, data->rlen);		\
+	return simple_copy_to_iter(data->rbuf, &iocb->ki_pos,		\
+					data->rlen, to);		\
 }
 
 static int _iwl_dbgfs_release(struct inode *inode, struct file *file)
@@ -63,7 +63,7 @@ static int _iwl_dbgfs_release(struct inode *inode, struct file *file)
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_READ_WRAPPER(name)						\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.read = _iwl_dbgfs_##name##_read,				\
+	.read_iter = _iwl_dbgfs_##name##_read,				\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -83,15 +83,16 @@ static ssize_t _iwl_dbgfs_##name##_write(struct file *file,		\
 		return -EFAULT;						\
 									\
 	return iwl_dbgfs_##name##_write(arg, buf, buf_size);		\
-}
+}									\
+FOPS_WRITE_ITER_HELPER(_iwl_dbgfs_##name##_write);			\
 
 #define _FWRT_DEBUGFS_READ_WRITE_FILE_OPS(name, buflen, argtype)	\
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_READ_WRAPPER(name)						\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
-	.read = _iwl_dbgfs_##name##_read,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
+	.read_iter = _iwl_dbgfs_##name##_read,				\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -101,7 +102,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = {		\
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -391,7 +392,7 @@ static int iwl_dbgfs_fw_info_open(struct inode *inode, struct file *filp)
 static const struct file_operations iwl_dbgfs_fw_info_ops = {
 	.owner = THIS_MODULE,
 	.open = iwl_dbgfs_fw_info_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index 1dd9106c6513..5ad9530659be 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -1849,9 +1849,8 @@ EXPORT_SYMBOL_GPL(iwl_mei_unregister_complete);
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 
 static ssize_t
-iwl_mei_dbgfs_send_start_message_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+iwl_mei_dbgfs_send_start_message_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	int ret;
 
@@ -1866,26 +1865,25 @@ iwl_mei_dbgfs_send_start_message_write(struct file *file,
 
 out:
 	mutex_unlock(&iwl_mei_mutex);
-	return ret ?: count;
+	return ret ?: iov_iter_count(from);
 }
 
 static const struct file_operations iwl_mei_dbgfs_send_start_message_ops = {
-	.write = iwl_mei_dbgfs_send_start_message_write,
+	.write_iter = iwl_mei_dbgfs_send_start_message_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t iwl_mei_dbgfs_req_ownership_write(struct file *file,
-						 const char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t iwl_mei_dbgfs_req_ownership_write(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
 	iwl_mei_get_ownership();
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations iwl_mei_dbgfs_req_ownership_ops = {
-	.write = iwl_mei_dbgfs_req_ownership_write,
+	.write_iter = iwl_mei_dbgfs_req_ownership_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index 52518a47554e..1d911bbef018 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -3405,10 +3405,9 @@ static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t iwl_mvm_d3_test_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	unsigned long end = jiffies + 60 * HZ;
 	u32 pme_asserted;
 
@@ -3492,7 +3491,7 @@ static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
 const struct file_operations iwl_dbgfs_d3_test_ops = {
 	.llseek = no_llseek,
 	.open = iwl_mvm_d3_test_open,
-	.read = iwl_mvm_d3_test_read,
+	.read_iter = iwl_mvm_d3_test_read,
 	.release = iwl_mvm_d3_test_release,
 };
 #endif
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 7fe57ecd0682..ea93054caf5a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -132,11 +132,10 @@ static ssize_t iwl_dbgfs_pm_params_write(struct ieee80211_vif *vif, char *buf,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_tx_pwr_lmt_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_tx_pwr_lmt_read_iter(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	char buf[64];
 	int bufsz = sizeof(buf);
 	int pos;
@@ -144,14 +143,13 @@ static ssize_t iwl_dbgfs_tx_pwr_lmt_read(struct file *file,
 	pos = scnprintf(buf, bufsz, "bss limit = %d\n",
 			vif->bss_conf.txpower);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_pm_params_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_pm_params_read_iter(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct iwl_mvm *mvm = mvmvif->mvm;
 	char buf[512];
@@ -160,14 +158,13 @@ static ssize_t iwl_dbgfs_pm_params_read(struct file *file,
 
 	pos = iwl_mvm_power_mac_dbgfs_read(mvm, vif, buf, bufsz);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_mac_params_read_iter(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct iwl_mvm *mvm = mvmvif->mvm;
 	u8 ap_sta_id;
@@ -244,7 +241,7 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
 
 	mutex_unlock(&mvm->mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static void iwl_dbgfs_update_bf(struct ieee80211_vif *vif,
@@ -389,11 +386,10 @@ static ssize_t iwl_dbgfs_bf_params_write(struct ieee80211_vif *vif, char *buf,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_bf_params_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_bf_params_read_iter(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	char buf[256];
 	int pos = 0;
@@ -435,14 +431,13 @@ static ssize_t iwl_dbgfs_bf_params_read(struct file *file,
 	pos += scnprintf(buf+pos, bufsz-pos, "ba_enable_beacon_abort = %d\n",
 			 le32_to_cpu(cmd.ba_enable_beacon_abort));
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
-						 char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_os_device_timediff_read_iter(struct kiocb *iocb,
+						      struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct iwl_mvm *mvm = mvmvif->mvm;
 	u32 curr_gp2;
@@ -460,7 +455,7 @@ static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
 	diff = curr_os - curr_gp2;
 	pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_low_latency_write(struct ieee80211_vif *vif, char *buf,
@@ -517,11 +512,10 @@ iwl_dbgfs_low_latency_force_write(struct ieee80211_vif *vif, char *buf,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_low_latency_read_iter(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	char format[] = "traffic=%d\ndbgfs=%d\nvcmd=%d\nvif_type=%d\n"
 			"dbgfs_force_enable=%d\ndbgfs_force=%d\nactual=%d\n";
@@ -542,20 +536,19 @@ static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
 			   LOW_LATENCY_DEBUGFS_FORCE_ENABLE),
 			!!(mvmvif->low_latency & LOW_LATENCY_DEBUGFS_FORCE),
 			!!(mvmvif->low_latency_actual));
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t iwl_dbgfs_uapsd_misbehaving_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_uapsd_misbehaving_read_iter(struct kiocb *iocb,
+						     struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	char buf[20];
 	int len;
 
 	len = sprintf(buf, "%pM\n", mvmvif->uapsd_misbehaving_ap_addr);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t iwl_dbgfs_uapsd_misbehaving_write(struct ieee80211_vif *vif,
@@ -624,11 +617,10 @@ static ssize_t iwl_dbgfs_rx_phyinfo_write(struct ieee80211_vif *vif, char *buf,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_rx_phyinfo_read(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rx_phyinfo_read_iter(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	char buf[8];
 	int len;
@@ -636,7 +628,7 @@ static ssize_t iwl_dbgfs_rx_phyinfo_read(struct file *file,
 	len = scnprintf(buf, sizeof(buf), "0x%04x\n",
 			mvmvif->mvm->dbgfs_rx_phyinfo);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static void iwl_dbgfs_quota_check(void *data, u8 *mac,
@@ -678,18 +670,17 @@ static ssize_t iwl_dbgfs_quota_min_write(struct ieee80211_vif *vif, char *buf,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_quota_min_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_quota_min_read_iter(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_vif *vif = file->private_data;
+	struct ieee80211_vif *vif = iocb->ki_filp->private_data;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	char buf[10];
 	int len;
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 #define MVM_DEBUGFS_WRITE_FILE_OPS(name, bufsz) \
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 79f4ac8cbc72..af0cc36aac13 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -19,11 +19,10 @@
 #include "fw/error-dump.h"
 #include "fw/api/phy-ctxt.h"
 
-static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ctdp_budget_read_iter(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char buf[16];
 	int pos, budget;
 
@@ -43,7 +42,7 @@ static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
 
 	pos = scnprintf(buf, sizeof(buf), "%d\n", budget);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
@@ -182,10 +181,9 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sram_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	const struct fw_img *img;
 	unsigned int ofs, len;
 	size_t ret;
@@ -210,7 +208,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
 
 	iwl_trans_read_mem_bytes(mvm->trans, ofs, ptr, len);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, ptr, len);
+	ret = simple_copy_to_iter(ptr, &iocb->ki_pos, len, to);
 
 	kfree(ptr);
 
@@ -248,11 +246,10 @@ static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
-						  char __user *user_buf,
-						  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_set_nic_temperature_read_iter(struct kiocb *iocb,
+						       struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char buf[16];
 	int pos;
 
@@ -261,7 +258,7 @@ static ssize_t iwl_dbgfs_set_nic_temperature_read(struct file *file,
 	else
 		pos = scnprintf(buf, sizeof(buf), "%d\n", mvm->temperature);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 /*
@@ -315,11 +312,10 @@ static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_nic_temp_read_iter(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char buf[16];
 	int pos, ret;
 	s32 temp;
@@ -336,15 +332,14 @@ static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
 
 	pos = scnprintf(buf, sizeof(buf), "%d\n", temp);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 #ifdef CONFIG_ACPI
-static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_sar_geo_profile_read_iter(struct kiocb *iocb,
+						   struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char buf[256];
 	int pos = 0;
 	int bufsz = sizeof(buf);
@@ -379,14 +374,13 @@ static ssize_t iwl_dbgfs_sar_geo_profile_read(struct file *file,
 	}
 	mutex_unlock(&mvm->mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_wifi_6e_enable_read(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_wifi_6e_enable_read_iter(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	int err, pos;
 	char buf[12];
 	u32 value;
@@ -397,14 +391,14 @@ static ssize_t iwl_dbgfs_wifi_6e_enable_read(struct file *file,
 
 	pos = sprintf(buf, "0x%08x\n", value);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 #endif
 
-static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_stations_read_iter(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct ieee80211_sta *sta;
 	char buf[400];
 	int i, pos = 0, bufsz = sizeof(buf);
@@ -427,7 +421,7 @@ static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&mvm->mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_rs_data_read(struct ieee80211_link_sta *link_sta,
@@ -524,11 +518,10 @@ static ssize_t iwl_dbgfs_amsdu_len_read(struct ieee80211_link_sta *link_sta,
 	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
 }
 
-static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_disable_power_off_read_iter(struct kiocb *iocb,
+						     struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char buf[64];
 	int bufsz = sizeof(buf);
 	int pos = 0;
@@ -538,7 +531,7 @@ static ssize_t iwl_dbgfs_disable_power_off_read(struct file *file,
 	pos += scnprintf(buf+pos, bufsz-pos, "disable_power_off_d3=%d\n",
 			 mvm->disable_power_off_d3);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
@@ -628,10 +621,10 @@ int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf,
 	return pos;
 }
 
-static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_bt_notif_read_iter(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif;
 	char *buf;
 	int ret, pos = 0, bufsz = sizeof(char) * 1024;
@@ -665,17 +658,17 @@ static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&mvm->mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 
 	return ret;
 }
 #undef BT_MBOX_PRINT
 
-static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_bt_cmd_read_iter(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd;
 	char buf[256];
 	int bufsz = sizeof(buf);
@@ -693,7 +686,7 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&mvm->mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
@@ -748,10 +741,10 @@ iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_fw_ver_read_iter(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char *buff, *pos, *endpos;
 	static const size_t bufsz = 1024;
 	char _fw_name_pre[FW_NAME_PRE_BUFSIZE];
@@ -773,17 +766,16 @@ static ssize_t iwl_dbgfs_fw_ver_read(struct file *file, char __user *user_buf,
 	pos += scnprintf(pos, endpos - pos, "Bus: %s\n",
 			 mvm->fwrt.dev->bus->name);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, pos - buff, to);
 	kfree(buff);
 
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_tas_get_status_read(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_tas_get_status_read_iter(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct iwl_mvm_tas_status_resp tas_rsp;
 	struct iwl_mvm_tas_status_resp *rsp = &tas_rsp;
 	static const size_t bufsz = 1024;
@@ -957,17 +949,16 @@ static ssize_t iwl_dbgfs_tas_get_status_read(struct file *file,
 	}
 
 out:
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, pos - buff, to);
 	kfree(buff);
 	iwl_free_resp(&hcmd);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_phy_integration_ver_read(struct file *file,
-						  char __user *user_buf,
-						  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_phy_integration_ver_read_iter(struct kiocb *iocb,
+						       struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	char *buf;
 	size_t bufsz;
 	int pos;
@@ -981,7 +972,7 @@ static ssize_t iwl_dbgfs_phy_integration_ver_read(struct file *file,
 	pos = scnprintf(buf, bufsz, "%.*s\n", mvm->fw->phy_integration_ver_len,
 			mvm->fw->phy_integration_ver);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 
 	kfree(buf);
 	return ret;
@@ -992,11 +983,10 @@ static ssize_t iwl_dbgfs_phy_integration_ver_read(struct file *file,
 					  fmt_table, #_memb,		\
 					  le32_to_cpu(_struct->_memb))
 
-static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
-					  char __user *user_buf, size_t count,
-					  loff_t *ppos)
+static ssize_t iwl_dbgfs_fw_rx_stats_read_iter(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	static const char *fmt_table = "\t%-30s %10u\n";
 	static const char *fmt_header = "%-32s\n";
 	int pos = 0;
@@ -1182,16 +1172,15 @@ static ssize_t iwl_dbgfs_fw_rx_stats_read(struct file *file,
 
 	mutex_unlock(&mvm->mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 
 	return ret;
 }
 #undef PRINT_STAT_LE32
 
-static ssize_t iwl_dbgfs_fw_system_stats_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_fw_system_stats_read_iter(struct kiocb *iocb,
+						   struct iov_iter *to)
 {
 	char *buff, *pos, *endpos;
 	int ret;
@@ -1199,7 +1188,7 @@ static ssize_t iwl_dbgfs_fw_system_stats_read(struct file *file,
 	int i;
 	struct iwl_mvm_vif *mvmvif;
 	struct ieee80211_vif *vif;
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
 					   WIDE_ID(SYSTEM_GROUP,
 						   SYSTEM_STATISTICS_CMD),
@@ -1278,7 +1267,7 @@ static ssize_t iwl_dbgfs_fw_system_stats_read(struct file *file,
 	mutex_unlock(&mvm->mutex);
 
 send_out:
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, pos - buff, to);
 	kfree(buff);
 
 	return ret;
@@ -1360,6 +1349,7 @@ static ssize_t iwl_dbgfs_drv_rx_stats_read(struct file *file,
 	return iwl_dbgfs_frame_stats_read(mvm, user_buf, count, ppos,
 					  &mvm->drv_rx_stats);
 }
+FOPS_READ_ITER_HELPER(iwl_dbgfs_drv_rx_stats_read);
 
 static ssize_t iwl_dbgfs_fw_restart_write(struct iwl_mvm *mvm, char *buf,
 					  size_t count, loff_t *ppos)
@@ -1405,11 +1395,9 @@ static ssize_t iwl_dbgfs_fw_nmi_write(struct iwl_mvm *mvm, char *buf,
 }
 
 static ssize_t
-iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
-				char __user *user_buf,
-				size_t count, loff_t *ppos)
+iwl_dbgfs_scan_ant_rxchain_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[32];
 	const size_t bufsz = sizeof(buf);
@@ -1422,7 +1410,7 @@ iwl_dbgfs_scan_ant_rxchain_read(struct file *file,
 		pos += scnprintf(buf + pos, bufsz - pos, "B");
 	pos += scnprintf(buf + pos, bufsz - pos, " (%x)\n", mvm->scan_rx_ant);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
@@ -1653,11 +1641,10 @@ static ssize_t iwl_dbgfs_inject_beacon_ie_restore_write(struct iwl_mvm *mvm,
 	return ret ?: count;
 }
 
-static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_fw_dbg_conf_read_iter(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	int conf;
 	char buf[8];
 	const size_t bufsz = sizeof(buf);
@@ -1669,7 +1656,7 @@ static ssize_t iwl_dbgfs_fw_dbg_conf_read(struct file *file,
 
 	pos += scnprintf(buf + pos, bufsz - pos, "%d\n", conf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_fw_dbg_conf_write(struct iwl_mvm *mvm,
@@ -1834,6 +1821,7 @@ static ssize_t _iwl_dbgfs_link_sta_##name##_write(struct file *file,	\
 					      file,			\
 					      buf, buf_size, ppos);	\
 }									\
+FOPS_WRITE_ITER_HELPER(_iwl_dbgfs_link_sta_##name##_write);		\
 
 #define MVM_DEBUGFS_LINK_STA_READ_WRAPPER(name)		\
 static ssize_t _iwl_dbgfs_link_sta_##name##_read(struct file *file,	\
@@ -1844,11 +1832,12 @@ static ssize_t _iwl_dbgfs_link_sta_##name##_read(struct file *file,	\
 					     file,			\
 					     user_buf, count, ppos);	\
 }									\
+FOPS_READ_ITER_HELPER(_iwl_dbgfs_link_sta_##name##_read);		\
 
 #define MVM_DEBUGFS_WRITE_LINK_STA_FILE_OPS(name, bufsz)		\
 MVM_DEBUGFS_LINK_STA_WRITE_WRAPPER(name, bufsz)				\
 static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
-	.write = _iwl_dbgfs_link_sta_##name##_write,			\
+	.write_iter = _iwl_dbgfs_link_sta_##name##_write_iter,		\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -1856,7 +1845,7 @@ static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
 #define MVM_DEBUGFS_READ_LINK_STA_FILE_OPS(name)			\
 MVM_DEBUGFS_LINK_STA_READ_WRAPPER(name)					\
 static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
-	.read = _iwl_dbgfs_link_sta_##name##_read,			\
+	.read_iter = _iwl_dbgfs_link_sta_##name##_read_iter,		\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -1865,8 +1854,8 @@ static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
 MVM_DEBUGFS_LINK_STA_READ_WRAPPER(name)					\
 MVM_DEBUGFS_LINK_STA_WRITE_WRAPPER(name, bufsz)				\
 static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
-	.read = _iwl_dbgfs_link_sta_##name##_read,			\
-	.write = _iwl_dbgfs_link_sta_##name##_write,			\
+	.read_iter = _iwl_dbgfs_link_sta_##name##_read_iter,		\
+	.write_iter = _iwl_dbgfs_link_sta_##name##_write_iter,		\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -1878,11 +1867,9 @@ static const struct file_operations iwl_dbgfs_link_sta_##name##_ops = {	\
 	MVM_DEBUGFS_ADD_LINK_STA_FILE_ALIAS(#name, name, parent, mode)
 
 static ssize_t
-iwl_dbgfs_prph_reg_read(struct file *file,
-			char __user *user_buf,
-			size_t count, loff_t *ppos)
+iwl_dbgfs_prph_reg_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	int pos = 0;
 	char buf[32];
 	const size_t bufsz = sizeof(buf);
@@ -1894,7 +1881,7 @@ iwl_dbgfs_prph_reg_read(struct file *file,
 		mvm->dbgfs_prph_reg_addr,
 		iwl_read_prph(mvm->trans, mvm->dbgfs_prph_reg_addr));
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
@@ -2012,10 +1999,9 @@ iwl_dbgfs_he_sniffer_params_write(struct iwl_mvm *mvm, char *buf,
 }
 
 static ssize_t
-iwl_dbgfs_he_sniffer_params_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+iwl_dbgfs_he_sniffer_params_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	u8 buf[32];
 	int len;
 
@@ -2025,14 +2011,13 @@ iwl_dbgfs_he_sniffer_params_read(struct file *file, char __user *user_buf,
 			mvm->cur_bssid[1], mvm->cur_bssid[2], mvm->cur_bssid[3],
 			mvm->cur_bssid[4], mvm->cur_bssid[5]);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t
-iwl_dbgfs_uapsd_noagg_bssids_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+iwl_dbgfs_uapsd_noagg_bssids_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	u8 buf[IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM * ETH_ALEN * 3 + 1];
 	unsigned int pos = 0;
 	size_t bufsz = sizeof(buf);
@@ -2046,7 +2031,7 @@ iwl_dbgfs_uapsd_noagg_bssids_read(struct file *file, char __user *user_buf,
 
 	mutex_unlock(&mvm->mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t
@@ -2110,11 +2095,10 @@ static ssize_t iwl_dbgfs_rfi_freq_table_write(struct iwl_mvm *mvm, char *buf,
 #define IWL_RFI_BUF_SIZE (IWL_RFI_LUT_INSTALLED_SIZE *\
 				(5 + IWL_RFI_LUT_ENTRY_CHANNELS_NUM * (6 + 5)))
 
-static ssize_t iwl_dbgfs_rfi_freq_table_read(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rfi_freq_table_read_iter(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct iwl_rfi_freq_table_resp_cmd *resp;
 	u32 status;
 	char buf[IWL_RFI_BUF_SIZE];
@@ -2144,7 +2128,7 @@ static ssize_t iwl_dbgfs_rfi_freq_table_read(struct file *file,
 
 out:
 	kfree(resp);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(prph_reg, 64);
@@ -2200,12 +2184,12 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(he_sniffer_params, 32);
 MVM_DEBUGFS_WRITE_FILE_OPS(ltr_config, 512);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(rfi_freq_table, 16);
 
-static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	struct iwl_dbg_mem_access_cmd cmd = {};
 	struct iwl_dbg_mem_access_rsp *rsp;
+	size_t count = iov_iter_count(to);
 	struct iwl_host_cmd hcmd = {
 		.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
 		.data = { &cmd, },
@@ -2217,12 +2201,12 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
 	if (!iwl_mvm_firmware_running(mvm))
 		return -EIO;
 
-	hcmd.id = WIDE_ID(DEBUG_GROUP, *ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR);
+	hcmd.id = WIDE_ID(DEBUG_GROUP, iocb->ki_pos >> 24 ? UMAC_RD_WR : LMAC_RD_WR);
 	cmd.op = cpu_to_le32(DEBUG_MEM_OP_READ);
 
 	/* Take care of alignment of both the position and the length */
-	delta = *ppos & 0x3;
-	cmd.addr = cpu_to_le32(*ppos - delta);
+	delta = iocb->ki_pos & 0x3;
+	cmd.addr = cpu_to_le32(iocb->ki_pos - delta);
 	cmd.len = cpu_to_le32(min(ALIGN(count + delta, 4) / 4,
 				  (size_t)DEBUG_MEM_MAX_SIZE_DWORDS));
 
@@ -2252,19 +2236,18 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,
 		goto out;
 	}
 
-	ret = len - copy_to_user(user_buf, (u8 *)rsp->data + delta, len);
-	*ppos += ret;
+	ret = copy_to_iter((u8 *)rsp->data + delta, len, to);
+	iocb->ki_pos += ret;
 
 out:
 	iwl_free_resp(&hcmd);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_mem_write(struct file *file,
-				   const char __user *user_buf, size_t count,
-				   loff_t *ppos)
+static ssize_t iwl_dbgfs_mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct iwl_dbg_mem_access_cmd *cmd;
 	struct iwl_dbg_mem_access_rsp *rsp;
 	struct iwl_host_cmd hcmd = {};
@@ -2276,11 +2259,11 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,
 	if (!iwl_mvm_firmware_running(mvm))
 		return -EIO;
 
-	hcmd.id = WIDE_ID(DEBUG_GROUP, *ppos >> 24 ? UMAC_RD_WR : LMAC_RD_WR);
+	hcmd.id = WIDE_ID(DEBUG_GROUP, iocb->ki_pos >> 24 ? UMAC_RD_WR : LMAC_RD_WR);
 
-	if (*ppos & 0x3 || count < 4) {
+	if (iocb->ki_pos & 0x3 || count < 4) {
 		op = DEBUG_MEM_OP_WRITE_BYTES;
-		len = min(count, (size_t)(4 - (*ppos & 0x3)));
+		len = min(count, (size_t)(4 - (iocb->ki_pos & 0x3)));
 		data_size = len;
 	} else {
 		op = DEBUG_MEM_OP_WRITE;
@@ -2295,8 +2278,8 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,
 
 	cmd->op = cpu_to_le32(op);
 	cmd->len = cpu_to_le32(len);
-	cmd->addr = cpu_to_le32(*ppos);
-	if (copy_from_user((void *)cmd->data, user_buf, data_size)) {
+	cmd->addr = cpu_to_le32(iocb->ki_pos);
+	if (!copy_from_iter_full((void *)cmd->data, data_size, from)) {
 		kfree(cmd);
 		return -EFAULT;
 	}
@@ -2326,7 +2309,7 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,
 	}
 
 	ret = data_size;
-	*ppos += ret;
+	iocb->ki_pos += ret;
 
 out:
 	iwl_free_resp(&hcmd);
@@ -2334,8 +2317,8 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,
 }
 
 static const struct file_operations iwl_dbgfs_mem_ops = {
-	.read = iwl_dbgfs_mem_read,
-	.write = iwl_dbgfs_mem_write,
+	.read_iter = iwl_dbgfs_mem_read,
+	.write_iter = iwl_dbgfs_mem_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
index cc2c45b45ddc..911c4f97709d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h
@@ -6,7 +6,7 @@
  */
 #define MVM_DEBUGFS_READ_FILE_OPS(name)					\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.read = iwl_dbgfs_##name##_read,				\
+	.read_iter = iwl_dbgfs_##name##_read_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -25,12 +25,13 @@ static ssize_t _iwl_dbgfs_##name##_write(struct file *file,		\
 									\
 	return iwl_dbgfs_##name##_write(arg, buf, buf_size, ppos);	\
 }									\
+FOPS_WRITE_ITER_HELPER(_iwl_dbgfs_##name##_write);			\
 
 #define _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, buflen, argtype)		\
 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
-	.read = iwl_dbgfs_##name##_read,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
+	.read_iter = iwl_dbgfs_##name##_read_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
@@ -38,7 +39,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = {		\
 #define _MVM_DEBUGFS_WRITE_FILE_OPS(name, buflen, argtype)		\
 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index a8c4e354e2ce..d034eff48c37 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -3720,10 +3720,11 @@ static void rs_program_fix_rate(struct iwl_mvm *mvm,
 	}
 }
 
-static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
-			const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_scale_table_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct iwl_mvm *mvm;
 	char buf[64];
 	size_t buf_size;
@@ -3732,7 +3733,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
 	mvm = lq_sta->pers.drv;
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) -  1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x", &parsed_rate) == 1)
@@ -3745,8 +3746,8 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
 	return count;
 }
 
-static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
-			char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_scale_table_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
@@ -3754,7 +3755,7 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
 	ssize_t ret;
 	static const size_t bufsz = 2048;
 
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct iwl_mvm_sta *mvmsta =
 		container_of(lq_sta, struct iwl_mvm_sta, deflink.lq_sta.rs_drv);
 	struct iwl_mvm *mvm;
@@ -3840,19 +3841,19 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
 			buff[desc++] = '\n';
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
-	.write = rs_sta_dbgfs_scale_table_write,
-	.read = rs_sta_dbgfs_scale_table_read,
+	.write_iter = rs_sta_dbgfs_scale_table_write,
+	.read_iter = rs_sta_dbgfs_scale_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
-static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
-			char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_stats_table_read(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
@@ -3860,7 +3861,7 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
 	ssize_t ret;
 	struct iwl_scale_tbl_info *tbl;
 	struct rs_rate *rate;
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -3888,20 +3889,19 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
 				tbl->win[j].success_ratio);
 		}
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = rs_sta_dbgfs_stats_table_read,
+	.read_iter = rs_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t rs_sta_dbgfs_drv_tx_stats_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_drv_tx_stats_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
 	static const char * const column_name[] = {
 		[RS_COLUMN_LEGACY_ANT_A] = "LEGACY_ANT_A",
@@ -3937,7 +3937,7 @@ static ssize_t rs_sta_dbgfs_drv_tx_stats_read(struct file *file,
 	char *buff, *pos, *endpos;
 	int col, rate;
 	ssize_t ret;
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct rs_rate_stats *stats;
 	static const size_t bufsz = 1024;
 
@@ -3967,33 +3967,31 @@ static ssize_t rs_sta_dbgfs_drv_tx_stats_read(struct file *file,
 		pos += scnprintf(pos, endpos - pos, "\n");
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, pos - buff, to);
 	kfree(buff);
 	return ret;
 }
 
-static ssize_t rs_sta_dbgfs_drv_tx_stats_write(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t rs_sta_dbgfs_drv_tx_stats_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	memset(lq_sta->pers.tx_stats, 0, sizeof(lq_sta->pers.tx_stats));
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations rs_sta_dbgfs_drv_tx_stats_ops = {
-	.read = rs_sta_dbgfs_drv_tx_stats_read,
-	.write = rs_sta_dbgfs_drv_tx_stats_write,
+	.read_iter = rs_sta_dbgfs_drv_tx_stats_read,
+	.write_iter = rs_sta_dbgfs_drv_tx_stats_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t iwl_dbgfs_ss_force_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_ss_force_read_iter(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct iwl_lq_sta *lq_sta = file->private_data;
+	struct iwl_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	char buf[12];
 	int bufsz = sizeof(buf);
 	int pos = 0;
@@ -4006,7 +4004,7 @@ static ssize_t iwl_dbgfs_ss_force_read(struct file *file,
 
 	pos += scnprintf(buf+pos, bufsz-pos, "%s\n",
 			 ss_force_name[lq_sta->pers.ss_force]);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static ssize_t iwl_dbgfs_ss_force_write(struct iwl_lq_sta *lq_sta, char *buf,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 6c76b2dd6878..b4e057adcdfe 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2574,22 +2574,22 @@ void iwl_pcie_dump_csr(struct iwl_trans *trans)
 /* file operation */
 #define DEBUGFS_READ_FILE_OPS(name)					\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.read = iwl_dbgfs_##name##_read,				\
+	.read_iter = iwl_dbgfs_##name##_read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
 
 #define DEBUGFS_WRITE_FILE_OPS(name)                                    \
 static const struct file_operations iwl_dbgfs_##name##_ops = {          \
-	.write = iwl_dbgfs_##name##_write,                              \
+	.write_iter = iwl_dbgfs_##name##_write_iter,                    \
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
 
 #define DEBUGFS_READ_WRITE_FILE_OPS(name)				\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = iwl_dbgfs_##name##_write,				\
-	.read = iwl_dbgfs_##name##_read,				\
+	.write_iter = iwl_dbgfs_##name##_write_iter,			\
+	.read_iter = iwl_dbgfs_##name##_read,				\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
@@ -2684,11 +2684,9 @@ static int iwl_dbgfs_tx_queue_open(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rx_queue_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	char *buf;
 	int pos = 0, i, ret;
@@ -2727,17 +2725,15 @@ static ssize_t iwl_dbgfs_rx_queue_read(struct file *file,
 					 "\tclosed_rb_num: Not Allocated\n");
 		}
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_interrupt_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
 
@@ -2786,22 +2782,22 @@ static ssize_t iwl_dbgfs_interrupt_read(struct file *file,
 	pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n",
 		isr_stats->unhandled);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_interrupt_write_iter(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
+	size_t count = iov_iter_count(from);
 	u32 reset_flag;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 16, &reset_flag);
+	ret = kstrtou32_from_iter(from, count, 16, &reset_flag);
 	if (ret)
 		return ret;
 	if (reset_flag == 0)
@@ -2810,22 +2806,19 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
 	return count;
 }
 
-static ssize_t iwl_dbgfs_csr_write(struct file *file,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_csr_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 
 	iwl_pcie_dump_csr(trans);
 
-	return count;
+	return iov_iter_count(from);
 }
 
-static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_fh_reg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	char *buf = NULL;
 	ssize_t ret;
 
@@ -2834,16 +2827,14 @@ static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
 		return ret;
 	if (!buf)
 		return -EINVAL;
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, ret, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t iwl_dbgfs_rfkill_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rfkill_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	char buf[100];
 	int pos;
@@ -2853,19 +2844,19 @@ static ssize_t iwl_dbgfs_rfkill_read(struct file *file,
 			!(iwl_read32(trans, CSR_GP_CNTRL) &
 				CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW));
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t iwl_dbgfs_rfkill_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rfkill_write_iter(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+	size_t count = iov_iter_count(from);
 	bool new_value;
 	int ret;
 
-	ret = kstrtobool_from_user(user_buf, count, &new_value);
+	ret = kstrtobool_from_iter(from, count, &new_value);
 	if (ret)
 		return ret;
 	if (new_value == trans_pcie->debug_rfkill)
@@ -3008,20 +2999,18 @@ static ssize_t iwl_dbgfs_monitor_data_read(struct file *file,
 
 	return bytes_copied;
 }
+FOPS_READ_ITER_HELPER(iwl_dbgfs_monitor_data_read);
 
-static ssize_t iwl_dbgfs_rf_read(struct file *file,
-				 char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t iwl_dbgfs_rf_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_trans *trans = file->private_data;
+	struct iwl_trans *trans = iocb->ki_filp->private_data;
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 
 	if (!trans_pcie->rf_name[0])
 		return -ENODEV;
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       trans_pcie->rf_name,
-				       strlen(trans_pcie->rf_name));
+	return simple_copy_to_iter(trans_pcie->rf_name, &iocb->ki_pos,
+				       strlen(trans_pcie->rf_name), to);
 }
 
 DEBUGFS_READ_WRITE_FILE_OPS(interrupt);
@@ -3034,13 +3023,13 @@ DEBUGFS_READ_FILE_OPS(rf);
 static const struct file_operations iwl_dbgfs_tx_queue_ops = {
 	.owner = THIS_MODULE,
 	.open = iwl_dbgfs_tx_queue_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
 
 static const struct file_operations iwl_dbgfs_monitor_data_ops = {
-	.read = iwl_dbgfs_monitor_data_read,
+	.read_iter = iwl_dbgfs_monitor_data_read_iter,
 	.open = iwl_dbgfs_monitor_data_open,
 	.release = iwl_dbgfs_monitor_data_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 297/437] drivers/net/wireless/mediatek: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (295 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 296/437] drivers/net/wireless/intel: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 298/437] drivers/net/wireless/ath/ath5k: " Jens Axboe
                   ` (140 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../wireless/mediatek/mt76/mt7615/debugfs.c   | 20 ++++---
 .../wireless/mediatek/mt76/mt7915/debugfs.c   | 52 +++++++++----------
 .../wireless/mediatek/mt76/mt7996/debugfs.c   | 33 ++++++------
 3 files changed, 48 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
index 2a6d317db5e0..d645550bab86 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
@@ -436,11 +436,9 @@ mt7615_rf_reg_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(fops_rf_reg, mt7615_rf_reg_get, mt7615_rf_reg_set,
 			 "0x%08llx\n");
 
-static ssize_t
-mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
-			 size_t count, loff_t *ppos)
+static ssize_t mt7615_ext_mac_addr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7615_dev *dev = file->private_data;
+	struct mt7615_dev *dev = iocb->ki_filp->private_data;
 	u32 len = 32 * ((ETH_ALEN * 3) + 4) + 1;
 	u8 addr[ETH_ALEN];
 	char *buf;
@@ -464,17 +462,17 @@ mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
 		ofs += snprintf(buf + ofs, len - ofs, "%d=%pM\n", i, addr);
 	}
 
-	ofs = simple_read_from_buffer(userbuf, count, ppos, buf, ofs);
+	ofs = simple_copy_to_iter(buf, &iocb->ki_pos, ofs, to);
 
 	kfree(buf);
 	return ofs;
 }
 
 static ssize_t
-mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
-			  size_t count, loff_t *ppos)
+mt7615_ext_mac_addr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7615_dev *dev = file->private_data;
+	struct mt7615_dev *dev = iocb->ki_filp->private_data;;
+	size_t count = iov_iter_count(from);
 	unsigned long idx = 0;
 	u8 addr[ETH_ALEN];
 	char buf[32];
@@ -483,7 +481,7 @@ mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
 	if (count > sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[sizeof(buf) - 1] = '\0';
@@ -526,8 +524,8 @@ mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
 static const struct file_operations fops_ext_mac_addr = {
 	.open = simple_open,
 	.llseek = generic_file_llseek,
-	.read = mt7615_ext_mac_addr_read,
-	.write = mt7615_ext_mac_addr_write,
+	.read_iter = mt7615_ext_mac_addr_read,
+	.write_iter = mt7615_ext_mac_addr_write,
 	.owner = THIS_MODULE,
 };
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index 6c3696c8c700..66ffdd915bc5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -46,10 +46,10 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_implicit_txbf, mt7915_implicit_txbf_get,
 
 /* test knob of system error recovery */
 static ssize_t
-mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
-			size_t count, loff_t *ppos)
+mt7915_sys_recovery_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7915_phy *phy = file->private_data;
+	struct mt7915_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mt7915_dev *dev = phy->dev;
 	bool band = phy->mt76->band_idx;
 	char buf[16];
@@ -59,7 +59,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -121,11 +121,9 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
 	return ret ? ret : count;
 }
 
-static ssize_t
-mt7915_sys_recovery_get(struct file *file, char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7915_sys_recovery_get(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7915_phy *phy = file->private_data;
+	struct mt7915_phy *phy = iocb->ki_filp->private_data;
 	struct mt7915_dev *dev = phy->dev;
 	char *buff;
 	int desc = 0;
@@ -196,14 +194,14 @@ mt7915_sys_recovery_get(struct file *file, char __user *user_buf,
 			  dev->recovery.wm_reset_count,
 			  dev->recovery.wa_reset_count);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations mt7915_sys_recovery_ops = {
-	.write = mt7915_sys_recovery_set,
-	.read = mt7915_sys_recovery_get,
+	.write_iter = mt7915_sys_recovery_set,
+	.read_iter = mt7915_sys_recovery_get,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -968,11 +966,9 @@ DEFINE_SHOW_ATTRIBUTE(mt7915_xmit_queues);
 	}							\
 })
 
-static ssize_t
-mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7915_rate_txpower_get(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7915_phy *phy = file->private_data;
+	struct mt7915_phy *phy = iocb->ki_filp->private_data;
 	struct mt7915_dev *dev = phy->dev;
 	s8 txpwr[MT7915_SKU_RATE_NUM];
 	static const size_t sz = 2048;
@@ -1038,7 +1034,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
 	len += scnprintf(buf + len, sz - len, "\nTx power (bbp)  : %6ld\n",
 			 mt76_get_field(dev, reg, MT_WF_PHY_TPC_POWER));
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 out:
 	kfree(buf);
@@ -1046,10 +1042,10 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
 }
 
 static ssize_t
-mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
-			size_t count, loff_t *ppos)
+mt7915_rate_txpower_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7915_phy *phy = file->private_data;
+	struct mt7915_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mt7915_dev *dev = phy->dev;
 	struct mt76_phy *mphy = phy->mt76;
 	struct mt7915_mcu_txpower_sku req = {
@@ -1064,7 +1060,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -1139,8 +1135,8 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations mt7915_rate_txpower_fops = {
-	.write = mt7915_rate_txpower_set,
-	.read = mt7915_rate_txpower_get,
+	.write_iter = mt7915_rate_txpower_set,
+	.read_iter = mt7915_rate_txpower_get,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1311,13 +1307,13 @@ bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len)
 #ifdef CONFIG_MAC80211_DEBUGFS
 /** per-station debugfs **/
 
-static ssize_t mt7915_sta_fixed_rate_set(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t mt7915_sta_fixed_rate_set(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
 	struct mt7915_dev *dev = msta->vif->phy->dev;
+	size_t count = iov_iter_count(from);
 	struct ieee80211_vif *vif;
 	struct sta_phy phy = {};
 	char buf[100];
@@ -1328,7 +1324,7 @@ static ssize_t mt7915_sta_fixed_rate_set(struct file *file,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -1371,7 +1367,7 @@ static ssize_t mt7915_sta_fixed_rate_set(struct file *file,
 }
 
 static const struct file_operations fops_fixed_rate = {
-	.write = mt7915_sta_fixed_rate_set,
+	.write_iter = mt7915_sta_fixed_rate_set,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
index 9bd953586b04..afd8a6623b9c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c
@@ -47,11 +47,10 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_implicit_txbf, mt7996_implicit_txbf_get,
 			 mt7996_implicit_txbf_set, "%lld\n");
 
 /* test knob of system error recovery */
-static ssize_t
-mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7996_sys_recovery_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7996_phy *phy = file->private_data;
+	struct mt7996_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mt7996_dev *dev = phy->dev;
 	bool band = phy->mt76->band_idx;
 	char buf[16];
@@ -61,7 +60,7 @@ mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -122,11 +121,9 @@ mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
 	return ret ? ret : count;
 }
 
-static ssize_t
-mt7996_sys_recovery_get(struct file *file, char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7996_sys_recovery_get(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7996_phy *phy = file->private_data;
+	struct mt7996_phy *phy = iocb->ki_filp->private_data;
 	struct mt7996_dev *dev = phy->dev;
 	char *buff;
 	int desc = 0;
@@ -205,14 +202,14 @@ mt7996_sys_recovery_get(struct file *file, char __user *user_buf,
 			  dev->recovery.wm_reset_count,
 			  dev->recovery.wa_reset_count);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations mt7996_sys_recovery_ops = {
-	.write = mt7996_sys_recovery_set,
-	.read = mt7996_sys_recovery_get,
+	.write_iter = mt7996_sys_recovery_set,
+	.read_iter = mt7996_sys_recovery_get,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -886,15 +883,15 @@ bool mt7996_debugfs_rx_log(struct mt7996_dev *dev, const void *data, int len)
 #ifdef CONFIG_MAC80211_DEBUGFS
 /** per-station debugfs **/
 
-static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t mt7996_sta_fixed_rate_set(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 #define SHORT_PREAMBLE 0
 #define LONG_PREAMBLE 1
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
 	struct mt7996_dev *dev = msta->vif->phy->dev;
+	size_t count = iov_iter_count(from);
 	struct ra_rate phy = {};
 	char buf[100];
 	int ret;
@@ -903,7 +900,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -944,7 +941,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
 }
 
 static const struct file_operations fops_fixed_rate = {
-	.write = mt7996_sta_fixed_rate_set,
+	.write_iter = mt7996_sta_fixed_rate_set,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 298/437] drivers/net/wireless/ath/ath5k: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (296 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 297/437] drivers/net/wireless/mediatek: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 299/437] drivers/net/wireless/ath/ath6kl: " Jens Axboe
                   ` (139 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/ath5k/debug.c | 148 +++++++++++--------------
 1 file changed, 66 insertions(+), 82 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index ec130510aeb2..22f19957887c 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -172,10 +172,9 @@ DEFINE_SEQ_ATTRIBUTE(registers);
 
 /* debugfs: beacons */
 
-static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_beacon(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[500];
 	unsigned int len = 0;
 	unsigned int v;
@@ -217,18 +216,17 @@ static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_beacon(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_beacon(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -243,8 +241,8 @@ static ssize_t write_file_beacon(struct file *file,
 }
 
 static const struct file_operations fops_beacon = {
-	.read = read_file_beacon,
-	.write = write_file_beacon,
+	.read_iter = read_file_beacon,
+	.write_iter = write_file_beacon,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -253,18 +251,16 @@ static const struct file_operations fops_beacon = {
 
 /* debugfs: reset */
 
-static ssize_t write_file_reset(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_reset(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
 	ieee80211_queue_work(ah->hw, &ah->reset_work);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_reset = {
-	.write = write_file_reset,
+	.write_iter = write_file_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
@@ -293,10 +289,9 @@ static const struct {
 	{ ATH5K_DEBUG_ANY,	"all",		"show all debug levels" },
 };
 
-static ssize_t read_file_debug(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_debug(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	unsigned int i;
@@ -318,19 +313,18 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_debug(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_debug(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned int i;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -345,8 +339,8 @@ static ssize_t write_file_debug(struct file *file,
 }
 
 static const struct file_operations fops_debug = {
-	.read = read_file_debug,
-	.write = write_file_debug,
+	.read_iter = read_file_debug,
+	.write_iter = write_file_debug,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -355,10 +349,9 @@ static const struct file_operations fops_debug = {
 
 /* debugfs: antenna */
 
-static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_antenna(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	unsigned int i;
@@ -423,19 +416,18 @@ static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_antenna(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_antenna(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned int i;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -459,8 +451,8 @@ static ssize_t write_file_antenna(struct file *file,
 }
 
 static const struct file_operations fops_antenna = {
-	.read = read_file_antenna,
-	.write = write_file_antenna,
+	.read_iter = read_file_antenna,
+	.write_iter = write_file_antenna,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -468,10 +460,9 @@ static const struct file_operations fops_antenna = {
 
 /* debugfs: misc */
 
-static ssize_t read_file_misc(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_misc(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	u32 filt = ath5k_hw_get_rx_filter(ah);
@@ -511,11 +502,11 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_misc = {
-	.read = read_file_misc,
+	.read_iter = read_file_misc,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 };
@@ -523,10 +514,9 @@ static const struct file_operations fops_misc = {
 
 /* debugfs: frameerrors */
 
-static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_frameerrors(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	struct ath5k_statistics *st = &ah->stats;
 	char buf[700];
 	unsigned int len = 0;
@@ -596,19 +586,18 @@ static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_frameerrors(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_frameerrors(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath5k_statistics *st = &ah->stats;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -631,8 +620,8 @@ static ssize_t write_file_frameerrors(struct file *file,
 }
 
 static const struct file_operations fops_frameerrors = {
-	.read = read_file_frameerrors,
-	.write = write_file_frameerrors,
+	.read_iter = read_file_frameerrors,
+	.write_iter = write_file_frameerrors,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -641,10 +630,9 @@ static const struct file_operations fops_frameerrors = {
 
 /* debugfs: ani */
 
-static ssize_t read_file_ani(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_ani(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	struct ath5k_statistics *st = &ah->stats;
 	struct ath5k_ani_state *as = &ah->ani_state;
 
@@ -746,18 +734,17 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_ani(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_ani(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -796,8 +783,8 @@ static ssize_t write_file_ani(struct file *file,
 }
 
 static const struct file_operations fops_ani = {
-	.read = read_file_ani,
-	.write = write_file_ani,
+	.read_iter = read_file_ani,
+	.write_iter = write_file_ani,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -806,10 +793,9 @@ static const struct file_operations fops_ani = {
 
 /* debugfs: queues etc */
 
-static ssize_t read_file_queue(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_queue(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 
@@ -844,18 +830,17 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_queue(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_queue(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -869,8 +854,8 @@ static ssize_t write_file_queue(struct file *file,
 
 
 static const struct file_operations fops_queue = {
-	.read = read_file_queue,
-	.write = write_file_queue,
+	.read_iter = read_file_queue,
+	.write_iter = write_file_queue,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -948,12 +933,11 @@ static int open_file_eeprom(struct inode *inode, struct file *file)
 
 }
 
-static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct eeprom_private *ep = file->private_data;
+	struct eeprom_private *ep = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(user_buf, count, ppos, ep->buf, ep->len);
+	return simple_copy_to_iter(ep->buf, &iocb->ki_pos, ep->len, to);
 }
 
 static int release_file_eeprom(struct inode *inode, struct file *file)
@@ -968,7 +952,7 @@ static int release_file_eeprom(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_eeprom = {
 	.open = open_file_eeprom,
-	.read = read_file_eeprom,
+	.read_iter = read_file_eeprom,
 	.release = release_file_eeprom,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 299/437] drivers/net/wireless/ath/ath6kl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (297 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 298/437] drivers/net/wireless/ath/ath5k: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 300/437] drivers/net/wireless/ath/carl9170: " Jens Axboe
                   ` (138 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/ath6kl/debug.c | 312 +++++++++++-------------
 1 file changed, 144 insertions(+), 168 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index b837d31416df..f3a7385cf7e5 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -297,10 +297,9 @@ void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
 	}
 }
 
-static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_war_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, buf_len = 1500;
 	ssize_t ret_cnt;
@@ -320,14 +319,14 @@ static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
 	if (WARN_ON(len > buf_len))
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_war_stats = {
-	.read = read_file_war_stats,
+	.read_iter = read_file_war_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -395,10 +394,10 @@ static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	ssize_t ret_cnt;
 	size_t len = 0;
@@ -431,7 +430,7 @@ static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
 
 	/* FIXME: what to do if len == 0? */
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	vfree(buf);
 
@@ -441,17 +440,15 @@ static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
 static const struct file_operations fops_fwlog = {
 	.open = ath6kl_fwlog_open,
 	.release = ath6kl_fwlog_release,
-	.read = ath6kl_fwlog_read,
+	.read_iter = ath6kl_fwlog_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_fwlog_block_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count,
-				       loff_t *ppos)
+static ssize_t ath6kl_fwlog_block_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	ssize_t ret_cnt;
 	size_t len = 0, not_copied;
@@ -498,13 +495,13 @@ static ssize_t ath6kl_fwlog_block_read(struct file *file,
 
 	/* FIXME: what to do if len == 0? */
 
-	not_copied = copy_to_user(user_buf, buf, len);
+	not_copied = !copy_to_iter_full(buf, len, to);
 	if (not_copied != 0) {
 		ret_cnt = -EFAULT;
 		goto out;
 	}
 
-	*ppos = *ppos + len;
+	iocb->ki_pos += len;
 
 	ret_cnt = len;
 
@@ -517,31 +514,29 @@ static ssize_t ath6kl_fwlog_block_read(struct file *file,
 static const struct file_operations fops_fwlog_block = {
 	.open = ath6kl_fwlog_open,
 	.release = ath6kl_fwlog_release,
-	.read = ath6kl_fwlog_block_read,
+	.read_iter = ath6kl_fwlog_block_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_fwlog_mask_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
+	ret = kstrtou32_from_iter(from, count, 0, &ar->debug.fwlog_mask);
 	if (ret)
 		return ret;
 
@@ -556,16 +551,15 @@ static ssize_t ath6kl_fwlog_mask_write(struct file *file,
 
 static const struct file_operations fops_fwlog_mask = {
 	.open = simple_open,
-	.read = ath6kl_fwlog_mask_read,
-	.write = ath6kl_fwlog_mask_write,
+	.read_iter = ath6kl_fwlog_mask_read,
+	.write_iter = ath6kl_fwlog_mask_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_tgt_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct ath6kl_vif *vif;
 	struct target_stats *tgt_stats;
 	char *buf;
@@ -681,14 +675,14 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_tgt_stats = {
-	.read = read_file_tgt_stats,
+	.read_iter = read_file_tgt_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -700,11 +694,10 @@ static const struct file_operations fops_tgt_stats = {
 #define CREDIT_INFO_DISPLAY_STRING_LEN	200
 #define CREDIT_INFO_LEN	128
 
-static ssize_t read_file_credit_dist_stats(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t read_file_credit_dist_stats(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
 	struct htc_endpoint_credit_dist *ep_list;
 	char *buf;
@@ -747,13 +740,13 @@ static ssize_t read_file_credit_dist_stats(struct file *file,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_credit_dist_stats = {
-	.read = read_file_credit_dist_stats,
+	.read_iter = read_file_credit_dist_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -778,11 +771,10 @@ static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
 	return len;
 }
 
-static ssize_t ath6kl_endpoint_stats_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath6kl_endpoint_stats_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
 	char *buf;
 	unsigned int buf_len, len = 0;
@@ -828,22 +820,22 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret_cnt;
 }
 
-static ssize_t ath6kl_endpoint_stats_write(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath6kl_endpoint_stats_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
+	size_t count = iov_iter_count(from);
 	int ret, i;
 	u32 val;
 	struct htc_endpoint_stats *ep_st;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &val);
+	ret = kstrtou32_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 	if (val == 0) {
@@ -858,8 +850,8 @@ static ssize_t ath6kl_endpoint_stats_write(struct file *file,
 
 static const struct file_operations fops_endpoint_stats = {
 	.open = simple_open,
-	.read = ath6kl_endpoint_stats_read,
-	.write = ath6kl_endpoint_stats_write,
+	.read_iter = ath6kl_endpoint_stats_read,
+	.write_iter = ath6kl_endpoint_stats_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -889,10 +881,9 @@ static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
 	return false;
 }
 
-static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regread_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	u8 buf[50];
 	unsigned int len = 0;
 
@@ -903,17 +894,16 @@ static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
 		len += scnprintf(buf + len, sizeof(buf) - len,
 				 "All diag registers\n");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_regread_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regread_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long reg_addr;
 
-	if (kstrtoul_from_user(user_buf, count, 0, &reg_addr))
+	if (kstrtoul_from_iter(from, count, 0, &reg_addr))
 		return -EINVAL;
 
 	if ((reg_addr % 4) != 0)
@@ -928,8 +918,8 @@ static ssize_t ath6kl_regread_write(struct file *file,
 }
 
 static const struct file_operations fops_diag_reg_read = {
-	.read = ath6kl_regread_read,
-	.write = ath6kl_regread_write,
+	.read_iter = ath6kl_regread_read,
+	.write_iter = ath6kl_regread_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1000,11 +990,10 @@ static int ath6kl_regdump_open(struct inode *inode, struct file *file)
 	return -EIO;
 }
 
-static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t ath6kl_regdump_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	u8 *buf = file->private_data;
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	u8 *buf = iocb->ki_filp->private_data;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 static int ath6kl_regdump_release(struct inode *inode, struct file *file)
@@ -1015,21 +1004,21 @@ static int ath6kl_regdump_release(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_reg_dump = {
 	.open = ath6kl_regdump_open,
-	.read = ath6kl_regdump_read,
+	.read_iter = ath6kl_regdump_read,
 	.release = ath6kl_regdump_release,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_lrssi_roam_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_lrssi_roam_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long lrssi_roam_threshold;
 	int ret;
 
-	if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
+	if (kstrtoul_from_iter(from, count, 0, &lrssi_roam_threshold))
 		return -EINVAL;
 
 	ar->lrssi_roam_threshold = lrssi_roam_threshold;
@@ -1041,53 +1030,48 @@ static ssize_t ath6kl_lrssi_roam_write(struct file *file,
 	return count;
 }
 
-static ssize_t ath6kl_lrssi_roam_read(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_lrssi_roam_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_lrssi_roam_threshold = {
-	.read = ath6kl_lrssi_roam_read,
-	.write = ath6kl_lrssi_roam_write,
+	.read_iter = ath6kl_lrssi_roam_read,
+	.write_iter = ath6kl_lrssi_roam_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_regwrite_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regwrite_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	u8 buf[32];
 	unsigned int len = 0;
 
 	len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
 			ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_regwrite_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath6kl_regwrite_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	char *sptr, *token;
 	unsigned int len = 0;
 	u32 reg_addr, reg_val;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1117,8 +1101,8 @@ static ssize_t ath6kl_regwrite_write(struct file *file,
 }
 
 static const struct file_operations fops_diag_reg_write = {
-	.read = ath6kl_regwrite_read,
-	.write = ath6kl_regwrite_write,
+	.read_iter = ath6kl_regwrite_read,
+	.write_iter = ath6kl_regwrite_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1157,10 +1141,9 @@ int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
 	return 0;
 }
 
-static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_roam_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	int ret;
 	long left;
 	struct wmi_target_roam_tbl *tbl;
@@ -1215,31 +1198,31 @@ static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_roam_table = {
-	.read = ath6kl_roam_table_read,
+	.read_iter = ath6kl_roam_table_read,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_force_roam_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_force_roam_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[20];
 	size_t len;
 	u8 bssid[ETH_ALEN];
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 
@@ -1254,24 +1237,23 @@ static ssize_t ath6kl_force_roam_write(struct file *file,
 }
 
 static const struct file_operations fops_force_roam = {
-	.write = ath6kl_force_roam_write,
+	.write_iter = ath6kl_force_roam_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_roam_mode_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_roam_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[20];
 	size_t len;
 	enum wmi_roam_mode mode;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	if (len > 0 && buf[len - 1] == '\n')
@@ -1294,7 +1276,7 @@ static ssize_t ath6kl_roam_mode_write(struct file *file,
 }
 
 static const struct file_operations fops_roam_mode = {
-	.write = ath6kl_roam_mode_write,
+	.write_iter = ath6kl_roam_mode_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1305,27 +1287,25 @@ void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
 	ar->debug.keepalive = keepalive;
 }
 
-static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath6kl_keepalive_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_keepalive_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_keepalive_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 val;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &val);
+	ret = kstrtou8_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1338,8 +1318,8 @@ static ssize_t ath6kl_keepalive_write(struct file *file,
 
 static const struct file_operations fops_keepalive = {
 	.open = simple_open,
-	.read = ath6kl_keepalive_read,
-	.write = ath6kl_keepalive_write,
+	.read_iter = ath6kl_keepalive_read,
+	.write_iter = ath6kl_keepalive_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -1349,28 +1329,27 @@ void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
 	ar->debug.disc_timeout = timeout;
 }
 
-static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath6kl_disconnect_timeout_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath6kl_disconnect_timeout_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 val;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &val);
+	ret = kstrtou8_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1383,17 +1362,17 @@ static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
 
 static const struct file_operations fops_disconnect_timeout = {
 	.open = simple_open,
-	.read = ath6kl_disconnect_timeout_read,
-	.write = ath6kl_disconnect_timeout_write,
+	.read_iter = ath6kl_disconnect_timeout_read,
+	.write_iter = ath6kl_disconnect_timeout_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_create_qos_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath6kl_create_qos_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	char buf[200];
 	ssize_t len;
@@ -1407,7 +1386,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1561,17 +1540,17 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
 }
 
 static const struct file_operations fops_create_qos = {
-	.write = ath6kl_create_qos_write,
+	.write_iter = ath6kl_create_qos_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_delete_qos_write(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t ath6kl_delete_qos_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	char buf[100];
 	ssize_t len;
@@ -1584,7 +1563,7 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1608,17 +1587,17 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
 }
 
 static const struct file_operations fops_delete_qos = {
-	.write = ath6kl_delete_qos_write,
+	.write_iter = ath6kl_delete_qos_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_bgscan_int_write(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t ath6kl_bgscan_int_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	u16 bgscan_int;
 	char buf[32];
@@ -1629,7 +1608,7 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1648,17 +1627,16 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file,
 }
 
 static const struct file_operations fops_bgscan_int = {
-	.write = ath6kl_bgscan_int_write,
+	.write_iter = ath6kl_bgscan_int_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_listen_int_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_listen_int_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	u16 listen_interval;
 	char buf[32];
@@ -1669,7 +1647,7 @@ static ssize_t ath6kl_listen_int_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1686,11 +1664,9 @@ static ssize_t ath6kl_listen_int_write(struct file *file,
 	return count;
 }
 
-static ssize_t ath6kl_listen_int_read(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_listen_int_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct ath6kl_vif *vif;
 	char buf[32];
 	int len;
@@ -1701,22 +1677,22 @@ static ssize_t ath6kl_listen_int_read(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_listen_int = {
-	.read = ath6kl_listen_int_read,
-	.write = ath6kl_listen_int_write,
+	.read_iter = ath6kl_listen_int_read,
+	.write_iter = ath6kl_listen_int_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_power_params_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath6kl_power_params_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 buf[100];
 	unsigned int len = 0;
 	char *sptr, *token;
@@ -1724,7 +1700,7 @@ static ssize_t ath6kl_power_params_write(struct file *file,
 		tx_wakeup, num_tx;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1766,7 +1742,7 @@ static ssize_t ath6kl_power_params_write(struct file *file,
 }
 
 static const struct file_operations fops_power_params = {
-	.write = ath6kl_power_params_write,
+	.write_iter = ath6kl_power_params_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 300/437] drivers/net/wireless/ath/carl9170: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (298 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 299/437] drivers/net/wireless/ath/ath6kl: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 301/437] drivers/net/wireless/ath/wcn36xx: " Jens Axboe
                   ` (137 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/carl9170/debug.c | 25 +++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/debug.c b/drivers/net/wireless/ath/carl9170/debug.c
index bb40889d7c72..1116f7c8ef61 100644
--- a/drivers/net/wireless/ath/carl9170/debug.c
+++ b/drivers/net/wireless/ath/carl9170/debug.c
@@ -59,10 +59,10 @@ struct carl9170_debugfs_fops {
 	enum carl9170_device_state req_dev_state;
 };
 
-static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t carl9170_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct carl9170_debugfs_fops *dfops;
+	size_t count = iov_iter_count(to);
 	struct ar9170 *ar;
 	char *buf = NULL, *res_buf = NULL;
 	ssize_t ret = 0;
@@ -71,11 +71,11 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	if (!count)
 		return 0;
 
-	ar = file->private_data;
+	ar = iocb->ki_filp->private_data;
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->read)
@@ -97,8 +97,7 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	res_buf = dfops->read(ar, buf, dfops->read_bufsize, &ret);
 
 	if (ret > 0)
-		err = simple_read_from_buffer(userbuf, count, ppos,
-					      res_buf, ret);
+		err = simple_copy_to_iter(res_buf, &iocb->ki_pos, ret, to);
 	else
 		err = ret;
 
@@ -110,10 +109,10 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	return err;
 }
 
-static ssize_t carl9170_debugfs_write(struct file *file,
-	const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t carl9170_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct carl9170_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	struct ar9170 *ar;
 	char *buf = NULL;
 	int err = 0;
@@ -124,11 +123,11 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (count > PAGE_SIZE)
 		return -E2BIG;
 
-	ar = file->private_data;
+	ar = iocb->ki_filp->private_data;
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->write)
@@ -138,7 +137,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_free;
 	}
@@ -175,8 +174,8 @@ static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
 	.req_dev_state = _dstate,					\
 	.fops = {							\
 		.open	= simple_open,					\
-		.read	= carl9170_debugfs_read,			\
-		.write	= carl9170_debugfs_write,			\
+		.read_iter	= carl9170_debugfs_read,		\
+		.write_iter	= carl9170_debugfs_write,		\
 		.owner	= THIS_MODULE					\
 	},								\
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 301/437] drivers/net/wireless/ath/wcn36xx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (299 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 300/437] drivers/net/wireless/ath/carl9170: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 302/437] drivers/net/wireless/ath/wil6210: " Jens Axboe
                   ` (136 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/wcn36xx/debug.c | 42 +++++++++++-------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
index 58b3c0501bfd..9dbfb831c0fd 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -25,10 +25,9 @@
 
 #ifdef CONFIG_WCN36XX_DEBUGFS
 
-static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_bool_bmps(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
 	struct wcn36xx_vif *vif_priv = NULL;
 	struct ieee80211_vif *vif = NULL;
 	char buf[3];
@@ -46,14 +45,13 @@ static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t write_file_bool_bmps(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t write_file_bool_bmps(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wcn36xx_vif *vif_priv = NULL;
 	struct ieee80211_vif *vif = NULL;
 
@@ -61,7 +59,7 @@ static ssize_t write_file_bool_bmps(struct file *file,
 	int buf_size;
 
 	buf_size = min(count, (sizeof(buf)-1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	switch (buf[0]) {
@@ -92,15 +90,14 @@ static ssize_t write_file_bool_bmps(struct file *file,
 
 static const struct file_operations fops_wcn36xx_bmps = {
 	.open = simple_open,
-	.read  =       read_file_bool_bmps,
-	.write =       write_file_bool_bmps,
+	.read_iter  =       read_file_bool_bmps,
+	.write_iter =       write_file_bool_bmps,
 };
 
-static ssize_t write_file_dump(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t write_file_dump(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[255], *tmp;
 	int buf_size;
 	u32 arg[WCN36xx_MAX_DUMP_ARGS];
@@ -110,7 +107,7 @@ static ssize_t write_file_dump(struct file *file,
 	memset(arg, 0, sizeof(arg));
 
 	buf_size = min(count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	tmp = buf;
@@ -134,14 +131,13 @@ static ssize_t write_file_dump(struct file *file,
 
 static const struct file_operations fops_wcn36xx_dump = {
 	.open = simple_open,
-	.write =       write_file_dump,
+	.write_iter =       write_file_dump,
 };
 
-static ssize_t read_file_firmware_feature_caps(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t read_file_firmware_feature_caps(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
 	size_t len = 0, buf_len = 2048;
 	char *buf;
 	int i;
@@ -162,7 +158,7 @@ static ssize_t read_file_firmware_feature_caps(struct file *file,
 	}
 	mutex_unlock(&wcn->hal_mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return ret;
@@ -170,7 +166,7 @@ static ssize_t read_file_firmware_feature_caps(struct file *file,
 
 static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
 	.open = simple_open,
-	.read = read_file_firmware_feature_caps,
+	.read_iter = read_file_firmware_feature_caps,
 };
 
 #define ADD_FILE(name, mode, fop, priv_data)		\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 302/437] drivers/net/wireless/ath/wil6210: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (300 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 301/437] drivers/net/wireless/ath/wcn36xx: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 303/437] drivers/net/wireless/ath/ath9k: " Jens Axboe
                   ` (135 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 235 ++++++++++-----------
 drivers/net/wireless/ath/wil6210/pmc.c     |  27 ++-
 drivers/net/wireless/ath/wil6210/pmc.h     |   2 +-
 3 files changed, 122 insertions(+), 142 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index c021ebcddee7..9cbbdd9b9b85 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -611,14 +611,14 @@ static int memread_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(memread);
 
-static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t wil_read_file_ioblob(struct kiocb *iocb, struct iov_iter *to)
 {
 	enum { max_count = 4096 };
-	struct wil_blob_wrapper *wil_blob = file->private_data;
+	struct wil_blob_wrapper *wil_blob = iocb->ki_filp->private_data;
 	struct wil6210_priv *wil = wil_blob->wil;
-	loff_t aligned_pos, pos = *ppos;
+	loff_t aligned_pos, pos = iocb->ki_pos;
 	size_t available = wil_blob->blob.size;
+	size_t count = iov_iter_count(to);
 	void *buf;
 	size_t unaligned_bytes, aligned_count, ret;
 	int rc;
@@ -659,7 +659,7 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
 	wil_memcpy_fromio_32(buf, (const void __iomem *)
 			     wil_blob->blob.data + aligned_pos, aligned_count);
 
-	ret = copy_to_user(user_buf, buf + unaligned_bytes, count);
+	ret = !copy_to_iter_full(buf + unaligned_bytes, count, to);
 
 	wil_mem_access_unlock(wil);
 	wil_pm_runtime_put(wil);
@@ -669,13 +669,12 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
 		return -EFAULT;
 
 	count -= ret;
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
 static const struct file_operations fops_ioblob = {
-	.read =		wil_read_file_ioblob,
+	.read_iter =	wil_read_file_ioblob,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
@@ -690,15 +689,15 @@ struct dentry *wil_debugfs_create_ioblob(const char *name,
 }
 
 /*---write channel 1..4 to rxon for it, 0 to rxoff---*/
-static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
-				   size_t len, loff_t *ppos)
+static ssize_t wil_write_file_rxon(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	long channel;
 	bool on;
 
-	char *kbuf = memdup_user_nul(buf, len);
+	char *kbuf = iterdup_nul(from, len);
 
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
@@ -727,19 +726,18 @@ static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_rxon = {
-	.write = wil_write_file_rxon,
+	.write_iter = wil_write_file_rxon,
 	.open  = simple_open,
 };
 
-static ssize_t wil_write_file_rbufcap(struct file *file,
-				      const char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_write_file_rbufcap(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int val;
 	int rc;
 
-	rc = kstrtoint_from_user(buf, count, 0, &val);
+	rc = kstrtoint_from_iter(from, count, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -765,7 +763,7 @@ static ssize_t wil_write_file_rbufcap(struct file *file,
 }
 
 static const struct file_operations fops_rbufcap = {
-	.write = wil_write_file_rbufcap,
+	.write_iter = wil_write_file_rbufcap,
 	.open  = simple_open,
 };
 
@@ -774,10 +772,10 @@ static const struct file_operations fops_rbufcap = {
  * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
  * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
  */
-static ssize_t wil_write_back(struct file *file, const char __user *buf,
-			      size_t len, loff_t *ppos)
+static ssize_t wil_write_back(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 	char cmd[9];
@@ -786,7 +784,7 @@ static ssize_t wil_write_back(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -847,8 +845,7 @@ static ssize_t wil_write_back(struct file *file, const char __user *buf,
 	return len;
 }
 
-static ssize_t wil_read_back(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t wil_read_back(struct kiocb *iocb, struct iov_iter *to)
 {
 	static const char text[] = "block ack control, write:\n"
 	" - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n"
@@ -857,13 +854,12 @@ static ssize_t wil_read_back(struct file *file, char __user *user_buf,
 	" - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n"
 	"If missing, <reason> set to \"STA_LEAVING\" (36)\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       sizeof(text));
+	return simple_copy_to_iter(text, &iocb->ki_pos, sizeof(text), to);
 }
 
 static const struct file_operations fops_back = {
-	.read = wil_read_back,
-	.write = wil_write_back,
+	.read_iter = wil_read_back,
+	.write_iter = wil_write_back,
 	.open  = simple_open,
 };
 
@@ -871,10 +867,10 @@ static const struct file_operations fops_back = {
  * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
  * - "free" to release memory allocated for PMC
  */
-static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
-				size_t len, loff_t *ppos)
+static ssize_t wil_write_pmccfg(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 	char cmd[9];
@@ -883,7 +879,7 @@ static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -921,10 +917,9 @@ static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
 	return len;
 }
 
-static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t wil_read_pmccfg(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char text[256];
 	char help[] = "pmc control, write:\n"
 	" - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
@@ -933,19 +928,18 @@ static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
 	snprintf(text, sizeof(text), "Last command status: %d\n\n%s",
 		 wil_pmc_last_cmd_status(wil), help);
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       strlen(text) + 1);
+	return simple_copy_to_iter(text, &iocb->ki_pos, strlen(text) + 1, to);
 }
 
 static const struct file_operations fops_pmccfg = {
-	.read = wil_read_pmccfg,
-	.write = wil_write_pmccfg,
+	.read_iter = wil_read_pmccfg,
+	.write_iter = wil_write_pmccfg,
 	.open  = simple_open,
 };
 
 static const struct file_operations fops_pmcdata = {
 	.open		= simple_open,
-	.read		= wil_pmc_read,
+	.read_iter	= wil_pmc_read,
 	.llseek		= wil_pmc_llseek,
 };
 
@@ -957,16 +951,16 @@ static int wil_pmcring_seq_open(struct inode *inode, struct file *file)
 static const struct file_operations fops_pmcring = {
 	.open		= wil_pmcring_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 };
 
 /*---tx_mgmt---*/
 /* Write mgmt frame to this file to send it */
-static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
-				     size_t len, loff_t *ppos)
+static ssize_t wil_write_file_txmgmt(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wiphy *wiphy = wil_to_wiphy(wil);
 	struct wireless_dev *wdev = wil->main_ndev->ieee80211_ptr;
 	struct cfg80211_mgmt_tx_params params;
@@ -978,7 +972,7 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
 	if (!len)
 		return -EINVAL;
 
-	frame = memdup_user(buf, len);
+	frame = iterdup(from, len);
 	if (IS_ERR(frame))
 		return PTR_ERR(frame);
 
@@ -994,17 +988,17 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_txmgmt = {
-	.write = wil_write_file_txmgmt,
+	.write_iter = wil_write_file_txmgmt,
 	.open  = simple_open,
 };
 
 /* Write WMI command (w/o mbox header) to this file to send it
  * WMI starts from wil6210_mbox_hdr_wmi header
  */
-static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
-				  size_t len, loff_t *ppos)
+static ssize_t wil_write_file_wmi(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
 	struct wmi_cmd_hdr *wmi;
 	void *cmd;
@@ -1012,10 +1006,10 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 	u16 cmdid;
 	int rc1;
 
-	if (cmdlen < 0 || *ppos != 0)
+	if (cmdlen < 0 || iocb->ki_pos != 0)
 		return -EINVAL;
 
-	wmi = memdup_user(buf, len);
+	wmi = iterdup(from, len);
 	if (IS_ERR(wmi))
 		return PTR_ERR(wmi);
 
@@ -1031,7 +1025,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_wmi = {
-	.write = wil_write_file_wmi,
+	.write_iter = wil_write_file_wmi,
 	.open  = simple_open,
 };
 
@@ -1484,10 +1478,9 @@ DEFINE_SHOW_ATTRIBUTE(info);
 /* mode = [manual|auto]
  * state = [idle|pending|running]
  */
-static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_read_file_recovery(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char buf[80];
 	int n;
 	static const char * const sstate[] = {"idle", "pending", "running"};
@@ -1498,17 +1491,16 @@ static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
 
 	n = min_t(int, n, sizeof(buf));
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t wil_write_file_recovery(struct file *file,
-				       const char __user *buf_,
-				       size_t count, loff_t *ppos)
+static ssize_t wil_write_file_recovery(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	static const char run_command[] = "run";
 	char buf[sizeof(run_command) + 1]; /* to detect "runx" */
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 
 	if (wil->recovery_state != fw_recovery_pending) {
@@ -1516,8 +1508,8 @@ static ssize_t wil_write_file_recovery(struct file *file,
 		return -EINVAL;
 	}
 
-	if (*ppos != 0) {
-		wil_err(wil, "Offset [%d]\n", (int)*ppos);
+	if (iocb->ki_pos != 0) {
+		wil_err(wil, "Offset [%d]\n", (int)iocb->ki_pos);
 		return -EINVAL;
 	}
 
@@ -1526,7 +1518,7 @@ static ssize_t wil_write_file_recovery(struct file *file,
 		return -EINVAL;
 	}
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
@@ -1540,8 +1532,8 @@ static ssize_t wil_write_file_recovery(struct file *file,
 }
 
 static const struct file_operations fops_recovery = {
-	.read = wil_read_file_recovery,
-	.write = wil_write_file_recovery,
+	.read_iter = wil_read_file_recovery,
+	.write_iter = wil_write_file_recovery,
 	.open  = simple_open,
 };
 
@@ -1766,15 +1758,15 @@ static int wil_tx_latency_seq_open(struct inode *inode, struct file *file)
 			   inode->i_private);
 }
 
-static ssize_t wil_tx_latency_write(struct file *file, const char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t wil_tx_latency_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int val, rc, i;
 	bool enable;
 
-	rc = kstrtoint_from_user(buf, len, 0, &val);
+	rc = kstrtoint_from_iter(from, len, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -1818,8 +1810,8 @@ static ssize_t wil_tx_latency_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_tx_latency = {
 	.open		= wil_tx_latency_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_tx_latency_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_tx_latency_write,
 	.llseek		= seq_lseek,
 };
 
@@ -1930,10 +1922,10 @@ static int wil_link_stats_seq_open(struct inode *inode, struct file *file)
 	return single_open(file, wil_link_stats_debugfs_show, inode->i_private);
 }
 
-static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t wil_link_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int cid, interval, rc, i;
 	struct wil6210_vif *vif;
@@ -1942,7 +1934,7 @@ static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -1982,8 +1974,8 @@ static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_link_stats = {
 	.open		= wil_link_stats_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_link_stats_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_link_stats_write,
 	.llseek		= seq_lseek,
 };
 
@@ -2009,16 +2001,16 @@ wil_link_stats_global_seq_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-wil_link_stats_global_write(struct file *file, const char __user *buf,
-			    size_t len, loff_t *ppos)
+wil_link_stats_global_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int interval, rc;
 	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
 
 	/* specify snapshot interval in ms */
-	rc = kstrtoint_from_user(buf, len, 0, &interval);
+	rc = kstrtoint_from_iter(from, len, 0, &interval);
 	if (rc || interval < 0) {
 		wil_err(wil, "Invalid argument\n");
 		return -EINVAL;
@@ -2036,13 +2028,12 @@ wil_link_stats_global_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_link_stats_global = {
 	.open		= wil_link_stats_global_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_link_stats_global_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_link_stats_global_write,
 	.llseek		= seq_lseek,
 };
 
-static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t wil_read_file_led_cfg(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[80];
 	int n;
@@ -2053,19 +2044,17 @@ static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
 
 	n = min_t(int, n, sizeof(buf));
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t wil_write_file_led_cfg(struct file *file,
-				      const char __user *buf_,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_write_file_led_cfg(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int val;
 	int rc;
 
-	rc = kstrtoint_from_user(buf_, count, 0, &val);
+	rc = kstrtoint_from_iter(from, count, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -2083,25 +2072,25 @@ static ssize_t wil_write_file_led_cfg(struct file *file,
 }
 
 static const struct file_operations fops_led_cfg = {
-	.read = wil_read_file_led_cfg,
-	.write = wil_write_file_led_cfg,
+	.read_iter = wil_read_file_led_cfg,
+	.write_iter = wil_write_file_led_cfg,
 	.open  = simple_open,
 };
 
 /* led_blink_time, write:
  * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast>
  */
-static ssize_t wil_write_led_blink_time(struct file *file,
-					const char __user *buf,
-					size_t len, loff_t *ppos)
+static ssize_t wil_write_led_blink_time(struct kiocb *iocb,
+					struct iov_iter *from)
 {
 	int rc;
+	size_t len = iov_iter_count(from);
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -2125,8 +2114,7 @@ static ssize_t wil_write_led_blink_time(struct file *file,
 	return len;
 }
 
-static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t wil_read_led_blink_time(struct kiocb *iocb, struct iov_iter *to)
 {
 	static char text[400];
 
@@ -2143,13 +2131,12 @@ static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
 		 led_blink_time[WIL_LED_TIME_FAST].on_ms,
 		 led_blink_time[WIL_LED_TIME_FAST].off_ms);
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       sizeof(text));
+	return simple_copy_to_iter(text, &iocb->ki_pos, sizeof(text), to);
 }
 
 static const struct file_operations fops_led_blink_time = {
-	.read = wil_read_led_blink_time,
-	.write = wil_write_led_blink_time,
+	.read_iter = wil_read_led_blink_time,
+	.write_iter = wil_write_led_blink_time,
 	.open  = simple_open,
 };
 
@@ -2180,22 +2167,18 @@ static int fw_version_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(fw_version);
 
 /*---------suspend_stats---------*/
-static ssize_t wil_write_suspend_stats(struct file *file,
-				       const char __user *buf,
-				       size_t len, loff_t *ppos)
+static ssize_t wil_write_suspend_stats(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 
 	memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
-
-	return len;
+	return iov_iter_count(from);
 }
 
-static ssize_t wil_read_suspend_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_read_suspend_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char *text;
 	int n, ret, text_size = 500;
 
@@ -2226,7 +2209,7 @@ static ssize_t wil_read_suspend_stats(struct file *file,
 
 	n = min_t(int, n, text_size);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, text, n);
+	ret = simple_copy_to_iter(text, &iocb->ki_pos, n, to);
 
 	kfree(text);
 
@@ -2234,22 +2217,22 @@ static ssize_t wil_read_suspend_stats(struct file *file,
 }
 
 static const struct file_operations fops_suspend_stats = {
-	.read = wil_read_suspend_stats,
-	.write = wil_write_suspend_stats,
+	.read_iter = wil_read_suspend_stats,
+	.write_iter = wil_write_suspend_stats,
 	.open  = simple_open,
 };
 
 /*---------compressed_rx_status---------*/
-static ssize_t wil_compressed_rx_status_write(struct file *file,
-					      const char __user *buf,
-					      size_t len, loff_t *ppos)
+static ssize_t wil_compressed_rx_status_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int compressed_rx_status;
 	int rc;
 
-	rc = kstrtoint_from_user(buf, len, 0, &compressed_rx_status);
+	rc = kstrtoint_from_iter(from, len, 0, &compressed_rx_status);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -2288,8 +2271,8 @@ wil_compressed_rx_status_seq_open(struct inode *inode, struct file *file)
 static const struct file_operations fops_compressed_rx_status = {
 	.open  = wil_compressed_rx_status_seq_open,
 	.release = single_release,
-	.read = seq_read,
-	.write = wil_compressed_rx_status_write,
+	.read_iter = seq_read_iter,
+	.write_iter = wil_compressed_rx_status_write,
 	.llseek	= seq_lseek,
 };
 
diff --git a/drivers/net/wireless/ath/wil6210/pmc.c b/drivers/net/wireless/ath/wil6210/pmc.c
index a2f7b4c1da48..9bd4bcd5bbcd 100644
--- a/drivers/net/wireless/ath/wil6210/pmc.c
+++ b/drivers/net/wireless/ath/wil6210/pmc.c
@@ -311,10 +311,10 @@ int wil_pmc_last_cmd_status(struct wil6210_priv *wil)
 /* Read from required position up to the end of current descriptor,
  * depends on descriptor size configured during alloc request.
  */
-ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count,
-		     loff_t *f_pos)
+ssize_t wil_pmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = filp->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct pmc_ctx *pmc = &wil->pmc;
 	size_t retval = 0;
 	unsigned long long idx;
@@ -334,33 +334,30 @@ ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count,
 
 	wil_dbg_misc(wil,
 		     "pmc_read: size %u, pos %lld\n",
-		     (u32)count, *f_pos);
+		     (u32)count, iocb->ki_pos);
 
 	pmc->last_cmd_status = 0;
 
-	idx = *f_pos;
+	idx = iocb->ki_pos;
 	do_div(idx, pmc->descriptor_size);
-	offset = *f_pos - (idx * pmc->descriptor_size);
+	offset = iocb->ki_pos - (idx * pmc->descriptor_size);
 
-	if (*f_pos >= pmc_size) {
+	if (iocb->ki_pos >= pmc_size) {
 		wil_dbg_misc(wil,
 			     "pmc_read: reached end of pmc buf: %lld >= %u\n",
-			     *f_pos, (u32)pmc_size);
+			     iocb->ki_pos, (u32)pmc_size);
 		pmc->last_cmd_status = -ERANGE;
 		goto out;
 	}
 
 	wil_dbg_misc(wil,
 		     "pmc_read: read from pos %lld (descriptor %llu, offset %llu) %zu bytes\n",
-		     *f_pos, idx, offset, count);
+		     iocb->ki_pos, idx, offset, count);
 
 	/* if no errors, return the copied byte count */
-	retval = simple_read_from_buffer(buf,
-					 count,
-					 &offset,
-					 pmc->descriptors[idx].va,
-					 pmc->descriptor_size);
-	*f_pos += retval;
+	retval = simple_copy_to_iter(pmc->descriptors[idx].va, &iocb->ki_pos,
+					 pmc->descriptor_size, to);
+	iocb->ki_pos += retval;
 out:
 	mutex_unlock(&pmc->lock);
 
diff --git a/drivers/net/wireless/ath/wil6210/pmc.h b/drivers/net/wireless/ath/wil6210/pmc.h
index b3d79eb50a43..d5ea8e94ccc4 100644
--- a/drivers/net/wireless/ath/wil6210/pmc.h
+++ b/drivers/net/wireless/ath/wil6210/pmc.h
@@ -10,6 +10,6 @@ void wil_pmc_alloc(struct wil6210_priv *wil,
 		   int num_descriptors, int descriptor_size);
 void wil_pmc_free(struct wil6210_priv *wil, int send_pmc_cmd);
 int wil_pmc_last_cmd_status(struct wil6210_priv *wil);
-ssize_t wil_pmc_read(struct file *, char __user *, size_t, loff_t *);
+ssize_t wil_pmc_read(struct kiocb *iocb, struct iov_iter *to);
 loff_t wil_pmc_llseek(struct file *filp, loff_t off, int whence);
 int wil_pmcring_read(struct seq_file *s, void *data);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 303/437] drivers/net/wireless/ath/ath9k: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (301 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 302/437] drivers/net/wireless/ath/wil6210: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 304/437] drivers/net/wireless/ath/ath10k: " Jens Axboe
                   ` (134 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/ath9k/common-debug.c |  36 ++-
 .../net/wireless/ath/ath9k/common-spectral.c  | 111 +++++----
 drivers/net/wireless/ath/ath9k/debug.c        | 210 ++++++++----------
 drivers/net/wireless/ath/ath9k/debug_sta.c    |  18 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c    |  30 ++-
 .../net/wireless/ath/ath9k/htc_drv_debug.c    |  82 +++----
 drivers/net/wireless/ath/ath9k/tx99.c         |  40 ++--
 7 files changed, 242 insertions(+), 285 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/common-debug.c b/drivers/net/wireless/ath/ath9k/common-debug.c
index 7aefb79f6bed..080a57674c23 100644
--- a/drivers/net/wireless/ath/ath9k/common-debug.c
+++ b/drivers/net/wireless/ath/ath9k/common-debug.c
@@ -16,10 +16,9 @@
 
 #include "common.h"
 
-static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t read_file_modal_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_hw *ah = file->private_data;
+	struct ath_hw *ah = iocb->ki_filp->private_data;
 	u32 len = 0, size = 6000;
 	char *buf;
 	size_t retval;
@@ -30,14 +29,14 @@ static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
 
 	len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_modal_eeprom = {
-	.read = read_file_modal_eeprom,
+	.read_iter = read_file_modal_eeprom,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -52,10 +51,9 @@ void ath9k_cmn_debug_modal_eeprom(struct dentry *debugfs_phy,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_modal_eeprom);
 
-static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t read_file_base_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_hw *ah = file->private_data;
+	struct ath_hw *ah = iocb->ki_filp->private_data;
 	u32 len = 0, size = 1500;
 	ssize_t retval = 0;
 	char *buf;
@@ -66,14 +64,14 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
 
 	len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_base_eeprom = {
-	.read = read_file_base_eeprom,
+	.read_iter = read_file_base_eeprom,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -120,8 +118,7 @@ void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_stat_rx);
 
-static ssize_t read_file_recv(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_recv(struct kiocb *iocb, struct iov_iter *to)
 {
 #define RXS_ERR(s, e)					\
 	do {						\
@@ -130,7 +127,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 				 rxstats->e);		\
 	} while (0)
 
-	struct ath_rx_stats *rxstats = file->private_data;
+	struct ath_rx_stats *rxstats = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1600;
 	ssize_t retval = 0;
@@ -162,7 +159,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -171,7 +168,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 }
 
 static const struct file_operations fops_recv = {
-	.read = read_file_recv,
+	.read_iter = read_file_recv,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -184,14 +181,13 @@ void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_recv);
 
-static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t read_file_phy_err(struct kiocb *iocb, struct iov_iter *to)
 {
 #define PHY_ERR(s, p) \
 	len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
 			 rxstats->phy_err_stats[p])
 
-	struct ath_rx_stats *rxstats = file->private_data;
+	struct ath_rx_stats *rxstats = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1600;
 	ssize_t retval = 0;
@@ -238,7 +234,7 @@ static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -247,7 +243,7 @@ static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
 }
 
 static const struct file_operations fops_phy_err = {
-	.read = read_file_phy_err,
+	.read_iter = read_file_phy_err,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/common-spectral.c b/drivers/net/wireless/ath/ath9k/common-spectral.c
index 4b27445a5fb8..56ea7faf2da1 100644
--- a/drivers/net/wireless/ath/ath9k/common-spectral.c
+++ b/drivers/net/wireless/ath/ath9k/common-spectral.c
@@ -686,10 +686,9 @@ EXPORT_SYMBOL(ath_cmn_process_fft);
 /* spectral_scan_ctl */
 /*********************/
 
-static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t read_file_spec_scan_ctl(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	char *mode = "";
 	unsigned int len;
 
@@ -708,7 +707,7 @@ static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
 		break;
 	}
 	len = strlen(mode);
-	return simple_read_from_buffer(user_buf, count, ppos, mode, len);
+	return simple_copy_to_iter(mode, &iocb->ki_pos, len, to);
 }
 
 void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
@@ -786,12 +785,12 @@ int ath9k_cmn_spectral_scan_config(struct ath_common *common,
 }
 EXPORT_SYMBOL(ath9k_cmn_spectral_scan_config);
 
-static ssize_t write_file_spec_scan_ctl(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t write_file_spec_scan_ctl(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	struct ath_common *common = ath9k_hw_common(spec_priv->ah);
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 
@@ -799,7 +798,7 @@ static ssize_t write_file_spec_scan_ctl(struct file *file,
 		return -EOPNOTSUPP;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -826,8 +825,8 @@ static ssize_t write_file_spec_scan_ctl(struct file *file,
 }
 
 static const struct file_operations fops_spec_scan_ctl = {
-	.read = read_file_spec_scan_ctl,
-	.write = write_file_spec_scan_ctl,
+	.read_iter = read_file_spec_scan_ctl,
+	.write_iter = write_file_spec_scan_ctl,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -837,27 +836,26 @@ static const struct file_operations fops_spec_scan_ctl = {
 /* spectral_short_repeat */
 /*************************/
 
-static ssize_t read_file_spectral_short_repeat(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_short_repeat(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", spec_priv->spec_config.short_repeat);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_short_repeat(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_short_repeat(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -869,8 +867,8 @@ static ssize_t write_file_spectral_short_repeat(struct file *file,
 }
 
 static const struct file_operations fops_spectral_short_repeat = {
-	.read = read_file_spectral_short_repeat,
-	.write = write_file_spectral_short_repeat,
+	.read_iter = read_file_spectral_short_repeat,
+	.write_iter = write_file_spectral_short_repeat,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -880,27 +878,25 @@ static const struct file_operations fops_spectral_short_repeat = {
 /* spectral_count */
 /******************/
 
-static ssize_t read_file_spectral_count(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_count(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", spec_priv->spec_config.count);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_count(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_count(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 	if (val > 255)
@@ -911,8 +907,8 @@ static ssize_t write_file_spectral_count(struct file *file,
 }
 
 static const struct file_operations fops_spectral_count = {
-	.read = read_file_spectral_count,
-	.write = write_file_spectral_count,
+	.read_iter = read_file_spectral_count,
+	.write_iter = write_file_spectral_count,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -922,27 +918,25 @@ static const struct file_operations fops_spectral_count = {
 /* spectral_period */
 /*******************/
 
-static ssize_t read_file_spectral_period(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_period(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", spec_priv->spec_config.period);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_period(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_period(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -954,8 +948,8 @@ static ssize_t write_file_spectral_period(struct file *file,
 }
 
 static const struct file_operations fops_spectral_period = {
-	.read = read_file_spectral_period,
-	.write = write_file_spectral_period,
+	.read_iter = read_file_spectral_period,
+	.write_iter = write_file_spectral_period,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -965,27 +959,26 @@ static const struct file_operations fops_spectral_period = {
 /* spectral_fft_period */
 /***********************/
 
-static ssize_t read_file_spectral_fft_period(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_fft_period(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", spec_priv->spec_config.fft_period);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_fft_period(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_fft_period(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath_spec_scan_priv *spec_priv = file->private_data;
+	struct ath_spec_scan_priv *spec_priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -997,8 +990,8 @@ static ssize_t write_file_spectral_fft_period(struct file *file,
 }
 
 static const struct file_operations fops_spectral_fft_period = {
-	.read = read_file_spectral_fft_period,
-	.write = write_file_spectral_fft_period,
+	.read_iter = read_file_spectral_fft_period,
+	.write_iter = write_file_spectral_fft_period,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index d84e3ee7b5d9..728b11732afd 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -68,11 +68,10 @@ void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
 		sc->debug.stats.istats.mac_sleep_access++;
 }
 
-static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath9k_debugfs_read_buf(struct kiocb *iocb, struct iov_iter *to)
 {
-	u8 *buf = file->private_data;
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	u8 *buf = iocb->ki_filp->private_data;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
@@ -83,27 +82,26 @@ static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
 
 #ifdef CONFIG_ATH_DEBUG
 
-static ssize_t read_file_debug(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_debug(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%08x\n", common->debug_mask);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t write_file_debug(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	unsigned long mask;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoul_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -112,8 +110,8 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_debug = {
-	.read = read_file_debug,
-	.write = write_file_debug,
+	.read_iter = read_file_debug,
+	.write_iter = write_file_debug,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -124,10 +122,9 @@ static const struct file_operations fops_debug = {
 #define DMA_BUF_LEN 1024
 
 
-static ssize_t read_file_ani(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_ani(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct ath_hw *ah = sc->sc_ah;
 	unsigned int len = 0;
@@ -173,22 +170,21 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
-static ssize_t write_file_ani(struct file *file,
-			      const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t write_file_ani(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	unsigned long ani;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &ani);
+	ret = kstrtoul_from_iter(from, count, 0, &ani);
 	if (ret)
 		return ret;
 
@@ -208,8 +204,8 @@ static ssize_t write_file_ani(struct file *file,
 }
 
 static const struct file_operations fops_ani = {
-	.read = read_file_ani,
-	.write = write_file_ani,
+	.read_iter = read_file_ani,
+	.write_iter = write_file_ani,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -217,30 +213,29 @@ static const struct file_operations fops_ani = {
 
 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
 
-static ssize_t read_file_bt_ant_diversity(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t read_file_bt_ant_diversity(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", common->bt_ant_diversity);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_bt_ant_diversity(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t write_file_bt_ant_diversity(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
 	unsigned long bt_ant_diversity;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &bt_ant_diversity);
+	ret = kstrtoul_from_iter(from, count, 0, &bt_ant_diversity);
 	if (ret)
 		return ret;
 
@@ -258,8 +253,8 @@ static ssize_t write_file_bt_ant_diversity(struct file *file,
 }
 
 static const struct file_operations fops_bt_ant_diversity = {
-	.read = read_file_bt_ant_diversity,
-	.write = write_file_bt_ant_diversity,
+	.read_iter = read_file_bt_ant_diversity,
+	.write_iter = write_file_bt_ant_diversity,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -281,11 +276,10 @@ void ath9k_debug_stat_ant(struct ath_softc *sc,
 	as_alt->rssi_avg = alt_rssi_avg;
 }
 
-static ssize_t read_file_antenna_diversity(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t read_file_antenna_diversity(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath9k_hw_capabilities *pCap = &ah->caps;
 	struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
@@ -373,14 +367,14 @@ static ssize_t read_file_antenna_diversity(struct file *file,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_antenna_diversity = {
-	.read = read_file_antenna_diversity,
+	.read_iter = read_file_antenna_diversity,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -769,17 +763,16 @@ static int open_file_reset(struct inode *inode, struct file *f)
 	return single_open(f, read_file_reset, inode->i_private);
 }
 
-static ssize_t write_file_reset(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t write_file_reset(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file_inode(file)->i_private;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath_common *common = ath9k_hw_common(ah);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -800,8 +793,8 @@ static ssize_t write_file_reset(struct file *file,
 }
 
 static const struct file_operations fops_reset = {
-	.read = seq_read,
-	.write = write_file_reset,
+	.read_iter = seq_read_iter,
+	.write_iter = write_file_reset,
 	.open = open_file_reset,
 	.owner = THIS_MODULE,
 	.llseek = seq_lseek,
@@ -850,25 +843,24 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
 	ath9k_cmn_debug_stat_rx(&sc->debug.stats.rxstats, rs);
 }
 
-static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t read_file_regidx(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_regidx(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long regidx;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &regidx);
+	ret = kstrtoul_from_iter(from, count, 0, &regidx);
 	if (ret)
 		return ret;
 
@@ -877,17 +869,16 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_regidx = {
-	.read = read_file_regidx,
-	.write = write_file_regidx,
+	.read_iter = read_file_regidx,
+	.write_iter = write_file_regidx,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_regval(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t read_file_regval(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_hw *ah = sc->sc_ah;
 	char buf[32];
 	unsigned int len;
@@ -897,18 +888,18 @@ static ssize_t read_file_regval(struct file *file, char __user *user_buf,
 	regval = REG_READ_D(ah, sc->debug.regidx);
 	ath9k_ps_restore(sc);
 	len = sprintf(buf, "0x%08x\n", regval);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_regval(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_hw *ah = sc->sc_ah;
 	unsigned long regval;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &regval);
+	ret = kstrtoul_from_iter(from, count, 0, &regval);
 	if (ret)
 		return ret;
 
@@ -919,8 +910,8 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_regval = {
-	.read = read_file_regval,
-	.write = write_file_regval,
+	.read_iter = read_file_regval,
+	.write_iter = write_file_regval,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -974,7 +965,7 @@ static int open_file_regdump(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_regdump = {
 	.open = open_file_regdump,
-	.read = ath9k_debugfs_read_buf,
+	.read_iter = ath9k_debugfs_read_buf,
 	.release = ath9k_debugfs_release_buf,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,/* read accesses f_pos */
@@ -1010,10 +1001,9 @@ static int read_file_dump_nfcal(struct seq_file *file, void *data)
 }
 
 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
-static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t read_file_btcoex(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	u32 len = 0, size = 1500;
 	char *buf;
 	size_t retval;
@@ -1030,14 +1020,14 @@ static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
 
 	len = ath9k_dump_btcoex(sc, buf, size);
 exit:
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_btcoex = {
-	.read = read_file_btcoex,
+	.read_iter = read_file_btcoex,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1045,10 +1035,9 @@ static const struct file_operations fops_btcoex = {
 #endif
 
 #ifdef CONFIG_ATH9K_DYNACK
-static ssize_t read_file_ackto(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t read_file_ackto(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_hw *ah = sc->sc_ah;
 	char buf[32];
 	unsigned int len;
@@ -1056,11 +1045,11 @@ static ssize_t read_file_ackto(struct file *file, char __user *user_buf,
 	len = sprintf(buf, "%u %c\n", ah->dynack.ackto,
 		      (ah->dynack.enabled) ? 'A' : 'S');
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ackto = {
-	.read = read_file_ackto,
+	.read_iter = read_file_ackto,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1069,10 +1058,9 @@ static const struct file_operations fops_ackto = {
 
 #ifdef CONFIG_ATH9K_WOW
 
-static ssize_t read_file_wow(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_wow(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	unsigned int len = 0, size = 32;
 	ssize_t retval;
 	char *buf;
@@ -1087,20 +1075,20 @@ static ssize_t read_file_wow(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
-static ssize_t write_file_wow(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t write_file_wow(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1116,8 +1104,8 @@ static ssize_t write_file_wow(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_wow = {
-	.read = read_file_wow,
-	.write = write_file_wow,
+	.read_iter = read_file_wow,
+	.write_iter = write_file_wow,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1125,10 +1113,9 @@ static const struct file_operations fops_wow = {
 
 #endif
 
-static ssize_t read_file_tpc(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_tpc(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_hw *ah = sc->sc_ah;
 	unsigned int len = 0, size = 32;
 	ssize_t retval;
@@ -1144,22 +1131,22 @@ static ssize_t read_file_tpc(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
-static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t write_file_tpc(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_hw *ah = sc->sc_ah;
 	unsigned long val;
 	ssize_t ret;
 	bool tpc_enabled;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1180,18 +1167,16 @@ static ssize_t write_file_tpc(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_tpc = {
-	.read = read_file_tpc,
-	.write = write_file_tpc,
+	.read_iter = read_file_tpc,
+	.write_iter = write_file_tpc,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_nf_override(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t read_file_nf_override(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath_hw *ah = sc->sc_ah;
 	char buf[32];
 	unsigned int len;
@@ -1201,21 +1186,20 @@ static ssize_t read_file_nf_override(struct file *file,
 	else
 		len = sprintf(buf, "%d\n", ah->nf_override);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_nf_override(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t write_file_nf_override(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_hw *ah = sc->sc_ah;
 	long val;
 	char buf[32];
 	ssize_t len;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1242,8 +1226,8 @@ static ssize_t write_file_nf_override(struct file *file,
 }
 
 static const struct file_operations fops_nf_override = {
-	.read = read_file_nf_override,
-	.write = write_file_nf_override,
+	.read_iter = read_file_nf_override,
+	.write_iter = write_file_nf_override,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/debug_sta.c b/drivers/net/wireless/ath/ath9k/debug_sta.c
index 1e2a30019fb6..18aa2b6d1c72 100644
--- a/drivers/net/wireless/ath/ath9k/debug_sta.c
+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
@@ -20,10 +20,9 @@
 /* node_aggr */
 /*************/
 
-static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_node_aggr(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_node *an = file->private_data;
+	struct ath_node *an = iocb->ki_filp->private_data;
 	struct ath_softc *sc = an->sc;
 	struct ath_atx_tid *tid;
 	struct ath_txq *txq;
@@ -71,14 +70,14 @@ static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
 		ath_txq_unlock(sc, txq);
 	}
 exit:
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_node_aggr = {
-	.read = read_file_node_aggr,
+	.read_iter = read_file_node_aggr,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -165,10 +164,9 @@ void ath_debug_rate_stats(struct ath_softc *sc,
 			 rstats->ofdm_stats[i].ofdm_cnt);	\
 	} while (0)
 
-static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_node_recv(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_node *an = file->private_data;
+	struct ath_node *an = iocb->ki_filp->private_data;
 	struct ath_softc *sc = an->sc;
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath_rx_rate_stats *rstats;
@@ -226,7 +224,7 @@ static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
 	PRINT_OFDM_RATE("OFDM-48M", 6);
 	PRINT_OFDM_RATE("OFDM-54M", 7);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -236,7 +234,7 @@ static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
 #undef PRINT_CCK_RATE
 
 static const struct file_operations fops_node_recv = {
-	.read = read_file_node_recv,
+	.read_iter = read_file_node_recv,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.c b/drivers/net/wireless/ath/ath9k/dfs_debug.c
index 8e18e9b4ef48..709e8be90e99 100644
--- a/drivers/net/wireless/ath/ath9k/dfs_debug.c
+++ b/drivers/net/wireless/ath/ath9k/dfs_debug.c
@@ -31,10 +31,9 @@ static struct ath_dfs_pool_stats dfs_pool_stats = { 0 };
 	len += scnprintf(buf + len, size - len, "%28s : %10u\n", s, \
 			 dfs_pool_stats.p);
 
-static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_dfs(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath9k_hw_version *hw_ver = &sc->sc_ah->hw_version;
 	char *buf;
 	unsigned int len = 0, size = 8000;
@@ -86,7 +85,7 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -94,14 +93,14 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
 
 /* magic number to prevent accidental reset of DFS statistics */
 #define DFS_STATS_RESET_MAGIC	0x80000000
-static ssize_t write_file_dfs(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t write_file_dfs(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 	if (val == DFS_STATS_RESET_MAGIC)
@@ -110,27 +109,26 @@ static ssize_t write_file_dfs(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t write_file_simulate_radar(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t write_file_simulate_radar(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 
 	ieee80211_radar_detected(sc->hw);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = write_file_simulate_radar,
+	.write_iter = write_file_simulate_radar,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations fops_dfs_stats = {
-	.read = read_file_dfs,
-	.write = write_file_dfs,
+	.read_iter = read_file_dfs,
+	.write_iter = write_file_dfs,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
index f7c6d9bc9311..4743687dc8ab 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -16,10 +16,9 @@
 
 #include "htc.h"
 
-static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t read_file_tgt_int_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	struct ath9k_htc_target_int_stats cmd_rsp;
 	char buf[512];
 	unsigned int len = 0;
@@ -64,20 +63,19 @@ static ssize_t read_file_tgt_int_stats(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tgt_int_stats = {
-	.read = read_file_tgt_int_stats,
+	.read_iter = read_file_tgt_int_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tgt_tx_stats(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t read_file_tgt_tx_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	struct ath9k_htc_target_tx_stats cmd_rsp;
 	char buf[512];
 	unsigned int len = 0;
@@ -134,20 +132,19 @@ static ssize_t read_file_tgt_tx_stats(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tgt_tx_stats = {
-	.read = read_file_tgt_tx_stats,
+	.read_iter = read_file_tgt_tx_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tgt_rx_stats(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t read_file_tgt_rx_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	struct ath9k_htc_target_rx_stats cmd_rsp;
 	char buf[512];
 	unsigned int len = 0;
@@ -180,20 +177,19 @@ static ssize_t read_file_tgt_rx_stats(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tgt_rx_stats = {
-	.read = read_file_tgt_rx_stats,
+	.read_iter = read_file_tgt_rx_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_xmit(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	char buf[512];
 	unsigned int len = 0;
 
@@ -232,11 +228,11 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_xmit = {
-	.read = read_file_xmit,
+	.read_iter = read_file_xmit,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -248,10 +244,9 @@ void ath9k_htc_err_stat_rx(struct ath9k_htc_priv *priv,
 	ath9k_cmn_debug_stat_rx(&priv->debug.rx_stats, rs);
 }
 
-static ssize_t read_file_skb_rx(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_skb_rx(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1500;
 	ssize_t retval = 0;
@@ -273,23 +268,22 @@ static ssize_t read_file_skb_rx(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_skb_rx = {
-	.read = read_file_skb_rx,
+	.read_iter = read_file_skb_rx,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_slot(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_slot(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	char buf[512];
 	unsigned int len;
 
@@ -300,20 +294,19 @@ static ssize_t read_file_slot(struct file *file, char __user *user_buf,
 			MAX_TX_BUF_NUM, priv->tx.tx_slot,
 			bitmap_weight(priv->tx.tx_slot, MAX_TX_BUF_NUM));
 	spin_unlock_bh(&priv->tx.tx_lock);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_slot = {
-	.read = read_file_slot,
+	.read_iter = read_file_slot,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_queue(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t read_file_queue(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	char buf[512];
 	unsigned int len = 0;
 
@@ -346,38 +339,37 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 }
 
 static const struct file_operations fops_queue = {
-	.read = read_file_queue,
+	.read_iter = read_file_queue,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_debug(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t read_file_debug(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
 	struct ath_common *common = ath9k_hw_common(priv->ah);
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%08x\n", common->debug_mask);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t write_file_debug(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath9k_htc_priv *priv = file->private_data;
+	struct ath9k_htc_priv *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(priv->ah);
 	unsigned long mask;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoul_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -386,8 +378,8 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_debug = {
-	.read = read_file_debug,
-	.write = write_file_debug,
+	.read_iter = read_file_debug,
+	.write_iter = write_file_debug,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath9k/tx99.c b/drivers/net/wireless/ath/ath9k/tx99.c
index f2144fd39093..349aa30cef9f 100644
--- a/drivers/net/wireless/ath/ath9k/tx99.c
+++ b/drivers/net/wireless/ath/ath9k/tx99.c
@@ -156,21 +156,20 @@ static int ath9k_tx99_init(struct ath_softc *sc)
 	return 0;
 }
 
-static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_tx99(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	char buf[3];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", sc->tx99_state);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t write_file_tx99(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	bool start;
 	ssize_t ret;
@@ -182,7 +181,7 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;
 
-	ret = kstrtobool_from_user(user_buf, count, &start);
+	ret = kstrtobool_from_iter(from, count, &start);
 	if (ret)
 		return ret;
 
@@ -211,18 +210,16 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_tx99 = {
-	.read = read_file_tx99,
-	.write = write_file_tx99,
+	.read_iter = read_file_tx99,
+	.write_iter = write_file_tx99,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tx99_power(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t read_file_tx99_power(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
@@ -230,18 +227,17 @@ static ssize_t read_file_tx99_power(struct file *file,
 		      sc->tx99_power,
 		      sc->tx99_power / 2);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_tx99_power(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t write_file_tx99_power(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int r;
 	u8 tx_power;
 
-	r = kstrtou8_from_user(user_buf, count, 0, &tx_power);
+	r = kstrtou8_from_iter(from, count, 0, &tx_power);
 	if (r)
 		return r;
 
@@ -258,8 +254,8 @@ static ssize_t write_file_tx99_power(struct file *file,
 }
 
 static const struct file_operations fops_tx99_power = {
-	.read = read_file_tx99_power,
-	.write = write_file_tx99_power,
+	.read_iter = read_file_tx99_power,
+	.write_iter = write_file_tx99_power,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 304/437] drivers/net/wireless/ath/ath10k: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (302 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 303/437] drivers/net/wireless/ath/ath9k: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 305/437] drivers/net/wireless/ath/ath11k: " Jens Axboe
                   ` (133 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/ath10k/debug.c       | 502 ++++++++----------
 drivers/net/wireless/ath/ath10k/debugfs_sta.c | 119 ++---
 drivers/net/wireless/ath/ath10k/spectral.c    |  65 ++-
 3 files changed, 316 insertions(+), 370 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index b93a64bf8190..63193a566868 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -148,11 +148,9 @@ EXPORT_SYMBOL(ath10k_warn);
 
 #ifdef CONFIG_ATH10K_DEBUGFS
 
-static ssize_t ath10k_read_wmi_services(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t ath10k_read_wmi_services(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char *buf;
 	size_t len = 0, buf_len = 8192;
 	const char *name;
@@ -186,7 +184,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
 	}
 	spin_unlock_bh(&ar->data_lock);
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
@@ -195,7 +193,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
 }
 
 static const struct file_operations fops_wmi_services = {
-	.read = ath10k_read_wmi_services,
+	.read_iter = ath10k_read_wmi_services,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -442,28 +440,26 @@ static int ath10k_fw_stats_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_fw_stats_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath10k_fw_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_fw_stats = {
 	.open = ath10k_fw_stats_open,
 	.release = ath10k_fw_stats_release,
-	.read = ath10k_fw_stats_read,
+	.read_iter = ath10k_fw_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_fw_reset_stats_read(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int ret;
 	size_t len = 0, buf_len = 500;
 	char *buf;
@@ -485,7 +481,7 @@ static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 
@@ -494,7 +490,7 @@ static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
 
 static const struct file_operations fops_fw_reset_stats = {
 	.open = simple_open,
-	.read = ath10k_debug_fw_reset_stats_read,
+	.read_iter = ath10k_debug_fw_reset_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -519,9 +515,8 @@ static int ath10k_debug_fw_assert(struct ath10k *ar)
 				   ar->wmi.cmd->vdev_install_key_cmdid);
 }
 
-static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_simulate_fw_crash(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	const char buf[] =
 		"To simulate firmware crash write one of the keywords to this file:\n"
@@ -530,7 +525,7 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
 		"`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n"
 		"`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 /* Simulate firmware crash:
@@ -540,26 +535,26 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
  * vdev id. This is hard firmware crash because it is recoverable only by cold
  * firmware reset.
  */
-static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_write_simulate_fw_crash(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32] = {0};
 	ssize_t rc;
 	int ret;
 
 	/* filter partial writes and invalid commands */
-	if (*ppos != 0 || count >= sizeof(buf) || count == 0)
+	if (iocb->ki_pos != 0 || count >= sizeof(buf) || count == 0)
 		return -EINVAL;
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
 	/* drop the possible '\n' from the end */
-	if (buf[*ppos - 1] == '\n')
-		buf[*ppos - 1] = '\0';
+	if (buf[iocb->ki_pos - 1] == '\n')
+		buf[iocb->ki_pos - 1] = '\0';
 
 	mutex_lock(&ar->conf_mutex);
 
@@ -605,37 +600,34 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
 }
 
 static const struct file_operations fops_simulate_fw_crash = {
-	.read = ath10k_read_simulate_fw_crash,
-	.write = ath10k_write_simulate_fw_crash,
+	.read_iter = ath10k_read_simulate_fw_crash,
+	.write_iter = ath10k_write_simulate_fw_crash,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t ath10k_read_chip_id(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[50];
 
 	len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->bus_param.chip_id);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_chip_id = {
-	.read = ath10k_read_chip_id,
+	.read_iter = ath10k_read_chip_id,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_reg_addr_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_addr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	u8 buf[32];
 	size_t len = 0;
 	u32 reg_addr;
@@ -646,18 +638,17 @@ static ssize_t ath10k_reg_addr_read(struct file *file,
 
 	len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n", reg_addr);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_reg_addr_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_addr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 reg_addr;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &reg_addr);
+	ret = kstrtou32_from_iter(from, count, 0, &reg_addr);
 	if (ret)
 		return ret;
 
@@ -672,18 +663,16 @@ static ssize_t ath10k_reg_addr_write(struct file *file,
 }
 
 static const struct file_operations fops_reg_addr = {
-	.read = ath10k_reg_addr_read,
-	.write = ath10k_reg_addr_write,
+	.read_iter = ath10k_reg_addr_read,
+	.write_iter = ath10k_reg_addr_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_reg_value_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_value_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	u8 buf[48];
 	size_t len;
 	u32 reg_addr, reg_val;
@@ -702,7 +691,7 @@ static ssize_t ath10k_reg_value_read(struct file *file,
 	reg_val = ath10k_hif_read32(ar, reg_addr);
 	len = scnprintf(buf, sizeof(buf), "0x%08x:0x%08x\n", reg_addr, reg_val);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 exit:
 	mutex_unlock(&ar->conf_mutex);
@@ -710,11 +699,10 @@ static ssize_t ath10k_reg_value_read(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_reg_value_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_value_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 reg_addr, reg_val;
 	int ret;
 
@@ -728,7 +716,7 @@ static ssize_t ath10k_reg_value_write(struct file *file,
 
 	reg_addr = ar->debug.reg_addr;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &reg_val);
+	ret = kstrtou32_from_iter(from, count, 0, &reg_val);
 	if (ret)
 		goto exit;
 
@@ -743,22 +731,21 @@ static ssize_t ath10k_reg_value_write(struct file *file,
 }
 
 static const struct file_operations fops_reg_value = {
-	.read = ath10k_reg_value_read,
-	.write = ath10k_reg_value_write,
+	.read_iter = ath10k_reg_value_read,
+	.write_iter = ath10k_reg_value_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_mem_value_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_mem_value_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	u8 *buf;
 	int ret;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 
 	if (!count)
@@ -778,21 +765,21 @@ static ssize_t ath10k_mem_value_read(struct file *file,
 		goto exit;
 	}
 
-	ret = ath10k_hif_diag_read(ar, *ppos, buf, count);
+	ret = ath10k_hif_diag_read(ar, iocb->ki_pos, buf, count);
 	if (ret) {
 		ath10k_warn(ar, "failed to read address 0x%08x via diagnose window from debugfs: %d\n",
-			    (u32)(*ppos), ret);
+			    (u32)(iocb->ki_pos), ret);
 		goto exit;
 	}
 
-	ret = copy_to_user(user_buf, buf, count);
+	ret = !copy_to_iter_full(buf, count, to);
 	if (ret) {
 		ret = -EFAULT;
 		goto exit;
 	}
 
 	count -= ret;
-	*ppos += count;
+	iocb->ki_pos += count;
 	ret = count;
 
 exit:
@@ -802,15 +789,14 @@ static ssize_t ath10k_mem_value_read(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_mem_value_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_mem_value_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 *buf;
 	int ret;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 
 	if (!count)
@@ -830,20 +816,20 @@ static ssize_t ath10k_mem_value_write(struct file *file,
 		goto exit;
 	}
 
-	ret = copy_from_user(buf, user_buf, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret) {
 		ret = -EFAULT;
 		goto exit;
 	}
 
-	ret = ath10k_hif_diag_write(ar, *ppos, buf, count);
+	ret = ath10k_hif_diag_write(ar, iocb->ki_pos, buf, count);
 	if (ret) {
 		ath10k_warn(ar, "failed to write address 0x%08x via diagnose window from debugfs: %d\n",
-			    (u32)(*ppos), ret);
+			    (u32)(iocb->ki_pos), ret);
 		goto exit;
 	}
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	ret = count;
 
 exit:
@@ -854,8 +840,8 @@ static ssize_t ath10k_mem_value_write(struct file *file,
 }
 
 static const struct file_operations fops_mem_value = {
-	.read = ath10k_mem_value_read,
-	.write = ath10k_mem_value_write,
+	.read_iter = ath10k_mem_value_read,
+	.write_iter = ath10k_mem_value_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -902,28 +888,27 @@ static void ath10k_debug_htt_stats_dwork(struct work_struct *work)
 	mutex_unlock(&ar->conf_mutex);
 }
 
-static ssize_t ath10k_read_htt_stats_mask(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_read_htt_stats_mask(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_htt_stats_mask(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_htt_stats_mask(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long mask;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoul_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -948,18 +933,17 @@ static ssize_t ath10k_write_htt_stats_mask(struct file *file,
 }
 
 static const struct file_operations fops_htt_stats_mask = {
-	.read = ath10k_read_htt_stats_mask,
-	.write = ath10k_write_htt_stats_mask,
+	.read_iter = ath10k_read_htt_stats_mask,
+	.write_iter = ath10k_write_htt_stats_mask,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[64];
 	u8 amsdu, ampdu;
 	size_t len;
@@ -972,20 +956,19 @@ static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int res;
 	char buf[64] = {0};
 	unsigned int amsdu, ampdu;
 
-	res = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	res = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (res <= 0)
 		return res;
 
@@ -1010,39 +993,35 @@ static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
 }
 
 static const struct file_operations fops_htt_max_amsdu_ampdu = {
-	.read = ath10k_read_htt_max_amsdu_ampdu,
-	.write = ath10k_write_htt_max_amsdu_ampdu,
+	.read_iter = ath10k_read_htt_max_amsdu_ampdu,
+	.write_iter = ath10k_write_htt_max_amsdu_ampdu,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_fw_dbglog(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_fw_dbglog(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[96];
 
 	len = scnprintf(buf, sizeof(buf), "0x%16llx %u\n",
 			ar->debug.fw_dbglog_mask, ar->debug.fw_dbglog_level);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_fw_dbglog(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_write_fw_dbglog(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[96] = {0};
 	unsigned int log_level;
 	u64 mask;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -1241,8 +1220,8 @@ void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
 }
 
 static const struct file_operations fops_fw_dbglog = {
-	.read = ath10k_read_fw_dbglog,
-	.write = ath10k_write_fw_dbglog,
+	.read_iter = ath10k_read_fw_dbglog,
+	.write_iter = ath10k_write_fw_dbglog,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1298,32 +1277,31 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_debug_cal_data_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_cal_data_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count;
 
 	mutex_lock(&ar->conf_mutex);
 
-	count = simple_read_from_buffer(user_buf, count, ppos,
-					ar->debug.cal_data,
-					ar->hw_params.cal_data_len);
+	count = simple_copy_to_iter(ar->debug.cal_data, &iocb->ki_pos,
+					ar->hw_params.cal_data_len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
 	return count;
 }
 
-static ssize_t ath10k_write_ani_enable(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath10k_write_ani_enable(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &enable))
+	if (kstrtou8_from_iter(from, count, 0, &enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1349,21 +1327,20 @@ static ssize_t ath10k_write_ani_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_ani_enable(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_read_ani_enable(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[32];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ani_enabled);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ani_enable = {
-	.read = ath10k_read_ani_enable,
-	.write = ath10k_write_ani_enable,
+	.read_iter = ath10k_read_ani_enable,
+	.write_iter = ath10k_write_ani_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1371,33 +1348,31 @@ static const struct file_operations fops_ani_enable = {
 
 static const struct file_operations fops_cal_data = {
 	.open = ath10k_debug_cal_data_open,
-	.read = ath10k_debug_cal_data_read,
+	.read_iter = ath10k_debug_cal_data_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_nf_cal_period(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_read_nf_cal_period(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[32];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->debug.nf_cal_period);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_nf_cal_period(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_nf_cal_period(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long period;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &period);
+	ret = kstrtoul_from_iter(from, count, 0, &period);
 	if (ret)
 		return ret;
 
@@ -1435,8 +1410,8 @@ static ssize_t ath10k_write_nf_cal_period(struct file *file,
 }
 
 static const struct file_operations fops_nf_cal_period = {
-	.read = ath10k_read_nf_cal_period,
-	.write = ath10k_write_nf_cal_period,
+	.read_iter = ath10k_read_nf_cal_period,
+	.write_iter = ath10k_write_nf_cal_period,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1673,19 +1648,18 @@ static int ath10k_tpc_stats_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_tpc_stats_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_tpc_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tpc_stats = {
 	.open = ath10k_tpc_stats_open,
 	.release = ath10k_tpc_stats_release,
-	.read = ath10k_tpc_stats_read,
+	.read_iter = ath10k_tpc_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -1759,11 +1733,10 @@ void ath10k_debug_stop(struct ath10k *ar)
 	ath10k_wmi_pdev_pktlog_disable(ar);
 }
 
-static ssize_t ath10k_write_simulate_radar(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_simulate_radar(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	struct ath10k_vif *arvif;
 
 	/* Just check for the first vif alone, as all the vifs will be
@@ -1775,12 +1748,11 @@ static ssize_t ath10k_write_simulate_radar(struct file *file,
 		return -EINVAL;
 
 	ieee80211_radar_detected(ar->hw);
-
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = ath10k_write_simulate_radar,
+	.write_iter = ath10k_write_simulate_radar,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1794,12 +1766,11 @@ static const struct file_operations fops_simulate_radar = {
 	len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \
 			 ar->debug.dfs_pool_stats.p))
 
-static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_dfs_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	int retval = 0, len = 0;
 	const int size = 8000;
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char *buf;
 
 	buf = kzalloc(size, GFP_KERNEL);
@@ -1835,28 +1806,28 @@ static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_dfs_stats = {
-	.read = ath10k_read_dfs_stats,
+	.read_iter = ath10k_read_dfs_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_pktlog_filter(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_pktlog_filter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1895,11 +1866,10 @@ static ssize_t ath10k_write_pktlog_filter(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_read_pktlog_filter(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1907,23 +1877,23 @@ static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf,
 			ar->pktlog_filter);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pktlog_filter = {
-	.read = ath10k_read_pktlog_filter,
-	.write = ath10k_write_pktlog_filter,
+	.read_iter = ath10k_read_pktlog_filter,
+	.write_iter = ath10k_write_pktlog_filter,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_quiet_period(struct file *file,
-					 const char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_write_quiet_period(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 period;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &period))
+	if (kstrtouint_from_iter(from, count, 0, &period))
 		return -EINVAL;
 
 	if (period < ATH10K_QUIET_PERIOD_MIN) {
@@ -1939,11 +1909,10 @@ static ssize_t ath10k_write_quiet_period(struct file *file,
 	return count;
 }
 
-static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
-					size_t count, loff_t *ppos)
+static ssize_t ath10k_read_quiet_period(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1951,25 +1920,24 @@ static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
 			ar->thermal.quiet_period);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_quiet_period = {
-	.read = ath10k_read_quiet_period,
-	.write = ath10k_write_quiet_period,
+	.read_iter = ath10k_read_quiet_period,
+	.write_iter = ath10k_write_quiet_period,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_btcoex(struct file *file,
-				   const char __user *ubuf,
-				   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_btcoex(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	bool val;
 	u32 pdev_param;
 
-	ret = kstrtobool_from_user(ubuf, count, &val);
+	ret = kstrtobool_from_iter(from, count, &val);
 	if (ret)
 		return ret;
 
@@ -2016,11 +1984,10 @@ static ssize_t ath10k_write_btcoex(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_btcoex(struct file *file, char __user *ubuf,
-				  size_t count, loff_t *ppos)
+static ssize_t ath10k_read_btcoex(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2028,24 +1995,24 @@ static ssize_t ath10k_read_btcoex(struct file *file, char __user *ubuf,
 			test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags));
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_btcoex = {
-	.read = ath10k_read_btcoex,
-	.write = ath10k_write_btcoex,
+	.read_iter = ath10k_read_btcoex,
+	.write_iter = ath10k_write_btcoex,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
-						 const char __user *ubuf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath10k_write_enable_extd_tx_stats(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2069,13 +2036,12 @@ static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
-						char __user *ubuf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_read_enable_extd_tx_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2083,24 +2049,24 @@ static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
 			ar->debug.enable_extd_tx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_enable_extd_tx_stats = {
-	.read = ath10k_read_enable_extd_tx_stats,
-	.write = ath10k_write_enable_extd_tx_stats,
+	.read_iter = ath10k_read_enable_extd_tx_stats,
+	.write_iter = ath10k_write_enable_extd_tx_stats,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_peer_stats(struct file *file,
-				       const char __user *ubuf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath10k_write_peer_stats(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	bool val;
 
-	ret = kstrtobool_from_user(ubuf, count, &val);
+	ret = kstrtobool_from_iter(from, count, &val);
 	if (ret)
 		return ret;
 
@@ -2132,12 +2098,10 @@ static ssize_t ath10k_write_peer_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_peer_stats(struct file *file, char __user *ubuf,
-				      size_t count, loff_t *ppos)
-
+static ssize_t ath10k_read_peer_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2145,20 +2109,19 @@ static ssize_t ath10k_read_peer_stats(struct file *file, char __user *ubuf,
 			test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags));
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_peer_stats = {
-	.read = ath10k_read_peer_stats,
-	.write = ath10k_write_peer_stats,
+	.read_iter = ath10k_read_peer_stats,
+	.write_iter = ath10k_write_peer_stats,
 	.open = simple_open
 };
 
-static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_fw_checksums_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len = 0, buf_len = 4096;
 	ssize_t ret_cnt;
 	char *buf;
@@ -2194,7 +2157,7 @@ static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
 			 crc32_le(0, ar->normal_mode_fw.board_data,
 				  ar->normal_mode_fw.board_len));
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
@@ -2203,33 +2166,32 @@ static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
 }
 
 static const struct file_operations fops_fw_checksums = {
-	.read = ath10k_debug_fw_checksums_read,
+	.read_iter = ath10k_debug_fw_checksums_read,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_sta_tid_stats_mask_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_sta_tid_stats_mask_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->sta_tid_stats_mask);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath10k_sta_tid_stats_mask_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	u32 mask;
 
-	ret = kstrtoint_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoint_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -2239,8 +2201,8 @@ static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
 }
 
 static const struct file_operations fops_sta_tid_stats_mask = {
-	.read = ath10k_sta_tid_stats_mask_read,
-	.write = ath10k_sta_tid_stats_mask_write,
+	.read_iter = ath10k_sta_tid_stats_mask_read,
+	.write_iter = ath10k_sta_tid_stats_mask_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -2317,33 +2279,32 @@ static int ath10k_tpc_stats_final_release(struct inode *inode,
 	return 0;
 }
 
-static ssize_t ath10k_tpc_stats_final_read(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_tpc_stats_final_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	unsigned int len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tpc_stats_final = {
 	.open = ath10k_tpc_stats_final_open,
 	.release = ath10k_tpc_stats_final_release,
-	.read = ath10k_tpc_stats_final_read,
+	.read_iter = ath10k_tpc_stats_final_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_warm_hw_reset(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_warm_hw_reset(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	bool val;
 
-	if (kstrtobool_from_user(user_buf, count, &val))
+	if (kstrtobool_from_iter(from, count, &val))
 		return -EFAULT;
 
 	if (!val)
@@ -2372,7 +2333,7 @@ static ssize_t ath10k_write_warm_hw_reset(struct file *file,
 }
 
 static const struct file_operations fops_warm_hw_reset = {
-	.write = ath10k_write_warm_hw_reset,
+	.write_iter = ath10k_write_warm_hw_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -2389,16 +2350,16 @@ static void ath10k_peer_ps_state_disable(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath10k_write_ps_state_enable(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath10k_write_ps_state_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u32 param;
 	u8 ps_state_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_state_enable))
 		return -EINVAL;
 
 	if (ps_state_enable > 1)
@@ -2433,11 +2394,10 @@ static ssize_t ath10k_write_ps_state_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_ps_state_enable(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_read_ps_state_enable(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[32];
 
@@ -2446,26 +2406,26 @@ static ssize_t ath10k_read_ps_state_enable(struct file *file,
 			ar->ps_state_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_state_enable = {
-	.read = ath10k_read_ps_state_enable,
-	.write = ath10k_write_ps_state_enable,
+	.read_iter = ath10k_read_ps_state_enable,
+	.write_iter = ath10k_write_ps_state_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_reset_htt_stats(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath10k_write_reset_htt_stats(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long reset;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &reset);
+	ret = kstrtoul_from_iter(from, count, 0, &reset);
 	if (ret)
 		return ret;
 
@@ -2489,7 +2449,7 @@ static ssize_t ath10k_write_reset_htt_stats(struct file *file,
 }
 
 static const struct file_operations fops_reset_htt_stats = {
-	.write = ath10k_write_reset_htt_stats,
+	.write_iter = ath10k_write_reset_htt_stats,
 	.owner = THIS_MODULE,
 	.open = simple_open,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath10k/debugfs_sta.c b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
index 394bf3c32abf..450ccb3b4483 100644
--- a/drivers/net/wireless/ath/ath10k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath10k/debugfs_sta.c
@@ -173,11 +173,10 @@ void ath10k_sta_update_rx_duration(struct ath10k *ar,
 		ath10k_sta_update_stats_rx_duration(ar, stats);
 }
 
-static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_read_aggr_mode(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
 	char buf[32];
@@ -189,20 +188,20 @@ static ssize_t ath10k_dbg_sta_read_aggr_mode(struct file *file,
 			"auto" : "manual");
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_dbg_sta_write_aggr_mode(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_write_aggr_mode(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
+	size_t count = iov_iter_count(from);
 	u32 aggr_mode;
 	int ret;
 
-	if (kstrtouint_from_user(user_buf, count, 0, &aggr_mode))
+	if (kstrtouint_from_iter(from, count, 0, &aggr_mode))
 		return -EINVAL;
 
 	if (aggr_mode >= ATH10K_DBG_AGGR_MODE_MAX)
@@ -228,26 +227,25 @@ static ssize_t ath10k_dbg_sta_write_aggr_mode(struct file *file,
 }
 
 static const struct file_operations fops_aggr_mode = {
-	.read = ath10k_dbg_sta_read_aggr_mode,
-	.write = ath10k_dbg_sta_write_aggr_mode,
+	.read_iter = ath10k_dbg_sta_read_aggr_mode,
+	.write_iter = ath10k_dbg_sta_write_aggr_mode,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_write_addba(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_write_addba(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
+	size_t count = iov_iter_count(from);
 	u32 tid, buf_size;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -280,25 +278,24 @@ static ssize_t ath10k_dbg_sta_write_addba(struct file *file,
 }
 
 static const struct file_operations fops_addba = {
-	.write = ath10k_dbg_sta_write_addba,
+	.write_iter = ath10k_dbg_sta_write_addba,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_write_addba_resp(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_write_addba_resp(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
+	size_t count = iov_iter_count(from);
 	u32 tid, status;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -330,25 +327,24 @@ static ssize_t ath10k_dbg_sta_write_addba_resp(struct file *file,
 }
 
 static const struct file_operations fops_addba_resp = {
-	.write = ath10k_dbg_sta_write_addba_resp,
+	.write_iter = ath10k_dbg_sta_write_addba_resp,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_write_delba(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_write_delba(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
+	size_t count = iov_iter_count(from);
 	u32 tid, initiator, reason;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -381,18 +377,16 @@ static ssize_t ath10k_dbg_sta_write_delba(struct file *file,
 }
 
 static const struct file_operations fops_delba = {
-	.write = ath10k_dbg_sta_write_delba,
+	.write_iter = ath10k_dbg_sta_write_delba,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_read_peer_debug_trigger(struct file *file,
-						      char __user *user_buf,
-						      size_t count,
-						      loff_t *ppos)
+static ssize_t ath10k_dbg_sta_read_peer_debug_trigger(struct kiocb *iocb,
+						      struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
 	char buf[8];
@@ -403,21 +397,21 @@ static ssize_t ath10k_dbg_sta_read_peer_debug_trigger(struct file *file,
 			"Write 1 to once trigger the debug logs\n");
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static ssize_t
-ath10k_dbg_sta_write_peer_debug_trigger(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+ath10k_dbg_sta_write_peer_debug_trigger(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
+	size_t count = iov_iter_count(from);
 	u8 peer_debug_trigger;
 	int ret;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &peer_debug_trigger))
+	if (kstrtou8_from_iter(from, count, 0, &peer_debug_trigger))
 		return -EINVAL;
 
 	if (peer_debug_trigger != 1)
@@ -444,17 +438,16 @@ ath10k_dbg_sta_write_peer_debug_trigger(struct file *file,
 
 static const struct file_operations fops_peer_debug_trigger = {
 	.open = simple_open,
-	.read = ath10k_dbg_sta_read_peer_debug_trigger,
-	.write = ath10k_dbg_sta_write_peer_debug_trigger,
+	.read_iter = ath10k_dbg_sta_read_peer_debug_trigger,
+	.write_iter = ath10k_dbg_sta_write_peer_debug_trigger,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_read_peer_ps_state(struct file *file,
-						 char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_read_peer_ps_state(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
 	char buf[20];
@@ -467,12 +460,12 @@ static ssize_t ath10k_dbg_sta_read_peer_ps_state(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_peer_ps_state = {
 	.open = simple_open,
-	.read = ath10k_dbg_sta_read_peer_ps_state,
+	.read_iter = ath10k_dbg_sta_read_peer_ps_state,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -560,11 +553,10 @@ static char *get_num_amsdu_subfrm_str(enum ath10k_amsdu_subfrm_num i)
 		len += scnprintf(buf + len, buf_len - len, "\n"); \
 	} while (0)
 
-static ssize_t ath10k_dbg_sta_read_tid_stats(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_read_tid_stats(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
 	struct ath10k_sta_tid_stats *stats = arsta->tid_stats;
@@ -627,7 +619,7 @@ static ssize_t ath10k_dbg_sta_read_tid_stats(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 
@@ -638,16 +630,15 @@ static ssize_t ath10k_dbg_sta_read_tid_stats(struct file *file,
 
 static const struct file_operations fops_tid_stats_dump = {
 	.open = simple_open,
-	.read = ath10k_dbg_sta_read_tid_stats,
+	.read_iter = ath10k_dbg_sta_read_tid_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
-					    char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath10k_dbg_sta_dump_tx_stats(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ath10k *ar = arsta->arvif->ar;
 	struct ath10k_htt_data_stats *stats;
@@ -741,7 +732,7 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
 
 	if (len > size)
 		len = size;
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	mutex_unlock(&ar->conf_mutex);
@@ -749,7 +740,7 @@ static ssize_t ath10k_dbg_sta_dump_tx_stats(struct file *file,
 }
 
 static const struct file_operations fops_tx_stats = {
-	.read = ath10k_dbg_sta_dump_tx_stats,
+	.read_iter = ath10k_dbg_sta_dump_tx_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c
index 2240994390ed..b427749a3c63 100644
--- a/drivers/net/wireless/ath/ath10k/spectral.c
+++ b/drivers/net/wireless/ath/ath10k/spectral.c
@@ -270,10 +270,9 @@ static int ath10k_spectral_scan_config(struct ath10k *ar,
 	return 0;
 }
 
-static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t read_file_spec_scan_ctl(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char *mode = "";
 	size_t len;
 	enum ath10k_spectral_mode spectral_mode;
@@ -295,20 +294,20 @@ static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
 	}
 
 	len = strlen(mode);
-	return simple_read_from_buffer(user_buf, count, ppos, mode, len);
+	return simple_copy_to_iter(mode, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spec_scan_ctl(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t write_file_spec_scan_ctl(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	int res;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -354,18 +353,16 @@ static ssize_t write_file_spec_scan_ctl(struct file *file,
 }
 
 static const struct file_operations fops_spec_scan_ctl = {
-	.read = read_file_spec_scan_ctl,
-	.write = write_file_spec_scan_ctl,
+	.read_iter = read_file_spec_scan_ctl,
+	.write_iter = write_file_spec_scan_ctl,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_spectral_count(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_count(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 	u8 spectral_count;
@@ -375,18 +372,18 @@ static ssize_t read_file_spectral_count(struct file *file,
 	mutex_unlock(&ar->conf_mutex);
 
 	len = sprintf(buf, "%d\n", spectral_count);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_count(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_count(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -401,18 +398,16 @@ static ssize_t write_file_spectral_count(struct file *file,
 }
 
 static const struct file_operations fops_spectral_count = {
-	.read = read_file_spectral_count,
-	.write = write_file_spectral_count,
+	.read_iter = read_file_spectral_count,
+	.write_iter = write_file_spectral_count,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_spectral_bins(struct file *file,
-				       char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t read_file_spectral_bins(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int bins, fft_size, bin_scale;
 	size_t len;
@@ -426,18 +421,18 @@ static ssize_t read_file_spectral_bins(struct file *file,
 	mutex_unlock(&ar->conf_mutex);
 
 	len = sprintf(buf, "%d\n", bins);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_spectral_bins(struct file *file,
-					const char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t write_file_spectral_bins(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -456,8 +451,8 @@ static ssize_t write_file_spectral_bins(struct file *file,
 }
 
 static const struct file_operations fops_spectral_bins = {
-	.read = read_file_spectral_bins,
-	.write = write_file_spectral_bins,
+	.read_iter = read_file_spectral_bins,
+	.write_iter = write_file_spectral_bins,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 305/437] drivers/net/wireless/ath/ath11k: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (303 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 304/437] drivers/net/wireless/ath/ath10k: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 306/437] drivers/net/wireless/broadcom: " Jens Axboe
                   ` (132 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/ath/ath11k/debugfs.c     | 300 ++++++++----------
 .../wireless/ath/ath11k/debugfs_htt_stats.c   |  56 ++--
 drivers/net/wireless/ath/ath11k/debugfs_sta.c | 163 +++++-----
 drivers/net/wireless/ath/ath11k/spectral.c    |  69 ++--
 4 files changed, 274 insertions(+), 314 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/debugfs.c b/drivers/net/wireless/ath/ath11k/debugfs.c
index a48e737ef35d..f51afdf83a89 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -296,20 +296,18 @@ static int ath11k_release_pdev_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_pdev_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_pdev_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pdev_stats = {
 	.open = ath11k_open_pdev_stats,
 	.release = ath11k_release_pdev_stats,
-	.read = ath11k_read_pdev_stats,
+	.read_iter = ath11k_read_pdev_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -367,20 +365,18 @@ static int ath11k_release_vdev_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_vdev_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_vdev_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_vdev_stats = {
 	.open = ath11k_open_vdev_stats,
 	.release = ath11k_release_vdev_stats,
-	.read = ath11k_read_vdev_stats,
+	.read_iter = ath11k_read_vdev_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -451,34 +447,31 @@ static int ath11k_release_bcn_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_bcn_stats(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_bcn_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_bcn_stats = {
 	.open = ath11k_open_bcn_stats,
 	.release = ath11k_release_bcn_stats,
-	.read = ath11k_read_bcn_stats,
+	.read_iter = ath11k_read_bcn_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_read_simulate_fw_crash(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_simulate_fw_crash(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	const char buf[] =
 		"To simulate firmware crash write one of the keywords to this file:\n"
 		"`assert` - this will send WMI_FORCE_FW_HANG_CMDID to firmware to cause assert.\n"
 		"`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 /* Simulate firmware crash:
@@ -488,11 +481,11 @@ static ssize_t ath11k_read_simulate_fw_crash(struct file *file,
  * vdev id. This is hard firmware crash because it is recoverable only by cold
  * firmware reset.
  */
-static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_simulate_fw_crash(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k_base *ab = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_pdev *pdev;
 	struct ath11k *ar = ab->pdevs[0].ar;
 	char buf[32] = {0};
@@ -508,16 +501,16 @@ static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
 		}
 	}
 	/* filter partial writes and invalid commands */
-	if (*ppos != 0 || count >= sizeof(buf) || count == 0)
+	if (iocb->ki_pos != 0 || count >= sizeof(buf) || count == 0)
 		return -EINVAL;
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
 	/* drop the possible '\n' from the end */
-	if (buf[*ppos - 1] == '\n')
-		buf[*ppos - 1] = '\0';
+	if (buf[iocb->ki_pos - 1] == '\n')
+		buf[iocb->ki_pos - 1] = '\0';
 
 	if (radioup == 0) {
 		ret = -ENETDOWN;
@@ -550,22 +543,22 @@ static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
 }
 
 static const struct file_operations fops_simulate_fw_crash = {
-	.read = ath11k_read_simulate_fw_crash,
-	.write = ath11k_write_simulate_fw_crash,
+	.read_iter = ath11k_read_simulate_fw_crash,
+	.write_iter = ath11k_write_simulate_fw_crash,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
-						 const char __user *ubuf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath11k_write_enable_extd_tx_stats(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -588,13 +581,11 @@ static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
-						char __user *ubuf,
-						size_t count, loff_t *ppos)
-
+static ssize_t ath11k_read_enable_extd_tx_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 {
 	char buf[32] = {0};
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -602,27 +593,27 @@ static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
 			ar->debug.extd_tx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_extd_tx_stats = {
-	.read = ath11k_read_enable_extd_tx_stats,
-	.write = ath11k_write_enable_extd_tx_stats,
+	.read_iter = ath11k_read_enable_extd_tx_stats,
+	.write_iter = ath11k_write_enable_extd_tx_stats,
 	.open = simple_open
 };
 
-static ssize_t ath11k_write_extd_rx_stats(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_write_extd_rx_stats(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_base *ab = ar->ab;
 	struct htt_rx_ring_tlv_filter tlv_filter = {0};
 	u32 enable, rx_filter = 0, ring_id;
 	int i;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &enable))
+	if (kstrtouint_from_iter(from, count, 0, &enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -687,11 +678,9 @@ static ssize_t ath11k_write_extd_rx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_extd_rx_stats(struct file *file,
-					 char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath11k_read_extd_rx_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len = 0;
 
@@ -700,12 +689,12 @@ static ssize_t ath11k_read_extd_rx_stats(struct file *file,
 			ar->debug.extd_rx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_extd_rx_stats = {
-	.read = ath11k_read_extd_rx_stats,
-	.write = ath11k_write_extd_rx_stats,
+	.read_iter = ath11k_read_extd_rx_stats,
+	.write_iter = ath11k_write_extd_rx_stats,
 	.open = simple_open,
 };
 
@@ -775,11 +764,10 @@ static ssize_t ath11k_debugfs_dump_soc_ring_bp_stats(struct ath11k_base *ab,
 	return len;
 }
 
-static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath11k_base *ab = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->private_data;
 	struct ath11k_soc_dp_stats *soc_stats = &ab->soc_stats;
 	int len = 0, i, retval;
 	const int size = 4096;
@@ -839,32 +827,30 @@ static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file,
 
 	if (len > size)
 		len = size;
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_soc_dp_stats = {
-	.read = ath11k_debugfs_dump_soc_dp_stats,
+	.read_iter = ath11k_debugfs_dump_soc_dp_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_fw_dbglog(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_fw_dbglog(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[128] = {0};
 	struct ath11k_fw_dbglog dbglog;
 	unsigned int param, mod_id_index, is_end;
 	u64 value;
 	int ret, num;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -909,7 +895,7 @@ static ssize_t ath11k_write_fw_dbglog(struct file *file,
 }
 
 static const struct file_operations fops_fw_dbglog = {
-	.write = ath11k_write_fw_dbglog,
+	.write_iter = ath11k_write_fw_dbglog,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -940,12 +926,10 @@ static int ath11k_open_sram_dump(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_sram_dump(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_sram_dump(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath11k_base *ab = file->f_inode->i_private;
-	const char *buf = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->f_inode->i_private;
+	const char *buf = iocb->ki_filp->private_data;
 	int len;
 	u32 start, end;
 
@@ -953,7 +937,7 @@ static ssize_t ath11k_read_sram_dump(struct file *file,
 	end = ab->hw_params.sram_dump.end;
 	len = end - start + 1;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static int ath11k_release_sram_dump(struct inode *inode, struct file *file)
@@ -966,7 +950,7 @@ static int ath11k_release_sram_dump(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_sram_dump = {
 	.open = ath11k_open_sram_dump,
-	.read = ath11k_read_sram_dump,
+	.read_iter = ath11k_read_sram_dump,
 	.release = ath11k_release_sram_dump,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1064,11 +1048,11 @@ void ath11k_debugfs_fw_stats_init(struct ath11k *ar)
 			    &fops_bcn_stats);
 }
 
-static ssize_t ath11k_write_pktlog_filter(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_write_pktlog_filter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_base *ab = ar->ab;
 	struct htt_rx_ring_tlv_filter tlv_filter = {0};
 	u32 rx_filter = 0, ring_id, filter, mode;
@@ -1082,7 +1066,7 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
 		goto out;
 	}
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0) {
 		ret = rc;
 		goto out;
@@ -1196,13 +1180,12 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_pktlog_filter(struct file *file,
-					 char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath11k_read_pktlog_filter(struct kiocb *iocb,
+					 struct iov_iter *to)
 
 {
 	char buf[32] = {0};
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1211,20 +1194,20 @@ static ssize_t ath11k_read_pktlog_filter(struct file *file,
 			ar->debug.pktlog_mode);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pktlog_filter = {
-	.read = ath11k_read_pktlog_filter,
-	.write = ath11k_write_pktlog_filter,
+	.read_iter = ath11k_read_pktlog_filter,
+	.write_iter = ath11k_write_pktlog_filter,
 	.open = simple_open
 };
 
-static ssize_t ath11k_write_simulate_radar(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_simulate_radar(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	ret = ath11k_wmi_simulate_radar(ar);
@@ -1235,15 +1218,14 @@ static ssize_t ath11k_write_simulate_radar(struct file *file,
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = ath11k_write_simulate_radar,
+	.write_iter = ath11k_write_simulate_radar,
 	.open = simple_open
 };
 
-static ssize_t ath11k_debug_dump_dbr_entries(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_debug_dump_dbr_entries(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ath11k_dbg_dbr_data *dbr_dbg_data = file->private_data;
+	struct ath11k_dbg_dbr_data *dbr_dbg_data = iocb->ki_filp->private_data;
 	static const char * const event_id_to_string[] = {"empty", "Rx", "Replenish"};
 	int size = ATH11K_DEBUG_DBR_ENTRIES_MAX * 100;
 	char *buf;
@@ -1274,14 +1256,14 @@ static ssize_t ath11k_debug_dump_dbr_entries(struct file *file,
 
 	spin_unlock_bh(&dbr_dbg_data->lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return ret;
 }
 
 static const struct file_operations fops_debug_dump_dbr_entries = {
-	.read = ath11k_debug_dump_dbr_entries,
+	.read_iter = ath11k_debug_dump_dbr_entries,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1350,11 +1332,11 @@ static int ath11k_debugfs_dbr_dbg_init(struct ath11k *ar, int dbr_id)
 	return 0;
 }
 
-static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
-						   const char __user *ubuf,
-						   size_t count, loff_t *ppos)
+static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32] = {0};
 	u32 dbr_id, enable;
 	int ret;
@@ -1366,7 +1348,7 @@ static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
 		goto out;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		goto out;
 
@@ -1396,21 +1378,21 @@ static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
 }
 
 static const struct file_operations fops_dbr_debug = {
-	.write = ath11k_debugfs_write_enable_dbr_dbg,
+	.write_iter = ath11k_debugfs_write_enable_dbr_dbg,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_ps_timekeeper_enable(struct file *file,
-						 const char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath11k_write_ps_timekeeper_enable(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	u8 ps_timekeeper_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_timekeeper_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_timekeeper_enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1433,11 +1415,10 @@ static ssize_t ath11k_write_ps_timekeeper_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_ps_timekeeper_enable(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_read_ps_timekeeper_enable(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len;
 
@@ -1445,12 +1426,12 @@ static ssize_t ath11k_read_ps_timekeeper_enable(struct file *file,
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ps_timekeeper_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_timekeeper_enable = {
-	.read = ath11k_read_ps_timekeeper_enable,
-	.write = ath11k_write_ps_timekeeper_enable,
+	.read_iter = ath11k_read_ps_timekeeper_enable,
+	.write_iter = ath11k_write_ps_timekeeper_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1467,15 +1448,15 @@ static void ath11k_reset_peer_ps_duration(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath11k_write_reset_ps_duration(struct file *file,
-					      const  char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_reset_ps_duration(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 reset_ps_duration;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &reset_ps_duration))
+	if (kstrtou8_from_iter(from, count, 0, &reset_ps_duration))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1501,7 +1482,7 @@ static ssize_t ath11k_write_reset_ps_duration(struct file *file,
 }
 
 static const struct file_operations fops_reset_ps_duration = {
-	.write = ath11k_write_reset_ps_duration,
+	.write_iter = ath11k_write_reset_ps_duration,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1520,17 +1501,17 @@ static void ath11k_peer_ps_state_disable(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath11k_write_ps_state_enable(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath11k_write_ps_state_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_pdev *pdev = ar->pdev;
 	int ret;
 	u32 param;
 	u8 ps_state_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_state_enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1566,11 +1547,10 @@ static ssize_t ath11k_write_ps_state_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_ps_state_enable(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_read_ps_state_enable(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len;
 
@@ -1578,12 +1558,12 @@ static ssize_t ath11k_read_ps_state_enable(struct file *file,
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ps_state_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_state_enable = {
-	.read = ath11k_read_ps_state_enable,
-	.write = ath11k_write_ps_state_enable,
+	.read_iter = ath11k_read_ps_state_enable,
+	.write_iter = ath11k_write_ps_state_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1671,13 +1651,13 @@ void ath11k_debugfs_unregister(struct ath11k *ar)
 	}
 }
 
-static ssize_t ath11k_write_twt_add_dialog(struct file *file,
-					   const char __user *ubuf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_add_dialog(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
 	struct wmi_twt_add_dialog_params params = { 0 };
 	struct wmi_twt_enable_params twt_params = {0};
+	size_t count = iov_iter_count(from);
 	struct ath11k *ar = arvif->ar;
 	u8 buf[128] = {0};
 	int ret;
@@ -1687,7 +1667,7 @@ static ssize_t ath11k_write_twt_add_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1747,11 +1727,11 @@ static ssize_t ath11k_write_twt_add_dialog(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_write_twt_del_dialog(struct file *file,
-					   const char __user *ubuf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_del_dialog(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_del_dialog_params params = { 0 };
 	struct wmi_twt_enable_params twt_params = {0};
 	struct ath11k *ar = arvif->ar;
@@ -1763,7 +1743,7 @@ static ssize_t ath11k_write_twt_del_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1794,11 +1774,11 @@ static ssize_t ath11k_write_twt_del_dialog(struct file *file,
 	return count;
 }
 
-static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
-					     const char __user *ubuf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_pause_dialog(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_pause_dialog_params params = { 0 };
 	u8 buf[64] = {0};
 	int ret;
@@ -1808,7 +1788,7 @@ static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1833,11 +1813,11 @@ static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
 	return count;
 }
 
-static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
-					      const char __user *ubuf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_resume_dialog(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_resume_dialog_params params = { 0 };
 	u8 buf[64] = {0};
 	int ret;
@@ -1847,7 +1827,7 @@ static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1875,22 +1855,22 @@ static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
 }
 
 static const struct file_operations ath11k_fops_twt_add_dialog = {
-	.write = ath11k_write_twt_add_dialog,
+	.write_iter = ath11k_write_twt_add_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_del_dialog = {
-	.write = ath11k_write_twt_del_dialog,
+	.write_iter = ath11k_write_twt_del_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_pause_dialog = {
-	.write = ath11k_write_twt_pause_dialog,
+	.write_iter = ath11k_write_twt_pause_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_resume_dialog = {
-	.write = ath11k_write_twt_resume_dialog,
+	.write_iter = ath11k_write_twt_resume_dialog,
 	.open = simple_open
 };
 
diff --git a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
index 870e86a31bf8..d2b444ad7157 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c
@@ -4601,28 +4601,27 @@ void ath11k_debugfs_htt_ext_stats_handler(struct ath11k_base *ab,
 		complete(&stats_req->cmpln);
 }
 
-static ssize_t ath11k_read_htt_stats_type(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_read_htt_stats_type(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%u\n", ar->debug.htt_stats.type);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_write_htt_stats_type(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_htt_stats_type(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 type;
 	int ret;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &type);
+	ret = kstrtou8_from_iter(from, count, 0, &type);
 	if (ret)
 		return ret;
 
@@ -4640,8 +4639,8 @@ static ssize_t ath11k_write_htt_stats_type(struct file *file,
 }
 
 static const struct file_operations fops_htt_stats_type = {
-	.read = ath11k_read_htt_stats_type,
-	.write = ath11k_write_htt_stats_type,
+	.read_iter = ath11k_read_htt_stats_type,
+	.write_iter = ath11k_write_htt_stats_type,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -4812,50 +4811,47 @@ static int ath11k_release_htt_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_htt_stats(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_htt_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debug_htt_stats_req *stats_req = file->private_data;
+	struct debug_htt_stats_req *stats_req = iocb->ki_filp->private_data;
 	char *buf;
 	u32 length = 0;
 
 	buf = stats_req->buf;
 	length = min_t(u32, stats_req->buf_len, ATH11K_HTT_STATS_BUF_SIZE);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, length);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations fops_dump_htt_stats = {
 	.open = ath11k_open_htt_stats,
 	.release = ath11k_release_htt_stats,
-	.read = ath11k_read_htt_stats,
+	.read_iter = ath11k_read_htt_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_read_htt_stats_reset(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_read_htt_stats_reset(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%u\n", ar->debug.htt_stats.reset);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_write_htt_stats_reset(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath11k_write_htt_stats_reset(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 type;
 	struct htt_ext_stats_cfg_params cfg_params = { 0 };
 	int ret;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &type);
+	ret = kstrtou8_from_iter(from, count, 0, &type);
 	if (ret)
 		return ret;
 
@@ -4885,8 +4881,8 @@ static ssize_t ath11k_write_htt_stats_reset(struct file *file,
 }
 
 static const struct file_operations fops_htt_stats_reset = {
-	.read = ath11k_read_htt_stats_reset,
-	.write = ath11k_write_htt_stats_reset,
+	.read_iter = ath11k_read_htt_stats_reset,
+	.write_iter = ath11k_write_htt_stats_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
diff --git a/drivers/net/wireless/ath/ath11k/debugfs_sta.c b/drivers/net/wireless/ath/ath11k/debugfs_sta.c
index f56a24b6c8da..19b2e974b484 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs_sta.c
@@ -132,11 +132,10 @@ void ath11k_debugfs_sta_update_txcompl(struct ath11k *ar,
 	ath11k_dp_tx_update_txcompl(ar, ts);
 }
 
-static ssize_t ath11k_dbg_sta_dump_tx_stats(struct file *file,
-					    char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_dump_tx_stats(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	struct ath11k_htt_data_stats *stats;
@@ -225,7 +224,7 @@ static ssize_t ath11k_dbg_sta_dump_tx_stats(struct file *file,
 
 	if (len > size)
 		len = size;
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	mutex_unlock(&ar->conf_mutex);
@@ -233,17 +232,16 @@ static ssize_t ath11k_dbg_sta_dump_tx_stats(struct file *file,
 }
 
 static const struct file_operations fops_tx_stats = {
-	.read = ath11k_dbg_sta_dump_tx_stats,
+	.read_iter = ath11k_dbg_sta_dump_tx_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_dump_rx_stats(struct file *file,
-					    char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_dump_rx_stats(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	struct ath11k_rx_peer_stats *rx_stats = arsta->rx_stats;
@@ -323,7 +321,7 @@ static ssize_t ath11k_dbg_sta_dump_rx_stats(struct file *file,
 
 	if (len > size)
 		len = size;
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	mutex_unlock(&ar->conf_mutex);
@@ -331,7 +329,7 @@ static ssize_t ath11k_dbg_sta_dump_rx_stats(struct file *file,
 }
 
 static const struct file_operations fops_rx_stats = {
-	.read = ath11k_dbg_sta_dump_rx_stats,
+	.read_iter = ath11k_dbg_sta_dump_rx_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -388,32 +386,31 @@ ath11k_dbg_sta_release_htt_peer_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_dbg_sta_read_htt_peer_stats(struct file *file,
-						  char __user *user_buf,
-						  size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_htt_peer_stats(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
-	struct debug_htt_stats_req *stats_req = file->private_data;
+	struct debug_htt_stats_req *stats_req = iocb->ki_filp->private_data;
 	char *buf;
 	u32 length = 0;
 
 	buf = stats_req->buf;
 	length = min_t(u32, stats_req->buf_len, ATH11K_HTT_STATS_BUF_SIZE);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, length);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, length, to);
 }
 
 static const struct file_operations fops_htt_peer_stats = {
 	.open = ath11k_dbg_sta_open_htt_peer_stats,
 	.release = ath11k_dbg_sta_release_htt_peer_stats,
-	.read = ath11k_dbg_sta_read_htt_peer_stats,
+	.read_iter = ath11k_dbg_sta_read_htt_peer_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
-						const char __user *buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	int ret, enable;
@@ -425,7 +422,7 @@ static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
 		goto out;
 	}
 
-	ret = kstrtoint_from_user(buf, count, 0, &enable);
+	ret = kstrtoint_from_iter(from, count, 0, &enable);
 	if (ret)
 		goto out;
 
@@ -449,11 +446,10 @@ static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_dbg_sta_read_peer_pktlog(struct file *file,
-					       char __user *ubuf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_peer_pktlog(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	char buf[32] = {0};
@@ -465,30 +461,29 @@ static ssize_t ath11k_dbg_sta_read_peer_pktlog(struct file *file,
 			ar->debug.pktlog_peer_addr);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_peer_pktlog = {
-	.write = ath11k_dbg_sta_write_peer_pktlog,
-	.read = ath11k_dbg_sta_read_peer_pktlog,
+	.write_iter = ath11k_dbg_sta_write_peer_pktlog,
+	.read_iter = ath11k_dbg_sta_read_peer_pktlog,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_write_delba(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_write_delba(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	u32 tid, initiator, reason;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -521,25 +516,24 @@ static ssize_t ath11k_dbg_sta_write_delba(struct file *file,
 }
 
 static const struct file_operations fops_delba = {
-	.write = ath11k_dbg_sta_write_delba,
+	.write_iter = ath11k_dbg_sta_write_delba,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_write_addba_resp(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_write_addba_resp(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	u32 tid, status;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -571,25 +565,24 @@ static ssize_t ath11k_dbg_sta_write_addba_resp(struct file *file,
 }
 
 static const struct file_operations fops_addba_resp = {
-	.write = ath11k_dbg_sta_write_addba_resp,
+	.write_iter = ath11k_dbg_sta_write_addba_resp,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_write_addba(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_write_addba(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	u32 tid, buf_size;
 	int ret;
 	char buf[64] = {0};
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -622,17 +615,16 @@ static ssize_t ath11k_dbg_sta_write_addba(struct file *file,
 }
 
 static const struct file_operations fops_addba = {
-	.write = ath11k_dbg_sta_write_addba,
+	.write_iter = ath11k_dbg_sta_write_addba,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_read_aggr_mode(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_aggr_mode(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	char buf[64];
@@ -645,20 +637,20 @@ static ssize_t ath11k_dbg_sta_read_aggr_mode(struct file *file,
 			"auto" : "manual", "auto = 0", "manual = 1");
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_dbg_sta_write_aggr_mode(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_write_aggr_mode(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	u32 aggr_mode;
 	int ret;
 
-	if (kstrtouint_from_user(user_buf, count, 0, &aggr_mode))
+	if (kstrtouint_from_iter(from, count, 0, &aggr_mode))
 		return -EINVAL;
 
 	if (aggr_mode >= ATH11K_DBG_AGGR_MODE_MAX)
@@ -685,26 +677,25 @@ static ssize_t ath11k_dbg_sta_write_aggr_mode(struct file *file,
 }
 
 static const struct file_operations fops_aggr_mode = {
-	.read = ath11k_dbg_sta_read_aggr_mode,
-	.write = ath11k_dbg_sta_write_aggr_mode,
+	.read_iter = ath11k_dbg_sta_read_aggr_mode,
+	.write_iter = ath11k_dbg_sta_write_aggr_mode,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
 static ssize_t
-ath11k_write_htt_peer_stats_reset(struct file *file,
-				  const char __user *user_buf,
-				  size_t count, loff_t *ppos)
+ath11k_write_htt_peer_stats_reset(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	struct htt_ext_stats_cfg_params cfg_params = { 0 };
 	int ret;
 	u8 type;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &type);
+	ret = kstrtou8_from_iter(from, count, 0, &type);
 	if (ret)
 		return ret;
 
@@ -746,17 +737,16 @@ ath11k_write_htt_peer_stats_reset(struct file *file,
 }
 
 static const struct file_operations fops_htt_peer_stats_reset = {
-	.write = ath11k_write_htt_peer_stats_reset,
+	.write_iter = ath11k_write_htt_peer_stats_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_read_peer_ps_state(struct file *file,
-						 char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_peer_ps_state(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	char buf[20];
@@ -768,22 +758,20 @@ static ssize_t ath11k_dbg_sta_read_peer_ps_state(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_peer_ps_state = {
 	.open = simple_open,
-	.read = ath11k_dbg_sta_read_peer_ps_state,
+	.read_iter = ath11k_dbg_sta_read_peer_ps_state,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_read_current_ps_duration(struct file *file,
-						       char __user *user_buf,
-						       size_t count,
-						       loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_current_ps_duration(struct kiocb *iocb,
+						       struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	u64 time_since_station_in_power_save;
@@ -803,21 +791,20 @@ static ssize_t ath11k_dbg_sta_read_current_ps_duration(struct file *file,
 			time_since_station_in_power_save);
 	spin_unlock_bh(&ar->data_lock);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_current_ps_duration = {
 	.open = simple_open,
-	.read = ath11k_dbg_sta_read_current_ps_duration,
+	.read_iter = ath11k_dbg_sta_read_current_ps_duration,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_dbg_sta_read_total_ps_duration(struct file *file,
-						     char __user *user_buf,
-						     size_t count, loff_t *ppos)
+static ssize_t ath11k_dbg_sta_read_total_ps_duration(struct kiocb *iocb,
+						     struct iov_iter *to)
 {
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct ath11k_sta *arsta = ath11k_sta_to_arsta(sta);
 	struct ath11k *ar = arsta->arvif->ar;
 	char buf[20];
@@ -838,12 +825,12 @@ static ssize_t ath11k_dbg_sta_read_total_ps_duration(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_total_ps_duration = {
 	.open = simple_open,
-	.read = ath11k_dbg_sta_read_total_ps_duration,
+	.read_iter = ath11k_dbg_sta_read_total_ps_duration,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
diff --git a/drivers/net/wireless/ath/ath11k/spectral.c b/drivers/net/wireless/ath/ath11k/spectral.c
index 79e091134515..77f3830dbb3a 100644
--- a/drivers/net/wireless/ath/ath11k/spectral.c
+++ b/drivers/net/wireless/ath/ath11k/spectral.c
@@ -266,11 +266,10 @@ static int ath11k_spectral_scan_config(struct ath11k *ar,
 	return 0;
 }
 
-static ssize_t ath11k_read_file_spec_scan_ctl(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_file_spec_scan_ctl(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char *mode = "";
 	size_t len;
 	enum ath11k_spectral_mode spectral_mode;
@@ -292,20 +291,20 @@ static ssize_t ath11k_read_file_spec_scan_ctl(struct file *file,
 	}
 
 	len = strlen(mode);
-	return simple_read_from_buffer(user_buf, count, ppos, mode, len);
+	return simple_copy_to_iter(mode, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_write_file_spec_scan_ctl(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath11k_write_file_spec_scan_ctl(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	int ret;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -353,18 +352,17 @@ static ssize_t ath11k_write_file_spec_scan_ctl(struct file *file,
 }
 
 static const struct file_operations fops_scan_ctl = {
-	.read = ath11k_read_file_spec_scan_ctl,
-	.write = ath11k_write_file_spec_scan_ctl,
+	.read_iter = ath11k_read_file_spec_scan_ctl,
+	.write_iter = ath11k_write_file_spec_scan_ctl,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_read_file_spectral_count(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath11k_read_file_spectral_count(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 	u16 spectral_count;
@@ -374,18 +372,18 @@ static ssize_t ath11k_read_file_spectral_count(struct file *file,
 	mutex_unlock(&ar->conf_mutex);
 
 	len = sprintf(buf, "%d\n", spectral_count);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_write_file_spectral_count(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_write_file_spectral_count(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -400,18 +398,17 @@ static ssize_t ath11k_write_file_spectral_count(struct file *file,
 }
 
 static const struct file_operations fops_scan_count = {
-	.read = ath11k_read_file_spectral_count,
-	.write = ath11k_write_file_spectral_count,
+	.read_iter = ath11k_read_file_spectral_count,
+	.write_iter = ath11k_write_file_spectral_count,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_read_file_spectral_bins(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_file_spectral_bins(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int bins, fft_size;
 	size_t len;
@@ -424,18 +421,18 @@ static ssize_t ath11k_read_file_spectral_bins(struct file *file,
 	mutex_unlock(&ar->conf_mutex);
 
 	len = sprintf(buf, "%d\n", bins);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath11k_write_file_spectral_bins(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath11k_write_file_spectral_bins(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -454,8 +451,8 @@ static ssize_t ath11k_write_file_spectral_bins(struct file *file,
 }
 
 static const struct file_operations fops_scan_bins = {
-	.read = ath11k_read_file_spectral_bins,
-	.write = ath11k_write_file_spectral_bins,
+	.read_iter = ath11k_read_file_spectral_bins,
+	.write_iter = ath11k_write_file_spectral_bins,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 306/437] drivers/net/wireless/broadcom: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (304 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 305/437] drivers/net/wireless/ath/ath11k: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 307/437] drivers/net/wireless/ralink: " Jens Axboe
                   ` (131 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/broadcom/b43/debugfs.c   | 30 +++++++++---------
 .../net/wireless/broadcom/b43legacy/debugfs.c | 31 +++++++++----------
 .../broadcom/brcm80211/brcmfmac/core.c        | 10 +++---
 .../broadcom/brcm80211/brcmsmac/debug.c       |  2 +-
 4 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/debugfs.c b/drivers/net/wireless/broadcom/b43/debugfs.c
index efa98444e3fb..bd82fc337500 100644
--- a/drivers/net/wireless/broadcom/b43/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43/debugfs.c
@@ -487,8 +487,7 @@ static ssize_t loctls_read_file(struct b43_wldev *dev,
 
 #undef fappend
 
-static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct b43_wldev *dev;
 	struct b43_debugfs_fops *dfops;
@@ -497,11 +496,12 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 	char *buf;
 	const size_t bufsize = 1024 * 16; /* 16 kiB buffer */
 	const size_t buforder = get_order(bufsize);
+	size_t count = iov_iter_count(to);
 	int err = 0;
 
 	if (!count)
 		return 0;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -511,7 +511,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
@@ -536,10 +536,9 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 		dfile->buffer = buf;
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos,
-				      dfile->buffer,
-				      dfile->data_len);
-	if (*ppos >= dfile->data_len) {
+	ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos, dfile->data_len,
+				  to);
+	if (iocb->ki_pos >= dfile->data_len) {
 		free_pages((unsigned long)dfile->buffer, buforder);
 		dfile->buffer = NULL;
 		dfile->data_len = 0;
@@ -550,12 +549,11 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 	return err ? err : ret;
 }
 
-static ssize_t b43_debugfs_write(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct b43_wldev *dev;
 	struct b43_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err = 0;
 
@@ -563,7 +561,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		return 0;
 	if (count > PAGE_SIZE)
 		return -E2BIG;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -573,7 +571,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
@@ -585,7 +583,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		err = -ENOMEM;
 		goto out_unlock;
 	}
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_freepage;
 	}
@@ -608,8 +606,8 @@ static ssize_t b43_debugfs_write(struct file *file,
 		.write	= _write,				\
 		.fops	= {					\
 			.open	= simple_open,			\
-			.read	= b43_debugfs_read,		\
-			.write	= b43_debugfs_write,		\
+			.read_iter	= b43_debugfs_read,	\
+			.write_iter	= b43_debugfs_write,	\
 			.llseek = generic_file_llseek,		\
 		},						\
 		.file_struct_offset = offsetof(struct b43_dfsentry, \
diff --git a/drivers/net/wireless/broadcom/b43legacy/debugfs.c b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
index 6b0e8d117061..3746e2fab874 100644
--- a/drivers/net/wireless/broadcom/b43legacy/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
@@ -184,8 +184,7 @@ static int restart_write_file(struct b43legacy_wldev *dev, const char *buf, size
 
 #undef fappend
 
-static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct b43legacy_wldev *dev;
 	struct b43legacy_debugfs_fops *dfops;
@@ -194,11 +193,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 	char *buf;
 	const size_t bufsize = 1024 * 16; /* 16 KiB buffer */
 	const size_t buforder = get_order(bufsize);
+	size_t count = iov_iter_count(to);
 	int err = 0;
 
 	if (!count)
 		return 0;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -208,7 +208,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
@@ -238,10 +238,9 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 		dfile->buffer = buf;
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos,
-				      dfile->buffer,
-				      dfile->data_len);
-	if (*ppos >= dfile->data_len) {
+	ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos,
+				  dfile->data_len, to);
+	if (iocb->ki_pos >= dfile->data_len) {
 		free_pages((unsigned long)dfile->buffer, buforder);
 		dfile->buffer = NULL;
 		dfile->data_len = 0;
@@ -252,12 +251,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 	return err ? err : ret;
 }
 
-static ssize_t b43legacy_debugfs_write(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	struct b43legacy_wldev *dev;
 	struct b43legacy_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err = 0;
 
@@ -265,7 +264,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		return 0;
 	if (count > PAGE_SIZE)
 		return -E2BIG;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -275,7 +274,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
@@ -287,7 +286,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		err = -ENOMEM;
 		goto out_unlock;
 	}
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_freepage;
 	}
@@ -315,8 +314,8 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		.write	= _write,				\
 		.fops	= {					\
 			.open	= simple_open,				\
-			.read	= b43legacy_debugfs_read,		\
-			.write	= b43legacy_debugfs_write,		\
+			.read_iter	= b43legacy_debugfs_read,	\
+			.write_iter	= b43legacy_debugfs_write,	\
 			.llseek = generic_file_llseek,			\
 		},						\
 		.file_struct_offset = offsetof(struct b43legacy_dfsentry, \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index bf91b1e1368f..d02dd7944bad 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1165,13 +1165,13 @@ static void brcmf_core_bus_reset(struct work_struct *work)
 	brcmf_bus_reset(drvr->bus_if);
 }
 
-static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t bus_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct brcmf_pub *drvr = file->private_data;
+	struct brcmf_pub *drvr = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 value;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &value))
+	if (kstrtou8_from_iter(from, count, 0, &value))
 		return -EINVAL;
 
 	if (value != 1)
@@ -1185,7 +1185,7 @@ static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
 static const struct file_operations bus_reset_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= bus_reset_write,
+	.write_iter	= bus_reset_write,
 };
 
 static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
index 6d776ef6ff54..cfc7ff6d3503 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
@@ -182,7 +182,7 @@ static const struct file_operations brcms_debugfs_def_ops = {
 	.owner = THIS_MODULE,
 	.open = brcms_debugfs_entry_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 307/437] drivers/net/wireless/ralink: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (305 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 306/437] drivers/net/wireless/broadcom: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 308/437] wifi: rtlwifi: convert debugfs helpers " Jens Axboe
                   ` (130 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../net/wireless/ralink/rt2x00/rt2x00debug.c  | 122 ++++++++----------
 1 file changed, 55 insertions(+), 67 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
index f2395309ec00..80f84dc700be 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
@@ -238,17 +238,16 @@ static int rt2x00debug_release_queue_dump(struct inode *inode, struct file *file
 	return rt2x00debug_file_release(inode, file);
 }
 
-static ssize_t rt2x00debug_read_queue_dump(struct file *file,
-					   char __user *buf,
-					   size_t length,
-					   loff_t *offset)
+static ssize_t rt2x00debug_read_queue_dump(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
+	size_t length = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t status;
 	int retval;
 
-	if (file->f_flags & O_NONBLOCK)
+	if (iocb->ki_filp->f_flags & O_NONBLOCK)
 		return -EAGAIN;
 
 	retval =
@@ -259,12 +258,12 @@ static ssize_t rt2x00debug_read_queue_dump(struct file *file,
 		return retval;
 
 	status = min_t(size_t, skb->len, length);
-	if (copy_to_user(buf, skb->data, status)) {
+	if (!copy_to_iter_full(skb->data, status, to)) {
 		status = -EFAULT;
 		goto exit;
 	}
 
-	*offset += status;
+	iocb->ki_pos += status;
 
 exit:
 	kfree_skb(skb);
@@ -287,27 +286,26 @@ static __poll_t rt2x00debug_poll_queue_dump(struct file *file,
 
 static const struct file_operations rt2x00debug_fop_queue_dump = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_queue_dump,
+	.read_iter	= rt2x00debug_read_queue_dump,
 	.poll		= rt2x00debug_poll_queue_dump,
 	.open		= rt2x00debug_open_queue_dump,
 	.release	= rt2x00debug_release_queue_dump,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_read_queue_stats(struct file *file,
-					    char __user *buf,
-					    size_t length,
-					    loff_t *offset)
+static ssize_t rt2x00debug_read_queue_stats(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
 	struct data_queue *queue;
 	unsigned long irqflags;
 	unsigned int lines = 1 + intf->rt2x00dev->data_queues;
+	size_t length = iov_iter_count(to);
 	size_t size;
 	char *data;
 	char *temp;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	data = kcalloc(lines, MAX_LINE_LENGTH, GFP_KERNEL);
@@ -333,39 +331,38 @@ static ssize_t rt2x00debug_read_queue_stats(struct file *file,
 	size = strlen(data);
 	size = min(size, length);
 
-	if (copy_to_user(buf, data, size)) {
+	if (!copy_to_iter_full(data, size, to)) {
 		kfree(data);
 		return -EFAULT;
 	}
 
 	kfree(data);
 
-	*offset += size;
+	iocb->ki_pos += size;
 	return size;
 }
 
 static const struct file_operations rt2x00debug_fop_queue_stats = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_queue_stats,
+	.read_iter	= rt2x00debug_read_queue_stats,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
 #ifdef CONFIG_RT2X00_LIB_CRYPTO
-static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
-					     char __user *buf,
-					     size_t length,
-					     loff_t *offset)
+static ssize_t rt2x00debug_read_crypto_stats(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
 	static const char * const name[] = { "WEP64", "WEP128", "TKIP", "AES" };
+	size_t length = iov_iter_count(to);
 	char *data;
 	char *temp;
 	size_t size;
 	unsigned int i;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL);
@@ -386,20 +383,20 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
 	size = strlen(data);
 	size = min(size, length);
 
-	if (copy_to_user(buf, data, size)) {
+	if (!copy_to_iter_full(data, size, to)) {
 		kfree(data);
 		return -EFAULT;
 	}
 
 	kfree(data);
 
-	*offset += size;
+	iocb->ki_pos += size;
 	return size;
 }
 
 static const struct file_operations rt2x00debug_fop_crypto_stats = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_crypto_stats,
+	.read_iter	= rt2x00debug_read_crypto_stats,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
@@ -407,19 +404,17 @@ static const struct file_operations rt2x00debug_fop_crypto_stats = {
 #endif
 
 #define RT2X00DEBUGFS_OPS_READ(__name, __format, __type)	\
-static ssize_t rt2x00debug_read_##__name(struct file *file,	\
-					 char __user *buf,	\
-					 size_t length,		\
-					 loff_t *offset)	\
+static ssize_t rt2x00debug_read_##__name(struct kiocb *iocb,	\
+					 struct iov_iter *to)	\
 {								\
-	struct rt2x00debug_intf *intf = file->private_data;	\
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;	\
 	const struct rt2x00debug *debug = intf->debug;		\
 	char line[16];						\
 	size_t size;						\
 	unsigned int index = intf->offset_##__name;		\
 	__type value;						\
 								\
-	if (*offset)						\
+	if (iocb->ki_pos)					\
 		return 0;					\
 								\
 	if (index >= debug->__name.word_count)			\
@@ -435,23 +430,22 @@ static ssize_t rt2x00debug_read_##__name(struct file *file,	\
 								\
 	size = sprintf(line, __format, value);			\
 								\
-	return simple_read_from_buffer(buf, length, offset, line, size); \
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to); \
 }
 
 #define RT2X00DEBUGFS_OPS_WRITE(__name, __type)			\
-static ssize_t rt2x00debug_write_##__name(struct file *file,	\
-					  const char __user *buf,\
-					  size_t length,	\
-					  loff_t *offset)	\
+static ssize_t rt2x00debug_write_##__name(struct kiocb *iocb,	\
+					  struct iov_iter *from)\
 {								\
-	struct rt2x00debug_intf *intf = file->private_data;	\
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;	\
 	const struct rt2x00debug *debug = intf->debug;		\
+	size_t length = iov_iter_count(from);			\
 	char line[17];						\
 	size_t size;						\
 	unsigned int index = intf->offset_##__name;		\
 	__type value;						\
 								\
-	if (*offset)						\
+	if (iocb->ki_pos)					\
 		return 0;					\
 								\
 	if (index >= debug->__name.word_count)			\
@@ -460,7 +454,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *file,	\
 	if (length > sizeof(line))				\
 		return -EINVAL;					\
 								\
-	if (copy_from_user(line, buf, length))			\
+	if (!copy_from_iter_full(line, length, from))		\
 		return -EFAULT;					\
 	line[16] = 0;						\
 						\
@@ -475,7 +469,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *file,	\
 								\
 	debug->__name.write(intf->rt2x00dev, index, value);	\
 								\
-	*offset += size;					\
+	iocb->ki_pos += size;					\
 	return size;						\
 }
 
@@ -485,8 +479,8 @@ RT2X00DEBUGFS_OPS_WRITE(__name, __type);			\
 								\
 static const struct file_operations rt2x00debug_fop_##__name = {\
 	.owner		= THIS_MODULE,				\
-	.read		= rt2x00debug_read_##__name,		\
-	.write		= rt2x00debug_write_##__name,		\
+	.read_iter	= rt2x00debug_read_##__name,		\
+	.write_iter	= rt2x00debug_write_##__name,		\
 	.open		= rt2x00debug_file_open,		\
 	.release	= rt2x00debug_file_release,		\
 	.llseek		= generic_file_llseek,			\
@@ -498,62 +492,56 @@ RT2X00DEBUGFS_OPS(bbp, "0x%.2x\n", u8);
 RT2X00DEBUGFS_OPS(rf, "0x%.8x\n", u32);
 RT2X00DEBUGFS_OPS(rfcsr, "0x%.2x\n", u8);
 
-static ssize_t rt2x00debug_read_dev_flags(struct file *file,
-					  char __user *buf,
-					  size_t length,
-					  loff_t *offset)
+static ssize_t rt2x00debug_read_dev_flags(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	char line[16];
 	size_t size;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->flags);
 
-	return simple_read_from_buffer(buf, length, offset, line, size);
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to);
 }
 
 static const struct file_operations rt2x00debug_fop_dev_flags = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_dev_flags,
+	.read_iter	= rt2x00debug_read_dev_flags,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_read_cap_flags(struct file *file,
-					  char __user *buf,
-					  size_t length,
-					  loff_t *offset)
+static ssize_t rt2x00debug_read_cap_flags(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	char line[16];
 	size_t size;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_flags);
 
-	return simple_read_from_buffer(buf, length, offset, line, size);
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to);
 }
 
 static const struct file_operations rt2x00debug_fop_cap_flags = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_cap_flags,
+	.read_iter	= rt2x00debug_read_cap_flags,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_write_restart_hw(struct file *file,
-					    const char __user *buf,
-					    size_t length,
-					    loff_t *offset)
+static ssize_t rt2x00debug_write_restart_hw(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	struct rt2x00_dev *rt2x00dev = intf->rt2x00dev;
 	static unsigned long last_reset = INITIAL_JIFFIES;
 
@@ -566,12 +554,12 @@ static ssize_t rt2x00debug_write_restart_hw(struct file *file,
 	last_reset = jiffies;
 
 	ieee80211_restart_hw(rt2x00dev->hw);
-	return length;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations rt2x00debug_restart_hw = {
 	.owner = THIS_MODULE,
-	.write = rt2x00debug_write_restart_hw,
+	.write_iter = rt2x00debug_write_restart_hw,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 308/437] wifi: rtlwifi: convert debugfs helpers to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (306 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 307/437] drivers/net/wireless/ralink: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 309/437] wifi: rtw88: " Jens Axboe
                   ` (129 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/realtek/rtlwifi/debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c b/drivers/net/wireless/realtek/rtlwifi/debug.c
index 9eb26dfe4ca9..11220484c4c6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/debug.c
+++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
@@ -66,7 +66,7 @@ static int dl_debug_open_common(struct inode *inode, struct file *file)
 
 static const struct file_operations file_ops_common = {
 	.open = dl_debug_open_common,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -411,10 +411,11 @@ static ssize_t rtl_debugfs_common_write(struct file *filp,
 
 	return debugfs_priv->cb_write(filp, buffer, count, loff);
 }
+FOPS_WRITE_ITER_HELPER(rtl_debugfs_common_write);
 
 static const struct file_operations file_ops_common_write = {
 	.owner = THIS_MODULE,
-	.write = rtl_debugfs_common_write,
+	.write_iter = rtl_debugfs_common_write_iter,
 	.open = simple_open,
 	.release = rtl_debugfs_close,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 309/437] wifi: rtw88: convert debugfs helpers to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (307 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 308/437] wifi: rtlwifi: convert debugfs helpers " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 310/437] wifi: rtw89: " Jens Axboe
                   ` (128 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/realtek/rtw88/debug.c | 163 ++++++++++-----------
 1 file changed, 79 insertions(+), 84 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c
index 5b2036798159..2a44bbc06a02 100644
--- a/drivers/net/wireless/realtek/rtw88/debug.c
+++ b/drivers/net/wireless/realtek/rtw88/debug.c
@@ -19,8 +19,7 @@
 struct rtw_debugfs_priv {
 	struct rtw_dev *rtwdev;
 	int (*cb_read)(struct seq_file *m, void *v);
-	ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
-			    size_t count, loff_t *loff);
+	ssize_t (*cb_write)(struct kiocb *, struct iov_iter *);
 	union {
 		u32 cb_data;
 		u8 *buf;
@@ -55,23 +54,21 @@ static int rtw_debugfs_single_show(struct seq_file *m, void *v)
 	return debugfs_priv->cb_read(m, v);
 }
 
-static ssize_t rtw_debugfs_common_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_common_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
-static ssize_t rtw_debugfs_single_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_single_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
 static int rtw_debugfs_single_open_rw(struct inode *inode, struct file *filp)
@@ -87,7 +84,7 @@ static int rtw_debugfs_close(struct inode *inode, struct file *filp)
 static const struct file_operations file_ops_single_r = {
 	.owner = THIS_MODULE,
 	.open = rtw_debugfs_single_open_rw,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -96,14 +93,14 @@ static const struct file_operations file_ops_single_rw = {
 	.owner = THIS_MODULE,
 	.open = rtw_debugfs_single_open_rw,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
-	.write = rtw_debugfs_single_write,
+	.write_iter = rtw_debugfs_single_write,
 };
 
 static const struct file_operations file_ops_common_write = {
 	.owner = THIS_MODULE,
-	.write = rtw_debugfs_common_write,
+	.write_iter = rtw_debugfs_common_write,
 	.open = simple_open,
 	.release = rtw_debugfs_close,
 };
@@ -171,9 +168,9 @@ static int rtw_debugfs_get_fix_rate(struct seq_file *m, void *v)
 }
 
 static int rtw_debugfs_copy_from_user(char tmp[], int size,
-				      const char __user *buffer, size_t count,
-				      int num)
+				      struct iov_iter *from, int num)
 {
+	size_t count = iov_iter_count(from);
 	int tmp_len;
 
 	memset(tmp, 0, size);
@@ -183,7 +180,7 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size,
 
 	tmp_len = (count > size - 1 ? size - 1 : count);
 
-	if (copy_from_user(tmp, buffer, tmp_len))
+	if (!copy_from_iter_full(tmp, tmp_len, from))
 		return -EFAULT;
 
 	tmp[tmp_len] = '\0';
@@ -191,19 +188,19 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size,
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_read_reg(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_read_reg(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 addr, len;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 2);
 	if (ret)
 		return ret;
 
@@ -281,19 +278,19 @@ static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rsvd_page(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 offset, page_num;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 2);
 	if (ret)
 		return ret;
 
@@ -310,16 +307,16 @@ static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_single_input(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_single_input(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
+	size_t count = iov_iter_count(from);
 	u32 input;
 	int ret;
 
-	ret = kstrtou32_from_user(buffer, count, 0, &input);
+	ret = kstrtou32_from_iter(from, count, 0, &input);
 	if (ret)
 		return ret;
 
@@ -328,18 +325,18 @@ static ssize_t rtw_debugfs_set_single_input(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_write_reg(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 addr, val, len;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -374,18 +371,17 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_h2c(struct file *filp,
-				   const char __user *buffer,
-				   size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_h2c(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u8 param[8];
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -404,18 +400,18 @@ static ssize_t rtw_debugfs_set_h2c(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rf_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 path, addr, mask, val;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 4);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 4);
 	if (ret)
 		return ret;
 
@@ -436,19 +432,18 @@ static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rf_read(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 path, addr, mask;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -466,18 +461,18 @@ static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_fix_rate(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_fix_rate(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	size_t count = iov_iter_count(from);
 	u8 fix_rate;
 	int ret;
 
-	ret = kstrtou8_from_user(buffer, count, 0, &fix_rate);
+	ret = kstrtou8_from_iter(from, count, 0, &fix_rate);
 	if (ret)
 		return ret;
 
@@ -854,18 +849,18 @@ static int rtw_debugfs_get_coex_info(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_coex_enable(struct file *filp,
-					   const char __user *buffer,
-					   size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_coex_enable(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_coex *coex = &rtwdev->coex;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int ret;
 
-	ret = kstrtobool_from_user(buffer, count, &enable);
+	ret = kstrtobool_from_iter(from, count, &enable);
 	if (ret)
 		return ret;
 
@@ -888,17 +883,17 @@ static int rtw_debugfs_get_coex_enable(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_edcca_enable(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_edcca_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int err;
 
-	err = kstrtobool_from_user(buffer, count, &input);
+	err = kstrtobool_from_iter(from, count, &input);
 	if (err)
 		return err;
 
@@ -920,17 +915,17 @@ static int rtw_debugfs_get_edcca_enable(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_fw_crash(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_fw_crash(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int ret;
 
-	ret = kstrtobool_from_user(buffer, count, &input);
+	ret = kstrtobool_from_iter(from, count, &input);
 	if (ret)
 		return ret;
 
@@ -960,17 +955,17 @@ static int rtw_debugfs_get_fw_crash(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_force_lowest_basic_rate(struct file *filp,
-						       const char __user *buffer,
-						       size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_force_lowest_basic_rate(struct kiocb *iocb,
+						       struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int err;
 
-	err = kstrtobool_from_user(buffer, count, &input);
+	err = kstrtobool_from_iter(from, count, &input);
 	if (err)
 		return err;
 
@@ -993,18 +988,18 @@ static int rtw_debugfs_get_force_lowest_basic_rate(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_dm_cap(struct file *filp,
-				      const char __user *buffer,
-				      size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_dm_cap(struct kiocb *iocb,
+				      struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	size_t count = iov_iter_count(from);
 	int ret, bit;
 	bool en;
 
-	ret = kstrtoint_from_user(buffer, count, 10, &bit);
+	ret = kstrtoint_from_iter(from, count, 10, &bit);
 	if (ret)
 		return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 310/437] wifi: rtw89: convert debugfs helpers to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (308 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 309/437] wifi: rtw88: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 311/437] wifi: rsi: rsi_91x_debugfs: convert " Jens Axboe
                   ` (127 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/realtek/rtw89/debug.c | 155 ++++++++++-----------
 1 file changed, 74 insertions(+), 81 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/debug.c b/drivers/net/wireless/realtek/rtw89/debug.c
index affffc4092ba..20d8774f151a 100644
--- a/drivers/net/wireless/realtek/rtw89/debug.c
+++ b/drivers/net/wireless/realtek/rtw89/debug.c
@@ -24,8 +24,7 @@ MODULE_PARM_DESC(debug_mask, "Debugging mask");
 struct rtw89_debugfs_priv {
 	struct rtw89_dev *rtwdev;
 	int (*cb_read)(struct seq_file *m, void *v);
-	ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
-			    size_t count, loff_t *loff);
+	ssize_t (*cb_write)(struct kiocb *, struct iov_iter *);
 	union {
 		u32 cb_data;
 		struct {
@@ -75,23 +74,21 @@ static int rtw89_debugfs_single_show(struct seq_file *m, void *v)
 	return debugfs_priv->cb_read(m, v);
 }
 
-static ssize_t rtw89_debugfs_single_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *loff)
+static ssize_t rtw89_debugfs_single_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
-static ssize_t rtw89_debugfs_seq_file_write(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw89_debugfs_seq_file_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = seqpriv->private;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
 static int rtw89_debugfs_single_open(struct inode *inode, struct file *filp)
@@ -107,7 +104,7 @@ static int rtw89_debugfs_close(struct inode *inode, struct file *filp)
 static const struct file_operations file_ops_single_r = {
 	.owner = THIS_MODULE,
 	.open = rtw89_debugfs_single_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -116,33 +113,32 @@ static const struct file_operations file_ops_common_rw = {
 	.owner = THIS_MODULE,
 	.open = rtw89_debugfs_single_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
-	.write = rtw89_debugfs_seq_file_write,
+	.write_iter = rtw89_debugfs_seq_file_write,
 };
 
 static const struct file_operations file_ops_single_w = {
 	.owner = THIS_MODULE,
-	.write = rtw89_debugfs_single_write,
+	.write_iter = rtw89_debugfs_single_write,
 	.open = simple_open,
 	.release = rtw89_debugfs_close,
 };
 
 static ssize_t
-rtw89_debug_priv_read_reg_select(struct file *filp,
-				 const char __user *user_buf,
-				 size_t count, loff_t *loff)
+rtw89_debug_priv_read_reg_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -207,19 +203,19 @@ static int rtw89_debug_priv_read_reg_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_write_reg_set(struct file *filp,
-					      const char __user *user_buf,
-					      size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_write_reg_set(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, val, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -251,13 +247,12 @@ static ssize_t rtw89_debug_priv_write_reg_set(struct file *filp,
 }
 
 static ssize_t
-rtw89_debug_priv_read_rf_select(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *loff)
+rtw89_debug_priv_read_rf_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, mask;
@@ -265,7 +260,7 @@ rtw89_debug_priv_read_rf_select(struct file *filp,
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -306,12 +301,12 @@ static int rtw89_debug_priv_read_rf_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_write_rf_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_write_rf_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, val, mask;
@@ -319,7 +314,7 @@ static ssize_t rtw89_debug_priv_write_rf_set(struct file *filp,
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -867,21 +862,20 @@ static int rtw89_debug_priv_txpwr_table_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_reg_dump_select(struct file *filp,
-				     const char __user *user_buf,
-				     size_t count, loff_t *loff)
+rtw89_debug_priv_mac_reg_dump_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	const struct rtw89_chip_info *chip = rtwdev->chip;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	int sel;
 	int ret;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -984,20 +978,19 @@ static int rtw89_debug_priv_mac_reg_dump_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_mem_dump_select(struct file *filp,
-				     const char __user *user_buf,
-				     size_t count, loff_t *loff)
+rtw89_debug_priv_mac_mem_dump_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 sel, start_addr, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1094,13 +1087,13 @@ rtw89_debug_priv_mac_mem_dump_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_dbg_port_dump_select(struct file *filp,
-					  const char __user *user_buf,
-					  size_t count, loff_t *loff)
+rtw89_debug_priv_mac_dbg_port_dump_select(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	int sel, set;
@@ -1108,7 +1101,7 @@ rtw89_debug_priv_mac_dbg_port_dump_select(struct file *filp,
 	bool enable;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -3222,15 +3215,15 @@ rtw89_debug_priv_mac_dbg_port_dump_get(struct seq_file *m, void *v)
 	return 0;
 };
 
-static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev,
-			      const char __user *user_buf, size_t count)
+static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char *buf;
 	u8 *bin;
 	int num;
 	int err = 0;
 
-	buf = memdup_user(user_buf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return buf;
 
@@ -3253,17 +3246,17 @@ static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev,
 	return err ? ERR_PTR(err) : bin;
 }
 
-static ssize_t rtw89_debug_priv_send_h2c_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_send_h2c_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	u8 *h2c;
 	int ret;
 	u16 h2c_len = count / 2;
 
-	h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
+	h2c = rtw89_hex2bin_user(rtwdev, from);
 	if (IS_ERR(h2c))
 		return -EFAULT;
 
@@ -3291,17 +3284,17 @@ rtw89_debug_priv_early_h2c_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_early_h2c_set(struct file *filp, const char __user *user_buf,
-			       size_t count, loff_t *loff)
+rtw89_debug_priv_early_h2c_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	struct rtw89_early_h2c *early_h2c;
 	u8 *h2c;
 	u16 h2c_len = count / 2;
 
-	h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
+	h2c = rtw89_hex2bin_user(rtwdev, from);
 	if (IS_ERR(h2c))
 		return -EFAULT;
 
@@ -3372,17 +3365,17 @@ enum rtw89_dbg_crash_simulation_type {
 };
 
 static ssize_t
-rtw89_debug_priv_fw_crash_set(struct file *filp, const char __user *user_buf,
-			      size_t count, loff_t *loff)
+rtw89_debug_priv_fw_crash_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	int (*sim)(struct rtw89_dev *rtwdev);
+	size_t count = iov_iter_count(from);
 	u8 crash_type;
 	int ret;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &crash_type);
+	ret = kstrtou8_from_iter(from, count, 0, &crash_type);
 	if (ret)
 		return -EINVAL;
 
@@ -3420,17 +3413,17 @@ static int rtw89_debug_priv_btc_info_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
-					       const char __user *user_buf,
-					       size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_btc_manual_set(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_btc *btc = &rtwdev->btc;
 	const struct rtw89_btc_ver *ver = btc->ver;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	ret = kstrtobool_from_user(user_buf, count, &btc->manual_ctrl);
+	ret = kstrtobool_from_iter(from, count, &btc->manual_ctrl);
 	if (ret)
 		return ret;
 
@@ -3442,16 +3435,16 @@ static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw89_debug_fw_log_manual_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_fw_log_manual_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_fw_log *log = &rtwdev->fw.log;
+	size_t count = iov_iter_count(from);
 	bool fw_log_manual;
 
-	if (kstrtobool_from_user(user_buf, count, &fw_log_manual))
+	if (kstrtobool_from_iter(from, count, &fw_log_manual))
 		goto out;
 
 	mutex_lock(&rtwdev->mutex);
@@ -3807,17 +3800,17 @@ rtw89_debug_priv_disable_dm_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_disable_dm_set(struct file *filp, const char __user *user_buf,
-				size_t count, loff_t *loff)
+rtw89_debug_priv_disable_dm_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_hal *hal = &rtwdev->hal;
+	size_t count = iov_iter_count(from);
 	u32 conf;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &conf);
+	ret = kstrtou32_from_iter(from, count, 0, &conf);
 	if (ret)
 		return -EINVAL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 311/437] wifi: rsi: rsi_91x_debugfs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (309 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 310/437] wifi: rtw89: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 312/437] drivers/net/wireless/silabs: " Jens Axboe
                   ` (126 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
index c528e6ca2c8d..4a8e71ff7ba6 100644
--- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c
+++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c
@@ -222,25 +222,21 @@ static int rsi_debug_read(struct inode *inode,
 /**
  * rsi_debug_zone_write() - This function writes into hal queues as per user
  *			    requirement.
- * @filp: Pointer to the file structure.
- * @buff: Pointer to the character buffer.
- * @len: Length of the data to be written into buffer.
- * @data: Pointer to the data.
+ * @iocb: Metadata for IO.
+ * @from: iov_iter to copy data from.
  *
  * Return: len: Number of bytes read.
  */
-static ssize_t rsi_debug_zone_write(struct file *filp,
-				    const char __user *buff,
-				    size_t len,
-				    loff_t *data)
+static ssize_t rsi_debug_zone_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	unsigned long dbg_zone;
 	int ret;
 
 	if (!len)
 		return 0;
 
-	ret = kstrtoul_from_user(buff, len, 16, &dbg_zone);
+	ret = kstrtoul_from_iter(from, len, 16, &dbg_zone);
 
 	if (ret)
 		return ret;
@@ -252,16 +248,16 @@ static ssize_t rsi_debug_zone_write(struct file *filp,
 #define FOPS(fopen) { \
 	.owner = THIS_MODULE, \
 	.open = (fopen), \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 }
 
 #define FOPS_RW(fopen, fwrite) { \
 	.owner = THIS_MODULE, \
 	.open = (fopen), \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
-	.write = (fwrite), \
+	.write_iter = (fwrite), \
 }
 
 static const struct rsi_dbg_files dev_debugfs_files[] = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 312/437] drivers/net/wireless/silabs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (310 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 311/437] wifi: rsi: rsi_91x_debugfs: convert " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 313/437] drivers/net/wireless/st: " Jens Axboe
                   ` (125 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/silabs/wfx/debug.c | 34 ++++++++++++-------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/silabs/wfx/debug.c b/drivers/net/wireless/silabs/wfx/debug.c
index e8265208f9a5..bd39be6a7f58 100644
--- a/drivers/net/wireless/silabs/wfx/debug.c
+++ b/drivers/net/wireless/silabs/wfx/debug.c
@@ -202,21 +202,21 @@ static int wfx_tx_power_loop_show(struct seq_file *seq, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(wfx_tx_power_loop);
 
-static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t wfx_send_pds_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wfx_dev *wdev = file->private_data;
+	struct wfx_dev *wdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int ret;
 
-	if (*ppos != 0) {
+	if (iocb->ki_pos != 0) {
 		dev_dbg(wdev->dev, "PDS data must be written in one transaction");
 		return -EBUSY;
 	}
-	buf = memdup_user(user_buf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
-	*ppos = *ppos + count;
+	iocb->ki_pos += count;
 	ret = wfx_send_pds(wdev, buf, count);
 	kfree(buf);
 	if (ret < 0)
@@ -226,7 +226,7 @@ static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf
 
 static const struct file_operations wfx_send_pds_fops = {
 	.open = simple_open,
-	.write = wfx_send_pds_write,
+	.write_iter = wfx_send_pds_write,
 };
 
 struct dbgfs_hif_msg {
@@ -236,10 +236,10 @@ struct dbgfs_hif_msg {
 	int ret;
 };
 
-static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wfx_send_hif_msg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dbgfs_hif_msg *context = file->private_data;
+	struct dbgfs_hif_msg *context = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wfx_dev *wdev = context->wdev;
 	struct wfx_hif_msg *request;
 
@@ -255,7 +255,7 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user
 	 * memory pattern may help user.
 	 */
 	memset(context->reply, 0xFF, sizeof(context->reply));
-	request = memdup_user(user_buf, count);
+	request = iterdup(from, count);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
 	if (le16_to_cpu(request->len) != count) {
@@ -269,10 +269,10 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user
 	return count;
 }
 
-static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t wfx_send_hif_msg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dbgfs_hif_msg *context = file->private_data;
+	struct dbgfs_hif_msg *context = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int ret;
 
 	if (count > sizeof(context->reply))
@@ -283,7 +283,7 @@ static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
 	if (context->ret < 0)
 		return context->ret;
 	/* Be careful, write() is waiting for a full message while read() only returns a payload */
-	if (copy_to_user(user_buf, context->reply, count))
+	if (!copy_to_iter_full(context->reply, count, to))
 		return -EFAULT;
 
 	return count;
@@ -312,8 +312,8 @@ static int wfx_send_hif_msg_release(struct inode *inode, struct file *file)
 static const struct file_operations wfx_send_hif_msg_fops = {
 	.open = wfx_send_hif_msg_open,
 	.release = wfx_send_hif_msg_release,
-	.write = wfx_send_hif_msg_write,
-	.read = wfx_send_hif_msg_read,
+	.write_iter = wfx_send_hif_msg_write,
+	.read_iter = wfx_send_hif_msg_read,
 };
 
 int wfx_debug_init(struct wfx_dev *wdev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 313/437] drivers/net/wireless/st: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (311 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 312/437] drivers/net/wireless/silabs: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 314/437] drivers/net/ieee802154: " Jens Axboe
                   ` (124 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wireless/st/cw1200/debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/debug.c b/drivers/net/wireless/st/cw1200/debug.c
index 8686929c70df..425fc06a9d38 100644
--- a/drivers/net/wireless/st/cw1200/debug.c
+++ b/drivers/net/wireless/st/cw1200/debug.c
@@ -332,15 +332,15 @@ static int cw1200_counters_show(struct seq_file *seq, void *v)
 
 DEFINE_SHOW_ATTRIBUTE(cw1200_counters);
 
-static ssize_t cw1200_wsm_dumps(struct file *file,
-	const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t cw1200_wsm_dumps(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct cw1200_common *priv = file->private_data;
+	struct cw1200_common *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[1];
 
 	if (!count)
 		return -EINVAL;
-	if (copy_from_user(buf, user_buf, 1))
+	if (!copy_from_iter_full(buf, 1, from))
 		return -EFAULT;
 
 	if (buf[0] == '1')
@@ -353,7 +353,7 @@ static ssize_t cw1200_wsm_dumps(struct file *file,
 
 static const struct file_operations fops_wsm_dumps = {
 	.open = simple_open,
-	.write = cw1200_wsm_dumps,
+	.write_iter = cw1200_wsm_dumps,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 314/437] drivers/net/ieee802154: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (312 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 313/437] drivers/net/wireless/st: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 315/437] drivers/net/netdevsim: " Jens Axboe
                   ` (123 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ieee802154/ca8210.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index e685a7f946f0..af2bf8c24572 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -2443,14 +2443,12 @@ static int ca8210_test_check_upstream(u8 *buf, void *device_ref)
  * Return: 0 or linux error code
  */
 static ssize_t ca8210_test_int_user_write(
-	struct file        *filp,
-	const char __user  *in_buf,
-	size_t              len,
-	loff_t             *off
-)
+	struct kiocb *iocb,
+	struct iov_iter *from)
 {
 	int ret;
-	struct ca8210_priv *priv = filp->private_data;
+	struct ca8210_priv *priv = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	u8 command[CA8210_SPI_BUF_SIZE];
 
 	memset(command, SPI_IDLE, 6);
@@ -2463,7 +2461,7 @@ static ssize_t ca8210_test_int_user_write(
 		return -EBADE;
 	}
 
-	ret = copy_from_user(command, in_buf, len);
+	ret = !copy_from_iter_full(command, len, from);
 	if (ret) {
 		dev_err(
 			&priv->spi->dev,
@@ -2518,18 +2516,15 @@ static ssize_t ca8210_test_int_user_write(
  * Return: number of bytes read
  */
 static ssize_t ca8210_test_int_user_read(
-	struct file  *filp,
-	char __user  *buf,
-	size_t        len,
-	loff_t       *offp
-)
+	struct kiocb *iocb,
+	struct iov_iter *to)
 {
 	int i, cmdlen;
-	struct ca8210_priv *priv = filp->private_data;
+	struct ca8210_priv *priv = iocb->ki_filp->private_data;
 	unsigned char *fifo_buffer;
 	unsigned long bytes_not_copied;
 
-	if (filp->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		/* Non-blocking mode */
 		if (kfifo_is_empty(&priv->test.up_fifo))
 			return 0;
@@ -2551,7 +2546,7 @@ static ssize_t ca8210_test_int_user_read(
 	cmdlen = fifo_buffer[1];
 	bytes_not_copied = cmdlen + 2;
 
-	bytes_not_copied = copy_to_user(buf, fifo_buffer, bytes_not_copied);
+	bytes_not_copied = !copy_to_iter_full(fifo_buffer, bytes_not_copied, to);
 	if (bytes_not_copied > 0) {
 		dev_err(
 			&priv->spi->dev,
@@ -2626,8 +2621,8 @@ static __poll_t ca8210_test_int_poll(
 }
 
 static const struct file_operations test_int_fops = {
-	.read =           ca8210_test_int_user_read,
-	.write =          ca8210_test_int_user_write,
+	.read_iter =      ca8210_test_int_user_read,
+	.write_iter =     ca8210_test_int_user_write,
 	.open =           ca8210_test_int_open,
 	.release =        NULL,
 	.unlocked_ioctl = ca8210_test_int_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 315/437] drivers/net/netdevsim: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (313 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 314/437] drivers/net/ieee802154: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 316/437] drivers/net/ppp: " Jens Axboe
                   ` (122 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/netdevsim/dev.c         | 73 ++++++++++++++---------------
 drivers/net/netdevsim/fib.c         | 16 +++----
 drivers/net/netdevsim/health.c      | 12 ++---
 drivers/net/netdevsim/hwstats.c     | 13 +++--
 drivers/net/netdevsim/ipsec.c       | 10 ++--
 drivers/net/netdevsim/psample.c     | 12 ++---
 drivers/net/netdevsim/udp_tunnels.c |  9 ++--
 7 files changed, 69 insertions(+), 76 deletions(-)

diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 92a7a36b93ac..41d49c53da39 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -93,11 +93,10 @@ nsim_dev_take_snapshot(struct devlink *devlink,
 	return 0;
 }
 
-static ssize_t nsim_dev_take_snapshot_write(struct file *file,
-					    const char __user *data,
-					    size_t count, loff_t *ppos)
+static ssize_t nsim_dev_take_snapshot_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct devlink *devlink;
 	u8 *dummy_data;
 	int err;
@@ -124,21 +123,20 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
 		return err;
 	}
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations nsim_dev_take_snapshot_fops = {
 	.open = simple_open,
-	.write = nsim_dev_take_snapshot_write,
+	.write_iter = nsim_dev_take_snapshot_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
-					    char __user *data,
-					    size_t count, loff_t *ppos)
+static ssize_t nsim_dev_trap_fa_cookie_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct flow_action_cookie *fa_cookie;
 	unsigned int buf_len;
 	ssize_t ret;
@@ -159,7 +157,7 @@ static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
 	bin2hex(buf, fa_cookie->cookie, fa_cookie->cookie_len);
 	spin_unlock(&nsim_dev->fa_cookie_lock);
 
-	ret = simple_read_from_buffer(data, count, ppos, buf, buf_len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, buf_len, to);
 
 	kfree(buf);
 	return ret;
@@ -169,23 +167,23 @@ static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
 	return ret;
 }
 
-static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t nsim_dev_trap_fa_cookie_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct flow_action_cookie *fa_cookie;
+	size_t count = iov_iter_count(from);
 	size_t cookie_len;
 	ssize_t ret;
 	char *buf;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 	cookie_len = (count - 1) / 2;
 	if ((count - 1) % 2)
 		return -EINVAL;
 
-	buf = memdup_user(data, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -218,42 +216,42 @@ static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
 
 static const struct file_operations nsim_dev_trap_fa_cookie_fops = {
 	.open = simple_open,
-	.read = nsim_dev_trap_fa_cookie_read,
-	.write = nsim_dev_trap_fa_cookie_write,
+	.read_iter = nsim_dev_trap_fa_cookie_read,
+	.write_iter = nsim_dev_trap_fa_cookie_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t nsim_bus_dev_max_vfs_read(struct file *file, char __user *data,
-					 size_t count, loff_t *ppos)
+static ssize_t nsim_bus_dev_max_vfs_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	char buf[11];
 	ssize_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%u\n",
 			READ_ONCE(nsim_dev->nsim_bus_dev->max_vfs));
 
-	return simple_read_from_buffer(data, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
-					  const char __user *data,
-					  size_t count, loff_t *ppos)
+static ssize_t nsim_bus_dev_max_vfs_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
 	struct nsim_vf_config *vfconfigs;
+	size_t count = iov_iter_count(from);
 	struct nsim_dev *nsim_dev;
 	char buf[10];
 	ssize_t ret;
 	u32 val;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= sizeof(buf))
 		return -ENOSPC;
 
-	ret = copy_from_user(buf, data, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret)
 		return -EFAULT;
 	buf[count] = '\0';
@@ -271,7 +269,7 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 	if (!vfconfigs)
 		return -ENOMEM;
 
-	nsim_dev = file->private_data;
+	nsim_dev = iocb->ki_filp->private_data;
 	devl_lock(priv_to_devlink(nsim_dev));
 	/* Reject if VFs are configured */
 	if (nsim_dev_get_vfs(nsim_dev)) {
@@ -279,7 +277,7 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 	} else {
 		swap(nsim_dev->vfconfigs, vfconfigs);
 		WRITE_ONCE(nsim_dev->nsim_bus_dev->max_vfs, val);
-		*ppos += count;
+		iocb->ki_pos += count;
 		ret = count;
 	}
 	devl_unlock(priv_to_devlink(nsim_dev));
@@ -290,8 +288,8 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 
 static const struct file_operations nsim_dev_max_vfs_fops = {
 	.open = simple_open,
-	.read = nsim_bus_dev_max_vfs_read,
-	.write = nsim_bus_dev_max_vfs_write,
+	.read_iter = nsim_bus_dev_max_vfs_read,
+	.write_iter = nsim_bus_dev_max_vfs_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
@@ -367,23 +365,22 @@ static void nsim_dev_debugfs_exit(struct nsim_dev *nsim_dev)
 	debugfs_remove_recursive(nsim_dev->ddir);
 }
 
-static ssize_t nsim_dev_rate_parent_read(struct file *file,
-					 char __user *data,
-					 size_t count, loff_t *ppos)
+static ssize_t nsim_dev_rate_parent_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	char **name_ptr = file->private_data;
+	char **name_ptr = iocb->ki_filp->private_data;
 	size_t len;
 
 	if (!*name_ptr)
 		return 0;
 
 	len = strlen(*name_ptr);
-	return simple_read_from_buffer(data, count, ppos, *name_ptr, len);
+	return simple_copy_to_iter(*name_ptr, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations nsim_dev_rate_parent_fops = {
 	.open = simple_open,
-	.read = nsim_dev_rate_parent_read,
+	.read_iter = nsim_dev_rate_parent_read,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c
index a1f91ff8ec56..4ab1b7944f3e 100644
--- a/drivers/net/netdevsim/fib.c
+++ b/drivers/net/netdevsim/fib.c
@@ -1361,15 +1361,15 @@ static void nsim_nexthop_free(void *ptr, void *arg)
 	nsim_nexthop_destroy(nexthop);
 }
 
-static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
-						  const char __user *user_buf,
-						  size_t size, loff_t *ppos)
+static ssize_t nsim_nexthop_bucket_activity_write(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
-	struct nsim_fib_data *data = file->private_data;
+	struct nsim_fib_data *data = iocb->ki_filp->private_data;
 	struct net *net = devlink_net(data->devlink);
+	size_t size = iov_iter_count(from);
 	struct nsim_nexthop *nexthop;
 	unsigned long *activity;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 	u16 bucket_index;
 	char buf[128];
 	int err = 0;
@@ -1379,7 +1379,7 @@ static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
 		return -EINVAL;
 	if (size > sizeof(buf))
 		return -EINVAL;
-	if (copy_from_user(buf, user_buf, size))
+	if (!copy_from_iter_full(buf, size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%u %hu", &nhid, &bucket_index) != 2)
 		return -EINVAL;
@@ -1407,13 +1407,13 @@ static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
 out:
 	rtnl_unlock();
 
-	*ppos = size;
+	iocb->ki_pos = size;
 	return err ?: size;
 }
 
 static const struct file_operations nsim_nexthop_bucket_activity_fops = {
 	.open = simple_open,
-	.write = nsim_nexthop_bucket_activity_write,
+	.write_iter = nsim_nexthop_bucket_activity_write,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
 };
diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 70e8bdf34be9..b1c23d23bee2 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -140,16 +140,16 @@ struct devlink_health_reporter_ops nsim_dev_dummy_reporter_ops = {
 	.diagnose = nsim_dev_dummy_reporter_diagnose,
 };
 
-static ssize_t nsim_dev_health_break_write(struct file *file,
-					   const char __user *data,
-					   size_t count, loff_t *ppos)
+static ssize_t nsim_dev_health_break_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct nsim_dev_health *health = file->private_data;
+	struct nsim_dev_health *health = iocb->ki_filp->private_data;
 	struct nsim_dev_dummy_reporter_ctx ctx;
+	size_t count = iov_iter_count(from);
 	char *break_msg;
 	int err;
 
-	break_msg = memdup_user_nul(data, count);
+	break_msg = iterdup_nul(from, count);
 	if (IS_ERR(break_msg))
 		return PTR_ERR(break_msg);
 
@@ -168,7 +168,7 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
 
 static const struct file_operations nsim_dev_health_break_fops = {
 	.open = simple_open,
-	.write = nsim_dev_health_break_write,
+	.write_iter = nsim_dev_health_break_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
diff --git a/drivers/net/netdevsim/hwstats.c b/drivers/net/netdevsim/hwstats.c
index 0e58aa7f0374..8e9b13c464a8 100644
--- a/drivers/net/netdevsim/hwstats.c
+++ b/drivers/net/netdevsim/hwstats.c
@@ -337,20 +337,19 @@ struct nsim_dev_hwstats_fops {
 };
 
 static ssize_t
-nsim_dev_hwstats_do_write(struct file *file,
-			  const char __user *data,
-			  size_t count, loff_t *ppos)
+nsim_dev_hwstats_do_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct nsim_dev_hwstats *hwstats = file->private_data;
+	struct nsim_dev_hwstats *hwstats = iocb->ki_filp->private_data;
 	struct nsim_dev_hwstats_fops *hwsfops;
+	size_t count = iov_iter_count(from);
 	struct list_head *hwsdev_list;
 	int ifindex;
 	int err;
 
-	hwsfops = container_of(debugfs_real_fops(file),
+	hwsfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			       struct nsim_dev_hwstats_fops, fops);
 
-	err = kstrtoint_from_user(data, count, 0, &ifindex);
+	err = kstrtoint_from_iter(from, count, 0, &ifindex);
 	if (err)
 		return err;
 
@@ -385,7 +384,7 @@ nsim_dev_hwstats_do_write(struct file *file,
 	{							\
 		.fops = {					\
 			.open = simple_open,			\
-			.write = nsim_dev_hwstats_do_write,	\
+			.write_iter = nsim_dev_hwstats_do_write,	\
 			.llseek = generic_file_llseek,		\
 			.owner = THIS_MODULE,			\
 		},						\
diff --git a/drivers/net/netdevsim/ipsec.c b/drivers/net/netdevsim/ipsec.c
index f0d58092e7e9..16535c552d12 100644
--- a/drivers/net/netdevsim/ipsec.c
+++ b/drivers/net/netdevsim/ipsec.c
@@ -9,11 +9,9 @@
 
 #define NSIM_IPSEC_AUTH_BITS	128
 
-static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
-					char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t nsim_dbg_netdev_ops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct netdevsim *ns = filp->private_data;
+	struct netdevsim *ns = iocb->ki_filp->private_data;
 	struct nsim_ipsec *ipsec = &ns->ipsec;
 	size_t bufsize;
 	char *buf, *p;
@@ -53,7 +51,7 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
 			       sap->key[2], sap->key[3]);
 	}
 
-	len = simple_read_from_buffer(buffer, count, ppos, buf, p - buf);
+	len = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 
 	kfree(buf);
 	return len;
@@ -62,7 +60,7 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
 static const struct file_operations ipsec_dbg_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = nsim_dbg_netdev_ops_read,
+	.read_iter = nsim_dbg_netdev_ops_read,
 };
 
 static int nsim_ipsec_find_empty_idx(struct nsim_ipsec *ipsec)
diff --git a/drivers/net/netdevsim/psample.c b/drivers/net/netdevsim/psample.c
index f0c6477dd0ae..21353aea4f4a 100644
--- a/drivers/net/netdevsim/psample.c
+++ b/drivers/net/netdevsim/psample.c
@@ -168,15 +168,15 @@ static int nsim_dev_psample_disable(struct nsim_dev *nsim_dev)
 	return 0;
 }
 
-static ssize_t nsim_dev_psample_enable_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t nsim_dev_psample_enable_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(data, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -190,7 +190,7 @@ static ssize_t nsim_dev_psample_enable_write(struct file *file,
 
 static const struct file_operations nsim_psample_enable_fops = {
 	.open = simple_open,
-	.write = nsim_dev_psample_enable_write,
+	.write_iter = nsim_dev_psample_enable_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c
index 02dc3123eb6c..efbd5af4562c 100644
--- a/drivers/net/netdevsim/udp_tunnels.c
+++ b/drivers/net/netdevsim/udp_tunnels.c
@@ -106,10 +106,9 @@ static const struct udp_tunnel_nic_info nsim_udp_tunnel_info = {
 };
 
 static ssize_t
-nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,
-				  size_t count, loff_t *ppos)
+nsim_udp_tunnels_info_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct net_device *dev = file->private_data;
+	struct net_device *dev = iocb->ki_filp->private_data;
 	struct netdevsim *ns = netdev_priv(dev);
 
 	memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports));
@@ -117,12 +116,12 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,
 	udp_tunnel_nic_reset_ntf(dev);
 	rtnl_unlock();
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations nsim_udp_tunnels_info_reset_fops = {
 	.open = simple_open,
-	.write = nsim_udp_tunnels_info_reset_write,
+	.write_iter = nsim_udp_tunnels_info_reset_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 316/437] drivers/net/ppp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (314 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 315/437] drivers/net/netdevsim: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 317/437] drivers/net/wwan: " Jens Axboe
                   ` (121 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ppp/ppp_generic.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index fe380fe196e7..6601b6c3e2b2 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -492,11 +492,12 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
  out:
 	return ret;
 }
+FOPS_READ_ITER_HELPER(ppp_read);
 
-static ssize_t ppp_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t ppp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ppp_file *pf = file->private_data;
+	struct ppp_file *pf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 	ssize_t ret;
 
@@ -511,7 +512,7 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,
 		goto out;
 	skb_reserve(skb, pf->hdrlen);
 	ret = -EFAULT;
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		goto out;
 	}
@@ -1092,8 +1093,8 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
 
 static const struct file_operations ppp_device_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ppp_read,
-	.write		= ppp_write,
+	.read_iter	= ppp_read_iter,
+	.write_iter	= ppp_write,
 	.poll		= ppp_poll,
 	.unlocked_ioctl	= ppp_ioctl,
 #ifdef CONFIG_COMPAT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 317/437] drivers/net/wwan: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (315 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 316/437] drivers/net/ppp: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 318/437] drivers/net/xen-netback: " Jens Axboe
                   ` (120 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/wwan/iosm/iosm_ipc_trace.c | 21 ++++++-------
 drivers/net/wwan/wwan_core.c           | 26 ++++++++--------
 drivers/net/wwan/wwan_hwsim.c          | 42 ++++++++++++--------------
 3 files changed, 42 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c
index eeecfa3d10c5..8374bd4826bc 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_trace.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c
@@ -70,10 +70,9 @@ static struct rchan_callbacks relay_callbacks = {
 };
 
 /* Copy the trace control mode to user buffer */
-static ssize_t ipc_trace_ctrl_file_read(struct file *filp, char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t ipc_trace_ctrl_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iosm_trace *ipc_trace = filp->private_data;
+	struct iosm_trace *ipc_trace = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
@@ -81,19 +80,19 @@ static ssize_t ipc_trace_ctrl_file_read(struct file *filp, char __user *buffer,
 	len = snprintf(buf, sizeof(buf), "%d\n", ipc_trace->mode);
 	mutex_unlock(&ipc_trace->trc_mutex);
 
-	return simple_read_from_buffer(buffer, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /* Open and close the trace channel depending on user input */
-static ssize_t ipc_trace_ctrl_file_write(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *ppos)
+static ssize_t ipc_trace_ctrl_file_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct iosm_trace *ipc_trace = filp->private_data;
+	struct iosm_trace *ipc_trace = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(buffer, count, 10, &val);
+	ret = kstrtoul_from_iter(from, count, 10, &val);
 	if (ret)
 		return ret;
 
@@ -122,8 +121,8 @@ static ssize_t ipc_trace_ctrl_file_write(struct file *filp,
 
 static const struct file_operations ipc_trace_fops = {
 	.open = simple_open,
-	.write = ipc_trace_ctrl_file_write,
-	.read  = ipc_trace_ctrl_file_read,
+	.write_iter = ipc_trace_ctrl_file_write,
+	.read_iter  = ipc_trace_ctrl_file_read,
 };
 
 /**
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index 17431f1b1a0c..1007d0255427 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -684,15 +684,15 @@ static int wwan_port_fops_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t wwan_port_fops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wwan_port *port = filp->private_data;
+	struct wwan_port *port = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t copied;
 	int ret;
 
-	ret = wwan_wait_rx(port, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_wait_rx(port, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (ret)
 		return ret;
 
@@ -701,7 +701,7 @@ static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
 		return -EIO;
 
 	copied = min_t(size_t, count, skb->len);
-	if (copy_to_user(buf, skb->data, copied)) {
+	if (!copy_to_iter_full(skb->data, copied, to)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -716,15 +716,15 @@ static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
 	return copied;
 }
 
-static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
-				    size_t count, loff_t *offp)
+static ssize_t wwan_port_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct sk_buff *skb, *head = NULL, *tail = NULL;
-	struct wwan_port *port = filp->private_data;
+	struct wwan_port *port = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t frag_len, remain = count;
 	int ret;
 
-	ret = wwan_wait_tx(port, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_wait_tx(port, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (ret)
 		return ret;
 
@@ -747,7 +747,7 @@ static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
 			tail = skb;
 		}
 
-		if (copy_from_user(skb_put(skb, frag_len), buf + count - remain, frag_len)) {
+		if (!copy_from_iter_full(skb_put(skb, frag_len), frag_len, from)) {
 			ret = -EFAULT;
 			goto freeskb;
 		}
@@ -759,7 +759,7 @@ static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
 		}
 	} while (remain -= frag_len);
 
-	ret = wwan_port_op_tx(port, head, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_port_op_tx(port, head, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (!ret)
 		return count;
 
@@ -897,8 +897,8 @@ static const struct file_operations wwan_port_fops = {
 	.owner = THIS_MODULE,
 	.open = wwan_port_fops_open,
 	.release = wwan_port_fops_release,
-	.read = wwan_port_fops_read,
-	.write = wwan_port_fops_write,
+	.read_iter = wwan_port_fops_read,
+	.write_iter = wwan_port_fops_write,
 	.poll = wwan_port_fops_poll,
 	.unlocked_ioctl = wwan_port_fops_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/net/wwan/wwan_hwsim.c b/drivers/net/wwan/wwan_hwsim.c
index b02befd1b6fb..7bf9a275b3c0 100644
--- a/drivers/net/wwan/wwan_hwsim.c
+++ b/drivers/net/wwan/wwan_hwsim.c
@@ -364,11 +364,10 @@ static void wwan_hwsim_dev_del_work(struct work_struct *work)
 	wwan_hwsim_dev_del(dev);
 }
 
-static ssize_t wwan_hwsim_debugfs_portdestroy_write(struct file *file,
-						    const char __user *usrbuf,
-						    size_t count, loff_t *ppos)
+static ssize_t wwan_hwsim_debugfs_portdestroy_write(struct kiocb *iocb,
+						    struct iov_iter *from)
 {
-	struct wwan_hwsim_port *port = file->private_data;
+	struct wwan_hwsim_port *port = iocb->ki_filp->private_data;
 
 	/* We can not delete port here since it will cause a deadlock due to
 	 * waiting this callback to finish in the debugfs_remove() call. So,
@@ -376,20 +375,19 @@ static ssize_t wwan_hwsim_debugfs_portdestroy_write(struct file *file,
 	 */
 	queue_work(wwan_wq, &port->del_work);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations wwan_hwsim_debugfs_portdestroy_fops = {
-	.write = wwan_hwsim_debugfs_portdestroy_write,
+	.write_iter = wwan_hwsim_debugfs_portdestroy_write,
 	.open = simple_open,
 	.llseek = noop_llseek,
 };
 
-static ssize_t wwan_hwsim_debugfs_portcreate_write(struct file *file,
-						   const char __user *usrbuf,
-						   size_t count, loff_t *ppos)
+static ssize_t wwan_hwsim_debugfs_portcreate_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct wwan_hwsim_dev *dev = file->private_data;
+	struct wwan_hwsim_dev *dev = iocb->ki_filp->private_data;
 	struct wwan_hwsim_port *port;
 
 	port = wwan_hwsim_port_new(dev);
@@ -400,20 +398,19 @@ static ssize_t wwan_hwsim_debugfs_portcreate_write(struct file *file,
 	list_add_tail(&port->list, &dev->ports);
 	spin_unlock(&dev->ports_lock);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations wwan_hwsim_debugfs_portcreate_fops = {
-	.write = wwan_hwsim_debugfs_portcreate_write,
+	.write_iter = wwan_hwsim_debugfs_portcreate_write,
 	.open = simple_open,
 	.llseek = noop_llseek,
 };
 
-static ssize_t wwan_hwsim_debugfs_devdestroy_write(struct file *file,
-						   const char __user *usrbuf,
-						   size_t count, loff_t *ppos)
+static ssize_t wwan_hwsim_debugfs_devdestroy_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct wwan_hwsim_dev *dev = file->private_data;
+	struct wwan_hwsim_dev *dev = iocb->ki_filp->private_data;
 
 	/* We can not delete device here since it will cause a deadlock due to
 	 * waiting this callback to finish in the debugfs_remove() call. So,
@@ -421,18 +418,17 @@ static ssize_t wwan_hwsim_debugfs_devdestroy_write(struct file *file,
 	 */
 	queue_work(wwan_wq, &dev->del_work);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations wwan_hwsim_debugfs_devdestroy_fops = {
-	.write = wwan_hwsim_debugfs_devdestroy_write,
+	.write_iter = wwan_hwsim_debugfs_devdestroy_write,
 	.open = simple_open,
 	.llseek = noop_llseek,
 };
 
-static ssize_t wwan_hwsim_debugfs_devcreate_write(struct file *file,
-						  const char __user *usrbuf,
-						  size_t count, loff_t *ppos)
+static ssize_t wwan_hwsim_debugfs_devcreate_write(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
 	struct wwan_hwsim_dev *dev;
 
@@ -444,11 +440,11 @@ static ssize_t wwan_hwsim_debugfs_devcreate_write(struct file *file,
 	list_add_tail(&dev->list, &wwan_hwsim_devs);
 	spin_unlock(&wwan_hwsim_devs_lock);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations wwan_hwsim_debugfs_devcreate_fops = {
-	.write = wwan_hwsim_debugfs_devcreate_write,
+	.write_iter = wwan_hwsim_debugfs_devcreate_write,
 	.open = simple_open,
 	.llseek = noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 318/437] drivers/net/xen-netback: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (316 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 317/437] drivers/net/wwan: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 319/437] drivers/net/ethernet/broadcom-bnxt: " Jens Axboe
                   ` (119 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/xen-netback/xenbus.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index a78a25b87240..5f2ef4d6bb17 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -102,26 +102,21 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
 #define XENVIF_KICK_STR "kick"
 #define BUFFER_SIZE     32
 
-static ssize_t
-xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
-		     loff_t *ppos)
+static ssize_t xenvif_write_io_ring(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct xenvif_queue *queue =
-		((struct seq_file *)filp->private_data)->private;
+		((struct seq_file *)iocb->ki_filp->private_data)->private;
+	size_t count = iov_iter_count(from);
 	int len;
 	char write[BUFFER_SIZE];
 
 	/* don't allow partial writes and check the length */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count >= sizeof(write))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(write,
-				     sizeof(write) - 1,
-				     ppos,
-				     buf,
-				     count);
+	len = simple_copy_from_iter(write, &iocb->ki_pos, sizeof(write) - 1, from);
 	if (len < 0)
 		return len;
 
@@ -152,10 +147,10 @@ static int xenvif_io_ring_open(struct inode *inode, struct file *filp)
 static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
 	.owner = THIS_MODULE,
 	.open = xenvif_io_ring_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = xenvif_write_io_ring,
+	.write_iter = xenvif_write_io_ring,
 };
 
 static int xenvif_ctrl_show(struct seq_file *m, void *v)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 319/437] drivers/net/ethernet/broadcom-bnxt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (317 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 318/437] drivers/net/xen-netback: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 320/437] drivers/net/brocade-bnad: ensure the copied buf is NULL terminated Jens Axboe
                   ` (118 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
index 156c2404854f..777f2e892869 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c
@@ -17,15 +17,14 @@
 
 static struct dentry *bnxt_debug_mnt;
 
-static ssize_t debugfs_dim_read(struct file *filep,
-				char __user *buffer,
-				size_t count, loff_t *ppos)
+static ssize_t debugfs_dim_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dim *dim = filep->private_data;
+	struct dim *dim = iocb->ki_filp->private_data;
 	int len;
 	char *buf;
+	size_t count = iov_iter_count(to);
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 	if (!dim)
 		return -ENODEV;
@@ -50,7 +49,7 @@ static ssize_t debugfs_dim_read(struct file *filep,
 		kfree(buf);
 		return -ENOSPC;
 	}
-	len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+	len = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 	return len;
 }
@@ -58,7 +57,7 @@ static ssize_t debugfs_dim_read(struct file *filep,
 static const struct file_operations debugfs_dim_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = debugfs_dim_read,
+	.read_iter = debugfs_dim_read_iter,
 };
 
 static void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 320/437] drivers/net/brocade-bnad: ensure the copied buf is NULL terminated
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (318 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 319/437] drivers/net/ethernet/broadcom-bnxt: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 321/437] drivers/net/brocade-bnad: convert to read/write iterators Jens Axboe
                   ` (117 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Currently, we allocate a nbytes-sized kernel buffer and copy nbytes from
userspace to that buffer. Later, we use scanf on this buffer but we don't
ensure that the string is terminated inside the buffer, this can lead to
OOB read when using scanf. Fix this issue by using memdup_user_nul instead
of memdup_user.

Fixes: 7afc5dbde091 ("bna: Add debugfs interface.")
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 7246e13dd559..97291bfbeea5 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -312,7 +312,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	void *kern_buf;
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = memdup_user_nul(buf, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -372,7 +372,7 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	void *kern_buf;
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = memdup_user_nul(buf, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 321/437] drivers/net/brocade-bnad: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (319 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 320/437] drivers/net/brocade-bnad: ensure the copied buf is NULL terminated Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 322/437] drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated Jens Axboe
                   ` (116 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../net/ethernet/brocade/bna/bnad_debugfs.c   | 47 +++++++++----------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 97291bfbeea5..88451f739f1f 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -229,16 +229,15 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 }
 
 static ssize_t
-bnad_debugfs_read(struct file *file, char __user *buf,
-		  size_t nbytes, loff_t *pos)
+bnad_debugfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bnad_debug_info *debug = file->private_data;
+	struct bnad_debug_info *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->debug_buffer)
 		return 0;
 
-	return simple_read_from_buffer(buf, nbytes, pos,
-				debug->debug_buffer, debug->buffer_len);
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+				   debug->buffer_len, to);
 }
 
 #define BFA_REG_CT_ADDRSZ	(0x40000)
@@ -275,18 +274,18 @@ bna_reg_offset_check(struct bfa_ioc *ioc, u32 offset, u32 len)
 }
 
 static ssize_t
-bnad_debugfs_read_regrd(struct file *file, char __user *buf,
-			size_t nbytes, loff_t *pos)
+bnad_debugfs_read_regrd_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bnad_debug_info *regrd_debug = file->private_data;
+	struct bnad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)regrd_debug->i_private;
 	ssize_t rc;
+	loff_t *pos = &iocb->ki_pos;
+	size_t nbytes = iov_iter_count(to);
 
 	if (!bnad->regdata)
 		return 0;
 
-	rc = simple_read_from_buffer(buf, nbytes, pos,
-			bnad->regdata, bnad->reglen);
+	rc = simple_copy_to_iter(bnad->regdata, pos, bnad->reglen, to);
 
 	if ((*pos + nbytes) >= bnad->reglen) {
 		kfree(bnad->regdata);
@@ -298,10 +297,9 @@ bnad_debugfs_read_regrd(struct file *file, char __user *buf,
 }
 
 static ssize_t
-bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bnad_debugfs_write_regrd_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bnad_debug_info *regrd_debug = file->private_data;
+	struct bnad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)regrd_debug->i_private;
 	struct bfa_ioc *ioc = &bnad->bna.ioceth.ioc;
 	int rc, i;
@@ -310,9 +308,10 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	void __iomem *rb, *reg_addr;
 	unsigned long flags;
 	void *kern_buf;
+	size_t nbytes = iov_iter_count(from);
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user_nul(buf, nbytes);
+	kern_buf = iterdup_nul(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -359,10 +358,9 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 }
 
 static ssize_t
-bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bnad_debugfs_write_regwr_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bnad_debug_info *debug = file->private_data;
+	struct bnad_debug_info *debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)debug->i_private;
 	struct bfa_ioc *ioc = &bnad->bna.ioceth.ioc;
 	int rc;
@@ -370,9 +368,10 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	void __iomem *reg_addr;
 	unsigned long flags;
 	void *kern_buf;
+	size_t nbytes = iov_iter_count(from);
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user_nul(buf, nbytes);
+	kern_buf = iterdup_nul(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -434,7 +433,7 @@ static const struct file_operations bnad_debugfs_op_fwtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_fwtrc,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
@@ -442,7 +441,7 @@ static const struct file_operations bnad_debugfs_op_fwsave = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_fwsave,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
@@ -450,8 +449,8 @@ static const struct file_operations bnad_debugfs_op_regrd = {
 	.owner		=       THIS_MODULE,
 	.open		=	bnad_debugfs_open_reg,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read_regrd,
-	.write		=	bnad_debugfs_write_regrd,
+	.read_iter	=	bnad_debugfs_read_regrd_iter,
+	.write_iter	=	bnad_debugfs_write_regrd_iter,
 	.release	=	bnad_debugfs_release,
 };
 
@@ -459,7 +458,7 @@ static const struct file_operations bnad_debugfs_op_regwr = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_reg,
 	.llseek		=	bnad_debugfs_lseek,
-	.write		=	bnad_debugfs_write_regwr,
+	.write_iter	=	bnad_debugfs_write_regwr_iter,
 	.release	=	bnad_debugfs_release,
 };
 
@@ -467,7 +466,7 @@ static const struct file_operations bnad_debugfs_op_drvinfo = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_drvinfo,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 322/437] drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (320 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 321/437] drivers/net/brocade-bnad: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 323/437] drivers/net/ethernet/intel: convert to read/write iterators Jens Axboe
                   ` (115 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Currently, we allocate a count-sized kernel buffer and copy count bytes
from userspace to that buffer. Later, we use sscanf on this buffer but we
don't ensure that the string is terminated inside the buffer, this can lead
to OOB read when using sscanf. Fix this issue by using memdup_user_nul
instead of memdup_user.

Fixes: 96a9a9341cda ("ice: configure FW logging")
Fixes: 73671c3162c8 ("ice: enable FW logging")
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/intel/ice/ice_debugfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index d252d98218d0..9fc0fd95a13d 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -171,7 +171,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 8)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -257,7 +257,7 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 4)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -332,7 +332,7 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 2)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -428,7 +428,7 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 5)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 323/437] drivers/net/ethernet/intel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (321 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 322/437] drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 324/437] drivers/net/ethernet/chelsio: " Jens Axboe
                   ` (114 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../net/ethernet/intel/fm10k/fm10k_debugfs.c  |  10 +-
 .../net/ethernet/intel/i40e/i40e_debugfs.c    | 103 +++++-----
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 181 ++++++++----------
 .../net/ethernet/intel/ixgbe/ixgbe_debugfs.c  |  99 ++++------
 4 files changed, 173 insertions(+), 220 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c b/drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c
index 5c77054d67c6..7995883a2c27 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c
@@ -132,11 +132,11 @@ static int fm10k_dbg_desc_open(struct inode *inode, struct file *filep)
 }
 
 static const struct file_operations fm10k_dbg_desc_fops = {
-	.owner   = THIS_MODULE,
-	.open    = fm10k_dbg_desc_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = fm10k_dbg_desc_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 /**
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index f9ba45f596c9..0afab111d1d4 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -43,23 +43,22 @@ static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
 static char i40e_dbg_command_buf[256] = "";
 
 /**
- * i40e_dbg_command_read - read for command datum
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * i40e_dbg_command_read_iter - read for command datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  **/
-static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t i40e_dbg_command_read_iter(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct i40e_pf *pf = filp->private_data;
-	int bytes_not_copied;
+	struct i40e_pf *pf = iocb->ki_filp->private_data;
 	int buf_size = 256;
 	char *buf;
 	int len;
+	size_t count = iov_iter_count(to);
+	bool ret;
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count < buf_size)
 		return -ENOSPC;
@@ -72,13 +71,13 @@ static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
 		       pf->vsi[pf->lan_vsi]->netdev->name,
 		       i40e_dbg_command_buf);
 
-	bytes_not_copied = copy_to_user(buffer, buf, len);
+	ret = !copy_to_iter_full(buf, len, to);
 	kfree(buf);
 
-	if (bytes_not_copied)
+	if (ret)
 		return -EFAULT;
 
-	*ppos = len;
+	iocb->ki_pos = len;
 	return len;
 }
 
@@ -742,34 +741,30 @@ static void i40e_dbg_dump_vf_all(struct i40e_pf *pf)
 }
 
 /**
- * i40e_dbg_command_write - write into command datum
- * @filp: the opened file
- * @buffer: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * i40e_dbg_command_write_iter - write into command datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  **/
-static ssize_t i40e_dbg_command_write(struct file *filp,
-				      const char __user *buffer,
-				      size_t count, loff_t *ppos)
+static ssize_t i40e_dbg_command_write_iter(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct i40e_pf *pf = filp->private_data;
+	struct i40e_pf *pf = iocb->ki_filp->private_data;
 	char *cmd_buf, *cmd_buf_tmp;
-	int bytes_not_copied;
 	struct i40e_vsi *vsi;
 	int vsi_seid;
 	int veb_seid;
 	int vf_id;
 	int cnt;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	cmd_buf = kzalloc(count + 1, GFP_KERNEL);
 	if (!cmd_buf)
 		return count;
-	bytes_not_copied = copy_from_user(cmd_buf, buffer, count);
-	if (bytes_not_copied) {
+	if (!copy_from_iter_full(cmd_buf, count, from)) {
 		kfree(cmd_buf);
 		return -EFAULT;
 	}
@@ -1617,8 +1612,8 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
 static const struct file_operations i40e_dbg_command_fops = {
 	.owner = THIS_MODULE,
 	.open =  simple_open,
-	.read =  i40e_dbg_command_read,
-	.write = i40e_dbg_command_write,
+	.read_iter =  i40e_dbg_command_read_iter,
+	.write_iter = i40e_dbg_command_write_iter,
 };
 
 /**************************************************************
@@ -1629,23 +1624,22 @@ static const struct file_operations i40e_dbg_command_fops = {
 static char i40e_dbg_netdev_ops_buf[256] = "";
 
 /**
- * i40e_dbg_netdev_ops_read - read for netdev_ops datum
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * i40e_dbg_netdev_ops_read_iter - read for netdev_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  **/
-static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t i40e_dbg_netdev_ops_read_iter(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct i40e_pf *pf = filp->private_data;
-	int bytes_not_copied;
+	struct i40e_pf *pf = iocb->ki_filp->private_data;
 	int buf_size = 256;
 	char *buf;
 	int len;
+	bool ret;
+	size_t count = iov_iter_count(to);
 
 	/* don't allow partal reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count < buf_size)
 		return -ENOSPC;
@@ -1658,44 +1652,39 @@ static ssize_t i40e_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
 		       pf->vsi[pf->lan_vsi]->netdev->name,
 		       i40e_dbg_netdev_ops_buf);
 
-	bytes_not_copied = copy_to_user(buffer, buf, len);
+	ret = !copy_to_iter_full(buf, len, to);
 	kfree(buf);
 
-	if (bytes_not_copied)
+	if (ret)
 		return -EFAULT;
 
-	*ppos = len;
+	iocb->ki_pos = len;
 	return len;
 }
 
 /**
- * i40e_dbg_netdev_ops_write - write into netdev_ops datum
- * @filp: the opened file
- * @buffer: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * i40e_dbg_netdev_ops_write_iter - write into netdev_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  **/
-static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *ppos)
+static ssize_t i40e_dbg_netdev_ops_write_iter(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct i40e_pf *pf = filp->private_data;
-	int bytes_not_copied;
+	struct i40e_pf *pf = iocb->ki_filp->private_data;
 	struct i40e_vsi *vsi;
 	char *buf_tmp;
 	int vsi_seid;
 	int i, cnt;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count >= sizeof(i40e_dbg_netdev_ops_buf))
 		return -ENOSPC;
 
 	memset(i40e_dbg_netdev_ops_buf, 0, sizeof(i40e_dbg_netdev_ops_buf));
-	bytes_not_copied = copy_from_user(i40e_dbg_netdev_ops_buf,
-					  buffer, count);
-	if (bytes_not_copied)
+	if (!copy_from_iter_full(i40e_dbg_netdev_ops_buf, count, from))
 		return -EFAULT;
 	i40e_dbg_netdev_ops_buf[count] = '\0';
 
@@ -1784,8 +1773,8 @@ static ssize_t i40e_dbg_netdev_ops_write(struct file *filp,
 static const struct file_operations i40e_dbg_netdev_ops_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = i40e_dbg_netdev_ops_read,
-	.write = i40e_dbg_netdev_ops_write,
+	.read_iter = i40e_dbg_netdev_ops_read_iter,
+	.write_iter = i40e_dbg_netdev_ops_write_iter,
 };
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_debugfs.c b/drivers/net/ethernet/intel/ice/ice_debugfs.c
index 9fc0fd95a13d..6ec1e04972c9 100644
--- a/drivers/net/ethernet/intel/ice/ice_debugfs.c
+++ b/drivers/net/ethernet/intel/ice/ice_debugfs.c
@@ -151,27 +151,25 @@ static int ice_debugfs_module_open(struct inode *inode, struct file *filp)
 }
 
 /**
- * ice_debugfs_module_write - write into 'module' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ice_debugfs_module_write_iter - write into 'module' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  */
 static ssize_t
-ice_debugfs_module_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *ppos)
+ice_debugfs_module_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ice_pf *pf = file_inode(filp)->i_private;
-	struct dentry *dentry = file_dentry(filp);
+	struct ice_pf *pf = file_inode(iocb->ki_filp)->i_private;
+	struct dentry *dentry = file_dentry(iocb->ki_filp);
 	struct device *dev = ice_pf_to_dev(pf);
 	char user_val[16], *cmd_buf;
 	int module, log_level, cnt;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes or invalid input */
-	if (*ppos != 0 || count > 8)
+	if (iocb->ki_pos != 0 || count > 8)
 		return -EINVAL;
 
-	cmd_buf = memdup_user_nul(buf, count);
+	cmd_buf = iterdup_nul(from, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -209,55 +207,50 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
 static const struct file_operations ice_debugfs_module_fops = {
 	.owner = THIS_MODULE,
 	.open  = ice_debugfs_module_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.release = single_release,
-	.write = ice_debugfs_module_write,
+	.write_iter = ice_debugfs_module_write_iter,
 };
 
 /**
- * ice_debugfs_nr_messages_read - read from 'nr_messages' file
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ice_debugfs_nr_messages_read_iter - read from 'nr_messages' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  */
-static ssize_t ice_debugfs_nr_messages_read(struct file *filp,
-					    char __user *buffer, size_t count,
-					    loff_t *ppos)
+static ssize_t ice_debugfs_nr_messages_read_iter(struct kiocb *iocb,
+						 struct iov_iter *to)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct ice_hw *hw = &pf->hw;
 	char buff[32] = {};
 
 	snprintf(buff, sizeof(buff), "%d\n",
 		 hw->fwlog_cfg.log_resolution);
 
-	return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff), to);
 }
 
 /**
- * ice_debugfs_nr_messages_write - write into 'nr_messages' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ice_debugfs_nr_messages_write_iter - write into 'nr_messages' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  */
 static ssize_t
-ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
-			      size_t count, loff_t *ppos)
+ice_debugfs_nr_messages_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct device *dev = ice_pf_to_dev(pf);
 	struct ice_hw *hw = &pf->hw;
 	char user_val[8], *cmd_buf;
 	s16 nr_messages;
 	ssize_t ret;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes or invalid input */
-	if (*ppos != 0 || count > 4)
+	if (iocb->ki_pos != 0 || count > 4)
 		return -EINVAL;
 
-	cmd_buf = memdup_user_nul(buf, count);
+	cmd_buf = iterdup_nul(from, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -285,22 +278,19 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
 static const struct file_operations ice_debugfs_nr_messages_fops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read = ice_debugfs_nr_messages_read,
-	.write = ice_debugfs_nr_messages_write,
+	.read_iter = ice_debugfs_nr_messages_read_iter,
+	.write_iter = ice_debugfs_nr_messages_write_iter,
 };
 
 /**
- * ice_debugfs_enable_read - read from 'enable' file
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ice_debugfs_enable_read_iter - read from 'enable' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  */
-static ssize_t ice_debugfs_enable_read(struct file *filp,
-				       char __user *buffer, size_t count,
-				       loff_t *ppos)
+static ssize_t ice_debugfs_enable_read_iter(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct ice_hw *hw = &pf->hw;
 	char buff[32] = {};
 
@@ -308,31 +298,29 @@ static ssize_t ice_debugfs_enable_read(struct file *filp,
 		 (u16)(hw->fwlog_cfg.options &
 		 ICE_FWLOG_OPTION_IS_REGISTERED) >> 3);
 
-	return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff), to);
 }
 
 /**
- * ice_debugfs_enable_write - write into 'enable' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ice_debugfs_enable_write_iter - write into 'enable' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  */
 static ssize_t
-ice_debugfs_enable_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *ppos)
+ice_debugfs_enable_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct ice_hw *hw = &pf->hw;
 	char user_val[8], *cmd_buf;
 	bool enable;
 	ssize_t ret;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes or invalid input */
-	if (*ppos != 0 || count > 2)
+	if (iocb->ki_pos != 0 || count > 2)
 		return -EINVAL;
 
-	cmd_buf = memdup_user_nul(buf, count);
+	cmd_buf = iterdup_nul(from, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -380,22 +368,19 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
 static const struct file_operations ice_debugfs_enable_fops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read = ice_debugfs_enable_read,
-	.write = ice_debugfs_enable_write,
+	.read_iter = ice_debugfs_enable_read_iter,
+	.write_iter = ice_debugfs_enable_write_iter,
 };
 
 /**
- * ice_debugfs_log_size_read - read from 'log_size' file
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ice_debugfs_log_size_read_iter - read from 'log_size' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  */
-static ssize_t ice_debugfs_log_size_read(struct file *filp,
-					 char __user *buffer, size_t count,
-					 loff_t *ppos)
+static ssize_t ice_debugfs_log_size_read_iter(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct ice_hw *hw = &pf->hw;
 	char buff[32] = {};
 	int index;
@@ -403,32 +388,30 @@ static ssize_t ice_debugfs_log_size_read(struct file *filp,
 	index = hw->fwlog_ring.index;
 	snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]);
 
-	return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff));
+	return simple_copy_to_iter(buff, &iocb->ki_pos, strlen(buff), to);
 }
 
 /**
- * ice_debugfs_log_size_write - write into 'log_size' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ice_debugfs_log_size_write_iter - write into 'log_size' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  */
 static ssize_t
-ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
-			   size_t count, loff_t *ppos)
+ice_debugfs_log_size_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct device *dev = ice_pf_to_dev(pf);
 	struct ice_hw *hw = &pf->hw;
 	char user_val[8], *cmd_buf;
 	ssize_t ret;
 	int index;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes or invalid input */
-	if (*ppos != 0 || count > 5)
+	if (iocb->ki_pos != 0 || count > 5)
 		return -EINVAL;
 
-	cmd_buf = memdup_user_nul(buf, count);
+	cmd_buf = iterdup_nul(from, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -470,24 +453,23 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
 static const struct file_operations ice_debugfs_log_size_fops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read = ice_debugfs_log_size_read,
-	.write = ice_debugfs_log_size_write,
+	.read_iter = ice_debugfs_log_size_read_iter,
+	.write_iter = ice_debugfs_log_size_write_iter,
 };
 
 /**
- * ice_debugfs_data_read - read from 'data' file
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ice_debugfs_data_read_iter - read from 'data' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  */
-static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t ice_debugfs_data_read_iter(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct ice_hw *hw = &pf->hw;
 	int data_copied = 0;
 	bool done = false;
+	size_t count = iov_iter_count(to);
 
 	if (ice_fwlog_ring_empty(&hw->fwlog_ring))
 		return 0;
@@ -503,7 +485,7 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
 			continue;
 		}
 
-		if (copy_to_user(buffer, log->data, cur_buf_len)) {
+		if (!copy_to_iter_full(log->data, cur_buf_len, to)) {
 			/* if there is an error then bail and return whatever
 			 * the driver has copied so far
 			 */
@@ -512,9 +494,8 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
 		}
 
 		data_copied += cur_buf_len;
-		buffer += cur_buf_len;
 		count -= cur_buf_len;
-		*ppos += cur_buf_len;
+		iocb->ki_pos += cur_buf_len;
 		ice_fwlog_ring_increment(&hw->fwlog_ring.head,
 					 hw->fwlog_ring.size);
 	}
@@ -523,23 +504,21 @@ static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer,
 }
 
 /**
- * ice_debugfs_data_write - write into 'data' file
- * @filp: the opened file
- * @buf: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ice_debugfs_data_write_iter - write into 'data' file
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  */
 static ssize_t
-ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
-		       loff_t *ppos)
+ice_debugfs_data_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ice_pf *pf = filp->private_data;
+	struct ice_pf *pf = iocb->ki_filp->private_data;
 	struct device *dev = ice_pf_to_dev(pf);
 	struct ice_hw *hw = &pf->hw;
 	ssize_t ret;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	/* any value is allowed to clear the buffer so no need to even look at
@@ -573,8 +552,8 @@ ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count,
 static const struct file_operations ice_debugfs_data_fops = {
 	.owner = THIS_MODULE,
 	.open  = simple_open,
-	.read = ice_debugfs_data_read,
-	.write = ice_debugfs_data_write,
+	.read_iter = ice_debugfs_data_read_iter,
+	.write_iter = ice_debugfs_data_write_iter,
 };
 
 /**
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 5b1cf49df3d3..077dd26e7079 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -10,16 +10,17 @@ static struct dentry *ixgbe_dbg_root;
 
 static char ixgbe_dbg_reg_ops_buf[256] = "";
 
-static ssize_t ixgbe_dbg_common_ops_read(struct file *filp, char __user *buffer,
-					 size_t count, loff_t *ppos,
+static ssize_t ixgbe_dbg_common_ops_read(struct kiocb *iocb,
+					 struct iov_iter *to,
 					 char *dbg_buf)
 {
-	struct ixgbe_adapter *adapter = filp->private_data;
+	struct ixgbe_adapter *adapter = iocb->ki_filp->private_data;
 	char *buf;
 	int len;
+	size_t count = iov_iter_count(to);
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buf = kasprintf(GFP_KERNEL, "%s: %s\n",
@@ -32,51 +33,43 @@ static ssize_t ixgbe_dbg_common_ops_read(struct file *filp, char __user *buffer,
 		return -ENOSPC;
 	}
 
-	len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+	len = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 
 	kfree(buf);
 	return len;
 }
 
 /**
- * ixgbe_dbg_reg_ops_read - read for reg_ops datum
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ixgbe_dbg_reg_ops_read_iter - read for reg_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  **/
-static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char __user *buffer,
-				      size_t count, loff_t *ppos)
+static ssize_t ixgbe_dbg_reg_ops_read_iter(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	return ixgbe_dbg_common_ops_read(filp, buffer, count, ppos,
-					 ixgbe_dbg_reg_ops_buf);
+	return ixgbe_dbg_common_ops_read(iocb, to, ixgbe_dbg_reg_ops_buf);
 }
 
 /**
- * ixgbe_dbg_reg_ops_write - write into reg_ops datum
- * @filp: the opened file
- * @buffer: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ixgbe_dbg_reg_ops_write_iter - write into reg_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  **/
-static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t ixgbe_dbg_reg_ops_write_iter(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ixgbe_adapter *adapter = filp->private_data;
+	struct ixgbe_adapter *adapter = iocb->ki_filp->private_data;
 	int len;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count >= sizeof(ixgbe_dbg_reg_ops_buf))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(ixgbe_dbg_reg_ops_buf,
-				     sizeof(ixgbe_dbg_reg_ops_buf)-1,
-				     ppos,
-				     buffer,
-				     count);
+	len = simple_copy_from_iter(ixgbe_dbg_reg_ops_buf, &iocb->ki_pos,
+				    sizeof(ixgbe_dbg_reg_ops_buf) - 1, from);
 	if (len < 0)
 		return len;
 
@@ -115,51 +108,43 @@ static ssize_t ixgbe_dbg_reg_ops_write(struct file *filp,
 static const struct file_operations ixgbe_dbg_reg_ops_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  ixgbe_dbg_reg_ops_read,
-	.write = ixgbe_dbg_reg_ops_write,
+	.read_iter = ixgbe_dbg_reg_ops_read_iter,
+	.write_iter = ixgbe_dbg_reg_ops_write_iter,
 };
 
 static char ixgbe_dbg_netdev_ops_buf[256] = "";
 
 /**
- * ixgbe_dbg_netdev_ops_read - read for netdev_ops datum
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
+ * ixgbe_dbg_netdev_ops_read_iter - read for netdev_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @to: iovec iterator
  **/
-static ssize_t ixgbe_dbg_netdev_ops_read(struct file *filp, char __user *buffer,
-					 size_t count, loff_t *ppos)
+static ssize_t ixgbe_dbg_netdev_ops_read_iter(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	return ixgbe_dbg_common_ops_read(filp, buffer, count, ppos,
-					 ixgbe_dbg_netdev_ops_buf);
+	return ixgbe_dbg_common_ops_read(iocb, to, ixgbe_dbg_netdev_ops_buf);
 }
 
 /**
- * ixgbe_dbg_netdev_ops_write - write into netdev_ops datum
- * @filp: the opened file
- * @buffer: where to find the user's data
- * @count: the length of the user's data
- * @ppos: file position offset
+ * ixgbe_dbg_netdev_ops_write_iter - write into netdev_ops datum
+ * @iocb: the kernel io callback (kiocb) struct
+ * @from: iovec iterator
  **/
-static ssize_t ixgbe_dbg_netdev_ops_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t ixgbe_dbg_netdev_ops_write_iter(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ixgbe_adapter *adapter = filp->private_data;
+	struct ixgbe_adapter *adapter = iocb->ki_filp->private_data;
 	int len;
+	size_t count = iov_iter_count(from);
 
 	/* don't allow partial writes */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count >= sizeof(ixgbe_dbg_netdev_ops_buf))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(ixgbe_dbg_netdev_ops_buf,
-				     sizeof(ixgbe_dbg_netdev_ops_buf)-1,
-				     ppos,
-				     buffer,
-				     count);
+	len = simple_copy_from_iter(ixgbe_dbg_netdev_ops_buf, &iocb->ki_pos,
+				    sizeof(ixgbe_dbg_netdev_ops_buf) - 1, from);
 	if (len < 0)
 		return len;
 
@@ -181,8 +166,8 @@ static ssize_t ixgbe_dbg_netdev_ops_write(struct file *filp,
 static const struct file_operations ixgbe_dbg_netdev_ops_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ixgbe_dbg_netdev_ops_read,
-	.write = ixgbe_dbg_netdev_ops_write,
+	.read_iter = ixgbe_dbg_netdev_ops_read_iter,
+	.write_iter = ixgbe_dbg_netdev_ops_write_iter,
 };
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 324/437] drivers/net/ethernet/chelsio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (322 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 323/437] drivers/net/ethernet/intel: convert to read/write iterators Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 325/437] drivers/net/ethernet/hisilicon: " Jens Axboe
                   ` (113 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 321 +++++++++---------
 drivers/net/ethernet/chelsio/cxgb4/l2t.c      |   2 +-
 2 files changed, 164 insertions(+), 159 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 14e0d989c3ba..a3b94ceea07d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -227,11 +227,11 @@ static int cim_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_pif_la_show(struct seq_file *seq, void *v, int idx)
@@ -270,11 +270,11 @@ static int cim_pif_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_pif_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_pif_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_pif_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)
@@ -316,11 +316,11 @@ static int cim_ma_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_ma_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_ma_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_ma_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_qcfg_show(struct seq_file *seq, void *v)
@@ -409,11 +409,11 @@ static int cim_ibq_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_ibq_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_ibq_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_ibq_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_obq_open(struct inode *inode, struct file *file)
@@ -438,11 +438,11 @@ static int cim_obq_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_obq_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_obq_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_obq_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 struct field_desc {
@@ -660,16 +660,16 @@ static int tp_la_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t tp_la_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
+static ssize_t tp_la_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err;
 	char s[32];
 	unsigned long val;
+	size_t count = iov_iter_count(from);
 	size_t size = min(sizeof(s) - 1, count);
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
 
-	if (copy_from_user(s, buf, size))
+	if (!copy_from_iter_full(s, size, from))
 		return -EFAULT;
 	s[size] = '\0';
 	err = kstrtoul(s, 0, &val);
@@ -684,12 +684,12 @@ static ssize_t tp_la_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations tp_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = tp_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private,
-	.write   = tp_la_write
+	.owner      = THIS_MODULE,
+	.open       = tp_la_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = seq_release_private,
+	.write_iter = tp_la_write_iter
 };
 
 static int ulprx_la_show(struct seq_file *seq, void *v, int idx)
@@ -720,11 +720,11 @@ static int ulprx_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations ulprx_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = ulprx_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = ulprx_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* Show the PM memory stats.  These stats include:
@@ -799,23 +799,22 @@ static int pm_stats_open(struct inode *inode, struct file *file)
 	return single_open(file, pm_stats_show, inode->i_private);
 }
 
-static ssize_t pm_stats_clear(struct file *file, const char __user *buf,
-			      size_t count, loff_t *pos)
+static ssize_t pm_stats_clear(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
 
 	t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0);
 	t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations pm_stats_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = pm_stats_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = pm_stats_clear
+	.owner      = THIS_MODULE,
+	.open       = pm_stats_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = pm_stats_clear
 };
 
 static int tx_rate_show(struct seq_file *seq, void *v)
@@ -1134,11 +1133,11 @@ static int devlog_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations devlog_fops = {
-	.owner   = THIS_MODULE,
-	.open    = devlog_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = devlog_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* Show Firmware Mailbox Command/Reply Log
@@ -1232,11 +1231,11 @@ static int mboxlog_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations mboxlog_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mboxlog_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = mboxlog_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 static int mbox_show(struct seq_file *seq, void *v)
@@ -1275,8 +1274,7 @@ static int mbox_open(struct inode *inode, struct file *file)
 	return single_open(file, mbox_show, inode->i_private);
 }
 
-static ssize_t mbox_write(struct file *file, const char __user *buf,
-			  size_t count, loff_t *pos)
+static ssize_t mbox_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i;
 	char c = '\n', s[256];
@@ -1286,10 +1284,11 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 	struct adapter *adap;
 	void __iomem *addr;
 	void __iomem *ctrl;
+	size_t count = iov_iter_count(from);
 
 	if (count > sizeof(s) - 1 || !count)
 		return -EINVAL;
-	if (copy_from_user(s, buf, count))
+	if (!copy_from_iter_full(s, count, from))
 		return -EFAULT;
 	s[count] = '\0';
 
@@ -1298,7 +1297,7 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 		   &data[7], &c) < 8 || c != '\n')
 		return -EINVAL;
 
-	ino = file_inode(file);
+	ino = file_inode(iocb->ki_filp);
 	mbox = (uintptr_t)ino->i_private & 7;
 	adap = ino->i_private - mbox;
 	addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
@@ -1315,12 +1314,12 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations mbox_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mbox_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = mbox_write
+	.owner      = THIS_MODULE,
+	.open       = mbox_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = mbox_write_iter
 };
 
 static int mps_trc_show(struct seq_file *seq, void *v)
@@ -1408,8 +1407,7 @@ static unsigned int xdigit2int(unsigned char c)
  * must be anchored at 0.  An omitted mask is taken as a mask of 1s, an omitted
  * anchor is taken as 0.
  */
-static ssize_t mps_trc_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t mps_trc_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, enable, ret;
 	u32 *data, *mask;
@@ -1419,8 +1417,9 @@ static ssize_t mps_trc_write(struct file *file, const char __user *buf,
 	char *s, *p, *word, *end;
 	struct adapter *adap;
 	u32 j;
+	size_t count = iov_iter_count(from);
 
-	ino = file_inode(file);
+	ino = file_inode(iocb->ki_filp);
 	trcidx = (uintptr_t)ino->i_private & 3;
 	adap = ino->i_private - trcidx;
 
@@ -1432,7 +1431,7 @@ static ssize_t mps_trc_write(struct file *file, const char __user *buf,
 	p = s = kzalloc(count + 1, GFP_USER);
 	if (!s)
 		return -ENOMEM;
-	if (copy_from_user(s, buf, count)) {
+	if (!copy_from_iter_full(s, count, from)) {
 		count = -EFAULT;
 		goto out;
 	}
@@ -1608,20 +1607,20 @@ inval:				count = -EINVAL;
 }
 
 static const struct file_operations mps_trc_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mps_trc_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = mps_trc_write
+	.owner      = THIS_MODULE,
+	.open       = mps_trc_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = mps_trc_write_iter
 };
 
-static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *ppos)
+static ssize_t flash_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
-	loff_t avail = file_inode(file)->i_size;
-	struct adapter *adap = file->private_data;
+	loff_t pos = iocb->ki_pos;
+	loff_t avail = file_inode(iocb->ki_filp)->i_size;
+	struct adapter *adap = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -1643,23 +1642,22 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
 			return ret;
 
 		len -= ofst;
-		if (copy_to_user(buf, data + ofst, len))
+		if (!copy_to_iter_full(data + ofst, len, to))
 			return -EFAULT;
 
-		buf += len;
 		pos += len;
 		count -= len;
 	}
-	count = pos - *ppos;
-	*ppos = pos;
+	count = pos - iocb->ki_pos;
+	iocb->ki_pos = pos;
 	return count;
 }
 
 static const struct file_operations flash_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mem_open,
-	.read    = flash_read,
-	.llseek  = default_llseek,
+	.owner     = THIS_MODULE,
+	.open      = mem_open,
+	.read_iter = flash_read_iter,
+	.llseek    = default_llseek,
 };
 
 static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
@@ -1928,11 +1926,11 @@ static int mps_tcam_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations mps_tcam_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mps_tcam_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = mps_tcam_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 /* Display various sensor information.
@@ -2005,11 +2003,11 @@ static int rss_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* RSS Configuration.
@@ -2194,17 +2192,17 @@ static int rss_key_open(struct inode *inode, struct file *file)
 	return single_open(file, rss_key_show, inode->i_private);
 }
 
-static ssize_t rss_key_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t rss_key_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, j;
 	u32 key[10];
 	char s[100], *p;
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 
 	if (count > sizeof(s) - 1)
 		return -EINVAL;
-	if (copy_from_user(s, buf, count))
+	if (!copy_from_iter_full(s, count, from))
 		return -EFAULT;
 	for (i = count; i > 0 && isspace(s[i - 1]); i--)
 		;
@@ -2224,12 +2222,12 @@ static ssize_t rss_key_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations rss_key_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_key_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = rss_key_write
+	.owner      = THIS_MODULE,
+	.open       = rss_key_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = rss_key_write_iter
 };
 
 /* PF RSS Configuration.
@@ -2308,11 +2306,11 @@ static int rss_pf_config_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_pf_config_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_pf_config_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_pf_config_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* VF RSS Configuration.
@@ -2371,11 +2369,11 @@ static int rss_vf_config_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_vf_config_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_vf_config_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_vf_config_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 #ifdef CONFIG_CHELSIO_T4_DCB
@@ -2559,11 +2557,11 @@ static int dcb_info_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations dcb_info_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = dcb_info_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = dcb_info_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 #endif /* CONFIG_CHELSIO_T4_DCB */
 
@@ -3243,11 +3241,11 @@ static int sge_qinfo_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations sge_qinfo_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = sge_qinfo_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = sge_qinfo_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 int mem_open(struct inode *inode, struct file *file)
@@ -3265,15 +3263,15 @@ int mem_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mem_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
-	loff_t avail = file_inode(file)->i_size;
-	unsigned int mem = (uintptr_t)file->private_data & 0x7;
-	struct adapter *adap = file->private_data - mem;
+	loff_t pos = iocb->ki_pos;
+	loff_t avail = file_inode(iocb->ki_filp)->i_size;
+	unsigned int mem = (uintptr_t)iocb->ki_filp->private_data & 0x7;
+	struct adapter *adap = iocb->ki_filp->private_data - mem;
 	__be32 *data;
 	int ret;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -3293,20 +3291,20 @@ static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
 		kvfree(data);
 		return ret;
 	}
-	ret = copy_to_user(buf, data, count);
+	ret = !copy_to_iter_full(data, count, to);
 
 	kvfree(data);
 	if (ret)
 		return -EFAULT;
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 	return count;
 }
 static const struct file_operations mem_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = simple_open,
-	.read    = mem_read,
-	.llseek  = default_llseek,
+	.owner     = THIS_MODULE,
+	.open      = simple_open,
+	.read_iter = mem_read_iter,
+	.llseek    = default_llseek,
 };
 
 static int tid_info_show(struct seq_file *seq, void *v)
@@ -3401,11 +3399,10 @@ static void add_debugfs_mem(struct adapter *adap, const char *name,
 				 size_mb << 20);
 }
 
-static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t blocked_fl_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	int len;
-	const struct adapter *adap = filp->private_data;
+	const struct adapter *adap = iocb->ki_filp->private_data;
 	char *buf;
 	ssize_t size = (adap->sge.egr_sz + 3) / 4 +
 			adap->sge.egr_sz / 32 + 2; /* includes ,/\n/\0 */
@@ -3417,23 +3414,31 @@ static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
 	len = snprintf(buf, size - 1, "%*pb\n",
 		       adap->sge.egr_sz, adap->sge.blocked_fl);
 	len += sprintf(buf + len, "\n");
-	size = simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	size = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return size;
 }
 
-static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t blocked_fl_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err;
 	unsigned long *t;
-	struct adapter *adap = filp->private_data;
+	struct adapter *adap = iocb->ki_filp->private_data;
+	void *kern_buf;
+	size_t count = iov_iter_count(from);
 
 	t = bitmap_zalloc(adap->sge.egr_sz, GFP_KERNEL);
 	if (!t)
 		return -ENOMEM;
 
-	err = bitmap_parse_user(ubuf, count, t, adap->sge.egr_sz);
+	kern_buf = kzalloc(count + 1, GFP_KERNEL);
+	if (!kern_buf)
+		return -ENOMEM;
+
+	if (!copy_from_iter_full(kern_buf, count, from))
+		return -EFAULT;
+
+	err = bitmap_parse(kern_buf, UINT_MAX, t, adap->sge.egr_sz);
 	if (err) {
 		bitmap_free(t);
 		return err;
@@ -3445,11 +3450,11 @@ static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
 }
 
 static const struct file_operations blocked_fl_fops = {
-	.owner   = THIS_MODULE,
-	.open    = simple_open,
-	.read    = blocked_fl_read,
-	.write   = blocked_fl_write,
-	.llseek  = generic_file_llseek,
+	.owner      = THIS_MODULE,
+	.open       = simple_open,
+	.read_iter  = blocked_fl_read_iter,
+	.write_iter = blocked_fl_write_iter,
+	.llseek     = generic_file_llseek,
 };
 
 static void mem_region_show(struct seq_file *seq, const char *name,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/l2t.c b/drivers/net/ethernet/chelsio/cxgb4/l2t.c
index 1e5f5b1a22a6..c4564a14b6ee 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/l2t.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/l2t.c
@@ -756,7 +756,7 @@ static int l2t_seq_open(struct inode *inode, struct file *file)
 const struct file_operations t4_l2t_fops = {
 	.owner = THIS_MODULE,
 	.open = l2t_seq_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 325/437] drivers/net/ethernet/hisilicon: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (323 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 324/437] drivers/net/ethernet/chelsio: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 326/437] drivers/net/ethernet/huawei: " Jens Axboe
                   ` (112 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../net/ethernet/hisilicon/hns3/hns3_debugfs.c    | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 807eb3bbb11c..0ea141e12655 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -1257,10 +1257,9 @@ static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,
 	return ops->dbg_read_cmd(dbg_data->handle, cmd, buf, len);
 }
 
-static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
-			     size_t count, loff_t *ppos)
+static ssize_t hns3_dbg_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hns3_dbg_data *dbg_data = filp->private_data;
+	struct hns3_dbg_data *dbg_data = iocb->ki_filp->private_data;
 	struct hnae3_handle *handle = dbg_data->handle;
 	struct hns3_nic_priv *priv = handle->priv;
 	ssize_t size = 0;
@@ -1301,8 +1300,8 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
 			goto out;
 	}
 
-	size = simple_read_from_buffer(buffer, count, ppos, read_buf,
-				       strlen(read_buf));
+	size = simple_copy_to_iter(read_buf, &iocb->ki_pos, strlen(read_buf),
+				   to);
 	if (size > 0) {
 		mutex_unlock(&handle->dbgfs_lock);
 		return size;
@@ -1320,9 +1319,9 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
 }
 
 static const struct file_operations hns3_dbg_fops = {
-	.owner = THIS_MODULE,
-	.open  = simple_open,
-	.read  = hns3_dbg_read,
+	.owner     = THIS_MODULE,
+	.open      = simple_open,
+	.read_iter = hns3_dbg_read_iter,
 };
 
 static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 326/437] drivers/net/ethernet/huawei: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (324 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 325/437] drivers/net/ethernet/hisilicon: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 327/437] drivers/net/ethernet/amd-xgbe: " Jens Axboe
                   ` (111 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/huawei/hinic/hinic_debugfs.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c b/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
index 061952c6c21a..411d005a4a95 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
@@ -133,8 +133,7 @@ static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
 	return ret;
 }
 
-static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t count,
-				  loff_t *ppos)
+static ssize_t hinic_dbg_cmd_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct hinic_debug_priv *dbg;
 	char ret_buf[20];
@@ -142,7 +141,7 @@ static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t
 	u64 out;
 	int ret;
 
-	desc = filp->private_data;
+	desc = iocb->ki_filp->private_data;
 	dbg = container_of(desc, struct hinic_debug_priv, field_id[*desc]);
 
 	switch (dbg->type) {
@@ -166,13 +165,13 @@ static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t
 
 	ret = snprintf(ret_buf, sizeof(ret_buf), "0x%llx\n", out);
 
-	return simple_read_from_buffer(buffer, count, ppos, ret_buf, ret);
+	return simple_copy_to_iter(ret_buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations hinic_dbg_cmd_fops = {
-	.owner = THIS_MODULE,
-	.open  = simple_open,
-	.read  = hinic_dbg_cmd_read,
+	.owner      = THIS_MODULE,
+	.open       = simple_open,
+	.read_iter  = hinic_dbg_cmd_read_iter,
 };
 
 static int create_dbg_files(struct hinic_dev *dev, enum hinic_dbg_type type, void *data,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 327/437] drivers/net/ethernet/amd-xgbe: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (325 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 326/437] drivers/net/ethernet/huawei: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 328/437] drivers/net/ethernet/marvell/octeontx2: " Jens Axboe
                   ` (110 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
[axboe: fix typo in xi2c_reg_value_read_iter]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c | 233 +++++++++----------
 1 file changed, 112 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
index b0a6c96b6ef4..5dfd4fc8618e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
@@ -121,36 +121,30 @@
 #include "xgbe.h"
 #include "xgbe-common.h"
 
-static ssize_t xgbe_common_read(char __user *buffer, size_t count,
-				loff_t *ppos, unsigned int value)
+static ssize_t xgbe_common_read_iter(struct iov_iter *to, loff_t *ppos,
+				     unsigned int value)
 {
-	char *buf;
-	ssize_t len;
+	char buf[16];
+	int len;
+	size_t count = iov_iter_count(to);
 
 	if (*ppos != 0)
 		return 0;
 
-	buf = kasprintf(GFP_KERNEL, "0x%08x\n", value);
-	if (!buf)
-		return -ENOMEM;
-
-	if (count < strlen(buf)) {
-		kfree(buf);
+	len = sprintf(buf, "0x%08x\n", value);
+	if (count < len)
 		return -ENOSPC;
-	}
-
-	len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-	kfree(buf);
 
-	return len;
+	return simple_copy_to_iter(buf, ppos, len, to);
 }
 
-static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
-				 loff_t *ppos, unsigned int *value)
+static ssize_t xgbe_common_write_iter(struct iov_iter *from, loff_t *ppos,
+				      unsigned int *value)
 {
 	char workarea[32];
 	ssize_t len;
 	int ret;
+	size_t count = iov_iter_count(from);
 
 	if (*ppos != 0)
 		return -EINVAL;
@@ -158,8 +152,8 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
 	if (count >= sizeof(workarea))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(workarea, sizeof(workarea) - 1, ppos,
-				     buffer, count);
+	len = simple_copy_from_iter(workarea, ppos, sizeof(workarea) - 1,
+				    from);
 	if (len < 0)
 		return len;
 
@@ -171,44 +165,43 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
 	return len;
 }
 
-static ssize_t xgmac_reg_addr_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_addr_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xgmac_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xgmac_reg);
 }
 
-static ssize_t xgmac_reg_addr_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_addr_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xgmac_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xgmac_reg);
 }
 
-static ssize_t xgmac_reg_value_read(struct file *filp, char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_value_read_iter(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XGMAC_IOREAD(pdata, pdata->debugfs_xgmac_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xgmac_reg_value_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_value_write_iter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -220,72 +213,73 @@ static ssize_t xgmac_reg_value_write(struct file *filp,
 static const struct file_operations xgmac_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xgmac_reg_addr_read,
-	.write = xgmac_reg_addr_write,
+	.read_iter =  xgmac_reg_addr_read_iter,
+	.write_iter = xgmac_reg_addr_write_iter,
 };
 
 static const struct file_operations xgmac_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xgmac_reg_value_read,
-	.write = xgmac_reg_value_write,
+	.read_iter =  xgmac_reg_value_read_iter,
+	.write_iter = xgmac_reg_value_write_iter,
 };
 
-static ssize_t xpcs_mmd_read(struct file *filp, char __user *buffer,
-			     size_t count, loff_t *ppos)
+static ssize_t xpcs_mmd_read_iter(struct kiocb *iocb,
+				  struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_mmd);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xpcs_mmd);
 }
 
-static ssize_t xpcs_mmd_write(struct file *filp, const char __user *buffer,
-			      size_t count, loff_t *ppos)
+static ssize_t xpcs_mmd_write_iter(struct kiocb *iocb,
+				   struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xpcs_mmd);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xpcs_mmd);
 }
 
-static ssize_t xpcs_reg_addr_read(struct file *filp, char __user *buffer,
-				  size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_addr_read_iter(struct kiocb *iocb,
+				       struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xpcs_reg);
 }
 
-static ssize_t xpcs_reg_addr_write(struct file *filp, const char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_addr_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xpcs_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xpcs_reg);
 }
 
-static ssize_t xpcs_reg_value_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_value_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XMDIO_READ(pdata, pdata->debugfs_xpcs_mmd,
 			   pdata->debugfs_xpcs_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xpcs_reg_value_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_value_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -298,62 +292,61 @@ static ssize_t xpcs_reg_value_write(struct file *filp,
 static const struct file_operations xpcs_mmd_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_mmd_read,
-	.write = xpcs_mmd_write,
+	.read_iter =  xpcs_mmd_read_iter,
+	.write_iter = xpcs_mmd_write_iter,
 };
 
 static const struct file_operations xpcs_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_reg_addr_read,
-	.write = xpcs_reg_addr_write,
+	.read_iter =  xpcs_reg_addr_read_iter,
+	.write_iter = xpcs_reg_addr_write_iter,
 };
 
 static const struct file_operations xpcs_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_reg_value_read,
-	.write = xpcs_reg_value_write,
+	.read_iter =  xpcs_reg_value_read_iter,
+	.write_iter = xpcs_reg_value_write_iter,
 };
 
-static ssize_t xprop_reg_addr_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xprop_reg_addr_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xprop_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xprop_reg);
 }
 
-static ssize_t xprop_reg_addr_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xprop_reg_addr_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xprop_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xprop_reg);
 }
 
-static ssize_t xprop_reg_value_read(struct file *filp, char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xprop_reg_value_read_iter(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XP_IOREAD(pdata, pdata->debugfs_xprop_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xprop_reg_value_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t xprop_reg_value_write_iter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -365,55 +358,53 @@ static ssize_t xprop_reg_value_write(struct file *filp,
 static const struct file_operations xprop_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xprop_reg_addr_read,
-	.write = xprop_reg_addr_write,
+	.read_iter =  xprop_reg_addr_read_iter,
+	.write_iter = xprop_reg_addr_write_iter,
 };
 
 static const struct file_operations xprop_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xprop_reg_value_read,
-	.write = xprop_reg_value_write,
+	.read_iter =  xprop_reg_value_read_iter,
+	.write_iter = xprop_reg_value_write_iter,
 };
 
-static ssize_t xi2c_reg_addr_read(struct file *filp, char __user *buffer,
-				  size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_addr_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xi2c_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xi2c_reg);
 }
 
-static ssize_t xi2c_reg_addr_write(struct file *filp,
-				   const char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_addr_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xi2c_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xi2c_reg);
 }
 
-static ssize_t xi2c_reg_value_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_value_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XI2C_IOREAD(pdata, pdata->debugfs_xi2c_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xi2c_reg_value_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_value_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -425,15 +416,15 @@ static ssize_t xi2c_reg_value_write(struct file *filp,
 static const struct file_operations xi2c_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xi2c_reg_addr_read,
-	.write = xi2c_reg_addr_write,
+	.read_iter =  xi2c_reg_addr_read_iter,
+	.write_iter = xi2c_reg_addr_write_iter,
 };
 
 static const struct file_operations xi2c_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xi2c_reg_value_read,
-	.write = xi2c_reg_value_write,
+	.read_iter =  xi2c_reg_value_read_iter,
+	.write_iter = xi2c_reg_value_write_iter,
 };
 
 void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 328/437] drivers/net/ethernet/marvell/octeontx2: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (326 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 327/437] drivers/net/ethernet/amd-xgbe: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 329/437] drivers/net/ethernet/mellanox/mlx5/core: " Jens Axboe
                   ` (109 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../marvell/octeontx2/af/rvu_debugfs.c        | 159 ++++++++----------
 1 file changed, 73 insertions(+), 86 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 2500f5ba4f5a..be3b071743f5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -209,8 +209,8 @@ static int rvu_dbg_open_##name(struct inode *inode, struct file *file) \
 static const struct file_operations rvu_dbg_##name##_fops = { \
 	.owner		= THIS_MODULE, \
 	.open		= rvu_dbg_open_##name, \
-	.read		= seq_read, \
-	.write		= rvu_dbg_##write_op, \
+	.read_iter	= seq_read_iter, \
+	.write_iter	= rvu_dbg_##write_op, \
 	.llseek		= seq_lseek, \
 	.release	= single_release, \
 }
@@ -219,8 +219,8 @@ static const struct file_operations rvu_dbg_##name##_fops = { \
 static const struct file_operations rvu_dbg_##name##_fops = { \
 	.owner = THIS_MODULE, \
 	.open = simple_open, \
-	.read = rvu_dbg_##read_op, \
-	.write = rvu_dbg_##write_op \
+	.read_iter = rvu_dbg_##read_op, \
+	.write_iter = rvu_dbg_##write_op \
 }
 
 static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf);
@@ -572,11 +572,10 @@ static void rvu_dbg_mcs_init(struct rvu *rvu)
 
 #define LMT_MAPTBL_ENTRY_SIZE 16
 /* Dump LMTST map table */
-static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
-					       char __user *buffer,
-					       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_lmtst_map_table_display(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct rvu *rvu = filp->private_data;
+	struct rvu *rvu = iocb->ki_filp->private_data;
 	u64 lmt_addr, val, tbl_base;
 	int pf, vf, num_vfs, hw_vfs;
 	void __iomem *lmt_map_base;
@@ -585,9 +584,10 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
 	int index = 0;
 	char *buf;
 	int ret;
+	size_t count = iov_iter_count(to);
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
@@ -649,15 +649,15 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
 	off +=	scnprintf(&buf[off], buf_size - 1 - off, "\n");
 
 	ret = min(off, count);
-	if (copy_to_user(buffer, buf, ret))
-		ret = -EFAULT;
+	if (!copy_to_iter_full(buf, ret, to))
+		return -EFAULT;
 	kfree(buf);
 
 	iounmap(lmt_map_base);
 	if (ret < 0)
 		return ret;
 
-	*ppos = ret;
+	iocb->ki_pos = ret;
 	return ret;
 }
 
@@ -731,22 +731,21 @@ static int get_max_column_width(struct rvu *rvu)
 }
 
 /* Dumps current provisioning status of all RVU block LFs */
-static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
-					  char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_rsrc_attach_status(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	int index, off = 0, flag = 0, len = 0, i = 0;
-	struct rvu *rvu = filp->private_data;
-	int bytes_not_copied = 0;
+	struct rvu *rvu = iocb->ki_filp->private_data;
 	struct rvu_block block;
 	int pf, vf, pcifunc;
 	int buf_size = 2048;
 	int lf_str_size;
 	char *lfs;
 	char *buf;
+	bool ret;
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
@@ -771,12 +770,13 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 		}
 
 	off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
-	bytes_not_copied = copy_to_user(buffer + (i * off), buf, off);
-	if (bytes_not_copied)
+	iov_iter_advance(to, i * off);
+	ret = !copy_to_iter_full(buf, off, to);
+	if (ret)
 		goto out;
 
 	i++;
-	*ppos += off;
+	iocb->ki_pos += off;
 	for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
 		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
 			off = 0;
@@ -813,14 +813,13 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 			if (flag) {
 				off +=	scnprintf(&buf[off],
 						  buf_size - 1 - off, "\n");
-				bytes_not_copied = copy_to_user(buffer +
-								(i * off),
-								buf, off);
-				if (bytes_not_copied)
+				iov_iter_advance(to, i * off);
+				ret = !copy_to_iter_full(buf, off, to);
+				if (ret)
 					goto out;
 
 				i++;
-				*ppos += off;
+				iocb->ki_pos += off;
 			}
 		}
 	}
@@ -828,10 +827,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 out:
 	kfree(lfs);
 	kfree(buf);
-	if (bytes_not_copied)
+	if (!ret)
 		return -EFAULT;
 
-	return *ppos;
+	return iocb->ki_pos;
 }
 
 RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL);
@@ -986,23 +985,26 @@ static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused,
 	return 0;
 }
 
-static ssize_t rvu_dbg_qsize_write(struct file *filp,
-				   const char __user *buffer, size_t count,
-				   loff_t *ppos, int blktype)
+static ssize_t rvu_dbg_qsize_write(struct kiocb *iocb, struct iov_iter *from,
+				   int blktype)
 {
 	char *blk_string = (blktype == BLKTYPE_NPA) ? "npa" : "nix";
-	struct seq_file *seqfile = filp->private_data;
+	struct seq_file *seqfile = iocb->ki_filp->private_data;
 	char *cmd_buf, *cmd_buf_tmp, *subtoken;
 	struct rvu *rvu = seqfile->private;
 	struct dentry *current_dir;
 	int blkaddr;
 	u16 pcifunc;
 	int ret, lf;
+	size_t count = iov_iter_count(from);
 
-	cmd_buf = memdup_user(buffer, count + 1);
-	if (IS_ERR(cmd_buf))
+	cmd_buf = kmalloc(count + 1, GFP_KERNEL);
+	if (!cmd_buf)
 		return -ENOMEM;
 
+	if (!copy_from_iter_full(cmd_buf, count, from))
+		return -EFAULT;
+
 	cmd_buf[count] = '\0';
 
 	cmd_buf_tmp = strchr(cmd_buf, '\n');
@@ -1025,7 +1027,7 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
 	if (blktype == BLKTYPE_NPA) {
 		blkaddr = BLKADDR_NPA;
 	} else {
-		current_dir = filp->f_path.dentry->d_parent;
+		current_dir = iocb->ki_filp->f_path.dentry->d_parent;
 		blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
 				   BLKADDR_NIX1 : BLKADDR_NIX0);
 	}
@@ -1044,12 +1046,10 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_npa_qsize_write(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_qsize_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	return rvu_dbg_qsize_write(filp, buffer, count, ppos,
-					    BLKTYPE_NPA);
+	return rvu_dbg_qsize_write(iocb, from, BLKTYPE_NPA);
 }
 
 static int rvu_dbg_npa_qsize_display(struct seq_file *filp, void *unused)
@@ -1292,16 +1292,14 @@ static int write_npa_ctx(struct rvu *rvu, bool all,
 }
 
 static int parse_cmd_buffer_ctx(char *cmd_buf, size_t *count,
-				const char __user *buffer, int *npalf,
+				struct iov_iter *from, int *npalf,
 				int *id, bool *all)
 {
-	int bytes_not_copied;
 	char *cmd_buf_tmp;
 	char *subtoken;
 	int ret;
 
-	bytes_not_copied = copy_from_user(cmd_buf, buffer, *count);
-	if (bytes_not_copied)
+	if (!copy_from_iter_full(cmd_buf, *count, from))
 		return -EFAULT;
 
 	cmd_buf[*count] = '\0';
@@ -1329,24 +1327,25 @@ static int parse_cmd_buffer_ctx(char *cmd_buf, size_t *count,
 	return ret;
 }
 
-static ssize_t rvu_dbg_npa_ctx_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos, int ctype)
+static ssize_t rvu_dbg_npa_ctx_write(struct kiocb *iocb,
+				     struct iov_iter *from,
+				     int ctype)
 {
 	char *cmd_buf, *ctype_string = (ctype == NPA_AQ_CTYPE_AURA) ?
 					"aura" : "pool";
-	struct seq_file *seqfp = filp->private_data;
+	struct seq_file *seqfp = iocb->ki_filp->private_data;
 	struct rvu *rvu = seqfp->private;
 	int npalf, id = 0, ret;
 	bool all = false;
+	size_t count = iov_iter_count(from);
 
-	if ((*ppos != 0) || !count)
+	if (iocb->ki_pos != 0 || !count)
 		return -EINVAL;
 
 	cmd_buf = kzalloc(count + 1, GFP_KERNEL);
 	if (!cmd_buf)
 		return count;
-	ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
+	ret = parse_cmd_buffer_ctx(cmd_buf, &count, from,
 				   &npalf, &id, &all);
 	if (ret < 0) {
 		dev_info(rvu->dev,
@@ -1361,12 +1360,10 @@ static ssize_t rvu_dbg_npa_ctx_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_npa_aura_ctx_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_aura_ctx_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
-				     NPA_AQ_CTYPE_AURA);
+	return rvu_dbg_npa_ctx_write(iocb, from, NPA_AQ_CTYPE_AURA);
 }
 
 static int rvu_dbg_npa_aura_ctx_display(struct seq_file *filp, void *unused)
@@ -1376,12 +1373,10 @@ static int rvu_dbg_npa_aura_ctx_display(struct seq_file *filp, void *unused)
 
 RVU_DEBUG_SEQ_FOPS(npa_aura_ctx, npa_aura_ctx_display, npa_aura_ctx_write);
 
-static ssize_t rvu_dbg_npa_pool_ctx_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_pool_ctx_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
-				     NPA_AQ_CTYPE_POOL);
+	return rvu_dbg_npa_ctx_write(iocb, from, NPA_AQ_CTYPE_POOL);
 }
 
 static int rvu_dbg_npa_pool_ctx_display(struct seq_file *filp, void *unused)
@@ -2021,19 +2016,19 @@ static int write_nix_queue_ctx(struct rvu *rvu, bool all, int nixlf,
 	return 0;
 }
 
-static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
-					   const char __user *buffer,
-					   size_t count, loff_t *ppos,
+static ssize_t rvu_dbg_nix_queue_ctx_write(struct kiocb *iocb,
+					   struct iov_iter *from,
 					   int ctype)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct nix_hw *nix_hw = m->private;
 	struct rvu *rvu = nix_hw->rvu;
 	char *cmd_buf, *ctype_string;
 	int nixlf, id = 0, ret;
 	bool all = false;
+	size_t count = iov_iter_count(from);
 
-	if ((*ppos != 0) || !count)
+	if (iocb->ki_pos != 0 || !count)
 		return -EINVAL;
 
 	switch (ctype) {
@@ -2055,7 +2050,7 @@ static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
 	if (!cmd_buf)
 		return count;
 
-	ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
+	ret = parse_cmd_buffer_ctx(cmd_buf, &count, from,
 				   &nixlf, &id, &all);
 	if (ret < 0) {
 		dev_info(rvu->dev,
@@ -2071,12 +2066,10 @@ static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_nix_sq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_sq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_SQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_SQ);
 }
 
 static int rvu_dbg_nix_sq_ctx_display(struct seq_file *filp, void *unused)
@@ -2086,12 +2079,10 @@ static int rvu_dbg_nix_sq_ctx_display(struct seq_file *filp, void *unused)
 
 RVU_DEBUG_SEQ_FOPS(nix_sq_ctx, nix_sq_ctx_display, nix_sq_ctx_write);
 
-static ssize_t rvu_dbg_nix_rq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_rq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_RQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_RQ);
 }
 
 static int rvu_dbg_nix_rq_ctx_display(struct seq_file *filp, void  *unused)
@@ -2101,12 +2092,10 @@ static int rvu_dbg_nix_rq_ctx_display(struct seq_file *filp, void  *unused)
 
 RVU_DEBUG_SEQ_FOPS(nix_rq_ctx, nix_rq_ctx_display, nix_rq_ctx_write);
 
-static ssize_t rvu_dbg_nix_cq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_cq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_CQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_CQ);
 }
 
 static int rvu_dbg_nix_cq_ctx_display(struct seq_file *filp, void *unused)
@@ -2153,12 +2142,10 @@ static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf)
 				     "sq");
 }
 
-static ssize_t rvu_dbg_nix_qsize_write(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_qsize_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	return rvu_dbg_qsize_write(filp, buffer, count, ppos,
-				   BLKTYPE_NIX);
+	return rvu_dbg_qsize_write(iocb, from, BLKTYPE_NIX);
 }
 
 static int rvu_dbg_nix_qsize_display(struct seq_file *filp, void *unused)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 329/437] drivers/net/ethernet/mellanox/mlx5/core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (327 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 328/437] drivers/net/ethernet/marvell/octeontx2: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 330/437] x86/kernel: " Jens Axboe
                   ` (108 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bui Quang Minh, Jens Axboe

From: Bui Quang Minh <minhquangbui99@gmail.com>

Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 78 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/debugfs.c | 49 ++++++------
 .../net/ethernet/mellanox/mlx5/core/lib/sd.c  | 13 ++--
 3 files changed, 69 insertions(+), 71 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 4957412ff1f6..fecd1553fac5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1246,13 +1246,13 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
 	return err ? : status;
 }
 
-static ssize_t dbg_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *pos)
+static ssize_t dbg_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char lbuf[3];
 	int err;
+	size_t count = iov_iter_count(from);
 
 	if (!dbg->in_msg || !dbg->out_msg)
 		return -ENOMEM;
@@ -1260,7 +1260,7 @@ static ssize_t dbg_write(struct file *filp, const char __user *buf,
 	if (count < sizeof(lbuf) - 1)
 		return -EINVAL;
 
-	if (copy_from_user(lbuf, buf, sizeof(lbuf) - 1))
+	if (!copy_from_iter_full(lbuf, sizeof(lbuf) - 1, from))
 		return -EFAULT;
 
 	lbuf[sizeof(lbuf) - 1] = 0;
@@ -1274,9 +1274,9 @@ static ssize_t dbg_write(struct file *filp, const char __user *buf,
 }
 
 static const struct file_operations fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= dbg_write,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= dbg_write_iter,
 };
 
 static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size,
@@ -1435,54 +1435,56 @@ static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
 	kfree(msg);
 }
 
-static ssize_t data_write(struct file *filp, const char __user *buf,
-			  size_t count, loff_t *pos)
+static ssize_t data_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	void *ptr;
+	size_t count = iov_iter_count(from);
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
 	kfree(dbg->in_msg);
 	dbg->in_msg = NULL;
 	dbg->inlen = 0;
-	ptr = memdup_user(buf, count);
-	if (IS_ERR(ptr))
-		return PTR_ERR(ptr);
+	ptr = kmalloc(count, GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	if (!copy_from_iter_full(ptr, count, from))
+		return -EFAULT;
+
 	dbg->in_msg = ptr;
 	dbg->inlen = count;
 
-	*pos = count;
+	iocb->ki_pos = count;
 
 	return count;
 }
 
-static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
-			 loff_t *pos)
+static ssize_t data_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 
 	if (!dbg->out_msg)
 		return -ENOMEM;
 
-	return simple_read_from_buffer(buf, count, pos, dbg->out_msg,
-				       dbg->outlen);
+	return simple_copy_to_iter(dbg->out_msg, &iocb->ki_pos,
+				   dbg->outlen, to);
 }
 
 static const struct file_operations dfops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= data_write,
-	.read	= data_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= data_write_iter,
+	.read_iter	= data_read_iter,
 };
 
-static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count,
-			   loff_t *pos)
+static ssize_t outlen_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char outlen[8];
 	int err;
@@ -1491,27 +1493,27 @@ static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(buf, count, pos, outlen, err);
+	return simple_copy_to_iter(outlen, &iocb->ki_pos, err, to);
 }
 
-static ssize_t outlen_write(struct file *filp, const char __user *buf,
-			    size_t count, loff_t *pos)
+static ssize_t outlen_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char outlen_str[8] = {0};
 	int outlen;
 	void *ptr;
 	int err;
+	size_t count = iov_iter_count(from);
 
-	if (*pos != 0 || count > 6)
+	if (iocb->ki_pos != 0 || count > 6)
 		return -EINVAL;
 
 	kfree(dbg->out_msg);
 	dbg->out_msg = NULL;
 	dbg->outlen = 0;
 
-	if (copy_from_user(outlen_str, buf, count))
+	if (!copy_from_iter_full(outlen_str, count, from))
 		return -EFAULT;
 
 	err = sscanf(outlen_str, "%d", &outlen);
@@ -1525,16 +1527,16 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
 	dbg->out_msg = ptr;
 	dbg->outlen = outlen;
 
-	*pos = count;
+	iocb->ki_pos = count;
 
 	return count;
 }
 
 static const struct file_operations olfops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= outlen_write,
-	.read	= outlen_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= outlen_write_iter,
+	.read_iter	= outlen_read_iter,
 };
 
 static void set_wqname(struct mlx5_core_dev *dev)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
index 09652dc89115..090b5b5d0acd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
@@ -126,48 +126,46 @@ void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev)
 	debugfs_remove_recursive(dev->priv.dbg.eq_debugfs);
 }
 
-static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
-			    loff_t *pos)
+static ssize_t average_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mlx5_cmd_stats *stats;
 	u64 field = 0;
 	int ret;
 	char tbuf[22];
 
-	stats = filp->private_data;
+	stats = iocb->ki_filp->private_data;
 	spin_lock_irq(&stats->lock);
 	if (stats->n)
 		field = div64_u64(stats->sum, stats->n);
 	spin_unlock_irq(&stats->lock);
 	ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 }
 
-static ssize_t average_write(struct file *filp, const char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t average_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct mlx5_cmd_stats *stats;
+	size_t count = iov_iter_count(from);
 
-	stats = filp->private_data;
+	stats = iocb->ki_filp->private_data;
 	spin_lock_irq(&stats->lock);
 	stats->sum = 0;
 	stats->n = 0;
 	spin_unlock_irq(&stats->lock);
 
-	*pos += count;
+	iocb->ki_pos += count;
 
 	return count;
 }
 
 static const struct file_operations stats_fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.read	= average_read,
-	.write	= average_write,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.read_iter	= average_read_iter,
+	.write_iter	= average_write_iter,
 };
 
-static ssize_t slots_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t slots_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mlx5_cmd *cmd;
 	char tbuf[6];
@@ -175,17 +173,17 @@ static ssize_t slots_read(struct file *filp, char __user *buf, size_t count,
 	int field;
 	int ret;
 
-	cmd = filp->private_data;
+	cmd = iocb->ki_filp->private_data;
 	weight = bitmap_weight(&cmd->vars.bitmask, cmd->vars.max_reg_cmds);
 	field = cmd->vars.max_reg_cmds - weight;
 	ret = snprintf(tbuf, sizeof(tbuf), "%d\n", field);
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations slots_fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.read	= slots_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.read_iter	= slots_read_iter,
 };
 
 static struct mlx5_cmd_stats *
@@ -445,8 +443,7 @@ static u64 cq_read_field(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
 	return param;
 }
 
-static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count,
-			loff_t *pos)
+static ssize_t dbg_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mlx5_field_desc *desc;
 	struct mlx5_rsc_debug *d;
@@ -455,7 +452,7 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count,
 	u64 field;
 	int ret;
 
-	desc = filp->private_data;
+	desc = iocb->ki_filp->private_data;
 	d = (void *)(desc - desc->i) - sizeof(*d);
 	switch (d->type) {
 	case MLX5_DBG_RSC_QP:
@@ -480,13 +477,13 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count,
 	else
 		ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field);
 
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.read	= dbg_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.read_iter	= dbg_read_iter,
 };
 
 static int add_res_tree(struct mlx5_core_dev *dev, enum dbg_rsc_type type,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
index 5b28084e8a03..09429b069c20 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c
@@ -393,24 +393,23 @@ static void sd_print_group(struct mlx5_core_dev *primary)
 			MLX5_CAP_GEN(pos, vhca_id));
 }
 
-static ssize_t dev_read(struct file *filp, char __user *buf, size_t count,
-			loff_t *pos)
+static ssize_t dev_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mlx5_core_dev *dev;
 	char tbuf[32];
 	int ret;
 
-	dev = filp->private_data;
+	dev = iocb->ki_filp->private_data;
 	ret = snprintf(tbuf, sizeof(tbuf), "%s vhca %#x\n", pci_name(dev->pdev),
 		       MLX5_CAP_GEN(dev, vhca_id));
 
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations dev_fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.read	= dev_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.read_iter	= dev_read_iter,
 };
 
 int mlx5_sd_init(struct mlx5_core_dev *dev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 330/437] x86/kernel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (328 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 329/437] drivers/net/ethernet/mellanox/mlx5/core: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 331/437] x86/kvm: " Jens Axboe
                   ` (107 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/x86/kernel/apm_32.c                  | 10 +++---
 arch/x86/kernel/callthunks.c              |  2 +-
 arch/x86/kernel/cpu/debugfs.c             |  4 +--
 arch/x86/kernel/cpu/mce/dev-mcelog.c      | 38 +++++++++++------------
 arch/x86/kernel/cpu/mce/inject.c          | 27 +++++++---------
 arch/x86/kernel/cpu/mce/severity.c        | 11 +++----
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 18 +++++------
 arch/x86/kernel/cpuid.c                   | 16 +++++-----
 arch/x86/kernel/kdebugfs.c                | 14 ++++-----
 arch/x86/kernel/msr.c                     | 28 +++++++----------
 arch/x86/kernel/tboot.c                   | 17 +++++-----
 11 files changed, 86 insertions(+), 99 deletions(-)

diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index b37ab1095707..bc4c8db6b52f 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1431,13 +1431,14 @@ static int check_apm_user(struct apm_user *as, const char *func)
 	return 0;
 }
 
-static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t do_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct apm_user *as;
 	int i;
 	apm_event_t event;
 
-	as = fp->private_data;
+	as = iocb->ki_filp->private_data;
 	if (check_apm_user(as, "read"))
 		return -EIO;
 	if ((int)count < sizeof(apm_event_t))
@@ -1448,7 +1449,7 @@ static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *
 	i = count;
 	while ((i >= sizeof(event)) && !queue_empty(as)) {
 		event = get_queued_event(as);
-		if (copy_to_user(buf, &event, sizeof(event))) {
+		if (!copy_to_iter_full(&event, sizeof(event), to)) {
 			if (i < count)
 				break;
 			return -EFAULT;
@@ -1464,7 +1465,6 @@ static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *
 			as->standbys_read++;
 			break;
 		}
-		buf += sizeof(event);
 		i -= sizeof(event);
 	}
 	if (i < count)
@@ -1876,7 +1876,7 @@ __setup("apm=", apm_setup);
 
 static const struct file_operations apm_bios_fops = {
 	.owner		= THIS_MODULE,
-	.read		= do_read,
+	.read_iter	= do_read,
 	.poll		= do_poll,
 	.unlocked_ioctl	= do_ioctl,
 	.open		= do_open,
diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index e92ff0c11db8..bec11795ff8e 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -375,7 +375,7 @@ static int callthunks_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_ops = {
 	.open		= callthunks_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/arch/x86/kernel/cpu/debugfs.c b/arch/x86/kernel/cpu/debugfs.c
index 3baf3e435834..1f29b224c8c0 100644
--- a/arch/x86/kernel/cpu/debugfs.c
+++ b/arch/x86/kernel/cpu/debugfs.c
@@ -42,7 +42,7 @@ static int cpu_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_cpu_ops = {
 	.open		= cpu_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -76,7 +76,7 @@ static int dom_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_dom_ops = {
 	.open		= dom_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c
index a05ac0716ecf..1d5d1b26b85b 100644
--- a/arch/x86/kernel/cpu/mce/dev-mcelog.c
+++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c
@@ -159,7 +159,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
 static int mce_apei_read_done;
 
 /* Collect MCE record of previous boot in persistent storage via APEI ERST. */
-static int __mce_read_apei(char __user **ubuf, size_t usize)
+static int __mce_read_apei(struct iov_iter *to, size_t usize)
 {
 	int rc;
 	u64 record_id;
@@ -181,7 +181,7 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
 		return rc;
 	}
 	rc = -EFAULT;
-	if (copy_to_user(*ubuf, &m, sizeof(struct mce)))
+	if (!copy_to_iter_full(&m, sizeof(struct mce), to))
 		return rc;
 	/*
 	 * In fact, we should have cleared the record after that has
@@ -194,51 +194,49 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
 		mce_apei_read_done = 1;
 		return rc;
 	}
-	*ubuf += sizeof(struct mce);
 
 	return 0;
 }
 
-static ssize_t mce_chrdev_read(struct file *filp, char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t mce_chrdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *buf = ubuf;
+	size_t copied, usize = iov_iter_count(to);
 	unsigned next;
 	int i, err;
 
 	mutex_lock(&mce_chrdev_read_mutex);
 
 	if (!mce_apei_read_done) {
-		err = __mce_read_apei(&buf, usize);
-		if (err || buf != ubuf)
+		err = __mce_read_apei(to, usize);
+		if (err)
 			goto out;
 	}
 
 	/* Only supports full reads right now */
 	err = -EINVAL;
-	if (*off != 0 || usize < mcelog->len * sizeof(struct mce))
+	if (iocb->ki_pos != 0 || usize < mcelog->len * sizeof(struct mce))
 		goto out;
 
 	next = mcelog->next;
 	err = 0;
+	copied = 0;
 
 	for (i = 0; i < next; i++) {
 		struct mce *m = &mcelog->entry[i];
 
-		err |= copy_to_user(buf, m, sizeof(*m));
-		buf += sizeof(*m);
+		if (copy_to_iter_full(m, sizeof(*m), to))
+			copied += sizeof(*m);
+		else
+			err = -EFAULT;
 	}
 
 	memset(mcelog->entry, 0, next * sizeof(struct mce));
 	mcelog->next = 0;
 
-	if (err)
-		err = -EFAULT;
-
 out:
 	mutex_unlock(&mce_chrdev_read_mutex);
 
-	return err ? err : buf - ubuf;
+	return err ? err : copied;
 }
 
 static __poll_t mce_chrdev_poll(struct file *file, poll_table *wait)
@@ -290,9 +288,9 @@ void mce_unregister_injector_chain(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(mce_unregister_injector_chain);
 
-static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t mce_chrdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t usize = iov_iter_count(from);
 	struct mce m;
 
 	if (!capable(CAP_SYS_ADMIN))
@@ -306,7 +304,7 @@ static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
 
 	if ((unsigned long)usize > sizeof(struct mce))
 		usize = sizeof(struct mce);
-	if (copy_from_user(&m, ubuf, usize))
+	if (!copy_from_iter_full(&m, usize, from))
 		return -EFAULT;
 
 	if (m.extcpu >= num_possible_cpus() || !cpu_online(m.extcpu))
@@ -326,8 +324,8 @@ static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
 static const struct file_operations mce_chrdev_ops = {
 	.open			= mce_chrdev_open,
 	.release		= mce_chrdev_release,
-	.read			= mce_chrdev_read,
-	.write			= mce_chrdev_write,
+	.read_iter		= mce_chrdev_read,
+	.write_iter		= mce_chrdev_write,
 	.poll			= mce_chrdev_poll,
 	.unlocked_ioctl		= mce_chrdev_ioctl,
 	.compat_ioctl		= compat_ptr_ioctl,
diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c
index 94953d749475..5d545f331d0d 100644
--- a/arch/x86/kernel/cpu/mce/inject.c
+++ b/arch/x86/kernel/cpu/mce/inject.c
@@ -349,27 +349,26 @@ static int __set_inj(const char *buf)
 	return -EINVAL;
 }
 
-static ssize_t flags_read(struct file *filp, char __user *ubuf,
-			  size_t cnt, loff_t *ppos)
+static ssize_t flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[MAX_FLAG_OPT_SIZE];
 	int n;
 
 	n = sprintf(buf, "%s\n", flags_options[inj_type]);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t flags_write(struct file *filp, const char __user *ubuf,
-			   size_t cnt, loff_t *ppos)
+static ssize_t flags_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[MAX_FLAG_OPT_SIZE], *__buf;
+	size_t cnt = iov_iter_count(from);
 	int err;
 
 	if (!cnt || cnt > MAX_FLAG_OPT_SIZE)
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt - 1] = 0;
@@ -383,14 +382,14 @@ static ssize_t flags_write(struct file *filp, const char __user *ubuf,
 		return err;
 	}
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
 static const struct file_operations flags_fops = {
-	.read           = flags_read,
-	.write          = flags_write,
+	.read_iter      = flags_read,
+	.write_iter     = flags_write,
 	.llseek         = generic_file_llseek,
 };
 
@@ -679,16 +678,14 @@ static const char readme_msg[] =
 "ipid:\t IPID (AMD-specific)\n"
 "\n";
 
-static ssize_t
-inj_readme_read(struct file *filp, char __user *ubuf,
-		       size_t cnt, loff_t *ppos)
+static ssize_t inj_readme_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(ubuf, cnt, ppos,
-					readme_msg, strlen(readme_msg));
+	return simple_copy_to_iter(readme_msg, &iocb->ki_pos,
+					strlen(readme_msg), to);
 }
 
 static const struct file_operations readme_fops = {
-	.read		= inj_readme_read,
+	.read_iter	= inj_readme_read,
 };
 
 static struct dfs_node {
diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c
index c4477162c07d..eb648f415d55 100644
--- a/arch/x86/kernel/cpu/mce/severity.c
+++ b/arch/x86/kernel/cpu/mce/severity.c
@@ -447,21 +447,20 @@ static int severities_coverage_open(struct inode *inode, struct file *file)
 	return seq_open(file, &severities_seq_ops);
 }
 
-static ssize_t severities_coverage_write(struct file *file,
-					 const char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t severities_coverage_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 	int i;
 	for (i = 0; i < ARRAY_SIZE(severities); i++)
 		severities[i].covered = 0;
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations severities_coverage_fops = {
 	.open		= severities_coverage_open,
 	.release	= seq_release,
-	.read		= seq_read,
-	.write		= severities_coverage_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= severities_coverage_write,
 	.llseek		= seq_lseek,
 };
 
diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index 884b88e25141..e10f1e9513ec 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -1244,18 +1244,18 @@ static int pseudo_lock_measure_cycles(struct rdtgroup *rdtgrp, int sel)
 	return ret;
 }
 
-static ssize_t pseudo_lock_measure_trigger(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t pseudo_lock_measure_trigger(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct rdtgroup *rdtgrp = file->private_data;
+	struct rdtgroup *rdtgrp = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t buf_size;
 	char buf[32];
 	int ret;
 	int sel;
 
 	buf_size = min(count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1263,20 +1263,20 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
 	if (ret == 0) {
 		if (sel != 1 && sel != 2 && sel != 3)
 			return -EINVAL;
-		ret = debugfs_file_get(file->f_path.dentry);
+		ret = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 		if (ret)
 			return ret;
 		ret = pseudo_lock_measure_cycles(rdtgrp, sel);
 		if (ret == 0)
 			ret = count;
-		debugfs_file_put(file->f_path.dentry);
+		debugfs_file_put(iocb->ki_filp->f_path.dentry);
 	}
 
 	return ret;
 }
 
 static const struct file_operations pseudo_measure_fops = {
-	.write = pseudo_lock_measure_trigger,
+	.write_iter = pseudo_lock_measure_trigger,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -1570,8 +1570,6 @@ static int pseudo_lock_dev_mmap(struct file *filp, struct vm_area_struct *vma)
 static const struct file_operations pseudo_lock_dev_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		NULL,
-	.write =	NULL,
 	.open =		pseudo_lock_dev_open,
 	.release =	pseudo_lock_dev_release,
 	.mmap =		pseudo_lock_dev_mmap,
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index dae436253de4..f33fc680cc7d 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -58,13 +58,12 @@ static void cpuid_smp_cpuid(void *cmd_block)
 	complete(&cmd->done);
 }
 
-static ssize_t cpuid_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t cpuid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *tmp = buf;
 	struct cpuid_regs_done cmd;
-	int cpu = iminor(file_inode(file));
-	u64 pos = *ppos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
+	size_t count = iov_iter_count(to);
+	u64 pos = iocb->ki_pos;
 	ssize_t bytes = 0;
 	int err = 0;
 
@@ -84,13 +83,12 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
 		if (err)
 			break;
 		wait_for_completion(&cmd.done);
-		if (copy_to_user(tmp, &cmd.regs, 16)) {
+		if (!copy_to_iter_full(&cmd.regs, 16, to)) {
 			err = -EFAULT;
 			break;
 		}
-		tmp += 16;
 		bytes += 16;
-		*ppos = ++pos;
+		iocb->ki_pos = ++pos;
 		reinit_completion(&cmd.done);
 	}
 
@@ -119,7 +117,7 @@ static int cpuid_open(struct inode *inode, struct file *file)
 static const struct file_operations cpuid_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_seek_end_llseek,
-	.read = cpuid_read,
+	.read_iter = cpuid_read,
 	.open = cpuid_open,
 };
 
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index e2e89bebcbc3..4b4db90ffab2 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -26,12 +26,12 @@ struct setup_data_node {
 	u32 len;
 };
 
-static ssize_t setup_data_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t setup_data_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct setup_data_node *node = file->private_data;
+	struct setup_data_node *node = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	unsigned long remain;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 	void *p;
 	u64 pa;
 
@@ -54,20 +54,20 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf,
 	if (!p)
 		return -ENOMEM;
 
-	remain = copy_to_user(user_buf, p, count);
+	remain = !copy_to_iter_full(p, count, to);
 
 	memunmap(p);
 
 	if (remain)
 		return -EFAULT;
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 
 	return count;
 }
 
 static const struct file_operations fops_setup_data = {
-	.read		= setup_data_read,
+	.read_iter	= setup_data_read,
 	.open		= simple_open,
 	.llseek		= default_llseek,
 };
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index e17c16c54a37..80cd3d83fb75 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -49,13 +49,12 @@ enum allow_write_msrs {
 
 static enum allow_write_msrs allow_writes = MSR_WRITES_DEFAULT;
 
-static ssize_t msr_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t msr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	u32 __user *tmp = (u32 __user *) buf;
 	u32 data[2];
-	u32 reg = *ppos;
-	int cpu = iminor(file_inode(file));
+	u32 reg = iocb->ki_pos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
+	size_t count = iov_iter_count(to);
 	int err = 0;
 	ssize_t bytes = 0;
 
@@ -66,11 +65,10 @@ static ssize_t msr_read(struct file *file, char __user *buf,
 		err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
 		if (err)
 			break;
-		if (copy_to_user(tmp, &data, 8)) {
+		if (!copy_to_iter_full(&data, 8, to)) {
 			err = -EFAULT;
 			break;
 		}
-		tmp += 2;
 		bytes += 8;
 	}
 
@@ -105,13 +103,12 @@ static int filter_write(u32 reg)
 	return 0;
 }
 
-static ssize_t msr_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t msr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const u32 __user *tmp = (const u32 __user *)buf;
+	size_t count = iov_iter_count(from);
 	u32 data[2];
-	u32 reg = *ppos;
-	int cpu = iminor(file_inode(file));
+	u32 reg = iocb->ki_pos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
 	int err = 0;
 	ssize_t bytes = 0;
 
@@ -127,7 +124,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 		return -EINVAL;	/* Invalid chunk size */
 
 	for (; count; count -= 8) {
-		if (copy_from_user(&data, tmp, 8)) {
+		if (!copy_from_iter_full(&data, 8, from)) {
 			err = -EFAULT;
 			break;
 		}
@@ -138,7 +135,6 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 		if (err)
 			break;
 
-		tmp += 2;
 		bytes += 8;
 	}
 
@@ -227,8 +223,8 @@ static int msr_open(struct inode *inode, struct file *file)
 static const struct file_operations msr_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_seek_end_llseek,
-	.read = msr_read,
-	.write = msr_write,
+	.read_iter = msr_read,
+	.write_iter = msr_write,
 	.open = msr_open,
 	.unlocked_ioctl = msr_ioctl,
 	.compat_ioctl = msr_ioctl,
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index 4c1bcb6053fc..59020897c7e6 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -356,8 +356,9 @@ static int tboot_dying_cpu(unsigned int cpu)
 
 static uint8_t tboot_log_uuid[16] = TBOOT_LOG_UUID;
 
-static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t tboot_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	void __iomem *log_base;
 	u8 log_uuid[16];
 	u32 max_size;
@@ -373,13 +374,13 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 		goto err_iounmap;
 
 	max_size = readl(log_base + LOG_MAX_SIZE_OFF);
-	if (*ppos >= max_size) {
+	if (iocb->ki_pos >= max_size) {
 		ret = 0;
 		goto err_iounmap;
 	}
 
-	if (*ppos + count > max_size)
-		count = max_size - *ppos;
+	if (iocb->ki_pos + count > max_size)
+		count = max_size - iocb->ki_pos;
 
 	kbuf = kmalloc(count, GFP_KERNEL);
 	if (!kbuf) {
@@ -387,11 +388,11 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 		goto err_iounmap;
 	}
 
-	memcpy_fromio(kbuf, log_base + LOG_BUF_OFF + *ppos, count);
-	if (copy_to_user(user_buf, kbuf, count))
+	memcpy_fromio(kbuf, log_base + LOG_BUF_OFF + iocb->ki_pos, count);
+	if (!copy_to_iter_full(kbuf, count, to))
 		goto err_kfree;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 
 	ret = count;
 
@@ -405,7 +406,7 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 }
 
 static const struct file_operations tboot_log_fops = {
-	.read	= tboot_log_read,
+	.read_iter	= tboot_log_read,
 	.llseek	= default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 331/437] x86/kvm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (329 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 330/437] x86/kernel: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 332/437] x86/mm: " Jens Axboe
                   ` (106 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/x86/kvm/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c
index 999227fc7c66..552db0812b02 100644
--- a/arch/x86/kvm/debugfs.c
+++ b/arch/x86/kvm/debugfs.c
@@ -184,7 +184,7 @@ static int kvm_mmu_rmaps_stat_release(struct inode *inode, struct file *file)
 static const struct file_operations mmu_rmaps_stat_fops = {
 	.owner		= THIS_MODULE,
 	.open		= kvm_mmu_rmaps_stat_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= kvm_mmu_rmaps_stat_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 332/437] x86/mm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (330 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 331/437] x86/kvm: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 333/437] arch/arm: " Jens Axboe
                   ` (105 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/x86/mm/pat/memtype.c    |  2 +-
 arch/x86/mm/pat/set_memory.c |  2 +-
 arch/x86/mm/pkeys.c          | 15 +++++++--------
 arch/x86/mm/tlb.c            | 15 +++++++--------
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index 36b603d0cdde..46f1d1966f96 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -1194,7 +1194,7 @@ static int memtype_seq_open(struct inode *inode, struct file *file)
 
 static const struct file_operations memtype_fops = {
 	.open    = memtype_seq_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release,
 };
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 80c9037ffadf..ee1888fbd218 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -186,7 +186,7 @@ static int cpastats_open(struct inode *inode, struct file *file)
 
 static const struct file_operations cpastats_fops = {
 	.open		= cpastats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
diff --git a/arch/x86/mm/pkeys.c b/arch/x86/mm/pkeys.c
index 7418c367e328..7f084e4f6bd2 100644
--- a/arch/x86/mm/pkeys.c
+++ b/arch/x86/mm/pkeys.c
@@ -127,25 +127,24 @@ u32 init_pkru_value = PKRU_AD_MASK( 1) | PKRU_AD_MASK( 2) |
 		      PKRU_AD_MASK(13) | PKRU_AD_MASK(14) |
 		      PKRU_AD_MASK(15);
 
-static ssize_t init_pkru_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t init_pkru_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%x\n", init_pkru_value);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t init_pkru_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t init_pkru_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	u32 new_init_pkru;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	/* Make the buffer a valid string that we can not overrun */
@@ -166,8 +165,8 @@ static ssize_t init_pkru_write_file(struct file *file,
 }
 
 static const struct file_operations fops_init_pkru = {
-	.read = init_pkru_read_file,
-	.write = init_pkru_write_file,
+	.read_iter = init_pkru_read_file,
+	.write_iter = init_pkru_write_file,
 	.llseek = default_llseek,
 };
 
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 44ac64f3a047..97edf3026036 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -1303,25 +1303,24 @@ bool nmi_uaccess_okay(void)
 	return true;
 }
 
-static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t tlbflush_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%ld\n", tlb_single_page_flush_ceiling);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t tlbflush_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t tlbflush_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	int ceiling;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1336,8 +1335,8 @@ static ssize_t tlbflush_write_file(struct file *file,
 }
 
 static const struct file_operations fops_tlbflush = {
-	.read = tlbflush_read_file,
-	.write = tlbflush_write_file,
+	.read_iter = tlbflush_read_file,
+	.write_iter = tlbflush_write_file,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 333/437] arch/arm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (331 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 332/437] x86/mm: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 334/437] arch/mips: " Jens Axboe
                   ` (104 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/arm/common/bL_switcher_dummy_if.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/common/bL_switcher_dummy_if.c b/arch/arm/common/bL_switcher_dummy_if.c
index cabc0659b329..f9794c4a6a40 100644
--- a/arch/arm/common/bL_switcher_dummy_if.c
+++ b/arch/arm/common/bL_switcher_dummy_if.c
@@ -15,9 +15,9 @@
 #include <linux/uaccess.h>
 #include <asm/bL_switcher.h>
 
-static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t bL_switcher_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	unsigned char val[3];
 	unsigned int cpu, cluster;
 	int ret;
@@ -27,7 +27,7 @@ static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
 	if (len < 3)
 		return -EINVAL;
 
-	if (copy_from_user(val, buf, 3))
+	if (!copy_from_iter_full(val, 3, fro))
 		return -EFAULT;
 
 	/* format: <cpu#>,<cluster#> */
@@ -44,7 +44,7 @@ static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations bL_switcher_fops = {
-	.write		= bL_switcher_write,
+	.write_iter	= bL_switcher_write,
 	.owner	= THIS_MODULE,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 334/437] arch/mips: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (332 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 333/437] arch/arm: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 335/437] parisc: eisa_eeprom: " Jens Axboe
                   ` (103 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/mips/kernel/rtlx.c   |  6 ++++--
 arch/mips/kernel/vpe.c    | 14 +++++++-------
 arch/mips/mm/sc-debugfs.c | 16 +++++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 18c509c59f33..6e3bf6d4c64b 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -369,6 +369,7 @@ static ssize_t file_read(struct file *file, char __user *buffer, size_t count,
 
 	return rtlx_read(minor, buffer, count);
 }
+FOPS_READ_ITER_HELPER(file_read);
 
 static ssize_t file_write(struct file *file, const char __user *buffer,
 			  size_t count, loff_t *ppos)
@@ -390,13 +391,14 @@ static ssize_t file_write(struct file *file, const char __user *buffer,
 
 	return rtlx_write(minor, buffer, count);
 }
+FOPS_WRITE_ITER_HELPER(file_write);
 
 const struct file_operations rtlx_fops = {
 	.owner =   THIS_MODULE,
 	.open =    file_open,
 	.release = file_release,
-	.write =   file_write,
-	.read =    file_read,
+	.write_iter =   file_write_iter,
+	.read_iter = file_read_iter,
 	.poll =    file_poll,
 	.llseek =  noop_llseek,
 };
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 737d0d4fdcd3..55db91fba7b0 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -834,13 +834,13 @@ static int vpe_release(struct inode *inode, struct file *filp)
 #endif
 }
 
-static ssize_t vpe_write(struct file *file, const char __user *buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t vpe_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t ret = count;
 	struct vpe *v;
 
-	if (iminor(file_inode(file)) != VPE_MODULE_MINOR)
+	if (iminor(file_inode(iocb->ki_filp)) != VPE_MODULE_MINOR)
 		return -ENODEV;
 
 	v = get_vpe(aprp_cpu_index());
@@ -853,19 +853,19 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
 		return -ENOMEM;
 	}
 
-	count -= copy_from_user(v->pbuffer + v->len, buffer, count);
-	if (!count)
+	ret !copy_from_iter_full(v->pbuffer + v->len, count, from);
+	if (!ret)
 		return -EFAULT;
 
 	v->len += count;
-	return ret;
+	return count;
 }
 
 const struct file_operations vpe_fops = {
 	.owner = THIS_MODULE,
 	.open = vpe_open,
 	.release = vpe_release,
-	.write = vpe_write,
+	.write_iter = vpe_write,
 	.llseek = noop_llseek,
 };
 
diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c
index 80ff3947157d..d85e8b95d9b5 100644
--- a/arch/mips/mm/sc-debugfs.c
+++ b/arch/mips/mm/sc-debugfs.c
@@ -10,8 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/init.h>
 
-static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	bool enabled = bc_prefetch_is_enabled();
 	char buf[3];
@@ -20,17 +19,16 @@ static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t sc_prefetch_write(struct file *file,
-				 const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	bool enabled;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enabled);
+	err = kstrtobool_from_iter(from, count, &enabled);
 	if (err)
 		return err;
 
@@ -45,8 +43,8 @@ static ssize_t sc_prefetch_write(struct file *file,
 static const struct file_operations sc_prefetch_fops = {
 	.open = simple_open,
 	.llseek = default_llseek,
-	.read = sc_prefetch_read,
-	.write = sc_prefetch_write,
+	.read_iter = sc_prefetch_read,
+	.write_iter = sc_prefetch_write,
 };
 
 static int __init sc_debugfs_init(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 335/437] parisc: eisa_eeprom: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (333 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 334/437] arch/mips: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 336/437] arch/parisc: " Jens Axboe
                   ` (102 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/parisc/eisa_eeprom.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c
index 443b15422fc1..87066c0cfc1d 100644
--- a/drivers/parisc/eisa_eeprom.c
+++ b/drivers/parisc/eisa_eeprom.c
@@ -22,23 +22,23 @@ static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin)
 	return fixed_size_llseek(file, offset, origin, HPEE_MAX_LENGTH);
 }
 
-static ssize_t eisa_eeprom_read(struct file * file,
-			      char __user *buf, size_t count, loff_t *ppos )
+static ssize_t eisa_eeprom_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	unsigned char *tmp;
 	ssize_t ret;
 	int i;
 	
-	if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH)
+	if (iocb->ki_pos < 0 || iocb->ki_pos >= HPEE_MAX_LENGTH)
 		return 0;
 	
-	count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
+	count = iocb->ki_pos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - iocb->ki_pos;
 	tmp = kmalloc(count, GFP_KERNEL);
 	if (tmp) {
 		for (i = 0; i < count; i++)
 			tmp[i] = readb(eisa_eeprom_addr+(*ppos)++);
 
-		if (copy_to_user (buf, tmp, count))
+		if (!copy_to_iter_full(tmp, count, to))
 			ret = -EFAULT;
 		else
 			ret = count;
@@ -68,7 +68,7 @@ static int eisa_eeprom_release(struct inode *inode, struct file *file)
 static const struct file_operations eisa_eeprom_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	eisa_eeprom_llseek,
-	.read =		eisa_eeprom_read,
+	.read_iter =	eisa_eeprom_read,
 	.open =		eisa_eeprom_open,
 	.release =	eisa_eeprom_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 336/437] arch/parisc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (334 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 335/437] parisc: eisa_eeprom: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 337/437] powerpc/kernel: " Jens Axboe
                   ` (101 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/parisc/kernel/perf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index b0f0816879df..a564c56ebb6f 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -181,7 +181,7 @@ static const uint64_t *bitmask_array;   /* array of bitmasks to use */
 static int perf_config(uint32_t *image_ptr);
 static int perf_release(struct inode *inode, struct file *file);
 static int perf_open(struct inode *inode, struct file *file);
-static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos);
+static ssize_t perf_read(struct kiocb *iocb, struct iov_iter *to);
 static ssize_t perf_write(struct file *file, const char __user *buf,
 	size_t count, loff_t *ppos);
 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
@@ -273,7 +273,7 @@ static int perf_release(struct inode *inode, struct file *file)
 /*
  * Read does nothing for this driver
  */
-static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos)
+static ssize_t perf_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -285,9 +285,9 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t
  * called on the processor that the download should happen
  * on.
  */
-static ssize_t perf_write(struct file *file, const char __user *buf,
-	size_t count, loff_t *ppos)
+static ssize_t perf_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t image_size __maybe_unused;
 	uint32_t image_type;
 	uint32_t interface_type;
@@ -306,7 +306,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf,
 	if (count != sizeof(uint32_t))
 		return -EIO;
 
-	if (copy_from_user(&image_type, buf, sizeof(uint32_t)))
+	if (!copy_from_iter_full(&image_type, sizeof(uint32_t), from))
 		return -EFAULT;
 
 	/* Get the interface type and test type */
@@ -467,8 +467,8 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations perf_fops = {
 	.llseek = no_llseek,
-	.read = perf_read,
-	.write = perf_write,
+	.read_iter = perf_read,
+	.write_iter = perf_write,
 	.unlocked_ioctl = perf_ioctl,
 	.compat_ioctl = perf_ioctl,
 	.open = perf_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 337/437] powerpc/kernel: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (335 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 336/437] arch/parisc: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 338/437] powerpc/kvm: " Jens Axboe
                   ` (100 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/kernel/eeh.c | 58 ++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index ab316e155ea9..35ea1c80e0de 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1588,9 +1588,8 @@ static int proc_eeh_show(struct seq_file *m, void *v)
 #ifdef CONFIG_DEBUG_FS
 
 
-static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static struct pci_dev *eeh_debug_lookup_pdev(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
 	uint32_t domain, bus, dev, fn;
 	struct pci_dev *pdev;
@@ -1598,7 +1597,7 @@ static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
 	int ret;
 
 	memset(buf, 0, sizeof(buf));
-	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf)-1, from);
 	if (!ret)
 		return ERR_PTR(-EFAULT);
 
@@ -1637,17 +1636,16 @@ static int eeh_enable_dbgfs_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
 			 eeh_enable_dbgfs_set, "0x%llx\n");
 
-static ssize_t eeh_force_recover_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_force_recover_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct pci_controller *hose;
 	uint32_t phbid, pe_no;
 	struct eeh_pe *pe;
 	char buf[20];
 	int ret;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf), from);
 	if (!ret)
 		return -EFAULT;
 
@@ -1690,28 +1688,23 @@ static ssize_t eeh_force_recover_write(struct file *filp,
 static const struct file_operations eeh_force_recover_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_force_recover_write,
+	.write_iter = eeh_force_recover_write,
 };
 
-static ssize_t eeh_debugfs_dev_usage(struct file *filp,
-				char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_debugfs_dev_usage(struct kiocb *iocb, struct iov_iter *to)
 {
 	static const char usage[] = "input format: <domain>:<bus>:<dev>.<fn>\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       usage, sizeof(usage) - 1);
+	return simple_copy_to_iter(usage, &iocb->ki_pos, sizeof(usage) - 1, to);
 }
 
-static ssize_t eeh_dev_check_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_dev_check_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct pci_dev *pdev;
 	struct eeh_dev *edev;
 	int ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1728,14 +1721,14 @@ static ssize_t eeh_dev_check_write(struct file *filp,
 
 	pci_dev_put(pdev);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations eeh_dev_check_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_check_write,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_check_write,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
 static int eeh_debugfs_break_device(struct pci_dev *pdev)
@@ -1831,14 +1824,12 @@ static int eeh_debugfs_break_device(struct pci_dev *pdev)
 	return 0;
 }
 
-static ssize_t eeh_dev_break_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_dev_break_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct pci_dev *pdev;
 	int ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1848,25 +1839,24 @@ static ssize_t eeh_dev_break_write(struct file *filp,
 	if (ret < 0)
 		return ret;
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations eeh_dev_break_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_break_write,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_break_write,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
-static ssize_t eeh_dev_can_recover(struct file *filp,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t eeh_dev_can_recover(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct pci_driver *drv;
 	struct pci_dev *pdev;
 	size_t ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1901,8 +1891,8 @@ static ssize_t eeh_dev_can_recover(struct file *filp,
 static const struct file_operations eeh_dev_can_recover_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_can_recover,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_can_recover,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 338/437] powerpc/kvm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (336 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 337/437] powerpc/kernel: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:17 ` [PATCH 339/437] powerpc/spufs: " Jens Axboe
                   ` (99 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/kvm/book3s_64_mmu_hv.c    | 25 ++++++++++++-------------
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 19 ++++++++-----------
 arch/powerpc/kvm/book3s_hv.c           | 26 +++++++++++---------------
 arch/powerpc/kvm/timing.c              | 14 +++++++-------
 4 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 2b1f0cdd8c18..254a267cac6f 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -1820,6 +1820,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
 
 	return nb;
 }
+FOPS_READ_ITER_HELPER(kvm_htab_read);
 
 static ssize_t kvm_htab_write(struct file *file, const char __user *buf,
 			      size_t count, loff_t *ppos)
@@ -1943,6 +1944,7 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf,
 		return err;
 	return nb;
 }
+FOPS_WRITE_ITER_HELPER(kvm_htab_write);
 
 static int kvm_htab_release(struct inode *inode, struct file *filp)
 {
@@ -1957,8 +1959,8 @@ static int kvm_htab_release(struct inode *inode, struct file *filp)
 }
 
 static const struct file_operations kvm_htab_fops = {
-	.read		= kvm_htab_read,
-	.write		= kvm_htab_write,
+	.read_iter	= kvm_htab_read_iter,
+	.write_iter	= kvm_htab_write_iter,
 	.llseek		= default_llseek,
 	.release	= kvm_htab_release,
 };
@@ -2035,10 +2037,10 @@ static int debugfs_htab_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *ppos)
+static ssize_t debugfs_htab_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_htab_state *p = file->private_data;
+	struct debugfs_htab_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret, r;
 	unsigned long i, n;
 	unsigned long v, hr, gr;
@@ -2057,11 +2059,10 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 		n = p->chars_left;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf + p->buf_index, n);
+		r = copy_to_iter(p->buf + p->buf_index, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index += n;
-		buf += n;
 		len -= n;
 		ret = n;
 		if (r) {
@@ -2097,11 +2098,10 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 		p->chars_left = n;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf, n);
+		r = copy_to_iter(p->buf, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index = n;
-		buf += n;
 		len -= n;
 		ret += n;
 		if (r) {
@@ -2117,8 +2117,7 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t debugfs_htab_write(struct file *file, const char __user *buf,
-			   size_t len, loff_t *ppos)
+static ssize_t debugfs_htab_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -2127,8 +2126,8 @@ static const struct file_operations debugfs_htab_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_htab_open,
 	.release = debugfs_htab_release,
-	.read	 = debugfs_htab_read,
-	.write	 = debugfs_htab_write,
+	.read_iter  = debugfs_htab_read,
+	.write_iter = debugfs_htab_write,
 	.llseek	 = generic_file_llseek,
 };
 
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 408d98f8a514..d33c92bbe6f2 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -1298,10 +1298,10 @@ static int debugfs_radix_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *ppos)
+static ssize_t debugfs_radix_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_radix_state *p = file->private_data;
+	struct debugfs_radix_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret, r;
 	unsigned long n;
 	struct kvm *kvm;
@@ -1328,11 +1328,10 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 		n = p->chars_left;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf + p->buf_index, n);
+		r = copy_to_iter(p->buf + p->buf_index, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index += n;
-		buf += n;
 		len -= n;
 		ret = n;
 		if (r) {
@@ -1428,11 +1427,10 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 		p->chars_left = n;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf, n);
+		r = copy_to_iter(p->buf, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index = n;
-		buf += n;
 		len -= n;
 		ret += n;
 		if (r) {
@@ -1450,8 +1448,7 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t debugfs_radix_write(struct file *file, const char __user *buf,
-			   size_t len, loff_t *ppos)
+static ssize_t debugfs_radix_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -1460,8 +1457,8 @@ static const struct file_operations debugfs_radix_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_radix_open,
 	.release = debugfs_radix_release,
-	.read	 = debugfs_radix_read,
-	.write	 = debugfs_radix_write,
+	.read_iter  = debugfs_radix_read,
+	.write_iter = debugfs_radix_write,
 	.llseek	 = generic_file_llseek,
 };
 
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 8e86eb577eb8..33ccdf765395 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2860,10 +2860,10 @@ static int debugfs_timings_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_timings_read(struct file *file, char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t debugfs_timings_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_timings_state *p = file->private_data;
+	struct debugfs_timings_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct kvm_vcpu *vcpu = p->vcpu;
 	char *s, *buf_end;
 	struct kvmhv_tb_accumulator tb;
@@ -2910,23 +2910,19 @@ static ssize_t debugfs_timings_read(struct file *file, char __user *buf,
 		p->buflen = s - p->buf;
 	}
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 	if (pos >= p->buflen)
 		return 0;
 	if (len > p->buflen - pos)
 		len = p->buflen - pos;
-	n = copy_to_user(buf, p->buf + pos, len);
-	if (n) {
-		if (n == len)
-			return -EFAULT;
-		len -= n;
-	}
-	*ppos = pos + len;
+	n = !copy_to_iter_full(p->buf + pos, len, to);
+	if (n)
+		return -EFAULT;
+	iocb->ki_pos = pos + len;
 	return len;
 }
 
-static ssize_t debugfs_timings_write(struct file *file, const char __user *buf,
-				     size_t len, loff_t *ppos)
+static ssize_t debugfs_timings_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -2935,8 +2931,8 @@ static const struct file_operations debugfs_timings_ops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_timings_open,
 	.release = debugfs_timings_release,
-	.read	 = debugfs_timings_read,
-	.write	 = debugfs_timings_write,
+	.read_iter = debugfs_timings_read,
+	.write_iter = debugfs_timings_write,
 	.llseek	 = generic_file_llseek,
 };
 
diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
index 25071331f8c1..1281aaef2b44 100644
--- a/arch/powerpc/kvm/timing.c
+++ b/arch/powerpc/kvm/timing.c
@@ -158,10 +158,10 @@ static int kvmppc_exit_timing_show(struct seq_file *m, void *private)
 }
 
 /* Write 'c' to clear the timing statistics. */
-static ssize_t kvmppc_exit_timing_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t kvmppc_exit_timing_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int err = -EINVAL;
 	char c;
 
@@ -169,13 +169,13 @@ static ssize_t kvmppc_exit_timing_write(struct file *file,
 		goto done;
 	}
 
-	if (get_user(c, user_buf)) {
+	if (get_iter(&c, from)) {
 		err = -EFAULT;
 		goto done;
 	}
 
 	if (c == 'c') {
-		struct seq_file *seqf = file->private_data;
+		struct seq_file *seqf = iocb->ki_filp->private_data;
 		struct kvm_vcpu *vcpu = seqf->private;
 		/* Write does not affect our buffers previously generated with
 		 * show. seq_file is locked here to prevent races of init with
@@ -198,8 +198,8 @@ static int kvmppc_exit_timing_open(struct inode *inode, struct file *file)
 static const struct file_operations kvmppc_exit_timing_fops = {
 	.owner   = THIS_MODULE,
 	.open    = kvmppc_exit_timing_open,
-	.read    = seq_read,
-	.write   = kvmppc_exit_timing_write,
+	.read_iter = seq_read_iter,
+	.write_iter = kvmppc_exit_timing_write,
 	.llseek  = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 339/437] powerpc/spufs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (337 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 338/437] powerpc/kvm: " Jens Axboe
@ 2024-04-11 15:17 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 340/437] powerpc/platforms: " Jens Axboe
                   ` (98 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/platforms/cell/spufs/file.c | 312 +++++++++++------------
 1 file changed, 147 insertions(+), 165 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 02a8158c469d..025c9b0a0470 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -67,14 +67,13 @@ static int spufs_attr_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t spufs_attr_read(struct file *file, char __user *buf,
-		size_t len, loff_t *ppos)
+static ssize_t spufs_attr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct spufs_attr *attr;
 	size_t size;
 	ssize_t ret;
 
-	attr = file->private_data;
+	attr = iocb->ki_filp->private_data;
 	if (!attr->get)
 		return -EACCES;
 
@@ -82,7 +81,7 @@ static ssize_t spufs_attr_read(struct file *file, char __user *buf,
 	if (ret)
 		return ret;
 
-	if (*ppos) {		/* continued read */
+	if (iocb->ki_pos) {	/* continued read */
 		size = strlen(attr->get_buf);
 	} else {		/* first read */
 		u64 val;
@@ -94,21 +93,21 @@ static ssize_t spufs_attr_read(struct file *file, char __user *buf,
 				 attr->fmt, (unsigned long long)val);
 	}
 
-	ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
+	ret = simple_copy_to_iter(attr->get_buf, &iocb->ki_pos, size, to);
 out:
 	mutex_unlock(&attr->mutex);
 	return ret;
 }
 
-static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
-		size_t len, loff_t *ppos)
+static ssize_t spufs_attr_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	struct spufs_attr *attr;
 	u64 val;
 	size_t size;
 	ssize_t ret;
 
-	attr = file->private_data;
+	attr = iocb->ki_filp->private_data;
 	if (!attr->set)
 		return -EACCES;
 
@@ -118,7 +117,7 @@ static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
 
 	ret = -EFAULT;
 	size = min(sizeof(attr->set_buf) - 1, len);
-	if (copy_from_user(attr->set_buf, buf, size))
+	if (!copy_from_iter_full(attr->set_buf, size, from))
 		goto out;
 
 	ret = len; /* claim we got the whole input */
@@ -147,8 +146,8 @@ static int __fops ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __fops = {				\
 	.open	 = __fops ## _open,					\
 	.release = spufs_attr_release,					\
-	.read	 = spufs_attr_read,					\
-	.write	 = spufs_attr_write,					\
+	.read_iter = spufs_attr_read,					\
+	.write_iter = spufs_attr_write,					\
 	.llseek  = generic_file_llseek,					\
 };
 
@@ -186,30 +185,27 @@ spufs_mem_dump(struct spu_context *ctx, struct coredump_params *cprm)
 	return spufs_dump_emit(cprm, ctx->ops->get_ls(ctx), LS_SIZE);
 }
 
-static ssize_t
-spufs_mem_read(struct file *file, char __user *buffer,
-				size_t size, loff_t *pos)
+static ssize_t spufs_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	ssize_t ret;
 
 	ret = spu_acquire(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, ctx->ops->get_ls(ctx),
-				      LS_SIZE);
+	ret = simple_copy_to_iter(ctx->ops->get_ls(ctx), &iocb->ki_pos, LS_SIZE,
+				  to);
 	spu_release(ctx);
 
 	return ret;
 }
 
-static ssize_t
-spufs_mem_write(struct file *file, const char __user *buffer,
-					size_t size, loff_t *ppos)
+static ssize_t spufs_mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	char *local_store;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
+	ssize_t size;
 	int ret;
 
 	if (pos > LS_SIZE)
@@ -220,7 +216,7 @@ spufs_mem_write(struct file *file, const char __user *buffer,
 		return ret;
 
 	local_store = ctx->ops->get_ls(ctx);
-	size = simple_write_to_buffer(local_store, LS_SIZE, ppos, buffer, size);
+	size = simple_copy_to_iter(local_store, &iocb->ki_pos, LS_SIZE, from);
 	spu_release(ctx);
 
 	return size;
@@ -301,8 +297,8 @@ static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_mem_fops = {
 	.open			= spufs_mem_open,
 	.release		= spufs_mem_release,
-	.read			= spufs_mem_read,
-	.write			= spufs_mem_write,
+	.read_iter		= spufs_mem_read,
+	.write_iter		= spufs_mem_write,
 	.llseek			= generic_file_llseek,
 	.mmap			= spufs_mem_mmap,
 };
@@ -451,8 +447,8 @@ spufs_cntl_release(struct inode *inode, struct file *file)
 static const struct file_operations spufs_cntl_fops = {
 	.open = spufs_cntl_open,
 	.release = spufs_cntl_release,
-	.read = simple_attr_read,
-	.write = simple_attr_write,
+	.read_iter = simple_attr_read_iter,
+	.write_iter = simple_attr_write_iter,
 	.llseek	= no_llseek,
 	.mmap = spufs_cntl_mmap,
 };
@@ -472,44 +468,41 @@ spufs_regs_dump(struct spu_context *ctx, struct coredump_params *cprm)
 			       sizeof(ctx->csa.lscsa->gprs));
 }
 
-static ssize_t
-spufs_regs_read(struct file *file, char __user *buffer,
-		size_t size, loff_t *pos)
+static ssize_t spufs_regs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret;
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 
 	/* pre-check for file position: if we'd return EOF, there's no point
 	 * causing a deschedule */
-	if (*pos >= sizeof(ctx->csa.lscsa->gprs))
+	if (iocb->ki_pos >= sizeof(ctx->csa.lscsa->gprs))
 		return 0;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, ctx->csa.lscsa->gprs,
-				      sizeof(ctx->csa.lscsa->gprs));
+	ret = simple_copy_to_iter(ctx->csa.lscsa->gprs, &iocb->ki_pos,
+				      sizeof(ctx->csa.lscsa->gprs), to);
 	spu_release_saved(ctx);
 	return ret;
 }
 
-static ssize_t
-spufs_regs_write(struct file *file, const char __user *buffer,
-		 size_t size, loff_t *pos)
+static ssize_t spufs_regs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_lscsa *lscsa = ctx->csa.lscsa;
+	ssize_t size;
 	int ret;
 
-	if (*pos >= sizeof(lscsa->gprs))
+	if (iocb->ki_pos >= sizeof(lscsa->gprs))
 		return -EFBIG;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
 
-	size = simple_write_to_buffer(lscsa->gprs, sizeof(lscsa->gprs), pos,
-					buffer, size);
+	size = simple_copy_from_iter(lscsa->gprs, &iocb->ki_pos,
+					sizeof(lscsa->gprs), from);
 
 	spu_release_saved(ctx);
 	return size;
@@ -517,8 +510,8 @@ spufs_regs_write(struct file *file, const char __user *buffer,
 
 static const struct file_operations spufs_regs_fops = {
 	.open	 = spufs_regs_open,
-	.read    = spufs_regs_read,
-	.write   = spufs_regs_write,
+	.read_iter = spufs_regs_read,
+	.write_iter = spufs_regs_write,
 	.llseek  = generic_file_llseek,
 };
 
@@ -529,39 +522,36 @@ spufs_fpcr_dump(struct spu_context *ctx, struct coredump_params *cprm)
 			       sizeof(ctx->csa.lscsa->fpcr));
 }
 
-static ssize_t
-spufs_fpcr_read(struct file *file, char __user * buffer,
-		size_t size, loff_t * pos)
+static ssize_t spufs_fpcr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret;
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, &ctx->csa.lscsa->fpcr,
-				      sizeof(ctx->csa.lscsa->fpcr));
+	ret = simple_copy_to_iter(&ctx->csa.lscsa->fpcr, &iocb->ki_pos,
+				      sizeof(ctx->csa.lscsa->fpcr), to);
 	spu_release_saved(ctx);
 	return ret;
 }
 
-static ssize_t
-spufs_fpcr_write(struct file *file, const char __user * buffer,
-		 size_t size, loff_t * pos)
+static ssize_t spufs_fpcr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_lscsa *lscsa = ctx->csa.lscsa;
+	ssize_t size;
 	int ret;
 
-	if (*pos >= sizeof(lscsa->fpcr))
+	if (iocb->ki_pos >= sizeof(lscsa->fpcr))
 		return -EFBIG;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
 
-	size = simple_write_to_buffer(&lscsa->fpcr, sizeof(lscsa->fpcr), pos,
-					buffer, size);
+	size = simple_copy_from_iter(&lscsa->fpcr, &iocb->ki_pos,
+					sizeof(lscsa->fpcr), from);
 
 	spu_release_saved(ctx);
 	return size;
@@ -569,8 +559,8 @@ spufs_fpcr_write(struct file *file, const char __user * buffer,
 
 static const struct file_operations spufs_fpcr_fops = {
 	.open = spufs_regs_open,
-	.read = spufs_fpcr_read,
-	.write = spufs_fpcr_write,
+	.read_iter = spufs_fpcr_read,
+	.write_iter = spufs_fpcr_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -591,11 +581,11 @@ static int spufs_pipe_open(struct inode *inode, struct file *file)
  * - end of the user provided buffer
  * - end of the mapped area
  */
-static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_mbox_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 mbox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
+	u32 mbox_data;
 	ssize_t count;
 
 	if (len < 4)
@@ -605,7 +595,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 	if (count)
 		return count;
 
-	for (count = 0; (count + 4) <= len; count += 4, udata++) {
+	for (count = 0; (count + 4) <= len; count += 4) {
 		int ret;
 		ret = ctx->ops->mbox_read(ctx, &mbox_data);
 		if (ret == 0)
@@ -616,7 +606,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 		 * but still need to return the data we have
 		 * read successfully so far.
 		 */
-		ret = put_user(mbox_data, udata);
+		ret = put_iter(mbox_data, to);
 		if (ret) {
 			if (!count)
 				count = -EFAULT;
@@ -633,14 +623,14 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_mbox_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_mbox_read,
+	.read_iter = spufs_mbox_read,
 	.llseek	= no_llseek,
 };
 
-static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_mbox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 mbox_stat;
 
@@ -655,7 +645,7 @@ static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
 
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
+	if (!copy_to_iter_full(&mbox_stat, sizeof (mbox_stat), to))
 		return -EFAULT;
 
 	return 4;
@@ -663,7 +653,7 @@ static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_mbox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_mbox_stat_read,
+	.read_iter = spufs_mbox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -694,11 +684,11 @@ void spufs_ibox_callback(struct spu *spu)
  * any data is available, but return when we have been able to
  * read something.
  */
-static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_ibox_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 ibox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
+	u32 ibox_data;
 	ssize_t count;
 
 	if (len < 4)
@@ -710,7 +700,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 
 	/* wait only for the first element */
 	count = 0;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (!spu_ibox_read(ctx, &ibox_data)) {
 			count = -EAGAIN;
 			goto out_unlock;
@@ -722,11 +712,11 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 	}
 
 	/* if we can't write at all, return -EFAULT */
-	count = put_user(ibox_data, udata);
+	count = put_iter(ibox_data, to);
 	if (count)
 		goto out_unlock;
 
-	for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
+	for (count = 4; (count + 4) <= len; count += 4) {
 		int ret;
 		ret = ctx->ops->ibox_read(ctx, &ibox_data);
 		if (ret == 0)
@@ -736,7 +726,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 		 * but still need to return the data we have
 		 * read successfully so far.
 		 */
-		ret = put_user(ibox_data, udata);
+		ret = put_iter(ibox_data, to);
 		if (ret)
 			break;
 	}
@@ -767,15 +757,15 @@ static __poll_t spufs_ibox_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_ibox_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_ibox_read,
+	.read_iter = spufs_ibox_read,
 	.poll	= spufs_ibox_poll,
 	.llseek = no_llseek,
 };
 
-static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_ibox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 ibox_stat;
 
@@ -788,7 +778,7 @@ static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
 	ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
+	if (!copy_to_iter_full(&ibox_stat, sizeof ibox_stat, to))
 		return -EFAULT;
 
 	return 4;
@@ -796,7 +786,7 @@ static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_ibox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_ibox_stat_read,
+	.read_iter = spufs_ibox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -827,17 +817,17 @@ void spufs_wbox_callback(struct spu *spu)
  * space is available, but return when we have been able to
  * write something.
  */
-static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_wbox_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 wbox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
+	u32 wbox_data;
 	ssize_t count;
 
 	if (len < 4)
 		return -EINVAL;
 
-	if (get_user(wbox_data, udata))
+	if (get_iter(wbox_data, from))
 		return -EFAULT;
 
 	count = spu_acquire(ctx);
@@ -849,7 +839,7 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
 	 * in case of !O_NONBLOCK
 	 */
 	count = 0;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (!spu_wbox_write(ctx, wbox_data)) {
 			count = -EAGAIN;
 			goto out_unlock;
@@ -862,9 +852,9 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
 
 
 	/* write as much as possible */
-	for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
+	for (count = 4; (count + 4) <= len; count += 4) {
 		int ret;
-		ret = get_user(wbox_data, udata);
+		ret = get_iter(wbox_data, from);
 		if (ret)
 			break;
 
@@ -899,15 +889,15 @@ static __poll_t spufs_wbox_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_wbox_fops = {
 	.open	= spufs_pipe_open,
-	.write	= spufs_wbox_write,
+	.write_iter = spufs_wbox_write,
 	.poll	= spufs_wbox_poll,
 	.llseek = no_llseek,
 };
 
-static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_wbox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 wbox_stat;
 
@@ -920,7 +910,7 @@ static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
 	wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
+	if (!copy_to_iter_full(&wbox_stat, sizeof wbox_stat, to))
 		return -EFAULT;
 
 	return 4;
@@ -928,7 +918,7 @@ static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_wbox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_wbox_stat_read,
+	.read_iter = spufs_wbox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -994,6 +984,7 @@ static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(spufs_signal1_read);
 
 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
 			size_t len, loff_t *pos)
@@ -1018,6 +1009,7 @@ static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
 
 	return 4;
 }
+FOPS_WRITE_ITER_HELPER(spufs_signal1_write);
 
 static vm_fault_t
 spufs_signal1_mmap_fault(struct vm_fault *vmf)
@@ -1053,8 +1045,8 @@ static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_signal1_fops = {
 	.open = spufs_signal1_open,
 	.release = spufs_signal1_release,
-	.read = spufs_signal1_read,
-	.write = spufs_signal1_write,
+	.read_iter = spufs_signal1_read_iter,
+	.write_iter = spufs_signal1_write_iter,
 	.mmap = spufs_signal1_mmap,
 	.llseek = no_llseek,
 };
@@ -1062,7 +1054,7 @@ static const struct file_operations spufs_signal1_fops = {
 static const struct file_operations spufs_signal1_nosched_fops = {
 	.open = spufs_signal1_open,
 	.release = spufs_signal1_release,
-	.write = spufs_signal1_write,
+	.write_iter = spufs_signal1_write_iter,
 	.mmap = spufs_signal1_mmap,
 	.llseek = no_llseek,
 };
@@ -1102,29 +1094,28 @@ static ssize_t spufs_signal2_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.spu_chnldata_RW[4]));
 }
 
-static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
-			size_t len)
+static ssize_t __spufs_signal2_read(struct spu_context *ctx, struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	if (len < sizeof(ctx->csa.spu_chnldata_RW[4]))
 		return -EINVAL;
 	if (!ctx->csa.spu_chnlcnt_RW[4])
 		return 0;
-	if (copy_to_user(buf, &ctx->csa.spu_chnldata_RW[4],
-			 sizeof(ctx->csa.spu_chnldata_RW[4])))
+	if (!copy_to_iter_full(&ctx->csa.spu_chnldata_RW[4],
+			 sizeof(ctx->csa.spu_chnldata_RW[4]), to))
 		return -EFAULT;
 	return sizeof(ctx->csa.spu_chnldata_RW[4]);
 }
 
-static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_signal2_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	int ret;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = __spufs_signal2_read(ctx, buf, len);
+	ret = __spufs_signal2_read(ctx, to);
 	spu_release_saved(ctx);
 
 	return ret;
@@ -1153,6 +1144,7 @@ static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
 
 	return 4;
 }
+FOPS_WRITE_ITER_HELPER(spufs_signal2_write);
 
 #if SPUFS_MMAP_4K
 static vm_fault_t
@@ -1192,8 +1184,8 @@ static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_signal2_fops = {
 	.open = spufs_signal2_open,
 	.release = spufs_signal2_release,
-	.read = spufs_signal2_read,
-	.write = spufs_signal2_write,
+	.read_iter = spufs_signal2_read,
+	.write_iter = spufs_signal2_write_iter,
 	.mmap = spufs_signal2_mmap,
 	.llseek = no_llseek,
 };
@@ -1201,7 +1193,7 @@ static const struct file_operations spufs_signal2_fops = {
 static const struct file_operations spufs_signal2_nosched_fops = {
 	.open = spufs_signal2_open,
 	.release = spufs_signal2_release,
-	.write = spufs_signal2_write,
+	.write_iter = spufs_signal2_write_iter,
 	.mmap = spufs_signal2_mmap,
 	.llseek = no_llseek,
 };
@@ -1491,10 +1483,10 @@ static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
 	return 0;
 }
 
-static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
-			size_t size, loff_t *pos)
+static ssize_t spufs_mfc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	int ret = -EINVAL;
 	u32 status;
 
@@ -1506,7 +1498,7 @@ static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
 		return ret;
 
 	ret = -EINVAL;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		status = ctx->ops->read_mfc_tagstatus(ctx);
 		if (!(status & ctx->tagwait))
 			ret = -EAGAIN;
@@ -1522,7 +1514,7 @@ static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
 	spu_release(ctx);
 
 	ret = 4;
-	if (copy_to_user(buffer, &status, 4))
+	if (!copy_to_iter_full(&status, 4, to))
 		ret = -EFAULT;
 
 out:
@@ -1617,10 +1609,10 @@ static int spu_send_mfc_command(struct spu_context *ctx,
 	return 1;
 }
 
-static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
-			size_t size, loff_t *pos)
+static ssize_t spufs_mfc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct mfc_dma_command cmd;
 	int ret = -EINVAL;
 
@@ -1628,7 +1620,7 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
 		goto out;
 
 	ret = -EFAULT;
-	if (copy_from_user(&cmd, buffer, sizeof cmd))
+	if (!copy_from_iter_full(&cmd, sizeof cmd, from))
 		goto out;
 
 	ret = spufs_check_valid_dma(&cmd);
@@ -1643,7 +1635,7 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
 	if (ret)
 		goto out;
 
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		ret = ctx->ops->send_mfc_command(ctx, &cmd);
 	} else {
 		int status;
@@ -1738,8 +1730,8 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
 static const struct file_operations spufs_mfc_fops = {
 	.open	 = spufs_mfc_open,
 	.release = spufs_mfc_release,
-	.read	 = spufs_mfc_read,
-	.write	 = spufs_mfc_write,
+	.read_iter = spufs_mfc_read,
+	.write_iter = spufs_mfc_write,
 	.poll	 = spufs_mfc_poll,
 	.flush	 = spufs_mfc_flush,
 	.fsync	 = spufs_mfc_fsync,
@@ -1943,7 +1935,7 @@ static int spufs_caps_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_caps_fops = {
 	.open		= spufs_caps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1957,10 +1949,9 @@ static ssize_t spufs_mbox_info_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.prob.pu_mb_R));
 }
 
-static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_mbox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 stat, data;
 	int ret;
 
@@ -1977,12 +1968,12 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
 	if (!(stat & 0x0000ff))
 		return 0;
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations spufs_mbox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_mbox_info_read,
+	.read_iter = spufs_mbox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -1995,10 +1986,9 @@ static ssize_t spufs_ibox_info_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.priv2.puint_mb_R));
 }
 
-static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_ibox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 stat, data;
 	int ret;
 
@@ -2015,12 +2005,12 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
 	if (!(stat & 0xff0000))
 		return 0;
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations spufs_ibox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_ibox_info_read,
+	.read_iter = spufs_ibox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -2036,10 +2026,9 @@ static ssize_t spufs_wbox_info_dump(struct spu_context *ctx,
 			spufs_wbox_info_cnt(ctx));
 }
 
-static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_wbox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 data[ARRAY_SIZE(ctx->csa.spu_mailbox_data)];
 	int ret, count;
 
@@ -2052,13 +2041,12 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &data,
-				count * sizeof(u32));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, count * sizeof(u32), to);
 }
 
 static const struct file_operations spufs_wbox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_wbox_info_read,
+	.read_iter = spufs_wbox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -2092,10 +2080,9 @@ static ssize_t spufs_dma_info_dump(struct spu_context *ctx,
 	return spufs_dump_emit(cprm, &info, sizeof(info));
 }
 
-static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
-			      size_t len, loff_t *pos)
+static ssize_t spufs_dma_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_dma_info info;
 	int ret;
 
@@ -2107,13 +2094,12 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &info,
-				sizeof(info));
+	return simple_copy_to_iter(&info, &iocb->ki_pos, sizeof(info), to);
 }
 
 static const struct file_operations spufs_dma_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_dma_info_read,
+	.read_iter = spufs_dma_info_read,
 	.llseek = no_llseek,
 };
 
@@ -2146,10 +2132,10 @@ static ssize_t spufs_proxydma_info_dump(struct spu_context *ctx,
 	return spufs_dump_emit(cprm, &info, sizeof(info));
 }
 
-static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_proxydma_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct spu_proxydma_info info;
 	int ret;
 
@@ -2164,13 +2150,12 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &info,
-				sizeof(info));
+	return simple_copy_to_iter(&info, &iocb->ki_pos, sizeof(info), to);
 }
 
 static const struct file_operations spufs_proxydma_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_proxydma_info_read,
+	.read_iter = spufs_proxydma_info_read,
 	.llseek = no_llseek,
 };
 
@@ -2189,7 +2174,7 @@ static int spufs_tid_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_tid_fops = {
 	.open		= spufs_tid_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2279,7 +2264,7 @@ static int spufs_stat_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_stat_fops = {
 	.open		= spufs_stat_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2357,16 +2342,13 @@ static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
 			(unsigned long long) p->timebase);
 }
 
-static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
-			     size_t len, loff_t *ppos)
+static ssize_t spufs_switch_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
+	size_t len = iov_iter_count(to);
 	int error = 0, cnt = 0;
 
-	if (!buf)
-		return -EINVAL;
-
 	error = spu_acquire(ctx);
 	if (error)
 		return error;
@@ -2381,7 +2363,7 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
 				 * just return straight away */
 				break;
 
-			} else if (file->f_flags & O_NONBLOCK) {
+			} else if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 				error = -EAGAIN;
 				break;
 
@@ -2417,7 +2399,7 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
 			 * partial buffer (so far) */
 			break;
 
-		error = copy_to_user(buf + cnt, tbuf, width);
+		error = !copy_to_iter_full(tbuf, width, to);
 		if (error)
 			break;
 		cnt += width;
@@ -2451,7 +2433,7 @@ static __poll_t spufs_switch_log_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_switch_log_fops = {
 	.open		= spufs_switch_log_open,
-	.read		= spufs_switch_log_read,
+	.read_iter	= spufs_switch_log_read,
 	.poll		= spufs_switch_log_poll,
 	.release	= spufs_switch_log_release,
 	.llseek		= no_llseek,
@@ -2532,7 +2514,7 @@ static int spufs_ctx_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_ctx_fops = {
 	.open           = spufs_ctx_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 340/437] powerpc/platforms: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (338 preceding siblings ...)
  2024-04-11 15:17 ` [PATCH 339/437] powerpc/spufs: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 341/437] s390: cio: " Jens Axboe
                   ` (97 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c    |  7 ++---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 11 ++++---
 arch/powerpc/platforms/powernv/memtrace.c    |  9 +++---
 arch/powerpc/platforms/powernv/opal-lpc.c    |  6 ++--
 arch/powerpc/platforms/powernv/opal-prd.c    | 22 +++++++-------
 arch/powerpc/platforms/powernv/opal-xscom.c  | 30 +++++++++-----------
 arch/powerpc/platforms/pseries/dtl.c         | 16 +++++------
 arch/powerpc/platforms/pseries/lpar.c        | 11 ++++---
 arch/powerpc/platforms/pseries/papr-vpd.c    |  8 +++---
 9 files changed, 57 insertions(+), 63 deletions(-)

diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
index 581059527c36..d166f153ad12 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
@@ -530,10 +530,9 @@ static inline void mpc52xx_gpt_wdt_ping(struct mpc52xx_gpt_priv *gpt_wdt)
 }
 
 /* wdt misc device api */
-static ssize_t mpc52xx_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t mpc52xx_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mpc52xx_gpt_priv *gpt_wdt = file->private_data;
+	struct mpc52xx_gpt_priv *gpt_wdt = iocb->ki_filp->private_data;
 	mpc52xx_gpt_wdt_ping(gpt_wdt);
 	return 0;
 }
@@ -645,7 +644,7 @@ static int mpc52xx_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations mpc52xx_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= mpc52xx_wdt_write,
+	.write_iter	= mpc52xx_wdt_write,
 	.unlocked_ioctl = mpc52xx_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mpc52xx_wdt_open,
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index af3a5d37a149..c2a6081fed1d 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -62,11 +62,10 @@ static irqreturn_t pnv_eeh_event(int irq, void *data)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t pnv_eeh_ei_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t pnv_eeh_ei_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct pci_controller *hose = filp->private_data;
+	struct pci_controller *hose = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct eeh_pe *pe;
 	int pe_no, type, func;
 	unsigned long addr, mask;
@@ -77,7 +76,7 @@ static ssize_t pnv_eeh_ei_write(struct file *filp,
 		return -ENXIO;
 
 	/* Copy over argument buffer */
-	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), from);
 	if (!ret)
 		return -EFAULT;
 
@@ -100,7 +99,7 @@ static ssize_t pnv_eeh_ei_write(struct file *filp,
 static const struct file_operations pnv_eeh_ei_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= pnv_eeh_ei_write,
+	.write_iter	= pnv_eeh_ei_write,
 };
 
 static int pnv_eeh_dbgfs_set(void *data, int offset, u64 val)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 877720c64515..366da300e605 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -37,12 +37,11 @@ static struct memtrace_entry *memtrace_array;
 static unsigned int memtrace_array_nr;
 
 
-static ssize_t memtrace_read(struct file *filp, char __user *ubuf,
-			     size_t count, loff_t *ppos)
+static ssize_t memtrace_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct memtrace_entry *ent = filp->private_data;
+	struct memtrace_entry *ent = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(ubuf, count, ppos, ent->mem, ent->size);
+	return simple_copy_to_iter(ent->mem, &iocb->ki_pos, ent->size, to);
 }
 
 static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)
@@ -62,7 +61,7 @@ static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)
 
 static const struct file_operations memtrace_fops = {
 	.llseek = default_llseek,
-	.read	= memtrace_read,
+	.read_iter = memtrace_read,
 	.open	= simple_open,
 	.mmap   = memtrace_mmap,
 };
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c
index a16f07cdab26..e2f18ed6af17 100644
--- a/arch/powerpc/platforms/powernv/opal-lpc.c
+++ b/arch/powerpc/platforms/powernv/opal-lpc.c
@@ -271,6 +271,7 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
 
 	return count;
 }
+FOPS_READ_ITER_HELPER(lpc_debug_read);
 
 static ssize_t lpc_debug_write(struct file *filp, const char __user *ubuf,
 			       size_t count, loff_t *ppos)
@@ -342,10 +343,11 @@ static ssize_t lpc_debug_write(struct file *filp, const char __user *ubuf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(lpc_debug_write);
 
 static const struct file_operations lpc_fops = {
-	.read =		lpc_debug_read,
-	.write =	lpc_debug_write,
+	.read_iter =	lpc_debug_read_iter,
+	.write_iter =	lpc_debug_write_iter,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
diff --git a/arch/powerpc/platforms/powernv/opal-prd.c b/arch/powerpc/platforms/powernv/opal-prd.c
index 24f04f20d3e8..ac760ad1e46d 100644
--- a/arch/powerpc/platforms/powernv/opal-prd.c
+++ b/arch/powerpc/platforms/powernv/opal-prd.c
@@ -156,10 +156,10 @@ static __poll_t opal_prd_poll(struct file *file,
 	return 0;
 }
 
-static ssize_t opal_prd_read(struct file *file, char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t opal_prd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct opal_prd_msg_queue_item *item;
+	size_t count = iov_iter_count(to);
 	unsigned long flags;
 	ssize_t size, err;
 	int rc;
@@ -168,7 +168,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 	if (count < sizeof(item->msg.header))
 		return -EINVAL;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
 
 	item = NULL;
@@ -186,7 +186,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 		if (item)
 			break;
 
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		rc = wait_event_interruptible(opal_prd_msg_wait,
@@ -201,7 +201,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 		goto err_requeue;
 	}
 
-	rc = copy_to_user(buf, &item->msg, size);
+	rc = !copy_to_iter_full(&item->msg, size, to);
 	if (rc) {
 		err = -EFAULT;
 		goto err_requeue;
@@ -219,9 +219,9 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 	return err;
 }
 
-static ssize_t opal_prd_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t opal_prd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct opal_prd_msg_header hdr;
 	struct opal_prd_msg *msg;
 	ssize_t size;
@@ -233,13 +233,13 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
 		return -EINVAL;
 
 	/* grab the header */
-	rc = copy_from_user(&hdr, buf, sizeof(hdr));
+	rc = !copy_from_iter_full(&hdr, sizeof(hdr), from);
 	if (rc)
 		return -EFAULT;
 
 	size = be16_to_cpu(hdr.size);
 
-	msg = memdup_user(buf, size);
+	msg = iterdup(from, size);
 	if (IS_ERR(msg))
 		return PTR_ERR(msg);
 
@@ -325,8 +325,8 @@ static const struct file_operations opal_prd_fops = {
 	.open		= opal_prd_open,
 	.mmap		= opal_prd_mmap,
 	.poll		= opal_prd_poll,
-	.read		= opal_prd_read,
-	.write		= opal_prd_write,
+	.read_iter	= opal_prd_read,
+	.write_iter	= opal_prd_write,
 	.unlocked_ioctl	= opal_prd_ioctl,
 	.release	= opal_prd_release,
 	.owner		= THIS_MODULE,
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 748c2b97fa53..344bc747f576 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -84,12 +84,11 @@ struct scom_debug_entry {
 	char name[16];
 };
 
-static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t scom_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct scom_debug_entry *ent = filp->private_data;
-	u64 __user *ubuf64 = (u64 __user *)ubuf;
-	loff_t off = *ppos;
+	struct scom_debug_entry *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
+	loff_t off = iocb->ki_pos;
 	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
@@ -102,25 +101,23 @@ static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
 	for (reg = 0; reg < reg_cnt; reg++) {
 		rc = opal_scom_read(ent->chip, reg_base, reg, &val);
 		if (!rc)
-			rc = put_user(val, ubuf64);
+			rc = put_iter(val, to);
 		if (rc) {
 			if (!done)
 				done = rc;
 			break;
 		}
-		ubuf64++;
-		*ppos += 8;
+		iocb->ki_pos += 8;
 		done += 8;
 	}
 	return done;
 }
 
-static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t scom_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct scom_debug_entry *ent = filp->private_data;
-	u64 __user *ubuf64 = (u64 __user *)ubuf;
-	loff_t off = *ppos;
+	struct scom_debug_entry *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
+	loff_t off = iocb->ki_pos;
 	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
@@ -131,7 +128,7 @@ static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
 	reg_cnt = count >> 3;
 
 	for (reg = 0; reg < reg_cnt; reg++) {
-		rc = get_user(val, ubuf64);
+		rc = get_iter(val, from);
 		if (!rc)
 			rc = opal_scom_write(ent->chip, reg_base, reg,  val);
 		if (rc) {
@@ -139,15 +136,14 @@ static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
 				done = rc;
 			break;
 		}
-		ubuf64++;
 		done += 8;
 	}
 	return done;
 }
 
 static const struct file_operations scom_debug_fops = {
-	.read =		scom_debug_read,
-	.write =	scom_debug_write,
+	.read_iter =	scom_debug_read,
+	.write_iter =	scom_debug_write,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index 3f1cdccebc9c..3efb00703b43 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -257,17 +257,17 @@ static int dtl_file_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
-		loff_t *pos)
+static ssize_t dtl_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	long int rc, n_read, n_req, read_size;
+	size_t len = iov_iter_count(to);
 	struct dtl *dtl;
 	u64 cur_idx, last_idx, i;
 
 	if ((len % sizeof(struct dtl_entry)) != 0)
 		return -EINVAL;
 
-	dtl = filp->private_data;
+	dtl = iocb->ki_filp->private_data;
 
 	/* requested number of entries to read */
 	n_req = len / sizeof(struct dtl_entry);
@@ -300,19 +300,19 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
 	if (i + n_req > dtl->buf_entries) {
 		read_size = dtl->buf_entries - i;
 
-		rc = copy_to_user(buf, &dtl->buf[i],
-				read_size * sizeof(struct dtl_entry));
+		rc = !copy_to_iter_full(&dtl->buf[i],
+				read_size * sizeof(struct dtl_entry), to);
 		if (rc)
 			return -EFAULT;
 
 		i = 0;
 		n_req -= read_size;
 		n_read += read_size;
-		buf += read_size * sizeof(struct dtl_entry);
 	}
 
 	/* .. and now the head */
-	rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry));
+	rc = !copy_to_iter_full(&dtl->buf[i], n_req * sizeof(struct dtl_entry),
+				to);
 	if (rc)
 		return -EFAULT;
 
@@ -324,7 +324,7 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
 static const struct file_operations dtl_fops = {
 	.open		= dtl_file_open,
 	.release	= dtl_file_release,
-	.read		= dtl_file_read,
+	.read_iter	= dtl_file_read,
 	.llseek		= no_llseek,
 };
 
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 4e9916bb03d7..2ccbcf9f295a 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1991,19 +1991,18 @@ machine_device_initcall(pseries, reserve_vrma_context_id);
 
 #ifdef CONFIG_DEBUG_FS
 /* debugfs file interface for vpa data */
-static ssize_t vpa_file_read(struct file *filp, char __user *buf, size_t len,
-			      loff_t *pos)
+static ssize_t vpa_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	int cpu = (long)filp->private_data;
+	int cpu = (long)iocb->ki_filp->private_data;
 	struct lppaca *lppaca = &lppaca_of(cpu);
 
-	return simple_read_from_buffer(buf, len, pos, lppaca,
-				sizeof(struct lppaca));
+	return simple_copy_to_iter(lppaca, &iocb->ki_pos, sizeof(struct lppaca),
+					to);
 }
 
 static const struct file_operations vpa_fops = {
 	.open		= simple_open,
-	.read		= vpa_file_read,
+	.read_iter	= vpa_file_read,
 	.llseek		= default_llseek,
 };
 
diff --git a/arch/powerpc/platforms/pseries/papr-vpd.c b/arch/powerpc/platforms/pseries/papr-vpd.c
index c29e85db5f35..bab048029ed5 100644
--- a/arch/powerpc/platforms/pseries/papr-vpd.c
+++ b/arch/powerpc/platforms/pseries/papr-vpd.c
@@ -408,9 +408,9 @@ static const struct vpd_blob *papr_vpd_retrieve(const struct papr_location_code
 	return blob;
 }
 
-static ssize_t papr_vpd_handle_read(struct file *file, char __user *buf, size_t size, loff_t *off)
+static ssize_t papr_vpd_handle_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const struct vpd_blob *blob = file->private_data;
+	const struct vpd_blob *blob = iocb->ki_filp->private_data;
 
 	/* bug: we should not instantiate a handle without any data attached. */
 	if (!vpd_blob_has_data(blob)) {
@@ -418,7 +418,7 @@ static ssize_t papr_vpd_handle_read(struct file *file, char __user *buf, size_t
 		return -EIO;
 	}
 
-	return simple_read_from_buffer(buf, size, off, blob->data, blob->len);
+	return simple_copy_to_iter(blob->data, &iocb->ki_pos, blob->len, to);
 }
 
 static int papr_vpd_handle_release(struct inode *inode, struct file *file)
@@ -439,7 +439,7 @@ static loff_t papr_vpd_handle_seek(struct file *file, loff_t off, int whence)
 
 
 static const struct file_operations papr_vpd_handle_ops = {
-	.read = papr_vpd_handle_read,
+	.read_iter = papr_vpd_handle_read,
 	.llseek = papr_vpd_handle_seek,
 	.release = papr_vpd_handle_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 341/437] s390: cio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (339 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 340/437] powerpc/platforms: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 342/437] s390: fs3270: " Jens Axboe
                   ` (96 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/cio/cio_inject.c | 11 ++++++-----
 drivers/s390/cio/qdio_debug.c | 12 ++++++------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/s390/cio/cio_inject.c b/drivers/s390/cio/cio_inject.c
index 8613fa937237..33ccd36098b3 100644
--- a/drivers/s390/cio/cio_inject.c
+++ b/drivers/s390/cio/cio_inject.c
@@ -123,15 +123,16 @@ static ssize_t crw_inject_write(struct file *file, const char __user *buf,
 
 	return lbuf;
 }
+FOPS_WRITE_ITER_HELPER(crw_inject_write);
 
 /* Debugfs write handler for inject_enable node*/
-static ssize_t enable_inject_write(struct file *file, const char __user *buf,
-				   size_t lbuf, loff_t *ppos)
+static ssize_t enable_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t lbuf = iov_iter_count(from);
 	unsigned long en = 0;
 	int rc;
 
-	rc = kstrtoul_from_user(buf, lbuf, 10, &en);
+	rc = kstrtoul_from_iter(from, lbuf, 10, &en);
 	if (rc)
 		return rc;
 
@@ -149,12 +150,12 @@ static ssize_t enable_inject_write(struct file *file, const char __user *buf,
 
 static const struct file_operations crw_fops = {
 	.owner = THIS_MODULE,
-	.write = crw_inject_write,
+	.write_iter = crw_inject_write_iter,
 };
 
 static const struct file_operations cio_en_fops = {
 	.owner = THIS_MODULE,
-	.write = enable_inject_write,
+	.write_iter = enable_inject_write,
 };
 
 static int __init cio_inject_init(void)
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index 1a9714af51e4..0c9f84c5197f 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -234,11 +234,11 @@ static int qperf_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
-			       size_t count, loff_t *off)
+static ssize_t qperf_seq_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
 	struct qdio_irq *irq_ptr = seq->private;
+	size_t count = iov_iter_count(from);
 	struct qdio_q *q;
 	unsigned long val;
 	int ret, i;
@@ -246,7 +246,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 	if (!irq_ptr)
 		return 0;
 
-	ret = kstrtoul_from_user(ubuf, count, 10, &val);
+	ret = kstrtoul_from_iter(from, count, 10, &val);
 	if (ret)
 		return ret;
 
@@ -275,8 +275,8 @@ static int qperf_seq_open(struct inode *inode, struct file *filp)
 static const struct file_operations debugfs_perf_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = qperf_seq_open,
-	.read	 = seq_read,
-	.write	 = qperf_seq_write,
+	.read_iter = seq_read_iter,
+	.write_iter = qperf_seq_write,
 	.llseek  = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 342/437] s390: fs3270: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (340 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 341/437] s390: cio: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 343/437] s390: hmcdrv: " Jens Axboe
                   ` (95 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/fs3270.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 4d824f86bbbb..c8c767342167 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -276,6 +276,7 @@ static ssize_t fs3270_read(struct file *filp, char __user *data,
 	idal_buffer_free(ib);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(fs3270_read);
 
 /*
  * Process writes to fullscreen 3270.
@@ -316,6 +317,7 @@ static ssize_t fs3270_write(struct file *filp, const char __user *data,
 	idal_buffer_free(ib);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(fs3270_write);
 
 /*
  * process ioctl commands for the tube driver
@@ -509,8 +511,8 @@ static int fs3270_close(struct inode *inode, struct file *filp)
 
 static const struct file_operations fs3270_fops = {
 	.owner		 = THIS_MODULE,		/* owner */
-	.read		 = fs3270_read,		/* read */
-	.write		 = fs3270_write,	/* write */
+	.read_iter	 = fs3270_read_iter,	/* read */
+	.write_iter	 = fs3270_write_iter,	/* write */
 	.unlocked_ioctl	 = fs3270_ioctl,	/* ioctl */
 	.compat_ioctl	 = fs3270_ioctl,	/* ioctl */
 	.open		 = fs3270_open,		/* open */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 343/437] s390: hmcdrv: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (341 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 342/437] s390: fs3270: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 344/437] s390: tape_char: " Jens Axboe
                   ` (94 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/hmcdrv_dev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/char/hmcdrv_dev.c b/drivers/s390/char/hmcdrv_dev.c
index 8d50c894711f..df793008a390 100644
--- a/drivers/s390/char/hmcdrv_dev.c
+++ b/drivers/s390/char/hmcdrv_dev.c
@@ -56,10 +56,8 @@ struct hmcdrv_dev_node {
 static int hmcdrv_dev_open(struct inode *inode, struct file *fp);
 static int hmcdrv_dev_release(struct inode *inode, struct file *fp);
 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence);
-static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
-			       size_t len, loff_t *pos);
-static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
-				size_t len, loff_t *pos);
+static ssize_t hmcdrv_dev_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t hmcdrv_dev_write_iter(struct kiocb *iocb, struct iov_iter *from);
 static ssize_t hmcdrv_dev_transfer(char __kernel *cmd, loff_t offset,
 				   char __user *buf, size_t len);
 
@@ -70,8 +68,8 @@ static const struct file_operations hmcdrv_dev_fops = {
 	.open = hmcdrv_dev_open,
 	.llseek = hmcdrv_dev_seek,
 	.release = hmcdrv_dev_release,
-	.read = hmcdrv_dev_read,
-	.write = hmcdrv_dev_write,
+	.read_iter = hmcdrv_dev_read_iter,
+	.write_iter = hmcdrv_dev_write_iter,
 };
 
 static struct hmcdrv_dev_node hmcdrv_dev; /* HMC device struct (static) */
@@ -239,6 +237,7 @@ static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
 
 	return retlen;
 }
+FOPS_READ_ITER_HELPER(hmcdrv_dev_read);
 
 /*
  * write()
@@ -276,6 +275,7 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
 
 	return retlen;
 }
+FOPS_WRITE_ITER_HELPER(hmcdrv_dev_write);
 
 /**
  * hmcdrv_dev_init() - creates a HMC drive CD/DVD device
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 344/437] s390: tape_char: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (342 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 343/437] s390: hmcdrv: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 345/437] s390: vmcp: " Jens Axboe
                   ` (93 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/tape_char.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
index cc8237afeffa..b6a8e99f0d31 100644
--- a/drivers/s390/char/tape_char.c
+++ b/drivers/s390/char/tape_char.c
@@ -32,8 +32,8 @@
 /*
  * file operation structure for tape character frontend
  */
-static ssize_t tapechar_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *);
+static ssize_t tapechar_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t tapechar_write_iter(struct kiocb *iocb, struct iov_iter *from);
 static int tapechar_open(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
@@ -44,8 +44,8 @@ static long tapechar_compat_ioctl(struct file *, unsigned int, unsigned long);
 static const struct file_operations tape_fops =
 {
 	.owner = THIS_MODULE,
-	.read = tapechar_read,
-	.write = tapechar_write,
+	.read_iter = tapechar_read_iter,
+	.write_iter = tapechar_write_iter,
 	.unlocked_ioctl = tapechar_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = tapechar_compat_ioctl,
@@ -179,6 +179,7 @@ tapechar_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
 	tape_free_request(request);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(tapechar_read);
 
 /*
  * Tape device write function
@@ -263,6 +264,7 @@ tapechar_write(struct file *filp, const char __user *data, size_t count, loff_t
 
 	return rc ? rc : written;
 }
+FOPS_WRITE_ITER_HELPER(tapechar_write);
 
 /*
  * Character frontend tape device open function.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 345/437] s390: vmcp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (343 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 344/437] s390: tape_char: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 346/437] s390: vmur: " Jens Axboe
                   ` (92 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/vmcp.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index eb0520a9d4af..348e528a386d 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -128,14 +128,13 @@ static int vmcp_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
+static ssize_t vmcp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	size_t size;
 	struct vmcp_session *session;
 
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (mutex_lock_interruptible(&session->mutex))
 		return -ERESTARTSYS;
 	if (!session->response) {
@@ -143,27 +142,25 @@ vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
 		return 0;
 	}
 	size = min_t(size_t, session->resp_size, session->bufsize);
-	ret = simple_read_from_buffer(buff, count, ppos,
-					session->response, size);
+	ret = simple_copy_to_iter(session->response, &iocb->ki_pos, size, to);
 
 	mutex_unlock(&session->mutex);
 
 	return ret;
 }
 
-static ssize_t
-vmcp_write(struct file *file, const char __user *buff, size_t count,
-	   loff_t *ppos)
+static ssize_t vmcp_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *cmd;
 	struct vmcp_session *session;
+	size_t count = iov_iter_count(from);
 
 	if (count > 240)
 		return -EINVAL;
-	cmd = memdup_user_nul(buff, count);
+	cmd = iterdup_nul(from, count);
 	if (IS_ERR(cmd))
 		return PTR_ERR(cmd);
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (mutex_lock_interruptible(&session->mutex)) {
 		kfree(cmd);
 		return -ERESTARTSYS;
@@ -180,7 +177,7 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
 				   &session->resp_code);
 	mutex_unlock(&session->mutex);
 	kfree(cmd);
-	*ppos = 0;		/* reset the file pointer after a command */
+	iocb->ki_pos = 0;	/* reset the file pointer after a command */
 	return count;
 }
 
@@ -238,8 +235,8 @@ static const struct file_operations vmcp_fops = {
 	.owner		= THIS_MODULE,
 	.open		= vmcp_open,
 	.release	= vmcp_release,
-	.read		= vmcp_read,
-	.write		= vmcp_write,
+	.read_iter	= vmcp_read,
+	.write_iter	= vmcp_write,
 	.unlocked_ioctl	= vmcp_ioctl,
 	.compat_ioctl	= vmcp_ioctl,
 	.llseek		= no_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 346/437] s390: vmur: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (344 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 345/437] s390: vmcp: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 347/437] s390: zcore: " Jens Axboe
                   ` (91 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/vmur.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index fe94dec427b6..187b0dde22e1 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -461,6 +461,7 @@ static ssize_t ur_write(struct file *file, const char __user *udata,
 
 	return do_write(urf->urd, udata, count, urf->dev_reclen, ppos);
 }
+FOPS_WRITE_ITER_HELPER(ur_write);
 
 /*
  * diagnose code 0x14 subcode 0x0028 - position spool file to designated
@@ -580,6 +581,7 @@ static ssize_t ur_read(struct file *file, char __user *ubuf, size_t count,
 	mutex_unlock(&urd->io_mutex);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(ur_read);
 
 /*
  * diagnose code 0x14 subcode 0x0fff - retrieve next file descriptor
@@ -799,8 +801,8 @@ static const struct file_operations ur_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = ur_open,
 	.release = ur_release,
-	.read	 = ur_read,
-	.write	 = ur_write,
+	.read_iter	 = ur_read_iter,
+	.write_iter	 = ur_write_iter,
 	.llseek  = ur_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 347/437] s390: zcore: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (345 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 346/437] s390: vmur: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 348/437] s390: crypto: " Jens Axboe
                   ` (90 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/zcore.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
index 0969fa01df58..8f5c890605ce 100644
--- a/drivers/s390/char/zcore.c
+++ b/drivers/s390/char/zcore.c
@@ -134,8 +134,7 @@ static void release_hsa(void)
 	hsa_available = 0;
 }
 
-static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t zcore_reipl_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	if (zcore_ipl_block) {
 		diag308(DIAG308_SET, zcore_ipl_block);
@@ -147,7 +146,7 @@ static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
 		else
 			diag308(DIAG308_LOAD_NORMAL, NULL);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
 static int zcore_reipl_open(struct inode *inode, struct file *filp)
@@ -162,14 +161,13 @@ static int zcore_reipl_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations zcore_reipl_fops = {
 	.owner		= THIS_MODULE,
-	.write		= zcore_reipl_write,
+	.write_iter	= zcore_reipl_write,
 	.open		= zcore_reipl_open,
 	.release	= zcore_reipl_release,
 	.llseek		= no_llseek,
 };
 
-static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	static char str[18];
 
@@ -177,28 +175,27 @@ static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
 		snprintf(str, sizeof(str), "%lx\n", sclp.hsa_size);
 	else
 		snprintf(str, sizeof(str), "0\n");
-	return simple_read_from_buffer(buf, count, ppos, str, strlen(str));
+	return simple_copy_to_iter(str, &iocb->ki_pos, strlen(str), to);
 }
 
-static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char value;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EPIPE;
-	if (copy_from_user(&value, buf, 1))
+	if (!copy_from_iter_full(&value, 1, from))
 		return -EFAULT;
 	if (value != '0')
 		return -EINVAL;
 	release_hsa();
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations zcore_hsa_fops = {
 	.owner		= THIS_MODULE,
-	.write		= zcore_hsa_write,
-	.read		= zcore_hsa_read,
+	.write_iter	= zcore_hsa_write,
+	.read_iter	= zcore_hsa_read,
 	.open		= nonseekable_open,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 348/437] s390: crypto: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (346 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 347/437] s390: zcore: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 349/437] s390: monreader: " Jens Axboe
                   ` (89 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/crypto/zcrypt_api.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index eba07f8ef308..bc2b385ea550 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -475,8 +475,7 @@ static void zcdn_destroy_all(void)
  *
  * This function is not supported beyond zcrypt 1.3.1.
  */
-static ssize_t zcrypt_read(struct file *filp, char __user *buf,
-			   size_t count, loff_t *f_pos)
+static ssize_t zcrypt_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EPERM;
 }
@@ -486,8 +485,7 @@ static ssize_t zcrypt_read(struct file *filp, char __user *buf,
  *
  * Write is not allowed
  */
-static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
-			    size_t count, loff_t *f_pos)
+static ssize_t zcrypt_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EPERM;
 }
@@ -1905,8 +1903,8 @@ static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd,
  */
 static const struct file_operations zcrypt_fops = {
 	.owner		= THIS_MODULE,
-	.read		= zcrypt_read,
-	.write		= zcrypt_write,
+	.read_iter	= zcrypt_read,
+	.write_iter	= zcrypt_write,
 	.unlocked_ioctl	= zcrypt_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= zcrypt_compat_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 349/437] s390: monreader: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (347 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 348/437] s390: crypto: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 350/437] s390: monwriter: " Jens Axboe
                   ` (88 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/monreader.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 7207a7f5842a..151030779624 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -358,10 +358,10 @@ static int mon_close(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t mon_read(struct file *filp, char __user *data,
-			size_t count, loff_t *ppos)
+static ssize_t mon_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mon_private *monpriv = filp->private_data;
+	struct mon_private *monpriv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct mon_msg *monmsg;
 	int ret;
 	u32 mce_start;
@@ -371,7 +371,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 		return PTR_ERR(monmsg);
 
 	if (!monmsg) {
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		ret = wait_event_interruptible(mon_read_wait_queue,
 					atomic_read(&monpriv->read_ready) ||
@@ -392,7 +392,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	mce_start = mon_mca_start(monmsg) + monmsg->mca_offset;
 	if ((monmsg->pos >= mce_start) && (monmsg->pos < mce_start + 12)) {
 		count = min(count, (size_t) mce_start + 12 - monmsg->pos);
-		ret = copy_to_user(data, __va(monmsg->pos), count);
+		ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
 		if (ret)
 			return -EFAULT;
 		monmsg->pos += count;
@@ -405,7 +405,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	if (monmsg->pos <= mon_rec_end(monmsg)) {
 		count = min(count, (size_t) mon_rec_end(monmsg) - monmsg->pos
 					    + 1);
-		ret = copy_to_user(data, __va(monmsg->pos), count);
+		ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
 		if (ret)
 			return -EFAULT;
 		monmsg->pos += count;
@@ -418,7 +418,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	return ret;
 
 out_copy:
-	*ppos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
@@ -438,7 +438,7 @@ static const struct file_operations mon_fops = {
 	.owner   = THIS_MODULE,
 	.open    = &mon_open,
 	.release = &mon_close,
-	.read    = &mon_read,
+	.read_iter = &mon_read,
 	.poll    = &mon_poll,
 	.llseek  = noop_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 350/437] s390: monwriter: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (348 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 349/437] s390: monreader: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 351/437] s390: hw_random: " Jens Axboe
                   ` (87 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/monwriter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index bc5193d81f9c..8baf04d05748 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -216,10 +216,10 @@ static int monwrite_close(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t monwrite_write(struct file *filp, const char __user *data,
-			      size_t count, loff_t *ppos)
+static ssize_t monwrite_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mon_private *monpriv = filp->private_data;
+	struct mon_private *monpriv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t len, written;
 	void *to;
 	int rc;
@@ -230,7 +230,7 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
 			len = min(count - written, monpriv->hdr_to_read);
 			to = (char *) &monpriv->hdr +
 				sizeof(monpriv->hdr) - monpriv->hdr_to_read;
-			if (copy_from_user(to, data + written, len)) {
+			if (!copy_from_iter_full(to, len, from)) {
 				rc = -EFAULT;
 				goto out_error;
 			}
@@ -249,7 +249,7 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
 			len = min(count - written, monpriv->data_to_read);
 			to = monpriv->current_buf->data +
 				monpriv->hdr.datalen - monpriv->data_to_read;
-			if (copy_from_user(to, data + written, len)) {
+			if (!copy_from_iter_full(to, len, from)) {
 				rc = -EFAULT;
 				goto out_error;
 			}
@@ -277,7 +277,7 @@ static const struct file_operations monwrite_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = &monwrite_open,
 	.release = &monwrite_close,
-	.write	 = &monwrite_write,
+	.write_iter	 = &monwrite_write,
 	.llseek  = noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 351/437] s390: hw_random: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (349 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 350/437] s390: monwriter: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 352/437] s390: vmlogrdr: " Jens Axboe
                   ` (86 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/char/hw_random/s390-trng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/char/hw_random/s390-trng.c b/drivers/char/hw_random/s390-trng.c
index d27e32e9bfee..b1e1b896907c 100644
--- a/drivers/char/hw_random/s390-trng.c
+++ b/drivers/char/hw_random/s390-trng.c
@@ -53,9 +53,9 @@ static int trng_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t trng_read(struct file *file, char __user *ubuf,
-			 size_t nbytes, loff_t *ppos)
+static ssize_t trng_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t nbytes = iov_iter_count(to);
 	u8 buf[32];
 	u8 *p = buf;
 	unsigned int n;
@@ -85,12 +85,11 @@ static ssize_t trng_read(struct file *file, char __user *ubuf,
 		n = nbytes > PAGE_SIZE ? PAGE_SIZE : nbytes;
 		cpacf_trng(NULL, 0, p, n);
 		atomic64_add(n, &trng_dev_counter);
-		if (copy_to_user(ubuf, p, n)) {
+		if (!copy_to_iter_full(p, n, to)) {
 			ret = -EFAULT;
 			break;
 		}
 		nbytes -= n;
-		ubuf += n;
 		ret += n;
 	}
 
@@ -139,7 +138,7 @@ static const struct file_operations trng_fops = {
 	.owner		= THIS_MODULE,
 	.open		= &trng_open,
 	.release	= NULL,
-	.read		= &trng_read,
+	.read_iter	= trng_read,
 	.llseek		= noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 352/437] s390: vmlogrdr: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (350 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 351/437] s390: hw_random: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 353/437] arch/s390: " Jens Axboe
                   ` (85 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/s390/char/vmlogrdr.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index d7e408c8d0b8..52595690e43c 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -88,14 +88,13 @@ struct vmlogrdr_priv_t {
  */
 static int vmlogrdr_open(struct inode *, struct file *);
 static int vmlogrdr_release(struct inode *, struct file *);
-static ssize_t vmlogrdr_read (struct file *filp, char __user *data,
-			      size_t count, loff_t * ppos);
+static ssize_t vmlogrdr_read(struct kiocb *iocb, struct iov_iter *to);
 
 static const struct file_operations vmlogrdr_fops = {
 	.owner   = THIS_MODULE,
 	.open    = vmlogrdr_open,
 	.release = vmlogrdr_release,
-	.read    = vmlogrdr_read,
+	.read_iter = vmlogrdr_read,
 	.llseek  = no_llseek,
 };
 
@@ -473,11 +472,11 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
 }
 
 
-static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
-			     size_t count, loff_t * ppos)
+static ssize_t vmlogrdr_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int rc;
-	struct vmlogrdr_priv_t * priv = filp->private_data;
+	struct vmlogrdr_priv_t * priv = iocb->ki_filp->private_data;
 
 	while (priv->buffer_free) {
 		rc = vmlogrdr_receive_data(priv);
@@ -492,10 +491,10 @@ static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
 	if (count > priv->remaining)
 		count = priv->remaining;
 
-	if (copy_to_user(data, priv->current_position, count))
+	if (!copy_to_iter_full(priv->current_position, count, to))
 		return -EFAULT;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	priv->current_position += count;
 	priv->remaining -= count;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 353/437] arch/s390: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (351 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 352/437] s390: vmlogrdr: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 354/437] arch/sh: " Jens Axboe
                   ` (84 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/s390/crypto/prng.c      | 18 ++++++++----------
 arch/s390/hypfs/hypfs_dbfs.c | 11 +++++------
 arch/s390/kernel/debug.c     | 29 +++++++++++++----------------
 arch/s390/kernel/sysinfo.c   |  6 +++---
 arch/s390/pci/pci_debug.c    | 12 ++++++------
 5 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index a077087bc6cc..472ff3fe73a9 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -509,9 +509,9 @@ static int prng_open(struct inode *inode, struct file *file)
 }
 
 
-static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
-			      size_t nbytes, loff_t *ppos)
+static ssize_t prng_tdes_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t nbytes = iov_iter_count(to);
 	int chunk, n, ret = 0;
 
 	/* lock prng_data struct */
@@ -570,14 +570,13 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
 		prng_data->prngws.byte_counter += n;
 		prng_data->prngws.reseed_counter += n;
 
-		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
+		if (!copy_to_iter_full(prng_data->buf, chunk, to)) {
 			ret = -EFAULT;
 			break;
 		}
 
 		nbytes -= chunk;
 		ret += chunk;
-		ubuf += chunk;
 	}
 
 	/* unlock prng_data struct */
@@ -587,9 +586,9 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
 }
 
 
-static ssize_t prng_sha512_read(struct file *file, char __user *ubuf,
-				size_t nbytes, loff_t *ppos)
+static ssize_t prng_sha512_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t nbytes = iov_iter_count(to);
 	int n, ret = 0;
 	u8 *p;
 
@@ -640,12 +639,11 @@ static ssize_t prng_sha512_read(struct file *file, char __user *ubuf,
 				prng_data->rest = 0;
 			}
 		}
-		if (copy_to_user(ubuf, p, n)) {
+		if (!copy_to_iter_full(p, n, to)) {
 			ret = -EFAULT;
 			break;
 		}
 		memzero_explicit(p, n);
-		ubuf += n;
 		nbytes -= n;
 		ret += n;
 	}
@@ -663,14 +661,14 @@ static const struct file_operations prng_sha512_fops = {
 	.owner		= THIS_MODULE,
 	.open		= &prng_open,
 	.release	= NULL,
-	.read		= &prng_sha512_read,
+	.read_iter	= &prng_sha512_read,
 	.llseek		= noop_llseek,
 };
 static const struct file_operations prng_tdes_fops = {
 	.owner		= THIS_MODULE,
 	.open		= &prng_open,
 	.release	= NULL,
-	.read		= &prng_tdes_read,
+	.read_iter	= &prng_tdes_read,
 	.llseek		= noop_llseek,
 };
 
diff --git a/arch/s390/hypfs/hypfs_dbfs.c b/arch/s390/hypfs/hypfs_dbfs.c
index 4024599eb448..964247caf5fb 100644
--- a/arch/s390/hypfs/hypfs_dbfs.c
+++ b/arch/s390/hypfs/hypfs_dbfs.c
@@ -28,17 +28,16 @@ static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)
 	kfree(data);
 }
 
-static ssize_t dbfs_read(struct file *file, char __user *buf,
-			 size_t size, loff_t *ppos)
+static ssize_t dbfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct hypfs_dbfs_data *data;
 	struct hypfs_dbfs_file *df;
 	ssize_t rc;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
-	df = file_inode(file)->i_private;
+	df = file_inode(iocb->ki_filp)->i_private;
 	mutex_lock(&df->lock);
 	data = hypfs_dbfs_data_alloc(df);
 	if (!data) {
@@ -53,7 +52,7 @@ static ssize_t dbfs_read(struct file *file, char __user *buf,
 	}
 	mutex_unlock(&df->lock);
 
-	rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size);
+	rc = simple_copy_to_iter(data->buf, &iocb->ki_pos, data->size, to);
 	hypfs_dbfs_data_free(data);
 	return rc;
 }
@@ -73,7 +72,7 @@ static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 }
 
 static const struct file_operations dbfs_ops = {
-	.read		= dbfs_read,
+	.read_iter	= dbfs_read,
 	.llseek		= no_llseek,
 	.unlocked_ioctl = dbfs_ioctl,
 };
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 85328a0ef3b6..2ba1ee0a0f1d 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -66,10 +66,8 @@ typedef struct {
 /* internal function prototyes */
 
 static int debug_init(void);
-static ssize_t debug_output(struct file *file, char __user *user_buf,
-			    size_t user_len, loff_t *offset);
-static ssize_t debug_input(struct file *file, const char __user *user_buf,
-			   size_t user_len, loff_t *offset);
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t debug_input_iter(struct kiocb *iocb, struct iov_iter *from);
 static int debug_open(struct inode *inode, struct file *file);
 static int debug_close(struct inode *inode, struct file *file);
 static debug_info_t *debug_info_create(const char *name, int pages_per_area,
@@ -159,8 +157,8 @@ static int debug_critical;
 
 static const struct file_operations debug_file_ops = {
 	.owner	 = THIS_MODULE,
-	.read	 = debug_output,
-	.write	 = debug_input,
+	.read_iter	 = debug_output,
+	.write_iter	 = debug_input_iter,
 	.open	 = debug_open,
 	.release = debug_close,
 	.llseek  = no_llseek,
@@ -452,17 +450,15 @@ static inline int debug_next_entry(file_private_info_t *p_info)
  * - called for user read()
  * - copies formated debug entries to the user buffer
  */
-static ssize_t debug_output(struct file *file,		/* file descriptor */
-			    char __user *user_buf,	/* user buffer */
-			    size_t len,			/* length of buffer */
-			    loff_t *offset)		/* offset in the file */
+static ssize_t debug_output(struct kiocb *iocb, struct iov_iter *to)
 {
 	size_t count = 0;
 	size_t entry_offset;
 	file_private_info_t *p_info;
+	size_t len = iov_iter_count(to);
 
-	p_info = (file_private_info_t *) file->private_data;
-	if (*offset != p_info->offset)
+	p_info = (file_private_info_t *) iocb->ki_filp->private_data;
+	if (iocb->ki_pos != p_info->offset)
 		return -EPIPE;
 	if (p_info->act_area >= p_info->debug_info_snap->nr_areas)
 		return 0;
@@ -478,8 +474,8 @@ static ssize_t debug_output(struct file *file,		/* file descriptor */
 		user_buf_residue = len-count;
 		copy_size = min(user_buf_residue, formatted_line_residue);
 		if (copy_size) {
-			if (copy_to_user(user_buf + count, p_info->temp_buf
-					 + entry_offset, copy_size))
+			if (!copy_to_iter_full(p_info->temp_buf
+					 + entry_offset, copy_size, to))
 				return -EFAULT;
 			count += copy_size;
 			entry_offset += copy_size;
@@ -491,9 +487,9 @@ static ssize_t debug_output(struct file *file,		/* file descriptor */
 		}
 	}
 out:
-	p_info->offset		 = *offset + count;
+	p_info->offset		 = iocb->ki_pos + count;
 	p_info->act_entry_offset = entry_offset;
-	*offset = p_info->offset;
+	iocb->ki_pos = p_info->offset;
 	return count;
 }
 
@@ -520,6 +516,7 @@ static ssize_t debug_input(struct file *file, const char __user *user_buf,
 	mutex_unlock(&debug_mutex);
 	return rc; /* number of input characters */
 }
+FOPS_WRITE_ITER_HELPER(debug_input);
 
 /*
  * debug_open:
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index 2be30a96696a..84cca91e86ff 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -497,7 +497,7 @@ static int stsi_open_##fc##_##s1##_##s2(struct inode *inode, struct file *file)\
 static const struct file_operations stsi_##fc##_##s1##_##s2##_fs_ops = {       \
 	.open		= stsi_open_##fc##_##s1##_##s2,			       \
 	.release	= stsi_release,					       \
-	.read		= stsi_read,					       \
+	.read_iter	= stsi_read,					       \
 	.llseek		= no_llseek,					       \
 };
 
@@ -507,9 +507,9 @@ static int stsi_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t stsi_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
+static ssize_t stsi_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, size, ppos, file->private_data, PAGE_SIZE);
+	return simple_copy_to_iter(iocb->ki_filp->private_data, &iocb->ki_pos, PAGE_SIZE, to);
 }
 
 STSI_FILE( 1, 1, 1);
diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
index 2cb5043a997d..9c4b1eb26103 100644
--- a/arch/s390/pci/pci_debug.c
+++ b/arch/s390/pci/pci_debug.c
@@ -134,17 +134,17 @@ static int pci_perf_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
-				  size_t count, loff_t *off)
+static ssize_t pci_perf_seq_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct zpci_dev *zdev = ((struct seq_file *) file->private_data)->private;
+	struct zpci_dev *zdev = ((struct seq_file *) iocb->ki_filp->private_data)->private;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	int rc;
 
 	if (!zdev)
 		return 0;
 
-	rc = kstrtoul_from_user(ubuf, count, 10, &val);
+	rc = kstrtoul_from_iter(from, count, 10, &val);
 	if (rc)
 		return rc;
 
@@ -169,8 +169,8 @@ static int pci_perf_seq_open(struct inode *inode, struct file *filp)
 
 static const struct file_operations debugfs_pci_perf_fops = {
 	.open	 = pci_perf_seq_open,
-	.read	 = seq_read,
-	.write	 = pci_perf_seq_write,
+	.read_iter = seq_read_iter,
+	.write_iter = pci_perf_seq_write,
 	.llseek  = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 354/437] arch/sh: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (352 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 353/437] arch/s390: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 355/437] arch/um: " Jens Axboe
                   ` (83 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/sh/mm/tlb-debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/mm/tlb-debugfs.c b/arch/sh/mm/tlb-debugfs.c
index 11c6148283f3..2ebb9db3ffa5 100644
--- a/arch/sh/mm/tlb-debugfs.c
+++ b/arch/sh/mm/tlb-debugfs.c
@@ -142,7 +142,7 @@ static int tlb_debugfs_open(struct inode *inode, struct file *file)
 static const struct file_operations tlb_debugfs_fops = {
 	.owner		= THIS_MODULE,
 	.open		= tlb_debugfs_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 355/437] arch/um: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (353 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 354/437] arch/sh: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 356/437] arch/sparc: " Jens Axboe
                   ` (82 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/um/drivers/harddog_kern.c   |  6 +++---
 arch/um/drivers/hostaudio_kern.c | 22 +++++++++++-----------
 arch/um/drivers/mmapper_kern.c   | 16 +++++++---------
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index 60d1c6cab8a9..77fa33f229f2 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -109,9 +109,9 @@ static int harddog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t harddog_write(struct file *file, const char __user *data, size_t len,
-			     loff_t *ppos)
+static ssize_t harddog_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	/*
 	 *	Refresh the timer.
 	 */
@@ -158,7 +158,7 @@ static long harddog_ioctl(struct file *file,
 
 static const struct file_operations harddog_fops = {
 	.owner		= THIS_MODULE,
-	.write		= harddog_write,
+	.write_iter	= harddog_write,
 	.unlocked_ioctl	= harddog_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= harddog_open,
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index c42b793bce65..8ea3bb32867c 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -67,10 +67,10 @@ static DEFINE_MUTEX(hostaudio_mutex);
 
 /* /dev/dsp file operations */
 
-static ssize_t hostaudio_read(struct file *file, char __user *buffer,
-			      size_t count, loff_t *ppos)
+static ssize_t hostaudio_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hostaudio_state *state = file->private_data;
+	struct hostaudio_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	void *kbuf;
 	int err;
 
@@ -86,7 +86,7 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
 	if (err < 0)
 		goto out;
 
-	if (copy_to_user(buffer, kbuf, err))
+	if (!copy_to_iter_full(kbuf, err, to))
 		err = -EFAULT;
 
 out:
@@ -94,10 +94,10 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
 	return err;
 }
 
-static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
-			       size_t count, loff_t *ppos)
+static ssize_t hostaudio_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hostaudio_state *state = file->private_data;
+	struct hostaudio_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	void *kbuf;
 	int err;
 
@@ -105,14 +105,14 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
 	printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
 #endif
 
-	kbuf = memdup_user(buffer, count);
+	kbuf = iterdup(from, count);
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
 
 	err = os_write_file(state->fd, kbuf, count);
 	if (err < 0)
 		goto out;
-	*ppos += err;
+	iocb->ki_pos += err;
 
  out:
 	kfree(kbuf);
@@ -292,8 +292,8 @@ static int hostmixer_release(struct inode *inode, struct file *file)
 static const struct file_operations hostaudio_fops = {
 	.owner          = THIS_MODULE,
 	.llseek         = no_llseek,
-	.read           = hostaudio_read,
-	.write          = hostaudio_write,
+	.read_iter      = hostaudio_read,
+	.write_iter     = hostaudio_write,
 	.poll           = hostaudio_poll,
 	.unlocked_ioctl	= hostaudio_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 807cd3358740..db66090177d4 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -26,19 +26,17 @@ static unsigned long mmapper_size;
 static unsigned long p_buf;
 static char *v_buf;
 
-static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *ppos)
+static ssize_t mmapper_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
+	return simple_copy_to_iter(v_buf, &iocb->ki_pos, mmapper_size, to);
 }
 
-static ssize_t mmapper_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *ppos)
+static ssize_t mmapper_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	if (*ppos > mmapper_size)
+	if (iocb->ki_pos > mmapper_size)
 		return -EINVAL;
 
-	return simple_write_to_buffer(v_buf, mmapper_size, ppos, buf, count);
+	return simple_copy_from_iter(v_buf, &iocb->ki_pos,  mmapper_size, from);
 }
 
 static long mmapper_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -82,8 +80,8 @@ static int mmapper_release(struct inode *inode, struct file *file)
 
 static const struct file_operations mmapper_fops = {
 	.owner		= THIS_MODULE,
-	.read		= mmapper_read,
-	.write		= mmapper_write,
+	.read_iter	= mmapper_read,
+	.write_iter	= mmapper_write,
 	.unlocked_ioctl	= mmapper_ioctl,
 	.mmap		= mmapper_mmap,
 	.open		= mmapper_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 356/437] arch/sparc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (354 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 355/437] arch/um: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 357/437] samples/vfio-mdev: " Jens Axboe
                   ` (81 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 arch/sparc/kernel/mdesc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 30f171b7b00c..bcc3afbc8760 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -1261,24 +1261,24 @@ static int mdesc_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t mdesc_read(struct file *file, char __user *buf,
-			  size_t len, loff_t *offp)
+static ssize_t mdesc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mdesc_handle *hp = file->private_data;
+	struct mdesc_handle *hp = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	unsigned char *mdesc;
 	int bytes_left, count = len;
 
-	if (*offp >= hp->handle_size)
+	if (iocb->ki_pos >= hp->handle_size)
 		return 0;
 
-	bytes_left = hp->handle_size - *offp;
+	bytes_left = hp->handle_size - iocb->ki_pos;
 	if (count > bytes_left)
 		count = bytes_left;
 
 	mdesc = (unsigned char *)&hp->mdesc;
-	mdesc += *offp;
-	if (!copy_to_user(buf, mdesc, count)) {
-		*offp += count;
+	mdesc += iocb->ki_pos;
+	if (!copy_to_iter_full(mdesc, count, to)) {
+		iocb->ki_pos += count;
 		return count;
 	} else {
 		return -EFAULT;
@@ -1303,7 +1303,7 @@ static int mdesc_close(struct inode *inode, struct file *file)
 
 static const struct file_operations mdesc_fops = {
 	.open    = mdesc_open,
-	.read	 = mdesc_read,
+	.read_iter	 = mdesc_read,
 	.llseek  = mdesc_llseek,
 	.release = mdesc_close,
 	.owner	 = THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 357/437] samples/vfio-mdev: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (355 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 356/437] arch/sparc: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 358/437] hwmon: fschmd: " Jens Axboe
                   ` (80 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 samples/vfio-mdev/mtty.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 2284b3751240..b7b9c39a0497 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -881,16 +881,17 @@ static long mtty_precopy_ioctl(struct file *filp, unsigned int cmd,
 	return ret;
 }
 
-static ssize_t mtty_save_read(struct file *filp, char __user *buf,
-			      size_t len, loff_t *pos)
+static ssize_t mtty_save_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mtty_migration_file *migf = filp->private_data;
+	struct mtty_migration_file *migf = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret = 0;
+	loff_t *pos;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
 
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	mutex_lock(&migf->lock);
 
@@ -908,7 +909,7 @@ static ssize_t mtty_save_read(struct file *filp, char __user *buf,
 
 	len = min_t(size_t, migf->filled_size - *pos, len);
 	if (len) {
-		if (copy_to_user(buf, (void *)&migf->data + *pos, len)) {
+		if (!copy_to_iter_full((void *)&migf->data + *pos, len, to)) {
 			ret = -EFAULT;
 			goto out_unlock;
 		}
@@ -923,7 +924,7 @@ static ssize_t mtty_save_read(struct file *filp, char __user *buf,
 
 static const struct file_operations mtty_save_fops = {
 	.owner = THIS_MODULE,
-	.read = mtty_save_read,
+	.read_iter = mtty_save_read,
 	.unlocked_ioctl = mtty_precopy_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.release = mtty_release_migf,
@@ -1018,18 +1019,19 @@ mtty_save_device_data(struct mdev_state *mdev_state,
 	return ret;
 }
 
-static ssize_t mtty_resume_write(struct file *filp, const char __user *buf,
-				 size_t len, loff_t *pos)
+static ssize_t mtty_resume_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mtty_migration_file *migf = filp->private_data;
+	struct mtty_migration_file *migf = iocb->ki_filp->private_data;
 	struct mdev_state *mdev_state = migf->mdev_state;
+	size_t len = iov_iter_count(from);
 	loff_t requested_length;
 	ssize_t ret = 0;
+	loff_t *pos;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
 
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	if (*pos < 0 ||
 	    check_add_overflow((loff_t)len, *pos, &requested_length))
@@ -1045,7 +1047,7 @@ static ssize_t mtty_resume_write(struct file *filp, const char __user *buf,
 		goto out_unlock;
 	}
 
-	if (copy_from_user((void *)&migf->data + *pos, buf, len)) {
+	if (!copy_from_iter_full((void *)&migf->data + *pos, len, from)) {
 		ret = -EFAULT;
 		goto out_unlock;
 	}
@@ -1080,7 +1082,7 @@ static ssize_t mtty_resume_write(struct file *filp, const char __user *buf,
 
 static const struct file_operations mtty_resume_fops = {
 	.owner = THIS_MODULE,
-	.write = mtty_resume_write,
+	.write_iter = mtty_resume_write,
 	.release = mtty_release_migf,
 	.llseek = no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 358/437] hwmon: fschmd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (356 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 357/437] samples/vfio-mdev: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 359/437] hwmon: w83793: " Jens Axboe
                   ` (79 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/fschmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index b30512a705a7..896a073811a0 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -848,11 +848,11 @@ static int watchdog_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t watchdog_write(struct file *filp, const char __user *buf,
-	size_t count, loff_t *offset)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
-	struct fschmd_data *data = filp->private_data;
+	struct fschmd_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (count) {
 		if (!nowayout) {
@@ -863,7 +863,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					data->watchdog_expect_close = 1;
@@ -951,7 +951,7 @@ static const struct file_operations watchdog_fops = {
 	.llseek = no_llseek,
 	.open = watchdog_open,
 	.release = watchdog_release,
-	.write = watchdog_write,
+	.write_iter = watchdog_write,
 	.unlocked_ioctl = watchdog_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 359/437] hwmon: w83793: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (357 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 358/437] hwmon: fschmd: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 360/437] hwmon: asus_atk0110: " Jens Axboe
                   ` (78 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/w83793.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 96bab94ba899..7594fc588112 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1352,11 +1352,11 @@ static int watchdog_close(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t watchdog_write(struct file *filp, const char __user *buf,
-	size_t count, loff_t *offset)
+static ssize_t watchdog_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	ssize_t ret;
-	struct w83793_data *data = filp->private_data;
+	struct w83793_data *data = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	if (count) {
 		if (!nowayout) {
@@ -1367,7 +1367,7 @@ static ssize_t watchdog_write(struct file *filp, const char __user *buf,
 
 			for (i = 0; i != count; i++) {
 				char c;
-				if (get_user(c, buf + i))
+				if (get_iter(c, from))
 					return -EFAULT;
 				if (c == 'V')
 					data->watchdog_expect_close = 1;
@@ -1454,7 +1454,7 @@ static const struct file_operations watchdog_fops = {
 	.llseek = no_llseek,
 	.open = watchdog_open,
 	.release = watchdog_close,
-	.write = watchdog_write,
+	.write_iter = watchdog_write,
 	.unlocked_ioctl = watchdog_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 360/437] hwmon: asus_atk0110: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (358 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 359/437] hwmon: w83793: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 361/437] hwmon: mr75203: " Jens Axboe
                   ` (77 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/asus_atk0110.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index d778a2aaefec..bd6eabfd7d73 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -764,13 +764,12 @@ static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t atk_debugfs_ggrp_read(struct file *file, char __user *buf,
-		size_t count, loff_t *pos)
+static ssize_t atk_debugfs_ggrp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char *str = file->private_data;
+	char *str = iocb->ki_filp->private_data;
 	size_t len = strlen(str);
 
-	return simple_read_from_buffer(buf, count, pos, str, len);
+	return simple_copy_to_iter(str, &iocb->ki_pos, len, to);
 }
 
 static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file)
@@ -780,7 +779,7 @@ static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations atk_debugfs_ggrp_fops = {
-	.read		= atk_debugfs_ggrp_read,
+	.read_iter	= atk_debugfs_ggrp_read,
 	.open		= atk_debugfs_ggrp_open,
 	.release	= atk_debugfs_ggrp_release,
 	.llseek		= no_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 361/437] hwmon: mr75203: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (359 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 360/437] hwmon: asus_atk0110: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 362/437] hwmon: acbel-fsg032: " Jens Axboe
                   ` (76 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/mr75203.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
index 50a8b9c3f94d..a2de0954b4e6 100644
--- a/drivers/hwmon/mr75203.c
+++ b/drivers/hwmon/mr75203.c
@@ -182,26 +182,24 @@ struct pvt_device {
 	u32			ip_freq;
 };
 
-static ssize_t pvt_ts_coeff_j_read(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t pvt_ts_coeff_j_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct pvt_device *pvt = file->private_data;
+	struct pvt_device *pvt = iocb->ki_filp->private_data;
 	unsigned int len;
 	char buf[13];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", pvt->ts_coeff.j);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t pvt_ts_coeff_j_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t pvt_ts_coeff_j_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct pvt_device *pvt = file->private_data;
+	struct pvt_device *pvt = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	ret = kstrtos32_from_user(user_buf, count, 0, &pvt->ts_coeff.j);
+	ret = kstrtos32_from_iter(from, count, 0, &pvt->ts_coeff.j);
 	if (ret)
 		return ret;
 
@@ -209,8 +207,8 @@ static ssize_t pvt_ts_coeff_j_write(struct file *file,
 }
 
 static const struct file_operations pvt_ts_coeff_j_fops = {
-	.read = pvt_ts_coeff_j_read,
-	.write = pvt_ts_coeff_j_write,
+	.read_iter = pvt_ts_coeff_j_read,
+	.write_iter = pvt_ts_coeff_j_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 362/437] hwmon: acbel-fsg032: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (360 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 361/437] hwmon: mr75203: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 363/437] hwmon: ibm-cffps: " Jens Axboe
                   ` (75 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/acbel-fsg032.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c
index e0c55fd8f3a6..cc8fec9d1ea1 100644
--- a/drivers/hwmon/pmbus/acbel-fsg032.c
+++ b/drivers/hwmon/pmbus/acbel-fsg032.c
@@ -15,10 +15,9 @@
 
 #define ACBEL_MFR_FW_REVISION	0xd9
 
-static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count,
-					 loff_t *ppos)
+static ssize_t acbel_fsg032_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct i2c_client *client = file->private_data;
+	struct i2c_client *client = iocb->ki_filp->private_data;
 	u8 data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
 	char out[8];
 	int rc;
@@ -28,13 +27,12 @@ static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, si
 		return rc;
 
 	rc = snprintf(out, sizeof(out), "%*phN\n", min(rc, 3), data);
-	return simple_read_from_buffer(buf, count, ppos, out, rc);
+	return simple_copy_to_iter(out, &iocb->ki_pos, rc, to);
 }
 
 static const struct file_operations acbel_debugfs_ops = {
 	.llseek = noop_llseek,
-	.read = acbel_fsg032_debugfs_read,
-	.write = NULL,
+	.read_iter = acbel_fsg032_debugfs_read,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 363/437] hwmon: ibm-cffps: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (361 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 362/437] hwmon: acbel-fsg032: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 364/437] hwmon: max20730: " Jens Axboe
                   ` (74 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/ibm-cffps.c | 35 +++++++++++++++------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index 1ba4c5e95820..b64875cf6d60 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -75,12 +75,12 @@ struct ibm_cffps {
 
 #define to_psu(x, y) container_of((x), struct ibm_cffps, debugfs_entries[(y)])
 
-static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __user *buf,
-						    size_t count, loff_t *ppos)
+static ssize_t ibm_cffps_debugfs_read_input_history(struct kiocb *iocb,
+						    struct iov_iter *to)
 {
 	int rc;
 	u8 cmd = CFFPS_INPUT_HISTORY_CMD;
-	struct ibm_cffps *psu = file->private_data;
+	struct ibm_cffps *psu = iocb->ki_filp->private_data;
 	struct i2c_msg msg[2] = {
 		{
 			.addr = psu->client->addr,
@@ -95,7 +95,7 @@ static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __us
 		},
 	};
 
-	if (!*ppos) {
+	if (!iocb->ki_pos) {
 		rc = pmbus_lock_interruptible(psu->client);
 		if (rc)
 			return rc;
@@ -116,22 +116,20 @@ static ssize_t ibm_cffps_debugfs_read_input_history(struct file *file, char __us
 			return rc;
 	}
 
-	return simple_read_from_buffer(buf, count, ppos,
-				       psu->input_history + 1,
-				       psu->input_history[0]);
+	return simple_copy_to_iter(psu->input_history + 1, &iocb->ki_pos,
+				   psu->input_history[0], to);
 }
 
 static const struct file_operations ibm_cffps_input_history_fops = {
 	.llseek = noop_llseek,
-	.read = ibm_cffps_debugfs_read_input_history,
+	.read_iter = ibm_cffps_debugfs_read_input_history,
 	.open = simple_open,
 };
 
-static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ibm_cffps_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int i, rc;
-	int *idxp = file->private_data;
+	int *idxp = iocb->ki_filp->private_data;
 	int idx = *idxp;
 	struct ibm_cffps *psu = to_psu(idxp, idx);
 	char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
@@ -205,22 +203,21 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
 	data[rc] = '\n';
 	rc += 2;
 
-	return simple_read_from_buffer(buf, count, ppos, data, rc);
+	return simple_copy_to_iter(data, &iocb->ki_pos, rc, to);
 }
 
-static ssize_t ibm_cffps_debugfs_write(struct file *file,
-				       const char __user *buf, size_t count,
-				       loff_t *ppos)
+static ssize_t ibm_cffps_debugfs_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	u8 data;
 	ssize_t rc;
-	int *idxp = file->private_data;
+	int *idxp = iocb->ki_filp->private_data;
 	int idx = *idxp;
 	struct ibm_cffps *psu = to_psu(idxp, idx);
 
 	switch (idx) {
 	case CFFPS_DEBUGFS_ON_OFF_CONFIG:
-		rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
+		rc = simple_copy_from_iter(&data, &iocb->ki_pos, 1, from);
 		if (rc <= 0)
 			return rc;
 
@@ -250,8 +247,8 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file,
 
 static const struct file_operations ibm_cffps_fops = {
 	.llseek = noop_llseek,
-	.read = ibm_cffps_debugfs_read,
-	.write = ibm_cffps_debugfs_write,
+	.read_iter = ibm_cffps_debugfs_read,
+	.write_iter = ibm_cffps_debugfs_write,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 364/437] hwmon: max20730: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (362 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 363/437] hwmon: ibm-cffps: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 365/437] hwmon: pmbus: core: " Jens Axboe
                   ` (73 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/max20730.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/pmbus/max20730.c b/drivers/hwmon/pmbus/max20730.c
index d56ec24764fd..9b0c6084cf12 100644
--- a/drivers/hwmon/pmbus/max20730.c
+++ b/drivers/hwmon/pmbus/max20730.c
@@ -104,11 +104,10 @@ struct max20730_debugfs_data {
 			struct max20730_debugfs_data, debugfs_entries[(y)])
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t max20730_debugfs_read(struct file *file, char __user *buf,
-				     size_t count, loff_t *ppos)
+static ssize_t max20730_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret, len;
-	int *idxp = file->private_data;
+	int *idxp = iocb->ki_filp->private_data;
 	int idx = *idxp;
 	struct max20730_debugfs_data *psu = to_psu(idxp, idx);
 	const struct pmbus_driver_info *info;
@@ -292,13 +291,12 @@ static ssize_t max20730_debugfs_read(struct file *file, char __user *buf,
 	}
 
 	len = strlen(result);
-	return simple_read_from_buffer(buf, count, ppos, result, len);
+	return simple_copy_to_iter(result, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations max20730_fops = {
 	.llseek = noop_llseek,
-	.read = max20730_debugfs_read,
-	.write = NULL,
+	.read_iter = max20730_debugfs_read,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 365/437] hwmon: pmbus: core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (363 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 364/437] hwmon: max20730: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 366/437] hwmon: q54sj108a2: " Jens Axboe
                   ` (72 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/pmbus_core.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index cb4c65a7f288..39b340024c28 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -3303,11 +3303,10 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status,
 			 NULL, "0x%04llx\n");
 
-static ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf,
-				       size_t count, loff_t *ppos)
+static ssize_t pmbus_debugfs_mfr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rc;
-	struct pmbus_debugfs_entry *entry = file->private_data;
+	struct pmbus_debugfs_entry *entry = iocb->ki_filp->private_data;
 	struct pmbus_data *pdata = i2c_get_clientdata(entry->client);
 	char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
 
@@ -3326,13 +3325,12 @@ static ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf,
 	/* Include newline into the length */
 	rc += 1;
 
-	return simple_read_from_buffer(buf, count, ppos, data, rc);
+	return simple_copy_to_iter(data, &iocb->ki_pos, rc, to);
 }
 
 static const struct file_operations pmbus_debugfs_ops_mfr = {
 	.llseek = noop_llseek,
-	.read = pmbus_debugfs_mfr_read,
-	.write = NULL,
+	.read_iter = pmbus_debugfs_mfr_read,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 366/437] hwmon: q54sj108a2: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (364 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 365/437] hwmon: pmbus: core: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 367/437] hwmon: ucd9000: " Jens Axboe
                   ` (71 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/q54sj108a2.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pmbus/q54sj108a2.c b/drivers/hwmon/pmbus/q54sj108a2.c
index a235c1cdf4fe..12634ede2c50 100644
--- a/drivers/hwmon/pmbus/q54sj108a2.c
+++ b/drivers/hwmon/pmbus/q54sj108a2.c
@@ -70,11 +70,10 @@ static struct pmbus_driver_info q54sj108a2_info[] = {
 	},
 };
 
-static ssize_t q54sj108a2_debugfs_read(struct file *file, char __user *buf,
-				       size_t count, loff_t *ppos)
+static ssize_t q54sj108a2_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rc;
-	int *idxp = file->private_data;
+	int *idxp = iocb->ki_filp->private_data;
 	int idx = *idxp;
 	struct q54sj108a2_data *psu = to_psu(idxp, idx);
 	char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
@@ -169,18 +168,18 @@ static ssize_t q54sj108a2_debugfs_read(struct file *file, char __user *buf,
 	data[rc] = '\n';
 	rc += 2;
 
-	return simple_read_from_buffer(buf, count, ppos, data, rc);
+	return simple_copy_to_iter(data, &iocb->ki_pos, rc, to);
 }
 
-static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *ppos)
+static ssize_t q54sj108a2_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	u8 flash_key[4];
 	u8 dst_data;
 	ssize_t rc;
-	int *idxp = file->private_data;
+	int *idxp = iocb->ki_filp->private_data;
 	int idx = *idxp;
 	struct q54sj108a2_data *psu = to_psu(idxp, idx);
+	size_t count = iov_iter_count(from);
 
 	rc = i2c_smbus_write_byte_data(psu->client, PMBUS_WRITE_PROTECT, 0);
 	if (rc)
@@ -188,7 +187,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bu
 
 	switch (idx) {
 	case Q54SJ108A2_DEBUGFS_OPERATION:
-		rc = kstrtou8_from_user(buf, count, 0, &dst_data);
+		rc = kstrtou8_from_iter(from, count, 0, &dst_data);
 		if (rc < 0)
 			return rc;
 
@@ -218,7 +217,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bu
 
 		break;
 	case Q54SJ108A2_DEBUGFS_VOOV_RESPONSE:
-		rc = kstrtou8_from_user(buf, count, 0, &dst_data);
+		rc = kstrtou8_from_iter(from, count, 0, &dst_data);
 		if (rc < 0)
 			return rc;
 
@@ -228,7 +227,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bu
 
 		break;
 	case Q54SJ108A2_DEBUGFS_IOOC_RESPONSE:
-		rc = kstrtou8_from_user(buf, count, 0, &dst_data);
+		rc = kstrtou8_from_iter(from, count, 0, &dst_data);
 		if (rc < 0)
 			return rc;
 
@@ -244,7 +243,7 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bu
 
 		break;
 	case Q54SJ108A2_DEBUGFS_BLACKBOX_SET_OFFSET:
-		rc = kstrtou8_from_user(buf, count, 0, &dst_data);
+		rc = kstrtou8_from_iter(from, count, 0, &dst_data);
 		if (rc < 0)
 			return rc;
 
@@ -262,8 +261,8 @@ static ssize_t q54sj108a2_debugfs_write(struct file *file, const char __user *bu
 
 static const struct file_operations q54sj108a2_fops = {
 	.llseek = noop_llseek,
-	.read = q54sj108a2_debugfs_read,
-	.write = q54sj108a2_debugfs_write,
+	.read_iter = q54sj108a2_debugfs_read,
+	.write_iter = q54sj108a2_debugfs_write,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 367/437] hwmon: ucd9000: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (365 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 366/437] hwmon: q54sj108a2: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 368/437] hwmon: pt5161l: " Jens Axboe
                   ` (70 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pmbus/ucd9000.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
index 8d9d422450e5..204c836fa322 100644
--- a/drivers/hwmon/pmbus/ucd9000.c
+++ b/drivers/hwmon/pmbus/ucd9000.c
@@ -471,11 +471,10 @@ static int ucd9000_debugfs_show_mfr_status_bit(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(ucd9000_debugfs_mfr_status_bit,
 			 ucd9000_debugfs_show_mfr_status_bit, NULL, "%1lld\n");
 
-static ssize_t ucd9000_debugfs_read_mfr_status(struct file *file,
-					       char __user *buf, size_t count,
-					       loff_t *ppos)
+static ssize_t ucd9000_debugfs_read_mfr_status(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct i2c_client *client = file->private_data;
+	struct i2c_client *client = iocb->ki_filp->private_data;
 	u8 buffer[I2C_SMBUS_BLOCK_MAX];
 	char str[(I2C_SMBUS_BLOCK_MAX * 2) + 2];
 	char *res;
@@ -489,12 +488,12 @@ static ssize_t ucd9000_debugfs_read_mfr_status(struct file *file,
 	*res++ = '\n';
 	*res = 0;
 
-	return simple_read_from_buffer(buf, count, ppos, str, res - str);
+	return simple_copy_to_iter(str, &iocb->ki_pos, res - str, to);
 }
 
 static const struct file_operations ucd9000_debugfs_show_mfr_status_fops = {
 	.llseek = noop_llseek,
-	.read = ucd9000_debugfs_read_mfr_status,
+	.read_iter = ucd9000_debugfs_read_mfr_status,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 368/437] hwmon: pt5161l: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (366 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 367/437] hwmon: ucd9000: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 369/437] drivers/mmc: " Jens Axboe
                   ` (69 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwmon/pt5161l.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/hwmon/pt5161l.c b/drivers/hwmon/pt5161l.c
index 60361e39c474..90cb27822ac0 100644
--- a/drivers/hwmon/pt5161l.c
+++ b/drivers/hwmon/pt5161l.c
@@ -493,10 +493,10 @@ static const struct hwmon_chip_info pt5161l_chip_info = {
 	.info = pt5161l_info,
 };
 
-static ssize_t pt5161l_debugfs_read_fw_ver(struct file *file, char __user *buf,
-					   size_t count, loff_t *ppos)
+static ssize_t pt5161l_debugfs_read_fw_ver(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct pt5161l_data *data = file->private_data;
+	struct pt5161l_data *data = iocb->ki_filp->private_data;
 	int ret;
 	char ver[32];
 
@@ -509,19 +509,18 @@ static ssize_t pt5161l_debugfs_read_fw_ver(struct file *file, char __user *buf,
 	ret = snprintf(ver, sizeof(ver), "%u.%u.%u\n", data->fw_ver.major,
 		       data->fw_ver.minor, data->fw_ver.build);
 
-	return simple_read_from_buffer(buf, count, ppos, ver, ret);
+	return simple_copy_to_iter(ver, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations pt5161l_debugfs_ops_fw_ver = {
-	.read = pt5161l_debugfs_read_fw_ver,
+	.read_iter = pt5161l_debugfs_read_fw_ver,
 	.open = simple_open,
 };
 
-static ssize_t pt5161l_debugfs_read_fw_load_sts(struct file *file,
-						char __user *buf, size_t count,
-						loff_t *ppos)
+static ssize_t pt5161l_debugfs_read_fw_load_sts(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct pt5161l_data *data = file->private_data;
+	struct pt5161l_data *data = iocb->ki_filp->private_data;
 	int ret;
 	bool status = false;
 	char health[16];
@@ -535,18 +534,18 @@ static ssize_t pt5161l_debugfs_read_fw_load_sts(struct file *file,
 	ret = snprintf(health, sizeof(health), "%s\n",
 		       status ? "normal" : "abnormal");
 
-	return simple_read_from_buffer(buf, count, ppos, health, ret);
+	return simple_copy_to_iter(health, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations pt5161l_debugfs_ops_fw_load_sts = {
-	.read = pt5161l_debugfs_read_fw_load_sts,
+	.read_iter = pt5161l_debugfs_read_fw_load_sts,
 	.open = simple_open,
 };
 
-static ssize_t pt5161l_debugfs_read_hb_sts(struct file *file, char __user *buf,
-					   size_t count, loff_t *ppos)
+static ssize_t pt5161l_debugfs_read_hb_sts(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct pt5161l_data *data = file->private_data;
+	struct pt5161l_data *data = iocb->ki_filp->private_data;
 	int ret;
 	bool status = false;
 	char health[16];
@@ -560,11 +559,11 @@ static ssize_t pt5161l_debugfs_read_hb_sts(struct file *file, char __user *buf,
 	ret = snprintf(health, sizeof(health), "%s\n",
 		       status ? "normal" : "abnormal");
 
-	return simple_read_from_buffer(buf, count, ppos, health, ret);
+	return simple_copy_to_iter(health, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations pt5161l_debugfs_ops_hb_sts = {
-	.read = pt5161l_debugfs_read_hb_sts,
+	.read_iter = pt5161l_debugfs_read_hb_sts,
 	.open = simple_open,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 369/437] drivers/mmc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (367 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 368/437] hwmon: pt5161l: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 370/437] drivers/most: " Jens Axboe
                   ` (68 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/mmc/core/block.c    | 10 ++++------
 drivers/mmc/core/debugfs.c  | 11 +++++------
 drivers/mmc/core/mmc_test.c | 12 ++++++------
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 90c51b12148e..490cf789de72 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2933,13 +2933,11 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
 	return err;
 }
 
-static ssize_t mmc_ext_csd_read(struct file *filp, char __user *ubuf,
-				size_t cnt, loff_t *ppos)
+static ssize_t mmc_ext_csd_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char *buf = filp->private_data;
+	char *buf = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(ubuf, cnt, ppos,
-				       buf, EXT_CSD_STR_LEN);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, EXT_CSD_STR_LEN, to);
 }
 
 static int mmc_ext_csd_release(struct inode *inode, struct file *file)
@@ -2950,7 +2948,7 @@ static int mmc_ext_csd_release(struct inode *inode, struct file *file)
 
 static const struct file_operations mmc_dbg_ext_csd_fops = {
 	.open		= mmc_ext_csd_open,
-	.read		= mmc_ext_csd_read,
+	.read_iter	= mmc_ext_csd_read,
 	.release	= mmc_ext_csd_release,
 	.llseek		= default_llseek,
 };
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 1642ea72d22c..37aa1529f4f8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -283,21 +283,20 @@ static int mmc_err_stats_open(struct inode *inode, struct file *file)
 	return single_open(file, mmc_err_stats_show, inode->i_private);
 }
 
-static ssize_t mmc_err_stats_write(struct file *filp, const char __user *ubuf,
-				   size_t cnt, loff_t *ppos)
+static ssize_t mmc_err_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mmc_host *host = filp->f_mapping->host->i_private;
+	struct mmc_host *host = iocb->ki_filp->f_mapping->host->i_private;
 
 	pr_debug("%s: Resetting MMC error statistics\n", __func__);
 	memset(host->err_stats, 0, sizeof(host->err_stats));
 
-	return cnt;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations mmc_err_stats_fops = {
 	.open	= mmc_err_stats_open,
-	.read	= seq_read,
-	.write	= mmc_err_stats_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= mmc_err_stats_write,
 	.release = single_release,
 };
 
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index 8f7f587a0025..6bbec9154f8a 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -3097,16 +3097,16 @@ static int mtf_test_open(struct inode *inode, struct file *file)
 	return single_open(file, mtf_test_show, inode->i_private);
 }
 
-static ssize_t mtf_test_write(struct file *file, const char __user *buf,
-	size_t count, loff_t *pos)
+static ssize_t mtf_test_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sf = file->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mmc_card *card = sf->private;
 	struct mmc_test_card *test;
 	long testcase;
 	int ret;
 
-	ret = kstrtol_from_user(buf, count, 10, &testcase);
+	ret = kstrtol_from_iter(from, count, 10, &testcase);
 	if (ret)
 		return ret;
 
@@ -3148,8 +3148,8 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 
 static const struct file_operations mmc_test_fops_test = {
 	.open		= mtf_test_open,
-	.read		= seq_read,
-	.write		= mtf_test_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= mtf_test_write,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 370/437] drivers/most: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (368 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 369/437] drivers/mmc: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 371/437] drivers/ntb: " Jens Axboe
                   ` (67 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/most/most_cdev.c | 50 ++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 30 deletions(-)

diff --git a/drivers/most/most_cdev.c b/drivers/most/most_cdev.c
index 3ed8f461e01e..1653f23caef4 100644
--- a/drivers/most/most_cdev.c
+++ b/drivers/most/most_cdev.c
@@ -174,24 +174,22 @@ static int comp_close(struct inode *inode, struct file *filp)
 
 /**
  * comp_write - implements the syscall to write to the device
- * @filp: file pointer
- * @buf: pointer to user buffer
- * @count: number of bytes to write
- * @offset: offset from where to start writing
+ * @iocb: metadata for IO
+ * @from: pointer to user buffer
  */
-static ssize_t comp_write(struct file *filp, const char __user *buf,
-			  size_t count, loff_t *offset)
+static ssize_t comp_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret;
-	size_t to_copy, left;
+	size_t to_copy;
 	struct mbo *mbo = NULL;
-	struct comp_channel *c = filp->private_data;
+	struct comp_channel *c = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 
 	mutex_lock(&c->io_mutex);
 	while (c->dev && !ch_get_mbo(c, &mbo)) {
 		mutex_unlock(&c->io_mutex);
 
-		if ((filp->f_flags & O_NONBLOCK))
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		if (wait_event_interruptible(c->wq, ch_has_mbo(c) || !c->dev))
 			return -ERESTARTSYS;
@@ -204,13 +202,13 @@ static ssize_t comp_write(struct file *filp, const char __user *buf,
 	}
 
 	to_copy = min(count, c->cfg->buffer_size - c->mbo_offs);
-	left = copy_from_user(mbo->virt_address + c->mbo_offs, buf, to_copy);
-	if (left == to_copy) {
+	ret = copy_from_iter(mbo->virt_address + c->mbo_offs, to_copy, from);
+	if (ret != to_copy) {
 		ret = -EFAULT;
 		goto unlock;
 	}
 
-	c->mbo_offs += to_copy - left;
+	c->mbo_offs += ret;
 	if (c->mbo_offs >= c->cfg->buffer_size ||
 	    c->cfg->data_type == MOST_CH_CONTROL ||
 	    c->cfg->data_type == MOST_CH_ASYNC) {
@@ -219,8 +217,6 @@ static ssize_t comp_write(struct file *filp, const char __user *buf,
 		c->mbo_offs = 0;
 		most_submit_mbo(mbo);
 	}
-
-	ret = to_copy - left;
 unlock:
 	mutex_unlock(&c->io_mutex);
 	return ret;
@@ -228,22 +224,20 @@ static ssize_t comp_write(struct file *filp, const char __user *buf,
 
 /**
  * comp_read - implements the syscall to read from the device
- * @filp: file pointer
- * @buf: pointer to user buffer
- * @count: number of bytes to read
- * @offset: offset from where to start reading
+ * @iocb: metadata for IO
+ * @to: pointer to user buffer
  */
-static ssize_t
-comp_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
+static ssize_t comp_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	size_t to_copy, not_copied, copied;
+	size_t to_copy, copied;
 	struct mbo *mbo = NULL;
-	struct comp_channel *c = filp->private_data;
+	struct comp_channel *c = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	mutex_lock(&c->io_mutex);
 	while (c->dev && !kfifo_peek(&c->fifo, &mbo)) {
 		mutex_unlock(&c->io_mutex);
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		if (wait_event_interruptible(c->wq,
 					     (!kfifo_is_empty(&c->fifo) ||
@@ -262,11 +256,7 @@ comp_read(struct file *filp, char __user *buf, size_t count, loff_t *offset)
 			count,
 			mbo->processed_length - c->mbo_offs);
 
-	not_copied = copy_to_user(buf,
-				  mbo->virt_address + c->mbo_offs,
-				  to_copy);
-
-	copied = to_copy - not_copied;
+	copied = copy_to_iter(mbo->virt_address + c->mbo_offs, to_copy, to);
 
 	c->mbo_offs += copied;
 	if (c->mbo_offs >= mbo->processed_length) {
@@ -302,8 +292,8 @@ static __poll_t comp_poll(struct file *filp, poll_table *wait)
  */
 static const struct file_operations channel_fops = {
 	.owner = THIS_MODULE,
-	.read = comp_read,
-	.write = comp_write,
+	.read_iter = comp_read,
+	.write_iter = comp_write,
 	.open = comp_open,
 	.release = comp_close,
 	.poll = comp_poll,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 371/437] drivers/ntb: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (369 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 370/437] drivers/most: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 372/437] drivers/md: convert bcache " Jens Axboe
                   ` (66 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/ntb/hw/amd/ntb_hw_amd.c    |  10 +-
 drivers/ntb/hw/idt/ntb_hw_idt.c    |  29 ++-
 drivers/ntb/hw/intel/ntb_hw_gen1.c |  21 +-
 drivers/ntb/hw/intel/ntb_hw_gen3.c |   8 +-
 drivers/ntb/hw/intel/ntb_hw_gen3.h |   3 +-
 drivers/ntb/hw/intel/ntb_hw_gen4.c |   8 +-
 drivers/ntb/hw/intel/ntb_hw_gen4.h |   5 +-
 drivers/ntb/ntb_transport.c        |   9 +-
 drivers/ntb/test/ntb_perf.c        |  49 +++--
 drivers/ntb/test/ntb_tool.c        | 307 +++++++++++++----------------
 10 files changed, 203 insertions(+), 246 deletions(-)

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index d687e8c2cc78..027bcfb2bb11 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -835,8 +835,7 @@ static void ndev_deinit_isr(struct amd_ntb_dev *ndev)
 	}
 }
 
-static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
-				 size_t count, loff_t *offp)
+static ssize_t ndev_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct amd_ntb_dev *ndev;
 	void __iomem *mmio;
@@ -844,8 +843,9 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
 	size_t buf_size;
 	ssize_t ret, off;
 	union { u64 v64; u32 v32; u16 v16; } u;
+	size_t count = iov_iter_count(to);
 
-	ndev = filp->private_data;
+	ndev = iocb->ki_filp->private_data;
 	mmio = ndev->self_mmio;
 
 	buf_size = min(count, 0x800ul);
@@ -927,7 +927,7 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
 	off += scnprintf(buf + off, buf_size - off,
 			 "LMT45 -\t\t\t%#018llx\n", u.v64);
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 	kfree(buf);
 	return ret;
 }
@@ -1299,7 +1299,7 @@ static void amd_ntb_pci_shutdown(struct pci_dev *pdev)
 static const struct file_operations amd_ntb_debugfs_info = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ndev_debugfs_read,
+	.read_iter = ndev_debugfs_read,
 };
 
 static const struct ntb_dev_data dev_data[] = {
diff --git a/drivers/ntb/hw/idt/ntb_hw_idt.c b/drivers/ntb/hw/idt/ntb_hw_idt.c
index 48823b53ede3..9213ba1eb36f 100644
--- a/drivers/ntb/hw/idt/ntb_hw_idt.c
+++ b/drivers/ntb/hw/idt/ntb_hw_idt.c
@@ -2312,18 +2312,6 @@ static void idt_unregister_device(struct idt_ntb_dev *ndev)
  *=============================================================================
  */
 
-static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf,
-				   size_t count, loff_t *offp);
-
-/*
- * Driver DebugFS info file operations
- */
-static const struct file_operations idt_dbgfs_info_ops = {
-	.owner = THIS_MODULE,
-	.open = simple_open,
-	.read = idt_dbgfs_info_read
-};
-
 /*
  * idt_dbgfs_info_read() - DebugFS read info node callback
  * @file:	File node descriptor.
@@ -2331,10 +2319,10 @@ static const struct file_operations idt_dbgfs_info_ops = {
  * @count:	Size of the buffer
  * @offp:	Offset within the buffer
  */
-static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf,
-				   size_t count, loff_t *offp)
+static ssize_t idt_dbgfs_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct idt_ntb_dev *ndev = filp->private_data;
+	struct idt_ntb_dev *ndev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	unsigned char idx, pidx, cnt;
 	unsigned long irqflags, mdeg;
 	ssize_t ret = 0, off = 0;
@@ -2492,12 +2480,21 @@ static ssize_t idt_dbgfs_info_read(struct file *filp, char __user *ubuf,
 		idt_get_deg(mdeg), idt_get_deg_frac(mdeg));
 
 	/* Copy the buffer to the User Space */
-	ret = simple_read_from_buffer(ubuf, count, offp, strbuf, off);
+	ret = simple_copy_to_iter(strbuf, &iocb->ki_pos, off, to);
 	kfree(strbuf);
 
 	return ret;
 }
 
+/*
+ * Driver DebugFS info file operations
+ */
+static const struct file_operations idt_dbgfs_info_ops = {
+	.owner = THIS_MODULE,
+	.open = simple_open,
+	.read_iter = idt_dbgfs_info_read
+};
+
 /*
  * idt_init_dbgfs() - initialize DebugFS node
  * @ndev:	IDT NTB hardware driver descriptor
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
index 9ab836d0d4f1..de31b75f3d20 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
+++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
@@ -488,8 +488,7 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev)
 	}
 }
 
-static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,
-				     size_t count, loff_t *offp)
+static ssize_t ndev_ntb_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct intel_ntb_dev *ndev;
 	struct pci_dev *pdev;
@@ -498,8 +497,9 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,
 	size_t buf_size;
 	ssize_t ret, off;
 	union { u64 v64; u32 v32; u16 v16; u8 v8; } u;
+	size_t count = iov_iter_count(to);
 
-	ndev = filp->private_data;
+	ndev = iocb->ki_filp->private_data;
 	pdev = ndev->ntb.pdev;
 	mmio = ndev->self_mmio;
 
@@ -749,22 +749,21 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,
 					 "CORERRSTS -\t\t%#06x\n", u.v32);
 	}
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 	kfree(buf);
 	return ret;
 }
 
-static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
-				 size_t count, loff_t *offp)
+static ssize_t ndev_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct intel_ntb_dev *ndev = filp->private_data;
+	struct intel_ntb_dev *ndev = iocb->ki_filp->private_data;
 
 	if (pdev_is_gen1(ndev->ntb.pdev))
-		return ndev_ntb_debugfs_read(filp, ubuf, count, offp);
+		return ndev_ntb_debugfs_read(iocb, to);
 	else if (pdev_is_gen3(ndev->ntb.pdev))
-		return ndev_ntb3_debugfs_read(filp, ubuf, count, offp);
+		return ndev_ntb3_debugfs_read(iocb, to);
 	else if (pdev_is_gen4(ndev->ntb.pdev) || pdev_is_gen5(ndev->ntb.pdev))
-		return ndev_ntb4_debugfs_read(filp, ubuf, count, offp);
+		return ndev_ntb4_debugfs_read(iocb, to);
 
 	return -ENXIO;
 }
@@ -2021,7 +2020,7 @@ static const struct ntb_dev_ops intel_ntb_ops = {
 static const struct file_operations intel_ntb_debugfs_info = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ndev_debugfs_read,
+	.read_iter = ndev_debugfs_read,
 };
 
 static const struct pci_device_id intel_ntb_pci_tbl[] = {
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen3.c b/drivers/ntb/hw/intel/ntb_hw_gen3.c
index ffcfc3e02c35..56caeb639016 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen3.c
+++ b/drivers/ntb/hw/intel/ntb_hw_gen3.c
@@ -252,8 +252,7 @@ int gen3_init_dev(struct intel_ntb_dev *ndev)
 	return gen3_init_isr(ndev);
 }
 
-ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp)
+ssize_t ndev_ntb3_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct intel_ntb_dev *ndev;
 	void __iomem *mmio;
@@ -261,8 +260,9 @@ ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
 	size_t buf_size;
 	ssize_t ret, off;
 	union { u64 v64; u32 v32; u16 v16; } u;
+	size_t count = iov_iter_count(to);
 
-	ndev = filp->private_data;
+	ndev = iocb->ki_filp->private_data;
 	mmio = ndev->self_mmio;
 
 	buf_size = min(count, 0x800ul);
@@ -410,7 +410,7 @@ ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
 		off += scnprintf(buf + off, buf_size - off,
 				 "CORERRSTS -\t\t%#06x\n", u.v32);
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 	kfree(buf);
 	return ret;
 }
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen3.h b/drivers/ntb/hw/intel/ntb_hw_gen3.h
index dea93989942d..0eddbee39972 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen3.h
+++ b/drivers/ntb/hw/intel/ntb_hw_gen3.h
@@ -101,8 +101,7 @@ static inline void gen3_db_iowrite(u64 bits, void __iomem *mmio)
 	iowrite64(bits, mmio);
 }
 
-ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp);
+ssize_t ndev_ntb3_debugfs_read(struct kiocb *iocb, struct iov_iter *to);
 int gen3_init_dev(struct intel_ntb_dev *ndev);
 int intel_ntb3_link_enable(struct ntb_dev *ntb, enum ntb_speed max_speed,
 		enum ntb_width max_width);
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen4.c b/drivers/ntb/hw/intel/ntb_hw_gen4.c
index 22cac7975b3c..7fb3d963abec 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen4.c
+++ b/drivers/ntb/hw/intel/ntb_hw_gen4.c
@@ -216,8 +216,7 @@ int gen4_init_dev(struct intel_ntb_dev *ndev)
 	return gen4_init_isr(ndev);
 }
 
-ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp)
+ssize_t ndev_ntb4_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct intel_ntb_dev *ndev;
 	void __iomem *mmio;
@@ -225,8 +224,9 @@ ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
 	size_t buf_size;
 	ssize_t ret, off;
 	union { u64 v64; u32 v32; u16 v16; } u;
+	size_t count = iov_iter_count(to);
 
-	ndev = filp->private_data;
+	ndev = iocb->ki_filp->private_data;
 	mmio = ndev->self_mmio;
 
 	buf_size = min(count, 0x800ul);
@@ -329,7 +329,7 @@ ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
 		off += scnprintf(buf + off, buf_size - off,
 				 "CORERRSTS -\t\t%#06x\n", u.v32);
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 	kfree(buf);
 	return ret;
 }
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen4.h b/drivers/ntb/hw/intel/ntb_hw_gen4.h
index f91323eaf5ce..6c0fa8c99715 100644
--- a/drivers/ntb/hw/intel/ntb_hw_gen4.h
+++ b/drivers/ntb/hw/intel/ntb_hw_gen4.h
@@ -103,11 +103,8 @@
 #define NTB_LTR_IDLE_LATSCALE		0x0800  /* 1us scale */
 #define NTB_LTR_IDLE_REQMNT		0x8000  /* snoop req enable */
 
-ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp);
+ssize_t ndev_ntb4_debugfs_read(struct kiocb *iocb, struct iov_iter *to);
 int gen4_init_dev(struct intel_ntb_dev *ndev);
-ssize_t ndev_ntb4_debugfs_read(struct file *filp, char __user *ubuf,
-				      size_t count, loff_t *offp);
 
 extern const struct ntb_dev_ops intel_ntb4_ops;
 
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index f9e7847a378e..bc69e3d81350 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -460,14 +460,13 @@ void ntb_transport_unregister_client(struct ntb_transport_client *drv)
 }
 EXPORT_SYMBOL_GPL(ntb_transport_unregister_client);
 
-static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
-			    loff_t *offp)
+static ssize_t debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct ntb_transport_qp *qp;
 	char *buf;
 	ssize_t ret, out_offset, out_count;
 
-	qp = filp->private_data;
+	qp = iocb->ki_filp->private_data;
 
 	if (!qp || !qp->link_is_up)
 		return 0;
@@ -548,7 +547,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
 	if (out_offset > out_count)
 		out_offset = out_count;
 
-	ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, out_offset, to);
 	kfree(buf);
 	return ret;
 }
@@ -556,7 +555,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
 static const struct file_operations ntb_qp_debugfs_stats = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = debugfs_read,
+	.read_iter = debugfs_read,
 };
 
 static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 553f1f46bc66..d3f9d2f5015d 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -1179,10 +1179,10 @@ static void perf_clear_threads(struct perf_ctx *perf)
  *==============================================================================
  */
 
-static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t perf_dbgfs_read_info(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct perf_ctx *perf = filep->private_data;
+	struct perf_ctx *perf = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	struct perf_peer *peer;
 	size_t buf_size;
 	ssize_t pos = 0;
@@ -1251,7 +1251,7 @@ static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf,
 			"\tIn buffer xlat %pad[p]\n", &peer->inbuf_xlat);
 	}
 
-	ret = simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 	kfree(buf);
 
 	return ret;
@@ -1259,13 +1259,12 @@ static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf,
 
 static const struct file_operations perf_dbgfs_info = {
 	.open = simple_open,
-	.read = perf_dbgfs_read_info
+	.read_iter = perf_dbgfs_read_info
 };
 
-static ssize_t perf_dbgfs_read_run(struct file *filep, char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t perf_dbgfs_read_run(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct perf_ctx *perf = filep->private_data;
+	struct perf_ctx *perf = iocb->ki_filp->private_data;
 	ssize_t ret, pos = 0;
 	char *buf;
 
@@ -1277,21 +1276,21 @@ static ssize_t perf_dbgfs_read_run(struct file *filep, char __user *ubuf,
 	if (ret)
 		goto err_free;
 
-	ret = simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 err_free:
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t perf_dbgfs_write_run(struct file *filep, const char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t perf_dbgfs_write_run(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct perf_ctx *perf = filep->private_data;
+	struct perf_ctx *perf = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct perf_peer *peer;
 	int pidx, ret;
 
-	ret = kstrtoint_from_user(ubuf, size, 0, &pidx);
+	ret = kstrtoint_from_iter(from, size, 0, &pidx);
 	if (ret)
 		return ret;
 
@@ -1309,31 +1308,29 @@ static ssize_t perf_dbgfs_write_run(struct file *filep, const char __user *ubuf,
 
 static const struct file_operations perf_dbgfs_run = {
 	.open = simple_open,
-	.read = perf_dbgfs_read_run,
-	.write = perf_dbgfs_write_run
+	.read_iter = perf_dbgfs_read_run,
+	.write_iter = perf_dbgfs_write_run,
 };
 
-static ssize_t perf_dbgfs_read_tcnt(struct file *filep, char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t perf_dbgfs_read_tcnt(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct perf_ctx *perf = filep->private_data;
+	struct perf_ctx *perf = iocb->ki_filp->private_data;
 	char buf[8];
 	ssize_t pos;
 
 	pos = scnprintf(buf, sizeof(buf), "%hhu\n", perf->tcnt);
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t perf_dbgfs_write_tcnt(struct file *filep,
-				     const char __user *ubuf,
-				     size_t size, loff_t *offp)
+static ssize_t perf_dbgfs_write_tcnt(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct perf_ctx *perf = filep->private_data;
+	struct perf_ctx *perf = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	int ret;
 	u8 val;
 
-	ret = kstrtou8_from_user(ubuf, size, 0, &val);
+	ret = kstrtou8_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1346,8 +1343,8 @@ static ssize_t perf_dbgfs_write_tcnt(struct file *filep,
 
 static const struct file_operations perf_dbgfs_tcnt = {
 	.open = simple_open,
-	.read = perf_dbgfs_read_tcnt,
-	.write = perf_dbgfs_write_tcnt
+	.read_iter = perf_dbgfs_read_tcnt,
+	.write_iter = perf_dbgfs_write_tcnt,
 };
 
 static void perf_setup_dbgfs(struct perf_ctx *perf)
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
index 641cb7e05a47..e3988468c92f 100644
--- a/drivers/ntb/test/ntb_tool.c
+++ b/drivers/ntb/test/ntb_tool.c
@@ -273,8 +273,8 @@ struct tool_ctx {
 	const struct file_operations __name = {	\
 		.owner = THIS_MODULE,		\
 		.open = simple_open,		\
-		.read = __read,			\
-		.write = __write,		\
+		.read_iter = __read,		\
+		.write_iter = __write,		\
 	}
 
 #define TOOL_BUF_LEN 32
@@ -338,8 +338,8 @@ static const struct ntb_ctx_ops tool_ops = {
  *==============================================================================
  */
 
-static ssize_t tool_fn_read(struct tool_ctx *tc, char __user *ubuf,
-			    size_t size, loff_t *offp,
+static ssize_t tool_fn_read(struct tool_ctx *tc, struct kiocb *iocb,
+			    struct iov_iter *to,
 			    u64 (*fn_read)(struct ntb_dev *))
 {
 	size_t buf_size;
@@ -349,28 +349,28 @@ static ssize_t tool_fn_read(struct tool_ctx *tc, char __user *ubuf,
 	if (!fn_read)
 		return -EINVAL;
 
-	buf_size = min(size, sizeof(buf));
+	buf_size = min(iov_iter_count(to), sizeof(buf));
 
 	pos = scnprintf(buf, buf_size, "%#llx\n", fn_read(tc->ntb));
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t tool_fn_write(struct tool_ctx *tc,
-			     const char __user *ubuf,
-			     size_t size, loff_t *offp,
+static ssize_t tool_fn_write(struct tool_ctx *tc, struct kiocb *iocb,
+			     struct iov_iter *from,
 			     int (*fn_set)(struct ntb_dev *, u64),
 			     int (*fn_clear)(struct ntb_dev *, u64))
 {
+	size_t size = iov_iter_count(from);
 	char *buf, cmd;
 	ssize_t ret;
 	u64 bits;
 	int n;
 
-	if (*offp)
+	if (iocb->ki_pos)
 		return 0;
 
-	buf = memdup_user_nul(ubuf, size);
+	buf = iterdup_nul(from, size);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -402,26 +402,24 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
  *==============================================================================
  */
 
-static ssize_t tool_port_read(struct file *filep, char __user *ubuf,
-			      size_t size, loff_t *offp)
+static ssize_t tool_port_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 	char buf[TOOL_BUF_LEN];
 	int pos;
 
 	pos = scnprintf(buf, sizeof(buf), "%d\n", ntb_port_number(tc->ntb));
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static TOOL_FOPS_RDWR(tool_port_fops,
 		      tool_port_read,
 		      NULL);
 
-static ssize_t tool_peer_port_read(struct file *filep, char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_peer_port_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_peer *peer = filep->private_data;
+	struct tool_peer *peer = iocb->ki_filp->private_data;
 	struct tool_ctx *tc = peer->tc;
 	char buf[TOOL_BUF_LEN];
 	int pos;
@@ -429,7 +427,7 @@ static ssize_t tool_peer_port_read(struct file *filep, char __user *ubuf,
 	pos = scnprintf(buf, sizeof(buf), "%d\n",
 		ntb_peer_port_number(tc->ntb, peer->pidx));
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static TOOL_FOPS_RDWR(tool_peer_port_fops,
@@ -459,14 +457,14 @@ static int tool_init_peers(struct tool_ctx *tc)
  *==============================================================================
  */
 
-static ssize_t tool_link_write(struct file *filep, const char __user *ubuf,
-			       size_t size, loff_t *offp)
+static ssize_t tool_link_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	bool val;
 	int ret;
 
-	ret = kstrtobool_from_user(ubuf, size, &val);
+	ret = kstrtobool_from_iter(from, size, &val);
 	if (ret)
 		return ret;
 
@@ -485,10 +483,9 @@ static TOOL_FOPS_RDWR(tool_link_fops,
 		      NULL,
 		      tool_link_write);
 
-static ssize_t tool_peer_link_read(struct file *filep, char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_peer_link_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_peer *peer = filep->private_data;
+	struct tool_peer *peer = iocb->ki_filp->private_data;
 	struct tool_ctx *tc = peer->tc;
 	char buf[3];
 
@@ -499,24 +496,24 @@ static ssize_t tool_peer_link_read(struct file *filep, char __user *ubuf,
 	buf[1] = '\n';
 	buf[2] = '\0';
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
 static TOOL_FOPS_RDWR(tool_peer_link_fops,
 		      tool_peer_link_read,
 		      NULL);
 
-static ssize_t tool_peer_link_event_write(struct file *filep,
-					  const char __user *ubuf,
-					  size_t size, loff_t *offp)
+static ssize_t tool_peer_link_event_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct tool_peer *peer = filep->private_data;
+	struct tool_peer *peer = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct tool_ctx *tc = peer->tc;
 	u64 link_msk;
 	bool val;
 	int ret;
 
-	ret = kstrtobool_from_user(ubuf, size, &val);
+	ret = kstrtobool_from_iter(from, size, &val);
 	if (ret)
 		return ret;
 
@@ -538,28 +535,25 @@ static TOOL_FOPS_RDWR(tool_peer_link_event_fops,
  *==============================================================================
  */
 
-static ssize_t tool_mw_read(struct file *filep, char __user *ubuf,
-			    size_t size, loff_t *offp)
+static ssize_t tool_mw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_mw *inmw = filep->private_data;
+	struct tool_mw *inmw = iocb->ki_filp->private_data;
 
 	if (inmw->mm_base == NULL)
 		return -ENXIO;
 
-	return simple_read_from_buffer(ubuf, size, offp,
-				       inmw->mm_base, inmw->size);
+	return simple_copy_to_iter(inmw->mm_base, &iocb->ki_pos, inmw->size, to);
 }
 
-static ssize_t tool_mw_write(struct file *filep, const char __user *ubuf,
-			     size_t size, loff_t *offp)
+static ssize_t tool_mw_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_mw *inmw = filep->private_data;
+	struct tool_mw *inmw = iocb->ki_filp->private_data;
 
 	if (inmw->mm_base == NULL)
 		return -ENXIO;
 
-	return simple_write_to_buffer(inmw->mm_base, inmw->size, offp,
-				      ubuf, size);
+	return simple_copy_from_iter(inmw->mm_base, &iocb->ki_pos, inmw->size,
+				     from);
 }
 
 static TOOL_FOPS_RDWR(tool_mw_fops,
@@ -634,10 +628,10 @@ static void tool_free_mw(struct tool_ctx *tc, int pidx, int widx)
 	inmw->dbgfs_file = NULL;
 }
 
-static ssize_t tool_mw_trans_read(struct file *filep, char __user *ubuf,
-				  size_t size, loff_t *offp)
+static ssize_t tool_mw_trans_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_mw *inmw = filep->private_data;
+	struct tool_mw *inmw = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	resource_size_t addr_align;
 	resource_size_t size_align;
 	resource_size_t size_max;
@@ -688,7 +682,7 @@ static ssize_t tool_mw_trans_read(struct file *filep, char __user *ubuf,
 			 "Size Max       \t%pap\n",
 			 &size_max);
 
-	ret = simple_read_from_buffer(ubuf, size, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 
 err:
 	kfree(buf);
@@ -696,14 +690,14 @@ static ssize_t tool_mw_trans_read(struct file *filep, char __user *ubuf,
 	return ret;
 }
 
-static ssize_t tool_mw_trans_write(struct file *filep, const char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_mw_trans_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_mw *inmw = filep->private_data;
+	struct tool_mw *inmw = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	unsigned int val;
 	int ret;
 
-	ret = kstrtouint_from_user(ubuf, size, 0, &val);
+	ret = kstrtouint_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -721,11 +715,11 @@ static TOOL_FOPS_RDWR(tool_mw_trans_fops,
 		      tool_mw_trans_read,
 		      tool_mw_trans_write);
 
-static ssize_t tool_peer_mw_read(struct file *filep, char __user *ubuf,
-				 size_t size, loff_t *offp)
+static ssize_t tool_peer_mw_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_mw *outmw = filep->private_data;
-	loff_t pos = *offp;
+	struct tool_mw *outmw = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
+	loff_t pos = iocb->ki_pos;
 	ssize_t ret;
 	void *buf;
 
@@ -743,14 +737,14 @@ static ssize_t tool_peer_mw_read(struct file *filep, char __user *ubuf,
 		return -ENOMEM;
 
 	memcpy_fromio(buf, outmw->io_base + pos, size);
-	ret = copy_to_user(ubuf, buf, size);
-	if (ret == size) {
+	ret = copy_to_iter(buf, size, to);
+	if (!ret) {
 		ret = -EFAULT;
 		goto err_free;
 	}
 
 	size -= ret;
-	*offp = pos + size;
+	iocb->ki_pos = pos + size;
 	ret = size;
 
 err_free:
@@ -759,12 +753,12 @@ static ssize_t tool_peer_mw_read(struct file *filep, char __user *ubuf,
 	return ret;
 }
 
-static ssize_t tool_peer_mw_write(struct file *filep, const char __user *ubuf,
-				  size_t size, loff_t *offp)
+static ssize_t tool_peer_mw_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_mw *outmw = filep->private_data;
+	struct tool_mw *outmw = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	ssize_t ret;
-	loff_t pos = *offp;
+	loff_t pos = iocb->ki_pos;
 	void *buf;
 
 	if (outmw->io_base == NULL)
@@ -779,14 +773,14 @@ static ssize_t tool_peer_mw_write(struct file *filep, const char __user *ubuf,
 	if (!buf)
 		return -ENOMEM;
 
-	ret = copy_from_user(buf, ubuf, size);
-	if (ret == size) {
+	ret = copy_from_iter(buf, size, from);
+	if (!ret) {
 		ret = -EFAULT;
 		goto err_free;
 	}
 
 	size -= ret;
-	*offp = pos + size;
+	iocb->ki_pos = pos + size;
 	ret = size;
 
 	memcpy_toio(outmw->io_base + pos, buf, size);
@@ -862,11 +856,11 @@ static void tool_free_peer_mw(struct tool_ctx *tc, int widx)
 	outmw->dbgfs_file = NULL;
 }
 
-static ssize_t tool_peer_mw_trans_read(struct file *filep, char __user *ubuf,
-					size_t size, loff_t *offp)
+static ssize_t tool_peer_mw_trans_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_mw_wrap *outmw_wrap = filep->private_data;
+	struct tool_mw_wrap *outmw_wrap = iocb->ki_filp->private_data;
 	struct tool_mw *outmw = outmw_wrap->mw;
+	size_t size = iov_iter_count(to);
 	resource_size_t map_size;
 	phys_addr_t map_base;
 	ssize_t off = 0;
@@ -913,25 +907,25 @@ static ssize_t tool_peer_mw_trans_read(struct file *filep, char __user *ubuf,
 	off += scnprintf(buf + off, buf_size - off,
 			 "Window Size         \t%pap\n", &outmw->size);
 
-	ret = simple_read_from_buffer(ubuf, size, offp, buf, off);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, off, to);
 	kfree(buf);
 
 	return ret;
 }
 
-static ssize_t tool_peer_mw_trans_write(struct file *filep,
-					const char __user *ubuf,
-					size_t size, loff_t *offp)
+static ssize_t tool_peer_mw_trans_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct tool_mw_wrap *outmw_wrap = filep->private_data;
+	struct tool_mw_wrap *outmw_wrap = iocb->ki_filp->private_data;
 	struct tool_mw *outmw = outmw_wrap->mw;
+	size_t size = iov_iter_count(from);
 	size_t buf_size, wsize;
 	char buf[TOOL_BUF_LEN];
 	int ret, n;
 	u64 addr;
 
 	buf_size = min(size, (sizeof(buf) - 1));
-	if (copy_from_user(buf, ubuf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1022,20 +1016,18 @@ static void tool_clear_mws(struct tool_ctx *tc)
  *==============================================================================
  */
 
-static ssize_t tool_db_read(struct file *filep, char __user *ubuf,
-			    size_t size, loff_t *offp)
+static ssize_t tool_db_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->db_read);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->db_read);
 }
 
-static ssize_t tool_db_write(struct file *filep, const char __user *ubuf,
-			     size_t size, loff_t *offp)
+static ssize_t tool_db_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp, tc->ntb->ops->db_set,
+	return tool_fn_write(tc, iocb, from, tc->ntb->ops->db_set,
 			     tc->ntb->ops->db_clear);
 }
 
@@ -1043,32 +1035,29 @@ static TOOL_FOPS_RDWR(tool_db_fops,
 		      tool_db_read,
 		      tool_db_write);
 
-static ssize_t tool_db_valid_mask_read(struct file *filep, char __user *ubuf,
-				       size_t size, loff_t *offp)
+static ssize_t tool_db_valid_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->db_valid_mask);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->db_valid_mask);
 }
 
 static TOOL_FOPS_RDWR(tool_db_valid_mask_fops,
 		      tool_db_valid_mask_read,
 		      NULL);
 
-static ssize_t tool_db_mask_read(struct file *filep, char __user *ubuf,
-				 size_t size, loff_t *offp)
+static ssize_t tool_db_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->db_read_mask);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->db_read_mask);
 }
 
-static ssize_t tool_db_mask_write(struct file *filep, const char __user *ubuf,
-			       size_t size, loff_t *offp)
+static ssize_t tool_db_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp, tc->ntb->ops->db_set_mask,
+	return tool_fn_write(tc, iocb, from, tc->ntb->ops->db_set_mask,
 			     tc->ntb->ops->db_clear_mask);
 }
 
@@ -1076,20 +1065,18 @@ static TOOL_FOPS_RDWR(tool_db_mask_fops,
 		      tool_db_mask_read,
 		      tool_db_mask_write);
 
-static ssize_t tool_peer_db_read(struct file *filep, char __user *ubuf,
-				 size_t size, loff_t *offp)
+static ssize_t tool_peer_db_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->peer_db_read);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->peer_db_read);
 }
 
-static ssize_t tool_peer_db_write(struct file *filep, const char __user *ubuf,
-				  size_t size, loff_t *offp)
+static ssize_t tool_peer_db_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp, tc->ntb->ops->peer_db_set,
+	return tool_fn_write(tc, iocb, from, tc->ntb->ops->peer_db_set,
 			     tc->ntb->ops->peer_db_clear);
 }
 
@@ -1097,23 +1084,18 @@ static TOOL_FOPS_RDWR(tool_peer_db_fops,
 		      tool_peer_db_read,
 		      tool_peer_db_write);
 
-static ssize_t tool_peer_db_mask_read(struct file *filep, char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_peer_db_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp,
-			    tc->ntb->ops->peer_db_read_mask);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->peer_db_read_mask);
 }
 
-static ssize_t tool_peer_db_mask_write(struct file *filep,
-				       const char __user *ubuf,
-				       size_t size, loff_t *offp)
+static ssize_t tool_peer_db_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp,
-			     tc->ntb->ops->peer_db_set_mask,
+	return tool_fn_write(tc, iocb, from, tc->ntb->ops->peer_db_set_mask,
 			     tc->ntb->ops->peer_db_clear_mask);
 }
 
@@ -1121,15 +1103,14 @@ static TOOL_FOPS_RDWR(tool_peer_db_mask_fops,
 		      tool_peer_db_mask_read,
 		      tool_peer_db_mask_write);
 
-static ssize_t tool_db_event_write(struct file *filep,
-				   const char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_db_event_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	u64 val;
 	int ret;
 
-	ret = kstrtou64_from_user(ubuf, size, 0, &val);
+	ret = kstrtou64_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1148,10 +1129,9 @@ static TOOL_FOPS_RDWR(tool_db_event_fops,
  *==============================================================================
  */
 
-static ssize_t tool_spad_read(struct file *filep, char __user *ubuf,
-			      size_t size, loff_t *offp)
+static ssize_t tool_spad_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_spad *spad = filep->private_data;
+	struct tool_spad *spad = iocb->ki_filp->private_data;
 	char buf[TOOL_BUF_LEN];
 	ssize_t pos;
 
@@ -1161,13 +1141,13 @@ static ssize_t tool_spad_read(struct file *filep, char __user *ubuf,
 	pos = scnprintf(buf, sizeof(buf), "%#x\n",
 		ntb_spad_read(spad->tc->ntb, spad->sidx));
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t tool_spad_write(struct file *filep, const char __user *ubuf,
-			       size_t size, loff_t *offp)
+static ssize_t tool_spad_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_spad *spad = filep->private_data;
+	struct tool_spad *spad = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	u32 val;
 	int ret;
 
@@ -1176,7 +1156,7 @@ static ssize_t tool_spad_write(struct file *filep, const char __user *ubuf,
 		return -EINVAL;
 	}
 
-	ret = kstrtou32_from_user(ubuf, size, 0, &val);
+	ret = kstrtou32_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1189,10 +1169,9 @@ static TOOL_FOPS_RDWR(tool_spad_fops,
 		      tool_spad_read,
 		      tool_spad_write);
 
-static ssize_t tool_peer_spad_read(struct file *filep, char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_peer_spad_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_spad *spad = filep->private_data;
+	struct tool_spad *spad = iocb->ki_filp->private_data;
 	char buf[TOOL_BUF_LEN];
 	ssize_t pos;
 
@@ -1202,13 +1181,13 @@ static ssize_t tool_peer_spad_read(struct file *filep, char __user *ubuf,
 	pos = scnprintf(buf, sizeof(buf), "%#x\n",
 		ntb_peer_spad_read(spad->tc->ntb, spad->pidx, spad->sidx));
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
-static ssize_t tool_peer_spad_write(struct file *filep, const char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t tool_peer_spad_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_spad *spad = filep->private_data;
+	struct tool_spad *spad = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	u32 val;
 	int ret;
 
@@ -1217,7 +1196,7 @@ static ssize_t tool_peer_spad_write(struct file *filep, const char __user *ubuf,
 		return -EINVAL;
 	}
 
-	ret = kstrtou32_from_user(ubuf, size, 0, &val);
+	ret = kstrtou32_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1271,10 +1250,9 @@ static int tool_init_spads(struct tool_ctx *tc)
  *==============================================================================
  */
 
-static ssize_t tool_inmsg_read(struct file *filep, char __user *ubuf,
-			       size_t size, loff_t *offp)
+static ssize_t tool_inmsg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_msg *msg = filep->private_data;
+	struct tool_msg *msg = iocb->ki_filp->private_data;
 	char buf[TOOL_BUF_LEN];
 	ssize_t pos;
 	u32 data;
@@ -1284,22 +1262,21 @@ static ssize_t tool_inmsg_read(struct file *filep, char __user *ubuf,
 
 	pos = scnprintf(buf, sizeof(buf), "0x%08x<-%d\n", data, pidx);
 
-	return simple_read_from_buffer(ubuf, size, offp, buf, pos);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, pos, to);
 }
 
 static TOOL_FOPS_RDWR(tool_inmsg_fops,
 		      tool_inmsg_read,
 		      NULL);
 
-static ssize_t tool_outmsg_write(struct file *filep,
-				 const char __user *ubuf,
-				 size_t size, loff_t *offp)
+static ssize_t tool_outmsg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_msg *msg = filep->private_data;
+	struct tool_msg *msg = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	u32 val;
 	int ret;
 
-	ret = kstrtou32_from_user(ubuf, size, 0, &val);
+	ret = kstrtou32_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1312,58 +1289,51 @@ static TOOL_FOPS_RDWR(tool_outmsg_fops,
 		      NULL,
 		      tool_outmsg_write);
 
-static ssize_t tool_msg_sts_read(struct file *filep, char __user *ubuf,
-				 size_t size, loff_t *offp)
+static ssize_t tool_msg_sts_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->msg_read_sts);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->msg_read_sts);
 }
 
-static ssize_t tool_msg_sts_write(struct file *filep, const char __user *ubuf,
-				  size_t size, loff_t *offp)
+static ssize_t tool_msg_sts_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp, NULL,
-			     tc->ntb->ops->msg_clear_sts);
+	return tool_fn_write(tc, iocb, from, NULL, tc->ntb->ops->msg_clear_sts);
 }
 
 static TOOL_FOPS_RDWR(tool_msg_sts_fops,
 		      tool_msg_sts_read,
 		      tool_msg_sts_write);
 
-static ssize_t tool_msg_inbits_read(struct file *filep, char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t tool_msg_inbits_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->msg_inbits);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->msg_inbits);
 }
 
 static TOOL_FOPS_RDWR(tool_msg_inbits_fops,
 		      tool_msg_inbits_read,
 		      NULL);
 
-static ssize_t tool_msg_outbits_read(struct file *filep, char __user *ubuf,
-				     size_t size, loff_t *offp)
+static ssize_t tool_msg_outbits_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_read(tc, ubuf, size, offp, tc->ntb->ops->msg_outbits);
+	return tool_fn_read(tc, iocb, to, tc->ntb->ops->msg_outbits);
 }
 
 static TOOL_FOPS_RDWR(tool_msg_outbits_fops,
 		      tool_msg_outbits_read,
 		      NULL);
 
-static ssize_t tool_msg_mask_write(struct file *filep, const char __user *ubuf,
-				   size_t size, loff_t *offp)
+static ssize_t tool_msg_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
 
-	return tool_fn_write(tc, ubuf, size, offp,
-			     tc->ntb->ops->msg_set_mask,
+	return tool_fn_write(tc, iocb, from, tc->ntb->ops->msg_set_mask,
 			     tc->ntb->ops->msg_clear_mask);
 }
 
@@ -1371,15 +1341,14 @@ static TOOL_FOPS_RDWR(tool_msg_mask_fops,
 		      NULL,
 		      tool_msg_mask_write);
 
-static ssize_t tool_msg_event_write(struct file *filep,
-				    const char __user *ubuf,
-				    size_t size, loff_t *offp)
+static ssize_t tool_msg_event_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct tool_ctx *tc = filep->private_data;
+	struct tool_ctx *tc = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	u64 val;
 	int ret;
 
-	ret = kstrtou64_from_user(ubuf, size, 0, &val);
+	ret = kstrtou64_from_iter(from, size, 0, &val);
 	if (ret)
 		return ret;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 372/437] drivers/md: convert bcache to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (370 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 371/437] drivers/ntb: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 373/437] drivers/remoteproc: convert " Jens Axboe
                   ` (65 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/md/bcache/debug.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 7510d1c983a5..6c28c8ca5629 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -169,10 +169,10 @@ static bool dump_pred(struct keybuf *buf, struct bkey *k)
 	return true;
 }
 
-static ssize_t bch_dump_read(struct file *file, char __user *buf,
-			     size_t size, loff_t *ppos)
+static ssize_t bch_dump_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dump_iterator *i = file->private_data;
+	struct dump_iterator *i = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	ssize_t ret = 0;
 	char kbuf[80];
 
@@ -180,11 +180,10 @@ static ssize_t bch_dump_read(struct file *file, char __user *buf,
 		struct keybuf_key *w;
 		unsigned int bytes = min(i->bytes, size);
 
-		if (copy_to_user(buf, i->buf, bytes))
+		if (!copy_to_iter_full(i->buf, bytes, to))
 			return -EFAULT;
 
 		ret	 += bytes;
-		buf	 += bytes;
 		size	 -= bytes;
 		i->bytes -= bytes;
 		memmove(i->buf, i->buf + bytes, i->bytes);
@@ -230,7 +229,7 @@ static int bch_dump_release(struct inode *inode, struct file *file)
 static const struct file_operations cache_set_debug_ops = {
 	.owner		= THIS_MODULE,
 	.open		= bch_dump_open,
-	.read		= bch_dump_read,
+	.read_iter	= bch_dump_read,
 	.release	= bch_dump_release
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 373/437] drivers/remoteproc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (371 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 372/437] drivers/md: convert bcache " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 374/437] drivers/thunderbolt: " Jens Axboe
                   ` (64 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/remoteproc/remoteproc_cdev.c    |  9 ++--
 drivers/remoteproc/remoteproc_debugfs.c | 68 +++++++++++--------------
 2 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c
index 687f205fd70a..c36a0fa6c991 100644
--- a/drivers/remoteproc/remoteproc_cdev.c
+++ b/drivers/remoteproc/remoteproc_cdev.c
@@ -18,16 +18,17 @@
 #define NUM_RPROC_DEVICES	64
 static dev_t rproc_major;
 
-static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_t len, loff_t *pos)
+static ssize_t rproc_cdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rproc *rproc = container_of(filp->f_inode->i_cdev, struct rproc, cdev);
+	struct rproc *rproc = container_of(iocb->ki_filp->f_inode->i_cdev, struct rproc, cdev);
+	size_t len = iov_iter_count(from);
 	int ret = 0;
 	char cmd[10];
 
 	if (!len || len > sizeof(cmd))
 		return -EINVAL;
 
-	ret = copy_from_user(cmd, buf, len);
+	ret = !copy_from_iter_full(cmd, len, from);
 	if (ret)
 		return -EFAULT;
 
@@ -89,7 +90,7 @@ static int rproc_cdev_release(struct inode *inode, struct file *filp)
 }
 
 static const struct file_operations rproc_fops = {
-	.write = rproc_cdev_write,
+	.write_iter = rproc_cdev_write,
 	.unlocked_ioctl = rproc_device_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.release = rproc_cdev_release,
diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c
index b86c1d09c70c..dd5900143475 100644
--- a/drivers/remoteproc/remoteproc_debugfs.c
+++ b/drivers/remoteproc/remoteproc_debugfs.c
@@ -39,17 +39,16 @@ static const char * const rproc_coredump_str[] = {
 };
 
 /* Expose the current coredump configuration via debugfs */
-static ssize_t rproc_coredump_read(struct file *filp, char __user *userbuf,
-				   size_t count, loff_t *ppos)
+static ssize_t rproc_coredump_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
 	char buf[20];
 	int len;
 
 	len = scnprintf(buf, sizeof(buf), "%s\n",
 			rproc_coredump_str[rproc->dump_conf]);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /*
@@ -68,18 +67,17 @@ static ssize_t rproc_coredump_read(struct file *filp, char __user *userbuf,
  *		recovery process will have to wait until data is read by
  *		userspace. But this avoid usage of extra memory.
  */
-static ssize_t rproc_coredump_write(struct file *filp,
-				    const char __user *user_buf, size_t count,
-				    loff_t *ppos)
+static ssize_t rproc_coredump_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret, err = 0;
 	char buf[20];
 
 	if (count < 1 || count > sizeof(buf))
 		return -EINVAL;
 
-	ret = copy_from_user(buf, user_buf, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret)
 		return -EFAULT;
 
@@ -108,8 +106,8 @@ static ssize_t rproc_coredump_write(struct file *filp,
 }
 
 static const struct file_operations rproc_coredump_fops = {
-	.read = rproc_coredump_read,
-	.write = rproc_coredump_write,
+	.read_iter = rproc_coredump_read,
+	.write_iter = rproc_coredump_write,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
@@ -123,10 +121,9 @@ static const struct file_operations rproc_coredump_fops = {
  * but this kind of lightweight and simple mechanism is always good to have,
  * as it provides very early tracing with little to no dependencies at all.
  */
-static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t rproc_trace_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rproc_debug_trace *data = filp->private_data;
+	struct rproc_debug_trace *data = iocb->ki_filp->private_data;
 	struct rproc_mem_entry *trace = &data->trace_mem;
 	void *va;
 	char buf[100];
@@ -142,43 +139,41 @@ static ssize_t rproc_trace_read(struct file *filp, char __user *userbuf,
 		len = strnlen(va, trace->len);
 	}
 
-	return simple_read_from_buffer(userbuf, count, ppos, va, len);
+	return simple_copy_to_iter(va, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations trace_rproc_ops = {
-	.read = rproc_trace_read,
+	.read_iter = rproc_trace_read,
 	.open = simple_open,
 	.llseek	= generic_file_llseek,
 };
 
 /* expose the name of the remote processor via debugfs */
-static ssize_t rproc_name_read(struct file *filp, char __user *userbuf,
-			       size_t count, loff_t *ppos)
+static ssize_t rproc_name_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
 	/* need room for the name, a newline and a terminating null */
 	char buf[100];
 	int i;
 
 	i = scnprintf(buf, sizeof(buf), "%.98s\n", rproc->name);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, i);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, i, to);
 }
 
 static const struct file_operations rproc_name_ops = {
-	.read = rproc_name_read,
+	.read_iter = rproc_name_read,
 	.open = simple_open,
 	.llseek	= generic_file_llseek,
 };
 
 /* expose recovery flag via debugfs */
-static ssize_t rproc_recovery_read(struct file *filp, char __user *userbuf,
-				   size_t count, loff_t *ppos)
+static ssize_t rproc_recovery_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
 	char *buf = rproc->recovery_disabled ? "disabled\n" : "enabled\n";
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 /*
@@ -206,17 +201,17 @@ static ssize_t rproc_recovery_read(struct file *filp, char __user *userbuf,
  *		instead use the "recover" command as needed.
  */
 static ssize_t
-rproc_recovery_write(struct file *filp, const char __user *user_buf,
-		     size_t count, loff_t *ppos)
+rproc_recovery_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[10];
 	int ret;
 
 	if (count < 1 || count > sizeof(buf))
 		return -EINVAL;
 
-	ret = copy_from_user(buf, user_buf, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret)
 		return -EFAULT;
 
@@ -241,22 +236,21 @@ rproc_recovery_write(struct file *filp, const char __user *user_buf,
 }
 
 static const struct file_operations rproc_recovery_ops = {
-	.read = rproc_recovery_read,
-	.write = rproc_recovery_write,
+	.read_iter = rproc_recovery_read,
+	.write_iter = rproc_recovery_write,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
 
 /* expose the crash trigger via debugfs */
-static ssize_t
-rproc_crash_write(struct file *filp, const char __user *user_buf,
-		  size_t count, loff_t *ppos)
+static ssize_t rproc_crash_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rproc *rproc = filp->private_data;
+	struct rproc *rproc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned int type;
 	int ret;
 
-	ret = kstrtouint_from_user(user_buf, count, 0, &type);
+	ret = kstrtouint_from_iter(from, count, 0, &type);
 	if (ret < 0)
 		return ret;
 
@@ -266,7 +260,7 @@ rproc_crash_write(struct file *filp, const char __user *user_buf,
 }
 
 static const struct file_operations rproc_crash_ops = {
-	.write = rproc_crash_write,
+	.write_iter = rproc_crash_write,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 374/437] drivers/thunderbolt: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (372 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 373/437] drivers/remoteproc: convert " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 375/437] drivers/vfio: " Jens Axboe
                   ` (63 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/thunderbolt/debugfs.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index e324cd899719..fbe0fb7d40a6 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -43,8 +43,8 @@ static const struct file_operations __space ## _fops = {		\
 	.owner = THIS_MODULE,						\
 	.open = __space ## _open,					\
 	.release = single_release,					\
-	.read  = seq_read,						\
-	.write = __write,						\
+	.read_iter  = seq_read_iter,					\
+	.write_iter = __write,						\
 	.llseek = seq_lseek,						\
 }
 
@@ -52,7 +52,7 @@ static const struct file_operations __space ## _fops = {		\
 	DEBUGFS_ATTR(__space, NULL)
 
 #define DEBUGFS_ATTR_RW(__space)					\
-	DEBUGFS_ATTR(__space, __space ## _write)
+	DEBUGFS_ATTR(__space, __space ## _write ## _iter)
 
 static struct dentry *tb_debugfs_root;
 
@@ -175,6 +175,7 @@ static ssize_t port_regs_write(struct file *file, const char __user *user_buf,
 
 	return regs_write(port->sw, port, user_buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(port_regs_write);
 
 static ssize_t switch_regs_write(struct file *file, const char __user *user_buf,
 				 size_t count, loff_t *ppos)
@@ -184,10 +185,11 @@ static ssize_t switch_regs_write(struct file *file, const char __user *user_buf,
 
 	return regs_write(sw, NULL, user_buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(switch_regs_write);
 #define DEBUGFS_MODE		0600
 #else
-#define port_regs_write		NULL
-#define switch_regs_write	NULL
+#define port_regs_write_iter	NULL
+#define switch_regs_write_iter	NULL
 #define DEBUGFS_MODE		0400
 #endif
 
@@ -305,6 +307,7 @@ margining_ber_level_write(struct file *file, const char __user *user_buf,
 
 	return ret < 0 ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(margining_ber_level_write);
 
 static void ber_level_show(struct seq_file *s, unsigned int val)
 {
@@ -445,6 +448,7 @@ margining_lanes_write(struct file *file, const char __user *user_buf,
 	free_page((unsigned long)buf);
 	return ret < 0 ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(margining_lanes_write);
 
 static int margining_lanes_show(struct seq_file *s, void *not_used)
 {
@@ -518,6 +522,7 @@ static ssize_t margining_mode_write(struct file *file,
 	free_page((unsigned long)buf);
 	return ret ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(margining_mode_write);
 
 static int margining_mode_show(struct seq_file *s, void *not_used)
 {
@@ -646,6 +651,7 @@ static ssize_t margining_results_write(struct file *file,
 	mutex_unlock(&tb->lock);
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(margining_results_write);
 
 static void voltage_margin_show(struct seq_file *s,
 				const struct tb_margining *margining, u8 val)
@@ -775,6 +781,7 @@ static ssize_t margining_test_write(struct file *file,
 	free_page((unsigned long)buf);
 	return ret ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(margining_test_write);
 
 static int margining_test_show(struct seq_file *s, void *not_used)
 {
@@ -843,6 +850,7 @@ static ssize_t margining_margin_write(struct file *file,
 	free_page((unsigned long)buf);
 	return ret ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(margining_margin_write);
 
 static int margining_margin_show(struct seq_file *s, void *not_used)
 {
@@ -1089,6 +1097,7 @@ static ssize_t counters_write(struct file *file, const char __user *user_buf,
 
 	return ret < 0 ? ret : count;
 }
+FOPS_WRITE_ITER_HELPER(counters_write);
 
 static void cap_show_by_dw(struct seq_file *s, struct tb_switch *sw,
 			   struct tb_port *port, unsigned int cap,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 375/437] drivers/vfio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (373 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 374/437] drivers/thunderbolt: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 376/437] drivers/fsi: " Jens Axboe
                   ` (62 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c    | 31 ++++++++++--------
 drivers/vfio/pci/mlx5/main.c                  |  6 ++--
 drivers/vfio/pci/pds/lm.c                     | 32 +++++++++----------
 drivers/vfio/vfio_main.c                      |  6 ++--
 4 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
index 9a3e97108ace..8ea4c46a3334 100644
--- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
+++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
@@ -676,18 +676,20 @@ static int hisi_acc_vf_release_file(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *buf,
-					size_t len, loff_t *pos)
+static ssize_t hisi_acc_vf_resume_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct hisi_acc_vf_migration_file *migf = filp->private_data;
+	struct hisi_acc_vf_migration_file *migf = iocb->ki_filp->private_data;
 	u8 *vf_data = (u8 *)&migf->vf_data;
+	size_t len = iov_iter_count(from);
 	loff_t requested_length;
 	ssize_t done = 0;
+	loff_t *pos;
 	int ret;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	if (*pos < 0 ||
 	    check_add_overflow((loff_t)len, *pos, &requested_length))
@@ -702,7 +704,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
 		goto out_unlock;
 	}
 
-	ret = copy_from_user(vf_data + *pos, buf, len);
+	ret = !copy_from_iter_full(vf_data + *pos, len, from);
 	if (ret) {
 		done = -EFAULT;
 		goto out_unlock;
@@ -721,7 +723,7 @@ static ssize_t hisi_acc_vf_resume_write(struct file *filp, const char __user *bu
 
 static const struct file_operations hisi_acc_vf_resume_fops = {
 	.owner = THIS_MODULE,
-	.write = hisi_acc_vf_resume_write,
+	.write_iter = hisi_acc_vf_resume_write,
 	.release = hisi_acc_vf_release_file,
 	.llseek = no_llseek,
 };
@@ -800,16 +802,17 @@ static long hisi_acc_vf_precopy_ioctl(struct file *filp,
 	return ret;
 }
 
-static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_t len,
-				     loff_t *pos)
+static ssize_t hisi_acc_vf_save_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hisi_acc_vf_migration_file *migf = filp->private_data;
+	struct hisi_acc_vf_migration_file *migf = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t done = 0;
+	loff_t *pos;
 	int ret;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	mutex_lock(&migf->lock);
 	if (*pos > migf->total_length) {
@@ -826,7 +829,7 @@ static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_t
 	if (len) {
 		u8 *vf_data = (u8 *)&migf->vf_data;
 
-		ret = copy_to_user(buf, vf_data + *pos, len);
+		ret = !copy_to_iter_full(vf_data + *pos, len, to);
 		if (ret) {
 			done = -EFAULT;
 			goto out_unlock;
@@ -841,7 +844,7 @@ static ssize_t hisi_acc_vf_save_read(struct file *filp, char __user *buf, size_t
 
 static const struct file_operations hisi_acc_vf_save_fops = {
 	.owner = THIS_MODULE,
-	.read = hisi_acc_vf_save_read,
+	.read_iter = hisi_acc_vf_save_read,
 	.unlocked_ioctl = hisi_acc_vf_precopy_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
 	.release = hisi_acc_vf_release_file,
diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index 61d9b0f9146d..05552bcb7a31 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -263,6 +263,7 @@ static ssize_t mlx5vf_save_read(struct file *filp, char __user *buf, size_t len,
 	mutex_unlock(&migf->lock);
 	return done;
 }
+FOPS_READ_ITER_HELPER(mlx5vf_save_read);
 
 static __poll_t mlx5vf_save_poll(struct file *filp,
 				 struct poll_table_struct *wait)
@@ -582,7 +583,7 @@ static long mlx5vf_precopy_ioctl(struct file *filp, unsigned int cmd,
 
 static const struct file_operations mlx5vf_save_fops = {
 	.owner = THIS_MODULE,
-	.read = mlx5vf_save_read,
+	.read_iter = mlx5vf_save_read_iter,
 	.poll = mlx5vf_save_poll,
 	.unlocked_ioctl = mlx5vf_precopy_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
@@ -995,10 +996,11 @@ static ssize_t mlx5vf_resume_write(struct file *filp, const char __user *buf,
 	mlx5vf_state_mutex_unlock(migf->mvdev);
 	return ret ? ret : done;
 }
+FOPS_WRITE_ITER_HELPER(mlx5vf_resume_write);
 
 static const struct file_operations mlx5vf_resume_fops = {
 	.owner = THIS_MODULE,
-	.write = mlx5vf_resume_write,
+	.write_iter = mlx5vf_resume_write_iter,
 	.release = mlx5vf_release_file,
 	.llseek = no_llseek,
 };
diff --git a/drivers/vfio/pci/pds/lm.c b/drivers/vfio/pci/pds/lm.c
index 6b94cc0bf45b..8e86b3c39a28 100644
--- a/drivers/vfio/pci/pds/lm.c
+++ b/drivers/vfio/pci/pds/lm.c
@@ -174,15 +174,16 @@ static int pds_vfio_release_file(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf,
-				  size_t len, loff_t *pos)
+static ssize_t pds_vfio_save_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct pds_vfio_lm_file *lm_file = filp->private_data;
+	struct pds_vfio_lm_file *lm_file = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t done = 0;
+	loff_t *pos;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	mutex_lock(&lm_file->lock);
 
@@ -214,7 +215,7 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf,
 
 		page_len = min_t(size_t, len, PAGE_SIZE - page_offset);
 		from_buff = kmap_local_page(page);
-		err = copy_to_user(buf, from_buff + page_offset, page_len);
+		err = !copy_to_iter_full(from_buff + page_offset, page_len, to);
 		kunmap_local(from_buff);
 		if (err) {
 			done = -EFAULT;
@@ -223,7 +224,6 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf,
 		*pos += page_len;
 		len -= page_len;
 		done += page_len;
-		buf += page_len;
 	}
 
 out_unlock:
@@ -233,7 +233,7 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf,
 
 static const struct file_operations pds_vfio_save_fops = {
 	.owner = THIS_MODULE,
-	.read = pds_vfio_save_read,
+	.read_iter = pds_vfio_save_read,
 	.release = pds_vfio_release_file,
 	.llseek = no_llseek,
 };
@@ -273,17 +273,18 @@ static int pds_vfio_get_save_file(struct pds_vfio_pci_device *pds_vfio)
 	return 0;
 }
 
-static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,
-				      size_t len, loff_t *pos)
+static ssize_t pds_vfio_restore_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct pds_vfio_lm_file *lm_file = filp->private_data;
+	struct pds_vfio_lm_file *lm_file = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	loff_t requested_length;
 	ssize_t done = 0;
+	loff_t *pos;
 
-	if (pos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
 
-	pos = &filp->f_pos;
+	pos = &iocb->ki_filp->f_pos;
 
 	if (*pos < 0 ||
 	    check_add_overflow((loff_t)len, *pos, &requested_length))
@@ -313,7 +314,7 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,
 
 		page_len = min_t(size_t, len, PAGE_SIZE - page_offset);
 		to_buff = kmap_local_page(page);
-		err = copy_from_user(to_buff + page_offset, buf, page_len);
+		err = !copy_from_iter_full(to_buff + page_offset, page_len, from);
 		kunmap_local(to_buff);
 		if (err) {
 			done = -EFAULT;
@@ -322,7 +323,6 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,
 		*pos += page_len;
 		len -= page_len;
 		done += page_len;
-		buf += page_len;
 		lm_file->size += page_len;
 	}
 out_unlock:
@@ -332,7 +332,7 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,
 
 static const struct file_operations pds_vfio_restore_fops = {
 	.owner = THIS_MODULE,
-	.write = pds_vfio_restore_write,
+	.write_iter = pds_vfio_restore_write,
 	.release = pds_vfio_release_file,
 	.llseek = no_llseek,
 };
diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index e97d796a54fb..dd96d1756110 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -1277,6 +1277,7 @@ static ssize_t vfio_device_fops_read(struct file *filep, char __user *buf,
 
 	return device->ops->read(device, buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(vfio_device_fops_read);
 
 static ssize_t vfio_device_fops_write(struct file *filep,
 				      const char __user *buf,
@@ -1294,6 +1295,7 @@ static ssize_t vfio_device_fops_write(struct file *filep,
 
 	return device->ops->write(device, buf, count, ppos);
 }
+FOPS_WRITE_ITER_HELPER(vfio_device_fops_write);
 
 static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma)
 {
@@ -1314,8 +1316,8 @@ const struct file_operations vfio_device_fops = {
 	.owner		= THIS_MODULE,
 	.open		= vfio_device_fops_cdev_open,
 	.release	= vfio_device_fops_release,
-	.read		= vfio_device_fops_read,
-	.write		= vfio_device_fops_write,
+	.read_iter	= vfio_device_fops_read_iter,
+	.write_iter	= vfio_device_fops_write_iter,
 	.unlocked_ioctl	= vfio_device_fops_unl_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.mmap		= vfio_device_fops_mmap,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 376/437] drivers/fsi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (374 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 375/437] drivers/vfio: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 377/437] iio: " Jens Axboe
                   ` (61 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/fsi/fsi-core.c    | 28 ++++++++++++++--------------
 drivers/fsi/fsi-occ.c     | 20 ++++++++++----------
 drivers/fsi/fsi-sbefifo.c |  6 ++++--
 drivers/fsi/fsi-scom.c    | 24 ++++++++++++------------
 drivers/fsi/i2cr-scom.c   | 23 ++++++++++++-----------
 5 files changed, 52 insertions(+), 49 deletions(-)

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 097d5a780264..ce68c470d30e 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -657,12 +657,12 @@ static struct device_node *fsi_slave_find_of_node(struct fsi_master *master,
 	return NULL;
 }
 
-static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count,
-			 loff_t *offset)
+static ssize_t cfam_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct fsi_slave *slave = filep->private_data;
+	struct fsi_slave *slave = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	size_t total_len, read_len;
-	loff_t off = *offset;
+	loff_t off = iocb->ki_pos;
 	ssize_t rc;
 
 	if (off < 0)
@@ -680,7 +680,7 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count,
 		rc = fsi_slave_read(slave, off, &data, read_len);
 		if (rc)
 			goto fail;
-		rc = copy_to_user(buf + total_len, &data, read_len);
+		rc = !copy_to_iter_full(&data, read_len, to);
 		if (rc) {
 			rc = -EFAULT;
 			goto fail;
@@ -689,16 +689,16 @@ static ssize_t cfam_read(struct file *filep, char __user *buf, size_t count,
 	}
 	rc = count;
  fail:
-	*offset = off;
+	iocb->ki_pos = off;
 	return rc;
 }
 
-static ssize_t cfam_write(struct file *filep, const char __user *buf,
-			  size_t count, loff_t *offset)
+static ssize_t cfam_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct fsi_slave *slave = filep->private_data;
+	struct fsi_slave *slave = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t total_len, write_len;
-	loff_t off = *offset;
+	loff_t off = iocb->ki_pos;
 	ssize_t rc;
 
 
@@ -714,7 +714,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf,
 		write_len = min_t(size_t, count, 4);
 		write_len -= off & 0x3;
 
-		rc = copy_from_user(&data, buf + total_len, write_len);
+		rc = !copy_from_iter_full(&data, write_len, from);
 		if (rc) {
 			rc = -EFAULT;
 			goto fail;
@@ -726,7 +726,7 @@ static ssize_t cfam_write(struct file *filep, const char __user *buf,
 	}
 	rc = count;
  fail:
-	*offset = off;
+	iocb->ki_pos = off;
 	return rc;
 }
 
@@ -758,8 +758,8 @@ static const struct file_operations cfam_fops = {
 	.owner		= THIS_MODULE,
 	.open		= cfam_open,
 	.llseek		= cfam_llseek,
-	.read		= cfam_read,
-	.write		= cfam_write,
+	.read_iter	= cfam_read,
+	.write_iter	= cfam_write,
 };
 
 static ssize_t send_term_store(struct device *dev,
diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index da35ca9e84a6..1145df7dbec8 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -104,10 +104,10 @@ static int occ_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
-			loff_t *offset)
+static ssize_t occ_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct occ_client *client = file->private_data;
+	struct occ_client *client = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t rc = 0;
 
 	if (!client)
@@ -126,7 +126,7 @@ static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
 
 	/* Grab how much data we have to read */
 	rc = min(len, client->data_size - client->read_offset);
-	if (copy_to_user(buf, client->buffer + client->read_offset, rc))
+	if (!copy_to_iter_full(client->buffer + client->read_offset, rc, to))
 		rc = -EFAULT;
 	else
 		client->read_offset += rc;
@@ -137,10 +137,10 @@ static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
 	return rc;
 }
 
-static ssize_t occ_write(struct file *file, const char __user *buf,
-			 size_t len, loff_t *offset)
+static ssize_t occ_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct occ_client *client = file->private_data;
+	struct occ_client *client = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	size_t rlen, data_length;
 	ssize_t rc;
 	u8 *cmd;
@@ -163,7 +163,7 @@ static ssize_t occ_write(struct file *file, const char __user *buf,
 	 * bytes 1-2: data length (msb first)
 	 * bytes 3-n: data
 	 */
-	if (copy_from_user(&cmd[1], buf, len)) {
+	if (!copy_from_iter_full(&cmd[1], len, from)) {
 		rc = -EFAULT;
 		goto done;
 	}
@@ -209,8 +209,8 @@ static int occ_release(struct inode *inode, struct file *file)
 static const struct file_operations occ_fops = {
 	.owner = THIS_MODULE,
 	.open = occ_open,
-	.read = occ_read,
-	.write = occ_write,
+	.read_iter = occ_read,
+	.write_iter = occ_write,
 	.release = occ_release,
 };
 
diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index 0a98517f3959..0fe2e4730b4b 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -864,6 +864,7 @@ static ssize_t sbefifo_user_read(struct file *file, char __user *buf,
 	mutex_unlock(&user->file_lock);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(sbefifo_user_read);
 
 static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
 				  size_t len, loff_t *offset)
@@ -927,6 +928,7 @@ static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
 	/* And that's it, we'll issue the command on a read */
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(sbefifo_user_write);
 
 static int sbefifo_user_release(struct inode *inode, struct file *file)
 {
@@ -1004,8 +1006,8 @@ static long sbefifo_user_ioctl(struct file *file, unsigned int cmd, unsigned lon
 static const struct file_operations sbefifo_fops = {
 	.owner		= THIS_MODULE,
 	.open		= sbefifo_user_open,
-	.read		= sbefifo_user_read,
-	.write		= sbefifo_user_write,
+	.read_iter	= sbefifo_user_read_iter,
+	.write_iter	= sbefifo_user_write_iter,
 	.release	= sbefifo_user_release,
 	.unlocked_ioctl = sbefifo_user_ioctl,
 };
diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c
index 61dbda9dbe2b..1e8e5dcdfb39 100644
--- a/drivers/fsi/fsi-scom.c
+++ b/drivers/fsi/fsi-scom.c
@@ -310,11 +310,11 @@ static int get_scom(struct scom_device *scom, uint64_t *value,
 				 >> SCOM_STATUS_PIB_RESP_SHIFT);
 }
 
-static ssize_t scom_read(struct file *filep, char __user *buf, size_t len,
-			 loff_t *offset)
+static ssize_t scom_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct scom_device *scom = filep->private_data;
+	struct scom_device *scom = iocb->ki_filp->private_data;
 	struct device *dev = &scom->fsi_dev->dev;
+	size_t len = iov_iter_count(to);
 	uint64_t val;
 	int rc;
 
@@ -325,32 +325,32 @@ static ssize_t scom_read(struct file *filep, char __user *buf, size_t len,
 	if (scom->dead)
 		rc = -ENODEV;
 	else
-		rc = get_scom(scom, &val, *offset);
+		rc = get_scom(scom, &val, iocb->ki_pos);
 	mutex_unlock(&scom->lock);
 	if (rc) {
 		dev_dbg(dev, "get_scom fail:%d\n", rc);
 		return rc;
 	}
 
-	rc = copy_to_user(buf, &val, len);
+	rc = !copy_to_iter_full(&val, len, to);
 	if (rc)
 		dev_dbg(dev, "copy to user failed:%d\n", rc);
 
 	return rc ? rc : len;
 }
 
-static ssize_t scom_write(struct file *filep, const char __user *buf,
-			  size_t len, loff_t *offset)
+static ssize_t scom_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int rc;
-	struct scom_device *scom = filep->private_data;
+	struct scom_device *scom = iocb->ki_filp->private_data;
 	struct device *dev = &scom->fsi_dev->dev;
+	size_t len = iov_iter_count(from);
 	uint64_t val;
 
 	if (len != sizeof(uint64_t))
 		return -EINVAL;
 
-	rc = copy_from_user(&val, buf, len);
+	rc = !copy_from_iter_full(&val, len, from);
 	if (rc) {
 		dev_dbg(dev, "copy from user failed:%d\n", rc);
 		return -EINVAL;
@@ -360,7 +360,7 @@ static ssize_t scom_write(struct file *filep, const char __user *buf,
 	if (scom->dead)
 		rc = -ENODEV;
 	else
-		rc = put_scom(scom, val, *offset);
+		rc = put_scom(scom, val, iocb->ki_pos);
 	mutex_unlock(&scom->lock);
 	if (rc) {
 		dev_dbg(dev, "put_scom failed with:%d\n", rc);
@@ -514,8 +514,8 @@ static const struct file_operations scom_fops = {
 	.owner		= THIS_MODULE,
 	.open		= scom_open,
 	.llseek		= scom_llseek,
-	.read		= scom_read,
-	.write		= scom_write,
+	.read_iter	= scom_read,
+	.write_iter	= scom_write,
 	.unlocked_ioctl	= scom_ioctl,
 };
 
diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c
index cb7e02213032..e4b3a8310775 100644
--- a/drivers/fsi/i2cr-scom.c
+++ b/drivers/fsi/i2cr-scom.c
@@ -32,41 +32,42 @@ static loff_t i2cr_scom_llseek(struct file *file, loff_t offset, int whence)
 	return offset;
 }
 
-static ssize_t i2cr_scom_read(struct file *filep, char __user *buf, size_t len, loff_t *offset)
+static ssize_t i2cr_scom_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct i2cr_scom *scom = filep->private_data;
+	struct i2cr_scom *scom = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	u64 data;
 	int ret;
 
 	if (len != sizeof(data))
 		return -EINVAL;
 
-	ret = fsi_master_i2cr_read(scom->i2cr, (u32)*offset, &data);
+	ret = fsi_master_i2cr_read(scom->i2cr, (u32)iocb->ki_pos, &data);
 	if (ret)
 		return ret;
 
-	ret = copy_to_user(buf, &data, len);
+	ret = !copy_to_iter_full(&data, len, to);
 	if (ret)
 		return ret;
 
 	return len;
 }
 
-static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_t len,
-			       loff_t *offset)
+static ssize_t i2cr_scom_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct i2cr_scom *scom = filep->private_data;
+	struct i2cr_scom *scom = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	u64 data;
 	int ret;
 
 	if (len != sizeof(data))
 		return -EINVAL;
 
-	ret = copy_from_user(&data, buf, len);
+	ret = !copy_from_iter(&data, len, from);
 	if (ret)
 		return ret;
 
-	ret = fsi_master_i2cr_write(scom->i2cr, (u32)*offset, data);
+	ret = fsi_master_i2cr_write(scom->i2cr, (u32)iocb->ki_pos, data);
 	if (ret)
 		return ret;
 
@@ -77,8 +78,8 @@ static const struct file_operations i2cr_scom_fops = {
 	.owner		= THIS_MODULE,
 	.open		= simple_open,
 	.llseek		= i2cr_scom_llseek,
-	.read		= i2cr_scom_read,
-	.write		= i2cr_scom_write,
+	.read_iter	= i2cr_scom_read,
+	.write_iter	= i2cr_scom_write,
 };
 
 static int i2cr_scom_probe(struct device *dev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 377/437] iio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (375 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 376/437] drivers/fsi: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 378/437] iio: adis16400: " Jens Axboe
                   ` (60 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/iio_core.h            |  7 +++----
 drivers/iio/industrialio-buffer.c | 20 +++++++++---------
 drivers/iio/industrialio-core.c   | 34 +++++++++++++++----------------
 drivers/iio/industrialio-event.c  |  3 ++-
 4 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
index 1a38b1915e7a..8aac545ec4d0 100644
--- a/drivers/iio/iio_core.h
+++ b/drivers/iio/iio_core.h
@@ -11,6 +11,7 @@
 #define _IIO_CORE_H_
 #include <linux/kernel.h>
 #include <linux/device.h>
+#include <linux/fs.h>
 
 struct iio_buffer;
 struct iio_chan_spec;
@@ -63,10 +64,8 @@ struct poll_table_struct;
 
 __poll_t iio_buffer_poll_wrapper(struct file *filp,
 				 struct poll_table_struct *wait);
-ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
-				size_t n, loff_t *f_ps);
-ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,
-				 size_t n, loff_t *f_ps);
+ssize_t iio_buffer_read_wrapper( struct kiocb *iocb, struct iov_iter *to);
+ssize_t iio_buffer_write_wrapper( struct kiocb *iocb, struct iov_iter *from);
 
 int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev);
 void iio_buffers_free_sysfs_and_mask(struct iio_dev *indio_dev);
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index b581a7e80566..38a75f88adf6 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -163,6 +163,7 @@ static ssize_t iio_buffer_read(struct file *filp, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(iio_buffer_read);
 
 static size_t iio_buffer_space_available(struct iio_buffer *buf)
 {
@@ -225,6 +226,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
 
 	return ret < 0 ? ret : written;
 }
+FOPS_WRITE_ITER_HELPER(iio_buffer_write);
 
 /**
  * iio_buffer_poll() - poll the buffer to find out if it has data
@@ -261,30 +263,28 @@ static __poll_t iio_buffer_poll(struct file *filp,
 	return 0;
 }
 
-ssize_t iio_buffer_read_wrapper(struct file *filp, char __user *buf,
-				size_t n, loff_t *f_ps)
+ssize_t iio_buffer_read_wrapper(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iio_dev_buffer_pair *ib = filp->private_data;
+	struct iio_dev_buffer_pair *ib = iocb->ki_filp->private_data;
 	struct iio_buffer *rb = ib->buffer;
 
 	/* check if buffer was opened through new API */
 	if (test_bit(IIO_BUSY_BIT_POS, &rb->flags))
 		return -EBUSY;
 
-	return iio_buffer_read(filp, buf, n, f_ps);
+	return vfs_read_iter(iocb, to, iio_buffer_read);
 }
 
-ssize_t iio_buffer_write_wrapper(struct file *filp, const char __user *buf,
-				 size_t n, loff_t *f_ps)
+ssize_t iio_buffer_write_wrapper(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct iio_dev_buffer_pair *ib = filp->private_data;
+	struct iio_dev_buffer_pair *ib = iocb->ki_filp->private_data;
 	struct iio_buffer *rb = ib->buffer;
 
 	/* check if buffer was opened through new API */
 	if (test_bit(IIO_BUSY_BIT_POS, &rb->flags))
 		return -EBUSY;
 
-	return iio_buffer_write(filp, buf, n, f_ps);
+	return vfs_write_iter(iocb, from, iio_buffer_write);
 }
 
 __poll_t iio_buffer_poll_wrapper(struct file *filp,
@@ -1537,8 +1537,8 @@ static int iio_buffer_chrdev_release(struct inode *inode, struct file *filep)
 static const struct file_operations iio_buffer_chrdev_fileops = {
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
-	.read = iio_buffer_read,
-	.write = iio_buffer_write,
+	.read_iter = iio_buffer_read_iter,
+	.write_iter = iio_buffer_write_iter,
 	.poll = iio_buffer_poll,
 	.release = iio_buffer_chrdev_release,
 };
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 4302093b92c7..6bf6818e505c 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -369,18 +369,17 @@ static void __exit iio_exit(void)
 }
 
 #if defined(CONFIG_DEBUG_FS)
-static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,
-			      size_t count, loff_t *ppos)
+static ssize_t iio_debugfs_read_reg(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iio_dev *indio_dev = file->private_data;
+	struct iio_dev *indio_dev = iocb->ki_filp->private_data;
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
 	unsigned int val = 0;
 	int ret;
 
-	if (*ppos > 0)
-		return simple_read_from_buffer(userbuf, count, ppos,
-					       iio_dev_opaque->read_buf,
-					       iio_dev_opaque->read_buf_len);
+	if (iocb->ki_pos > 0)
+		return simple_copy_to_iter(iio_dev_opaque->read_buf,
+					   &iocb->ki_pos,
+					   iio_dev_opaque->read_buf_len, to);
 
 	ret = indio_dev->info->debugfs_reg_access(indio_dev,
 						  iio_dev_opaque->cached_reg_addr,
@@ -394,22 +393,21 @@ static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,
 						sizeof(iio_dev_opaque->read_buf),
 						"0x%X\n", val);
 
-	return simple_read_from_buffer(userbuf, count, ppos,
-				       iio_dev_opaque->read_buf,
-				       iio_dev_opaque->read_buf_len);
+	return simple_copy_to_iter(iio_dev_opaque->read_buf, &iocb->ki_pos,
+				       iio_dev_opaque->read_buf_len, to);
 }
 
-static ssize_t iio_debugfs_write_reg(struct file *file,
-		     const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t iio_debugfs_write_reg(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct iio_dev *indio_dev = file->private_data;
+	struct iio_dev *indio_dev = iocb->ki_filp->private_data;
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+	size_t count = iov_iter_count(from);
 	unsigned int reg, val;
 	char buf[80];
 	int ret;
 
 	count = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = 0;
@@ -439,8 +437,8 @@ static ssize_t iio_debugfs_write_reg(struct file *file,
 
 static const struct file_operations iio_debugfs_reg_fops = {
 	.open = simple_open,
-	.read = iio_debugfs_read_reg,
-	.write = iio_debugfs_write_reg,
+	.read_iter = iio_debugfs_read_reg,
+	.write_iter = iio_debugfs_write_reg,
 };
 
 static void iio_device_unregister_debugfs(struct iio_dev *indio_dev)
@@ -1839,8 +1837,8 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 static const struct file_operations iio_buffer_fileops = {
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
-	.read = iio_buffer_read_outer_addr,
-	.write = iio_buffer_write_outer_addr,
+	.read_iter = iio_buffer_read_outer_addr,
+	.write_iter = iio_buffer_write_outer_addr,
 	.poll = iio_buffer_poll_addr,
 	.unlocked_ioctl = iio_ioctl,
 	.compat_ioctl = compat_ptr_ioctl,
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index 910c1f14abd5..b6ce1ac1d1ca 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -167,6 +167,7 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
 
 	return copied;
 }
+FOPS_READ_ITER_HELPER(iio_event_chrdev_read);
 
 static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
 {
@@ -182,7 +183,7 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
 }
 
 static const struct file_operations iio_event_chrdev_fileops = {
-	.read =  iio_event_chrdev_read,
+	.read_iter =  iio_event_chrdev_read_iter,
 	.poll =  iio_event_poll,
 	.release = iio_event_chrdev_release,
 	.owner = THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 378/437] iio: adis16400: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (376 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 377/437] iio: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 379/437] iio: adis16475: " Jens Axboe
                   ` (59 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/imu/adis16400.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
index 3eda32e12a53..78182bc33bac 100644
--- a/drivers/iio/imu/adis16400.c
+++ b/drivers/iio/imu/adis16400.c
@@ -204,10 +204,10 @@ enum {
 
 #ifdef CONFIG_DEBUG_FS
 
-static ssize_t adis16400_show_serial_number(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t adis16400_show_serial_number(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct adis16400_state *st = file->private_data;
+	struct adis16400_state *st = iocb->ki_filp->private_data;
 	u16 lot1, lot2, serial_number;
 	char buf[16];
 	size_t len;
@@ -229,12 +229,12 @@ static ssize_t adis16400_show_serial_number(struct file *file,
 	len = snprintf(buf, sizeof(buf), "%.4x-%.4x-%.4x\n", lot1, lot2,
 			serial_number);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16400_serial_number_fops = {
 	.open = simple_open,
-	.read = adis16400_show_serial_number,
+	.read_iter = adis16400_show_serial_number,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 379/437] iio: adis16475: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (377 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 378/437] iio: adis16400: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 380/437] iio: adis16480: " Jens Axboe
                   ` (58 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/imu/adis16475.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c
index 01f55cc902fa..6772ca783e9d 100644
--- a/drivers/iio/imu/adis16475.c
+++ b/drivers/iio/imu/adis16475.c
@@ -142,11 +142,10 @@ MODULE_PARM_DESC(low_rate_allow,
 		 "Allow IMU rates below the minimum advisable when external clk is used in SCALED mode (default: N)");
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t adis16475_show_firmware_revision(struct file *file,
-						char __user *userbuf,
-						size_t count, loff_t *ppos)
+static ssize_t adis16475_show_firmware_revision(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct adis16475 *st = file->private_data;
+	struct adis16475 *st = iocb->ki_filp->private_data;
 	char buf[7];
 	size_t len;
 	u16 rev;
@@ -158,21 +157,20 @@ static ssize_t adis16475_show_firmware_revision(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16475_firmware_revision_fops = {
 	.open = simple_open,
-	.read = adis16475_show_firmware_revision,
+	.read_iter = adis16475_show_firmware_revision,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t adis16475_show_firmware_date(struct file *file,
-					    char __user *userbuf,
-					    size_t count, loff_t *ppos)
+static ssize_t adis16475_show_firmware_date(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct adis16475 *st = file->private_data;
+	struct adis16475 *st = iocb->ki_filp->private_data;
 	u16 md, year;
 	char buf[12];
 	size_t len;
@@ -189,12 +187,12 @@ static ssize_t adis16475_show_firmware_date(struct file *file,
 	len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n", md >> 8, md & 0xff,
 		       year);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16475_firmware_date_fops = {
 	.open = simple_open,
-	.read = adis16475_show_firmware_date,
+	.read_iter = adis16475_show_firmware_date,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 380/437] iio: adis16480: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (378 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 379/437] iio: adis16475: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 381/437] iio: bno055: " Jens Axboe
                   ` (57 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/imu/adis16480.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
index b40a55bba30c..2664a187872f 100644
--- a/drivers/iio/imu/adis16480.c
+++ b/drivers/iio/imu/adis16480.c
@@ -188,10 +188,10 @@ MODULE_PARM_DESC(low_rate_allow,
 
 #ifdef CONFIG_DEBUG_FS
 
-static ssize_t adis16480_show_firmware_revision(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t adis16480_show_firmware_revision(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct adis16480 *adis16480 = file->private_data;
+	struct adis16480 *adis16480 = iocb->ki_filp->private_data;
 	char buf[7];
 	size_t len;
 	u16 rev;
@@ -203,20 +203,20 @@ static ssize_t adis16480_show_firmware_revision(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%x.%x\n", rev >> 8, rev & 0xff);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16480_firmware_revision_fops = {
 	.open = simple_open,
-	.read = adis16480_show_firmware_revision,
+	.read_iter = adis16480_show_firmware_revision,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t adis16480_show_firmware_date(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t adis16480_show_firmware_date(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct adis16480 *adis16480 = file->private_data;
+	struct adis16480 *adis16480 = iocb->ki_filp->private_data;
 	u16 md, year;
 	char buf[12];
 	size_t len;
@@ -233,12 +233,12 @@ static ssize_t adis16480_show_firmware_date(struct file *file,
 	len = snprintf(buf, sizeof(buf), "%.2x-%.2x-%.4x\n",
 			md >> 8, md & 0xff, year);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16480_firmware_date_fops = {
 	.open = simple_open,
-	.read = adis16480_show_firmware_date,
+	.read_iter = adis16480_show_firmware_date,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 381/437] iio: bno055: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (379 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 380/437] iio: adis16480: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 382/437] iio: gyro/adis16136: " Jens Axboe
                   ` (56 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/imu/bno055/bno055.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno055.c
index 52744dd98e65..729b42e31757 100644
--- a/drivers/iio/imu/bno055/bno055.c
+++ b/drivers/iio/imu/bno055/bno055.c
@@ -1269,10 +1269,9 @@ static int bno055_debugfs_reg_access(struct iio_dev *iio_dev, unsigned int reg,
 		return regmap_write(priv->regmap, reg, writeval);
 }
 
-static ssize_t bno055_show_fw_version(struct file *file, char __user *userbuf,
-				      size_t count, loff_t *ppos)
+static ssize_t bno055_show_fw_version( struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bno055_priv *priv = file->private_data;
+	struct bno055_priv *priv = iocb->ki_filp->private_data;
 	int rev, ver;
 	char *buf;
 	int ret;
@@ -1289,7 +1288,7 @@ static ssize_t bno055_show_fw_version(struct file *file, char __user *userbuf,
 	if (!buf)
 		return -ENOMEM;
 
-	ret = simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 
 	return ret;
@@ -1297,7 +1296,7 @@ static ssize_t bno055_show_fw_version(struct file *file, char __user *userbuf,
 
 static const struct file_operations bno055_fw_version_ops = {
 	.open = simple_open,
-	.read = bno055_show_fw_version,
+	.read_iter = bno055_show_fw_version,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 382/437] iio: gyro/adis16136: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (380 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 381/437] iio: bno055: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 383/437] intel_th: " Jens Axboe
                   ` (55 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/iio/gyro/adis16136.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
index c95cf41be34b..3fa17f582444 100644
--- a/drivers/iio/gyro/adis16136.c
+++ b/drivers/iio/gyro/adis16136.c
@@ -65,10 +65,9 @@ struct adis16136 {
 
 #ifdef CONFIG_DEBUG_FS
 
-static ssize_t adis16136_show_serial(struct file *file,
-		char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t adis16136_show_serial(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct adis16136 *adis16136 = file->private_data;
+	struct adis16136 *adis16136 = iocb->ki_filp->private_data;
 	uint16_t lot1, lot2, lot3, serial;
 	char buf[20];
 	size_t len;
@@ -94,12 +93,12 @@ static ssize_t adis16136_show_serial(struct file *file,
 	len = snprintf(buf, sizeof(buf), "%.4x%.4x%.4x-%.4x\n", lot1, lot2,
 		lot3, serial);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations adis16136_serial_fops = {
 	.open = simple_open,
-	.read = adis16136_show_serial,
+	.read_iter = adis16136_show_serial,
 	.llseek = default_llseek,
 	.owner = THIS_MODULE,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 383/437] intel_th: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (381 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 382/437] iio: gyro/adis16136: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 384/437] stm class: " Jens Axboe
                   ` (54 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwtracing/intel_th/msu.c | 46 +++++++++++++++-----------------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 9621efe0e95c..a48d7ca8209a 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1429,8 +1429,8 @@ static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff)
  * @offset:	running offset
  */
 struct msc_win_to_user_struct {
-	char __user	*buf;
-	unsigned long	offset;
+	struct iov_iter	*to;
+	struct kiocb	*iocb;
 };
 
 /**
@@ -1442,11 +1442,11 @@ struct msc_win_to_user_struct {
 static unsigned long msc_win_to_user(void *data, void *src, size_t len)
 {
 	struct msc_win_to_user_struct *u = data;
-	unsigned long ret;
-
-	ret = copy_to_user(u->buf + u->offset, src, len);
-	u->offset += len - ret;
+	size_t ret;
 
+	ret = copy_to_iter(src, len, u->to);
+	if (ret > 0)
+		u->iocb->ki_pos += ret;
 	return ret;
 }
 
@@ -1483,20 +1483,20 @@ static int intel_th_msc_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len)
+static ssize_t msc_single_to_user(struct msc *msc, struct kiocb *iocb,
+				  struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	unsigned long size = msc->nr_pages << PAGE_SHIFT, rem = len;
-	unsigned long start = off, tocopy = 0;
+	unsigned long start = iocb->ki_pos, tocopy = 0;
 
 	if (msc->single_wrap) {
 		start += msc->single_sz;
 		if (start < size) {
 			tocopy = min(rem, size - start);
-			if (copy_to_user(buf, msc->base + start, tocopy))
+			if (!copy_to_iter_full(msc->base + start, tocopy, to))
 				return -EFAULT;
 
-			buf += tocopy;
 			rem -= tocopy;
 			start += tocopy;
 		}
@@ -1504,7 +1504,7 @@ msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len)
 		start &= size - 1;
 		if (rem) {
 			tocopy = min(rem, msc->single_sz - start);
-			if (copy_to_user(buf, msc->base + start, tocopy))
+			if (!copy_to_iter_full(msc->base + start, tocopy, to))
 				return -EFAULT;
 
 			rem -= tocopy;
@@ -1513,19 +1513,19 @@ msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len)
 		return len - rem;
 	}
 
-	if (copy_to_user(buf, msc->base + start, rem))
+	if (!copy_to_iter_full(msc->base + start, rem, to))
 		return -EFAULT;
 
 	return len;
 }
 
-static ssize_t intel_th_msc_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *ppos)
+static ssize_t intel_th_msc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct msc_iter *iter = file->private_data;
+	struct msc_iter *iter = iocb->ki_filp->private_data;
 	struct msc *msc = iter->msc;
+	size_t len = iov_iter_count(to);
 	size_t size;
-	loff_t off = *ppos;
+	loff_t off = iocb->ki_pos;
 	ssize_t ret = 0;
 
 	if (!atomic_inc_unless_negative(&msc->user_count))
@@ -1546,18 +1546,16 @@ static ssize_t intel_th_msc_read(struct file *file, char __user *buf,
 		len = size - off;
 
 	if (msc->mode == MSC_MODE_SINGLE) {
-		ret = msc_single_to_user(msc, buf, off, len);
+		ret = msc_single_to_user(msc, iocb, to);
 		if (ret >= 0)
-			*ppos += ret;
+			iocb->ki_pos += ret;
 	} else if (msc->mode == MSC_MODE_MULTI) {
 		struct msc_win_to_user_struct u = {
-			.buf	= buf,
-			.offset	= 0,
+			.to	= to,
+			.iocb	= iocb,
 		};
 
 		ret = msc_buffer_iterate(iter, len, &u, msc_win_to_user);
-		if (ret >= 0)
-			*ppos = iter->offset;
 	} else {
 		ret = -EINVAL;
 	}
@@ -1667,7 +1665,7 @@ static int intel_th_msc_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations intel_th_msc_fops = {
 	.open		= intel_th_msc_open,
 	.release	= intel_th_msc_release,
-	.read		= intel_th_msc_read,
+	.read_iter	= intel_th_msc_read,
 	.mmap		= intel_th_msc_mmap,
 	.llseek		= no_llseek,
 	.owner		= THIS_MODULE,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 384/437] stm class: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (382 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 383/437] intel_th: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 385/437] speakup: " Jens Axboe
                   ` (53 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hwtracing/stm/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 534fbefc7f6a..c66f1864adcd 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -615,11 +615,11 @@ stm_write(struct stm_device *stm, struct stm_output *output,
 	return err;
 }
 
-static ssize_t stm_char_write(struct file *file, const char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t stm_char_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct stm_file *stmf = file->private_data;
+	struct stm_file *stmf = iocb->ki_filp->private_data;
 	struct stm_device *stm = stmf->stm;
+	size_t count = iov_iter_count(from);
 	char *kbuf;
 	int err;
 
@@ -649,7 +649,7 @@ static ssize_t stm_char_write(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	err = copy_from_user(kbuf, buf, count);
+	err = !copy_from_iter_full(kbuf, count, from);
 	if (err) {
 		kfree(kbuf);
 		return -EFAULT;
@@ -835,7 +835,7 @@ stm_char_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static const struct file_operations stm_fops = {
 	.open		= stm_char_open,
 	.release	= stm_char_release,
-	.write		= stm_char_write,
+	.write_iter	= stm_char_write,
 	.mmap		= stm_char_mmap,
 	.unlocked_ioctl	= stm_char_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 385/437] speakup: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (383 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 384/437] stm class: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 386/437] EDAC/versal: " Jens Axboe
                   ` (52 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/accessibility/speakup/devsynth.c     | 27 +++++-------
 drivers/accessibility/speakup/speakup_soft.c | 46 +++++++++-----------
 2 files changed, 31 insertions(+), 42 deletions(-)

diff --git a/drivers/accessibility/speakup/devsynth.c b/drivers/accessibility/speakup/devsynth.c
index cb7e1114e8eb..dd65b3882344 100644
--- a/drivers/accessibility/speakup/devsynth.c
+++ b/drivers/accessibility/speakup/devsynth.c
@@ -11,11 +11,10 @@ static int synth_registered, synthu_registered;
 static int dev_opened;
 
 /* Latin1 version */
-static ssize_t speakup_file_write(struct file *fp, const char __user *buffer,
-				  size_t nbytes, loff_t *ppos)
+static ssize_t speakup_file_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t nbytes = iov_iter_count(from);
 	size_t count = nbytes;
-	const char __user *ptr = buffer;
 	size_t bytes;
 	unsigned long flags;
 	u_char buf[256];
@@ -24,10 +23,9 @@ static ssize_t speakup_file_write(struct file *fp, const char __user *buffer,
 		return -ENODEV;
 	while (count > 0) {
 		bytes = min(count, sizeof(buf));
-		if (copy_from_user(buf, ptr, bytes))
+		if (!copy_from_iter_full(buf, bytes, from))
 			return -EFAULT;
 		count -= bytes;
-		ptr += bytes;
 		spin_lock_irqsave(&speakup_info.spinlock, flags);
 		synth_write(buf, bytes);
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
@@ -36,11 +34,10 @@ static ssize_t speakup_file_write(struct file *fp, const char __user *buffer,
 }
 
 /* UTF-8 version */
-static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,
-				   size_t nbytes, loff_t *ppos)
+static ssize_t speakup_file_writeu(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t nbytes = iov_iter_count(from);
 	size_t count = nbytes, want;
-	const char __user *ptr = buffer;
 	size_t bytes;
 	unsigned long flags;
 	unsigned char buf[256];
@@ -54,7 +51,7 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,
 	while (count >= want) {
 		/* Copy some UTF-8 piece from userland */
 		bytes = min(count, sizeof(buf));
-		if (copy_from_user(buf, ptr, bytes))
+		if (!copy_from_iter_full(buf, bytes, from))
 			return -EFAULT;
 
 		/* Convert to u16 */
@@ -112,7 +109,6 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,
 		}
 
 		count -= bytes;
-		ptr += bytes;
 
 		/* And speak this up */
 		if (out) {
@@ -127,8 +123,7 @@ static ssize_t speakup_file_writeu(struct file *fp, const char __user *buffer,
 	return (ssize_t)(nbytes - count);
 }
 
-static ssize_t speakup_file_read(struct file *fp, char __user *buf,
-				 size_t nbytes, loff_t *ppos)
+static ssize_t speakup_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -149,15 +144,15 @@ static int speakup_file_release(struct inode *ip, struct file *fp)
 }
 
 static const struct file_operations synth_fops = {
-	.read = speakup_file_read,
-	.write = speakup_file_write,
+	.read_iter = speakup_file_read,
+	.write_iter = speakup_file_write,
 	.open = speakup_file_open,
 	.release = speakup_file_release,
 };
 
 static const struct file_operations synthu_fops = {
-	.read = speakup_file_read,
-	.write = speakup_file_writeu,
+	.read_iter = speakup_file_read,
+	.write_iter = speakup_file_writeu,
 	.open = speakup_file_open,
 	.release = speakup_file_release,
 };
diff --git a/drivers/accessibility/speakup/speakup_soft.c b/drivers/accessibility/speakup/speakup_soft.c
index 6d446824677b..bc88e7e25910 100644
--- a/drivers/accessibility/speakup/speakup_soft.c
+++ b/drivers/accessibility/speakup/speakup_soft.c
@@ -215,17 +215,17 @@ static int softsynth_close(struct inode *inode, struct file *fp)
 	return 0;
 }
 
-static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
-			       loff_t *pos, int unicode)
+static ssize_t softsynthx_read(struct kiocb *iocb, struct iov_iter *to,
+			       int unicode)
 {
 	int chars_sent = 0;
-	char __user *cp;
 	char *init;
 	size_t bytes_per_ch = unicode ? 3 : 1;
 	u16 ch;
 	int empty;
 	unsigned long flags;
 	DEFINE_WAIT(wait);
+	size_t count = iov_iter_count(to);
 
 	if (count < bytes_per_ch)
 		return -EINVAL;
@@ -241,7 +241,7 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
 				break;
 		}
 		spin_unlock_irqrestore(&speakup_info.spinlock, flags);
-		if (fp->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			finish_wait(&speakup_event, &wait);
 			return -EAGAIN;
 		}
@@ -254,7 +254,6 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
 	}
 	finish_wait(&speakup_event, &wait);
 
-	cp = buf;
 	init = get_initstring();
 
 	/* Keep 3 bytes available for a 16bit UTF-8-encoded character */
@@ -278,22 +277,20 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
 		if ((!unicode && ch < 0x100) || (unicode && ch < 0x80)) {
 			u_char c = ch;
 
-			if (copy_to_user(cp, &c, 1))
+			if (!copy_to_iter_full(&c, 1, to))
 				return -EFAULT;
 
 			chars_sent++;
-			cp++;
 		} else if (unicode && ch < 0x800) {
 			u_char s[2] = {
 				0xc0 | (ch >> 6),
 				0x80 | (ch & 0x3f)
 			};
 
-			if (copy_to_user(cp, s, sizeof(s)))
+			if (!copy_to_iter_full(s, sizeof(s), to))
 				return -EFAULT;
 
 			chars_sent += sizeof(s);
-			cp += sizeof(s);
 		} else if (unicode) {
 			u_char s[3] = {
 				0xe0 | (ch >> 12),
@@ -301,46 +298,43 @@ static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count,
 				0x80 | (ch & 0x3f)
 			};
 
-			if (copy_to_user(cp, s, sizeof(s)))
+			if (!copy_to_iter_full(s, sizeof(s), to))
 				return -EFAULT;
 
 			chars_sent += sizeof(s);
-			cp += sizeof(s);
 		}
 
 		spin_lock_irqsave(&speakup_info.spinlock, flags);
 	}
-	*pos += chars_sent;
+	iocb->ki_pos += chars_sent;
 	empty = synth_buffer_empty();
 	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 	if (empty) {
 		speakup_start_ttys();
-		*pos = 0;
+		iocb->ki_pos = 0;
 	}
 	return chars_sent;
 }
 
-static ssize_t softsynth_read(struct file *fp, char __user *buf, size_t count,
-			      loff_t *pos)
+static ssize_t softsynth_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return softsynthx_read(fp, buf, count, pos, 0);
+	return softsynthx_read(iocb, to, 0);
 }
 
-static ssize_t softsynthu_read(struct file *fp, char __user *buf, size_t count,
-			       loff_t *pos)
+static ssize_t softsynthu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return softsynthx_read(fp, buf, count, pos, 1);
+	return softsynthx_read(iocb, to, 1);
 }
 
 static int last_index;
 
-static ssize_t softsynth_write(struct file *fp, const char __user *buf,
-			       size_t count, loff_t *pos)
+static ssize_t softsynth_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	unsigned long supplied_index = 0;
+	size_t count = iov_iter_count(from);
 	int converted;
 
-	converted = kstrtoul_from_user(buf, count, 0, &supplied_index);
+	converted = kstrtoul_from_iter(from, count, 0, &supplied_index);
 
 	if (converted < 0)
 		return converted;
@@ -376,8 +370,8 @@ static unsigned char get_index(struct spk_synth *synth)
 static const struct file_operations softsynth_fops = {
 	.owner = THIS_MODULE,
 	.poll = softsynth_poll,
-	.read = softsynth_read,
-	.write = softsynth_write,
+	.read_iter = softsynth_read,
+	.write_iter = softsynth_write,
 	.open = softsynth_open,
 	.release = softsynth_close,
 };
@@ -385,8 +379,8 @@ static const struct file_operations softsynth_fops = {
 static const struct file_operations softsynthu_fops = {
 	.owner = THIS_MODULE,
 	.poll = softsynth_poll,
-	.read = softsynthu_read,
-	.write = softsynth_write,
+	.read_iter = softsynthu_read,
+	.write_iter = softsynth_write,
 	.open = softsynth_open,
 	.release = softsynth_close,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 386/437] EDAC/versal: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (384 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 385/437] speakup: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 387/437] EDAC/xgene: " Jens Axboe
                   ` (51 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/versal_edac.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/edac/versal_edac.c b/drivers/edac/versal_edac.c
index 1688a5050f63..bd3abd3598ba 100644
--- a/drivers/edac/versal_edac.c
+++ b/drivers/edac/versal_edac.c
@@ -781,16 +781,16 @@ static void xddr_inject_data_ce_store(struct mem_ctl_info *mci, u8 ce_bitpos)
  *
  * Upon doing a read to the address the errors are injected.
  */
-static ssize_t inject_data_ce_store(struct file *file, const char __user *data,
-				    size_t count, loff_t *ppos)
+static ssize_t inject_data_ce_store(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
 	struct edac_priv *priv = mci->pvt_info;
+	size_t count = iov_iter_count(from);
 	u8 ce_bitpos;
 	int ret;
 
-	ret = kstrtou8_from_user(data, count, 0, &ce_bitpos);
+	ret = kstrtou8_from_iter(from, count, 0, &ce_bitpos);
 	if (ret)
 		return ret;
 
@@ -812,7 +812,7 @@ static ssize_t inject_data_ce_store(struct file *file, const char __user *data,
 
 static const struct file_operations xddr_inject_ce_fops = {
 	.open = simple_open,
-	.write = inject_data_ce_store,
+	.write_iter = inject_data_ce_store,
 	.llseek = generic_file_llseek,
 };
 
@@ -845,19 +845,19 @@ static void xddr_inject_data_ue_store(struct mem_ctl_info *mci, u32 val0, u32 va
  *
  * Upon doing a read to the address the errors are injected.
  */
-static ssize_t inject_data_ue_store(struct file *file, const char __user *data,
-				    size_t count, loff_t *ppos)
+static ssize_t inject_data_ue_store(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
 	struct edac_priv *priv = mci->pvt_info;
+	size_t count = iov_iter_count(from);
 	char buf[6], *pbuf, *token[2];
 	u32 val0 = 0, val1 = 0;
 	u8 len, ue0, ue1;
 	int i, ret;
 
 	len = min_t(size_t, count, sizeof(buf));
-	if (copy_from_user(buf, data, len))
+	if (!copy_from_iter_full(from, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -903,7 +903,7 @@ static ssize_t inject_data_ue_store(struct file *file, const char __user *data,
 
 static const struct file_operations xddr_inject_ue_fops = {
 	.open = simple_open,
-	.write = inject_data_ue_store,
+	.write_iter = inject_data_ue_store,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 387/437] EDAC/xgene: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (385 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 386/437] EDAC/versal: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 388/437] EDAC/zynqmp: " Jens Axboe
                   ` (50 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/xgene_edac.c | 43 ++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/drivers/edac/xgene_edac.c b/drivers/edac/xgene_edac.c
index 1b50f8160013..deabb9743f9e 100644
--- a/drivers/edac/xgene_edac.c
+++ b/drivers/edac/xgene_edac.c
@@ -137,11 +137,10 @@ struct xgene_edac_mc_ctx {
 	u32			mcu_id;
 };
 
-static ssize_t xgene_edac_mc_err_inject_write(struct file *file,
-					      const char __user *data,
-					      size_t count, loff_t *ppos)
+static ssize_t xgene_edac_mc_err_inject_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct mem_ctl_info *mci = file->private_data;
+	struct mem_ctl_info *mci = iocb->ki_filp->private_data;
 	struct xgene_edac_mc_ctx *ctx = mci->pvt_info;
 	int i;
 
@@ -150,12 +149,12 @@ static ssize_t xgene_edac_mc_err_inject_write(struct file *file,
 		       MCU_ESRR_DEMANDUCERR_MASK | MCU_ESRR_CERR_MASK,
 		       ctx->mcu_csr + MCUESRRA0 + i * MCU_RANK_STRIDE);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations xgene_edac_mc_debug_inject_fops = {
 	.open = simple_open,
-	.write = xgene_edac_mc_err_inject_write,
+	.write_iter = xgene_edac_mc_err_inject_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -803,11 +802,10 @@ static void xgene_edac_pmd_hw_ctl(struct edac_device_ctl_info *edac_dev,
 	}
 }
 
-static ssize_t xgene_edac_pmd_l1_inject_ctrl_write(struct file *file,
-						   const char __user *data,
-						   size_t count, loff_t *ppos)
+static ssize_t xgene_edac_pmd_l1_inject_ctrl_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dev = file->private_data;
+	struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;
 	struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info;
 	void __iomem *cpux_pg_f;
 	int i;
@@ -826,16 +824,16 @@ static ssize_t xgene_edac_pmd_l1_inject_ctrl_write(struct file *file,
 		       MEMERR_CPU_MMUESR_CERR_MASK,
 		       cpux_pg_f + MEMERR_CPU_MMUESRA_PAGE_OFFSET);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
-static ssize_t xgene_edac_pmd_l2_inject_ctrl_write(struct file *file,
-						   const char __user *data,
-						   size_t count, loff_t *ppos)
+static ssize_t xgene_edac_pmd_l2_inject_ctrl_write(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dev = file->private_data;
+	struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;
 	struct xgene_edac_pmd_ctx *ctx = edac_dev->pvt_info;
 	void __iomem *pg_e = ctx->pmd_csr + CPU_MEMERR_L2C_PAGE;
+	size_t count = iov_iter_count(from);
 
 	writel(MEMERR_L2C_L2ESR_MULTUCERR_MASK |
 	       MEMERR_L2C_L2ESR_MULTICERR_MASK |
@@ -848,11 +846,11 @@ static ssize_t xgene_edac_pmd_l2_inject_ctrl_write(struct file *file,
 static const struct file_operations xgene_edac_pmd_debug_inject_fops[] = {
 	{
 	.open = simple_open,
-	.write = xgene_edac_pmd_l1_inject_ctrl_write,
+	.write_iter = xgene_edac_pmd_l1_inject_ctrl_write,
 	.llseek = generic_file_llseek, },
 	{
 	.open = simple_open,
-	.write = xgene_edac_pmd_l2_inject_ctrl_write,
+	.write_iter = xgene_edac_pmd_l2_inject_ctrl_write,
 	.llseek = generic_file_llseek, },
 	{ }
 };
@@ -1143,21 +1141,20 @@ static void xgene_edac_l3_hw_init(struct edac_device_ctl_info *edac_dev,
 	}
 }
 
-static ssize_t xgene_edac_l3_inject_ctrl_write(struct file *file,
-					       const char __user *data,
-					       size_t count, loff_t *ppos)
+static ssize_t xgene_edac_l3_inject_ctrl_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dev = file->private_data;
+	struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;
 	struct xgene_edac_dev_ctx *ctx = edac_dev->pvt_info;
 
 	/* Generate all errors */
 	writel(0xFFFFFFFF, ctx->dev_csr + L3C_ESR);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations xgene_edac_l3_debug_inject_fops = {
 	.open = simple_open,
-	.write = xgene_edac_l3_inject_ctrl_write,
+	.write_iter = xgene_edac_l3_inject_ctrl_write,
 	.llseek = generic_file_llseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 388/437] EDAC/zynqmp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (386 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 387/437] EDAC/xgene: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 389/437] EDAC/thunderx: " Jens Axboe
                   ` (49 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/zynqmp_edac.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/edac/zynqmp_edac.c b/drivers/edac/zynqmp_edac.c
index 2d9a5cfd8931..53d697b4137a 100644
--- a/drivers/edac/zynqmp_edac.c
+++ b/drivers/edac/zynqmp_edac.c
@@ -247,17 +247,14 @@ static void write_fault_count(struct edac_priv *priv)
  * - Write the Correctable Error bit position value:
  *	echo <bit_pos val> > /sys/kernel/debug/edac/ocm/inject_ce_bitpos
  */
-static ssize_t inject_ce_write(struct file *file, const char __user *data,
-			       size_t count, loff_t *ppos)
+static ssize_t inject_ce_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dev = file->private_data;
+	struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;
 	struct edac_priv *priv = edac_dev->pvt_info;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	if (!data)
-		return -EFAULT;
-
-	ret = kstrtou8_from_user(data, count, 0, &priv->ce_bitpos);
+	ret = kstrtou8_from_iter(from, count, 0, &priv->ce_bitpos);
 	if (ret)
 		return ret;
 
@@ -280,7 +277,7 @@ static ssize_t inject_ce_write(struct file *file, const char __user *data,
 
 static const struct file_operations inject_ce_fops = {
 	.open = simple_open,
-	.write = inject_ce_write,
+	.write_iter = inject_ce_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -291,21 +288,18 @@ static const struct file_operations inject_ce_fops = {
  * - Write the Uncorrectable Error bit position values:
  *      echo <bit_pos0 val>,<bit_pos1 val> > /sys/kernel/debug/edac/ocm/inject_ue_bitpos
  */
-static ssize_t inject_ue_write(struct file *file, const char __user *data,
-			       size_t count, loff_t *ppos)
+static ssize_t inject_ue_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dev = file->private_data;
+	struct edac_device_ctl_info *edac_dev = iocb->ki_filp->private_data;
 	struct edac_priv *priv = edac_dev->pvt_info;
 	char buf[6], *pbuf, *token[2];
+	size_t count = iov_iter_count(from);
 	u64 ue_bitpos;
 	int i, ret;
 	u8 len;
 
-	if (!data)
-		return -EFAULT;
-
 	len = min_t(size_t, count, sizeof(buf));
-	if (copy_from_user(buf, data, len))
+	if (!copy_from_iter_full(from, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -342,7 +336,7 @@ static ssize_t inject_ue_write(struct file *file, const char __user *data,
 
 static const struct file_operations inject_ue_fops = {
 	.open = simple_open,
-	.write = inject_ue_write,
+	.write_iter = inject_ue_write,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 389/437] EDAC/thunderx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (387 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 388/437] EDAC/zynqmp: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 390/437] EDAC/npcm: " Jens Axboe
                   ` (48 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/thunderx_edac.c | 71 +++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 38 deletions(-)

diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c
index 90d46e5c4ff0..54edd310c6f0 100644
--- a/drivers/edac/thunderx_edac.c
+++ b/drivers/edac/thunderx_edac.c
@@ -219,33 +219,32 @@ static struct debugfs_entry debugfs_##_name = {				    \
 	.mode = VERIFY_OCTAL_PERMISSIONS(_mode),			    \
 	.fops = {							    \
 		.open = simple_open,					    \
-		.write = _write,					    \
-		.read  = _read,						    \
+		.write_iter = _write,					    \
+		.read_iter  = _read,					    \
 		.llseek = generic_file_llseek,				    \
 	},								    \
 }
 
 #define DEBUGFS_FIELD_ATTR(_type, _field)				    \
-static ssize_t thunderx_##_type##_##_field##_read(struct file *file,	    \
-					    char __user *data,		    \
-					    size_t count, loff_t *ppos)	    \
+static ssize_t thunderx_##_type##_##_field##_read(struct kiocb *iocb,	    \
+					    struct iov_iter *to)	    \
 {									    \
-	struct thunderx_##_type *pdata = file->private_data;		    \
+	struct thunderx_##_type *pdata = iocb->ki_filp->private_data;	    \
+	size_t count = iov_iter_count(to);				    \
 	char buf[20];							    \
 									    \
 	snprintf(buf, count, "0x%016llx", pdata->_field);		    \
-	return simple_read_from_buffer(data, count, ppos,		    \
-				       buf, sizeof(buf));		    \
+	return simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), to);    \
 }									    \
 									    \
-static ssize_t thunderx_##_type##_##_field##_write(struct file *file,	    \
-					     const char __user *data,	    \
-					     size_t count, loff_t *ppos)    \
+static ssize_t thunderx_##_type##_##_field##_write(struct kiocb *iocb,	    \
+					     struct iov_iter *from)	    \
 {									    \
-	struct thunderx_##_type *pdata = file->private_data;		    \
+	struct thunderx_##_type *pdata = iocb->ki_filp->private_data;	    \
+	size_t count = iov_iter_count(from);				    \
 	int res;							    \
 									    \
-	res = kstrtoull_from_user(data, count, 0, &pdata->_field);	    \
+	res = kstrtoull_from_iter(from, count, 0, &pdata->_field);	    \
 									    \
 	return res ? res : count;					    \
 }									    \
@@ -255,27 +254,25 @@ DEBUGFS_STRUCT(_field, 0600,						    \
 		   thunderx_##_type##_##_field##_read)			    \
 
 #define DEBUGFS_REG_ATTR(_type, _name, _reg)				    \
-static ssize_t thunderx_##_type##_##_name##_read(struct file *file,	    \
-					   char __user *data,		    \
-					   size_t count, loff_t *ppos)      \
+static ssize_t thunderx_##_type##_##_name##_read(struct kiocb *iocb,	    \
+					   struct iov_iter *to)		    \
 {									    \
-	struct thunderx_##_type *pdata = file->private_data;		    \
+	struct thunderx_##_type *pdata = iocb->ki_filp->private_data;	    \
 	char buf[20];							    \
 									    \
 	sprintf(buf, "0x%016llx", readq(pdata->regs + _reg));		    \
-	return simple_read_from_buffer(data, count, ppos,		    \
-				       buf, sizeof(buf));		    \
+	return simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf), to);  \
 }									    \
 									    \
-static ssize_t thunderx_##_type##_##_name##_write(struct file *file,	    \
-					    const char __user *data,	    \
-					    size_t count, loff_t *ppos)     \
+static ssize_t thunderx_##_type##_##_name##_write(struct kiocb *iocb,	    \
+					    struct iov_iter *from)	    \
 {									    \
-	struct thunderx_##_type *pdata = file->private_data;		    \
+	struct thunderx_##_type *pdata = iocb->ki_filp->private_data;	    \
+	size_t count = iov_iter_count(from);				    \
 	u64 val;							    \
 	int res;							    \
 									    \
-	res = kstrtoull_from_user(data, count, 0, &val);		    \
+	res = kstrtoull_from_iter(from, count, 0, &val);		    \
 									    \
 	if (!res) {							    \
 		writeq(val, pdata->regs + _reg);			    \
@@ -300,15 +297,15 @@ DEBUGFS_STRUCT(_name, 0600,						    \
  * - Do the actual injection:
  *	echo 1 > /sys/kernel/debug/<device number>/inject_ecc
  */
-static ssize_t thunderx_lmc_inject_int_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t thunderx_lmc_inject_int_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct thunderx_lmc *lmc = file->private_data;
+	struct thunderx_lmc *lmc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u64 val;
 	int res;
 
-	res = kstrtoull_from_user(data, count, 0, &val);
+	res = kstrtoull_from_iter(from, count, 0, &val);
 
 	if (!res) {
 		/* Trigger the interrupt */
@@ -319,16 +316,14 @@ static ssize_t thunderx_lmc_inject_int_write(struct file *file,
 	return res;
 }
 
-static ssize_t thunderx_lmc_int_read(struct file *file,
-				     char __user *data,
-				     size_t count, loff_t *ppos)
+static ssize_t thunderx_lmc_int_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct thunderx_lmc *lmc = file->private_data;
+	struct thunderx_lmc *lmc = iocb->ki_filp->private_data;
 	char buf[20];
 	u64 lmc_int = readq(lmc->regs + LMC_INT);
 
 	snprintf(buf, sizeof(buf), "0x%016llx", lmc_int);
-	return simple_read_from_buffer(data, count, ppos, buf, sizeof(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), to);
 }
 
 #define TEST_PATTERN 0xa5
@@ -403,12 +398,12 @@ static int inject_ecc_fn(void *arg)
 	return 0;
 }
 
-static ssize_t thunderx_lmc_inject_ecc_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t thunderx_lmc_inject_ecc_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct thunderx_lmc *lmc = file->private_data;
+	struct thunderx_lmc *lmc = iocb->ki_filp->private_data;
 	unsigned int cline_size = cache_line_size();
+	size_t count = iov_iter_count(from);
 	u8 *tmp;
 	void __iomem *addr;
 	unsigned int offs, timeout = 100000;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 390/437] EDAC/npcm: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (388 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 389/437] EDAC/thunderx: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 391/437] EDAC/i5100: " Jens Axboe
                   ` (47 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/npcm_edac.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/npcm_edac.c b/drivers/edac/npcm_edac.c
index 2e2133b784e9..54a756db7d67 100644
--- a/drivers/edac/npcm_edac.c
+++ b/drivers/edac/npcm_edac.c
@@ -195,13 +195,13 @@ static irqreturn_t edac_ecc_isr(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static ssize_t force_ecc_error(struct file *file, const char __user *data,
-			       size_t count, loff_t *ppos)
+static ssize_t force_ecc_error(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
 	struct priv_data *priv = mci->pvt_info;
 	const struct npcm_platform_data *pdata;
+	size_t count = iov_iter_count(from);
 	u32 val, syndrome;
 	int ret;
 
@@ -261,7 +261,7 @@ static ssize_t force_ecc_error(struct file *file, const char __user *data,
 
 static const struct file_operations force_ecc_error_fops = {
 	.open = simple_open,
-	.write = force_ecc_error,
+	.write_iter = force_ecc_error,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 391/437] EDAC/i5100: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (389 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 390/437] EDAC/npcm: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 392/437] EDAC/altera: " Jens Axboe
                   ` (46 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/i5100_edac.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index d470afe65001..d35064a74fe2 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -924,20 +924,19 @@ static void i5100_do_inject(struct mem_ctl_info *mci)
 }
 
 #define to_mci(k) container_of(k, struct mem_ctl_info, dev)
-static ssize_t inject_enable_write(struct file *file, const char __user *data,
-		size_t count, loff_t *ppos)
+static ssize_t inject_enable_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
 
 	i5100_do_inject(mci);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations i5100_inject_enable_fops = {
 	.open = simple_open,
-	.write = inject_enable_write,
+	.write_iter = inject_enable_write,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 392/437] EDAC/altera: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (390 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 391/437] EDAC/i5100: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 393/437] EDAC/debugfs: " Jens Axboe
                   ` (45 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/altera_edac.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index ae17ce4d9722..889722751163 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -115,13 +115,13 @@ static irqreturn_t altr_sdram_mc_err_handler(int irq, void *dev_id)
 	return IRQ_NONE;
 }
 
-static ssize_t altr_sdr_mc_err_inject_write(struct file *file,
-					    const char __user *data,
-					    size_t count, loff_t *ppos)
+static ssize_t altr_sdr_mc_err_inject_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct mem_ctl_info *mci = file->private_data;
+	struct mem_ctl_info *mci = iocb->ki_filp->private_data;
 	struct altr_sdram_mc_data *drvdata = mci->pvt_info;
 	const struct altr_sdram_prv_data *priv = drvdata->data;
+	size_t count = iov_iter_count(from);
 	u32 *ptemp;
 	dma_addr_t dma_handle;
 	u32 reg, read_reg;
@@ -187,7 +187,7 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file,
 
 static const struct file_operations altr_sdr_mc_debug_inject_fops = {
 	.open = simple_open,
-	.write = altr_sdr_mc_err_inject_write,
+	.write_iter = altr_sdr_mc_err_inject_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -640,30 +640,29 @@ altr_edac_device_trig(struct file *file, const char __user *user_buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(altr_edac_device_trig);
 
 static const struct file_operations altr_edac_device_inject_fops __maybe_unused = {
 	.open = simple_open,
-	.write = altr_edac_device_trig,
+	.write_iter = altr_edac_device_trig_iter,
 	.llseek = generic_file_llseek,
 };
 
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,
-			  size_t count, loff_t *ppos);
+altr_edac_a10_device_trig_iter(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations altr_edac_a10_device_inject_fops __maybe_unused = {
 	.open = simple_open,
-	.write = altr_edac_a10_device_trig,
+	.write_iter = altr_edac_a10_device_trig_iter,
 	.llseek = generic_file_llseek,
 };
 
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,
-			   size_t count, loff_t *ppos);
+altr_edac_a10_device_trig2_iter(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations altr_edac_a10_device_inject2_fops __maybe_unused = {
 	.open = simple_open,
-	.write = altr_edac_a10_device_trig2,
+	.write_iter = altr_edac_a10_device_trig2_iter,
 	.llseek = generic_file_llseek,
 };
 
@@ -1760,6 +1759,7 @@ altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig);
 
 /*
  * The Stratix10 EDAC Error Injection Functions differ from Arria10
@@ -1823,6 +1823,7 @@ altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig2);
 
 static void altr_edac_a10_irq_handler(struct irq_desc *desc)
 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 393/437] EDAC/debugfs: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (391 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 392/437] EDAC/altera: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 394/437] drivers/hsi: " Jens Axboe
                   ` (44 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/edac/altera_edac.c | 37 +++++++++++++++++--------------------
 drivers/edac/debugfs.c     |  9 ++++-----
 2 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 889722751163..45536199e9b0 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -571,20 +571,20 @@ static irqreturn_t altr_edac_device_handler(int irq, void *dev_id)
 }
 
 static ssize_t __maybe_unused
-altr_edac_device_trig(struct file *file, const char __user *user_buf,
-		      size_t count, loff_t *ppos)
+altr_edac_device_trig(struct kiocb *iocb, struct iov_iter *from)
 
 {
 	u32 *ptemp, i, error_mask;
 	int result = 0;
 	u8 trig_type;
 	unsigned long flags;
-	struct edac_device_ctl_info *edac_dci = file->private_data;
+	struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;
 	struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;
 	const struct edac_device_prv_data *priv = drvdata->data;
+	size_t count = iov_iter_count(from);
 	void *generic_ptr = edac_dci->dev;
 
-	if (!user_buf || get_user(trig_type, user_buf))
+	if (get_iter(trig_type, from))
 		return -EFAULT;
 
 	if (!priv->alloc_mem)
@@ -640,29 +640,28 @@ altr_edac_device_trig(struct file *file, const char __user *user_buf,
 
 	return count;
 }
-FOPS_WRITE_ITER_HELPER(altr_edac_device_trig);
 
 static const struct file_operations altr_edac_device_inject_fops __maybe_unused = {
 	.open = simple_open,
-	.write_iter = altr_edac_device_trig_iter,
+	.write_iter = altr_edac_device_trig,
 	.llseek = generic_file_llseek,
 };
 
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig_iter(struct kiocb *iocb, struct iov_iter *from);
+altr_edac_a10_device_trig(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations altr_edac_a10_device_inject_fops __maybe_unused = {
 	.open = simple_open,
-	.write_iter = altr_edac_a10_device_trig_iter,
+	.write_iter = altr_edac_a10_device_trig,
 	.llseek = generic_file_llseek,
 };
 
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig2_iter(struct kiocb *iocb, struct iov_iter *from);
+altr_edac_a10_device_trig2(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations altr_edac_a10_device_inject2_fops __maybe_unused = {
 	.open = simple_open,
-	.write_iter = altr_edac_a10_device_trig2_iter,
+	.write_iter = altr_edac_a10_device_trig2,
 	.llseek = generic_file_llseek,
 };
 
@@ -1734,17 +1733,17 @@ MODULE_DEVICE_TABLE(of, altr_edac_a10_device_of_match);
  */
 
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,
-			  size_t count, loff_t *ppos)
+altr_edac_a10_device_trig(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dci = file->private_data;
+	struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;
 	struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;
 	const struct edac_device_prv_data *priv = drvdata->data;
 	void __iomem *set_addr = (drvdata->base + priv->set_err_ofst);
+	size_t count = iov_iter_count(from);
 	unsigned long flags;
 	u8 trig_type;
 
-	if (!user_buf || get_user(trig_type, user_buf))
+	if (get_iter(trig_type, from))
 		return -EFAULT;
 
 	local_irq_save(flags);
@@ -1759,7 +1758,6 @@ altr_edac_a10_device_trig(struct file *file, const char __user *user_buf,
 
 	return count;
 }
-FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig);
 
 /*
  * The Stratix10 EDAC Error Injection Functions differ from Arria10
@@ -1767,17 +1765,17 @@ FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig);
  * Inject the error into the memory and then readback to trigger the IRQ.
  */
 static ssize_t __maybe_unused
-altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,
-			   size_t count, loff_t *ppos)
+altr_edac_a10_device_trig2(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct edac_device_ctl_info *edac_dci = file->private_data;
+	struct edac_device_ctl_info *edac_dci = iocb->ki_filp->private_data;
 	struct altr_edac_device_dev *drvdata = edac_dci->pvt_info;
 	const struct edac_device_prv_data *priv = drvdata->data;
 	void __iomem *set_addr = (drvdata->base + priv->set_err_ofst);
+	size_t count = iov_iter_count(from);
 	unsigned long flags;
 	u8 trig_type;
 
-	if (!user_buf || get_user(trig_type, user_buf))
+	if (get_iter(trig_type, from))
 		return -EFAULT;
 
 	local_irq_save(flags);
@@ -1823,7 +1821,6 @@ altr_edac_a10_device_trig2(struct file *file, const char __user *user_buf,
 
 	return count;
 }
-FOPS_WRITE_ITER_HELPER(altr_edac_a10_device_trig2);
 
 static void altr_edac_a10_irq_handler(struct irq_desc *desc)
 {
diff --git a/drivers/edac/debugfs.c b/drivers/edac/debugfs.c
index 4804332d9946..a2b8458a4c1a 100644
--- a/drivers/edac/debugfs.c
+++ b/drivers/edac/debugfs.c
@@ -3,14 +3,13 @@
 
 static struct dentry *edac_debugfs;
 
-static ssize_t edac_fake_inject_write(struct file *file,
-				      const char __user *data,
-				      size_t count, loff_t *ppos)
+static ssize_t edac_fake_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mem_ctl_info *mci = to_mci(dev);
 	static enum hw_event_mc_err_type type;
 	u16 errcount = mci->fake_inject_count;
+	size_t count = iov_iter_count(from);
 
 	if (!errcount)
 		errcount = 1;
@@ -38,7 +37,7 @@ static ssize_t edac_fake_inject_write(struct file *file,
 
 static const struct file_operations debug_fake_inject_fops = {
 	.open = simple_open,
-	.write = edac_fake_inject_write,
+	.write_iter = edac_fake_inject_write,
 	.llseek = generic_file_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 394/437] drivers/hsi: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (392 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 393/437] EDAC/debugfs: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 395/437] hsi: clients: cmt_speech: " Jens Axboe
                   ` (43 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hsi/clients/hsi_char.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/hsi/clients/hsi_char.c b/drivers/hsi/clients/hsi_char.c
index 71ce7dbfe31d..47ddfe14459b 100644
--- a/drivers/hsi/clients/hsi_char.c
+++ b/drivers/hsi/clients/hsi_char.c
@@ -409,10 +409,10 @@ static inline void hsc_tx_get(struct hsi_client *cl, struct hsc_tx_config *txc)
 	txc->arb_mode = cl->tx_cfg.arb_mode;
 }
 
-static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
-						loff_t *ppos __maybe_unused)
+static ssize_t hsc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hsc_channel *channel = file->private_data;
+	struct hsc_channel *channel = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct hsi_msg *msg;
 	ssize_t ret;
 
@@ -451,8 +451,8 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
 	msg = hsc_get_first_msg(channel, &channel->rx_msgs_queue);
 	if (msg) {
 		if (msg->status != HSI_STATUS_ERROR) {
-			ret = copy_to_user((void __user *)buf,
-			sg_virt(msg->sgt.sgl), hsc_msg_len_get(msg));
+			ret = !copy_to_iter_full(sg_virt(msg->sgt.sgl),
+						 hsc_msg_len_get(msg), to);
 			if (ret)
 				ret = -EFAULT;
 			else
@@ -468,10 +468,10 @@ static ssize_t hsc_read(struct file *file, char __user *buf, size_t len,
 	return ret;
 }
 
-static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,
-						loff_t *ppos __maybe_unused)
+static ssize_t hsc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hsc_channel *channel = file->private_data;
+	struct hsc_channel *channel = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct hsi_msg *msg;
 	ssize_t ret;
 
@@ -488,7 +488,7 @@ static ssize_t hsc_write(struct file *file, const char __user *buf, size_t len,
 		clear_bit(HSC_CH_WRITE, &channel->flags);
 		return -ENOSPC;
 	}
-	if (copy_from_user(sg_virt(msg->sgt.sgl), (void __user *)buf, len)) {
+	if (!copy_from_iter_full(sg_virt(msg->sgt.sgl), len, from)) {
 		ret = -EFAULT;
 		goto out;
 	}
@@ -655,8 +655,8 @@ static int hsc_release(struct inode *inode __maybe_unused, struct file *file)
 
 static const struct file_operations hsc_fops = {
 	.owner		= THIS_MODULE,
-	.read		= hsc_read,
-	.write		= hsc_write,
+	.read_iter	= hsc_read,
+	.write_iter	= hsc_write,
 	.unlocked_ioctl	= hsc_ioctl,
 	.open		= hsc_open,
 	.release	= hsc_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 395/437] hsi: clients: cmt_speech: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (393 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 394/437] drivers/hsi: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 396/437] macintosh: adb: " Jens Axboe
                   ` (42 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hsi/clients/cmt_speech.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/hsi/clients/cmt_speech.c b/drivers/hsi/clients/cmt_speech.c
index daa8e1bff5d9..8de1beb45119 100644
--- a/drivers/hsi/clients/cmt_speech.c
+++ b/drivers/hsi/clients/cmt_speech.c
@@ -1126,10 +1126,10 @@ static __poll_t cs_char_poll(struct file *file, poll_table *wait)
 	return ret;
 }
 
-static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,
-								loff_t *unused)
+static ssize_t cs_char_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct cs_char *csdata = file->private_data;
+	struct cs_char *csdata = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	u32 data;
 	ssize_t retval;
 
@@ -1152,7 +1152,7 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,
 
 		if (data)
 			break;
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			retval = -EAGAIN;
 			goto out;
 		} else if (signal_pending(current)) {
@@ -1165,7 +1165,7 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,
 		finish_wait(&csdata->wait, &wait);
 	}
 
-	retval = put_user(data, (u32 __user *)buf);
+	retval = put_iter(data, to);
 	if (!retval)
 		retval = sizeof(data);
 
@@ -1173,10 +1173,10 @@ static ssize_t cs_char_read(struct file *file, char __user *buf, size_t count,
 	return retval;
 }
 
-static ssize_t cs_char_write(struct file *file, const char __user *buf,
-						size_t count, loff_t *unused)
+static ssize_t cs_char_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct cs_char *csdata = file->private_data;
+	struct cs_char *csdata = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 data;
 	int err;
 	ssize_t	retval;
@@ -1184,7 +1184,7 @@ static ssize_t cs_char_write(struct file *file, const char __user *buf,
 	if (count < sizeof(data))
 		return -EINVAL;
 
-	if (get_user(data, (u32 __user *)buf))
+	if (get_iter(data, from))
 		retval = -EFAULT;
 	else
 		retval = count;
@@ -1349,8 +1349,8 @@ static int cs_char_release(struct inode *unused, struct file *file)
 
 static const struct file_operations cs_char_fops = {
 	.owner		= THIS_MODULE,
-	.read		= cs_char_read,
-	.write		= cs_char_write,
+	.read_iter	= cs_char_read,
+	.write_iter	= cs_char_write,
 	.poll		= cs_char_poll,
 	.unlocked_ioctl	= cs_char_ioctl,
 	.mmap		= cs_char_mmap,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 396/437] macintosh: adb: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (394 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 395/437] hsi: clients: cmt_speech: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 397/437] macintosh: ans-lcd: " Jens Axboe
                   ` (41 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/macintosh/adb.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index b0407c5fadb2..1b95911ded5d 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -713,11 +713,11 @@ static int adb_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t adb_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t adb_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret = 0;
-	struct adbdev_state *state = file->private_data;
+	struct adbdev_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct adb_request *req;
 	DECLARE_WAITQUEUE(wait, current);
 	unsigned long flags;
@@ -741,7 +741,7 @@ static ssize_t adb_read(struct file *file, char __user *buf,
 		if (req != NULL || ret != 0)
 			break;
 		
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			ret = -EAGAIN;
 			break;
 		}
@@ -764,18 +764,18 @@ static ssize_t adb_read(struct file *file, char __user *buf,
 	ret = req->reply_len;
 	if (ret > count)
 		ret = count;
-	if (ret > 0 && copy_to_user(buf, req->reply, ret))
+	if (ret > 0 && !copy_to_iter_full(req->reply, ret, to))
 		ret = -EFAULT;
 
 	kfree(req);
 	return ret;
 }
 
-static ssize_t adb_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t adb_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int ret/*, i*/;
-	struct adbdev_state *state = file->private_data;
+	struct adbdev_state *state = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct adb_request *req;
 
 	if (count < 2 || count > sizeof(req->data))
@@ -794,7 +794,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
 	req->complete = 0;
 	
 	ret = -EFAULT;
-	if (copy_from_user(req->data, buf, count))
+	if (!copy_from_iter_full(req->data, count, from))
 		goto out;
 
 	atomic_inc(&state->n_pending);
@@ -843,8 +843,8 @@ static ssize_t adb_write(struct file *file, const char __user *buf,
 static const struct file_operations adb_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.read		= adb_read,
-	.write		= adb_write,
+	.read_iter	= adb_read,
+	.write_iter	= adb_write,
 	.open		= adb_open,
 	.release	= adb_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 397/437] macintosh: ans-lcd: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (395 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 396/437] macintosh: adb: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 398/437] macintosh: smu: " Jens Axboe
                   ` (40 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/macintosh/ans-lcd.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index fa904b24a600..cfc0a95f0b8b 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -53,30 +53,31 @@ anslcd_write_byte_data ( unsigned char c )
 	udelay(anslcd_short_delay);
 }
 
-static ssize_t
-anslcd_write( struct file * file, const char __user * buf, 
-				size_t count, loff_t *ppos )
+static ssize_t anslcd_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const char __user *p = buf;
-	int i;
+	size_t count = iov_iter_count(from);
+	int i, err = 0;
 
 #ifdef DEBUG
 	printk(KERN_DEBUG "LCD: write\n");
 #endif
 
-	if (!access_ok(buf, count))
-		return -EFAULT;
-
 	mutex_lock(&anslcd_mutex);
-	for ( i = *ppos; count > 0; ++i, ++p, --count ) 
+	for ( i = iocb->ki_pos; count > 0; ++i, --count ) 
 	{
 		char c;
-		__get_user(c, p);
-		anslcd_write_byte_data( c );
+		if (get_iter(c, from)) {
+			err = -EFAULT;
+			break;
+		}
+		anslcd_write_byte_data(c);
 	}
 	mutex_unlock(&anslcd_mutex);
-	*ppos = i;
-	return p - buf;
+	if (i - iocb->ki_pos) {
+		err = i - iocb->ki_pos;
+		iocb->ki_pos = i;
+	}
+	return err;
 }
 
 static long
@@ -135,7 +136,7 @@ anslcd_open( struct inode * inode, struct file * file )
 }
 
 const struct file_operations anslcd_fops = {
-	.write		= anslcd_write,
+	.write_iter	= anslcd_write,
 	.unlocked_ioctl	= anslcd_ioctl,
 	.open		= anslcd_open,
 	.llseek		= default_llseek,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 398/437] macintosh: smu: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (396 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 397/437] macintosh: ans-lcd: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:18 ` [PATCH 399/437] macintosh: via-pmu: " Jens Axboe
                   ` (39 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/macintosh/smu.c | 40 ++++++++++++++++++----------------------
 1 file changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index b2b78a53e532..c66fcb746123 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -1111,17 +1111,17 @@ static void smu_user_cmd_done(struct smu_cmd *cmd, void *misc)
 }
 
 
-static ssize_t smu_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t smu_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct smu_private *pp = file->private_data;
+	struct smu_private *pp = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long flags;
 	struct smu_user_cmd_hdr hdr;
 	int rc = 0;
 
 	if (pp->busy)
 		return -EBUSY;
-	else if (copy_from_user(&hdr, buf, sizeof(hdr)))
+	else if (!copy_from_iter_full(&hdr, sizeof(hdr), from))
 		return -EFAULT;
 	else if (hdr.cmdtype == SMU_CMDTYPE_WANTS_EVENTS) {
 		pp->mode = smu_file_events;
@@ -1150,7 +1150,7 @@ static ssize_t smu_write(struct file *file, const char __user *buf,
 	pp->cmd.status = 1;
 	spin_unlock_irqrestore(&pp->lock, flags);
 
-	if (copy_from_user(pp->buffer, buf + sizeof(hdr), hdr.data_len)) {
+	if (!copy_from_iter_full(pp->buffer, hdr.data_len, from)) {
 		pp->busy = 0;
 		return -EFAULT;
 	}
@@ -1168,10 +1168,10 @@ static ssize_t smu_write(struct file *file, const char __user *buf,
 	return count;
 }
 
-
-static ssize_t smu_read_command(struct file *file, struct smu_private *pp,
-				char __user *buf, size_t count)
+static ssize_t smu_read_command(struct smu_private *pp, struct kiocb *iocb,
+				struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	DECLARE_WAITQUEUE(wait, current);
 	struct smu_user_reply_hdr hdr;
 	unsigned long flags;
@@ -1183,7 +1183,7 @@ static ssize_t smu_read_command(struct file *file, struct smu_private *pp,
 		return -EOVERFLOW;
 	spin_lock_irqsave(&pp->lock, flags);
 	if (pp->cmd.status == 1) {
-		if (file->f_flags & O_NONBLOCK) {
+		if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 			spin_unlock_irqrestore(&pp->lock, flags);
 			return -EAGAIN;
 		}
@@ -1214,35 +1214,31 @@ static ssize_t smu_read_command(struct file *file, struct smu_private *pp,
 	rc = size;
 	hdr.status = pp->cmd.status;
 	hdr.reply_len = pp->cmd.reply_len;
-	if (copy_to_user(buf, &hdr, sizeof(hdr)))
+	if (!copy_to_iter_full(&hdr, sizeof(hdr), to))
 		return -EFAULT;
 	size -= sizeof(hdr);
-	if (size && copy_to_user(buf + sizeof(hdr), pp->buffer, size))
+	if (size && !copy_to_iter_full(pp->buffer, size, to))
 		return -EFAULT;
 	pp->busy = 0;
 
 	return rc;
 }
 
-
-static ssize_t smu_read_events(struct file *file, struct smu_private *pp,
-			       char __user *buf, size_t count)
+static ssize_t smu_read_events(void)
 {
 	/* Not implemented */
 	msleep_interruptible(1000);
 	return 0;
 }
 
-
-static ssize_t smu_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t smu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct smu_private *pp = file->private_data;
+	struct smu_private *pp = iocb->ki_filp->private_data;
 
 	if (pp->mode == smu_file_commands)
-		return smu_read_command(file, pp, buf, count);
+		return smu_read_command(pp, iocb, to);
 	if (pp->mode == smu_file_events)
-		return smu_read_events(file, pp, buf, count);
+		return smu_read_events();
 
 	return -EBADFD;
 }
@@ -1315,8 +1311,8 @@ static int smu_release(struct inode *inode, struct file *file)
 
 static const struct file_operations smu_device_fops = {
 	.llseek		= no_llseek,
-	.read		= smu_read,
-	.write		= smu_write,
+	.read_iter	= smu_read,
+	.write_iter	= smu_write,
 	.poll		= smu_fpoll,
 	.open		= smu_open,
 	.release	= smu_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 399/437] macintosh: via-pmu: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (397 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 398/437] macintosh: smu: " Jens Axboe
@ 2024-04-11 15:18 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 400/437] drivers/extcon: " Jens Axboe
                   ` (38 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/macintosh/via-pmu.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 9d5703b60937..b7f11200949d 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2165,12 +2165,11 @@ pmu_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t 
-pmu_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t pmu_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct pmu_private *pp = file->private_data;
+	struct pmu_private *pp = iocb->ki_filp->private_data;
 	DECLARE_WAITQUEUE(wait, current);
+	size_t count = iov_iter_count(to);
 	unsigned long flags;
 	int ret = 0;
 
@@ -2190,7 +2189,7 @@ pmu_read(struct file *file, char __user *buf,
 			spin_unlock_irqrestore(&pp->lock, flags);
 			if (ret > count)
 				ret = count;
-			if (ret > 0 && copy_to_user(buf, rp->data, ret))
+			if (ret > 0 && !copy_to_iter_full(rp->data, ret, to))
 				ret = -EFAULT;
 			if (++i >= RB_SIZE)
 				i = 0;
@@ -2199,7 +2198,7 @@ pmu_read(struct file *file, char __user *buf,
 		}
 		if (ret >= 0)
 			break;
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			break;
 		ret = -ERESTARTSYS;
 		if (signal_pending(current))
@@ -2215,9 +2214,7 @@ pmu_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t
-pmu_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t pmu_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return 0;
 }
@@ -2464,8 +2461,8 @@ static long compat_pmu_ioctl (struct file *filp, u_int cmd, u_long arg)
 #endif
 
 static const struct file_operations pmu_device_fops = {
-	.read		= pmu_read,
-	.write		= pmu_write,
+	.read_iter	= pmu_read,
+	.write_iter	= pmu_write,
 	.poll		= pmu_fpoll,
 	.unlocked_ioctl	= pmu_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 400/437] drivers/extcon: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (398 preceding siblings ...)
  2024-04-11 15:18 ` [PATCH 399/437] macintosh: via-pmu: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 401/437] drivers/gnss: " Jens Axboe
                   ` (37 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/extcon/extcon-rtk-type-c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-rtk-type-c.c b/drivers/extcon/extcon-rtk-type-c.c
index a592bab77538..70a83ce3318e 100644
--- a/drivers/extcon/extcon-rtk-type-c.c
+++ b/drivers/extcon/extcon-rtk-type-c.c
@@ -796,7 +796,7 @@ static int type_c_parameter_open(struct inode *inode, struct file *file)
 
 static const struct file_operations type_c_parameter_fops = {
 	.open			= type_c_parameter_open,
-	.read			= seq_read,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
@@ -838,7 +838,7 @@ static int type_c_status_open(struct inode *inode, struct file *file)
 
 static const struct file_operations type_c_status_fops = {
 	.open			= type_c_status_open,
-	.read			= seq_read,
+	.read_iter		= seq_read_iter,
 	.llseek			= seq_lseek,
 	.release		= single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 401/437] drivers/gnss: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (399 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 400/437] drivers/extcon: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 402/437] drivers/rapidio: " Jens Axboe
                   ` (36 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/gnss/core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index 48f2ee0f78c4..ce66ffb85832 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -119,11 +119,12 @@ static ssize_t gnss_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(gnss_read);
 
-static ssize_t gnss_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *pos)
+static ssize_t gnss_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct gnss_device *gdev = file->private_data;
+	struct gnss_device *gdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t written = 0;
 	int ret;
 
@@ -148,7 +149,7 @@ static ssize_t gnss_write(struct file *file, const char __user *buf,
 		if (n > GNSS_WRITE_BUF_SIZE)
 			n = GNSS_WRITE_BUF_SIZE;
 
-		if (copy_from_user(gdev->write_buf, buf, n)) {
+		if (!copy_from_iter_full(gdev->write_buf, n, from)) {
 			ret = -EFAULT;
 			goto out_unlock;
 		}
@@ -170,7 +171,6 @@ static ssize_t gnss_write(struct file *file, const char __user *buf,
 			break;
 
 		written += ret;
-		buf += ret;
 
 		if (written == count)
 			break;
@@ -203,8 +203,8 @@ static const struct file_operations gnss_fops = {
 	.owner		= THIS_MODULE,
 	.open		= gnss_open,
 	.release	= gnss_release,
-	.read		= gnss_read,
-	.write		= gnss_write,
+	.read_iter	= gnss_read_iter,
+	.write_iter	= gnss_write,
 	.poll		= gnss_poll,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 402/437] drivers/rapidio: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (400 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 401/437] drivers/gnss: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 403/437] drivers/media/platform/mediatek/vcodec: " Jens Axboe
                   ` (35 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/rapidio/devices/rio_mport_cdev.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 27afbb9d544b..de1628737808 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -2297,12 +2297,13 @@ static ssize_t mport_read(struct file *filp, char __user *buf, size_t count,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(mport_read);
 
-static ssize_t mport_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t mport_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mport_cdev_priv *priv = filp->private_data;
+	struct mport_cdev_priv *priv = iocb->ki_filp->private_data;
 	struct rio_mport *mport = priv->md->mport;
+	size_t count = iov_iter_count(from);
 	struct rio_event event;
 	int len, ret;
 
@@ -2314,7 +2315,7 @@ static ssize_t mport_write(struct file *filp, const char __user *buf,
 
 	len = 0;
 	while ((count - len) >= (int)sizeof(event)) {
-		if (copy_from_user(&event, buf, sizeof(event)))
+		if (!copy_from_iter_full(&event,sizeof(event), from))
 			return -EFAULT;
 
 		if (event.header != RIO_DOORBELL)
@@ -2327,7 +2328,6 @@ static ssize_t mport_write(struct file *filp, const char __user *buf,
 			return ret;
 
 		len += sizeof(event);
-		buf += sizeof(event);
 	}
 
 	return len;
@@ -2338,8 +2338,8 @@ static const struct file_operations mport_fops = {
 	.open		= mport_cdev_open,
 	.release	= mport_cdev_release,
 	.poll		= mport_cdev_poll,
-	.read		= mport_read,
-	.write		= mport_write,
+	.read_iter	= mport_read_iter,
+	.write_iter	= mport_write,
 	.mmap		= mport_cdev_mmap,
 	.fasync		= mport_cdev_fasync,
 	.unlocked_ioctl = mport_cdev_ioctl
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 403/437] drivers/media/platform/mediatek/vcodec: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (401 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 402/437] drivers/rapidio: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 404/437] infiniband/core: " Jens Axboe
                   ` (34 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Krzysztof Kanas, Jens Axboe

From: Krzysztof Kanas <kkanas@fastmail.com>

Signed-off-by: Krzysztof Kanas <kkanas@fastmail.com>
[axboe: fold in patch for killing FOPS helpers]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../mediatek/vcodec/common/mtk_vcodec_dbgfs.c | 21 +++++++++----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
index 5ad3797836db..b8e4779b32d2 100644
--- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
+++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_dbgfs.c
@@ -70,15 +70,15 @@ static void mtk_vdec_dbgfs_get_help(char *buf, int *used, int total)
 	*used += curr_len;
 }
 
-static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
-				    size_t count, loff_t *ppos)
+static ssize_t mtk_vdec_dbgfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
+	struct mtk_vcodec_dec_dev *vcodec_dev = iocb->ki_filp->private_data;
 	struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
+	size_t count = iov_iter_count(from);
 
 	mutex_lock(&dbgfs->dbgfs_lock);
-	dbgfs->buf_size = simple_write_to_buffer(dbgfs->dbgfs_buf, sizeof(dbgfs->dbgfs_buf),
-						 ppos, ubuf, count);
+	dbgfs->buf_size = simple_copy_to_iter(dbgfs->dbgfs_buf, &iocb->ki_pos,
+						sizeof(dbgfs->dbgfs_buf), from);
 	mutex_unlock(&dbgfs->dbgfs_lock);
 	if (dbgfs->buf_size > 0)
 		return count;
@@ -86,10 +86,9 @@ static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
 	return dbgfs->buf_size;
 }
 
-static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
-				   size_t count, loff_t *ppos)
+static ssize_t mtk_vdec_dbgfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
+	struct mtk_vcodec_dec_dev *vcodec_dev = iocb->ki_filp->private_data;
 	struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
 	struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
 	struct mtk_vcodec_dec_ctx *ctx;
@@ -133,15 +132,15 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
 	}
 	mutex_unlock(&dbgfs->dbgfs_lock);
 read_buffer:
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, used_len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, used_len, to);
 	kfree(buf);
 	return ret;
 }
 
 static const struct file_operations vdec_fops = {
 	.open = simple_open,
-	.write = mtk_vdec_dbgfs_write,
-	.read = mtk_vdec_dbgfs_read,
+	.write_iter = mtk_vdec_dbgfs_write,
+	.read_iter = mtk_vdec_dbgfs_read,
 };
 
 void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 404/437] infiniband/core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (402 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 403/437] drivers/media/platform/mediatek/vcodec: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 405/437] infiniband/cxgb4: " Jens Axboe
                   ` (33 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/core/ucma.c        |  3 ++-
 drivers/infiniband/core/user_mad.c    |  6 ++++--
 drivers/infiniband/core/uverbs_main.c | 11 +++++++----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 5f5ad8faf86e..b9aa99083dd9 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1746,6 +1746,7 @@ static ssize_t ucma_write(struct file *filp, const char __user *buf,
 
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ucma_write);
 
 static __poll_t ucma_poll(struct file *filp, struct poll_table_struct *wait)
 {
@@ -1815,7 +1816,7 @@ static const struct file_operations ucma_fops = {
 	.owner 	 = THIS_MODULE,
 	.open 	 = ucma_open,
 	.release = ucma_close,
-	.write	 = ucma_write,
+	.write_iter = ucma_write_iter,
 	.poll    = ucma_poll,
 	.llseek	 = no_llseek,
 };
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index f5feca7fa9b9..dcb065c3d8c5 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -429,6 +429,7 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf,
 	}
 	return ret;
 }
+FOPS_READ_ITER_HELPER(ib_umad_read);
 
 static int copy_rmpp_mad(struct ib_mad_send_buf *msg, const char __user *buf)
 {
@@ -660,6 +661,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 	kfree(packet);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(ib_umad_write);
 
 static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
 {
@@ -1064,8 +1066,8 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
 
 static const struct file_operations umad_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ib_umad_read,
-	.write		= ib_umad_write,
+	.read_iter	= ib_umad_read_iter,
+	.write_iter	= ib_umad_write_iter,
 	.poll		= ib_umad_poll,
 	.unlocked_ioctl = ib_umad_ioctl,
 #ifdef CONFIG_COMPAT
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 495d5a5d0373..7834a30e182b 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -285,6 +285,7 @@ static ssize_t ib_uverbs_async_event_read(struct file *filp, char __user *buf,
 	return ib_uverbs_event_read(&file->ev_queue, filp, buf, count, pos,
 				    sizeof(struct ib_uverbs_async_event_desc));
 }
+FOPS_READ_ITER_HELPER(ib_uverbs_async_event_read);
 
 static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf,
 					 size_t count, loff_t *pos)
@@ -296,6 +297,7 @@ static ssize_t ib_uverbs_comp_event_read(struct file *filp, char __user *buf,
 				    pos,
 				    sizeof(struct ib_uverbs_comp_event_desc));
 }
+FOPS_READ_ITER_HELPER(ib_uverbs_comp_event_read);
 
 static __poll_t ib_uverbs_event_poll(struct ib_uverbs_event_queue *ev_queue,
 					 struct file *filp,
@@ -349,7 +351,7 @@ static int ib_uverbs_comp_event_fasync(int fd, struct file *filp, int on)
 
 const struct file_operations uverbs_event_fops = {
 	.owner	 = THIS_MODULE,
-	.read	 = ib_uverbs_comp_event_read,
+	.read_iter = ib_uverbs_comp_event_read_iter,
 	.poll    = ib_uverbs_comp_event_poll,
 	.release = uverbs_uobject_fd_release,
 	.fasync  = ib_uverbs_comp_event_fasync,
@@ -358,7 +360,7 @@ const struct file_operations uverbs_event_fops = {
 
 const struct file_operations uverbs_async_event_fops = {
 	.owner	 = THIS_MODULE,
-	.read	 = ib_uverbs_async_event_read,
+	.read_iter = ib_uverbs_async_event_read_iter,
 	.poll    = ib_uverbs_async_event_poll,
 	.release = uverbs_async_event_release,
 	.fasync  = ib_uverbs_async_event_fasync,
@@ -684,6 +686,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
 	srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
 	return (ret) ? : count;
 }
+FOPS_WRITE_ITER_HELPER(ib_uverbs_write);
 
 static const struct vm_operations_struct rdma_umap_ops;
 
@@ -988,7 +991,7 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)
 
 static const struct file_operations uverbs_fops = {
 	.owner	 = THIS_MODULE,
-	.write	 = ib_uverbs_write,
+	.write_iter = ib_uverbs_write_iter,
 	.open	 = ib_uverbs_open,
 	.release = ib_uverbs_close,
 	.llseek	 = no_llseek,
@@ -998,7 +1001,7 @@ static const struct file_operations uverbs_fops = {
 
 static const struct file_operations uverbs_mmap_fops = {
 	.owner	 = THIS_MODULE,
-	.write	 = ib_uverbs_write,
+	.write_iter = ib_uverbs_write_iter,
 	.mmap    = ib_uverbs_mmap,
 	.open	 = ib_uverbs_open,
 	.release = ib_uverbs_close,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 405/437] infiniband/cxgb4: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (403 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 404/437] infiniband/core: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 406/437] infiniband/hfi1: " Jens Axboe
                   ` (32 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/cxgb4/device.c | 35 +++++++++++++---------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 80970a1738f8..7067ecc4f9e6 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -81,12 +81,11 @@ struct c4iw_debugfs_data {
 	int pos;
 };
 
-static ssize_t debugfs_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *ppos)
+static ssize_t debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct c4iw_debugfs_data *d = file->private_data;
+	struct c4iw_debugfs_data *d = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(buf, count, ppos, d->buf, d->pos);
+	return simple_copy_to_iter(d->buf, &iocb->ki_pos, d->pos, to);
 }
 
 void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe)
@@ -175,25 +174,24 @@ static int wr_log_open(struct inode *inode, struct file *file)
 	return single_open(file, wr_log_show, inode->i_private);
 }
 
-static ssize_t wr_log_clear(struct file *file, const char __user *buf,
-			    size_t count, loff_t *pos)
+static ssize_t wr_log_clear(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct c4iw_dev *dev = ((struct seq_file *)file->private_data)->private;
+	struct c4iw_dev *dev = ((struct seq_file *)iocb->ki_filp->private_data)->private;
 	int i;
 
 	if (dev->rdev.wr_log)
 		for (i = 0; i < dev->rdev.wr_log_size; i++)
 			dev->rdev.wr_log[i].valid = 0;
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations wr_log_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = wr_log_open,
 	.release = single_release,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
-	.write   = wr_log_clear,
+	.write_iter = wr_log_clear,
 };
 
 static struct sockaddr_in zero_sin = {
@@ -365,7 +363,7 @@ static const struct file_operations qp_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = qp_open,
 	.release = qp_release,
-	.read    = debugfs_read,
+	.read_iter = debugfs_read,
 	.llseek  = default_llseek,
 };
 
@@ -460,7 +458,7 @@ static const struct file_operations stag_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = stag_open,
 	.release = stag_release,
-	.read    = debugfs_read,
+	.read_iter = debugfs_read,
 	.llseek  = default_llseek,
 };
 
@@ -515,10 +513,9 @@ static int stats_open(struct inode *inode, struct file *file)
 	return single_open(file, stats_show, inode->i_private);
 }
 
-static ssize_t stats_clear(struct file *file, const char __user *buf,
-		size_t count, loff_t *pos)
+static ssize_t stats_clear(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct c4iw_dev *dev = ((struct seq_file *)file->private_data)->private;
+	struct c4iw_dev *dev = ((struct seq_file *)iocb->ki_filp->private_data)->private;
 
 	mutex_lock(&dev->rdev.stats.lock);
 	dev->rdev.stats.pd.max = 0;
@@ -543,16 +540,16 @@ static ssize_t stats_clear(struct file *file, const char __user *buf,
 	dev->rdev.stats.act_ofld_conn_fails = 0;
 	dev->rdev.stats.pas_ofld_conn_fails = 0;
 	mutex_unlock(&dev->rdev.stats.lock);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations stats_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = stats_open,
 	.release = single_release,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
-	.write   = stats_clear,
+	.write_iter = stats_clear,
 };
 
 static int dump_ep(struct c4iw_ep *ep, struct c4iw_debugfs_data *epd)
@@ -722,7 +719,7 @@ static const struct file_operations ep_debugfs_fops = {
 	.owner   = THIS_MODULE,
 	.open    = ep_open,
 	.release = ep_release,
-	.read    = debugfs_read,
+	.read_iter = debugfs_read,
 };
 
 static void setup_debugfs(struct c4iw_dev *devp)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 406/437] infiniband/hfi1: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (404 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 405/437] infiniband/cxgb4: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 407/437] infiniband/mlx5: " Jens Axboe
                   ` (31 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/hfi1/debugfs.c | 162 +++++++++++++--------------
 drivers/infiniband/hw/hfi1/debugfs.h |   6 +-
 drivers/infiniband/hw/hfi1/fault.c   |  27 +++--
 3 files changed, 91 insertions(+), 104 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c
index a1e01b447265..9b6c9d726c11 100644
--- a/drivers/infiniband/hw/hfi1/debugfs.c
+++ b/drivers/infiniband/hw/hfi1/debugfs.c
@@ -23,16 +23,15 @@
 static struct dentry *hfi1_dbg_root;
 
 /* wrappers to enforce srcu in seq file */
-ssize_t hfi1_seq_read(struct file *file, char __user *buf, size_t size,
-		      loff_t *ppos)
+ssize_t hfi1_seq_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dentry *d = file->f_path.dentry;
+	struct dentry *d = iocb->ki_filp->f_path.dentry;
 	ssize_t r;
 
 	r = debugfs_file_get(d);
 	if (unlikely(r))
 		return r;
-	r = seq_read(file, buf, size, ppos);
+	r = seq_read_iter(iocb, to);
 	debugfs_file_put(d);
 	return r;
 }
@@ -414,33 +413,27 @@ DEBUGFS_SEQ_FILE_OPEN(pios)
 DEBUGFS_FILE_OPS(pios);
 
 /* read the per-device counters */
-static ssize_t dev_counters_read(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t dev_counters_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 *counters;
 	size_t avail;
 	struct hfi1_devdata *dd;
-	ssize_t rval;
 
-	dd = private2dd(file);
+	dd = private2dd(iocb->ki_filp);
 	avail = hfi1_read_cntrs(dd, NULL, &counters);
-	rval =  simple_read_from_buffer(buf, count, ppos, counters, avail);
-	return rval;
+	return simple_copy_to_iter(counters, &iocb->ki_pos, avail, to);
 }
 
 /* read the per-device counters */
-static ssize_t dev_names_read(struct file *file, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t dev_names_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *names;
 	size_t avail;
 	struct hfi1_devdata *dd;
-	ssize_t rval;
 
-	dd = private2dd(file);
+	dd = private2dd(iocb->ki_filp);
 	avail = hfi1_read_cntrs(dd, &names, NULL);
-	rval =  simple_read_from_buffer(buf, count, ppos, names, avail);
-	return rval;
+	return simple_copy_to_iter(names, &iocb->ki_pos, avail, to);
 }
 
 struct counter_info {
@@ -454,33 +447,27 @@ struct counter_info {
  */
 
 /* read the per-port names (same for each port) */
-static ssize_t portnames_read(struct file *file, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t portnames_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *names;
 	size_t avail;
 	struct hfi1_devdata *dd;
-	ssize_t rval;
 
-	dd = private2dd(file);
+	dd = private2dd(iocb->ki_filp);
 	avail = hfi1_read_portcntrs(dd->pport, &names, NULL);
-	rval = simple_read_from_buffer(buf, count, ppos, names, avail);
-	return rval;
+	return simple_copy_to_iter(names, &iocb->ki_pos, avail, to);
 }
 
 /* read the per-port counters */
-static ssize_t portcntrs_debugfs_read(struct file *file, char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t portcntrs_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 *counters;
 	size_t avail;
 	struct hfi1_pportdata *ppd;
-	ssize_t rval;
 
-	ppd = private2ppd(file);
+	ppd = private2ppd(iocb->ki_filp);
 	avail = hfi1_read_portcntrs(ppd, NULL, &counters);
-	rval = simple_read_from_buffer(buf, count, ppos, counters, avail);
-	return rval;
+	return simple_copy_to_iter(counters, &iocb->ki_pos, avail, to);
 }
 
 static void check_dyn_flag(u64 scratch0, char *p, int size, int *used,
@@ -497,8 +484,7 @@ static void check_dyn_flag(u64 scratch0, char *p, int size, int *used,
 	}
 }
 
-static ssize_t asic_flags_read(struct file *file, char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t asic_flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct hfi1_pportdata *ppd;
 	struct hfi1_devdata *dd;
@@ -509,7 +495,7 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf,
 	int used;
 	int i;
 
-	ppd = private2ppd(file);
+	ppd = private2ppd(iocb->ki_filp);
 	dd = ppd->dd;
 	size = PAGE_SIZE;
 	used = 0;
@@ -541,14 +527,14 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf,
 	}
 	used += scnprintf(tmp + used, size - used, "Write bits to clear\n");
 
-	ret = simple_read_from_buffer(buf, count, ppos, tmp, used);
+	ret = simple_copy_to_iter(tmp, &iocb->ki_pos, used, to);
 	kfree(tmp);
 	return ret;
 }
 
-static ssize_t asic_flags_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t asic_flags_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct hfi1_pportdata *ppd;
 	struct hfi1_devdata *dd;
 	char *buff;
@@ -557,11 +543,11 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf,
 	u64 scratch0;
 	u64 clear;
 
-	ppd = private2ppd(file);
+	ppd = private2ppd(iocb->ki_filp);
 	dd = ppd->dd;
 
 	/* zero terminate and read the expected integer */
-	buff = memdup_user_nul(buf, count);
+	buff = iterdup_nul(from, count);
 	if (IS_ERR(buff))
 		return PTR_ERR(buff);
 
@@ -592,16 +578,16 @@ static ssize_t asic_flags_write(struct file *file, const char __user *buf,
 }
 
 /* read the dc8051 memory */
-static ssize_t dc8051_memory_read(struct file *file, char __user *buf,
-				  size_t count, loff_t *ppos)
+static ssize_t dc8051_memory_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hfi1_pportdata *ppd = private2ppd(file);
+	struct hfi1_pportdata *ppd = private2ppd(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	ssize_t rval;
 	void *tmp;
 	loff_t start, end;
 
 	/* the checks below expect the position to be positive */
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 
 	tmp = kzalloc(DC8051_DATA_MEM_SIZE, GFP_KERNEL);
@@ -614,9 +600,9 @@ static ssize_t dc8051_memory_read(struct file *file, char __user *buf,
 	 * Adjust start and end to fit.  Skip reading anything if out of
 	 * range.
 	 */
-	start = *ppos & ~0x7;	/* round down */
+	start = iocb->ki_pos & ~0x7;	/* round down */
 	if (start < DC8051_DATA_MEM_SIZE) {
-		end = (*ppos + count + 7) & ~0x7; /* round up */
+		end = (iocb->ki_pos + count + 7) & ~0x7; /* round up */
 		if (end > DC8051_DATA_MEM_SIZE)
 			end = DC8051_DATA_MEM_SIZE;
 		rval = read_8051_data(ppd->dd, start, end - start,
@@ -625,98 +611,96 @@ static ssize_t dc8051_memory_read(struct file *file, char __user *buf,
 			goto done;
 	}
 
-	rval = simple_read_from_buffer(buf, count, ppos, tmp,
-				       DC8051_DATA_MEM_SIZE);
+	rval = simple_copy_to_iter(tmp, &iocb->ki_pos, DC8051_DATA_MEM_SIZE, to);
 done:
 	kfree(tmp);
 	return rval;
 }
 
-static ssize_t debugfs_lcb_read(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t debugfs_lcb_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hfi1_pportdata *ppd = private2ppd(file);
+	struct hfi1_pportdata *ppd = private2ppd(iocb->ki_filp);
+	size_t count = iov_iter_count(to);
 	struct hfi1_devdata *dd = ppd->dd;
 	unsigned long total, csr_off;
 	u64 data;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	/* only read 8 byte quantities */
 	if ((count % 8) != 0)
 		return -EINVAL;
 	/* offset must be 8-byte aligned */
-	if ((*ppos % 8) != 0)
+	if ((iocb->ki_pos % 8) != 0)
 		return -EINVAL;
 	/* do nothing if out of range or zero count */
-	if (*ppos >= (LCB_END - LCB_START) || !count)
+	if (iocb->ki_pos >= (LCB_END - LCB_START) || !count)
 		return 0;
 	/* reduce count if needed */
-	if (*ppos + count > LCB_END - LCB_START)
-		count = (LCB_END - LCB_START) - *ppos;
+	if (iocb->ki_pos + count > LCB_END - LCB_START)
+		count = (LCB_END - LCB_START) - iocb->ki_pos;
 
-	csr_off = LCB_START + *ppos;
+	csr_off = LCB_START + iocb->ki_pos;
 	for (total = 0; total < count; total += 8, csr_off += 8) {
 		if (read_lcb_csr(dd, csr_off, (u64 *)&data))
 			break; /* failed */
-		if (put_user(data, (unsigned long __user *)(buf + total)))
+		if (!copy_to_iter_full(&data, sizeof(data), to))
 			break;
 	}
-	*ppos += total;
+	iocb->ki_pos += total;
 	return total;
 }
 
-static ssize_t debugfs_lcb_write(struct file *file, const char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t debugfs_lcb_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hfi1_pportdata *ppd = private2ppd(file);
+	struct hfi1_pportdata *ppd = private2ppd(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	struct hfi1_devdata *dd = ppd->dd;
 	unsigned long total, csr_off, data;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 	/* only write 8 byte quantities */
 	if ((count % 8) != 0)
 		return -EINVAL;
 	/* offset must be 8-byte aligned */
-	if ((*ppos % 8) != 0)
+	if ((iocb->ki_pos % 8) != 0)
 		return -EINVAL;
 	/* do nothing if out of range or zero count */
-	if (*ppos >= (LCB_END - LCB_START) || !count)
+	if (iocb->ki_pos >= (LCB_END - LCB_START) || !count)
 		return 0;
 	/* reduce count if needed */
-	if (*ppos + count > LCB_END - LCB_START)
-		count = (LCB_END - LCB_START) - *ppos;
+	if (iocb->ki_pos + count > LCB_END - LCB_START)
+		count = (LCB_END - LCB_START) - iocb->ki_pos;
 
-	csr_off = LCB_START + *ppos;
+	csr_off = LCB_START + iocb->ki_pos;
 	for (total = 0; total < count; total += 8, csr_off += 8) {
-		if (get_user(data, (unsigned long __user *)(buf + total)))
+		if (!copy_from_iter_full(&data, sizeof(data), from))
 			break;
 		if (write_lcb_csr(dd, csr_off, data))
 			break; /* failed */
 	}
-	*ppos += total;
+	iocb->ki_pos += total;
 	return total;
 }
 
 /*
  * read the per-port QSFP data for ppd
  */
-static ssize_t qsfp_debugfs_dump(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t qsfp_debugfs_dump(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct hfi1_pportdata *ppd;
 	char *tmp;
 	int ret;
 
-	ppd = private2ppd(file);
+	ppd = private2ppd(iocb->ki_filp);
 	tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!tmp)
 		return -ENOMEM;
 
 	ret = qsfp_dump(ppd, tmp, PAGE_SIZE);
 	if (ret > 0)
-		ret = simple_read_from_buffer(buf, count, ppos, tmp, ret);
+		ret = simple_copy_to_iter(tmp, &iocb->ki_pos, ret, to);
 	kfree(tmp);
 	return ret;
 }
@@ -767,6 +751,7 @@ static ssize_t i2c1_debugfs_write(struct file *file, const char __user *buf,
 {
 	return __i2c_debugfs_write(file, buf, count, ppos, 0);
 }
+FOPS_WRITE_ITER_HELPER(i2c1_debugfs_write);
 
 /* Do an i2c write operation on chain for HFI 1. */
 static ssize_t i2c2_debugfs_write(struct file *file, const char __user *buf,
@@ -774,6 +759,7 @@ static ssize_t i2c2_debugfs_write(struct file *file, const char __user *buf,
 {
 	return __i2c_debugfs_write(file, buf, count, ppos, 1);
 }
+FOPS_WRITE_ITER_HELPER(i2c2_debugfs_write);
 
 /* Do an i2c read operation on the chain for the given HFI. */
 static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf,
@@ -827,6 +813,7 @@ static ssize_t i2c1_debugfs_read(struct file *file, char __user *buf,
 {
 	return __i2c_debugfs_read(file, buf, count, ppos, 0);
 }
+FOPS_READ_ITER_HELPER(i2c1_debugfs_read);
 
 /* Do an i2c read operation on chain for HFI 1. */
 static ssize_t i2c2_debugfs_read(struct file *file, char __user *buf,
@@ -834,6 +821,7 @@ static ssize_t i2c2_debugfs_read(struct file *file, char __user *buf,
 {
 	return __i2c_debugfs_read(file, buf, count, ppos, 1);
 }
+FOPS_READ_ITER_HELPER(i2c2_debugfs_read);
 
 /* Do a QSFP write operation on the i2c chain for the given HFI. */
 static ssize_t __qsfp_debugfs_write(struct file *file, const char __user *buf,
@@ -874,6 +862,7 @@ static ssize_t qsfp1_debugfs_write(struct file *file, const char __user *buf,
 {
 	return __qsfp_debugfs_write(file, buf, count, ppos, 0);
 }
+FOPS_WRITE_ITER_HELPER(qsfp1_debugfs_write);
 
 /* Do a QSFP write operation on i2c chain for HFI 1. */
 static ssize_t qsfp2_debugfs_write(struct file *file, const char __user *buf,
@@ -881,6 +870,7 @@ static ssize_t qsfp2_debugfs_write(struct file *file, const char __user *buf,
 {
 	return __qsfp_debugfs_write(file, buf, count, ppos, 1);
 }
+FOPS_WRITE_ITER_HELPER(qsfp2_debugfs_write);
 
 /* Do a QSFP read operation on the i2c chain for the given HFI. */
 static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf,
@@ -932,6 +922,7 @@ static ssize_t qsfp1_debugfs_read(struct file *file, char __user *buf,
 {
 	return __qsfp_debugfs_read(file, buf, count, ppos, 0);
 }
+FOPS_READ_ITER_HELPER(qsfp1_debugfs_read);
 
 /* Do a QSFP read operation on i2c chain for HFI 1. */
 static ssize_t qsfp2_debugfs_read(struct file *file, char __user *buf,
@@ -939,6 +930,7 @@ static ssize_t qsfp2_debugfs_read(struct file *file, char __user *buf,
 {
 	return __qsfp_debugfs_read(file, buf, count, ppos, 1);
 }
+FOPS_READ_ITER_HELPER(qsfp2_debugfs_read);
 
 static int __i2c_debugfs_open(struct inode *in, struct file *fp, u32 target)
 {
@@ -1043,22 +1035,20 @@ static int exprom_wp_set(struct hfi1_devdata *dd, bool disable)
 	return 0;
 }
 
-static ssize_t exprom_wp_debugfs_read(struct file *file, char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t exprom_wp_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
 
-static ssize_t exprom_wp_debugfs_write(struct file *file,
-				       const char __user *buf, size_t count,
-				       loff_t *ppos)
+static ssize_t exprom_wp_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct hfi1_pportdata *ppd = private2ppd(file);
+	struct hfi1_pportdata *ppd = private2ppd(iocb->ki_filp);
+	size_t count = iov_iter_count(from);
 	char cdata;
 
 	if (count != 1)
 		return -EINVAL;
-	if (get_user(cdata, buf))
+	if (get_iter(cdata, from))
 		return -EFAULT;
 	if (cdata == '0')
 		exprom_wp_set(ppd->dd, false);
@@ -1096,8 +1086,8 @@ static int exprom_wp_debugfs_release(struct inode *in, struct file *fp)
 	.name = nm, \
 	.ops = { \
 		.owner = THIS_MODULE, \
-		.read = readroutine, \
-		.write = writeroutine, \
+		.read_iter = readroutine, \
+		.write_iter = writeroutine, \
 		.llseek = generic_file_llseek, \
 	}, \
 }
@@ -1107,8 +1097,8 @@ static int exprom_wp_debugfs_release(struct inode *in, struct file *fp)
 	.name = nm, \
 	.ops = { \
 		.owner = THIS_MODULE, \
-		.read = readf, \
-		.write = writef, \
+		.read_iter = readf, \
+		.write_iter = writef, \
 		.llseek = generic_file_llseek, \
 		.open = openf, \
 		.release = releasef \
@@ -1123,14 +1113,14 @@ static const struct counter_info cntr_ops[] = {
 
 static const struct counter_info port_cntr_ops[] = {
 	DEBUGFS_OPS("port%dcounters", portcntrs_debugfs_read, NULL),
-	DEBUGFS_XOPS("i2c1", i2c1_debugfs_read, i2c1_debugfs_write,
+	DEBUGFS_XOPS("i2c1", i2c1_debugfs_read_iter, i2c1_debugfs_write_iter,
 		     i2c1_debugfs_open, i2c1_debugfs_release),
-	DEBUGFS_XOPS("i2c2", i2c2_debugfs_read, i2c2_debugfs_write,
+	DEBUGFS_XOPS("i2c2", i2c2_debugfs_read_iter, i2c2_debugfs_write_iter,
 		     i2c2_debugfs_open, i2c2_debugfs_release),
 	DEBUGFS_OPS("qsfp_dump%d", qsfp_debugfs_dump, NULL),
-	DEBUGFS_XOPS("qsfp1", qsfp1_debugfs_read, qsfp1_debugfs_write,
+	DEBUGFS_XOPS("qsfp1", qsfp1_debugfs_read_iter, qsfp1_debugfs_write_iter,
 		     qsfp1_debugfs_open, qsfp1_debugfs_release),
-	DEBUGFS_XOPS("qsfp2", qsfp2_debugfs_read, qsfp2_debugfs_write,
+	DEBUGFS_XOPS("qsfp2", qsfp2_debugfs_read_iter, qsfp2_debugfs_write_iter,
 		     qsfp2_debugfs_open, qsfp2_debugfs_release),
 	DEBUGFS_XOPS("exprom_wp", exprom_wp_debugfs_read,
 		     exprom_wp_debugfs_write, exprom_wp_debugfs_open,
@@ -1222,7 +1212,7 @@ void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
 				 port_cntr_ops[i].name,
 				 j + 1);
 			debugfs_create_file(name,
-					    !port_cntr_ops[i].ops.write ?
+					    !port_cntr_ops[i].ops.write_iter ?
 						    S_IRUGO :
 						    S_IRUGO | S_IWUSR,
 					    root, ppd, &port_cntr_ops[i].ops);
diff --git a/drivers/infiniband/hw/hfi1/debugfs.h b/drivers/infiniband/hw/hfi1/debugfs.h
index 54d952a4016c..62f549a1adb4 100644
--- a/drivers/infiniband/hw/hfi1/debugfs.h
+++ b/drivers/infiniband/hw/hfi1/debugfs.h
@@ -33,14 +33,12 @@ static int _##name##_open(struct inode *inode, struct file *s) \
 static const struct file_operations _##name##_file_ops = { \
 	.owner   = THIS_MODULE, \
 	.open    = _##name##_open, \
-	.read    = hfi1_seq_read, \
+	.read_iter = hfi1_seq_read, \
 	.llseek  = hfi1_seq_lseek, \
 	.release = seq_release \
 }
 
-
-ssize_t hfi1_seq_read(struct file *file, char __user *buf, size_t size,
-		      loff_t *ppos);
+ssize_t hfi1_seq_read(struct kiocb *iocb, struct iov_iter *to);
 loff_t hfi1_seq_lseek(struct file *file, loff_t offset, int whence);
 
 #ifdef CONFIG_DEBUG_FS
diff --git a/drivers/infiniband/hw/hfi1/fault.c b/drivers/infiniband/hw/hfi1/fault.c
index 35d2382ee618..0fe332245501 100644
--- a/drivers/infiniband/hw/hfi1/fault.c
+++ b/drivers/infiniband/hw/hfi1/fault.c
@@ -86,25 +86,25 @@ static int fault_opcodes_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t fault_opcodes_write(struct file *file, const char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t fault_opcodes_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	ssize_t ret = 0;
 	/* 1280 = 256 opcodes * 4 chars/opcode + 255 commas + NULL */
 	size_t copy, datalen = 1280;
 	char *data, *token, *ptr, *end;
-	struct fault *fault = file->private_data;
+	struct fault *fault = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 
 	data = kcalloc(datalen, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 	copy = min(len, datalen - 1);
-	if (copy_from_user(data, buf, copy)) {
+	if (!copy_from_iter_full(data, copy, from)) {
 		ret = -EFAULT;
 		goto free_data;
 	}
 
-	ret = debugfs_file_get(file->f_path.dentry);
+	ret = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 	if (unlikely(ret))
 		goto free_data;
 	ptr = data;
@@ -154,26 +154,25 @@ static ssize_t fault_opcodes_write(struct file *file, const char __user *buf,
 	}
 	ret = len;
 
-	debugfs_file_put(file->f_path.dentry);
+	debugfs_file_put(iocb->ki_filp->f_path.dentry);
 free_data:
 	kfree(data);
 	return ret;
 }
 
-static ssize_t fault_opcodes_read(struct file *file, char __user *buf,
-				  size_t len, loff_t *pos)
+static ssize_t fault_opcodes_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret = 0;
 	char *data;
 	size_t datalen = 1280, size = 0; /* see fault_opcodes_write() */
 	unsigned long bit = 0, zero = 0;
-	struct fault *fault = file->private_data;
+	struct fault *fault = iocb->ki_filp->private_data;
 	size_t bitsize = sizeof(fault->opcodes) * BITS_PER_BYTE;
 
 	data = kcalloc(datalen, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
-	ret = debugfs_file_get(file->f_path.dentry);
+	ret = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 	if (unlikely(ret))
 		goto free_data;
 	bit = find_first_bit(fault->opcodes, bitsize);
@@ -189,10 +188,10 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf,
 					 bit);
 		bit = find_next_bit(fault->opcodes, bitsize, zero);
 	}
-	debugfs_file_put(file->f_path.dentry);
+	debugfs_file_put(iocb->ki_filp->f_path.dentry);
 	data[size - 1] = '\n';
 	data[size] = '\0';
-	ret = simple_read_from_buffer(buf, len, pos, data, size);
+	ret = simple_copy_to_iter(data, &iocb->ki_pos, size, to);
 free_data:
 	kfree(data);
 	return ret;
@@ -201,8 +200,8 @@ static ssize_t fault_opcodes_read(struct file *file, char __user *buf,
 static const struct file_operations __fault_opcodes_fops = {
 	.owner = THIS_MODULE,
 	.open = fault_opcodes_open,
-	.read = fault_opcodes_read,
-	.write = fault_opcodes_write,
+	.read_iter = fault_opcodes_read,
+	.write_iter = fault_opcodes_write,
 	.llseek = no_llseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 407/437] infiniband/mlx5: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (405 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 406/437] infiniband/hfi1: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 408/437] infiniband/ocrdma: " Jens Axboe
                   ` (30 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/mlx5/cong.c | 19 ++++++++--------
 drivers/infiniband/hw/mlx5/devx.c | 24 +++++++++----------
 drivers/infiniband/hw/mlx5/main.c | 20 ++++++++--------
 drivers/infiniband/hw/mlx5/mr.c   | 38 +++++++++++++++----------------
 4 files changed, 49 insertions(+), 52 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/cong.c b/drivers/infiniband/hw/mlx5/cong.c
index a78a067e3ce7..b7ca85f516fc 100644
--- a/drivers/infiniband/hw/mlx5/cong.c
+++ b/drivers/infiniband/hw/mlx5/cong.c
@@ -368,10 +368,10 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, u32 port_num,
 	return err;
 }
 
-static ssize_t set_param(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *pos)
+static ssize_t set_param(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_ib_dbg_param *param = filp->private_data;
+	struct mlx5_ib_dbg_param *param = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int offset = param->offset;
 	char lbuf[11] = { };
 	u32 var;
@@ -380,7 +380,7 @@ static ssize_t set_param(struct file *filp, const char __user *buf,
 	if (count > sizeof(lbuf))
 		return -EINVAL;
 
-	if (copy_from_user(lbuf, buf, count))
+	if (!copy_from_iter_full(lbuf, count, from))
 		return -EFAULT;
 
 	lbuf[sizeof(lbuf) - 1] = '\0';
@@ -392,10 +392,9 @@ static ssize_t set_param(struct file *filp, const char __user *buf,
 	return ret ? ret : count;
 }
 
-static ssize_t get_param(struct file *filp, char __user *buf, size_t count,
-			 loff_t *pos)
+static ssize_t get_param(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_ib_dbg_param *param = filp->private_data;
+	struct mlx5_ib_dbg_param *param = iocb->ki_filp->private_data;
 	int offset = param->offset;
 	u32 var = 0;
 	int ret;
@@ -409,14 +408,14 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count,
 	if (ret < 0)
 		return ret;
 
-	return simple_read_from_buffer(buf, count, pos, lbuf, ret);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations dbg_cc_fops = {
 	.owner	= THIS_MODULE,
 	.open	= simple_open,
-	.write	= set_param,
-	.read	= get_param,
+	.write_iter	= set_param,
+	.read_iter	= get_param,
 };
 
 void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u32 port_num)
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index 253fea374a72..a73c9ba11912 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -2595,11 +2595,11 @@ void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev)
 	}
 }
 
-static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
-					 size_t count, loff_t *pos)
+static ssize_t devx_async_cmd_event_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct devx_async_cmd_event_file *comp_ev_file = filp->private_data;
+	struct devx_async_cmd_event_file *comp_ev_file = iocb->ki_filp->private_data;
 	struct devx_async_event_queue *ev_queue = &comp_ev_file->ev_queue;
+	size_t count = iov_iter_count(to);
 	struct devx_async_data *event;
 	int ret = 0;
 	size_t eventsz;
@@ -2609,7 +2609,7 @@ static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
 	while (list_empty(&ev_queue->event_list)) {
 		spin_unlock_irq(&ev_queue->lock);
 
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		if (wait_event_interruptible(
@@ -2639,7 +2639,7 @@ static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
 	list_del(ev_queue->event_list.next);
 	spin_unlock_irq(&ev_queue->lock);
 
-	if (copy_to_user(buf, &event->hdr, eventsz))
+	if (!copy_to_iter_full(&event->hdr, eventsz, to))
 		ret = -EFAULT;
 	else
 		ret = eventsz;
@@ -2670,18 +2670,18 @@ static __poll_t devx_async_cmd_event_poll(struct file *filp,
 
 static const struct file_operations devx_async_cmd_event_fops = {
 	.owner	 = THIS_MODULE,
-	.read	 = devx_async_cmd_event_read,
+	.read_iter	 = devx_async_cmd_event_read,
 	.poll    = devx_async_cmd_event_poll,
 	.release = uverbs_uobject_fd_release,
 	.llseek	 = no_llseek,
 };
 
-static ssize_t devx_async_event_read(struct file *filp, char __user *buf,
-				     size_t count, loff_t *pos)
+static ssize_t devx_async_event_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct devx_async_event_file *ev_file = filp->private_data;
+	struct devx_async_event_file *ev_file = iocb->ki_filp->private_data;
 	struct devx_event_subscription *event_sub;
 	struct devx_async_event_data *event;
+	size_t count = iov_iter_count(to);
 	int ret = 0;
 	size_t eventsz;
 	bool omit_data;
@@ -2701,7 +2701,7 @@ static ssize_t devx_async_event_read(struct file *filp, char __user *buf,
 	while (list_empty(&ev_file->event_list)) {
 		spin_unlock_irq(&ev_file->lock);
 
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		if (wait_event_interruptible(ev_file->poll_wait,
@@ -2743,7 +2743,7 @@ static ssize_t devx_async_event_read(struct file *filp, char __user *buf,
 
 	spin_unlock_irq(&ev_file->lock);
 
-	if (copy_to_user(buf, event_data, eventsz))
+	if (!copy_to_iter_full(event_data, eventsz, to))
 		/* This points to an application issue, not a kernel concern */
 		ret = -EFAULT;
 	else
@@ -2785,7 +2785,7 @@ static void devx_free_subscription(struct rcu_head *rcu)
 
 static const struct file_operations devx_async_event_fops = {
 	.owner	 = THIS_MODULE,
-	.read	 = devx_async_event_read,
+	.read_iter	 = devx_async_event_read,
 	.poll    = devx_async_event_poll,
 	.release = uverbs_uobject_fd_release,
 	.llseek	 = no_llseek,
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index c2b557e64290..f531568cfead 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3154,25 +3154,25 @@ static int mlx5_ib_rn_get_params(struct ib_device *device, u32 port_num,
 	return mlx5_rdma_rn_get_params(to_mdev(device)->mdev, device, params);
 }
 
-static ssize_t delay_drop_timeout_read(struct file *filp, char __user *buf,
-				       size_t count, loff_t *pos)
+static ssize_t delay_drop_timeout_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_ib_delay_drop *delay_drop = filp->private_data;
+	struct mlx5_ib_delay_drop *delay_drop = iocb->ki_filp->private_data;
 	char lbuf[20];
 	int len;
 
 	len = snprintf(lbuf, sizeof(lbuf), "%u\n", delay_drop->timeout);
-	return simple_read_from_buffer(buf, count, pos, lbuf, len);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t delay_drop_timeout_write(struct file *filp, const char __user *buf,
-					size_t count, loff_t *pos)
+static ssize_t delay_drop_timeout_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct mlx5_ib_delay_drop *delay_drop = filp->private_data;
+	struct mlx5_ib_delay_drop *delay_drop = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 timeout;
 	u32 var;
 
-	if (kstrtouint_from_user(buf, count, 0, &var))
+	if (kstrtouint_from_iter(from, count, 0, &var))
 		return -EFAULT;
 
 	timeout = min_t(u32, roundup(var, 100), MLX5_MAX_DELAY_DROP_TIMEOUT_MS *
@@ -3189,8 +3189,8 @@ static ssize_t delay_drop_timeout_write(struct file *filp, const char __user *bu
 static const struct file_operations fops_delay_drop_timeout = {
 	.owner	= THIS_MODULE,
 	.open	= simple_open,
-	.write	= delay_drop_timeout_write,
-	.read	= delay_drop_timeout_read,
+	.write_iter	= delay_drop_timeout_write,
+	.read_iter	= delay_drop_timeout_read,
 };
 
 static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index a8ee2ca1f4a1..779da5c2f911 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -366,14 +366,14 @@ static int resize_available_mrs(struct mlx5_cache_ent *ent, unsigned int target,
 	}
 }
 
-static ssize_t size_write(struct file *filp, const char __user *buf,
-			  size_t count, loff_t *pos)
+static ssize_t size_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_cache_ent *ent = filp->private_data;
+	struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 target;
 	int err;
 
-	err = kstrtou32_from_user(buf, count, 0, &target);
+	err = kstrtou32_from_iter(from, count, 0, &target);
 	if (err)
 		return err;
 
@@ -404,10 +404,9 @@ static ssize_t size_write(struct file *filp, const char __user *buf,
 	return err;
 }
 
-static ssize_t size_read(struct file *filp, char __user *buf, size_t count,
-			 loff_t *pos)
+static ssize_t size_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_cache_ent *ent = filp->private_data;
+	struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;
 	char lbuf[20];
 	int err;
 
@@ -416,24 +415,24 @@ static ssize_t size_read(struct file *filp, char __user *buf, size_t count,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(buf, count, pos, lbuf, err);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, err, to);
 }
 
 static const struct file_operations size_fops = {
 	.owner	= THIS_MODULE,
 	.open	= simple_open,
-	.write	= size_write,
-	.read	= size_read,
+	.write_iter	= size_write,
+	.read_iter	= size_read,
 };
 
-static ssize_t limit_write(struct file *filp, const char __user *buf,
-			   size_t count, loff_t *pos)
+static ssize_t limit_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_cache_ent *ent = filp->private_data;
+	struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 var;
 	int err;
 
-	err = kstrtou32_from_user(buf, count, 0, &var);
+	err = kstrtou32_from_iter(from, count, 0, &var);
 	if (err)
 		return err;
 
@@ -450,10 +449,9 @@ static ssize_t limit_write(struct file *filp, const char __user *buf,
 	return count;
 }
 
-static ssize_t limit_read(struct file *filp, char __user *buf, size_t count,
-			  loff_t *pos)
+static ssize_t limit_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_cache_ent *ent = filp->private_data;
+	struct mlx5_cache_ent *ent = iocb->ki_filp->private_data;
 	char lbuf[20];
 	int err;
 
@@ -461,14 +459,14 @@ static ssize_t limit_read(struct file *filp, char __user *buf, size_t count,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(buf, count, pos, lbuf, err);
+	return simple_copy_to_iter(lbuf, &iocb->ki_pos, err, to);
 }
 
 static const struct file_operations limit_fops = {
 	.owner	= THIS_MODULE,
 	.open	= simple_open,
-	.write	= limit_write,
-	.read	= limit_read,
+	.write_iter	= limit_write,
+	.read_iter	= limit_read,
 };
 
 static bool someone_adding(struct mlx5_mkey_cache *cache)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 408/437] infiniband/ocrdma: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (406 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 407/437] infiniband/mlx5: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 409/437] infiniband/qib: " Jens Axboe
                   ` (29 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 26 ++++++++++-----------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 5f831e3bdbad..687174d32365 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -631,20 +631,19 @@ static void ocrdma_update_stats(struct ocrdma_dev *dev)
 	}
 }
 
-static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t ocrdma_dbgfs_ops_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char tmp_str[32];
 	long reset;
 	int status;
-	struct ocrdma_stats *pstats = filp->private_data;
+	struct ocrdma_stats *pstats = iocb->ki_filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
+	size_t count = iov_iter_count(from);
 
-	if (*ppos != 0 || count == 0 || count > sizeof(tmp_str))
+	if (iocb->ki_pos != 0 || count == 0 || count > sizeof(tmp_str))
 		goto err;
 
-	if (copy_from_user(tmp_str, buffer, count))
+	if (!copy_from_iter_full(tmp_str, count, from))
 		goto err;
 
 	tmp_str[count-1] = '\0';
@@ -683,16 +682,16 @@ void ocrdma_pma_counters(struct ocrdma_dev *dev, struct ib_mad *out_mad)
 	pma_cnt->port_rcv_packets  = cpu_to_be32(ocrdma_sysfs_rcv_pkts(dev));
 }
 
-static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,
-					size_t usr_buf_len, loff_t *ppos)
+static ssize_t ocrdma_dbgfs_ops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ocrdma_stats *pstats = filp->private_data;
+	struct ocrdma_stats *pstats = iocb->ki_filp->private_data;
+	size_t usr_buf_len = iov_iter_count(to);
 	struct ocrdma_dev *dev = pstats->dev;
 	ssize_t status = 0;
 	char *data = NULL;
 
 	/* No partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	mutex_lock(&dev->stats_lock);
@@ -741,8 +740,7 @@ static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,
 		goto exit;
 	}
 
-	status = simple_read_from_buffer(buffer, usr_buf_len, ppos, data,
-					 strlen(data));
+	status = simple_copy_to_iter(data, &iocb->ki_pos, strlen(data), to);
 exit:
 	mutex_unlock(&dev->stats_lock);
 	return status;
@@ -751,8 +749,8 @@ static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,
 static const struct file_operations ocrdma_dbg_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = ocrdma_dbgfs_ops_read,
-	.write = ocrdma_dbgfs_ops_write,
+	.read_iter = ocrdma_dbgfs_ops_read,
+	.write_iter = ocrdma_dbgfs_ops_write,
 };
 
 void ocrdma_add_port_stats(struct ocrdma_dev *dev)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 409/437] infiniband/qib: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (407 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 408/437] infiniband/ocrdma: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 410/437] infiniband/hns: " Jens Axboe
                   ` (28 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/qib/qib_debugfs.c  |   2 +-
 drivers/infiniband/hw/qib/qib_diag.c     |  18 ++--
 drivers/infiniband/hw/qib/qib_file_ops.c |   4 +-
 drivers/infiniband/hw/qib/qib_fs.c       | 119 +++++++++++------------
 4 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_debugfs.c b/drivers/infiniband/hw/qib/qib_debugfs.c
index caeb77d07a58..79144e7b42bd 100644
--- a/drivers/infiniband/hw/qib/qib_debugfs.c
+++ b/drivers/infiniband/hw/qib/qib_debugfs.c
@@ -61,7 +61,7 @@ static int _##name##_open(struct inode *inode, struct file *s) \
 static const struct file_operations _##name##_file_ops = { \
 	.owner   = THIS_MODULE, \
 	.open    = _##name##_open, \
-	.read    = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek  = seq_lseek, \
 	.release = seq_release \
 };
diff --git a/drivers/infiniband/hw/qib/qib_diag.c b/drivers/infiniband/hw/qib/qib_diag.c
index 11da796dd1b7..898937c2aead 100644
--- a/drivers/infiniband/hw/qib/qib_diag.c
+++ b/drivers/infiniband/hw/qib/qib_diag.c
@@ -130,15 +130,13 @@ static void return_client(struct qib_diag_client *dc)
 
 static int qib_diag_open(struct inode *in, struct file *fp);
 static int qib_diag_release(struct inode *in, struct file *fp);
-static ssize_t qib_diag_read(struct file *fp, char __user *data,
-			     size_t count, loff_t *off);
-static ssize_t qib_diag_write(struct file *fp, const char __user *data,
-			      size_t count, loff_t *off);
+static ssize_t qib_diag_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t qib_diag_write_iter(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations diag_file_ops = {
 	.owner = THIS_MODULE,
-	.write = qib_diag_write,
-	.read = qib_diag_read,
+	.write_iter = qib_diag_write_iter,
+	.read_iter = qib_diag_read_iter,
 	.open = qib_diag_open,
 	.release = qib_diag_release,
 	.llseek = default_llseek,
@@ -148,12 +146,11 @@ static atomic_t diagpkt_count = ATOMIC_INIT(0);
 static struct cdev *diagpkt_cdev;
 static struct device *diagpkt_device;
 
-static ssize_t qib_diagpkt_write(struct file *fp, const char __user *data,
-				 size_t count, loff_t *off);
+static ssize_t qib_diagpkt_write_iter(struct kiocb *iocb, struct iov_iter *from);
 
 static const struct file_operations diagpkt_file_ops = {
 	.owner = THIS_MODULE,
-	.write = qib_diagpkt_write,
+	.write_iter = qib_diagpkt_write_iter,
 	.llseek = noop_llseek,
 };
 
@@ -672,6 +669,7 @@ static ssize_t qib_diagpkt_write(struct file *fp,
 	vfree(tmpbuf);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(qib_diagpkt_write);
 
 static int qib_diag_release(struct inode *in, struct file *fp)
 {
@@ -829,6 +827,7 @@ static ssize_t qib_diag_read(struct file *fp, char __user *data,
 bail:
 	return ret;
 }
+FOPS_READ_ITER_HELPER(qib_diag_read);
 
 static ssize_t qib_diag_write(struct file *fp, const char __user *data,
 			      size_t count, loff_t *off)
@@ -904,3 +903,4 @@ static ssize_t qib_diag_write(struct file *fp, const char __user *data,
 bail:
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(qib_diag_write);
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index 29e4c59aa23b..5bfecbbe2173 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -68,7 +68,6 @@ static int qib_mmapf(struct file *, struct vm_area_struct *);
  */
 static const struct file_operations qib_file_ops = {
 	.owner = THIS_MODULE,
-	.write = qib_write,
 	.write_iter = qib_write_iter,
 	.open = qib_open,
 	.release = qib_close,
@@ -2244,6 +2243,9 @@ static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	struct qib_ctxtdata *rcd = ctxt_fp(iocb->ki_filp);
 	struct qib_user_sdma_queue *pq = fp->pq;
 
+	if (!(iocb->ki_flags & IOCB_VECTORED))
+		vfs_write_iter(iocb, from, qib_write);
+
 	if (!user_backed_iter(from) || !from->nr_segs || !pq)
 		return -EINVAL;
 
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index 455e966eeff3..87817e706e05 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -100,12 +100,11 @@ static int create_file(const char *name, umode_t mode,
 	return error;
 }
 
-static ssize_t driver_stats_read(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t driver_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	qib_stats.sps_ints = qib_sps_ints();
-	return simple_read_from_buffer(buf, count, ppos, &qib_stats,
-				       sizeof(qib_stats));
+	return simple_copy_to_iter(&qib_stats, &iocb->ki_pos, sizeof(qib_stats),
+					to);
 }
 
 /*
@@ -128,45 +127,42 @@ static const char qib_statnames[] =
 	"EgrHdrFull\n"
 	;
 
-static ssize_t driver_names_read(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t driver_names_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(buf, count, ppos, qib_statnames,
-		sizeof(qib_statnames) - 1); /* no null */
+	return simple_copy_to_iter(qib_statnames, &iocb->ki_pos,
+		sizeof(qib_statnames) - 1, to); /* no null */
 }
 
 static const struct file_operations driver_ops[] = {
-	{ .read = driver_stats_read, .llseek = generic_file_llseek, },
-	{ .read = driver_names_read, .llseek = generic_file_llseek, },
+	{ .read_iter = driver_stats_read, .llseek = generic_file_llseek, },
+	{ .read_iter = driver_names_read, .llseek = generic_file_llseek, },
 };
 
 /* read the per-device counters */
-static ssize_t dev_counters_read(struct file *file, char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t dev_counters_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 *counters;
 	size_t avail;
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 
-	avail = dd->f_read_cntrs(dd, *ppos, NULL, &counters);
-	return simple_read_from_buffer(buf, count, ppos, counters, avail);
+	avail = dd->f_read_cntrs(dd, iocb->ki_pos, NULL, &counters);
+	return simple_copy_to_iter(counters, &iocb->ki_pos, avail, to);
 }
 
 /* read the per-device counters */
-static ssize_t dev_names_read(struct file *file, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t dev_names_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *names;
 	size_t avail;
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 
-	avail = dd->f_read_cntrs(dd, *ppos, &names, NULL);
-	return simple_read_from_buffer(buf, count, ppos, names, avail);
+	avail = dd->f_read_cntrs(dd, iocb->ki_pos, &names, NULL);
+	return simple_copy_to_iter(names, &iocb->ki_pos, avail, to);
 }
 
 static const struct file_operations cntr_ops[] = {
-	{ .read = dev_counters_read, .llseek = generic_file_llseek, },
-	{ .read = dev_names_read, .llseek = generic_file_llseek, },
+	{ .read_iter = dev_counters_read, .llseek = generic_file_llseek, },
+	{ .read_iter = dev_names_read, .llseek = generic_file_llseek, },
 };
 
 /*
@@ -175,54 +171,50 @@ static const struct file_operations cntr_ops[] = {
  */
 
 /* read the per-port names (same for each port) */
-static ssize_t portnames_read(struct file *file, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t portnames_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *names;
 	size_t avail;
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 
-	avail = dd->f_read_portcntrs(dd, *ppos, 0, &names, NULL);
-	return simple_read_from_buffer(buf, count, ppos, names, avail);
+	avail = dd->f_read_portcntrs(dd, iocb->ki_pos, 0, &names, NULL);
+	return simple_copy_to_iter(names, &iocb->ki_pos, avail, to);
 }
 
 /* read the per-port counters for port 1 (pidx 0) */
-static ssize_t portcntrs_1_read(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t portcntrs_1_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 *counters;
 	size_t avail;
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 
-	avail = dd->f_read_portcntrs(dd, *ppos, 0, NULL, &counters);
-	return simple_read_from_buffer(buf, count, ppos, counters, avail);
+	avail = dd->f_read_portcntrs(dd, iocb->ki_pos, 0, NULL, &counters);
+	return simple_copy_to_iter(counters, &iocb->ki_pos, avail, to);
 }
 
 /* read the per-port counters for port 2 (pidx 1) */
-static ssize_t portcntrs_2_read(struct file *file, char __user *buf,
-				size_t count, loff_t *ppos)
+static ssize_t portcntrs_2_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	u64 *counters;
 	size_t avail;
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 
-	avail = dd->f_read_portcntrs(dd, *ppos, 1, NULL, &counters);
-	return simple_read_from_buffer(buf, count, ppos, counters, avail);
+	avail = dd->f_read_portcntrs(dd, iocb->ki_pos, 1, NULL, &counters);
+	return simple_copy_to_iter(counters, &iocb->ki_pos, avail, to);
 }
 
 static const struct file_operations portcntr_ops[] = {
-	{ .read = portnames_read, .llseek = generic_file_llseek, },
-	{ .read = portcntrs_1_read, .llseek = generic_file_llseek, },
-	{ .read = portcntrs_2_read, .llseek = generic_file_llseek, },
+	{ .read_iter = portnames_read, .llseek = generic_file_llseek, },
+	{ .read_iter = portcntrs_1_read, .llseek = generic_file_llseek, },
+	{ .read_iter = portcntrs_2_read, .llseek = generic_file_llseek, },
 };
 
 /*
  * read the per-port QSFP data for port 1 (pidx 0)
  */
-static ssize_t qsfp_1_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t qsfp_1_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 	char *tmp;
 	int ret;
 
@@ -232,7 +224,7 @@ static ssize_t qsfp_1_read(struct file *file, char __user *buf,
 
 	ret = qib_qsfp_dump(dd->pport, tmp, PAGE_SIZE);
 	if (ret > 0)
-		ret = simple_read_from_buffer(buf, count, ppos, tmp, ret);
+		ret = simple_copy_to_iter(tmp, &iocb->ki_pos, ret, to);
 	kfree(tmp);
 	return ret;
 }
@@ -240,10 +232,9 @@ static ssize_t qsfp_1_read(struct file *file, char __user *buf,
 /*
  * read the per-port QSFP data for port 2 (pidx 1)
  */
-static ssize_t qsfp_2_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t qsfp_2_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct qib_devdata *dd = private2dd(file);
+	struct qib_devdata *dd = private2dd(iocb->ki_filp);
 	char *tmp;
 	int ret;
 
@@ -256,25 +247,25 @@ static ssize_t qsfp_2_read(struct file *file, char __user *buf,
 
 	ret = qib_qsfp_dump(dd->pport + 1, tmp, PAGE_SIZE);
 	if (ret > 0)
-		ret = simple_read_from_buffer(buf, count, ppos, tmp, ret);
+		ret = simple_copy_to_iter(tmp, &iocb->ki_pos, ret, to);
 	kfree(tmp);
 	return ret;
 }
 
 static const struct file_operations qsfp_ops[] = {
-	{ .read = qsfp_1_read, .llseek = generic_file_llseek, },
-	{ .read = qsfp_2_read, .llseek = generic_file_llseek, },
+	{ .read_iter = qsfp_1_read, .llseek = generic_file_llseek, },
+	{ .read_iter = qsfp_2_read, .llseek = generic_file_llseek, },
 };
 
-static ssize_t flash_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t flash_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct qib_devdata *dd;
 	ssize_t ret;
 	loff_t pos;
 	char *tmp;
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 
 	if (pos < 0) {
 		ret = -EINVAL;
@@ -295,19 +286,19 @@ static ssize_t flash_read(struct file *file, char __user *buf,
 		goto bail;
 	}
 
-	dd = private2dd(file);
+	dd = private2dd(iocb->ki_filp);
 	if (qib_eeprom_read(dd, pos, tmp, count)) {
 		qib_dev_err(dd, "failed to read from flash\n");
 		ret = -ENXIO;
 		goto bail_tmp;
 	}
 
-	if (copy_to_user(buf, tmp, count)) {
+	if (!copy_to_iter_full(tmp, count, to)) {
 		ret = -EFAULT;
 		goto bail_tmp;
 	}
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 	ret = count;
 
 bail_tmp:
@@ -317,31 +308,31 @@ static ssize_t flash_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t flash_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t flash_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct qib_devdata *dd;
 	ssize_t ret;
 	loff_t pos;
 	char *tmp;
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 
 	if (pos != 0 || count != sizeof(struct qib_flash))
 		return -EINVAL;
 
-	tmp = memdup_user(buf, count);
+	tmp = iterdup(from, count);
 	if (IS_ERR(tmp))
 		return PTR_ERR(tmp);
 
-	dd = private2dd(file);
+	dd = private2dd(iocb->ki_filp);
 	if (qib_eeprom_write(dd, pos, tmp, count)) {
 		ret = -ENXIO;
 		qib_dev_err(dd, "failed to write to flash\n");
 		goto bail_tmp;
 	}
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 	ret = count;
 
 bail_tmp:
@@ -350,8 +341,8 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations flash_ops = {
-	.read = flash_read,
-	.write = flash_write,
+	.read_iter = flash_read,
+	.write_iter = flash_write,
 	.llseek = default_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 410/437] infiniband/hns: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (408 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 409/437] infiniband/qib: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 411/437] infiniband/usnic: " Jens Axboe
                   ` (27 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/hns/hns_roce_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c
index e8febb40f645..102ccddf598a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c
+++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c
@@ -21,7 +21,7 @@ static const struct file_operations hns_debugfs_seqfile_fops = {
 	.owner = THIS_MODULE,
 	.open = hns_debugfs_seqfile_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 411/437] infiniband/usnic: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (409 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 410/437] infiniband/hns: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 412/437] hv: " Jens Axboe
                   ` (26 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/infiniband/hw/usnic/usnic_debugfs.c | 22 ++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/usnic/usnic_debugfs.c b/drivers/infiniband/hw/usnic/usnic_debugfs.c
index 10a8cd5ba076..7383b0131cd4 100644
--- a/drivers/infiniband/hw/usnic/usnic_debugfs.c
+++ b/drivers/infiniband/hw/usnic/usnic_debugfs.c
@@ -42,13 +42,13 @@
 static struct dentry *debugfs_root;
 static struct dentry *flows_dentry;
 
-static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data,
-						size_t count, loff_t *ppos)
+static ssize_t usnic_debugfs_buildinfo_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
 	char buf[500];
 	int res;
 
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
 	res = scnprintf(buf, sizeof(buf),
@@ -56,29 +56,29 @@ static ssize_t usnic_debugfs_buildinfo_read(struct file *f, char __user *data,
 			"build date:    %s\n",
 			DRV_VERSION, DRV_RELDATE);
 
-	return simple_read_from_buffer(data, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 static const struct file_operations usnic_debugfs_buildinfo_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = usnic_debugfs_buildinfo_read
+	.read_iter = usnic_debugfs_buildinfo_read
 };
 
-static ssize_t flowinfo_read(struct file *f, char __user *data,
-				size_t count, loff_t *ppos)
+static ssize_t flowinfo_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct usnic_ib_qp_grp_flow *qp_flow;
+	size_t count = iov_iter_count(to);
 	int n;
 	int left;
 	char *ptr;
 	char buf[512];
 
-	qp_flow = f->private_data;
+	qp_flow = iocb->ki_filp->private_data;
 	ptr = buf;
 	left = count;
 
-	if (*ppos > 0)
+	if (iocb->ki_pos > 0)
 		return 0;
 
 	spin_lock(&qp_flow->qp_grp->lock);
@@ -100,13 +100,13 @@ static ssize_t flowinfo_read(struct file *f, char __user *data,
 	}
 	spin_unlock(&qp_flow->qp_grp->lock);
 
-	return simple_read_from_buffer(data, count, ppos, buf, ptr - buf);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, ptr - buf, to);
 }
 
 static const struct file_operations flowinfo_ops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = flowinfo_read,
+	.read_iter = flowinfo_read,
 };
 
 void usnic_debugfs_init(void)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 412/437] hv: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (410 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 411/437] infiniband/usnic: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 413/437] media/rc: " Jens Axboe
                   ` (25 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/hv/hv_utils_transport.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 832885198643..fa93ac3800ae 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -24,13 +24,13 @@ static void hvt_reset(struct hvutil_transport *hvt)
 		hvt->on_reset();
 }
 
-static ssize_t hvt_op_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
+static ssize_t hvt_op_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct hvutil_transport *hvt;
 	int ret;
 
-	hvt = container_of(file->f_op, struct hvutil_transport, fops);
+	hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops);
 
 	if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0 ||
 				     hvt->mode != HVUTIL_TRANSPORT_CHARDEV))
@@ -53,7 +53,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
 		goto out_unlock;
 	}
 
-	if (!copy_to_user(buf, hvt->outmsg, hvt->outmsg_len))
+	if (copy_to_iter_full(hvt->outmsg, hvt->outmsg_len, to))
 		ret = hvt->outmsg_len;
 	else
 		ret = -EFAULT;
@@ -71,16 +71,16 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t hvt_op_write(struct file *file, const char __user *buf,
-			    size_t count, loff_t *ppos)
+static ssize_t hvt_op_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct hvutil_transport *hvt;
 	u8 *inmsg;
 	int ret;
 
-	hvt = container_of(file->f_op, struct hvutil_transport, fops);
+	hvt = container_of(iocb->ki_filp->f_op, struct hvutil_transport, fops);
 
-	inmsg = memdup_user(buf, count);
+	inmsg = iterdup(from, count);
 	if (IS_ERR(inmsg))
 		return PTR_ERR(inmsg);
 
@@ -285,8 +285,8 @@ struct hvutil_transport *hvutil_transport_init(const char *name,
 	hvt->mdev.name = name;
 
 	hvt->fops.owner = THIS_MODULE;
-	hvt->fops.read = hvt_op_read;
-	hvt->fops.write = hvt_op_write;
+	hvt->fops.read_iter = hvt_op_read;
+	hvt->fops.write_iter = hvt_op_write;
 	hvt->fops.poll = hvt_op_poll;
 	hvt->fops.open = hvt_op_open;
 	hvt->fops.release = hvt_op_release;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 413/437] media/rc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (411 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 412/437] hv: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-05-04 12:31   ` Mauro Carvalho Chehab
  2024-04-11 15:19 ` [PATCH 414/437] media/dvb-core: " Jens Axboe
                   ` (24 subsequent siblings)
  437 siblings, 1 reply; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/rc/imon.c     | 26 ++++++++++++--------------
 drivers/media/rc/lirc_dev.c | 15 ++++++++-------
 2 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 5719dda6e0f0..cfcf8101164a 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -65,12 +65,10 @@ static int display_open(struct inode *inode, struct file *file);
 static int display_close(struct inode *inode, struct file *file);
 
 /* VFD write operation */
-static ssize_t vfd_write(struct file *file, const char __user *buf,
-			 size_t n_bytes, loff_t *pos);
+static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from);
 
 /* LCD file_operations override function prototypes */
-static ssize_t lcd_write(struct file *file, const char __user *buf,
-			 size_t n_bytes, loff_t *pos);
+static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from);
 
 /*** G L O B A L S ***/
 
@@ -179,7 +177,7 @@ struct imon_context {
 static const struct file_operations vfd_fops = {
 	.owner		= THIS_MODULE,
 	.open		= display_open,
-	.write		= vfd_write,
+	.write_iter	= vfd_write,
 	.release	= display_close,
 	.llseek		= noop_llseek,
 };
@@ -188,7 +186,7 @@ static const struct file_operations vfd_fops = {
 static const struct file_operations lcd_fops = {
 	.owner		= THIS_MODULE,
 	.open		= display_open,
-	.write		= lcd_write,
+	.write_iter	= lcd_write,
 	.release	= display_close,
 	.llseek		= noop_llseek,
 };
@@ -938,16 +936,16 @@ static const struct attribute_group imon_rf_attr_group = {
  * than 32 bytes are provided spaces will be appended to
  * generate a full screen.
  */
-static ssize_t vfd_write(struct file *file, const char __user *buf,
-			 size_t n_bytes, loff_t *pos)
+static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i;
 	int offset;
 	int seq;
 	int retval = 0;
-	struct imon_context *ictx = file->private_data;
+	struct imon_context *ictx = iocb->ki_filp->private_data;
 	static const unsigned char vfd_packet6[] = {
 		0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
+	size_t n_bytes = iov_iter_count(from);
 
 	if (ictx->disconnected)
 		return -ENODEV;
@@ -967,7 +965,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
 		goto exit;
 	}
 
-	if (copy_from_user(ictx->tx.data_buf, buf, n_bytes)) {
+	if (!copy_from_iter_full(ictx->tx.data_buf, n_bytes, from)) {
 		retval = -EFAULT;
 		goto exit;
 	}
@@ -1023,11 +1021,11 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
  * display whatever diacritics you need, and so on), but it's also
  * a lot more complicated than most LCDs...
  */
-static ssize_t lcd_write(struct file *file, const char __user *buf,
-			 size_t n_bytes, loff_t *pos)
+static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	int retval = 0;
-	struct imon_context *ictx = file->private_data;
+	struct imon_context *ictx = iocb->ki_filp->private_data;
+	size_t n_bytes = iov_iter_count(from);
 
 	if (ictx->disconnected)
 		return -ENODEV;
@@ -1047,7 +1045,7 @@ static ssize_t lcd_write(struct file *file, const char __user *buf,
 		goto exit;
 	}
 
-	if (copy_from_user(ictx->usb_tx_buf, buf, 8)) {
+	if (!copy_from_iter_full(ictx->usb_tx_buf, 8, from)) {
 		retval = -EFAULT;
 		goto exit;
 	}
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index caad59f76793..e88ba11192ea 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -211,10 +211,10 @@ static int lirc_close(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t lirc_transmit(struct file *file, const char __user *buf,
-			     size_t n, loff_t *ppos)
+static ssize_t lirc_transmit(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct lirc_fh *fh = file->private_data;
+	struct lirc_fh *fh = iocb->ki_filp->private_data;
+	size_t n = iov_iter_count(from);
 	struct rc_dev *dev = fh->rc;
 	unsigned int *txbuf;
 	struct ir_raw_event *raw = NULL;
@@ -247,7 +247,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf,
 			goto out_unlock;
 		}
 
-		if (copy_from_user(&scan, buf, sizeof(scan))) {
+		if (!copy_from_iter_full(&scan, sizeof(scan), from)) {
 			ret = -EFAULT;
 			goto out_unlock;
 		}
@@ -309,7 +309,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf,
 			goto out_unlock;
 		}
 
-		txbuf = memdup_user(buf, n);
+		txbuf = iterdup(from, n);
 		if (IS_ERR(txbuf)) {
 			ret = PTR_ERR(txbuf);
 			goto out_unlock;
@@ -694,13 +694,14 @@ static ssize_t lirc_read(struct file *file, char __user *buffer, size_t length,
 	else /* LIRC_MODE_SCANCODE */
 		return lirc_read_scancode(file, buffer, length);
 }
+FOPS_READ_ITER_HELPER(lirc_read);
 
 static const struct file_operations lirc_fops = {
 	.owner		= THIS_MODULE,
-	.write		= lirc_transmit,
+	.write_iter	= lirc_transmit,
 	.unlocked_ioctl	= lirc_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
-	.read		= lirc_read,
+	.read_iter	= lirc_read_iter,
 	.poll		= lirc_poll,
 	.open		= lirc_open,
 	.release	= lirc_close,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 414/437] media/dvb-core: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (412 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 413/437] media/rc: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 415/437] media/common: " Jens Axboe
                   ` (23 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/dvb-core/dmxdev.c         |  9 ++++++---
 drivers/media/dvb-core/dvb_ca_en50221.c | 25 +++++++++++--------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 9ce5f010de3f..f30ec9c3cade 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -261,6 +261,7 @@ static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
 	mutex_unlock(&dmxdev->mutex);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(dvb_dvr_write);
 
 static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
 			    loff_t *ppos)
@@ -275,6 +276,7 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
 				      file->f_flags & O_NONBLOCK,
 				      buf, count, ppos);
 }
+FOPS_READ_ITER_HELPER(dvb_dvr_read);
 
 static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev,
 				      unsigned long size)
@@ -1025,6 +1027,7 @@ dvb_demux_read(struct file *file, char __user *buf, size_t count,
 	mutex_unlock(&dmxdevfilter->mutex);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(dvb_demux_read);
 
 static int dvb_demux_do_ioctl(struct file *file,
 			      unsigned int cmd, void *parg)
@@ -1258,7 +1261,7 @@ static int dvb_demux_release(struct inode *inode, struct file *file)
 
 static const struct file_operations dvb_demux_fops = {
 	.owner = THIS_MODULE,
-	.read = dvb_demux_read,
+	.read_iter = dvb_demux_read_iter,
 	.unlocked_ioctl = dvb_demux_ioctl,
 	.compat_ioctl = dvb_demux_ioctl,
 	.open = dvb_demux_open,
@@ -1385,8 +1388,8 @@ static int dvb_dvr_mmap(struct file *file, struct vm_area_struct *vma)
 
 static const struct file_operations dvb_dvr_fops = {
 	.owner = THIS_MODULE,
-	.read = dvb_dvr_read,
-	.write = dvb_dvr_write,
+	.read_iter = dvb_dvr_read_iter,
+	.write_iter = dvb_dvr_write_iter,
 	.unlocked_ioctl = dvb_dvr_ioctl,
 	.open = dvb_dvr_open,
 	.release = dvb_dvr_release,
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index baf64540dc00..ccb9bff21304 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -1436,19 +1436,16 @@ static long dvb_ca_en50221_io_ioctl(struct file *file,
 /**
  * dvb_ca_en50221_io_write - Implementation of write() syscall.
  *
- * @file: File structure.
- * @buf: Source buffer.
- * @count: Size of source buffer.
- * @ppos: Position in file (ignored).
+ * @iocb: metadata for IO
+ * @from: buffer to read from
  *
  * return: Number of bytes read, or <0 on error.
  */
-static ssize_t dvb_ca_en50221_io_write(struct file *file,
-				       const char __user *buf, size_t count,
-				       loff_t *ppos)
+static ssize_t dvb_ca_en50221_io_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dvb_device *dvbdev = file->private_data;
+	struct dvb_device *dvbdev = iocb->ki_filp->private_data;
 	struct dvb_ca_private *ca = dvbdev->priv;
+	size_t count = iov_iter_count(from);
 	struct dvb_ca_slot *sl;
 	u8 slot, connection_id;
 	int status;
@@ -1468,11 +1465,10 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 		return -EINVAL;
 
 	/* extract slot & connection id */
-	if (copy_from_user(&slot, buf, 1))
+	if (!copy_from_iter_full(&slot, 1, from))
 		return -EFAULT;
-	if (copy_from_user(&connection_id, buf + 1, 1))
+	if (!copy_from_iter_full(&connection_id, 1, from))
 		return -EFAULT;
-	buf += 2;
 	count -= 2;
 
 	if (slot >= ca->slot_count)
@@ -1496,7 +1492,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
 
 		fragbuf[0] = connection_id;
 		fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
-		status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen);
+		status = !copy_from_iter_full(fragbuf + 2, fraglen, from);
 		if (status) {
 			status = -EFAULT;
 			goto exit;
@@ -1699,6 +1695,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
 exit:
 	return status;
 }
+FOPS_READ_ITER_HELPER(dvb_ca_en50221_io_read);
 
 /**
  * dvb_ca_en50221_io_open - Implementation of file open syscall.
@@ -1834,8 +1831,8 @@ static __poll_t dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations dvb_ca_fops = {
 	.owner = THIS_MODULE,
-	.read = dvb_ca_en50221_io_read,
-	.write = dvb_ca_en50221_io_write,
+	.read_iter = dvb_ca_en50221_io_read_iter,
+	.write_iter = dvb_ca_en50221_io_write,
 	.unlocked_ioctl = dvb_ca_en50221_io_ioctl,
 	.open = dvb_ca_en50221_io_open,
 	.release = dvb_ca_en50221_io_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 415/437] media/common: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (413 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 414/437] media/dvb-core: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 416/437] media/platform: amphion: " Jens Axboe
                   ` (22 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/common/siano/smsdvb-debugfs.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c
index 73990e469df9..e81b17b599ec 100644
--- a/drivers/media/common/siano/smsdvb-debugfs.c
+++ b/drivers/media/common/siano/smsdvb-debugfs.c
@@ -280,15 +280,14 @@ static __poll_t smsdvb_stats_poll(struct file *file, poll_table *wait)
 	return rc > 0 ? EPOLLIN | EPOLLRDNORM : 0;
 }
 
-static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
-				      size_t nbytes, loff_t *ppos)
+static ssize_t smsdvb_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int rc = 0, len;
-	struct smsdvb_debugfs *debug_data = file->private_data;
+	struct smsdvb_debugfs *debug_data = iocb->ki_filp->private_data;
 
 	kref_get(&debug_data->refcount);
 
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		rc = smsdvb_stats_wait_read(debug_data);
 		if (!rc) {
 			rc = -EWOULDBLOCK;
@@ -306,14 +305,14 @@ static ssize_t smsdvb_stats_read(struct file *file, char __user *user_buf,
 		goto ret;
 	}
 
-	len = debug_data->stats_count - *ppos;
+	len = debug_data->stats_count - iocb->ki_pos;
 	if (len >= 0)
-		rc = simple_read_from_buffer(user_buf, nbytes, ppos,
-					     debug_data->stats_data, len);
+		rc = simple_copy_to_iter(debug_data->stats_data, &iocb->ki_pos,
+					 len, to);
 	else
 		rc = 0;
 
-	if (*ppos >= debug_data->stats_count) {
+	if (iocb->ki_pos >= debug_data->stats_count) {
 		spin_lock(&debug_data->lock);
 		debug_data->stats_was_read = true;
 		spin_unlock(&debug_data->lock);
@@ -341,7 +340,7 @@ static int smsdvb_stats_release(struct inode *inode, struct file *file)
 static const struct file_operations debugfs_stats_ops = {
 	.open = smsdvb_stats_open,
 	.poll = smsdvb_stats_poll,
-	.read = smsdvb_stats_read,
+	.read_iter = smsdvb_stats_read,
 	.release = smsdvb_stats_release,
 	.llseek = generic_file_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 416/437] media/platform: amphion: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (414 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 415/437] media/common: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 417/437] media/platform: mediatek: " Jens Axboe
                   ` (21 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/platform/amphion/vpu_dbg.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
index 940e5bda5fa3..71c752081ab3 100644
--- a/drivers/media/platform/amphion/vpu_dbg.c
+++ b/drivers/media/platform/amphion/vpu_dbg.c
@@ -353,21 +353,19 @@ static int vpu_dbg_inst_open(struct inode *inode, struct file *filp)
 	return single_open(filp, vpu_dbg_instance, inode->i_private);
 }
 
-static ssize_t vpu_dbg_inst_write(struct file *file,
-				  const char __user *user_buf, size_t size, loff_t *ppos)
+static ssize_t vpu_dbg_inst_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct vpu_inst *inst = s->private;
 
 	vpu_session_debug(inst);
 
-	return size;
+	return iov_iter_count(from);
 }
 
-static ssize_t vpu_dbg_core_write(struct file *file,
-				  const char __user *user_buf, size_t size, loff_t *ppos)
+static ssize_t vpu_dbg_core_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
 	struct vpu_core *core = s->private;
 
 	pm_runtime_resume_and_get(core->dev);
@@ -382,7 +380,7 @@ static ssize_t vpu_dbg_core_write(struct file *file,
 	mutex_unlock(&core->lock);
 	pm_runtime_put_sync(core->dev);
 
-	return size;
+	return iov_iter_count(from);
 }
 
 static int vpu_dbg_core_open(struct inode *inode, struct file *filp)
@@ -399,23 +397,23 @@ static const struct file_operations vpu_dbg_inst_fops = {
 	.owner = THIS_MODULE,
 	.open = vpu_dbg_inst_open,
 	.release = single_release,
-	.read = seq_read,
-	.write = vpu_dbg_inst_write,
+	.read_iter = seq_read_iter,
+	.write_iter = vpu_dbg_inst_write,
 };
 
 static const struct file_operations vpu_dbg_core_fops = {
 	.owner = THIS_MODULE,
 	.open = vpu_dbg_core_open,
 	.release = single_release,
-	.read = seq_read,
-	.write = vpu_dbg_core_write,
+	.read_iter = seq_read_iter,
+	.write_iter = vpu_dbg_core_write,
 };
 
 static const struct file_operations vpu_dbg_fwlog_fops = {
 	.owner = THIS_MODULE,
 	.open = vpu_dbg_fwlog_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 };
 
 int vpu_inst_create_dbgfs_file(struct vpu_inst *inst)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 417/437] media/platform: mediatek: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (415 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 416/437] media/platform: amphion: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 418/437] media: cec: " Jens Axboe
                   ` (20 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c
index 724ae7c2ab3b..ab285cf4bfef 100644
--- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c
+++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c
@@ -648,14 +648,13 @@ static void vpu_init_ipi_handler(void *data, unsigned int len, void *priv)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t vpu_debug_read(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t vpu_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[256];
 	unsigned int len;
 	unsigned int running, pc, vpu_to_host, host_to_vpu, wdt, idle, ra, sp;
 	int ret;
-	struct device *dev = file->private_data;
+	struct device *dev = iocb->ki_filp->private_data;
 	struct mtk_vpu *vpu = dev_get_drvdata(dev);
 
 	ret = vpu_clock_enable(vpu);
@@ -692,12 +691,12 @@ static ssize_t vpu_debug_read(struct file *file, char __user *user_buf,
 		len = snprintf(buf, sizeof(buf), "VPU not running\n");
 	}
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations vpu_debug_fops = {
 	.open = simple_open,
-	.read = vpu_debug_read,
+	.read_iter = vpu_debug_read,
 };
 #endif /* CONFIG_DEBUG_FS */
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 418/437] media: cec: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (416 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 417/437] media/platform: mediatek: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 419/437] media: media-devnode: " Jens Axboe
                   ` (19 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/cec/core/cec-core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
index 5a54db839e5d..307763fa251d 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -200,16 +200,16 @@ static void cec_devnode_unregister(struct cec_adapter *adap)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t cec_error_inj_write(struct file *file,
-	const char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t cec_error_inj_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *sf = file->private_data;
+	struct seq_file *sf = iocb->ki_filp->private_data;
 	struct cec_adapter *adap = sf->private;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	char *line;
 	char *p;
 
-	buf = memdup_user_nul(ubuf, min_t(size_t, PAGE_SIZE, count));
+	buf = iterdup_nul(from, min_t(size_t, PAGE_SIZE, count));
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 	p = buf;
@@ -241,8 +241,8 @@ static int cec_error_inj_open(struct inode *inode, struct file *file)
 
 static const struct file_operations cec_error_inj_fops = {
 	.open = cec_error_inj_open,
-	.write = cec_error_inj_write,
-	.read = seq_read,
+	.write_iter = cec_error_inj_write,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 419/437] media: media-devnode: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (417 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 418/437] media: cec: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 420/437] media: bt8xx: " Jens Axboe
                   ` (18 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/mc/mc-devnode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/mc/mc-devnode.c b/drivers/media/mc/mc-devnode.c
index 7f67825c8757..43e3297e0447 100644
--- a/drivers/media/mc/mc-devnode.c
+++ b/drivers/media/mc/mc-devnode.c
@@ -78,6 +78,7 @@ static ssize_t media_read(struct file *filp, char __user *buf,
 		return -EIO;
 	return devnode->fops->read(filp, buf, sz, off);
 }
+FOPS_READ_ITER_HELPER(media_read);
 
 static ssize_t media_write(struct file *filp, const char __user *buf,
 		size_t sz, loff_t *off)
@@ -90,6 +91,7 @@ static ssize_t media_write(struct file *filp, const char __user *buf,
 		return -EIO;
 	return devnode->fops->write(filp, buf, sz, off);
 }
+FOPS_WRITE_ITER_HELPER(media_write);
 
 static __poll_t media_poll(struct file *filp,
 			       struct poll_table_struct *poll)
@@ -195,8 +197,8 @@ static int media_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations media_devnode_fops = {
 	.owner = THIS_MODULE,
-	.read = media_read,
-	.write = media_write,
+	.read_iter = media_read_iter,
+	.write_iter = media_write_iter,
 	.open = media_open,
 	.unlocked_ioctl = media_ioctl,
 #ifdef CONFIG_COMPAT
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 420/437] media: bt8xx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (418 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 419/437] media: media-devnode: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 421/437] media: dbbridge: " Jens Axboe
                   ` (17 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/pci/bt8xx/dst_ca.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index a9cc6e7a57f9..3e0cbd71cd0f 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -622,14 +622,14 @@ static int dst_ca_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
+static ssize_t dst_ca_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	dprintk(verbose, DST_CA_DEBUG, 1, " Device read.");
 
 	return 0;
 }
 
-static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
+static ssize_t dst_ca_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	dprintk(verbose, DST_CA_DEBUG, 1, " Device write.");
 
@@ -641,8 +641,8 @@ static const struct file_operations dst_ca_fops = {
 	.unlocked_ioctl = dst_ca_ioctl,
 	.open = dst_ca_open,
 	.release = dst_ca_release,
-	.read = dst_ca_read,
-	.write = dst_ca_write,
+	.read_iter = dst_ca_read,
+	.write_iter = dst_ca_write,
 	.llseek = noop_llseek,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 421/437] media: dbbridge: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (419 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 420/437] media: bt8xx: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 422/437] media: ngene: " Jens Axboe
                   ` (16 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 40e6c873c36d..118f22cced88 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -731,6 +731,7 @@ static ssize_t ts_write(struct file *file, const __user char *buf,
 	}
 	return (left == count) ? -EAGAIN : (count - left);
 }
+FOPS_WRITE_ITER_HELPER(ts_write);
 
 static ssize_t ts_read(struct file *file, __user char *buf,
 		       size_t count, loff_t *ppos)
@@ -761,6 +762,7 @@ static ssize_t ts_read(struct file *file, __user char *buf,
 	}
 	return (count && (left == count)) ? -EAGAIN : (count - left);
 }
+FOPS_READ_ITER_HELPER(ts_read);
 
 static __poll_t ts_poll(struct file *file, poll_table *wait)
 {
@@ -838,8 +840,8 @@ static int ts_open(struct inode *inode, struct file *file)
 
 static const struct file_operations ci_fops = {
 	.owner   = THIS_MODULE,
-	.read    = ts_read,
-	.write   = ts_write,
+	.read_iter = ts_read_iter,
+	.write_iter = ts_write_iter,
 	.open    = ts_open,
 	.release = ts_release,
 	.poll    = ts_poll,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 422/437] media: ngene: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (420 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 421/437] media: dbbridge: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 423/437] media: radio-si476x: " Jens Axboe
                   ` (15 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/pci/ngene/ngene-dvb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-dvb.c b/drivers/media/pci/ngene/ngene-dvb.c
index fda24ba3dc3c..dacf56140347 100644
--- a/drivers/media/pci/ngene/ngene-dvb.c
+++ b/drivers/media/pci/ngene/ngene-dvb.c
@@ -49,6 +49,7 @@ static ssize_t ts_write(struct file *file, const char __user *buf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(ts_write);
 
 static ssize_t ts_read(struct file *file, char __user *buf,
 		       size_t count, loff_t *ppos)
@@ -73,6 +74,7 @@ static ssize_t ts_read(struct file *file, char __user *buf,
 	}
 	return count;
 }
+FOPS_READ_ITER_HELPER(ts_read);
 
 static __poll_t ts_poll(struct file *file, poll_table *wait)
 {
@@ -96,8 +98,8 @@ static __poll_t ts_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations ci_fops = {
 	.owner   = THIS_MODULE,
-	.read    = ts_read,
-	.write   = ts_write,
+	.read_iter = ts_read_iter,
+	.write_iter = ts_write_iter,
 	.open    = dvb_generic_open,
 	.release = dvb_generic_release,
 	.poll    = ts_poll,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 423/437] media: radio-si476x: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (421 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 422/437] media: ngene: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 424/437] media: usb: uvc: " Jens Axboe
                   ` (14 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/radio/radio-si476x.c | 60 +++++++++++++-----------------
 1 file changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
index b2c5809a8bc7..fcc330d6dc75 100644
--- a/drivers/media/radio/radio-si476x.c
+++ b/drivers/media/radio/radio-si476x.c
@@ -1178,12 +1178,11 @@ static const struct video_device si476x_viddev_template = {
 
 
 
-static ssize_t si476x_radio_read_acf_blob(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t si476x_radio_read_acf_blob(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	int err;
-	struct si476x_radio *radio = file->private_data;
+	struct si476x_radio *radio = iocb->ki_filp->private_data;
 	struct si476x_acf_status_report report;
 
 	si476x_core_lock(radio->core);
@@ -1196,22 +1195,20 @@ static ssize_t si476x_radio_read_acf_blob(struct file *file,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(user_buf, count, ppos, &report,
-				       sizeof(report));
+	return simple_copy_to_iter(&report, &iocb->ki_pos, sizeof(report), to);
 }
 
 static const struct file_operations radio_acf_fops = {
 	.open	= simple_open,
 	.llseek = default_llseek,
-	.read	= si476x_radio_read_acf_blob,
+	.read_iter = si476x_radio_read_acf_blob,
 };
 
-static ssize_t si476x_radio_read_rds_blckcnt_blob(struct file *file,
-						  char __user *user_buf,
-						  size_t count, loff_t *ppos)
+static ssize_t si476x_radio_read_rds_blckcnt_blob(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
 	int err;
-	struct si476x_radio *radio = file->private_data;
+	struct si476x_radio *radio = iocb->ki_filp->private_data;
 	struct si476x_rds_blockcount_report report;
 
 	si476x_core_lock(radio->core);
@@ -1225,22 +1222,20 @@ static ssize_t si476x_radio_read_rds_blckcnt_blob(struct file *file,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(user_buf, count, ppos, &report,
-				       sizeof(report));
+	return simple_copy_to_iter(&report, &iocb->ki_pos, sizeof(report), to);
 }
 
 static const struct file_operations radio_rds_blckcnt_fops = {
 	.open	= simple_open,
 	.llseek = default_llseek,
-	.read	= si476x_radio_read_rds_blckcnt_blob,
+	.read_iter = si476x_radio_read_rds_blckcnt_blob,
 };
 
-static ssize_t si476x_radio_read_agc_blob(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t si476x_radio_read_agc_blob(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	int err;
-	struct si476x_radio *radio = file->private_data;
+	struct si476x_radio *radio = iocb->ki_filp->private_data;
 	struct si476x_agc_status_report report;
 
 	si476x_core_lock(radio->core);
@@ -1253,22 +1248,20 @@ static ssize_t si476x_radio_read_agc_blob(struct file *file,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(user_buf, count, ppos, &report,
-				       sizeof(report));
+	return simple_copy_to_iter(&report, &iocb->ki_pos, sizeof(report), to);
 }
 
 static const struct file_operations radio_agc_fops = {
 	.open	= simple_open,
 	.llseek = default_llseek,
-	.read	= si476x_radio_read_agc_blob,
+	.read_iter = si476x_radio_read_agc_blob,
 };
 
-static ssize_t si476x_radio_read_rsq_blob(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t si476x_radio_read_rsq_blob(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	int err;
-	struct si476x_radio *radio = file->private_data;
+	struct si476x_radio *radio = iocb->ki_filp->private_data;
 	struct si476x_rsq_status_report report;
 	struct si476x_rsq_status_args args = {
 		.primary	= false,
@@ -1288,22 +1281,20 @@ static ssize_t si476x_radio_read_rsq_blob(struct file *file,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(user_buf, count, ppos, &report,
-				       sizeof(report));
+	return simple_copy_to_iter(&report, &iocb->ki_pos, sizeof(report), to);
 }
 
 static const struct file_operations radio_rsq_fops = {
 	.open	= simple_open,
 	.llseek = default_llseek,
-	.read	= si476x_radio_read_rsq_blob,
+	.read_iter = si476x_radio_read_rsq_blob,
 };
 
-static ssize_t si476x_radio_read_rsq_primary_blob(struct file *file,
-						  char __user *user_buf,
-						  size_t count, loff_t *ppos)
+static ssize_t si476x_radio_read_rsq_primary_blob(struct kiocb *iocb,
+						  struct iov_iter *to)
 {
 	int err;
-	struct si476x_radio *radio = file->private_data;
+	struct si476x_radio *radio = iocb->ki_filp->private_data;
 	struct si476x_rsq_status_report report;
 	struct si476x_rsq_status_args args = {
 		.primary	= true,
@@ -1323,14 +1314,13 @@ static ssize_t si476x_radio_read_rsq_primary_blob(struct file *file,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(user_buf, count, ppos, &report,
-				       sizeof(report));
+	return simple_copy_to_iter(&report, &iocb->ki_pos, sizeof(report), to);
 }
 
 static const struct file_operations radio_rsq_primary_fops = {
 	.open	= simple_open,
 	.llseek = default_llseek,
-	.read	= si476x_radio_read_rsq_primary_blob,
+	.read_iter = si476x_radio_read_rsq_primary_blob,
 };
 
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 424/437] media: usb: uvc: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (422 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 423/437] media: radio-si476x: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 425/437] media: v4l2-dev: " Jens Axboe
                   ` (13 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/usb/uvc/uvc_debugfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_debugfs.c b/drivers/media/usb/uvc/uvc_debugfs.c
index 1a1258d4ffca..2c4935a0257e 100644
--- a/drivers/media/usb/uvc/uvc_debugfs.c
+++ b/drivers/media/usb/uvc/uvc_debugfs.c
@@ -39,13 +39,11 @@ static int uvc_debugfs_stats_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t uvc_debugfs_stats_read(struct file *file, char __user *user_buf,
-				      size_t nbytes, loff_t *ppos)
+static ssize_t uvc_debugfs_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct uvc_debugfs_buffer *buf = file->private_data;
+	struct uvc_debugfs_buffer *buf = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(user_buf, nbytes, ppos, buf->data,
-				       buf->count);
+	return simple_copy_to_iter(buf->data, &iocb->ki_pos, buf->count, to);
 }
 
 static int uvc_debugfs_stats_release(struct inode *inode, struct file *file)
@@ -60,7 +58,7 @@ static const struct file_operations uvc_debugfs_stats_fops = {
 	.owner = THIS_MODULE,
 	.open = uvc_debugfs_stats_open,
 	.llseek = no_llseek,
-	.read = uvc_debugfs_stats_read,
+	.read_iter = uvc_debugfs_stats_read,
 	.release = uvc_debugfs_stats_release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 425/437] media: v4l2-dev: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (423 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 424/437] media: usb: uvc: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 426/437] firmware: xilinx: " Jens Axboe
                   ` (12 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/media/v4l2-core/v4l2-dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d13954bd31fd..0ebc049fe333 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -318,6 +318,7 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
 			video_device_node_name(vdev), sz, ret);
 	return ret;
 }
+FOPS_READ_ITER_HELPER(v4l2_read);
 
 static ssize_t v4l2_write(struct file *filp, const char __user *buf,
 		size_t sz, loff_t *off)
@@ -335,6 +336,7 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
 			video_device_node_name(vdev), sz, ret);
 	return ret;
 }
+FOPS_WRITE_ITER_HELPER(v4l2_write);
 
 static __poll_t v4l2_poll(struct file *filp, struct poll_table_struct *poll)
 {
@@ -472,8 +474,8 @@ static int v4l2_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations v4l2_fops = {
 	.owner = THIS_MODULE,
-	.read = v4l2_read,
-	.write = v4l2_write,
+	.read_iter = v4l2_read_iter,
+	.write_iter = v4l2_write_iter,
 	.open = v4l2_open,
 	.get_unmapped_area = v4l2_get_unmapped_area,
 	.mmap = v4l2_mmap,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 426/437] firmware: xilinx: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (424 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 425/437] media: v4l2-dev: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 427/437] hwtracing: coresight: " Jens Axboe
                   ` (11 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/firmware/xilinx/zynqmp-debug.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp-debug.c b/drivers/firmware/xilinx/zynqmp-debug.c
index 8528850af889..8d64bffd1890 100644
--- a/drivers/firmware/xilinx/zynqmp-debug.c
+++ b/drivers/firmware/xilinx/zynqmp-debug.c
@@ -143,9 +143,8 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
  * Return: Number of bytes copied if PM-API request succeeds,
  *	   the corresponding error code otherwise
  */
-static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
-					   const char __user *ptr, size_t len,
-					   loff_t *off)
+static ssize_t zynqmp_pm_debugfs_api_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
 	char *kern_buff, *tmp_buff;
 	char *pm_api_req;
@@ -153,16 +152,17 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
 	u64 pm_api_arg[4] = {0, 0, 0, 0};
 	/* Return values from PM APIs calls */
 	u32 pm_api_ret[4] = {0, 0, 0, 0};
+	size_t len = iov_iter_count(from);
 
 	int ret;
 	int i = 0;
 
 	strcpy(debugfs_buf, "");
 
-	if (*off != 0 || len <= 1 || len > PAGE_SIZE - 1)
+	if (iocb->ki_pos != 0 || len <= 1 || len > PAGE_SIZE - 1)
 		return -EINVAL;
 
-	kern_buff = memdup_user_nul(ptr, len);
+	kern_buff = iterdup_user(from, len);
 	if (IS_ERR(kern_buff))
 		return PTR_ERR(kern_buff);
 	tmp_buff = kern_buff;
@@ -201,18 +201,18 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
  * Return: Length of the version string on success
  *	   else error code
  */
-static ssize_t zynqmp_pm_debugfs_api_read(struct file *file, char __user *ptr,
-					  size_t len, loff_t *off)
+static ssize_t zynqmp_pm_debugfs_api_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	return simple_read_from_buffer(ptr, len, off, debugfs_buf,
-				       strlen(debugfs_buf));
+	return simple_copy_to_iter(debugfs_buf, &iocb->ki_pos,
+				       strlen(debugfs_buf), to);
 }
 
 /* Setup debugfs fops */
 static const struct file_operations fops_zynqmp_pm_dbgfs = {
 	.owner = THIS_MODULE,
-	.write = zynqmp_pm_debugfs_api_write,
-	.read = zynqmp_pm_debugfs_api_read,
+	.write_iter = zynqmp_pm_debugfs_api_write,
+	.read_iter = zynqmp_pm_debugfs_api_read,
 };
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 427/437] hwtracing: coresight: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (425 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 426/437] firmware: xilinx: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 428/437] sbus: oradax: " Jens Axboe
                   ` (10 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 .../hwtracing/coresight/coresight-cpu-debug.c  | 15 +++++++--------
 drivers/hwtracing/coresight/coresight-etb10.c  | 18 +++++++++---------
 .../hwtracing/coresight/coresight-tmc-core.c   | 14 +++++++-------
 drivers/hwtracing/coresight/ultrasoc-smb.c     | 12 ++++++------
 4 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cpu-debug.c b/drivers/hwtracing/coresight/coresight-cpu-debug.c
index 1874df7c6a73..5ee3dc600066 100644
--- a/drivers/hwtracing/coresight/coresight-cpu-debug.c
+++ b/drivers/hwtracing/coresight/coresight-cpu-debug.c
@@ -471,13 +471,13 @@ static int debug_disable_func(void)
 	return err;
 }
 
-static ssize_t debug_func_knob_write(struct file *f,
-		const char __user *buf, size_t count, loff_t *ppos)
+static ssize_t debug_func_knob_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	u8 val;
 	int ret;
 
-	ret = kstrtou8_from_user(buf, count, 2, &val);
+	ret = kstrtou8_from_iter(from, count, 2, &val);
 	if (ret)
 		return ret;
 
@@ -505,8 +505,7 @@ static ssize_t debug_func_knob_write(struct file *f,
 	return ret;
 }
 
-static ssize_t debug_func_knob_read(struct file *f,
-		char __user *ubuf, size_t count, loff_t *ppos)
+static ssize_t debug_func_knob_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	char buf[3];
@@ -515,14 +514,14 @@ static ssize_t debug_func_knob_read(struct file *f,
 	snprintf(buf, sizeof(buf), "%d\n", debug_enable);
 	mutex_unlock(&debug_lock);
 
-	ret = simple_read_from_buffer(ubuf, count, ppos, buf, sizeof(buf));
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), to);
 	return ret;
 }
 
 static const struct file_operations debug_func_knob_fops = {
 	.open	= simple_open,
-	.read	= debug_func_knob_read,
-	.write	= debug_func_knob_write,
+	.read_iter	= debug_func_knob_read,
+	.write_iter	= debug_func_knob_write,
 };
 
 static int debug_func_init(void)
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
index 3aab182b562f..14735de16316 100644
--- a/drivers/hwtracing/coresight/coresight-etb10.c
+++ b/drivers/hwtracing/coresight/coresight-etb10.c
@@ -610,30 +610,30 @@ static int etb_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t etb_read(struct file *file, char __user *data,
-				size_t len, loff_t *ppos)
+static ssize_t etb_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	u32 depth;
-	struct etb_drvdata *drvdata = container_of(file->private_data,
+	struct etb_drvdata *drvdata = container_of(iocb->ki_filp->private_data,
 						   struct etb_drvdata, miscdev);
 	struct device *dev = &drvdata->csdev->dev;
 
 	etb_dump(drvdata);
 
 	depth = drvdata->buffer_depth;
-	if (*ppos + len > depth * 4)
-		len = depth * 4 - *ppos;
+	if (iocb->ki_pos + len > depth * 4)
+		len = depth * 4 - iocb->ki_pos;
 
-	if (copy_to_user(data, drvdata->buf + *ppos, len)) {
+	if (!copy_to_iter_full(drvdata->buf + iocb->ki_pos, len, to)) {
 		dev_dbg(dev,
 			"%s: copy_to_user failed\n", __func__);
 		return -EFAULT;
 	}
 
-	*ppos += len;
+	iocb->ki_pos += len;
 
 	dev_dbg(dev, "%s: %zu bytes copied, %d bytes left\n",
-		__func__, len, (int)(depth * 4 - *ppos));
+		__func__, len, (int)(depth * 4 - iocb->ki_pos));
 	return len;
 }
 
@@ -650,7 +650,7 @@ static int etb_release(struct inode *inode, struct file *file)
 static const struct file_operations etb_fops = {
 	.owner		= THIS_MODULE,
 	.open		= etb_open,
-	.read		= etb_read,
+	.read_iter	= etb_read,
 	.release	= etb_release,
 	.llseek		= no_llseek,
 };
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index 72005b0c633e..337599655242 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -176,24 +176,24 @@ static inline ssize_t tmc_get_sysfs_trace(struct tmc_drvdata *drvdata,
 	return -EINVAL;
 }
 
-static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
-			loff_t *ppos)
+static ssize_t tmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	char *bufp;
 	ssize_t actual;
-	struct tmc_drvdata *drvdata = container_of(file->private_data,
+	struct tmc_drvdata *drvdata = container_of(iocb->ki_filp->private_data,
 						   struct tmc_drvdata, miscdev);
-	actual = tmc_get_sysfs_trace(drvdata, *ppos, len, &bufp);
+	actual = tmc_get_sysfs_trace(drvdata, iocb->ki_pos, len, &bufp);
 	if (actual <= 0)
 		return 0;
 
-	if (copy_to_user(data, bufp, actual)) {
+	if (!copy_to_iter_full(bufp, actual, to)) {
 		dev_dbg(&drvdata->csdev->dev,
 			"%s: copy_to_user failed\n", __func__);
 		return -EFAULT;
 	}
 
-	*ppos += actual;
+	iocb->ki_pos += actual;
 	dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual);
 
 	return actual;
@@ -216,7 +216,7 @@ static int tmc_release(struct inode *inode, struct file *file)
 static const struct file_operations tmc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= tmc_open,
-	.read		= tmc_read,
+	.read_iter	= tmc_read,
 	.release	= tmc_release,
 	.llseek		= no_llseek,
 };
diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing/coresight/ultrasoc-smb.c
index f9ebf20c91e6..27e883e69ce6 100644
--- a/drivers/hwtracing/coresight/ultrasoc-smb.c
+++ b/drivers/hwtracing/coresight/ultrasoc-smb.c
@@ -112,13 +112,13 @@ static int smb_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t smb_read(struct file *file, char __user *data, size_t len,
-			loff_t *ppos)
+static ssize_t smb_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct smb_drv_data *drvdata = container_of(file->private_data,
+	struct smb_drv_data *drvdata = container_of(iocb->ki_filp->private_data,
 					struct smb_drv_data, miscdev);
 	struct smb_data_buffer *sdb = &drvdata->sdb;
 	struct device *dev = &drvdata->csdev->dev;
+	size_t len = iov_iter_count(to);
 	ssize_t to_copy = 0;
 
 	if (!len)
@@ -133,12 +133,12 @@ static ssize_t smb_read(struct file *file, char __user *data, size_t len,
 	if (sdb->buf_rdptr + to_copy > sdb->buf_size)
 		to_copy = sdb->buf_size - sdb->buf_rdptr;
 
-	if (copy_to_user(data, sdb->buf_base + sdb->buf_rdptr, to_copy)) {
+	if (!copy_to_iter_full(sdb->buf_base + sdb->buf_rdptr, to_copy, to)) {
 		dev_dbg(dev, "Failed to copy data to user\n");
 		return -EFAULT;
 	}
 
-	*ppos += to_copy;
+	iocb->ki_pos += to_copy;
 	smb_update_read_ptr(drvdata, to_copy);
 	if (!sdb->data_size)
 		smb_reset_buffer(drvdata);
@@ -161,7 +161,7 @@ static int smb_release(struct inode *inode, struct file *file)
 static const struct file_operations smb_fops = {
 	.owner		= THIS_MODULE,
 	.open		= smb_open,
-	.read		= smb_read,
+	.read_iter	= smb_read,
 	.release	= smb_release,
 	.llseek		= no_llseek,
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 428/437] sbus: oradax: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (426 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 427/437] hwtracing: coresight: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 429/437] sbus: envctrl: " Jens Axboe
                   ` (9 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/sbus/char/oradax.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c
index a536dd6f4f7c..2e99e25b4b50 100644
--- a/drivers/sbus/char/oradax.c
+++ b/drivers/sbus/char/oradax.c
@@ -204,24 +204,21 @@ struct dax_ctx {
 
 /* driver public entry points */
 static int dax_open(struct inode *inode, struct file *file);
-static ssize_t dax_read(struct file *filp, char __user *buf,
-			size_t count, loff_t *ppos);
-static ssize_t dax_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *ppos);
+static ssize_t dax_read(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t dax_write(struct kiocb *iocb, struct iov_iter *from);
 static int dax_devmap(struct file *f, struct vm_area_struct *vma);
 static int dax_close(struct inode *i, struct file *f);
 
 static const struct file_operations dax_fops = {
 	.owner	=	THIS_MODULE,
 	.open	=	dax_open,
-	.read	=	dax_read,
-	.write	=	dax_write,
+	.read_iter	=	dax_read,
+	.write_iter	=	dax_write,
 	.mmap	=	dax_devmap,
 	.release =	dax_close,
 };
 
-static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
-			size_t count, loff_t *ppos);
+static int dax_ccb_exec(struct dax_ctx *ctx, loff_t *ppos, struct iov_iter *from);
 static int dax_ccb_info(u64 ca, struct ccb_info_result *info);
 static int dax_ccb_kill(u64 ca, u16 *kill_res);
 
@@ -541,10 +538,10 @@ static int dax_close(struct inode *ino, struct file *f)
 	return 0;
 }
 
-static ssize_t dax_read(struct file *f, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t dax_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dax_ctx *ctx = f->private_data;
+	struct dax_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (ctx->client != current)
 		return -EUSERS;
@@ -553,15 +550,15 @@ static ssize_t dax_read(struct file *f, char __user *buf,
 
 	if (count != sizeof(union ccb_result))
 		return -EINVAL;
-	if (copy_to_user(buf, &ctx->result, sizeof(union ccb_result)))
+	if (!copy_to_iter_full(&ctx->result, sizeof(union ccb_result), to))
 		return -EFAULT;
 	return count;
 }
 
-static ssize_t dax_write(struct file *f, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t dax_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dax_ctx *ctx = f->private_data;
+	struct dax_ctx *ctx = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct dax_command hdr;
 	unsigned long ca;
 	int i, idx, ret;
@@ -573,7 +570,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,
 		return -EINVAL;
 
 	if (count % sizeof(struct dax_ccb) == 0)
-		return dax_ccb_exec(ctx, buf, count, ppos); /* CCB EXEC */
+		return dax_ccb_exec(ctx, &iocb->ki_pos, from); /* CCB EXEC */
 
 	if (count != sizeof(struct dax_command))
 		return -EINVAL;
@@ -582,7 +579,7 @@ static ssize_t dax_write(struct file *f, const char __user *buf,
 	if (ctx->owner != current)
 		return -EUSERS;
 
-	if (copy_from_user(&hdr, buf, sizeof(hdr)))
+	if (!copy_from_iter_full(&hdr, sizeof(hdr), from))
 		return -EFAULT;
 
 	ca = ctx->ca_buf_ra + hdr.ca_offset;
@@ -846,9 +843,9 @@ static int dax_preprocess_usr_ccbs(struct dax_ctx *ctx, int idx, int nelem)
 	return DAX_SUBMIT_OK;
 }
 
-static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
-			size_t count, loff_t *ppos)
+static int dax_ccb_exec(struct dax_ctx *ctx, loff_t *ppos, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	unsigned long accepted_len, hv_rv;
 	int i, idx, nccbs, naccepted;
 
@@ -873,7 +870,7 @@ static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
 	 * Copy CCBs into kernel buffer to prevent modification by the
 	 * user in between validation and submission.
 	 */
-	if (copy_from_user(ctx->ccb_buf, buf, count)) {
+	if (!copy_from_iter_full(ctx->ccb_buf, count, from)) {
 		dax_dbg("copyin of user CCB buffer failed");
 		ctx->result.exec.status = DAX_SUBMIT_ERR_CCB_ARR_MMU_MISS;
 		return 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 429/437] sbus: envctrl: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (427 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 428/437] sbus: oradax: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 430/437] sbus: flash: " Jens Axboe
                   ` (8 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/sbus/char/envctrl.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 491cc6c0b3f9..ceebe708647d 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -533,8 +533,7 @@ static unsigned char envctrl_i2c_voltage_status(struct i2c_child_t *pchild,
 /* Function Description: Read a byte from /dev/envctrl. Mapped to user read().
  * Return: Number of read bytes. 0 for error.
  */
-static ssize_t
-envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t envctrl_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct i2c_child_t *pchild;
 	unsigned char data[10];
@@ -545,14 +544,14 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	 * Get the data and put back to the user buffer.
 	 */
 
-	switch ((int)(long)file->private_data) {
+	switch ((int)(long)iocb->ki_filp->private_data) {
 	case ENVCTRL_RD_WARNING_TEMPERATURE:
 		if (warning_temperature == 0)
 			return 0;
 
 		data[0] = (unsigned char)(warning_temperature);
 		ret = 1;
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -562,7 +561,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 
 		data[0] = (unsigned char)(shutdown_temperature);
 		ret = 1;
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -570,7 +569,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		if (!(pchild = envctrl_get_i2c_child(ENVCTRL_MTHRBDTEMP_MON)))
 			return 0;
 		ret = envctrl_read_noncpu_info(pchild, ENVCTRL_MTHRBDTEMP_MON, data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -580,7 +579,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		ret = envctrl_read_cpu_info(read_cpu, pchild, ENVCTRL_CPUTEMP_MON, data);
 
 		/* Reset cpu to the default cpu0. */
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -590,7 +589,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		ret = envctrl_read_cpu_info(read_cpu, pchild, ENVCTRL_CPUVOLTAGE_MON, data);
 
 		/* Reset cpu to the default cpu0. */
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -598,7 +597,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		if (!(pchild = envctrl_get_i2c_child(ENVCTRL_SCSITEMP_MON)))
 			return 0;
 		ret = envctrl_read_noncpu_info(pchild, ENVCTRL_SCSITEMP_MON, data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -606,7 +605,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 		if (!(pchild = envctrl_get_i2c_child(ENVCTRL_ETHERTEMP_MON)))
 			return 0;
 		ret = envctrl_read_noncpu_info(pchild, ENVCTRL_ETHERTEMP_MON, data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -615,7 +614,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			return 0;
 		data[0] = envctrl_i2c_read_8574(pchild->addr);
 		ret = envctrl_i2c_fan_status(pchild,data[0], data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 	
@@ -624,7 +623,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 			return 0;
 		data[0] = envctrl_i2c_read_8574(pchild->addr);
 		ret = envctrl_i2c_globaladdr(pchild, data[0], data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -635,7 +634,7 @@ envctrl_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 				return 0;
 		data[0] = envctrl_i2c_read_8574(pchild->addr);
 		ret = envctrl_i2c_voltage_status(pchild, data[0], data);
-		if (copy_to_user(buf, data, ret))
+		if (!copy_to_iter_full(data, ret, to))
 			ret = -EFAULT;
 		break;
 
@@ -711,7 +710,7 @@ envctrl_release(struct inode *inode, struct file *file)
 
 static const struct file_operations envctrl_fops = {
 	.owner =		THIS_MODULE,
-	.read =			envctrl_read,
+	.read_iter =		envctrl_read,
 	.unlocked_ioctl =	envctrl_ioctl,
 	.compat_ioctl =		compat_ptr_ioctl,
 	.open =			envctrl_open,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 430/437] sbus: flash: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (428 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 429/437] sbus: envctrl: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 431/437] pci: hotplug: cpqphp: " Jens Axboe
                   ` (7 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/sbus/char/flash.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
index 05d37d31c3b8..4b21dc0cb3c4 100644
--- a/drivers/sbus/char/flash.c
+++ b/drivers/sbus/char/flash.c
@@ -98,11 +98,10 @@ flash_llseek(struct file *file, long long offset, int origin)
 	return file->f_pos;
 }
 
-static ssize_t
-flash_read(struct file * file, char __user * buf,
-	   size_t count, loff_t *ppos)
+static ssize_t flash_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t p = *ppos;
+	size_t count = iov_iter_count(to);
+	loff_t p = iocb->ki_pos;
 	int i;
 
 	if (count > flash.read_size - p)
@@ -110,12 +109,11 @@ flash_read(struct file * file, char __user * buf,
 
 	for (i = 0; i < count; i++) {
 		u8 data = upa_readb(flash.read_base + p + i);
-		if (put_user(data, buf))
+		if (put_iter(data, to))
 			return -EFAULT;
-		buf++;
 	}
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
@@ -148,7 +146,7 @@ static const struct file_operations flash_fops = {
 	 */
 	.owner =	THIS_MODULE,
 	.llseek =	flash_llseek,
-	.read =		flash_read,
+	.read_iter =	flash_read,
 	.mmap =		flash_mmap,
 	.open =		flash_open,
 	.release =	flash_release,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 431/437] pci: hotplug: cpqphp: convert to read/write iterators
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (429 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 430/437] sbus: flash: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 432/437] seq_file: switch to using ->read_iter() Jens Axboe
                   ` (6 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 drivers/pci/hotplug/cpqphp_sysfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index fed1360ee9b1..234e7ab66660 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -157,11 +157,10 @@ static loff_t lseek(struct file *file, loff_t off, int whence)
 	return fixed_size_llseek(file, off, whence, dbg->size);
 }
 
-static ssize_t read(struct file *file, char __user *buf,
-		    size_t nbytes, loff_t *ppos)
+static ssize_t read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ctrl_dbg *dbg = file->private_data;
-	return simple_read_from_buffer(buf, nbytes, ppos, dbg->data, dbg->size);
+	struct ctrl_dbg *dbg = iocb->ki_filp->private_data;
+	return simple_copy_from_iter(dbg->data, &iocb->ki_pos, dbg->size, to);
 }
 
 static int release(struct inode *inode, struct file *file)
@@ -177,7 +176,7 @@ static const struct file_operations debug_ops = {
 	.owner = THIS_MODULE,
 	.open = open,
 	.llseek = lseek,
-	.read = read,
+	.read_iter = read,
 	.release = release,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 432/437] seq_file: switch to using ->read_iter()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (430 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 431/437] pci: hotplug: cpqphp: " Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 433/437] fs/debugfs: remove (now) dead non-iterator debugfs_attr functions Jens Axboe
                   ` (5 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

There's a seq_read_iter() helper already, use it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/seq_file.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 234bcdb1fba4..a562c611ed3d 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -188,7 +188,7 @@ static int __name ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __name ## _fops = {			\
 	.owner		= THIS_MODULE,					\
 	.open		= __name ## _open,				\
-	.read		= seq_read,					\
+	.read_iter	= seq_read_iter,				\
 	.llseek		= seq_lseek,					\
 	.release	= seq_release,					\
 }
@@ -202,7 +202,7 @@ static int __name ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __name ## _fops = {			\
 	.owner		= THIS_MODULE,					\
 	.open		= __name ## _open,				\
-	.read		= seq_read,					\
+	.read_iter	= seq_read_iter,				\
 	.llseek		= seq_lseek,					\
 	.release	= single_release,				\
 }
@@ -216,8 +216,8 @@ static int __name ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __name ## _fops = {			\
 	.owner		= THIS_MODULE,					\
 	.open		= __name ## _open,				\
-	.read		= seq_read,					\
-	.write		= __name ## _write,				\
+	.read_iter	= seq_read_iter,				\
+	.write_iter	= __name ## _write_iter,			\
 	.llseek		= seq_lseek,					\
 	.release	= single_release,				\
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 433/437] fs/debugfs: remove (now) dead non-iterator debugfs_attr functions
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (431 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 432/437] seq_file: switch to using ->read_iter() Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 434/437] lib/string_helpers: kill parse_int_array_user() Jens Axboe
                   ` (4 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/debugfs/file.c       | 46 -----------------------------------------
 include/linux/debugfs.h |  6 ------
 2 files changed, 52 deletions(-)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 6463b4a274d4..9c8fe0834b2b 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -451,21 +451,6 @@ const struct file_operations debugfs_full_proxy_file_operations = {
 	.open = full_proxy_open,
 };
 
-ssize_t debugfs_attr_read(struct file *file, char __user *buf,
-			size_t len, loff_t *ppos)
-{
-	struct dentry *dentry = F_DENTRY(file);
-	ssize_t ret;
-
-	ret = debugfs_file_get(dentry);
-	if (unlikely(ret))
-		return ret;
-	ret = simple_attr_read(file, buf, len, ppos);
-	debugfs_file_put(dentry);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(debugfs_attr_read);
-
 ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct dentry *dentry = F_DENTRY(iocb->ki_filp);
@@ -480,37 +465,6 @@ ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to)
 }
 EXPORT_SYMBOL_GPL(debugfs_attr_read_iter);
 
-static ssize_t debugfs_attr_write_xsigned(struct file *file, const char __user *buf,
-			 size_t len, loff_t *ppos, bool is_signed)
-{
-	struct dentry *dentry = F_DENTRY(file);
-	ssize_t ret;
-
-	ret = debugfs_file_get(dentry);
-	if (unlikely(ret))
-		return ret;
-	if (is_signed)
-		ret = simple_attr_write_signed(file, buf, len, ppos);
-	else
-		ret = simple_attr_write(file, buf, len, ppos);
-	debugfs_file_put(dentry);
-	return ret;
-}
-
-ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
-			 size_t len, loff_t *ppos)
-{
-	return debugfs_attr_write_xsigned(file, buf, len, ppos, false);
-}
-EXPORT_SYMBOL_GPL(debugfs_attr_write);
-
-ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
-			 size_t len, loff_t *ppos)
-{
-	return debugfs_attr_write_xsigned(file, buf, len, ppos, true);
-}
-EXPORT_SYMBOL_GPL(debugfs_attr_write_signed);
-
 static ssize_t debugfs_attr_write_iter_xsigned(struct kiocb *iocb,
 					       struct iov_iter *from,
 					       bool is_signed)
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index c6d189059d3d..7d08c0900b4c 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -104,14 +104,8 @@ const struct file_operations *debugfs_real_fops(const struct file *filp);
 int debugfs_file_get(struct dentry *dentry);
 void debugfs_file_put(struct dentry *dentry);
 
-ssize_t debugfs_attr_read(struct file *file, char __user *buf,
-			size_t len, loff_t *ppos);
 ssize_t debugfs_attr_read_iter(struct kiocb *iocb, struct iov_iter *to);
-ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
-			size_t len, loff_t *ppos);
 ssize_t debugfs_attr_write_iter(struct kiocb *iocb, struct iov_iter *from);
-ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
-			size_t len, loff_t *ppos);
 ssize_t debugfs_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from);
 
 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 434/437] lib/string_helpers: kill parse_int_array_user()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (432 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 433/437] fs/debugfs: remove (now) dead non-iterator debugfs_attr functions Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 435/437] fs: kill off non-iter variants of simple_attr_{read,write}* Jens Axboe
                   ` (3 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

It's no longer used, get rid of it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/string_helpers.h |  1 -
 lib/string_helpers.c           | 61 ++++++++++------------------------
 2 files changed, 18 insertions(+), 44 deletions(-)

diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index f38157114fc0..5e913f1fad60 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -32,7 +32,6 @@ enum string_size_units {
 int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 		    char *buf, int len);
 
-int parse_int_array_user(const char __user *from, size_t count, int **array);
 int parse_int_array_iter(struct iov_iter *from, int **array);
 
 #define UNESCAPE_SPACE		BIT(0)
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index ced4f77dc5e8..8582f9adfa76 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -138,10 +138,27 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
 }
 EXPORT_SYMBOL(string_get_size);
 
-static int __parse_int_array(char *buf, int **array)
+/**
+ * parse_int_array_iter - Split string into a sequence of integers
+ * @from:	The iov_iter buffer to read from
+ * @array:	Returned pointer to sequence of integers
+ *
+ * On success @array is allocated and initialized with a sequence of
+ * integers extracted from the @from plus an additional element that
+ * begins the sequence and specifies the integers count.
+ *
+ * Caller takes responsibility for freeing @array when it is no longer
+ * needed.
+ */
+int parse_int_array_iter(struct iov_iter *from, int **array)
 {
 	int *ints, nints;
 	int ret = 0;
+	char *buf;
+
+	buf = iterdup_nul(from, iov_iter_count(from));
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
 
 	get_options(buf, 0, &nints);
 	if (!nints) {
@@ -161,49 +178,7 @@ static int __parse_int_array(char *buf, int **array)
 free_buf:
 	kfree(buf);
 	return ret;
-}
-
-/**
- * parse_int_array_user - Split string into a sequence of integers
- * @from:	The user space buffer to read from
- * @count:	The maximum number of bytes to read
- * @array:	Returned pointer to sequence of integers
- *
- * On success @array is allocated and initialized with a sequence of
- * integers extracted from the @from plus an additional element that
- * begins the sequence and specifies the integers count.
- *
- * Caller takes responsibility for freeing @array when it is no longer
- * needed.
- */
-int parse_int_array_user(const char __user *from, size_t count, int **array)
-{
-	char *buf;
-
-	buf = memdup_user_nul(from, count);
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
-
-	return __parse_int_array(buf, array);
-}
-EXPORT_SYMBOL(parse_int_array_user);
-
-/**
- * parse_int_array_iter - Split string into a sequence of integers
- * @from:	The iov_iter buffer to read from
- * @array:	Returned pointer to sequence of integers
- *
- * See @parse_int_array_user, this is just the iov_iter variant.
- */
-int parse_int_array_iter(struct iov_iter *from, int **array)
-{
-	char *buf;
-
-	buf = iterdup_nul(from, iov_iter_count(from));
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
 
-	return __parse_int_array(buf, array);
 }
 EXPORT_SYMBOL(parse_int_array_iter);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 435/437] fs: kill off non-iter variants of simple_attr_{read,write}*
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (433 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 434/437] lib/string_helpers: kill parse_int_array_user() Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 436/437] kstrtox: remove (now) dead helpers Jens Axboe
                   ` (2 subsequent siblings)
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

They are no longer used, kill them with fire.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/libfs.c         | 89 ----------------------------------------------
 include/linux/fs.h |  6 ----
 2 files changed, 95 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 56b404ad4cfb..74159f63334e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1337,44 +1337,6 @@ int simple_attr_release(struct inode *inode, struct file *file)
 }
 EXPORT_SYMBOL_GPL(simple_attr_release);	/* GPL-only?  This?  Really? */
 
-/* read from the buffer that is filled with the get function */
-ssize_t simple_attr_read(struct file *file, char __user *buf,
-			 size_t len, loff_t *ppos)
-{
-	struct simple_attr *attr;
-	size_t size;
-	ssize_t ret;
-
-	attr = file->private_data;
-
-	if (!attr->get)
-		return -EACCES;
-
-	ret = mutex_lock_interruptible(&attr->mutex);
-	if (ret)
-		return ret;
-
-	if (*ppos && attr->get_buf[0]) {
-		/* continued read */
-		size = strlen(attr->get_buf);
-	} else {
-		/* first read */
-		u64 val;
-		ret = attr->get(attr->data, &val);
-		if (ret)
-			goto out;
-
-		size = scnprintf(attr->get_buf, sizeof(attr->get_buf),
-				 attr->fmt, (unsigned long long)val);
-	}
-
-	ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
-out:
-	mutex_unlock(&attr->mutex);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(simple_attr_read);
-
 /* read from the buffer that is filled with the get function */
 ssize_t simple_attr_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
@@ -1462,57 +1424,6 @@ ssize_t simple_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from)
 }
 EXPORT_SYMBOL_GPL(simple_attr_write_iter_signed);
 
-/* interpret the buffer as a number to call the set function with */
-static ssize_t simple_attr_write_xsigned(struct file *file, const char __user *buf,
-			  size_t len, loff_t *ppos, bool is_signed)
-{
-	struct simple_attr *attr;
-	unsigned long long val;
-	size_t size;
-	ssize_t ret;
-
-	attr = file->private_data;
-	if (!attr->set)
-		return -EACCES;
-
-	ret = mutex_lock_interruptible(&attr->mutex);
-	if (ret)
-		return ret;
-
-	ret = -EFAULT;
-	size = min(sizeof(attr->set_buf) - 1, len);
-	if (copy_from_user(attr->set_buf, buf, size))
-		goto out;
-
-	attr->set_buf[size] = '\0';
-	if (is_signed)
-		ret = kstrtoll(attr->set_buf, 0, &val);
-	else
-		ret = kstrtoull(attr->set_buf, 0, &val);
-	if (ret)
-		goto out;
-	ret = attr->set(attr->data, val);
-	if (ret == 0)
-		ret = len; /* on success, claim we got the whole input */
-out:
-	mutex_unlock(&attr->mutex);
-	return ret;
-}
-
-ssize_t simple_attr_write(struct file *file, const char __user *buf,
-			  size_t len, loff_t *ppos)
-{
-	return simple_attr_write_xsigned(file, buf, len, ppos, false);
-}
-EXPORT_SYMBOL_GPL(simple_attr_write);
-
-ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
-			  size_t len, loff_t *ppos)
-{
-	return simple_attr_write_xsigned(file, buf, len, ppos, true);
-}
-EXPORT_SYMBOL_GPL(simple_attr_write_signed);
-
 /**
  * generic_encode_ino32_fh - generic export_operations->encode_fh function
  * @inode:   the object to encode
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 85db7dde4778..55fc02b99cf6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3552,12 +3552,6 @@ int simple_attr_open(struct inode *inode, struct file *file,
 		     int (*get)(void *, u64 *), int (*set)(void *, u64),
 		     const char *fmt);
 int simple_attr_release(struct inode *inode, struct file *file);
-ssize_t simple_attr_read(struct file *file, char __user *buf,
-			 size_t len, loff_t *ppos);
-ssize_t simple_attr_write(struct file *file, const char __user *buf,
-			  size_t len, loff_t *ppos);
-ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
-				 size_t len, loff_t *ppos);
 ssize_t simple_attr_read_iter(struct kiocb *iocb, struct iov_iter *to);
 ssize_t simple_attr_write_iter(struct kiocb *iocb, struct iov_iter *from);
 ssize_t simple_attr_write_iter_signed(struct kiocb *iocb, struct iov_iter *from);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 436/437] kstrtox: remove (now) dead helpers
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (434 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 435/437] fs: kill off non-iter variants of simple_attr_{read,write}* Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-11 15:19 ` [PATCH 437/437] REMOVE ->read() and ->write() Jens Axboe
  2024-04-12  4:29 ` [PATCHSET RFC 0/437] Kill off old fops " Al Viro
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

This drops:

kstrtoll_from_user()
kstrtol_from_user()
kstrtouint_from_user()
kstrtou16_from_user()
kstrtos16_from_user()
kstrtos8_from_user()
kstrtou64_from_user()
kstrtos64_from_user()
kstrtou32_from_user()
kstrtos32_from_user()

as they are no longer used in the code base.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/kstrtox.h | 26 --------------------------
 lib/kstrtox.c           |  6 ------
 2 files changed, 32 deletions(-)

diff --git a/include/linux/kstrtox.h b/include/linux/kstrtox.h
index 229e0162849a..2fa469860c42 100644
--- a/include/linux/kstrtox.h
+++ b/include/linux/kstrtox.h
@@ -98,15 +98,9 @@ int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
 int __must_check kstrtobool(const char *s, bool *res);
 
 int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
-int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
 int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
-int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
-int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
 int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
-int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
-int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
 int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
-int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
 int __must_check kstrtobool_from_user(const char __user *s, size_t count, bool *res);
 
 struct iov_iter;
@@ -119,36 +113,16 @@ int __must_check kstrtou16_from_iter(struct iov_iter *s, size_t count, unsigned
 int __must_check kstrtou8_from_iter(struct iov_iter *s, size_t count, unsigned int base, u8 *res);
 int __must_check kstrtobool_from_iter(struct iov_iter *src, size_t count, bool *res);
 
-static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
-{
-	return kstrtoull_from_user(s, count, base, res);
-}
-
 static inline int __must_check kstrtou64_from_iter(struct iov_iter *src, size_t count, unsigned int base, u64 *res)
 {
 	return kstrtoull_from_iter(src, count, base, res);
 }
 
-static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
-{
-	return kstrtoll_from_user(s, count, base, res);
-}
-
-static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
-{
-	return kstrtouint_from_user(s, count, base, res);
-}
-
 static inline int __must_check kstrtou32_from_iter(struct iov_iter *src, size_t count, unsigned int base, u32 *res)
 {
 	return kstrtouint_from_iter(src, count, base, res);
 }
 
-static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
-{
-	return kstrtoint_from_user(s, count, base, res);
-}
-
 static inline int __must_check kstrtos32_from_iter(struct iov_iter *src, size_t count, unsigned int base, s32 *res)
 {
 	return kstrtoint_from_iter(src, count, base, res);
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
index 111231cb4148..e8a603954396 100644
--- a/lib/kstrtox.c
+++ b/lib/kstrtox.c
@@ -438,15 +438,9 @@ int f(const char __user *s, size_t count, unsigned int base, type *res)	\
 EXPORT_SYMBOL(f)
 
 kstrto_from_user(kstrtoull_from_user,	kstrtoull,	unsigned long long);
-kstrto_from_user(kstrtoll_from_user,	kstrtoll,	long long);
 kstrto_from_user(kstrtoul_from_user,	kstrtoul,	unsigned long);
-kstrto_from_user(kstrtol_from_user,	kstrtol,	long);
-kstrto_from_user(kstrtouint_from_user,	kstrtouint,	unsigned int);
 kstrto_from_user(kstrtoint_from_user,	kstrtoint,	int);
-kstrto_from_user(kstrtou16_from_user,	kstrtou16,	u16);
-kstrto_from_user(kstrtos16_from_user,	kstrtos16,	s16);
 kstrto_from_user(kstrtou8_from_user,	kstrtou8,	u8);
-kstrto_from_user(kstrtos8_from_user,	kstrtos8,	s8);
 
 #define kstrto_from_iter(f, g, type)					\
 int f(struct iov_iter *s, size_t count, unsigned int base, type *res)	\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* [PATCH 437/437] REMOVE ->read() and ->write()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (435 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 436/437] kstrtox: remove (now) dead helpers Jens Axboe
@ 2024-04-11 15:19 ` Jens Axboe
  2024-04-12  4:29 ` [PATCHSET RFC 0/437] Kill off old fops " Al Viro
  437 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-11 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

Test patch just to check coverage.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 fs/file_table.c    |  4 +--
 fs/open.c          |  4 +--
 fs/read_write.c    | 16 +++--------
 include/linux/fs.h |  2 --
 io_uring/rw.c      | 70 ----------------------------------------------
 5 files changed, 8 insertions(+), 88 deletions(-)

diff --git a/fs/file_table.c b/fs/file_table.c
index 4f03beed4737..54cf21766633 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -292,10 +292,10 @@ static void file_init_path(struct file *file, const struct path *path,
 	if (fop->llseek)
 		file->f_mode |= FMODE_LSEEK;
 	if ((file->f_mode & FMODE_READ) &&
-	     likely(fop->read || fop->read_iter))
+	     likely(fop->read_iter))
 		file->f_mode |= FMODE_CAN_READ;
 	if ((file->f_mode & FMODE_WRITE) &&
-	     likely(fop->write || fop->write_iter))
+	     likely(fop->write_iter))
 		file->f_mode |= FMODE_CAN_WRITE;
 	file->f_iocb_flags = iocb_flags(file);
 	file->f_mode |= FMODE_OPENED;
diff --git a/fs/open.c b/fs/open.c
index ee8460c83c77..63caada91fc5 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -958,10 +958,10 @@ static int do_dentry_open(struct file *f,
 	}
 	f->f_mode |= FMODE_OPENED;
 	if ((f->f_mode & FMODE_READ) &&
-	     likely(f->f_op->read || f->f_op->read_iter))
+	     likely(f->f_op->read_iter))
 		f->f_mode |= FMODE_CAN_READ;
 	if ((f->f_mode & FMODE_WRITE) &&
-	     likely(f->f_op->write || f->f_op->write_iter))
+	     likely(f->f_op->write_iter))
 		f->f_mode |= FMODE_CAN_WRITE;
 	if ((f->f_mode & FMODE_LSEEK) && !f->f_op->llseek)
 		f->f_mode &= ~FMODE_LSEEK;
diff --git a/fs/read_write.c b/fs/read_write.c
index efddd395d436..caec0998f28a 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -425,7 +425,7 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
 	 * Also fail if ->read_iter and ->read are both wired up as that
 	 * implies very convoluted semantics.
 	 */
-	if (unlikely(!file->f_op->read_iter || file->f_op->read))
+	if (unlikely(!file->f_op->read_iter))
 		return warn_unsupported(file, "read");
 
 	init_sync_kiocb(&kiocb, file);
@@ -470,9 +470,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
 	if (count > MAX_RW_COUNT)
 		count =  MAX_RW_COUNT;
 
-	if (file->f_op->read)
-		ret = file->f_op->read(file, buf, count, pos);
-	else if (file->f_op->read_iter)
+	if (file->f_op->read_iter)
 		ret = new_sync_read(file, buf, count, pos);
 	else
 		ret = -EINVAL;
@@ -515,7 +513,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po
 	 * Also fail if ->write_iter and ->write are both wired up as that
 	 * implies very convoluted semantics.
 	 */
-	if (unlikely(!file->f_op->write_iter || file->f_op->write))
+	if (unlikely(!file->f_op->write_iter))
 		return warn_unsupported(file, "write");
 
 	init_sync_kiocb(&kiocb, file);
@@ -584,9 +582,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
 	if (count > MAX_RW_COUNT)
 		count =  MAX_RW_COUNT;
 	file_start_write(file);
-	if (file->f_op->write)
-		ret = file->f_op->write(file, buf, count, pos);
-	else if (file->f_op->write_iter)
+	if (file->f_op->write_iter)
 		ret = new_sync_write(file, buf, count, pos);
 	else
 		ret = -EINVAL;
@@ -972,8 +968,6 @@ static ssize_t vfs_readv(struct file *file, const struct iovec __user *vec,
 
 	if (file->f_op->read_iter)
 		ret = do_iter_readv_writev(file, &iter, pos, READ, flags);
-	else
-		ret = do_loop_readv(file, &iter, pos, flags, file->f_op->read);
 out:
 	if (ret >= 0)
 		fsnotify_access(file);
@@ -1011,8 +1005,6 @@ static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
 	file_start_write(file);
 	if (file->f_op->write_iter)
 		ret = do_iter_readv_writev(file, &iter, pos, WRITE, flags);
-	else
-		ret = do_loop_writev(file, &iter, pos, flags, file->f_op->write);
 	if (ret > 0)
 		fsnotify_modify(file);
 	file_end_write(file);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 55fc02b99cf6..7606ed6b9dbc 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2009,8 +2009,6 @@ struct offset_ctx;
 struct file_operations {
 	struct module *owner;
 	loff_t (*llseek) (struct file *, loff_t, int);
-	ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
-	ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
 	ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
 	ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
 	int (*iopoll)(struct kiocb *kiocb, struct io_comp_batch *,
diff --git a/io_uring/rw.c b/io_uring/rw.c
index c8d48287439e..9178b1bccb8b 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -474,72 +474,6 @@ static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb)
 	return (kiocb->ki_filp->f_mode & FMODE_STREAM) ? NULL : &kiocb->ki_pos;
 }
 
-/*
- * For files that don't have ->read_iter() and ->write_iter(), handle them
- * by looping over ->read() or ->write() manually.
- */
-static ssize_t loop_rw_iter(int ddir, struct io_rw *rw, struct iov_iter *iter)
-{
-	struct kiocb *kiocb = &rw->kiocb;
-	struct file *file = kiocb->ki_filp;
-	ssize_t ret = 0;
-	loff_t *ppos;
-
-	/*
-	 * Don't support polled IO through this interface, and we can't
-	 * support non-blocking either. For the latter, this just causes
-	 * the kiocb to be handled from an async context.
-	 */
-	if (kiocb->ki_flags & IOCB_HIPRI)
-		return -EOPNOTSUPP;
-	if ((kiocb->ki_flags & IOCB_NOWAIT) &&
-	    !(kiocb->ki_filp->f_flags & O_NONBLOCK))
-		return -EAGAIN;
-
-	ppos = io_kiocb_ppos(kiocb);
-
-	while (iov_iter_count(iter)) {
-		void __user *addr;
-		size_t len;
-		ssize_t nr;
-
-		if (iter_is_ubuf(iter)) {
-			addr = iter->ubuf + iter->iov_offset;
-			len = iov_iter_count(iter);
-		} else if (!iov_iter_is_bvec(iter)) {
-			addr = iter_iov_addr(iter);
-			len = iter_iov_len(iter);
-		} else {
-			addr = u64_to_user_ptr(rw->addr);
-			len = rw->len;
-		}
-
-		if (ddir == READ)
-			nr = file->f_op->read(file, addr, len, ppos);
-		else
-			nr = file->f_op->write(file, addr, len, ppos);
-
-		if (nr < 0) {
-			if (!ret)
-				ret = nr;
-			break;
-		}
-		ret += nr;
-		if (!iov_iter_is_bvec(iter)) {
-			iov_iter_advance(iter, nr);
-		} else {
-			rw->addr += nr;
-			rw->len -= nr;
-			if (!rw->len)
-				break;
-		}
-		if (nr != len)
-			break;
-	}
-
-	return ret;
-}
-
 static void io_req_map_rw(struct io_kiocb *req, const struct iovec *iovec,
 			  const struct iovec *fast_iov, struct iov_iter *iter)
 {
@@ -702,8 +636,6 @@ static inline int io_iter_do_read(struct io_rw *rw, struct iov_iter *iter)
 
 	if (likely(file->f_op->read_iter))
 		return call_read_iter(file, &rw->kiocb, iter);
-	else if (file->f_op->read)
-		return loop_rw_iter(READ, rw, iter);
 	else
 		return -EINVAL;
 }
@@ -1055,8 +987,6 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags)
 
 	if (likely(req->file->f_op->write_iter))
 		ret2 = call_write_iter(req->file, kiocb, &s->iter);
-	else if (req->file->f_op->write)
-		ret2 = loop_rw_iter(WRITE, rw, &s->iter);
 	else
 		ret2 = -EINVAL;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 451+ messages in thread

* Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
  2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
                   ` (436 preceding siblings ...)
  2024-04-11 15:19 ` [PATCH 437/437] REMOVE ->read() and ->write() Jens Axboe
@ 2024-04-12  4:29 ` Al Viro
  2024-04-12  4:37   ` Al Viro
  2024-04-12 13:58   ` Jens Axboe
  437 siblings, 2 replies; 451+ messages in thread
From: Al Viro @ 2024-04-12  4:29 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Thu, Apr 11, 2024 at 09:12:20AM -0600, Jens Axboe wrote:
> Hi,
> 
> This patchset will obviously be split, commit messages updated, and
> specific driver patches targeted to where they belong. But I figured
> it'd be useful to blast out the full set at least once for reference,
> and then I'll continue down the right path for the next one.
> 
> Subject line says it all, really. 10 years ago we added ->read_iter()
> and ->write_iter() to struct file_operations. These are great, as they
> pass in an iov_iter rather than a user buffer + length, and they also
> take a struct kiocb rather than just a file. Since then we've had two
> paths for any read or write - one legacy one that can't do per-IO hints
> like "This read should be non-blocking", they strictly only work with
> O_NONBLOCK on the file, and a newer one that supports everything the
> old path does and a bunch more. We've had a few issues with the
> iov_iter based path being slower, but those have basically been
> resolved with solutions like ITER_UBUF to optimize the single segment
> case that is often the fast path.
> 
> There are basically three parts to this series:
> 
> 1) Add generic helpers that we need to convert drivers.
> 2) Convert any use of fops->read() and ->write()
> 3) Kill off old cruft.
> 3a) Profit.

The fundamental problem with that is that a bunch of drivers
do care about the vector boundaries.  Very much so.  It's very
common to have this kind of situation:
	write() parses the buffer sloppily, and ignores the junk in
the end, claiming that everything that been written.
	writev() feeds each vector to write().

From a cursory look through that pile, you seem to have broken
writev() on at least some (if not all) of those.

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
  2024-04-12  4:29 ` [PATCHSET RFC 0/437] Kill off old fops " Al Viro
@ 2024-04-12  4:37   ` Al Viro
  2024-04-12 13:58   ` Jens Axboe
  1 sibling, 0 replies; 451+ messages in thread
From: Al Viro @ 2024-04-12  4:37 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Fri, Apr 12, 2024 at 05:29:10AM +0100, Al Viro wrote:
> On Thu, Apr 11, 2024 at 09:12:20AM -0600, Jens Axboe wrote:
> > Hi,
> > 
> > This patchset will obviously be split, commit messages updated, and
> > specific driver patches targeted to where they belong. But I figured
> > it'd be useful to blast out the full set at least once for reference,
> > and then I'll continue down the right path for the next one.
> > 
> > Subject line says it all, really. 10 years ago we added ->read_iter()
> > and ->write_iter() to struct file_operations. These are great, as they
> > pass in an iov_iter rather than a user buffer + length, and they also
> > take a struct kiocb rather than just a file. Since then we've had two
> > paths for any read or write - one legacy one that can't do per-IO hints
> > like "This read should be non-blocking", they strictly only work with
> > O_NONBLOCK on the file, and a newer one that supports everything the
> > old path does and a bunch more. We've had a few issues with the
> > iov_iter based path being slower, but those have basically been
> > resolved with solutions like ITER_UBUF to optimize the single segment
> > case that is often the fast path.
> > 
> > There are basically three parts to this series:
> > 
> > 1) Add generic helpers that we need to convert drivers.
> > 2) Convert any use of fops->read() and ->write()
> > 3) Kill off old cruft.
> > 3a) Profit.
> 
> The fundamental problem with that is that a bunch of drivers
> do care about the vector boundaries.  Very much so.  It's very
> common to have this kind of situation:
> 	write() parses the buffer sloppily, and ignores the junk in
> the end, claiming that everything that been written.
> 	writev() feeds each vector to write().
> 
> From a cursory look through that pile, you seem to have broken
> writev() on at least some (if not all) of those.

OK, it's 'some', not 'all', but AFAICS you'd been far too
optimistic about the number of instances that do not need
your vfs_write_iter() wrappers...

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
  2024-04-12  4:29 ` [PATCHSET RFC 0/437] Kill off old fops " Al Viro
  2024-04-12  4:37   ` Al Viro
@ 2024-04-12 13:58   ` Jens Axboe
  2024-04-13  4:15     ` Al Viro
  1 sibling, 1 reply; 451+ messages in thread
From: Jens Axboe @ 2024-04-12 13:58 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On 4/11/24 10:29 PM, Al Viro wrote:
> On Thu, Apr 11, 2024 at 09:12:20AM -0600, Jens Axboe wrote:
>> Hi,
>>
>> This patchset will obviously be split, commit messages updated, and
>> specific driver patches targeted to where they belong. But I figured
>> it'd be useful to blast out the full set at least once for reference,
>> and then I'll continue down the right path for the next one.
>>
>> Subject line says it all, really. 10 years ago we added ->read_iter()
>> and ->write_iter() to struct file_operations. These are great, as they
>> pass in an iov_iter rather than a user buffer + length, and they also
>> take a struct kiocb rather than just a file. Since then we've had two
>> paths for any read or write - one legacy one that can't do per-IO hints
>> like "This read should be non-blocking", they strictly only work with
>> O_NONBLOCK on the file, and a newer one that supports everything the
>> old path does and a bunch more. We've had a few issues with the
>> iov_iter based path being slower, but those have basically been
>> resolved with solutions like ITER_UBUF to optimize the single segment
>> case that is often the fast path.
>>
>> There are basically three parts to this series:
>>
>> 1) Add generic helpers that we need to convert drivers.
>> 2) Convert any use of fops->read() and ->write()
>> 3) Kill off old cruft.
>> 3a) Profit.
> 
> The fundamental problem with that is that a bunch of drivers
> do care about the vector boundaries.  Very much so.  It's very
> common to have this kind of situation:
> 	write() parses the buffer sloppily, and ignores the junk in
> the end, claiming that everything that been written.
> 	writev() feeds each vector to write().
> 
> From a cursory look through that pile, you seem to have broken
> writev() on at least some (if not all) of those.

I'm aware of some drivers that do different things from write vs writev,
or read vs readv for instance. But those I did cater to, by having a
flag they can now check.

Can you be a bit more specific on an example of a driver that does the
above?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
  2024-04-12 13:58   ` Jens Axboe
@ 2024-04-13  4:15     ` Al Viro
  2024-04-13 15:37       ` Jens Axboe
  0 siblings, 1 reply; 451+ messages in thread
From: Al Viro @ 2024-04-13  4:15 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Fri, Apr 12, 2024 at 07:58:13AM -0600, Jens Axboe wrote:

> I'm aware of some drivers that do different things from write vs writev,
> or read vs readv for instance. But those I did cater to, by having a
> flag they can now check.
> 
> Can you be a bit more specific on an example of a driver that does the
> above?

Consider e.g. your #39.  Current mainline: 1 call of ->set() for each
segment passed to writev() on any of those.  With your patch: call
segments concatenated and if the concatenation looks like a number,
a single call of ->set().

If nothing else, it's a user-visible ABI change.  And in cases when ->set()
has non-trivial side effects, it just might break a real-world code that
is currently correct.

I picked that one because I didn't want to dig through the drivers -
I'm pretty sure that there's more to be found there.

It's not just "write() and writev() parse the data in different way" - we do
have a couple of those, but that's a minor problem.

"write(fd, buf, len1); write(fd, buf + len1, len1 + len2); is not the same
thing as write(fd, buf, len1 + len2)" is not rare for character devices and
for regular files on procfs/debugfs/etc.

For any of those you need to use you vfs_write_iter() helper or you'll
be breaking userland ABI.  The cost of audit of several thousands of ->write()
(and ->read() - similar problem applies there) instances, checking that property
is the main reason this conversion hadn't been already done.

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()
  2024-04-13  4:15     ` Al Viro
@ 2024-04-13 15:37       ` Jens Axboe
  0 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-04-13 15:37 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On 4/12/24 10:15 PM, Al Viro wrote:
> On Fri, Apr 12, 2024 at 07:58:13AM -0600, Jens Axboe wrote:
> 
>> I'm aware of some drivers that do different things from write vs writev,
>> or read vs readv for instance. But those I did cater to, by having a
>> flag they can now check.
>>
>> Can you be a bit more specific on an example of a driver that does the
>> above?
> 
> Consider e.g. your #39.  Current mainline: 1 call of ->set() for each
> segment passed to writev() on any of those.  With your patch: call
> segments concatenated and if the concatenation looks like a number, a
> single call of ->set().
> 
> If nothing else, it's a user-visible ABI change.  And in cases when
> ->set() has non-trivial side effects, it just might break a real-world
> code that is currently correct.
> 
> I picked that one because I didn't want to dig through the drivers -
> I'm pretty sure that there's more to be found there.
> 
> It's not just "write() and writev() parse the data in different way" -
> we do have a couple of those, but that's a minor problem.
> 
> "write(fd, buf, len1); write(fd, buf + len1, len1 + len2); is not the
> same thing as write(fd, buf, len1 + len2)" is not rare for character
> devices and for regular files on procfs/debugfs/etc.
> 
> For any of those you need to use you vfs_write_iter() helper or you'll
> be breaking userland ABI.  The cost of audit of several thousands of
> ->write() (and ->read() - similar problem applies there) instances,
> checking that property is the main reason this conversion hadn't been
> already done.

Thanks Al, I see what you mean now, and yes  that certainly makes
sense. I'll go over the conversions and see what might be affected, and
for those we'll probably just play it safe initially and use the FOPS
iterators helpers to avoid changing behavior.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-11 15:12 ` [PATCH 002/437] fs: add generic read/write iterator helpers Jens Axboe
@ 2024-04-15 19:55   ` Al Viro
  2024-04-15 20:11     ` Jens Axboe
  2024-04-16 20:14     ` David Laight
  0 siblings, 2 replies; 451+ messages in thread
From: Al Viro @ 2024-04-15 19:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Thu, Apr 11, 2024 at 09:12:22AM -0600, Jens Axboe wrote:

> +/* generic read side helper for drivers converting to ->read_iter() */
> +ssize_t vfs_read_iter(struct kiocb *iocb, struct iov_iter *to,
> +		      ssize_t (*read)(struct file *, char __user *,
> +				     size_t, loff_t *))
> +{
> +	return do_loop_readv(iocb->ki_filp, to, &iocb->ki_pos, 0, read);
> +}
> +EXPORT_SYMBOL(vfs_read_iter);
> +
> +/* generic write side helper for drivers converting to ->write_iter() */
> +ssize_t vfs_write_iter(struct kiocb *iocb, struct iov_iter *from,
> +		       ssize_t (*write)(struct file *, const char __user *,
> +				       size_t, loff_t *))
> +{
> +	return do_loop_writev(iocb->ki_filp, from, &iocb->ki_pos, 0, write);
> +}
> +EXPORT_SYMBOL(vfs_write_iter);

Wait a minute; just what do you expect to happen if that ever gets called
for ITER_BVEC or ITER_XARRAY?

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-15 19:55   ` Al Viro
@ 2024-04-15 20:11     ` Jens Axboe
  2024-04-15 21:08       ` Al Viro
  2024-04-16 20:14     ` David Laight
  1 sibling, 1 reply; 451+ messages in thread
From: Jens Axboe @ 2024-04-15 20:11 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On 4/15/24 1:55 PM, Al Viro wrote:
> On Thu, Apr 11, 2024 at 09:12:22AM -0600, Jens Axboe wrote:
> 
>> +/* generic read side helper for drivers converting to ->read_iter() */
>> +ssize_t vfs_read_iter(struct kiocb *iocb, struct iov_iter *to,
>> +		      ssize_t (*read)(struct file *, char __user *,
>> +				     size_t, loff_t *))
>> +{
>> +	return do_loop_readv(iocb->ki_filp, to, &iocb->ki_pos, 0, read);
>> +}
>> +EXPORT_SYMBOL(vfs_read_iter);
>> +
>> +/* generic write side helper for drivers converting to ->write_iter() */
>> +ssize_t vfs_write_iter(struct kiocb *iocb, struct iov_iter *from,
>> +		       ssize_t (*write)(struct file *, const char __user *,
>> +				       size_t, loff_t *))
>> +{
>> +	return do_loop_writev(iocb->ki_filp, from, &iocb->ki_pos, 0, write);
>> +}
>> +EXPORT_SYMBOL(vfs_write_iter);
> 
> Wait a minute; just what do you expect to happen if that ever gets called
> for ITER_BVEC or ITER_XARRAY?

do_loop_{readv,writev} need to look like the one io_uring had, which was
just an augmented version of the fs/ version. At least for handling
anything that is IOVEC/UBUF/BVEC. Outside of that, should not be
callable for eg ITER_XARRAY, who would do that? We should probably add a
check at the top of each just to vet the iter type and -EINVAL if it's
not one of the supported ones. With a WARN_ON_ONCE(), I suspect.

I'll be posting the first patches separately again, I've made some local
tweaks, with some drivers that can support it as-is. Just haven't gotten
around to doing this weeks iteration on it yet.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-15 20:11     ` Jens Axboe
@ 2024-04-15 21:08       ` Al Viro
  2024-04-15 21:16         ` Jens Axboe
  0 siblings, 1 reply; 451+ messages in thread
From: Al Viro @ 2024-04-15 21:08 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Mon, Apr 15, 2024 at 02:11:56PM -0600, Jens Axboe wrote:

> do_loop_{readv,writev} need to look like the one io_uring had, which was
> just an augmented version of the fs/ version. At least for handling
> anything that is IOVEC/UBUF/BVEC.

IOVEC and UBUF: pointer will be __user one; copy_from_user() works.
KVEC: kernel pointer.  Try copy_from_user() on that on x86 with SMAP (or
on e.g. sparc64, etc.) and you'll get an oops.
BVEC: page + offset, page quite possibly not mapped anywhere in kernel page
tables.  And "just kmap() around the call of your callback" is not a good
idea either, for even more reason that for KVEC.

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-15 21:08       ` Al Viro
@ 2024-04-15 21:16         ` Jens Axboe
  2024-04-15 23:42           ` Al Viro
  0 siblings, 1 reply; 451+ messages in thread
From: Jens Axboe @ 2024-04-15 21:16 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

On 4/15/24 3:08 PM, Al Viro wrote:
> On Mon, Apr 15, 2024 at 02:11:56PM -0600, Jens Axboe wrote:
> 
>> do_loop_{readv,writev} need to look like the one io_uring had, which was
>> just an augmented version of the fs/ version. At least for handling
>> anything that is IOVEC/UBUF/BVEC.
> 
> IOVEC and UBUF: pointer will be __user one; copy_from_user() works.
> KVEC: kernel pointer.  Try copy_from_user() on that on x86 with SMAP (or
> on e.g. sparc64, etc.) and you'll get an oops.
> BVEC: page + offset, page quite possibly not mapped anywhere in kernel page
> tables.  And "just kmap() around the call of your callback" is not a good
> idea either, for even more reason that for KVEC.

The old read/write path only handled user pointers, with the exception
being bvecs mapped on the io_uring side (which the io_uring version
dealt with) which also originally came from user pointers. So just user
memory. Why would we need to expand that now? Who would be doing
->read_iter() or ->write_iter() with something that isn't either UBUF or
IOVEC? Because that would break horrible as it is in the current kernel.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-15 21:16         ` Jens Axboe
@ 2024-04-15 23:42           ` Al Viro
  0 siblings, 0 replies; 451+ messages in thread
From: Al Viro @ 2024-04-15 23:42 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

On Mon, Apr 15, 2024 at 03:16:12PM -0600, Jens Axboe wrote:

> The old read/write path only handled user pointers, with the exception
> being bvecs mapped on the io_uring side (which the io_uring version
> dealt with) which also originally came from user pointers. So just user
> memory. Why would we need to expand that now? Who would be doing
> ->read_iter() or ->write_iter() with something that isn't either UBUF or
> IOVEC? Because that would break horrible as it is in the current kernel.

No, it will not.  And yes, it does happen.  Look, for example, at
fs/coredump.c:dump_emit_page().  ->write_iter() (regular file or pipe one)
is called.  On ITER_BVEC.

It happens, and not only there.  Look at how /dev/loop works, for crying
out loud!  You get a struct request; the backing pages might very well have
_never_ been mapped to any userland address (e.g. when it's something like
a directory block).  And you hit this:

static int lo_write_simple(struct loop_device *lo, struct request *rq,
                loff_t pos)
{
        struct bio_vec bvec;
        struct req_iterator iter;
        int ret = 0;

        rq_for_each_segment(bvec, rq, iter) {
                ret = lo_write_bvec(lo->lo_backing_file, &bvec, &pos);
                if (ret < 0)
                        break;
                cond_resched();
        }

        return ret;
}

with lo_write_bvec() being

static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
{
        struct iov_iter i;
        ssize_t bw;

        iov_iter_bvec(&i, ITER_SOURCE, bvec, 1, bvec->bv_len);

        bw = vfs_iter_write(file, &i, ppos, 0);

        if (likely(bw ==  bvec->bv_len))
                return 0;   

        printk_ratelimited(KERN_ERR
                "loop: Write error at byte offset %llu, length %i.\n",
                (unsigned long long)*ppos, bvec->bv_len);
        if (bw >= 0)
                bw = -EIO;
        return bw;
}


Neither ->read_iter() nor ->write_iter() can make an assumption that it
will be used with userland buffer.  And yes, it works...

^ permalink raw reply	[flat|nested] 451+ messages in thread

* RE: [PATCH 002/437] fs: add generic read/write iterator helpers
  2024-04-15 19:55   ` Al Viro
  2024-04-15 20:11     ` Jens Axboe
@ 2024-04-16 20:14     ` David Laight
  1 sibling, 0 replies; 451+ messages in thread
From: David Laight @ 2024-04-16 20:14 UTC (permalink / raw)
  To: 'Al Viro', Jens Axboe; +Cc: linux-kernel

From: Al Viro
> Sent: 15 April 2024 20:55
> 
> On Thu, Apr 11, 2024 at 09:12:22AM -0600, Jens Axboe wrote:
> 
> > +/* generic read side helper for drivers converting to ->read_iter() */
> > +ssize_t vfs_read_iter(struct kiocb *iocb, struct iov_iter *to,
> > +		      ssize_t (*read)(struct file *, char __user *,
> > +				     size_t, loff_t *))
> > +{
> > +	return do_loop_readv(iocb->ki_filp, to, &iocb->ki_pos, 0, read);
> > +}
> > +EXPORT_SYMBOL(vfs_read_iter);
> > +
> > +/* generic write side helper for drivers converting to ->write_iter() */
> > +ssize_t vfs_write_iter(struct kiocb *iocb, struct iov_iter *from,
> > +		       ssize_t (*write)(struct file *, const char __user *,
> > +				       size_t, loff_t *))
> > +{
> > +	return do_loop_writev(iocb->ki_filp, from, &iocb->ki_pos, 0, write);
> > +}
> > +EXPORT_SYMBOL(vfs_write_iter);
> 
> Wait a minute; just what do you expect to happen if that ever gets called
> for ITER_BVEC or ITER_XARRAY?

The extra indirect call is also going to be noticeable.
You need a code loop with a direct call.
That probably requires the loop to be a #define.

I was also thinking about drivers that only handle 'user' buffers and
where there really isn't a requirement to do anything else.

I've a driver that basically does:
	if (!access_ok(....))
		return -EFAULT;
	for (off = 0; off < len; off += 8) {
		if (__put_user(readq(io_addr + off), uaddr + off))
			return -EFAULT;
	}

Any non-trivial change requires a function that return the first/only
user buffer address/length and an error for a non-user address.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 413/437] media/rc: convert to read/write iterators
  2024-04-11 15:19 ` [PATCH 413/437] media/rc: " Jens Axboe
@ 2024-05-04 12:31   ` Mauro Carvalho Chehab
  2024-05-05 13:16     ` Jens Axboe
  0 siblings, 1 reply; 451+ messages in thread
From: Mauro Carvalho Chehab @ 2024-05-04 12:31 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, linux-media

Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <axboe@kernel.dk> escreveu:

> Signed-off-by: Jens Axboe <axboe@kernel.dk>

Please add a patch description to media patches. Also, please
c/c linux-media@vger.kernel.org, as otherwise patchwork.linuxtv.org
won't track it, and such patches will be silently ignored[1].

[1] I only got aware of this series due to https://lwn.net/Articles/972081/

Regards,
Mauro

> ---
>  drivers/media/rc/imon.c     | 26 ++++++++++++--------------
>  drivers/media/rc/lirc_dev.c | 15 ++++++++-------
>  2 files changed, 20 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
> index 5719dda6e0f0..cfcf8101164a 100644
> --- a/drivers/media/rc/imon.c
> +++ b/drivers/media/rc/imon.c
> @@ -65,12 +65,10 @@ static int display_open(struct inode *inode, struct file *file);
>  static int display_close(struct inode *inode, struct file *file);
>  
>  /* VFD write operation */
> -static ssize_t vfd_write(struct file *file, const char __user *buf,
> -			 size_t n_bytes, loff_t *pos);
> +static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from);
>  
>  /* LCD file_operations override function prototypes */
> -static ssize_t lcd_write(struct file *file, const char __user *buf,
> -			 size_t n_bytes, loff_t *pos);
> +static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from);
>  
>  /*** G L O B A L S ***/
>  
> @@ -179,7 +177,7 @@ struct imon_context {
>  static const struct file_operations vfd_fops = {
>  	.owner		= THIS_MODULE,
>  	.open		= display_open,
> -	.write		= vfd_write,
> +	.write_iter	= vfd_write,
>  	.release	= display_close,
>  	.llseek		= noop_llseek,
>  };
> @@ -188,7 +186,7 @@ static const struct file_operations vfd_fops = {
>  static const struct file_operations lcd_fops = {
>  	.owner		= THIS_MODULE,
>  	.open		= display_open,
> -	.write		= lcd_write,
> +	.write_iter	= lcd_write,
>  	.release	= display_close,
>  	.llseek		= noop_llseek,
>  };
> @@ -938,16 +936,16 @@ static const struct attribute_group imon_rf_attr_group = {
>   * than 32 bytes are provided spaces will be appended to
>   * generate a full screen.
>   */
> -static ssize_t vfd_write(struct file *file, const char __user *buf,
> -			 size_t n_bytes, loff_t *pos)
> +static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from)
>  {
>  	int i;
>  	int offset;
>  	int seq;
>  	int retval = 0;
> -	struct imon_context *ictx = file->private_data;
> +	struct imon_context *ictx = iocb->ki_filp->private_data;
>  	static const unsigned char vfd_packet6[] = {
>  		0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF };
> +	size_t n_bytes = iov_iter_count(from);
>  
>  	if (ictx->disconnected)
>  		return -ENODEV;
> @@ -967,7 +965,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
>  		goto exit;
>  	}
>  
> -	if (copy_from_user(ictx->tx.data_buf, buf, n_bytes)) {
> +	if (!copy_from_iter_full(ictx->tx.data_buf, n_bytes, from)) {
>  		retval = -EFAULT;
>  		goto exit;
>  	}
> @@ -1023,11 +1021,11 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
>   * display whatever diacritics you need, and so on), but it's also
>   * a lot more complicated than most LCDs...
>   */
> -static ssize_t lcd_write(struct file *file, const char __user *buf,
> -			 size_t n_bytes, loff_t *pos)
> +static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from)
>  {
>  	int retval = 0;
> -	struct imon_context *ictx = file->private_data;
> +	struct imon_context *ictx = iocb->ki_filp->private_data;
> +	size_t n_bytes = iov_iter_count(from);
>  
>  	if (ictx->disconnected)
>  		return -ENODEV;
> @@ -1047,7 +1045,7 @@ static ssize_t lcd_write(struct file *file, const char __user *buf,
>  		goto exit;
>  	}
>  
> -	if (copy_from_user(ictx->usb_tx_buf, buf, 8)) {
> +	if (!copy_from_iter_full(ictx->usb_tx_buf, 8, from)) {
>  		retval = -EFAULT;
>  		goto exit;
>  	}
> diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
> index caad59f76793..e88ba11192ea 100644
> --- a/drivers/media/rc/lirc_dev.c
> +++ b/drivers/media/rc/lirc_dev.c
> @@ -211,10 +211,10 @@ static int lirc_close(struct inode *inode, struct file *file)
>  	return 0;
>  }
>  
> -static ssize_t lirc_transmit(struct file *file, const char __user *buf,
> -			     size_t n, loff_t *ppos)
> +static ssize_t lirc_transmit(struct kiocb *iocb, struct iov_iter *from)
>  {
> -	struct lirc_fh *fh = file->private_data;
> +	struct lirc_fh *fh = iocb->ki_filp->private_data;
> +	size_t n = iov_iter_count(from);
>  	struct rc_dev *dev = fh->rc;
>  	unsigned int *txbuf;
>  	struct ir_raw_event *raw = NULL;
> @@ -247,7 +247,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf,
>  			goto out_unlock;
>  		}
>  
> -		if (copy_from_user(&scan, buf, sizeof(scan))) {
> +		if (!copy_from_iter_full(&scan, sizeof(scan), from)) {
>  			ret = -EFAULT;
>  			goto out_unlock;
>  		}
> @@ -309,7 +309,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf,
>  			goto out_unlock;
>  		}
>  
> -		txbuf = memdup_user(buf, n);
> +		txbuf = iterdup(from, n);
>  		if (IS_ERR(txbuf)) {
>  			ret = PTR_ERR(txbuf);
>  			goto out_unlock;
> @@ -694,13 +694,14 @@ static ssize_t lirc_read(struct file *file, char __user *buffer, size_t length,
>  	else /* LIRC_MODE_SCANCODE */
>  		return lirc_read_scancode(file, buffer, length);
>  }
> +FOPS_READ_ITER_HELPER(lirc_read);
>  
>  static const struct file_operations lirc_fops = {
>  	.owner		= THIS_MODULE,
> -	.write		= lirc_transmit,
> +	.write_iter	= lirc_transmit,
>  	.unlocked_ioctl	= lirc_ioctl,
>  	.compat_ioctl	= compat_ptr_ioctl,
> -	.read		= lirc_read,
> +	.read_iter	= lirc_read_iter,
>  	.poll		= lirc_poll,
>  	.open		= lirc_open,
>  	.release	= lirc_close,

^ permalink raw reply	[flat|nested] 451+ messages in thread

* Re: [PATCH 413/437] media/rc: convert to read/write iterators
  2024-05-04 12:31   ` Mauro Carvalho Chehab
@ 2024-05-05 13:16     ` Jens Axboe
  0 siblings, 0 replies; 451+ messages in thread
From: Jens Axboe @ 2024-05-05 13:16 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-kernel, linux-media

On 5/4/24 6:31 AM, Mauro Carvalho Chehab wrote:
> Em Thu, 11 Apr 2024 09:19:13 -0600
> Jens Axboe <axboe@kernel.dk> escreveu:
> 
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> Please add a patch description to media patches. Also, please
> c/c linux-media@vger.kernel.org, as otherwise patchwork.linuxtv.org
> won't track it, and such patches will be silently ignored[1].

Certainly, it's all just a RFC to get the full picture idea out in the
open. Any individual patches/series will go out separately to the
respective lists and maintainers, and it'll have actual commit message
as well at that point.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 451+ messages in thread

end of thread, other threads:[~2024-05-05 13:16 UTC | newest]

Thread overview: 451+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 15:12 [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write() Jens Axboe
2024-04-11 15:12 ` [PATCH 001/437] fs: split do_loop_readv_writev() into separate read/write side helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 002/437] fs: add generic read/write iterator helpers Jens Axboe
2024-04-15 19:55   ` Al Viro
2024-04-15 20:11     ` Jens Axboe
2024-04-15 21:08       ` Al Viro
2024-04-15 21:16         ` Jens Axboe
2024-04-15 23:42           ` Al Viro
2024-04-16 20:14     ` David Laight
2024-04-11 15:12 ` [PATCH 003/437] fs: add helpers for defining " Jens Axboe
2024-04-11 15:12 ` [PATCH 004/437] fs: add simple_copy_{to,from}_iter() helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 005/437] uio: add get/put_iter helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 006/437] fs: add uio.h to fs.h Jens Axboe
2024-04-11 15:12 ` [PATCH 007/437] mm/util: add iterdup_nul() and iterdup() helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 008/437] kstrtox: add iov_iter versions of the string conversion helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 009/437] lib/string_helpers: split __parse_int_array() into a helper Jens Axboe
2024-04-11 15:12 ` [PATCH 010/437] lib/string_helpers: add parse_int_array_iter() Jens Axboe
2024-04-11 15:12 ` [PATCH 011/437] virtio_console: convert to read/write iterator helpers Jens Axboe
2024-04-11 15:12 ` [PATCH 012/437] char/adi: convert to read/write iterators Jens Axboe
2024-04-11 15:12 ` [PATCH 013/437] char/apm-emulation: " Jens Axboe
2024-04-11 15:12 ` [PATCH 014/437] char/applicom: " Jens Axboe
2024-04-11 15:12 ` [PATCH 015/437] char/nsc_gpio: " Jens Axboe
2024-04-11 15:12 ` [PATCH 016/437] char/dsp1620: " Jens Axboe
2024-04-11 15:12 ` [PATCH 017/437] char/dsp56k: " Jens Axboe
2024-04-11 15:12 ` [PATCH 018/437] char/dtlk: " Jens Axboe
2024-04-11 15:12 ` [PATCH 019/437] char/hpet: " Jens Axboe
2024-04-11 15:12 ` [PATCH 020/437] char/hw_random: " Jens Axboe
2024-04-11 15:12 ` [PATCH 021/437] char/ipmi: " Jens Axboe
2024-04-11 15:12 ` [PATCH 022/437] char/tpm: " Jens Axboe
2024-04-11 15:12 ` [PATCH 023/437] char/lp: " Jens Axboe
2024-04-11 15:12 ` [PATCH 024/437] char/mem: " Jens Axboe
2024-04-11 15:12 ` [PATCH 025/437] char/mwave: " Jens Axboe
2024-04-11 15:12 ` [PATCH 026/437] char/nvram: " Jens Axboe
2024-04-11 15:12 ` [PATCH 027/437] char/nwbutton: " Jens Axboe
2024-04-11 15:12 ` [PATCH 028/437] char/nwflash: " Jens Axboe
2024-04-11 15:12 ` [PATCH 029/437] char/pc8736x_gpio: " Jens Axboe
2024-04-11 15:12 ` [PATCH 030/437] char/powernv-op-panel: " Jens Axboe
2024-04-11 15:12 ` [PATCH 031/437] char/ppdev: " Jens Axboe
2024-04-11 15:12 ` [PATCH 032/437] char/ps3flash: " Jens Axboe
2024-04-11 15:12 ` [PATCH 033/437] char/scx200_gpio: " Jens Axboe
2024-04-11 15:12 ` [PATCH 034/437] char/sonypi: " Jens Axboe
2024-04-11 15:12 ` [PATCH 035/437] char/tlclk: " Jens Axboe
2024-04-11 15:12 ` [PATCH 036/437] char/xilinx_hwicap: " Jens Axboe
2024-04-11 15:12 ` [PATCH 037/437] char/xillybus: " Jens Axboe
2024-04-11 15:12 ` [PATCH 038/437] debugfs: convert to ->read_iter() Jens Axboe
2024-04-11 15:12 ` [PATCH 039/437] libfs: switch to read iter and add copy helpers Jens Axboe
2024-04-11 15:13 ` [PATCH 040/437] fs: convert generic_read_dir() to ->read_iter() Jens Axboe
2024-04-11 15:13 ` [PATCH 041/437] fs: convert any user of fops->read() for seq_read to read_iter Jens Axboe
2024-04-11 15:13 ` [PATCH 042/437] ceph: convert read_dir handler to read_iter() Jens Axboe
2024-04-11 15:13 ` [PATCH 043/437] ecryptfs: miscdev: convert to read/write iterators Jens Axboe
2024-04-11 15:13 ` [PATCH 044/437] ocfs2: " Jens Axboe
2024-04-11 15:13 ` [PATCH 045/437] orangefs: " Jens Axboe
2024-04-11 15:13 ` [PATCH 046/437] dlm: " Jens Axboe
2024-04-11 15:13 ` [PATCH 047/437] tracefs: " Jens Axboe
2024-04-11 15:13 ` [PATCH 048/437] ubifs: " Jens Axboe
2024-04-11 15:13 ` [PATCH 049/437] fuse: " Jens Axboe
2024-04-11 15:13 ` [PATCH 050/437] staging: convert drivers " Jens Axboe
2024-04-11 15:13 ` [PATCH 051/437] Bluetooth: convert " Jens Axboe
2024-04-11 15:13 ` [PATCH 052/437] net: mac80211: " Jens Axboe
2024-04-11 15:13 ` [PATCH 053/437] net: 6lowpan: convert debugfs " Jens Axboe
2024-04-11 15:13 ` [PATCH 054/437] net: sunrpc: convert " Jens Axboe
2024-04-11 15:13 ` [PATCH 055/437] net: wireless: " Jens Axboe
2024-04-11 15:13 ` [PATCH 056/437] net: rfkill: " Jens Axboe
2024-04-11 15:13 ` [PATCH 057/437] net: l2tp: " Jens Axboe
2024-04-11 15:13 ` [PATCH 058/437] fs: add IOCB_VECTORED flags Jens Axboe
2024-04-11 15:13 ` [PATCH 059/437] ALSA: core: convert to read/write iterators Jens Axboe
2024-04-11 15:13 ` [PATCH 060/437] ASoC: Intel: " Jens Axboe
2024-04-11 15:13 ` [PATCH 061/437] ASoC: fsl: " Jens Axboe
2024-04-11 15:13 ` [PATCH 062/437] ALSA: pcmtest: " Jens Axboe
2024-04-11 15:13 ` [PATCH 063/437] sound/oss/dmasound: " Jens Axboe
2024-04-11 15:13 ` [PATCH 064/437] ASoC: SOF: icp3-dtrace: " Jens Axboe
2024-04-11 15:13 ` [PATCH 065/437] SoC: SOF: icp4: " Jens Axboe
2024-04-11 15:13 ` [PATCH 066/437] ASoC: SOF: Core: " Jens Axboe
2024-04-11 15:13 ` [PATCH 067/437] ASoC: SOF: " Jens Axboe
2024-04-11 15:13 ` [PATCH 068/437] block: " Jens Axboe
2024-04-11 15:13 ` [PATCH 069/437] bpf: " Jens Axboe
2024-04-11 15:13 ` [PATCH 070/437] perf: convert events " Jens Axboe
2024-04-11 15:13 ` [PATCH 071/437] dma-debug: convert " Jens Axboe
2024-04-11 15:13 ` [PATCH 072/437] kernel/fail_function: " Jens Axboe
2024-04-11 15:13 ` [PATCH 073/437] kcsan: " Jens Axboe
2024-04-11 15:13 ` [PATCH 074/437] module: " Jens Axboe
2024-04-11 15:13 ` [PATCH 075/437] kernel/power: " Jens Axboe
2024-04-11 15:13 ` [PATCH 076/437] printk: " Jens Axboe
2024-04-11 15:13 ` [PATCH 077/437] relay: " Jens Axboe
2024-04-11 15:13 ` [PATCH 078/437] kernel/time: " Jens Axboe
2024-04-11 15:13 ` [PATCH 079/437] rv: " Jens Axboe
2024-04-11 15:13 ` [PATCH 080/437] tracing: " Jens Axboe
2024-04-11 15:13 ` [PATCH 081/437] gcov: " Jens Axboe
2024-04-11 15:13 ` [PATCH 082/437] sched/debug: " Jens Axboe
2024-04-11 15:13 ` [PATCH 083/437] kernel/irq: convert debugfs helpers " Jens Axboe
2024-04-11 15:13 ` [PATCH 084/437] locking/lock_events: convert " Jens Axboe
2024-04-11 15:13 ` [PATCH 085/437] kprobes: " Jens Axboe
2024-04-11 15:13 ` [PATCH 086/437] fs: add iterator based version of simple_transaction_read() Jens Axboe
2024-04-11 15:13 ` [PATCH 087/437] tomoyo: convert to read/write iterators Jens Axboe
2024-04-11 15:13 ` [PATCH 088/437] smack: " Jens Axboe
2024-04-11 15:13 ` [PATCH 089/437] apparmor: " Jens Axboe
2024-04-11 15:13 ` [PATCH 090/437] landlock: " Jens Axboe
2024-04-11 15:13 ` [PATCH 091/437] lsm: " Jens Axboe
2024-04-11 15:13 ` [PATCH 092/437] selinux: " Jens Axboe
2024-04-11 15:13 ` [PATCH 093/437] integrity: " Jens Axboe
2024-04-11 15:13 ` [PATCH 094/437] lockdown: " Jens Axboe
2024-04-11 15:13 ` [PATCH 095/437] security: " Jens Axboe
2024-04-11 15:13 ` [PATCH 096/437] mm: " Jens Axboe
2024-04-11 15:13 ` [PATCH 097/437] aoe: " Jens Axboe
2024-04-11 15:13 ` [PATCH 098/437] drbd: " Jens Axboe
2024-04-11 15:13 ` [PATCH 099/437] mtip32xx: " Jens Axboe
2024-04-11 15:14 ` [PATCH 100/437] zram: " Jens Axboe
2024-04-11 15:14 ` [PATCH 101/437] s390/dasd: " Jens Axboe
2024-04-11 15:14 ` [PATCH 102/437] lib: " Jens Axboe
2024-04-11 15:14 ` [PATCH 103/437] ipc: " Jens Axboe
2024-04-11 15:14 ` [PATCH 104/437] drivers/accel: " Jens Axboe
2024-04-11 15:14 ` [PATCH 105/437] drivers/acpi: " Jens Axboe
2024-04-11 15:14 ` [PATCH 106/437] crypto: hisilicon: " Jens Axboe
2024-04-11 15:14 ` [PATCH 107/437] crypto: iaa: " Jens Axboe
2024-04-11 15:14 ` [PATCH 108/437] crypto: qat: " Jens Axboe
2024-04-11 15:14 ` [PATCH 109/437] crypto: cpp: " Jens Axboe
2024-04-11 15:14 ` [PATCH 110/437] fs/pstore: " Jens Axboe
2024-04-11 15:14 ` [PATCH 111/437] drivers/gpio: convert to ->read_iter and ->write_iter Jens Axboe
2024-04-11 15:14 ` [PATCH 112/437] drivers/bluetooth: convert to read/write iterators Jens Axboe
2024-04-11 15:14 ` [PATCH 113/437] drivers/ras: " Jens Axboe
2024-04-11 15:14 ` [PATCH 114/437] fs/efivars: " Jens Axboe
2024-04-11 15:14 ` [PATCH 115/437] drivers/comedi: " Jens Axboe
2024-04-11 15:14 ` [PATCH 116/437] drivers/counter: " Jens Axboe
2024-04-11 15:14 ` [PATCH 117/437] drivers/hid: " Jens Axboe
2024-04-11 15:14 ` [PATCH 118/437] drivers/tty: convert to ->read_iter and ->write_iter Jens Axboe
2024-04-11 15:14 ` [PATCH 119/437] drivers/auxdisplay: convert to read/write iterators Jens Axboe
2024-04-11 15:14 ` [PATCH 120/437] fs/eventfd: " Jens Axboe
2024-04-11 15:14 ` [PATCH 121/437] drivers/input: " Jens Axboe
2024-04-11 15:14 ` [PATCH 122/437] drivers/pci: " Jens Axboe
2024-04-11 15:14 ` [PATCH 123/437] fs/fuse: " Jens Axboe
2024-04-11 15:14 ` [PATCH 124/437] firmware: arm_scmi: " Jens Axboe
2024-04-11 15:14 ` [PATCH 125/437] firmware: cirrus: " Jens Axboe
2024-04-11 15:14 ` [PATCH 126/437] firmware: efi: " Jens Axboe
2024-04-11 15:14 ` [PATCH 127/437] firmware: psci: " Jens Axboe
2024-04-11 15:14 ` [PATCH 128/437] firmware: turris-mox-rwtm: " Jens Axboe
2024-04-11 15:14 ` [PATCH 129/437] firmware: tegra: " Jens Axboe
2024-04-11 15:14 ` [PATCH 130/437] drivers/i2c: " Jens Axboe
2024-04-11 15:14 ` [PATCH 131/437] drivers/opp: " Jens Axboe
2024-04-11 15:14 ` [PATCH 132/437] drivers/base: " Jens Axboe
2024-04-11 15:14 ` [PATCH 133/437] drivers/bus: " Jens Axboe
2024-04-11 15:14 ` [PATCH 134/437] drivers/regulator: " Jens Axboe
2024-04-11 15:14 ` [PATCH 135/437] fs/notify: " Jens Axboe
2024-04-11 15:14 ` [PATCH 136/437] drm: switch drm_read() to be iterator based Jens Axboe
2024-04-11 15:14 ` [PATCH 137/437] drm: convert debugfs helpers to be read/write " Jens Axboe
2024-04-11 15:14 ` [PATCH 138/437] drm/i915: convert to read/write iterators Jens Axboe
2024-04-11 15:14 ` [PATCH 139/437] drm: amd: " Jens Axboe
2024-04-11 15:14 ` [PATCH 140/437] drm: msm: " Jens Axboe
2024-04-11 15:14 ` [PATCH 141/437] drm: nouveau: " Jens Axboe
2024-04-11 15:14 ` [PATCH 142/437] drm: mipi: " Jens Axboe
2024-04-11 15:14 ` [PATCH 143/437] drm: mali: " Jens Axboe
2024-04-11 15:14 ` [PATCH 144/437] drm/bridge: it6505: " Jens Axboe
2024-04-11 15:14 ` [PATCH 145/437] drm/imagination: " Jens Axboe
2024-04-11 15:14 ` [PATCH 146/437] drm/loongson: " Jens Axboe
2024-04-11 15:14 ` [PATCH 147/437] drm/radeon/radeon_ttm: " Jens Axboe
2024-04-11 15:14 ` [PATCH 148/437] drm: armada: " Jens Axboe
2024-04-11 15:14 ` [PATCH 149/437] drm: omap: " Jens Axboe
2024-04-11 15:14 ` [PATCH 150/437] vga_switcheroo: " Jens Axboe
2024-04-11 15:14 ` [PATCH 151/437] drivers/clk: " Jens Axboe
2024-04-11 15:14 ` [PATCH 152/437] drivers/rtc: " Jens Axboe
2024-04-11 15:14 ` [PATCH 153/437] drivers/dma: " Jens Axboe
2024-04-11 15:14 ` [PATCH 154/437] fs/debugfs: " Jens Axboe
2024-04-11 15:14 ` [PATCH 155/437] HID: usbhid: " Jens Axboe
2024-04-11 15:14 ` [PATCH 156/437] usb: chipidea: " Jens Axboe
2024-04-11 15:14 ` [PATCH 157/437] usb: class: " Jens Axboe
2024-04-11 15:14 ` [PATCH 158/437] usb: core: " Jens Axboe
2024-04-11 15:14 ` [PATCH 159/437] usb: dwc2: " Jens Axboe
2024-04-11 15:15 ` [PATCH 160/437] usb: dwc3: " Jens Axboe
2024-04-11 15:15 ` [PATCH 161/437] usb: fotg210-hcd: " Jens Axboe
2024-04-11 15:15 ` [PATCH 162/437] usb: gadget: " Jens Axboe
2024-04-11 15:15 ` [PATCH 163/437] usb: host: ehci: " Jens Axboe
2024-04-11 15:15 ` [PATCH 164/437] usb: host: ohci: " Jens Axboe
2024-04-11 15:15 ` [PATCH 165/437] usb: host: uhci: " Jens Axboe
2024-04-11 15:15 ` [PATCH 166/437] usb: host: xhci: " Jens Axboe
2024-04-11 15:15 ` [PATCH 167/437] usb: image: mdc800: " Jens Axboe
2024-04-11 15:15 ` [PATCH 168/437] usb: misc: " Jens Axboe
2024-04-11 15:15 ` [PATCH 169/437] usb: mon: " Jens Axboe
2024-04-11 15:15 ` [PATCH 170/437] usb: mtu3: " Jens Axboe
2024-04-11 15:15 ` [PATCH 171/437] usb: musb: " Jens Axboe
2024-04-11 15:15 ` [PATCH 172/437] usb: skeleton: " Jens Axboe
2024-04-11 15:15 ` [PATCH 173/437] usb: gadget: atmel_usba_udc: " Jens Axboe
2024-04-11 15:15 ` [PATCH 174/437] soc: qcom: " Jens Axboe
2024-04-11 15:15 ` [PATCH 175/437] soc: aspeed: " Jens Axboe
2024-04-11 15:15 ` [PATCH 176/437] soc: fsl: " Jens Axboe
2024-04-11 15:15 ` [PATCH 177/437] soc: mediatek: " Jens Axboe
2024-04-11 15:15 ` [PATCH 178/437] soc: sifive: ccache: " Jens Axboe
2024-04-11 15:15 ` [PATCH 179/437] drivers/pinctrl: convert to ->read_iter and ->write_iter Jens Axboe
2024-04-11 15:15 ` [PATCH 180/437] drivers/phy: " Jens Axboe
2024-04-11 15:15 ` [PATCH 181/437] drivers/ufs: " Jens Axboe
2024-04-11 15:15 ` [PATCH 182/437] drivers/uio: " Jens Axboe
2024-04-11 15:15 ` [PATCH 183/437] drivers/platform: " Jens Axboe
2024-04-11 15:15 ` [PATCH 184/437] drivers/mtd: " Jens Axboe
2024-04-11 15:15 ` [PATCH 185/437] scsi: bfa: convert to read/write iterators Jens Axboe
2024-04-11 15:15 ` [PATCH 186/437] scsi: csiostor: " Jens Axboe
2024-04-11 15:15 ` [PATCH 187/437] scsi: fnic: " Jens Axboe
2024-04-11 15:15 ` [PATCH 188/437] scsi: hisi_sas: " Jens Axboe
2024-04-11 15:15 ` [PATCH 189/437] scsi: lpfc: " Jens Axboe
2024-04-11 15:15 ` [PATCH 190/437] scsi: megaraid: " Jens Axboe
2024-04-11 15:15 ` [PATCH 191/437] scsi: mpt3sas: " Jens Axboe
2024-04-11 15:15 ` [PATCH 192/437] scsi: qedf: " Jens Axboe
2024-04-11 15:15 ` [PATCH 193/437] scsi: qedi: " Jens Axboe
2024-04-11 15:15 ` [PATCH 194/437] scsi: qla2xxx: " Jens Axboe
2024-04-11 15:15 ` [PATCH 195/437] scsi: snic: " Jens Axboe
2024-04-11 15:15 ` [PATCH 196/437] scsi: cxlflash: " Jens Axboe
2024-04-11 15:15 ` [PATCH 197/437] scsi: scsi_debug: " Jens Axboe
2024-04-11 15:15 ` [PATCH 198/437] scsi: sg: " Jens Axboe
2024-04-11 15:15 ` [PATCH 199/437] scsi: st: " Jens Axboe
2024-04-11 15:15 ` [PATCH 200/437] staging: axis: " Jens Axboe
2024-04-11 15:15 ` [PATCH 201/437] staging: fieldbus: " Jens Axboe
2024-04-11 15:15 ` [PATCH 202/437] staging: greybus: " Jens Axboe
2024-04-11 15:15 ` [PATCH 203/437] staging: av7110: " Jens Axboe
2024-04-11 15:15 ` [PATCH 204/437] staging: vc04_services: " Jens Axboe
2024-04-11 15:15 ` [PATCH 205/437] drivers/xen: convert to ->read_iter and ->write_iter Jens Axboe
2024-04-11 15:15 ` [PATCH 206/437] virt: " Jens Axboe
2024-04-11 15:15 ` [PATCH 207/437] virt: fsl_hypervisor: convert to read/write iterators Jens Axboe
2024-04-11 15:15 ` [PATCH 208/437] drivers/video: convert to ->read_iter and ->write_iter Jens Axboe
2024-04-11 15:15 ` [PATCH 209/437] video: fbdev: pxa3xx-gcu: convert to read/write iterators Jens Axboe
2024-04-11 15:15 ` [PATCH 210/437] drivers/iommu: convert intel iommu " Jens Axboe
2024-04-11 15:15 ` [PATCH 211/437] drivers/iommu: convert omap " Jens Axboe
2024-04-11 15:15 ` [PATCH 212/437] misc: bcm_vk: convert to iterators Jens Axboe
2024-04-11 15:15 ` [PATCH 213/437] misc: lis3lv02d: " Jens Axboe
2024-04-11 15:15 ` [PATCH 214/437] misc: eeprom/idt_89hpesx: convert to read/write iterators Jens Axboe
2024-04-11 15:15 ` [PATCH 215/437] misc: hpilo: " Jens Axboe
2024-04-11 15:15 ` [PATCH 216/437] misc: lkdtm: " Jens Axboe
2024-04-11 15:15 ` [PATCH 217/437] misc: open-dice: " Jens Axboe
2024-04-11 15:15 ` [PATCH 218/437] misc: tps6594-pfsm: " Jens Axboe
2024-04-11 15:15 ` [PATCH 219/437] misc: ibmvmc: " Jens Axboe
2024-04-11 15:16 ` [PATCH 220/437] misc: cxl: " Jens Axboe
2024-04-11 15:16 ` [PATCH 221/437] misc: ocxl: " Jens Axboe
2024-04-11 15:16 ` [PATCH 222/437] drivers/isdn: " Jens Axboe
2024-04-11 15:16 ` [PATCH 223/437] drivers/leds: " Jens Axboe
2024-04-11 15:16 ` [PATCH 224/437] drivers/mailbox: " Jens Axboe
2024-04-11 15:16 ` [PATCH 225/437] drivers/mfd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 226/437] drivers/misc/mei: " Jens Axboe
2024-04-11 15:16 ` [PATCH 227/437] misc: ibmasm: " Jens Axboe
2024-04-11 15:16 ` [PATCH 228/437] drivers/spi: " Jens Axboe
2024-04-11 15:16 ` [PATCH 229/437] drivers/nfc: " Jens Axboe
2024-04-11 15:16 ` [PATCH 230/437] drivers/nvme: " Jens Axboe
2024-04-11 15:16 ` [PATCH 231/437] drivers/firewire: " Jens Axboe
2024-04-11 15:16 ` [PATCH 232/437] drivers/mfd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 233/437] watchdog: acquirewdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 234/437] watchdog: advantechwdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 235/437] watchdog: alim1535_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 236/437] watchdog: alim7101_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 237/437] watchdog: at91rm9200_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 238/437] watchdog: cpu5wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 239/437] watchdog: eurotechwdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 240/437] watchdog: geodewdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 241/437] watchdog: ib700wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 242/437] watchdog: ibmasr: " Jens Axboe
2024-04-11 15:16 ` [PATCH 243/437] watchdog: it8712f_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 244/437] watchdog: machzwd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 245/437] watchdog: mei_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 246/437] watchdog: nv_tco: " Jens Axboe
2024-04-11 15:16 ` [PATCH 247/437] watchdog: pc87413_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 248/437] watchdog: pcwd_pci: " Jens Axboe
2024-04-11 15:16 ` [PATCH 249/437] watchdog: pcwd_usb: " Jens Axboe
2024-04-11 15:16 ` [PATCH 250/437] watchdog: rdc321x_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 251/437] watchdog: sa1100_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 252/437] watchdog: sbc60xxwdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 253/437] watchdog: sbc_epx_c3: " Jens Axboe
2024-04-11 15:16 ` [PATCH 254/437] watchdog: sbc_fitpc2_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 255/437] watchdog: sc1200wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 256/437] watchdog: sc520_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 257/437] watchdog: sch311x_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 258/437] watchdog: smsc37b787_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 259/437] watchdog: w83877f_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 260/437] watchdog: w83977f_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 261/437] watchdog: wafer5823wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 262/437] watchdog: watchdog_dev: " Jens Axboe
2024-04-11 15:16 ` [PATCH 263/437] watchdog: wdt_pci: " Jens Axboe
2024-04-11 15:16 ` [PATCH 264/437] watchdog: ath79_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 265/437] watchdog: cpwd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 266/437] watchdog: gef_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 267/437] watchdog: indydog: " Jens Axboe
2024-04-11 15:16 ` [PATCH 268/437] watchdog: m54xx_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 269/437] watchdog: mixcomwd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 270/437] watchdog: mtx-1_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 271/437] watchdog: pcwd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 272/437] watchdog: pika_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 273/437] watchdog: rc32434_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 274/437] watchdog: riowd: " Jens Axboe
2024-04-11 15:16 ` [PATCH 275/437] watchdog: sb_wdog: " Jens Axboe
2024-04-11 15:16 ` [PATCH 276/437] watchdog: sbc7240_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 277/437] watchdog: sbc8360: " Jens Axboe
2024-04-11 15:16 ` [PATCH 278/437] watchdog: scx200_wdt: " Jens Axboe
2024-04-11 15:16 ` [PATCH 279/437] watchdog: wdrtas: " Jens Axboe
2024-04-11 15:17 ` [PATCH 280/437] watchdog: wdt: " Jens Axboe
2024-04-11 15:17 ` [PATCH 281/437] watchdog: wdt285: " Jens Axboe
2024-04-11 15:17 ` [PATCH 282/437] watchdog: wdt977: " Jens Axboe
2024-04-11 15:17 ` [PATCH 283/437] fs/binfmt_misc: " Jens Axboe
2024-04-11 15:17 ` [PATCH 284/437] fs/coda: " Jens Axboe
2024-04-11 15:17 ` [PATCH 285/437] fs/nfsd: " Jens Axboe
2024-04-11 15:17 ` [PATCH 286/437] ubifs: " Jens Axboe
2024-04-11 15:17 ` [PATCH 287/437] cachefiles: " Jens Axboe
2024-04-11 15:17 ` [PATCH 288/437] fs/xfs: " Jens Axboe
2024-04-11 15:17 ` [PATCH 289/437] fs/bcachefs: " Jens Axboe
2024-04-11 15:17 ` [PATCH 290/437] fs/ocfs2: " Jens Axboe
2024-04-11 15:17 ` [PATCH 291/437] drivers/net/wireless/marvell: " Jens Axboe
2024-04-11 15:17 ` [PATCH 292/437] fs/proc: " Jens Axboe
2024-04-11 15:17 ` [PATCH 293/437] fs: convert fs_open " Jens Axboe
2024-04-11 15:17 ` [PATCH 294/437] openpromfs: convert " Jens Axboe
2024-04-11 15:17 ` [PATCH 295/437] drivers/net/wireless/ti: " Jens Axboe
2024-04-11 15:17 ` [PATCH 296/437] drivers/net/wireless/intel: " Jens Axboe
2024-04-11 15:17 ` [PATCH 297/437] drivers/net/wireless/mediatek: " Jens Axboe
2024-04-11 15:17 ` [PATCH 298/437] drivers/net/wireless/ath/ath5k: " Jens Axboe
2024-04-11 15:17 ` [PATCH 299/437] drivers/net/wireless/ath/ath6kl: " Jens Axboe
2024-04-11 15:17 ` [PATCH 300/437] drivers/net/wireless/ath/carl9170: " Jens Axboe
2024-04-11 15:17 ` [PATCH 301/437] drivers/net/wireless/ath/wcn36xx: " Jens Axboe
2024-04-11 15:17 ` [PATCH 302/437] drivers/net/wireless/ath/wil6210: " Jens Axboe
2024-04-11 15:17 ` [PATCH 303/437] drivers/net/wireless/ath/ath9k: " Jens Axboe
2024-04-11 15:17 ` [PATCH 304/437] drivers/net/wireless/ath/ath10k: " Jens Axboe
2024-04-11 15:17 ` [PATCH 305/437] drivers/net/wireless/ath/ath11k: " Jens Axboe
2024-04-11 15:17 ` [PATCH 306/437] drivers/net/wireless/broadcom: " Jens Axboe
2024-04-11 15:17 ` [PATCH 307/437] drivers/net/wireless/ralink: " Jens Axboe
2024-04-11 15:17 ` [PATCH 308/437] wifi: rtlwifi: convert debugfs helpers " Jens Axboe
2024-04-11 15:17 ` [PATCH 309/437] wifi: rtw88: " Jens Axboe
2024-04-11 15:17 ` [PATCH 310/437] wifi: rtw89: " Jens Axboe
2024-04-11 15:17 ` [PATCH 311/437] wifi: rsi: rsi_91x_debugfs: convert " Jens Axboe
2024-04-11 15:17 ` [PATCH 312/437] drivers/net/wireless/silabs: " Jens Axboe
2024-04-11 15:17 ` [PATCH 313/437] drivers/net/wireless/st: " Jens Axboe
2024-04-11 15:17 ` [PATCH 314/437] drivers/net/ieee802154: " Jens Axboe
2024-04-11 15:17 ` [PATCH 315/437] drivers/net/netdevsim: " Jens Axboe
2024-04-11 15:17 ` [PATCH 316/437] drivers/net/ppp: " Jens Axboe
2024-04-11 15:17 ` [PATCH 317/437] drivers/net/wwan: " Jens Axboe
2024-04-11 15:17 ` [PATCH 318/437] drivers/net/xen-netback: " Jens Axboe
2024-04-11 15:17 ` [PATCH 319/437] drivers/net/ethernet/broadcom-bnxt: " Jens Axboe
2024-04-11 15:17 ` [PATCH 320/437] drivers/net/brocade-bnad: ensure the copied buf is NULL terminated Jens Axboe
2024-04-11 15:17 ` [PATCH 321/437] drivers/net/brocade-bnad: convert to read/write iterators Jens Axboe
2024-04-11 15:17 ` [PATCH 322/437] drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated Jens Axboe
2024-04-11 15:17 ` [PATCH 323/437] drivers/net/ethernet/intel: convert to read/write iterators Jens Axboe
2024-04-11 15:17 ` [PATCH 324/437] drivers/net/ethernet/chelsio: " Jens Axboe
2024-04-11 15:17 ` [PATCH 325/437] drivers/net/ethernet/hisilicon: " Jens Axboe
2024-04-11 15:17 ` [PATCH 326/437] drivers/net/ethernet/huawei: " Jens Axboe
2024-04-11 15:17 ` [PATCH 327/437] drivers/net/ethernet/amd-xgbe: " Jens Axboe
2024-04-11 15:17 ` [PATCH 328/437] drivers/net/ethernet/marvell/octeontx2: " Jens Axboe
2024-04-11 15:17 ` [PATCH 329/437] drivers/net/ethernet/mellanox/mlx5/core: " Jens Axboe
2024-04-11 15:17 ` [PATCH 330/437] x86/kernel: " Jens Axboe
2024-04-11 15:17 ` [PATCH 331/437] x86/kvm: " Jens Axboe
2024-04-11 15:17 ` [PATCH 332/437] x86/mm: " Jens Axboe
2024-04-11 15:17 ` [PATCH 333/437] arch/arm: " Jens Axboe
2024-04-11 15:17 ` [PATCH 334/437] arch/mips: " Jens Axboe
2024-04-11 15:17 ` [PATCH 335/437] parisc: eisa_eeprom: " Jens Axboe
2024-04-11 15:17 ` [PATCH 336/437] arch/parisc: " Jens Axboe
2024-04-11 15:17 ` [PATCH 337/437] powerpc/kernel: " Jens Axboe
2024-04-11 15:17 ` [PATCH 338/437] powerpc/kvm: " Jens Axboe
2024-04-11 15:17 ` [PATCH 339/437] powerpc/spufs: " Jens Axboe
2024-04-11 15:18 ` [PATCH 340/437] powerpc/platforms: " Jens Axboe
2024-04-11 15:18 ` [PATCH 341/437] s390: cio: " Jens Axboe
2024-04-11 15:18 ` [PATCH 342/437] s390: fs3270: " Jens Axboe
2024-04-11 15:18 ` [PATCH 343/437] s390: hmcdrv: " Jens Axboe
2024-04-11 15:18 ` [PATCH 344/437] s390: tape_char: " Jens Axboe
2024-04-11 15:18 ` [PATCH 345/437] s390: vmcp: " Jens Axboe
2024-04-11 15:18 ` [PATCH 346/437] s390: vmur: " Jens Axboe
2024-04-11 15:18 ` [PATCH 347/437] s390: zcore: " Jens Axboe
2024-04-11 15:18 ` [PATCH 348/437] s390: crypto: " Jens Axboe
2024-04-11 15:18 ` [PATCH 349/437] s390: monreader: " Jens Axboe
2024-04-11 15:18 ` [PATCH 350/437] s390: monwriter: " Jens Axboe
2024-04-11 15:18 ` [PATCH 351/437] s390: hw_random: " Jens Axboe
2024-04-11 15:18 ` [PATCH 352/437] s390: vmlogrdr: " Jens Axboe
2024-04-11 15:18 ` [PATCH 353/437] arch/s390: " Jens Axboe
2024-04-11 15:18 ` [PATCH 354/437] arch/sh: " Jens Axboe
2024-04-11 15:18 ` [PATCH 355/437] arch/um: " Jens Axboe
2024-04-11 15:18 ` [PATCH 356/437] arch/sparc: " Jens Axboe
2024-04-11 15:18 ` [PATCH 357/437] samples/vfio-mdev: " Jens Axboe
2024-04-11 15:18 ` [PATCH 358/437] hwmon: fschmd: " Jens Axboe
2024-04-11 15:18 ` [PATCH 359/437] hwmon: w83793: " Jens Axboe
2024-04-11 15:18 ` [PATCH 360/437] hwmon: asus_atk0110: " Jens Axboe
2024-04-11 15:18 ` [PATCH 361/437] hwmon: mr75203: " Jens Axboe
2024-04-11 15:18 ` [PATCH 362/437] hwmon: acbel-fsg032: " Jens Axboe
2024-04-11 15:18 ` [PATCH 363/437] hwmon: ibm-cffps: " Jens Axboe
2024-04-11 15:18 ` [PATCH 364/437] hwmon: max20730: " Jens Axboe
2024-04-11 15:18 ` [PATCH 365/437] hwmon: pmbus: core: " Jens Axboe
2024-04-11 15:18 ` [PATCH 366/437] hwmon: q54sj108a2: " Jens Axboe
2024-04-11 15:18 ` [PATCH 367/437] hwmon: ucd9000: " Jens Axboe
2024-04-11 15:18 ` [PATCH 368/437] hwmon: pt5161l: " Jens Axboe
2024-04-11 15:18 ` [PATCH 369/437] drivers/mmc: " Jens Axboe
2024-04-11 15:18 ` [PATCH 370/437] drivers/most: " Jens Axboe
2024-04-11 15:18 ` [PATCH 371/437] drivers/ntb: " Jens Axboe
2024-04-11 15:18 ` [PATCH 372/437] drivers/md: convert bcache " Jens Axboe
2024-04-11 15:18 ` [PATCH 373/437] drivers/remoteproc: convert " Jens Axboe
2024-04-11 15:18 ` [PATCH 374/437] drivers/thunderbolt: " Jens Axboe
2024-04-11 15:18 ` [PATCH 375/437] drivers/vfio: " Jens Axboe
2024-04-11 15:18 ` [PATCH 376/437] drivers/fsi: " Jens Axboe
2024-04-11 15:18 ` [PATCH 377/437] iio: " Jens Axboe
2024-04-11 15:18 ` [PATCH 378/437] iio: adis16400: " Jens Axboe
2024-04-11 15:18 ` [PATCH 379/437] iio: adis16475: " Jens Axboe
2024-04-11 15:18 ` [PATCH 380/437] iio: adis16480: " Jens Axboe
2024-04-11 15:18 ` [PATCH 381/437] iio: bno055: " Jens Axboe
2024-04-11 15:18 ` [PATCH 382/437] iio: gyro/adis16136: " Jens Axboe
2024-04-11 15:18 ` [PATCH 383/437] intel_th: " Jens Axboe
2024-04-11 15:18 ` [PATCH 384/437] stm class: " Jens Axboe
2024-04-11 15:18 ` [PATCH 385/437] speakup: " Jens Axboe
2024-04-11 15:18 ` [PATCH 386/437] EDAC/versal: " Jens Axboe
2024-04-11 15:18 ` [PATCH 387/437] EDAC/xgene: " Jens Axboe
2024-04-11 15:18 ` [PATCH 388/437] EDAC/zynqmp: " Jens Axboe
2024-04-11 15:18 ` [PATCH 389/437] EDAC/thunderx: " Jens Axboe
2024-04-11 15:18 ` [PATCH 390/437] EDAC/npcm: " Jens Axboe
2024-04-11 15:18 ` [PATCH 391/437] EDAC/i5100: " Jens Axboe
2024-04-11 15:18 ` [PATCH 392/437] EDAC/altera: " Jens Axboe
2024-04-11 15:18 ` [PATCH 393/437] EDAC/debugfs: " Jens Axboe
2024-04-11 15:18 ` [PATCH 394/437] drivers/hsi: " Jens Axboe
2024-04-11 15:18 ` [PATCH 395/437] hsi: clients: cmt_speech: " Jens Axboe
2024-04-11 15:18 ` [PATCH 396/437] macintosh: adb: " Jens Axboe
2024-04-11 15:18 ` [PATCH 397/437] macintosh: ans-lcd: " Jens Axboe
2024-04-11 15:18 ` [PATCH 398/437] macintosh: smu: " Jens Axboe
2024-04-11 15:18 ` [PATCH 399/437] macintosh: via-pmu: " Jens Axboe
2024-04-11 15:19 ` [PATCH 400/437] drivers/extcon: " Jens Axboe
2024-04-11 15:19 ` [PATCH 401/437] drivers/gnss: " Jens Axboe
2024-04-11 15:19 ` [PATCH 402/437] drivers/rapidio: " Jens Axboe
2024-04-11 15:19 ` [PATCH 403/437] drivers/media/platform/mediatek/vcodec: " Jens Axboe
2024-04-11 15:19 ` [PATCH 404/437] infiniband/core: " Jens Axboe
2024-04-11 15:19 ` [PATCH 405/437] infiniband/cxgb4: " Jens Axboe
2024-04-11 15:19 ` [PATCH 406/437] infiniband/hfi1: " Jens Axboe
2024-04-11 15:19 ` [PATCH 407/437] infiniband/mlx5: " Jens Axboe
2024-04-11 15:19 ` [PATCH 408/437] infiniband/ocrdma: " Jens Axboe
2024-04-11 15:19 ` [PATCH 409/437] infiniband/qib: " Jens Axboe
2024-04-11 15:19 ` [PATCH 410/437] infiniband/hns: " Jens Axboe
2024-04-11 15:19 ` [PATCH 411/437] infiniband/usnic: " Jens Axboe
2024-04-11 15:19 ` [PATCH 412/437] hv: " Jens Axboe
2024-04-11 15:19 ` [PATCH 413/437] media/rc: " Jens Axboe
2024-05-04 12:31   ` Mauro Carvalho Chehab
2024-05-05 13:16     ` Jens Axboe
2024-04-11 15:19 ` [PATCH 414/437] media/dvb-core: " Jens Axboe
2024-04-11 15:19 ` [PATCH 415/437] media/common: " Jens Axboe
2024-04-11 15:19 ` [PATCH 416/437] media/platform: amphion: " Jens Axboe
2024-04-11 15:19 ` [PATCH 417/437] media/platform: mediatek: " Jens Axboe
2024-04-11 15:19 ` [PATCH 418/437] media: cec: " Jens Axboe
2024-04-11 15:19 ` [PATCH 419/437] media: media-devnode: " Jens Axboe
2024-04-11 15:19 ` [PATCH 420/437] media: bt8xx: " Jens Axboe
2024-04-11 15:19 ` [PATCH 421/437] media: dbbridge: " Jens Axboe
2024-04-11 15:19 ` [PATCH 422/437] media: ngene: " Jens Axboe
2024-04-11 15:19 ` [PATCH 423/437] media: radio-si476x: " Jens Axboe
2024-04-11 15:19 ` [PATCH 424/437] media: usb: uvc: " Jens Axboe
2024-04-11 15:19 ` [PATCH 425/437] media: v4l2-dev: " Jens Axboe
2024-04-11 15:19 ` [PATCH 426/437] firmware: xilinx: " Jens Axboe
2024-04-11 15:19 ` [PATCH 427/437] hwtracing: coresight: " Jens Axboe
2024-04-11 15:19 ` [PATCH 428/437] sbus: oradax: " Jens Axboe
2024-04-11 15:19 ` [PATCH 429/437] sbus: envctrl: " Jens Axboe
2024-04-11 15:19 ` [PATCH 430/437] sbus: flash: " Jens Axboe
2024-04-11 15:19 ` [PATCH 431/437] pci: hotplug: cpqphp: " Jens Axboe
2024-04-11 15:19 ` [PATCH 432/437] seq_file: switch to using ->read_iter() Jens Axboe
2024-04-11 15:19 ` [PATCH 433/437] fs/debugfs: remove (now) dead non-iterator debugfs_attr functions Jens Axboe
2024-04-11 15:19 ` [PATCH 434/437] lib/string_helpers: kill parse_int_array_user() Jens Axboe
2024-04-11 15:19 ` [PATCH 435/437] fs: kill off non-iter variants of simple_attr_{read,write}* Jens Axboe
2024-04-11 15:19 ` [PATCH 436/437] kstrtox: remove (now) dead helpers Jens Axboe
2024-04-11 15:19 ` [PATCH 437/437] REMOVE ->read() and ->write() Jens Axboe
2024-04-12  4:29 ` [PATCHSET RFC 0/437] Kill off old fops " Al Viro
2024-04-12  4:37   ` Al Viro
2024-04-12 13:58   ` Jens Axboe
2024-04-13  4:15     ` Al Viro
2024-04-13 15:37       ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).