2024-04-11 16:13:51

by Jens Axboe

[permalink] [raw]
Subject: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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



2024-04-11 16:14:51

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 155/437] HID: usbhid: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:14:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 148/437] drm: armada: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:15:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 144/437] drm/bridge: it6505: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:15:21

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 149/437] drm: omap: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:15:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 145/437] drm/imagination: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:15:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 005/437] uio: add get/put_iter helpers

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 <[email protected]>
---
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


2024-04-11 16:16:02

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 160/437] usb: dwc3: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:16:10

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 161/437] usb: fotg210-hcd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:16:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 153/437] drivers/dma: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:16:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 154/437] fs/debugfs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:16:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 163/437] usb: host: ehci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:01

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 165/437] usb: host: uhci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 015/437] char/nsc_gpio: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:03

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 018/437] char/dtlk: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:06

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 150/437] vga_switcheroo: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:27

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 151/437] drivers/clk: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 167/437] usb: image: mdc800: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 152/437] drivers/rtc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:17:41

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 162/437] usb: gadget: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:18:07

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 170/437] usb: mtu3: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:18:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 156/437] usb: chipidea: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:18:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 158/437] usb: core: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:19:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 169/437] usb: mon: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:19:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 159/437] usb: dwc2: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:19:16

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 175/437] soc: aspeed: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:19:57

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 178/437] soc: sifive: ccache: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:20:41

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 180/437] drivers/phy: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:20:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 181/437] drivers/ufs: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:20:57

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 183/437] drivers/platform: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:21:15

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 184/437] drivers/mtd: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:21:16

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 186/437] scsi: csiostor: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:21:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 166/437] usb: host: xhci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:22:16

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 191/437] scsi: mpt3sas: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:22:18

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 168/437] usb: misc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:22:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 193/437] scsi: qedi: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:22:38

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 171/437] usb: musb: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:22:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 172/437] usb: skeleton: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:23:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 174/437] soc: qcom: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:23:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 197/437] scsi: scsi_debug: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:23:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 176/437] soc: fsl: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:23:49

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 198/437] scsi: sg: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:24:02

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 199/437] scsi: st: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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;
}
-
+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;
}
-
-
+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


