[PATCH 05/28] kref.h: move declarations to kref_types.h

Max Kellermann
2024-01-31T14:50:22Z

arch/arm64/kvm/vgic/vgic.h | 1 +
block/bsg-lib.c | 1 +
drivers/acpi/acpi_ipmi.c | 1 +
drivers/acpi/ec.c | 1 +
drivers/ata/libata-core.c | 1 +
drivers/base/core.c | 1 +
drivers/char/hw_random/core.c | 1 +
drivers/char/ipmi/ipmi_msghandler.c | 1 +
drivers/char/xillybus/xillyusb.c | 1 +
drivers/clk/clk.c | 1 +
drivers/comedi/comedi_buf.c | 1 +
drivers/comedi/comedi_fops.c | 1 +
drivers/dax/bus.c | 1 +
drivers/gpu/drm/drm_auth.c | 1 +
drivers/gpu/drm/drm_connector.c | 1 +
drivers/gpu/drm/drm_drv.c | 1 +
drivers/gpu/drm/msm/msm_gem.h | 1 +
drivers/gpu/drm/nouveau/nvkm/core/memory.c | 2 ++
drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.c | 1 +
drivers/gpu/drm/nouveau/nvkm/engine/fifo/chid.c | 2 ++
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 1 +
drivers/greybus/connection.c | 1 +
drivers/greybus/operation.c | 1 +
drivers/hid/hid-core.c | 1 +
drivers/hid/hid-cougar.c | 1 +
drivers/hid/hid-debug.c | 1 +
drivers/hid/hid-logitech-dj.c | 1 +
drivers/hid/wacom_sys.c | 1 +
drivers/iio/buffer/industrialio-buffer-dma.c | 1 +
drivers/iio/industrialio-buffer.c | 1 +
drivers/infiniband/core/cache.c | 1 +
drivers/infiniband/core/cm.c | 1 +
drivers/infiniband/core/counters.c | 2 ++
drivers/infiniband/core/device.c | 1 +
drivers/infiniband/core/restrack.c | 1 +
drivers/infiniband/hw/erdma/erdma_cm.c | 1 +
drivers/infiniband/hw/erdma/erdma_qp.c | 2 ++
drivers/infiniband/hw/qedr/qedr_iw_cm.c | 2 ++
drivers/infiniband/sw/rxe/rxe_pool.h | 2 ++
drivers/infiniband/sw/rxe/rxe_queue.c | 1 +
drivers/infiniband/sw/siw/siw.h | 1 +
drivers/infiniband/ulp/isert/ib_isert.c | 1 +
drivers/infiniband/ulp/rtrs/rtrs.c | 1 +
drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
drivers/media/dvb-core/dvb_ca_en50221.c | 1 +
drivers/media/dvb-core/dvb_frontend.c | 1 +
drivers/media/dvb-core/dvbdev.c | 1 +
drivers/misc/genwqe/card_dev.c | 1 +
drivers/mtd/mtd_blkdevs.c | 1 +
.../net/ethernet/chelsio/inline_crypto/chtls/chtls.h | 1 +
.../ethernet/chelsio/inline_crypto/chtls/chtls_cm.c | 1 +
drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c | 1 +
drivers/net/ethernet/intel/ice/ice_sriov.c | 2 ++
drivers/net/ethernet/intel/ice/ice_vf_lib.c | 2 ++
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c | 1 +
drivers/net/ethernet/mellanox/mlx5/core/uar.c | 1 +
.../net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c | 1 +
drivers/net/ethernet/qlogic/qede/qede_rdma.c | 1 +
drivers/net/pse-pd/pse_core.c | 1 +
drivers/net/wireless/ath/carl9170/tx.c | 1 +
drivers/nvdimm/core.c | 1 +
drivers/nvdimm/dimm.c | 1 +
drivers/nvdimm/dimm_devs.c | 1 +
drivers/of/dynamic.c | 1 +
drivers/of/unittest.c | 1 +
drivers/pci/hotplug/acpiphp_glue.c | 1 +
drivers/pci/slot.c | 1 +
drivers/pci/switch/switchtec.c | 1 +
drivers/rpmsg/mtk_rpmsg.c | 1 +
drivers/rpmsg/qcom_glink_native.c | 1 +
drivers/rpmsg/qcom_smd.c | 1 +
drivers/rpmsg/virtio_rpmsg_bus.c | 1 +
drivers/scsi/bnx2fc/bnx2fc_els.c | 2 ++
drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 1 +
drivers/scsi/bnx2fc/bnx2fc_hwi.c | 2 ++
drivers/scsi/bnx2fc/bnx2fc_io.c | 2 ++
drivers/scsi/bnx2fc/bnx2fc_tgt.c | 3 +++
drivers/scsi/ch.c | 1 +
drivers/scsi/cxgbi/libcxgbi.h | 1 +
drivers/scsi/device_handler/scsi_dh_alua.c | 1 +
drivers/scsi/device_handler/scsi_dh_rdac.c | 1 +
drivers/scsi/elx/efct/efct_hw.c | 2 ++
drivers/scsi/elx/efct/efct_io.c | 2 ++
drivers/scsi/elx/efct/efct_lio.c | 2 ++
drivers/scsi/elx/efct/efct_scsi.c | 2 ++
drivers/scsi/elx/efct/efct_unsol.c | 2 ++
drivers/scsi/elx/libefc/efc_domain.c | 2 ++
drivers/scsi/elx/libefc/efc_els.c | 1 +
drivers/scsi/elx/libefc/efc_node.c | 2 ++
drivers/scsi/elx/libefc/efc_nport.c | 2 ++
drivers/scsi/fcoe/fcoe_ctlr.c | 1 +
drivers/scsi/hosts.c | 1 +
drivers/scsi/libfc/fc_disc.c | 1 +
drivers/scsi/libfc/fc_exch.c | 1 +
drivers/scsi/libfc/fc_lport.c | 1 +
drivers/scsi/libfc/fc_rport.c | 1 +
drivers/scsi/libsas/sas_internal.h | 1 +
drivers/scsi/lpfc/lpfc_bsg.c | 1 +
drivers/scsi/lpfc/lpfc_debugfs.c | 1 +
drivers/scsi/lpfc/lpfc_els.c | 1 +
drivers/scsi/lpfc/lpfc_hbadisc.c | 1 +
drivers/scsi/lpfc/lpfc_init.c | 1 +
drivers/scsi/lpfc/lpfc_nportdisc.c | 1 +
drivers/scsi/lpfc/lpfc_nvme.c | 1 +
drivers/scsi/lpfc/lpfc_nvmet.c | 1 +
drivers/scsi/lpfc/lpfc_sli.c | 1 +
drivers/scsi/mpi3mr/mpi3mr.h | 1 +
drivers/scsi/mpt3sas/mpt3sas_base.h | 1 +
drivers/scsi/qedf/qedf_els.c | 2 ++
drivers/scsi/qedf/qedf_io.c | 1 +
drivers/scsi/qedf/qedf_main.c | 1 +
drivers/scsi/qla2xxx/qla_inline.h | 3 +++
drivers/scsi/qla4xxx/ql4_isr.c | 2 ++
drivers/scsi/qla4xxx/ql4_os.c | 1 +
drivers/scsi/scsi_scan.c | 1 +
drivers/scsi/scsi_sysfs.c | 1 +
drivers/scsi/sg.c | 1 +
drivers/soc/qcom/smem_state.c | 1 +
drivers/staging/greybus/authentication.c | 1 +
drivers/staging/greybus/fw-download.c | 1 +
drivers/staging/greybus/fw-management.c | 1 +
drivers/target/iscsi/iscsi_target.c | 1 +
drivers/target/iscsi/iscsi_target_nego.c | 1 +
drivers/target/iscsi/iscsi_target_tpg.c | 1 +
drivers/target/target_core_device.c | 1 +
drivers/target/target_core_pr.c | 1 +
drivers/target/target_core_tmr.c | 2 ++
drivers/target/target_core_tpg.c | 1 +
drivers/target/target_core_transport.c | 1 +
drivers/target/target_core_user.c | 1 +
drivers/usb/core/config.c | 1 +
drivers/usb/core/hcd.c | 1 +
drivers/usb/core/hub.c | 1 +
drivers/usb/core/message.c | 1 +
drivers/usb/core/urb.c | 1 +
drivers/usb/gadget/function/f_fs.c | 1 +
drivers/usb/host/oxu210hp-hcd.c | 1 +
drivers/usb/misc/usblcd.c | 1 +
drivers/vfio/container.c | 1 +
drivers/vhost/scsi.c | 1 +
drivers/video/fbdev/smscufx.c | 1 +
drivers/xen/xen-scsiback.c | 1 +
drivers/xen/xenbus/xenbus_dev_frontend.c | 1 +
fs/configfs/item.c | 1 +
include/drm/drm_atomic.h | 2 ++
include/drm/drm_auth.h | 2 +-
include/drm/drm_device.h | 2 +-
include/drm/drm_framebuffer.h | 1 +
include/drm/drm_mode_object.h | 2 +-
include/kvm/arm_vgic.h | 2 +-
include/linux/backing-dev-defs.h | 2 +-
include/linux/backing-dev.h | 1 +
include/linux/ceph/messenger.h | 2 +-
include/linux/ceph/mon_client.h | 2 +-
include/linux/ceph/osd_client.h | 2 +-
include/linux/comedi/comedidev.h | 2 +-
include/linux/configfs.h | 2 +-
include/linux/cpu_rmap.h | 2 +-
include/linux/dmaengine.h | 1 +
include/linux/greybus/connection.h | 2 +-
include/linux/greybus/operation.h | 2 +-
include/linux/hugetlb.h | 2 +-
include/linux/hw_random.h | 2 +-
include/linux/iio/buffer-dma.h | 2 +-
include/linux/iio/buffer_impl.h | 2 +-
include/linux/interrupt.h | 2 +-
include/linux/klist.h | 2 +-
include/linux/kobject.h | 2 +-
include/linux/kref.h | 5 +----
include/linux/kref_types.h | 12 ++++++++++++
include/linux/lockd/lockd.h | 2 +-
include/linux/memory-tiers.h | 2 +-
include/linux/mm_inline.h | 4 ++++
include/linux/mm_types.h | 2 +-
include/linux/mtd/blktrans.h | 2 +-
include/linux/nfs_page.h | 2 +-
include/linux/relay.h | 2 +-
include/linux/rpmsg.h | 2 +-
include/linux/sh_clk.h | 2 +-
include/linux/sunrpc/xprt.h | 2 +-
include/linux/surface_aggregator/serial_hub.h | 2 +-
include/linux/tee_drv.h | 2 +-
include/linux/usb.h | 2 +-
include/linux/usb/serial.h | 2 +-
include/linux/watch_queue.h | 2 +-
include/media/media-request.h | 1 +
include/media/v4l2-device.h | 2 ++
include/net/bluetooth/hci_core.h | 1 +
include/net/tls_toe.h | 2 +-
include/rdma/ib_verbs.h | 2 +-
include/rdma/restrack.h | 2 +-
include/rdma/uverbs_types.h | 1 +
kernel/irq/manage.c | 1 +
kernel/relay.c | 1 +
kernel/watch_queue.c | 1 +
lib/klist.c | 1 +
lib/kobject.c | 1 +
mm/memory-tiers.c | 1 +
mm/z3fold.c | 1 +
mm/zswap.c | 1 +
net/can/j1939/main.c | 1 +
net/can/j1939/transport.c | 1 +
net/dsa/dsa.c | 1 +
net/nfc/llcp_core.c | 1 +
net/qrtr/af_qrtr.c | 1 +
net/rds/message.c | 1 +
net/rds/rdma.c | 1 +
net/tipc/node.c | 2 ++
net/tipc/subscr.c | 2 ++
net/tipc/topsrv.c | 1 +
net/tls/tls_toe.c | 1 +
sound/soc/qcom/qdsp6/q6apm.c | 1 +
213 files changed, 257 insertions(+), 41 deletions(-)
create mode 100644 include/linux/kref_types.h

diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h
index 8d134569d0a1..6aeffbe017c0 100644
--- a/arch/arm64/kvm/vgic/vgic.h
+++ b/arch/arm64/kvm/vgic/vgic.h
@@ -6,6 +6,7 @@
#define __KVM_ARM_VGIC_NEW_H__

#include <linux/irqchip/arm-gic-common.h>
+#include <linux/kref.h>
#include <asm/kvm_mmu.h>

#define PRODUCT_ID_KVM 0x4b /* ASCII code K */
diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index b3acdbdb6e7e..15d31c179ad7 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -9,6 +9,7 @@
#include <linux/bsg.h>
#include <linux/slab.h>
#include <linux/blk-mq.h>
+#include <linux/kref.h>
#include <linux/delay.h>
#include <linux/scatterlist.h>
#include <linux/bsg-lib.h>
diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
index 0555f68c2dfd..447260a44019 100644
--- a/drivers/acpi/acpi_ipmi.c
+++ b/drivers/acpi/acpi_ipmi.c
@@ -11,6 +11,7 @@
#include <linux/acpi.h>
#include <linux/ipmi.h>
#include <linux/spinlock.h>
+#include <linux/kref.h>

MODULE_AUTHOR("Zhao Yakui");
MODULE_DESCRIPTION("ACPI IPMI Opregion driver");
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index dbdee2924594..6d8678f80a5a 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -28,6 +28,7 @@
#include <linux/suspend.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
+#include <linux/kref.h>
#include <asm/io.h>

#include "internal.h"
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 09ed67772fae..490d71e7dccb 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -45,6 +45,7 @@
#include <linux/log2.h>
#include <linux/slab.h>
#include <linux/glob.h>
+#include <linux/kref.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_host.h>
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 14d46af40f9a..03a6375a150c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -14,6 +14,7 @@
#include <linux/err.h>
#include <linux/fwnode.h>
#include <linux/init.h>
+#include <linux/kref.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/slab.h>
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index a3bbdd6e60fc..3f0e9121ed28 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/uaccess.h>
+#include <linux/kref.h>

#define RNG_MODULE_NAME "hw_random"

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index a35d6487867c..fbb21189f396 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -37,6 +37,7 @@
#include <linux/nospec.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
+#include <linux/kref.h>

#define IPMI_DRIVER_VERSION "39.2"

diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index 5a5afa14ca8c..37994b7b30d7 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -28,6 +28,7 @@
#include <linux/poll.h>
#include <linux/delay.h>
#include <linux/usb.h>
+#include <linux/kref.h>

#include "xillybus_class.h"

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 2253c154a824..bf9131940cb1 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -9,6 +9,7 @@
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/clk/clk-conf.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
diff --git a/drivers/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c
index 393966c09740..ac9e8b2c58a3 100644
--- a/drivers/comedi/comedi_buf.c
+++ b/drivers/comedi/comedi_buf.c
@@ -9,6 +9,7 @@

#include <linux/vmalloc.h>
#include <linux/slab.h>
+#include <linux/kref.h>
#include <linux/comedi/comedidev.h>
#include "comedi_internal.h"

diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index 1b481731df96..469560b7aba6 100644
--- a/drivers/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
@@ -25,6 +25,7 @@
#include <linux/fs.h>
#include <linux/comedi/comedidev.h>
#include <linux/cdev.h>
+#include <linux/kref.h>

#include <linux/io.h>
#include <linux/uaccess.h>
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 27c86d0ca711..7a54bca555c4 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -7,6 +7,7 @@
#include <linux/slab.h>
#include <linux/dax.h>
#include <linux/io.h>
+#include <linux/kref.h>
#include "dax-private.h"
#include "bus.h"

diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 22aa015df387..5b1481720007 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -29,6 +29,7 @@
*/

#include <linux/slab.h>
+#include <linux/kref.h>

#include <drm/drm_auth.h>
#include <drm/drm_drv.h>
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b0516505f7ae..2dbd3963fca5 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -35,6 +35,7 @@

#include <linux/property.h>
#include <linux/uaccess.h>
+#include <linux/kref.h>

#include <video/cmdline.h>

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 243cacb3575c..f74a65d74f1e 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -34,6 +34,7 @@
#include <linux/pseudo_fs.h>
#include <linux/slab.h>
#include <linux/srcu.h>
+#include <linux/kref.h>

#include <drm/drm_accel.h>
#include <drm/drm_cache.h>
diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h
index 8d414b072c29..735963ce4e6e 100644
--- a/drivers/gpu/drm/msm/msm_gem.h
+++ b/drivers/gpu/drm/msm/msm_gem.h
@@ -9,6 +9,7 @@

#include <linux/kref.h>
#include <linux/dma-resv.h>
+#include <linux/ratelimit.h>
#include "drm/drm_exec.h"
#include "drm/gpu_scheduler.h"
#include "msm_drv.h"
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/memory.c b/drivers/gpu/drm/nouveau/nvkm/core/memory.c
index a705c2dfca80..a40cd36d0d7d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/memory.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/memory.c
@@ -26,6 +26,8 @@
#include <subdev/fb.h>
#include <subdev/instmem.h>

+#include <linux/kref.h>
+
void
nvkm_memory_tags_put(struct nvkm_memory *memory, struct nvkm_device *device,
struct nvkm_tags **ptags)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.c
index 814db9daa194..190e1227c342 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.c
@@ -27,6 +27,7 @@

#include <core/gpuobj.h>
#include <subdev/mmu.h>
+#include <linux/kref.h>

static void
nvkm_cgrp_ectx_put(struct nvkm_cgrp *cgrp, struct nvkm_ectx **pectx)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chid.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chid.c
index 23944d95efd5..f7b4da9d231e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chid.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/chid.c
@@ -21,6 +21,8 @@
*/
#include "chid.h"

