[PATCH] drm: fix writing to /sys/class/drm/*/status

Russell King rmk+kernel at arm.linux.org.uk
Fri Jun 5 11:47:22 PDT 2015


Writing to a file is supposed to return the number of bytes written.
Returning zero unfortunately causes bash to constantly spin trying
to write to the sysfs file, to such an extent that even ^c and ^z
have no effect.  The only way out of that is to kill the shell and
log back in.  This isn't nice behaviour.

Fix it by returning the number of characters written to sysfs files.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 drivers/gpu/drm/drm_sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index ffc305fc2076..e7e7edeee9fb 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -181,6 +181,8 @@ static ssize_t status_store(struct device *device,
 
 	old_status = connector->status;
 
+	ret = count;
+
 	if (sysfs_streq(buf, "detect")) {
 		connector->force = 0;
 		connector->status = connector->funcs->detect(connector, true);
@@ -193,7 +195,7 @@ static ssize_t status_store(struct device *device,
 	} else
 		ret = -EINVAL;
 
-	if (ret == 0 && connector->force) {
+	if (ret >= 0 && connector->force) {
 		if (connector->force == DRM_FORCE_ON ||
 		    connector->force == DRM_FORCE_ON_DIGITAL)
 			connector->status = connector_status_connected;
-- 
2.1.0



More information about the dri-devel mailing list