[PATCH] nvme: make controller 'state' sysfs attribute pollable

Johannes Thumshirn jthumshirn at suse.de
Wed Sep 20 03:40:32 PDT 2017


Notify sysfs about changes of a nvme controller so user-space can watch the
file via poll() or select() in order to react to a state change.

Signed-off-by: Johannes Thumshirn <jthumshirn at suse.de>
---
 drivers/nvme/host/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index acc816b67582..064d973f1e22 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -237,8 +237,10 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		break;
 	}
 
-	if (changed)
+	if (changed) {
 		ctrl->state = new_state;
+		sysfs_notify(&ctrl->dev->kobj, NULL, "state");
+	}
 
 	spin_unlock_irqrestore(&ctrl->lock, flags);
 
-- 
2.13.5




More information about the Linux-nvme mailing list