2024-04-11 16:24:10

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 179/437] drivers/pinctrl: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:24:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 024/437] char/mem: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:24:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 201/437] staging: fieldbus: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:24:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 202/437] staging: greybus: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:25:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 206/437] virt: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:25:35

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 187/437] scsi: fnic: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:25:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 207/437] virt: fsl_hypervisor: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:07

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 190/437] scsi: megaraid: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:08

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 208/437] drivers/video: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:27

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 209/437] video: fbdev: pxa3xx-gcu: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 189/437] scsi: lpfc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:55

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 210/437] drivers/iommu: convert intel iommu to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:26:55

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 194/437] scsi: qla2xxx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:27:11

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 213/437] misc: lis3lv02d: convert to iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:27:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 195/437] scsi: snic: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:28:02

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 068/437] block: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:28:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 203/437] staging: av7110: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:29:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 221/437] misc: ocxl: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:29:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 211/437] drivers/iommu: convert omap to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:30:04

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 222/437] drivers/isdn: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:30:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 095/437] security: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:30:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 049/437] fuse: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:30:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 225/437] drivers/mfd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:30:57

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 218/437] misc: tps6594-pfsm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:31:03

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 219/437] misc: ibmvmc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:31:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 226/437] drivers/misc/mei: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:31:39

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 227/437] misc: ibmasm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:31:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 205/437] drivers/xen: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:31:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 200/437] staging: axis: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:01

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 228/437] drivers/spi: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:11

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 229/437] drivers/nfc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:24

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 230/437] drivers/nvme: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:25

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 231/437] drivers/firewire: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:25

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 037/437] char/xillybus: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 234/437] watchdog: advantechwdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 235/437] watchdog: alim1535_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 232/437] drivers/mfd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:33:57

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 233/437] watchdog: acquirewdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:34:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 238/437] watchdog: cpu5wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:34:31

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 239/437] watchdog: eurotechwdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:08

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 240/437] watchdog: geodewdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:10

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 041/437] fs: convert any user of fops->read() for seq_read to read_iter

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

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 242/437] watchdog: ibmasr: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 053/437] net: 6lowpan: convert debugfs to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 243/437] watchdog: it8712f_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:35:49

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 244/437] watchdog: machzwd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:36:02

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 099/437] mtip32xx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:36:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 248/437] watchdog: pcwd_pci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:36:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 217/437] misc: open-dice: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:36:50

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 216/437] misc: lkdtm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:37:04

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 212/437] misc: bcm_vk: convert to iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:37:06

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 249/437] watchdog: pcwd_usb: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:37:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 091/437] lsm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:37:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 215/437] misc: hpilo: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:37:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 246/437] watchdog: nv_tco: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 250/437] watchdog: rdc321x_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 254/437] watchdog: sbc_fitpc2_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 088/437] smack: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 251/437] watchdog: sa1100_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:38

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 252/437] watchdog: sbc60xxwdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 253/437] watchdog: sbc_epx_c3: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 255/437] watchdog: sc1200wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:38:56

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 256/437] watchdog: sc520_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:39:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 257/437] watchdog: sch311x_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:39:23

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 258/437] watchdog: smsc37b787_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:39:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 259/437] watchdog: w83877f_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:39:46

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 260/437] watchdog: w83977f_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:40:01

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 261/437] watchdog: wafer5823wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:40:10

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 262/437] watchdog: watchdog_dev: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:40:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 263/437] watchdog: wdt_pci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:40:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 264/437] watchdog: ath79_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:40:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 265/437] watchdog: cpwd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:03

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 266/437] watchdog: gef_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:18

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 267/437] watchdog: indydog: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 269/437] watchdog: mixcomwd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:41

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 270/437] watchdog: mtx-1_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 074/437] module: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:41:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 268/437] watchdog: m54xx_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:42:04

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 271/437] watchdog: pcwd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:42:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 272/437] watchdog: pika_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:42:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 273/437] watchdog: rc32434_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:42:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 274/437] watchdog: riowd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:42:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 275/437] watchdog: sb_wdog: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:43:27

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 277/437] watchdog: sbc8360: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:43:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 278/437] watchdog: scx200_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:43:58

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 280/437] watchdog: wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:44:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 282/437] watchdog: wdt977: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:44:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 283/437] fs/binfmt_misc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:44:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 285/437] fs/nfsd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:44:56

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 284/437] fs/coda: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:45:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 287/437] cachefiles: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:46:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 173/437] usb: gadget: atmel_usba_udc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:47:12

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 294/437] openpromfs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:47:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 291/437] drivers/net/wireless/marvell: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:47:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 164/437] usb: host: ohci: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:47:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 297/437] drivers/net/wireless/mediatek: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:48:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 295/437] drivers/net/wireless/ti: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:48:12

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 177/437] soc: mediatek: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:48:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 298/437] drivers/net/wireless/ath/ath5k: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:48:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 185/437] scsi: bfa: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:48:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 196/437] scsi: cxlflash: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:49:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 301/437] drivers/net/wireless/ath/wcn36xx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:49:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 296/437] drivers/net/wireless/intel: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:50:04

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 204/437] staging: vc04_services: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:50:08

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 302/437] drivers/net/wireless/ath/wil6210: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:50:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 306/437] drivers/net/wireless/broadcom: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:50:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 303/437] drivers/net/wireless/ath/ath9k: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:50:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 307/437] drivers/net/wireless/ralink: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:50:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 308/437] wifi: rtlwifi: convert debugfs helpers to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:50:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 304/437] drivers/net/wireless/ath/ath10k: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 223/437] drivers/leds: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:24

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 305/437] drivers/net/wireless/ath/ath11k: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 290/437] fs/ocfs2: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 309/437] wifi: rtw88: convert debugfs helpers to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 288/437] fs/xfs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:51:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 311/437] wifi: rsi: rsi_91x_debugfs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:52:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 157/437] usb: class: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:52:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 313/437] drivers/net/wireless/st: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:52:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 312/437] drivers/net/wireless/silabs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:53:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 220/437] misc: cxl: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:53:31

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 315/437] drivers/net/netdevsim: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:53:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 182/437] drivers/uio: convert to ->read_iter and ->write_iter

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:53:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 317/437] drivers/net/wwan: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:53:57

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 318/437] drivers/net/xen-netback: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:54:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 192/437] scsi: qedf: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:54:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 320/437] drivers/net/brocade-bnad: ensure the copied buf is NULL terminated

