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

From: Johannes Thumshirn
Date: Wed Sep 20 2017 - 06:40:54 EST


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@xxxxxxx>
---
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