Просмотр исходного кода

coresight: Handle build path error

Enabling a component via sysfs (echo 1 > enable_source), would
trigger building a path from the enabled sources to the sink.
If there is an error in the process (e.g, sink not enabled or
the device (CPU corresponding to ETM) is not online), we never report
failure, except for leaving a message in the dmesg.

Do proper error checking for the build path and return the error.

Before:
 $ echo 0 > /sys/devices/system/cpu/cpu2/online
 $ echo 1 > /sys/devices/cs_etm/cpu2/enable_source
 $ echo $?
 0

After:
 $ echo 0 > /sys/devices/system/cpu/cpu2/online
 $ echo 1 > /sys/devices/cs_etm/cpu2/enable_source
 -bash: echo: write error: No such device or address

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suzuki K Poulose 9 лет назад
Родитель
Сommit
5014e90468
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      drivers/hwtracing/coresight/coresight.c

+ 6 - 3
drivers/hwtracing/coresight/coresight.c

@@ -425,6 +425,7 @@ out:
 struct list_head *coresight_build_path(struct coresight_device *csdev)
 struct list_head *coresight_build_path(struct coresight_device *csdev)
 {
 {
 	struct list_head *path;
 	struct list_head *path;
+	int rc;
 
 
 	path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
 	path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
 	if (!path)
 	if (!path)
@@ -432,9 +433,10 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
 
 
 	INIT_LIST_HEAD(path);
 	INIT_LIST_HEAD(path);
 
 
-	if (_coresight_build_path(csdev, path)) {
+	rc = _coresight_build_path(csdev, path);
+	if (rc) {
 		kfree(path);
 		kfree(path);
-		path = NULL;
+		return ERR_PTR(rc);
 	}
 	}
 
 
 	return path;
 	return path;
@@ -507,8 +509,9 @@ int coresight_enable(struct coresight_device *csdev)
 		goto out;
 		goto out;
 
 
 	path = coresight_build_path(csdev);
 	path = coresight_build_path(csdev);
-	if (!path) {
+	if (IS_ERR(path)) {
 		pr_err("building path(s) failed\n");
 		pr_err("building path(s) failed\n");
+		ret = PTR_ERR(path);
 		goto out;
 		goto out;
 	}
 	}