From: Bui Quang Minh <[email protected]>

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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:54:55

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 321/437] drivers/net/brocade-bnad: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:55:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 325/437] drivers/net/ethernet/hisilicon: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:55:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 323/437] drivers/net/ethernet/intel: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:55:23

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 324/437] drivers/net/ethernet/chelsio: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:55:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 214/437] misc: eeprom/idt_89hpesx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:55:50

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 327/437] drivers/net/ethernet/amd-xgbe: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
[axboe: fix typo in xi2c_reg_value_read_iter]
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:56:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 328/437] drivers/net/ethernet/marvell/octeontx2: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 16:56:12

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 329/437] drivers/net/ethernet/mellanox/mlx5/core: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:56:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 331/437] x86/kvm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:56:51

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 236/437] watchdog: alim7101_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:57:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 188/437] scsi: hisi_sas: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:57:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 334/437] arch/mips: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:57:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 289/437] fs/bcachefs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:57:38

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 336/437] arch/parisc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 300/437] drivers/net/wireless/ath/carl9170: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:01

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 292/437] fs/proc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:12

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 330/437] x86/kernel: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 338/437] powerpc/kvm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 332/437] x86/mm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:27

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 333/437] arch/arm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 335/437] parisc: eisa_eeprom: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:58:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 342/437] s390: fs3270: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 337/437] powerpc/kernel: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 339/437] powerpc/spufs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:23

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 341/437] s390: cio: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 343/437] s390: hmcdrv: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 344/437] s390: tape_char: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 346/437] s390: vmur: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 16:59:55

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 345/437] s390: vmcp: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:00:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 348/437] s390: crypto: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:00:31

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 349/437] s390: monreader: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:00:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 237/437] watchdog: at91rm9200_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:01:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 353/437] arch/s390: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:01:58

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 356/437] arch/sparc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:02:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 355/437] arch/um: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:02:11

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 357/437] samples/vfio-mdev: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:02:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 360/437] hwmon: asus_atk0110: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:02:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 361/437] hwmon: mr75203: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:03:07

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 362/437] hwmon: acbel-fsg032: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:03:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 245/437] watchdog: mei_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:03:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 364/437] hwmon: max20730: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:03:46

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 365/437] hwmon: pmbus: core: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:04:35

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 367/437] hwmon: ucd9000: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:04:51

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 368/437] hwmon: pt5161l: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:11

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 279/437] watchdog: wdrtas: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 370/437] drivers/most: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 372/437] drivers/md: convert bcache to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:46

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 241/437] watchdog: ib700wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 373/437] drivers/remoteproc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:05:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 371/437] drivers/ntb: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:06:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 374/437] drivers/thunderbolt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:06:34

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 375/437] drivers/vfio: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 17:06:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 247/437] watchdog: pc87413_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:06:41

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 354/437] arch/sh: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:06:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 376/437] drivers/fsi: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:06:59

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 378/437] iio: adis16400: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:07:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 351/437] s390: hw_random: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:07:19

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 379/437] iio: adis16475: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:07:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 382/437] iio: gyro/adis16136: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:08:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 383/437] intel_th: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:08:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 350/437] s390: monwriter: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:08:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 384/437] stm class: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:08:50

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 286/437] ubifs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:08:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 387/437] EDAC/xgene: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:09:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 388/437] EDAC/zynqmp: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:09:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 390/437] EDAC/npcm: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:09:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 347/437] s390: zcore: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:09:42

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 391/437] EDAC/i5100: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:09:55

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 377/437] iio: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 224/437] drivers/mailbox: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:16

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 393/437] EDAC/debugfs: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 394/437] drivers/hsi: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:39

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 293/437] fs: convert fs_open to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 380/437] iio: adis16480: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 395/437] hsi: clients: cmt_speech: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:10:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 381/437] iio: bno055: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:11:01

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 396/437] macintosh: adb: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:11:18

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 397/437] macintosh: ans-lcd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:11:31

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 385/437] speakup: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:11:44

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 398/437] macintosh: smu: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:12:06

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 401/437] drivers/gnss: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:12:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 400/437] drivers/extcon: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:12:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 402/437] drivers/rapidio: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:12:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 389/437] EDAC/thunderx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:12:30

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 403/437] drivers/media/platform/mediatek/vcodec: convert to read/write iterators

From: Krzysztof Kanas <[email protected]>