+#include <linux/kref.h>
+
void
nvkm_chid_put(struct nvkm_chid *chid, int id, spinlock_t *data_lock)
{
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
index 9c97800fe037..5efb47168315 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
@@ -23,6 +23,7 @@
#include "vmm.h"

#include <subdev/fb.h>
+#include <linux/kref.h>

static void
nvkm_vmm_pt_del(struct nvkm_vmm_pt **ppgt)
diff --git a/drivers/greybus/connection.c b/drivers/greybus/connection.c
index 9c88861986c8..0fdfaa815429 100644
--- a/drivers/greybus/connection.c
+++ b/drivers/greybus/connection.c
@@ -7,6 +7,7 @@
*/

#include <linux/workqueue.h>
+#include <linux/kref.h>
#include <linux/greybus.h>

#include "greybus_trace.h"
diff --git a/drivers/greybus/operation.c b/drivers/greybus/operation.c
index 8459e9bc0749..008a56a07473 100644
--- a/drivers/greybus/operation.c
+++ b/drivers/greybus/operation.c
@@ -13,6 +13,7 @@
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/greybus.h>
+#include <linux/kref.h>

#include "greybus_trace.h"

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index de7a477d6665..d429bc5cc183 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -17,6 +17,7 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/spinlock.h>
diff --git a/drivers/hid/hid-cougar.c b/drivers/hid/hid-cougar.c
index cb8bd8aae15b..2452cddc96c3 100644
--- a/drivers/hid/hid-cougar.c
+++ b/drivers/hid/hid-cougar.c
@@ -8,6 +8,7 @@
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/printk.h>
+#include <linux/kref.h>

#include "hid-ids.h"

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 7dd83ec74f8a..578a6a97eb51 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -19,6 +19,7 @@
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/kfifo.h>
+#include <linux/kref.h>
#include <linux/sched/signal.h>
#include <linux/export.h>
#include <linux/slab.h>
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index e6a8b6d8eab7..4507f266a6dc 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -11,6 +11,7 @@
#include <linux/hid.h>
#include <linux/module.h>
#include <linux/kfifo.h>
+#include <linux/kref.h>
#include <linux/delay.h>
#include <linux/usb.h> /* For to_usb_interface for kvm extra intf check */
#include <asm/unaligned.h>
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index b613f11ed949..157de6bdd639 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -6,6 +6,7 @@
#include "wacom_wac.h"
#include "wacom.h"
#include <linux/input/mt.h>
+#include <linux/kref.h>

#define WAC_MSG_RETRIES 5
#define WAC_CMD_RETRIES 10
diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c
index 5610ba67925e..e60eaf64157b 100644
--- a/drivers/iio/buffer/industrialio-buffer-dma.c
+++ b/drivers/iio/buffer/industrialio-buffer-dma.c
@@ -6,6 +6,7 @@

#include <linux/slab.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/workqueue.h>
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index b581a7e80566..b4857010a08b 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/sched/signal.h>
+#include <linux/kref.h>

#include <linux/iio/iio.h>
#include <linux/iio/iio-opaque.h>
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index c02a96d3572a..0e93a2c47a36 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -38,6 +38,7 @@
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/netdevice.h>
+#include <linux/kref.h>
#include <net/addrconf.h>

#include <rdma/ib_cache.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index ff58058aeadc..9ce6e86c0ab4 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -10,6 +10,7 @@
#include <linux/completion.h>
#include <linux/dma-mapping.h>
#include <linux/device.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/idr.h>
diff --git a/drivers/infiniband/core/counters.c b/drivers/infiniband/core/counters.c
index af59486fe418..e6be9912ccd3 100644
--- a/drivers/infiniband/core/counters.c
+++ b/drivers/infiniband/core/counters.c
@@ -8,6 +8,8 @@
#include "core_priv.h"
#include "restrack.h"

+#include <linux/kref.h>
+
#define ALL_AUTO_MODE_MASKS (RDMA_COUNTER_MASK_QP_TYPE | RDMA_COUNTER_MASK_PID)

static int __counter_set_mode(struct rdma_port_counter *port_counter,
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 67bcea7a153c..cd2599f49168 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -35,6 +35,7 @@
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/netdevice.h>
diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index 01a499a8b88d..dd6b781f03ef 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -10,6 +10,7 @@
#include <linux/mutex.h>
#include <linux/sched/task.h>
#include <linux/pid_namespace.h>
+#include <linux/kref.h>

#include "cma_priv.h"
#include "restrack.h"
diff --git a/drivers/infiniband/hw/erdma/erdma_cm.c b/drivers/infiniband/hw/erdma/erdma_cm.c
index 771059a8eb7d..92dc689691d8 100644
--- a/drivers/infiniband/hw/erdma/erdma_cm.c
+++ b/drivers/infiniband/hw/erdma/erdma_cm.c
@@ -11,6 +11,7 @@
/* Copyright (c) 2017, Open Grid Computing, Inc. */

#include <linux/workqueue.h>
+#include <linux/kref.h>
#include <trace/events/sock.h>

#include "erdma.h"
diff --git a/drivers/infiniband/hw/erdma/erdma_qp.c b/drivers/infiniband/hw/erdma/erdma_qp.c
index 6d0330badd68..96ed236f47fc 100644
--- a/drivers/infiniband/hw/erdma/erdma_qp.c
+++ b/drivers/infiniband/hw/erdma/erdma_qp.c
@@ -9,6 +9,8 @@
#include "erdma_cm.h"
#include "erdma_verbs.h"

+#include <linux/kref.h>
+
void erdma_qp_llp_close(struct erdma_qp *qp)
{
struct erdma_qp_attrs qp_attrs;
diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
index a51fc6854984..6d3bddc5a215 100644
--- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
+++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
@@ -39,6 +39,8 @@
#include "qedr.h"
#include "qedr_iw_cm.h"

+#include <linux/kref.h>
+
static inline void
qedr_fill_sockaddr4(const struct qed_iwarp_cm_info *cm_info,
struct iw_cm_event *event)
diff --git a/drivers/infiniband/sw/rxe/rxe_pool.h b/drivers/infiniband/sw/rxe/rxe_pool.h
index b42e26427a70..15b0084b534e 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.h
+++ b/drivers/infiniband/sw/rxe/rxe_pool.h
@@ -7,6 +7,8 @@
#ifndef RXE_POOL_H
#define RXE_POOL_H

+#include <linux/kref.h>
+
enum rxe_elem_type {
RXE_TYPE_UC,
RXE_TYPE_PD,
diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index 9611ee191a46..50c8865f313e 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -5,6 +5,7 @@
*/

#include <linux/vmalloc.h>
+#include <linux/kref.h>
#include "rxe.h"
#include "rxe_loc.h"
#include "rxe_queue.h"
diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h
index 75253f2b3e3d..a8aaa1c55a30 100644
--- a/drivers/infiniband/sw/siw/siw.h
+++ b/drivers/infiniband/sw/siw/siw.h
@@ -10,6 +10,7 @@
#include <rdma/restrack.h>
#include <linux/socket.h>
#include <linux/skbuff.h>
+#include <linux/kref.h>
#include <crypto/hash.h>
#include <linux/crc32.h>
#include <linux/crc32c.h>
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 00a7303c8cc6..3dba906546fd 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -14,6 +14,7 @@
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/in6.h>
+#include <linux/kref.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_cm.h>
#include <rdma/rdma_cm.h>
diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
index 4e17d546d4cc..d203f248f766 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs.c
@@ -11,6 +11,7 @@

#include <linux/module.h>
#include <linux/inet.h>
+#include <linux/kref.h>

#include "rtrs-pri.h"
#include "rtrs-log.h"
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 58f70cfec45a..41280ffff606 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -38,6 +38,7 @@
#include <linux/err.h>
#include <linux/ctype.h>
#include <linux/kthread.h>
+#include <linux/kref.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/atomic.h>
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index baf64540dc00..2fe271dca822 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -26,6 +26,7 @@
#include <linux/spinlock.h>
#include <linux/sched/signal.h>
#include <linux/kthread.h>
+#include <linux/kref.h>

#include <media/dvb_ca_en50221.h>
#include <media/dvb_ringbuffer.h>
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 9293b058ab99..21694f3e8db3 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/semaphore.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/nospec.h>
#include <linux/list.h>
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 49f0eb7d0b9d..b40367834d22 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -21,6 +21,7 @@
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
+#include <linux/kref.h>
#include <media/dvbdev.h>

/* Due to enum tuner_pad_index */
diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c
index 4441aca2280a..a2a2dd307942 100644
--- a/drivers/misc/genwqe/card_dev.c
+++ b/drivers/misc/genwqe/card_dev.c
@@ -25,6 +25,7 @@
#include <linux/wait.h>
#include <linux/delay.h>
#include <linux/atomic.h>
+#include <linux/kref.h>

#include "card_base.h"
#include "card_ddcb.h"
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 7e52f6cd0cc2..00bba45a7971 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -20,6 +20,7 @@
#include <linux/hdreg.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
+#include <linux/kref.h>

#include "mtdcore.h"

diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h
index 7ff82b6778ba..946e03bf687b 100644
--- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h
+++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h
@@ -20,6 +20,7 @@
#include <crypto/scatterwalk.h>
#include <crypto/internal/hash.h>
#include <linux/tls.h>
+#include <linux/kref.h>
#include <net/tls.h>
#include <net/tls_prot.h>
#include <net/tls_toe.h>
diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
index 6f6525983130..fcff72267c1c 100644
--- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
+++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
@@ -14,6 +14,7 @@
#include <linux/inetdevice.h>
#include <linux/ip.h>
#include <linux/tcp.h>
+#include <linux/kref.h>
#include <linux/sched/signal.h>
#include <linux/kallsyms.h>
#include <linux/kprobes.h>
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
index 854d87e1125c..e1d418aa5253 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
@@ -47,6 +47,7 @@
#include <linux/skbuff.h>
#include <linux/pci.h>
#include <linux/scatterlist.h>
+#include <linux/kref.h>

#include "libcxgb_ppm.h"

diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index a94a1c48c3de..fd87757bad43 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -14,6 +14,8 @@
#include "ice_vf_vsi_vlan_ops.h"
#include "ice_vlan.h"

+#include <linux/kref.h>
+
/**
* ice_free_vf_entries - Free all VF entries from the hash table
* @pf: pointer to the PF structure
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index 2ffdae9a82df..604effc72bb8 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -7,6 +7,8 @@
#include "ice_fltr.h"
#include "ice_virtchnl_allowlist.h"

+#include <linux/kref.h>
+
/* Public functions which may be accessed by all driver files */

/**
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index d14459e5c04f..531ef375566c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -35,6 +35,7 @@
#include <linux/mlx5/driver.h>
#include <linux/mlx5/eswitch.h>
#include <linux/mlx5/vport.h>
+#include <linux/kref.h>
#include "lib/devcom.h"
#include "mlx5_core.h"
#include "eswitch.h"
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
index e7d59cfa8708..dbe7fb20fbc6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
@@ -3,6 +3,7 @@

#include <linux/mlx5/vport.h>
#include <linux/list.h>
+#include <linux/kref.h>
#include "lib/devcom.h"
#include "mlx5_core.h"

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/uar.c b/drivers/net/ethernet/mellanox/mlx5/core/uar.c
index 1513112ecec8..a34567921588 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/uar.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/uar.c
@@ -31,6 +31,7 @@
*/

#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/mlx5/driver.h>
#include "mlx5_core.h"

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c
index a8286d0032d1..79e2585caea2 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c
@@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/wait.h>
+#include <linux/kref.h>

#include "nfp_arm.h"
#include "nfp_cpp.h"
diff --git a/drivers/net/ethernet/qlogic/qede/qede_rdma.c b/drivers/net/ethernet/qlogic/qede/qede_rdma.c
index 6304514a6f2c..f82501dbf6d2 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_rdma.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_rdma.c
@@ -7,6 +7,7 @@
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/list.h>
+#include <linux/kref.h>
#include <linux/mutex.h>
#include <linux/qed/qede_rdma.h>
#include "qede.h"
diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
index 146b81f08a89..a1e8b7f6e1f6 100644
--- a/drivers/net/pse-pd/pse_core.c
+++ b/drivers/net/pse-pd/pse_core.c
@@ -8,6 +8,7 @@
#include <linux/device.h>
#include <linux/of.h>
#include <linux/pse-pd/pse.h>
+#include <linux/kref.h>

static DEFINE_MUTEX(pse_list_mutex);
static LIST_HEAD(pse_controller_list);
diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
index 6bb9aa2bfe65..4cd2e15a6a2c 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -40,6 +40,7 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/etherdevice.h>
+#include <linux/kref.h>
#include <net/mac80211.h>
#include "carl9170.h"
#include "hw.h"
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
index d91799b71d23..daf599f431eb 100644
--- a/drivers/nvdimm/core.c
+++ b/drivers/nvdimm/core.c
@@ -14,6 +14,7 @@
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/io.h>
+#include <linux/kref.h>
#include "nd-core.h"
#include "nd.h"

diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index 91d9163ee303..4013e842ac1f 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/nd.h>
+#include <linux/kref.h>
#include "label.h"
#include "nd.h"

diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 21498d461fde..576fdeed35d6 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -11,6 +11,7 @@
#include <linux/io.h>
#include <linux/fs.h>
#include <linux/mm.h>
+#include <linux/kref.h>
#include "nd-core.h"
#include "label.h"
#include "pmem.h"
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 3bf27052832f..e0af9ac292d6 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/proc_fs.h>
+#include <linux/kref.h>

#include "of_private.h"

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index cfd60e35a899..d920a99ecc25 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -11,6 +11,7 @@
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/hashtable.h>
+#include <linux/kref.h>
#include <linux/libfdt.h>
#include <linux/of.h>
#include <linux/of_address.h>
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 5b1f271c6034..7cf646925192 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -37,6 +37,7 @@
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/acpi.h>
+#include <linux/kref.h>

#include "../pci.h"
#include "acpiphp.h"
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 0f87cade10f7..220212310b30 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/err.h>
+#include <linux/kref.h>
#include "pci.h"

struct kset *pci_slots_kset;
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index eea031b3f0ef..b971519e5756 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -16,6 +16,7 @@
#include <linux/wait.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/nospec.h>
+#include <linux/kref.h>

MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver");
MODULE_VERSION("0.1");
diff --git a/drivers/rpmsg/mtk_rpmsg.c b/drivers/rpmsg/mtk_rpmsg.c
index d1213c33da20..c3a099ab2508 100644
--- a/drivers/rpmsg/mtk_rpmsg.c
+++ b/drivers/rpmsg/mtk_rpmsg.c
@@ -10,6 +10,7 @@
#include <linux/rpmsg/mtk_rpmsg.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
+#include <linux/kref.h>

#include "rpmsg_internal.h"

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 82d460ff4777..b8b1a2ff6d91 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -19,6 +19,7 @@
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/mailbox_client.h>
+#include <linux/kref.h>

#include "rpmsg_internal.h"
#include "qcom_glink_native.h"
diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
index 43f601c84b4f..e464ad92b818 100644
--- a/drivers/rpmsg/qcom_smd.c
+++ b/drivers/rpmsg/qcom_smd.c
@@ -20,6 +20,7 @@
#include <linux/wait.h>
#include <linux/rpmsg.h>
#include <linux/rpmsg/qcom_smd.h>
+#include <linux/kref.h>

#include "rpmsg_internal.h"

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 1062939c3264..7cd43e2bb13a 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -15,6 +15,7 @@
#include <linux/idr.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/rpmsg.h>
diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index 754f2e82d955..3b1a9ac9fd9c 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -16,6 +16,8 @@

#include "bnx2fc.h"

+#include <linux/kref.h>
+
static void bnx2fc_logo_resp(struct fc_seq *seq, struct fc_frame *fp,
void *arg);
static void bnx2fc_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 1078c20c5ef6..5f7fce039d6f 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -17,6 +17,7 @@
#include "bnx2fc.h"

#include <linux/ethtool.h>
+#include <linux/kref.h>

static struct list_head adapter_list;
static struct list_head if_list;
diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index 090d436bcef8..cf2052f6f0b7 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -15,6 +15,8 @@

#include "bnx2fc.h"

+#include <linux/kref.h>
+
DECLARE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu);

static void bnx2fc_fastpath_notification(struct bnx2fc_hba *hba,
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 33057908f147..7595fbd7fb02 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -14,6 +14,8 @@

#include "bnx2fc.h"

+#include <linux/kref.h>
+
#define RESERVE_FREE_LIST_INDEX num_possible_cpus()

static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
index 2c246e80c1c4..9d474ad61c3f 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
@@ -14,6 +14,9 @@
*/

#include "bnx2fc.h"
+
+#include <linux/kref.h>
+
static void bnx2fc_upld_timer(struct timer_list *t);
static void bnx2fc_ofld_timer(struct timer_list *t);
static int bnx2fc_init_tgt(struct bnx2fc_rport *tgt,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 1befcd5b2a0f..34543cf1a193 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -24,6 +24,7 @@
#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/slab.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index d92cf1dccc2f..d33f45d78dbe 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -15,6 +15,7 @@
#define __LIBCXGBI_H__

#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/debugfs.h>
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index a226dc1b65d7..671730961232 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -7,6 +7,7 @@
*/
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <asm/unaligned.h>
#include <scsi/scsi.h>
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index f8a09e3eba58..584c3eb2a34f 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -25,6 +25,7 @@
#include <linux/workqueue.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/kref.h>

#define RDAC_NAME "rdac"
#define RDAC_RETRY_COUNT 5
diff --git a/drivers/scsi/elx/efct/efct_hw.c b/drivers/scsi/elx/efct/efct_hw.c
index 5a5525054d71..6be1d4043dda 100644
--- a/drivers/scsi/elx/efct/efct_hw.c
+++ b/drivers/scsi/elx/efct/efct_hw.c
@@ -8,6 +8,8 @@
#include "efct_hw.h"
#include "efct_unsol.h"

+#include <linux/kref.h>
+
struct efct_hw_link_stat_cb_arg {
void (*cb)(int status, u32 num_counters,
struct efct_hw_link_stat_counts *counters, void *arg);
diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
index c612f0a48839..bc2a8361b32c 100644
--- a/drivers/scsi/elx/efct/efct_io.c
+++ b/drivers/scsi/elx/efct/efct_io.c
@@ -8,6 +8,8 @@
#include "efct_hw.h"
#include "efct_io.h"

+#include <linux/kref.h>
+
struct efct_io_pool {
struct efct *efct;
spinlock_t lock; /* IO pool lock */
diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
index 6a6ec32c46bd..435b18877277 100644
--- a/drivers/scsi/elx/efct/efct_lio.c
+++ b/drivers/scsi/elx/efct/efct_lio.c
@@ -9,6 +9,8 @@
#include "efct_driver.h"
#include "efct_lio.h"

+#include <linux/kref.h>
+
/*
* lio_wq is used to call the LIO backed during creation or deletion of
* sessions. This brings serialization to the session management as we create
diff --git a/drivers/scsi/elx/efct/efct_scsi.c b/drivers/scsi/elx/efct/efct_scsi.c
index afb154992053..b219e56e40b9 100644
--- a/drivers/scsi/elx/efct/efct_scsi.c
+++ b/drivers/scsi/elx/efct/efct_scsi.c
@@ -7,6 +7,8 @@
#include "efct_driver.h"
#include "efct_hw.h"

+#include <linux/kref.h>
+
#define enable_tsend_auto_resp(efct) 1
#define enable_treceive_auto_resp(efct) 0

diff --git a/drivers/scsi/elx/efct/efct_unsol.c b/drivers/scsi/elx/efct/efct_unsol.c
index e6addab66a60..51db356a5122 100644
--- a/drivers/scsi/elx/efct/efct_unsol.c
+++ b/drivers/scsi/elx/efct/efct_unsol.c
@@ -7,6 +7,8 @@
#include "efct_driver.h"
#include "efct_unsol.h"

+#include <linux/kref.h>
+
#define frame_printf(efct, hdr, fmt, ...) \
do { \
char s_id_text[16]; \
diff --git a/drivers/scsi/elx/libefc/efc_domain.c b/drivers/scsi/elx/libefc/efc_domain.c
index ca9d7ff2c0d2..5b0943ea2bcb 100644
--- a/drivers/scsi/elx/libefc/efc_domain.c
+++ b/drivers/scsi/elx/libefc/efc_domain.c
@@ -10,6 +10,8 @@

#include "efc.h"

+#include <linux/kref.h>
+
int
efc_domain_cb(void *arg, int event, void *data)
{
diff --git a/drivers/scsi/elx/libefc/efc_els.c b/drivers/scsi/elx/libefc/efc_els.c
index 84bc81d7ce76..49d1446b826a 100644
--- a/drivers/scsi/elx/libefc/efc_els.c
+++ b/drivers/scsi/elx/libefc/efc_els.c
@@ -11,6 +11,7 @@
#include "efc.h"
#include "efc_els.h"
#include "../libefc_sli/sli4.h"
+#include <linux/kref.h>

#define EFC_LOG_ENABLE_ELS_TRACE(efc) \
(((efc) != NULL) ? (((efc)->logmask & (1U << 1)) != 0) : 0)
diff --git a/drivers/scsi/elx/libefc/efc_node.c b/drivers/scsi/elx/libefc/efc_node.c
index a1b4ce6a27b4..3dbb95aa5727 100644
--- a/drivers/scsi/elx/libefc/efc_node.c
+++ b/drivers/scsi/elx/libefc/efc_node.c
@@ -6,6 +6,8 @@

#include "efc.h"

+#include <linux/kref.h>
+
int
efc_remote_node_cb(void *arg, int event, void *data)
{
diff --git a/drivers/scsi/elx/libefc/efc_nport.c b/drivers/scsi/elx/libefc/efc_nport.c
index 2e83a667901f..84dcd6cc445e 100644
--- a/drivers/scsi/elx/libefc/efc_nport.c
+++ b/drivers/scsi/elx/libefc/efc_nport.c
@@ -27,6 +27,8 @@

#include "efc.h"

+#include <linux/kref.h>
+
void
efc_nport_cb(void *arg, int event, void *data)
{
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 19eee108db02..06aed8faebd5 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -20,6 +20,7 @@
#include <linux/errno.h>
#include <linux/bitops.h>
#include <linux/slab.h>
+#include <linux/kref.h>
#include <net/rtnetlink.h>

#include <scsi/fc/fc_els.h>
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index d7f51b84f3c7..ca4a8664a533 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -35,6 +35,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/idr.h>
+#include <linux/kref.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h>
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 384f48ff64d7..b6e43d94aab1 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -25,6 +25,7 @@
#include <linux/err.h>
#include <linux/export.h>
#include <linux/list.h>
+#include <linux/kref.h>

#include <asm/unaligned.h>

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 1d91c457527f..783a3e1ddf2b 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/export.h>
#include <linux/log2.h>
+#include <linux/kref.h>

#include <scsi/fc/fc_fc2.h>

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index ab06e9aeb613..210222ec25c1 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -79,6 +79,7 @@
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/kref.h>
#include <asm/unaligned.h>

#include <scsi/fc/fc_gs.h>
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 33da3c1085f0..13f7745d1605 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -54,6 +54,7 @@
#include <linux/workqueue.h>
#include <linux/export.h>
#include <linux/rculist.h>
+#include <linux/kref.h>

#include <asm/unaligned.h>

diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 3804aef165ad..97903a3fecfd 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -15,6 +15,7 @@
#include <scsi/libsas.h>
#include <scsi/sas_ata.h>
#include <linux/pm_runtime.h>
+#include <linux/kref.h>

#ifdef pr_fmt
#undef pr_fmt
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 595dca92e8db..ce6fa90cdb41 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -28,6 +28,7 @@
#include <linux/list.h>
#include <linux/bsg-lib.h>
#include <linux/vmalloc.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index ea9b42225e62..d7a3ea3abdb1 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -27,6 +27,7 @@
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
+#include <linux/kref.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 4d723200690a..de690023b63f 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index f80bbc315f4c..48fe93633c2f 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -29,6 +29,7 @@
#include <linux/interrupt.h>
#include <linux/lockdep.h>
#include <linux/utsname.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ee966d95b470..e97255e88ab6 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -28,6 +28,7 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/kthread.h>
+#include <linux/kref.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/sched/clock.h>
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index d9074929fbab..5ea5b829fe65 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -25,6 +25,7 @@
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 128fc1bab586..b8dfc7610a3b 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -23,6 +23,7 @@
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
+#include <linux/kref.h>
#include <linux/delay.h>
#include <asm/unaligned.h>
#include <linux/crc-t10dif.h>
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 425328d9c2d8..9c32e48e92a1 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -23,6 +23,7 @@
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
+#include <linux/kref.h>
#include <linux/delay.h>
#include <asm/unaligned.h>
#include <linux/crc-t10dif.h>
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 706985358c6a..6c780b8525f7 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -25,6 +25,7 @@
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
+#include <linux/kref.h>
#include <linux/slab.h>
#include <linux/lockdep.h>

diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index 3de1ee05c44e..0d2c32c8d9ff 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/pci.h>
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index bf100a4ebfc3..c561ec02c57a 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -68,6 +68,7 @@
#include <linux/pci.h>
#include <linux/poll.h>
#include <linux/irq_poll.h>
+#include <linux/kref.h>

#include "mpt3sas_debug.h"
#include "mpt3sas_trigger_diag.h"
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index 1ff5bc314fc0..44fd48a14abb 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -5,6 +5,8 @@
*/
#include "qedf.h"

+#include <linux/kref.h>
+
/* It's assumed that the lock is held when calling this function. */
static int qedf_initiate_els(struct qedf_rport *fcport, unsigned int op,
void *data, uint32_t data_len,
diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index bf921caaf6ae..71a4ba767212 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -5,6 +5,7 @@
*/
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
+#include <linux/kref.h>
#include "qedf.h"
#include <scsi/scsi_tcq.h>

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index a58353b7b4e8..a10e77fc79d4 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -20,6 +20,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/cpu.h>
+#include <linux/kref.h>
#include "qedf.h"
#include "qedf_dbg.h"
#include <uapi/linux/pci_regs.h>
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index a4a56ab0ba74..f12eb8bea8e6 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -5,6 +5,9 @@
*/

#include "qla_target.h"
+
+#include <linux/kref.h>
+
/**
* qla24xx_calc_iocbs() - Determine number of Command Type 3 and
* Continuation Type 1 IOCBs to allocate.
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index cf52258ecdde..c6b143cfd84a 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -9,6 +9,8 @@
#include "ql4_dbg.h"
#include "ql4_inline.h"

+#include <linux/kref.h>
+
/**
* qla4xxx_copy_sense - copy sense data into cmd sense buffer
* @ha: Pointer to host adapter structure.
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 675332e49a7b..b6faa09eedb3 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -8,6 +8,7 @@
#include <linux/blkdev.h>
#include <linux/iscsi_boot_sysfs.h>
#include <linux/inet.h>
+#include <linux/kref.h>

#include <scsi/scsi_tcq.h>
#include <scsi/scsicam.h>
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 70c0319be34c..ebfe960b2f45 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -35,6 +35,7 @@
#include <linux/spinlock.h>
#include <linux/async.h>
#include <linux/slab.h>
+#include <linux/kref.h>
#include <asm/unaligned.h>

#include <scsi/scsi.h>
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 24f6eefb6803..dbd5e097a1fd 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -14,6 +14,7 @@
#include <linux/device.h>
#include <linux/pm_runtime.h>
#include <linux/bsg.h>
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 86210e4dd0d3..ef420343c5b5 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -48,6 +48,7 @@ static int sg_version_num = 30536; /* 2 digits for each component */
#include <linux/ratelimit.h>
#include <linux/uio.h>
#include <linux/cred.h> /* for sg_check_file_access() */
+#include <linux/kref.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
diff --git a/drivers/soc/qcom/smem_state.c b/drivers/soc/qcom/smem_state.c
index e848cc9a3cf8..ded25c077ec5 100644
--- a/drivers/soc/qcom/smem_state.c
+++ b/drivers/soc/qcom/smem_state.c
@@ -9,6 +9,7 @@
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/soc/qcom/smem_state.h>
+#include <linux/kref.h>

static LIST_HEAD(smem_states);
static DEFINE_MUTEX(list_lock);
diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c
index d53e58f92e81..6d900eebfcb3 100644
--- a/drivers/staging/greybus/authentication.c
+++ b/drivers/staging/greybus/authentication.c
@@ -11,6 +11,7 @@
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/uaccess.h>
+#include <linux/kref.h>

#include "greybus_authentication.h"
#include "firmware.h"
diff --git a/drivers/staging/greybus/fw-download.c b/drivers/staging/greybus/fw-download.c
index 2a5c6d1b049c..455888dcb13b 100644
--- a/drivers/staging/greybus/fw-download.c
+++ b/drivers/staging/greybus/fw-download.c
@@ -8,6 +8,7 @@

#include <linux/firmware.h>
#include <linux/jiffies.h>
+#include <linux/kref.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/greybus.h>
diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c
index 3054f084d777..33073951a2cb 100644
--- a/drivers/staging/greybus/fw-management.c
+++ b/drivers/staging/greybus/fw-management.c
@@ -14,6 +14,7 @@
#include <linux/ioctl.h>
#include <linux/uaccess.h>
#include <linux/greybus.h>
+#include <linux/kref.h>

#include "firmware.h"
#include "greybus_firmware.h"
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 1d25e64b068a..3a59f3732047 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -16,6 +16,7 @@
#include <linux/vmalloc.h>
#include <linux/idr.h>
#include <linux/delay.h>
+#include <linux/kref.h>
#include <linux/sched/signal.h>
#include <asm/unaligned.h>
#include <linux/inet.h>
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c
index fa3fb5f4e6bc..a10e01a34b49 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -12,6 +12,7 @@
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>
+#include <linux/kref.h>
#include <net/sock.h>
#include <trace/events/sock.h>
#include <scsi/iscsi_proto.h>
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
index f7bac98fd4fe..f6ed6a65e90e 100644
--- a/drivers/target/iscsi/iscsi_target_tpg.c
+++ b/drivers/target/iscsi/iscsi_target_tpg.c
@@ -9,6 +9,7 @@
******************************************************************************/

#include <linux/slab.h>
+#include <linux/kref.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/iscsi/iscsi_target_core.h>
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 7a85e6477e46..f9abc0895dbd 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -17,6 +17,7 @@
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
+#include <linux/kref.h>
#include <linux/kthread.h>
#include <linux/in.h>
#include <linux/export.h>
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 80b7d85030d0..a566d4d38192 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -18,6 +18,7 @@
#include <linux/file.h>
#include <linux/fcntl.h>
#include <linux/fs.h>
+#include <linux/kref.h>
#include <scsi/scsi_proto.h>
#include <asm/unaligned.h>

diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 4718db628222..16da808bcc61 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -14,6 +14,8 @@
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/export.h>
+#include <linux/workqueue.h>
+#include <linux/kref.h>

#include <target/target_core_base.h>
#include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index c0e429e5ef31..881b5d362064 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -17,6 +17,7 @@
#include <linux/spinlock.h>
#include <linux/in.h>
#include <linux/export.h>
+#include <linux/kref.h>
#include <net/sock.h>
#include <net/tcp.h>
#include <scsi/scsi_proto.h>
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 73d0d6133ac8..03ed135934b0 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -16,6 +16,7 @@
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
+#include <linux/kref.h>
#include <linux/kthread.h>
#include <linux/in.h>
#include <linux/cdrom.h>
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 7eb94894bd68..13817d9b18ca 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -21,6 +21,7 @@
#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/pagemap.h>
+#include <linux/kref.h>
#include <net/genetlink.h>
#include <scsi/scsi_common.h>
#include <scsi/scsi_proto.h>
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 7f8d33f92ddb..095a913b7b2a 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/device.h>
+#include <linux/kref.h>
#include <asm/byteorder.h>
#include "usb.h"

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 14fc28c4cf48..d311effc69a4 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -32,6 +32,7 @@
#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/kcov.h>
+#include <linux/kref.h>

#include <linux/phy/phy.h>
#include <linux/usb.h>
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 3ee8455585b6..8813cd02d505 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -31,6 +31,7 @@
#include <linux/random.h>
#include <linux/pm_qos.h>
#include <linux/kobject.h>
+#include <linux/kref.h>

#include <linux/bitfield.h>
#include <linux/uaccess.h>
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 077dfe48d01c..522b571aaba1 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -21,6 +21,7 @@
#include <linux/usb/quirks.h>
#include <linux/usb/hcd.h> /* for usbcore internals */
#include <linux/usb/of.h>
+#include <linux/kref.h>
#include <asm/byteorder.h>

#include "usb.h"
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 7576920e2d5a..0b66127e3b8f 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -13,6 +13,7 @@
#include <linux/wait.h>
#include <linux/usb/hcd.h>
#include <linux/scatterlist.h>
+#include <linux/kref.h>

#define to_urb(d) container_of(d, struct urb, kref)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index be3851cffb73..c71496856fcc 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -25,6 +25,7 @@
#include <linux/sched/signal.h>
#include <linux/uio.h>
#include <linux/vmalloc.h>
+#include <linux/kref.h>
#include <asm/unaligned.h>

#include <linux/usb/ccid.h>
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index d467472f9d3c..98f5c649df3d 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -25,6 +25,7 @@
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/iopoll.h>
+#include <linux/kref.h>

#include <asm/irq.h>
#include <asm/unaligned.h>
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index bb546f624a45..b91645d9b3c4 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -21,6 +21,7 @@
#include <linux/rwsem.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
+#include <linux/kref.h>

#define DRIVER_VERSION "USBLCD Driver Version 1.05"

diff --git a/drivers/vfio/container.c b/drivers/vfio/container.c
index d53d08f16973..7ef54f61c423 100644
--- a/drivers/vfio/container.c
+++ b/drivers/vfio/container.c
@@ -9,6 +9,7 @@
#include <linux/fs.h>
#include <linux/capability.h>
#include <linux/iommu.h>
+#include <linux/kref.h>
#include <linux/miscdevice.h>
#include <linux/vfio.h>
#include <uapi/linux/vfio.h>
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 282aac45c690..f7e467a946e8 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -36,6 +36,7 @@
#include <linux/virtio_scsi.h>
#include <linux/llist.h>
#include <linux/bitmap.h>
+#include <linux/kref.h>

#include "vhost.h"

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 35d682b110c4..2b6143c7203c 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -29,6 +29,7 @@
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/kref.h>
#include "edid.h"

#define check_warn(status, fmt, args...) \
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 0c51edfd13dc..946bcd5e0eea 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -44,6 +44,7 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/configfs.h>
+#include <linux/kref.h>

#include <generated/utsrelease.h>

diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 6f56640092a9..5a639f2ff6bb 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -56,6 +56,7 @@
#include <linux/slab.h>
#include <linux/miscdevice.h>
#include <linux/workqueue.h>
+#include <linux/kref.h>

#include <xen/xenbus.h>
#include <xen/xen.h>
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index 254170a82aa3..07d43d0a8410 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/stat.h>
#include <linux/slab.h>
+#include <linux/kref.h>

#include <linux/configfs.h>

diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index cf8e1220a4ac..fb92a70a83dc 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -31,6 +31,8 @@
#include <drm/drm_crtc.h>
#include <drm/drm_util.h>

+#include <linux/kref.h>
+
/**
* struct drm_crtc_commit - track modeset commits on a CRTC
*
diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h
index cb7377d5f5c3..da669629536c 100644
--- a/include/drm/drm_auth.h
+++ b/include/drm/drm_auth.h
@@ -29,7 +29,7 @@
*/

#include <linux/idr.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

struct drm_file;

diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index 6a1bbdd515cd..6ea1ca468d20 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -2,7 +2,7 @@
#define _DRM_DEVICE_H_

#include <linux/list.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mutex_types.h>
#include <linux/idr.h>

diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index 668077009fce..bdee553d86fb 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -26,6 +26,7 @@
#include <linux/ctype.h>
#include <linux/list.h>
#include <linux/sched.h>
+#include <linux/kref.h>

#include <drm/drm_fourcc.h>
#include <drm/drm_mode_object.h>
diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h
index 08d7a7f0188f..df8f92230fda 100644
--- a/include/drm/drm_mode_object.h
+++ b/include/drm/drm_mode_object.h
@@ -23,7 +23,7 @@
#ifndef __DRM_MODESET_H__
#define __DRM_MODESET_H__

-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <drm/drm_lease.h>
struct drm_object_properties;
struct drm_property;
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index c1c4a6266b58..00bf2cc4bb02 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -8,7 +8,7 @@
#include <linux/bits.h>
#include <linux/kvm.h>
#include <linux/irqreturn.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mutex_types.h>
#include <linux/spinlock_types.h>
#include <linux/static_key.h>
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index 977f0323383d..b379687434fa 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -12,7 +12,7 @@
#include <linux/timer_types.h>
#include <linux/wait.h>
#include <linux/workqueue_types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

#ifdef CONFIG_CGROUP_WRITEBACK
#include <linux/rwsem.h>
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 8e7af9a03b41..cc56faa15622 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -16,6 +16,7 @@
#include <linux/writeback.h>
#include <linux/backing-dev-defs.h>
#include <linux/slab.h>
+#include <linux/kref.h>

static inline struct backing_dev_info *bdi_get(struct backing_dev_info *bdi)
{
diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 908b4a7fcb45..100083dfcedf 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -4,7 +4,7 @@

#include <linux/bvec.h>
#include <linux/crypto.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mutex_types.h>
#include <linux/net.h>
#include <linux/uio.h>
diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h
index 8226ea42fc78..1b23c4cf663b 100644
--- a/include/linux/ceph/mon_client.h
+++ b/include/linux/ceph/mon_client.h
@@ -3,7 +3,7 @@
#define _FS_CEPH_MON_CLIENT_H

#include <linux/completion.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/rbtree_types.h>

#include <linux/ceph/messenger.h>
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index b27b9faeabf7..2e6320a4c1d3 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -4,7 +4,7 @@

#include <linux/bitrev.h>
#include <linux/completion.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mempool.h>
#include <linux/rbtree_types.h>
#include <linux/refcount_types.h>
diff --git a/include/linux/comedi/comedidev.h b/include/linux/comedi/comedidev.h
index bde0255d4406..d7a75b15c6f7 100644
--- a/include/linux/comedi/comedidev.h
+++ b/include/linux/comedi/comedidev.h
@@ -14,7 +14,7 @@
#include <linux/mutex_types.h>
#include <linux/spinlock_types.h>
#include <linux/rwsem.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/comedi.h>

#define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 4a8326e7342b..5aac65d90883 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -22,7 +22,7 @@
#include <linux/stat.h> /* S_IRUGO */
#include <linux/types.h> /* ssize_t */
#include <linux/list.h> /* struct list_head */
-#include <linux/kref.h> /* struct kref */
+#include <linux/kref_types.h> /* struct kref */
#include <linux/mutex_types.h> /* struct mutex */

#define CONFIGFS_ITEM_NAME_LEN 20
diff --git a/include/linux/cpu_rmap.h b/include/linux/cpu_rmap.h
index effe8bef0a3a..db82833bfe21 100644
--- a/include/linux/cpu_rmap.h
+++ b/include/linux/cpu_rmap.h
@@ -10,7 +10,7 @@
#include <linux/cpumask.h>
#include <linux/gfp_types.h>
#include <linux/slab.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

/**
* struct cpu_rmap - CPU affinity reverse-map
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 1a202761599a..32c2f49177b1 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -13,6 +13,7 @@
#include <linux/scatterlist.h>
#include <linux/bitmap.h>
#include <linux/types.h>
+#include <linux/kref.h>
#include <asm/page.h>

/**
diff --git a/include/linux/greybus/connection.h b/include/linux/greybus/connection.h
index d8926e864937..168fa2a284a8 100644
--- a/include/linux/greybus/connection.h
+++ b/include/linux/greybus/connection.h
@@ -12,7 +12,7 @@
#include <linux/bits.h>
#include <linux/list.h>
#include <linux/kfifo.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

#define GB_CONNECTION_FLAG_CSD BIT(0)
#define GB_CONNECTION_FLAG_NO_FLOWCTRL BIT(1)
diff --git a/include/linux/greybus/operation.h b/include/linux/greybus/operation.h
index ba5f09816035..c49053e5707d 100644
--- a/include/linux/greybus/operation.h
+++ b/include/linux/greybus/operation.h
@@ -10,7 +10,7 @@
#define __OPERATION_H

#include <linux/completion.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/timer_types.h>
#include <linux/types.h>
#include <linux/workqueue_types.h>
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 444d509c2647..de6cbc00806e 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -10,7 +10,7 @@
#include <linux/cgroup.h>
#include <linux/page_ref.h>
#include <linux/list.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/pgtable.h>
#include <linux/gfp_types.h>
#include <linux/userfaultfd_k.h>
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 136e9842120e..96cad10d0201 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -15,7 +15,7 @@
#include <linux/completion.h>
#include <linux/types.h>
#include <linux/list.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

/**
* struct hwrng - Hardware Random Number Generator driver
diff --git a/include/linux/iio/buffer-dma.h b/include/linux/iio/buffer-dma.h
index 395762ed9bf1..8c04fff96e57 100644
--- a/include/linux/iio/buffer-dma.h
+++ b/include/linux/iio/buffer-dma.h
@@ -8,7 +8,7 @@
#define __INDUSTRIALIO_DMA_BUFFER_H__

#include <linux/list.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/spinlock_types.h>
#include <linux/mutex_types.h>
#include <linux/iio/buffer_impl.h>
diff --git a/include/linux/iio/buffer_impl.h b/include/linux/iio/buffer_impl.h
index 89c3fd7c29ca..184f8c399854 100644
--- a/include/linux/iio/buffer_impl.h
+++ b/include/linux/iio/buffer_impl.h
@@ -2,7 +2,7 @@
#ifndef _IIO_BUFFER_GENERIC_IMPL_H_
#define _IIO_BUFFER_GENERIC_IMPL_H_
#include <linux/sysfs.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>

#ifdef CONFIG_IIO_BUFFER

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 2ac9e5f9af3d..e3a0f2c22a75 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -10,7 +10,7 @@
#include <linux/irqnr.h>
#include <linux/hardirq.h>
#include <linux/irqflags.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/workqueue_types.h>
#include <linux/jump_label.h>

diff --git a/include/linux/klist.h b/include/linux/klist.h
index 632ae9c720ac..5bd7819286d7 100644
--- a/include/linux/klist.h
+++ b/include/linux/klist.h
@@ -11,7 +11,7 @@
#define _LINUX_KLIST_H

#include <linux/spinlock_types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>

struct klist_node;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 774db9d28800..c120ea4addca 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -21,7 +21,7 @@
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/spinlock_types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/kobject_ns.h>
#include <linux/uidgid_types.h>

diff --git a/include/linux/kref.h b/include/linux/kref.h
index 536ada1a1bc4..ca6280808d1a 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -13,12 +13,9 @@
#ifndef _KREF_H_
#define _KREF_H_

+#include <linux/kref_types.h>
#include <linux/refcount.h>

-struct kref {
- refcount_t refcount;
-};
-
#define KREF_INIT(n) { .refcount = REFCOUNT_INIT(n), }

/**
diff --git a/include/linux/kref_types.h b/include/linux/kref_types.h
new file mode 100644
index 000000000000..cd048cc26178
--- /dev/null
+++ b/include/linux/kref_types.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _KREF_TYPES_H_
+#define _KREF_TYPES_H_
+
+#include <linux/refcount_types.h>
+
+struct kref {
+ refcount_t refcount;
+};
+
+#endif /* _KREF_TYPES_H_ */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 81432629646d..f9f8ad171d6a 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -16,7 +16,7 @@
#include <linux/in6.h>
#include <net/ipv6.h>
#include <linux/fs.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/refcount_types.h>
#include <linux/utsname.h>
#include <linux/lockd/bind.h>
diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h
index f3f91280d20b..524d774e52b0 100644
--- a/include/linux/memory-tiers.h
+++ b/include/linux/memory-tiers.h
@@ -4,7 +4,7 @@

#include <linux/types.h>
#include <linux/nodemask_types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mmzone.h>
#include <linux/notifier.h>
/*
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index f4fe593c1400..e9b6c2d1348d 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -10,6 +10,10 @@
#include <linux/userfaultfd_k.h>
#include <linux/swapops.h>

+#ifdef CONFIG_ANON_VMA_NAME
+#include <linux/kref.h>
+#endif
+
/**
* folio_is_file_lru - Should the folio be on a file LRU or anon LRU?
* @folio: The folio to test.
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 81d042c00018..28856bc6fdde 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -5,7 +5,7 @@
#include <linux/mm_types_task.h>

#include <linux/auxvec.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>
#include <linux/spinlock_types.h>
#include <linux/rbtree_types.h>
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 7be6117fad23..a50f6bce4db1 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -7,7 +7,7 @@
#define __MTD_TRANS_H__

#include <linux/mutex_types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>

struct hd_geometry;
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 13411baa80c6..69e5528cd6c4 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -16,7 +16,7 @@
#include <linux/sunrpc/auth.h>
#include <linux/nfs_xdr.h>

-#include <linux/kref.h>
+#include <linux/kref_types.h>

/*
* Valid flags for a dirty buffer
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 50ac01f8d6d1..d33735edc3cb 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -19,7 +19,7 @@
#include <linux/bug.h>
#include <linux/fs.h>
#include <linux/poll.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/percpu.h>

/*
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index cdc3574fd712..f4113dc73dce 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -14,7 +14,7 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/mod_devicetable.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mutex_types.h>
#include <linux/poll.h>
#include <linux/rpmsg/byteorder.h>
diff --git a/include/linux/sh_clk.h b/include/linux/sh_clk.h
index 3b2d8de6e7d8..ec5c2199bfce 100644
--- a/include/linux/sh_clk.h
+++ b/include/linux/sh_clk.h
@@ -5,7 +5,7 @@
#include <linux/list.h>
#include <linux/cpufreq.h>
#include <linux/types.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/clk.h>
#include <linux/err.h>

diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 464f6a9492ab..8e0db9706986 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -14,7 +14,7 @@
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/ktime.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/xdr.h>
#include <linux/sunrpc/msg_prot.h>
diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h
index d8dbef6b7fc2..a1fa81483c61 100644
--- a/include/linux/surface_aggregator/serial_hub.h
+++ b/include/linux/surface_aggregator/serial_hub.h
@@ -13,7 +13,7 @@
#define _LINUX_SURFACE_AGGREGATOR_SERIAL_HUB_H

#include <linux/crc-itu-t.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/ktime.h>
#include <linux/list.h>
#include <linux/types.h>
diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
index 911ddf92dcee..6e900afbefb8 100644
--- a/include/linux/tee_drv.h
+++ b/include/linux/tee_drv.h
@@ -8,7 +8,7 @@

#include <linux/device.h>
#include <linux/idr.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>
#include <linux/mod_devicetable.h>
#include <linux/tee.h>
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 311a30c69a89..3dbfbef457de 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -15,7 +15,7 @@
#include <linux/delay.h> /* for mdelay() */
#include <linux/interrupt.h> /* for in_interrupt() */
#include <linux/list.h> /* for struct list_head */
-#include <linux/kref.h> /* for struct kref */
+#include <linux/kref_types.h> /* for struct kref */
#include <linux/device.h> /* for struct device */
#include <linux/fs.h> /* for struct file_operations */
#include <linux/completion.h> /* for struct completion */
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 2d47c0ae9d64..9e187981537e 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -9,7 +9,7 @@
#ifndef __LINUX_USB_SERIAL_H
#define __LINUX_USB_SERIAL_H

-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/mutex_types.h>
#include <linux/serial.h>
#include <linux/kfifo.h>
diff --git a/include/linux/watch_queue.h b/include/linux/watch_queue.h
index 429c7b6afead..7943a4d15c2f 100644
--- a/include/linux/watch_queue.h
+++ b/include/linux/watch_queue.h
@@ -11,7 +11,7 @@
#define _LINUX_WATCH_QUEUE_H

#include <uapi/linux/watch_queue.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/rcupdate.h>

#ifdef CONFIG_WATCH_QUEUE
diff --git a/include/media/media-request.h b/include/media/media-request.h
index 3cd25a2717ce..0747bd09d93d 100644
--- a/include/media/media-request.h
+++ b/include/media/media-request.h
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/refcount.h>
+#include <linux/kref.h>

#include <media/media-device.h>

diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index f6f111fae33c..59bdd74f312c 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -13,6 +13,8 @@
#include <media/v4l2-subdev.h>
#include <media/v4l2-dev.h>

+#include <linux/kref.h>
+
struct v4l2_ctrl_handler;

/**
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 8f8dd9173714..eb1e03e8f479 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -29,6 +29,7 @@
#include <linux/idr.h>
#include <linux/leds.h>
#include <linux/rculist.h>
+#include <linux/kref.h>

#include <net/bluetooth/hci.h>
#include <net/bluetooth/hci_sync.h>
diff --git a/include/net/tls_toe.h b/include/net/tls_toe.h
index b3aa7593ce2c..7bd0d9edfe8c 100644
--- a/include/net/tls_toe.h
+++ b/include/net/tls_toe.h
@@ -31,7 +31,7 @@
* SOFTWARE.
*/

-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>

struct sock;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3800bb8b9c14..64b62d1388a4 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -16,7 +16,7 @@
#include <linux/types.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/list.h>
#include <linux/rwsem.h>
#include <linux/workqueue_types.h>
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
index 11e487bdf61c..f5a4ae56a1d9 100644
--- a/include/rdma/restrack.h
+++ b/include/rdma/restrack.h
@@ -8,7 +8,7 @@

#include <linux/typecheck.h>
#include <linux/sched.h>
-#include <linux/kref.h>
+#include <linux/kref_types.h>
#include <linux/completion.h>
#include <linux/sched/task.h>
#include <uapi/rdma/rdma_netlink.h>
diff --git a/include/rdma/uverbs_types.h b/include/rdma/uverbs_types.h
index ccd11631c167..8744e75220a3 100644
--- a/include/rdma/uverbs_types.h
+++ b/include/rdma/uverbs_types.h
@@ -7,6 +7,7 @@
#define _UVERBS_TYPES_

#include <linux/kernel.h>
+#include <linux/kref.h>
#include <rdma/ib_verbs.h>

struct uverbs_obj_type;
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1782f90cd8c6..9fc9d3dd066c 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -10,6 +10,7 @@

#include <linux/irq.h>
#include <linux/kthread.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/interrupt.h>
diff --git a/kernel/relay.c b/kernel/relay.c
index a8e90e98bf2c..c4e746950db9 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -22,6 +22,7 @@
#include <linux/mm.h>
#include <linux/cpu.h>
#include <linux/splice.h>
+#include <linux/kref.h>

/* list of open channels, for cpu hotplug */
static DEFINE_MUTEX(relay_channels_mutex);
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 2655c71c0763..89f29ce7c58c 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -15,6 +15,7 @@
#include <linux/printk.h>
#include <linux/miscdevice.h>
#include <linux/fs.h>
+#include <linux/kref.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/poll.h>
diff --git a/lib/klist.c b/lib/klist.c
index 332a4fbf18ff..4b21ad1f24ad 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -36,6 +36,7 @@
#include <linux/klist.h>
#include <linux/export.h>
#include <linux/sched.h>
+#include <linux/kref.h>

/*
* Use the lowest bit of n_klist to mark deleted nodes and exclude
diff --git a/lib/kobject.c b/lib/kobject.c
index 3375f5b92baf..c7b3513158ad 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -20,6 +20,7 @@
#include <linux/random.h>
#include <linux/uidgid.h>
#include <linux/workqueue.h>
+#include <linux/kref.h>

/**
* kobject_namespace() - Return @kobj's namespace tag.
diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
index 58636ccd0494..425fcd857ef1 100644
--- a/mm/memory-tiers.c
+++ b/mm/memory-tiers.c
@@ -3,6 +3,7 @@
#include <linux/lockdep.h>
#include <linux/sysfs.h>
#include <linux/kobject.h>
+#include <linux/kref.h>
#include <linux/memory.h>
#include <linux/memory-tiers.h>
#include <linux/notifier.h>
diff --git a/mm/z3fold.c b/mm/z3fold.c
index 7c76b396b74c..8ce04e6e7443 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -40,6 +40,7 @@
#include <linux/spinlock.h>
#include <linux/zpool.h>
#include <linux/kmemleak.h>
+#include <linux/kref.h>

/*
* NCHUNKS_ORDER determines the internal allocation granularity, effectively
diff --git a/mm/zswap.c b/mm/zswap.c
index de68a5928527..01d2a0722d45 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -36,6 +36,7 @@
#include <linux/pagemap.h>
#include <linux/workqueue.h>
#include <linux/list_lru.h>
+#include <linux/kref.h>

#include "swap.h"
#include "internal.h"
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index ecff1c947d68..5ee94b242a25 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -17,6 +17,7 @@
#include <linux/can/skb.h>
#include <linux/if_arp.h>
#include <linux/module.h>
+#include <linux/kref.h>

#include "j1939-priv.h"

diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index fba7d1a0bd5c..258d638701f5 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -10,6 +10,7 @@

#include <linux/can/skb.h>
#include <linux/hrtimer.h>
+#include <linux/kref.h>

#include "j1939-priv.h"

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index ac7be864e80d..8d2de3a80e7f 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -17,6 +17,7 @@
#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
+#include <linux/kref.h>
#include <net/dsa_stubs.h>
#include <net/sch_generic.h>

diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index 18be13fb9b75..0a0af3b7f7e6 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -8,6 +8,7 @@

#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/list.h>
#include <linux/nfc.h>

diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c
index 41ece61eb57a..f26aa822c8ef 100644
--- a/net/qrtr/af_qrtr.c
+++ b/net/qrtr/af_qrtr.c
@@ -9,6 +9,7 @@
#include <linux/termios.h> /* For TIOCINQ/OUTQ */
#include <linux/spinlock.h>
#include <linux/wait.h>
+#include <linux/kref.h>

#include <net/sock.h>

diff --git a/net/rds/message.c b/net/rds/message.c
index 7af59d2443e5..8f9d4d0b3b54 100644
--- a/net/rds/message.c
+++ b/net/rds/message.c
@@ -36,6 +36,7 @@
#include <linux/skbuff.h>
#include <linux/list.h>
#include <linux/errqueue.h>
+#include <linux/kref.h>

#include "rds.h"

diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index fba82d36593a..b1746a7efd7d 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -31,6 +31,7 @@
*
*/
#include <linux/pagemap.h>
+#include <linux/kref.h>
#include <linux/slab.h>
#include <linux/rbtree.h>
#include <linux/dma-mapping.h> /* for DMA_*_DEVICE */
diff --git a/net/tipc/node.c b/net/tipc/node.c
index c1e890a82434..9f57d181e468 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -46,6 +46,8 @@
#include "trace.h"
#include "crypto.h"

+#include <linux/kref.h>
+
#define INVALID_NODE_SIG 0x10000
#define NODE_CLEANUP_AFTER 300000

diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 05d49ad81290..2aecf783a314 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -39,6 +39,8 @@
#include "name_table.h"
#include "subscr.h"

+#include <linux/kref.h>
+
static void tipc_sub_send_event(struct tipc_subscription *sub,
struct publication *p,
u32 event)
diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c
index 8ee0c07d00e9..5691abab78f2 100644
--- a/net/tipc/topsrv.c
+++ b/net/tipc/topsrv.c
@@ -43,6 +43,7 @@
#include "bearer.h"
#include <net/sock.h>
#include <linux/module.h>
+#include <linux/kref.h>
#include <trace/events/sock.h>

/* Number of messages to send before rescheduling */
diff --git a/net/tls/tls_toe.c b/net/tls/tls_toe.c
index 825669e1ab47..1a1c7aca3cda 100644
--- a/net/tls/tls_toe.c
+++ b/net/tls/tls_toe.c
@@ -34,6 +34,7 @@
#include <linux/list.h>
#include <linux/rcupdate.h>
#include <linux/spinlock.h>
+#include <linux/kref.h>
#include <net/inet_connection_sock.h>
#include <net/tls.h>
#include <net/tls_toe.h>
diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
index 2a2a5bd98110..93dcbc01db77 100644
--- a/sound/soc/qcom/qdsp6/q6apm.c
+++ b/sound/soc/qcom/qdsp6/q6apm.c
@@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/soc/qcom/apr.h>
#include <linux/wait.h>
+#include <linux/kref.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/pcm.h>
--
2.39.2