]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvme-core: add method to check for an I/O controller
authorKamaljit Singh <kamaljit.singh@opensource.wdc.com>
Fri, 5 Sep 2025 23:25:49 +0000 (16:25 -0700)
committerKeith Busch <kbusch@kernel.org>
Tue, 23 Sep 2025 22:38:28 +0000 (15:38 -0700)
Add nvme_is_io_ctrl() to check if the controller is of type I/O
controller. Uses negative logic by excluding an administrative
controller and a discovery controller.

Signed-off-by: Kamaljit Singh <kamaljit.singh@opensource.wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/core.c

index 812c1565114fde21000c80ae8968c4346179133d..0f20adcebcf156bb62c9f57318936fa9d9df496d 100644 (file)
@@ -3163,6 +3163,11 @@ static inline bool nvme_admin_ctrl(struct nvme_ctrl *ctrl)
        return ctrl->cntrltype == NVME_CTRL_ADMIN;
 }
 
+static inline bool nvme_is_io_ctrl(struct nvme_ctrl *ctrl)
+{
+       return !nvme_discovery_ctrl(ctrl) && !nvme_admin_ctrl(ctrl);
+}
+
 static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
                struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 {