Signed-off-by: Krzysztof Kanas <[email protected]>
[axboe: fold in patch for killing FOPS helpers]
Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 17:13:02

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 392/437] EDAC/altera: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:13:17

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 299/437] drivers/net/wireless/ath/ath6kl: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:14:21

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 399/437] macintosh: via-pmu: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:15:24

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 358/437] hwmon: fschmd: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:15:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 418/437] media: cec: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:15:48

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 419/437] media: media-devnode: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:16:58

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 281/437] watchdog: wdt285: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:17:00

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 404/437] infiniband/core: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:17:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 423/437] media: radio-si476x: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:17:27

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 406/437] infiniband/hfi1: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:07

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 411/437] infiniband/usnic: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:07

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 314/437] drivers/net/ieee802154: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:24

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 412/437] hv: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:40

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 413/437] media/rc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 414/437] media/dvb-core: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:18:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 429/437] sbus: envctrl: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:19:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 430/437] sbus: flash: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:19:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 417/437] media/platform: mediatek: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:19:28

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 326/437] drivers/net/ethernet/huawei: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:20:24

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 435/437] fs: kill off non-iter variants of simple_attr_{read,write}*

They are no longer used, kill them with fire.

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:13

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 424/437] media: usb: uvc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:25

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 410/437] infiniband/hns: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 409/437] infiniband/qib: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 408/437] infiniband/ocrdma: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:32

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 407/437] infiniband/mlx5: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:43

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 415/437] media/common: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:21:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 427/437] hwtracing: coresight: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
.../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


2024-04-11 17:22:22

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 416/437] media/platform: amphion: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:22:37

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 405/437] infiniband/cxgb4: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:22:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 431/437] pci: hotplug: cpqphp: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:23:05

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 433/437] fs/debugfs: remove (now) dead non-iterator debugfs_attr functions

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:23:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 436/437] kstrtox: remove (now) dead helpers

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 <[email protected]>
---
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


2024-04-11 17:23:39

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 437/437] REMOVE ->read() and ->write()

Test patch just to check coverage.

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:24:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 316/437] drivers/net/ppp: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:26:41

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 422/437] media: ngene: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:26:49

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 425/437] media: v4l2-dev: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:26:54

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 276/437] watchdog: sbc7240_wdt: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:28:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 352/437] s390: vmlogrdr: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:31:47

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 363/437] hwmon: ibm-cffps: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:32:20

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 319/437] drivers/net/ethernet/broadcom-bnxt: convert to read/write iterators

From: Bui Quang Minh <[email protected]>

Signed-off-by: Bui Quang Minh <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:32:29

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 310/437] wifi: rtw89: convert debugfs helpers to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:36:14

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 322/437] drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated

From: Bui Quang Minh <[email protected]>

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 <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:38:03

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 359/437] hwmon: w83793: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:43:45

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 434/437] lib/string_helpers: kill parse_int_array_user()

It's no longer used, get rid of it.

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:45:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 340/437] powerpc/platforms: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:46:26

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 421/437] media: dbbridge: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:46:53

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 420/437] media: bt8xx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:47:35

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 366/437] hwmon: q54sj108a2: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:52:09

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 428/437] sbus: oradax: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:55:52

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 369/437] drivers/mmc: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:57:03

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 426/437] firmware: xilinx: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 17:58:36

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 386/437] EDAC/versal: convert to read/write iterators

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-11 18:13:33

by Jens Axboe

[permalink] [raw]
Subject: [PATCH 432/437] seq_file: switch to using ->read_iter()

There's a seq_read_iter() helper already, use it.

Signed-off-by: Jens Axboe <[email protected]>
---
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


2024-04-12 04:29:23

by Al Viro

[permalink] [raw]
Subject: Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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.

2024-04-12 07:38:48

by Al Viro

[permalink] [raw]
Subject: Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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...

2024-04-12 13:58:24

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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


2024-04-13 04:15:48

by Al Viro

[permalink] [raw]
Subject: Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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.

2024-04-13 15:38:07

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

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


2024-05-04 12:32:20

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 413/437] media/rc: convert to read/write iterators

Em Thu, 11 Apr 2024 09:19:13 -0600
Jens Axboe <[email protected]> escreveu:

> Signed-off-by: Jens Axboe <[email protected]>

Please add a patch description to media patches. Also, please
c/c [email protected], 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,

2024-05-05 13:16:55

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH 413/437] media/rc: convert to read/write iterators

On 5/4/24 6:31 AM, Mauro Carvalho Chehab wrote:
> Em Thu, 11 Apr 2024 09:19:13 -0600
> Jens Axboe <[email protected]> escreveu:
>
>> Signed-off-by: Jens Axboe <[email protected]>
>
> Please add a patch description to media patches. Also, please
> c/c [email protected], 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