mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
coresight: improve error handling for exported coresight apis
Enhance error handling to provide graceful behavior in the case of incorrect topology representation by the user. This specifically improves the behavior when some of the required device DT nodes are missed or required driver(s) are not compiled. CRs-Fixed: 446155 Change-Id: I1bb72732a6f2d230775d8ce1ffec574adc3890d0 Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
This commit is contained in:
parent
33192b8cf9
commit
34e53ba15d
1 changed files with 37 additions and 8 deletions
|
@ -196,6 +196,9 @@ static struct list_head *coresight_build_path(struct coresight_device *csdev,
|
|||
struct list_head *p;
|
||||
struct coresight_connection *conn;
|
||||
|
||||
if (!csdev)
|
||||
return NULL;
|
||||
|
||||
if (csdev->id == curr_sink) {
|
||||
list_add_tail(&csdev->path_link, path);
|
||||
return path;
|
||||
|
@ -273,9 +276,9 @@ static void coresight_disable_path(struct list_head *path, bool incl_source)
|
|||
|
||||
static int coresight_switch_sink(struct coresight_device *csdev)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret, prev_sink;
|
||||
LIST_HEAD(path);
|
||||
struct coresight_device *cd;
|
||||
struct coresight_device *cd, *err_cd;
|
||||
|
||||
if (IS_ERR_OR_NULL(csdev))
|
||||
return -EINVAL;
|
||||
|
@ -291,10 +294,15 @@ static int coresight_switch_sink(struct coresight_device *csdev)
|
|||
coresight_release_path(&path);
|
||||
}
|
||||
}
|
||||
prev_sink = curr_sink;
|
||||
curr_sink = csdev->id;
|
||||
list_for_each_entry(cd, &coresight_devs, dev_link) {
|
||||
if (cd->type == CORESIGHT_DEV_TYPE_SOURCE && cd->enable) {
|
||||
coresight_build_path(cd, &path);
|
||||
if (!coresight_build_path(cd, &path)) {
|
||||
ret = -EINVAL;
|
||||
pr_err("coresight: build path failed\n");
|
||||
goto err;
|
||||
}
|
||||
ret = coresight_enable_path(&path, false);
|
||||
coresight_release_path(&path);
|
||||
if (ret)
|
||||
|
@ -305,17 +313,30 @@ out:
|
|||
up(&coresight_mutex);
|
||||
return 0;
|
||||
err:
|
||||
list_for_each_entry(cd, &coresight_devs, dev_link) {
|
||||
err_cd = cd;
|
||||
list_for_each_entry_continue_reverse(cd, &coresight_devs, dev_link) {
|
||||
if (cd->type == CORESIGHT_DEV_TYPE_SOURCE && cd->enable) {
|
||||
coresight_build_path(cd, &path);
|
||||
coresight_disable_path(&path, true);
|
||||
coresight_release_path(&path);
|
||||
}
|
||||
}
|
||||
cd = err_cd;
|
||||
/* This should be an enabled source, so we can disable it directly */
|
||||
coresight_disable_source(cd);
|
||||
list_for_each_entry_continue(cd, &coresight_devs, dev_link) {
|
||||
if (cd->type == CORESIGHT_DEV_TYPE_SOURCE && cd->enable)
|
||||
coresight_disable_source(cd);
|
||||
}
|
||||
curr_sink = prev_sink;
|
||||
up(&coresight_mutex);
|
||||
pr_err("coresight: sink switch failed, sources disabled; try again\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int coresight_enable(struct coresight_device *csdev)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
LIST_HEAD(path);
|
||||
|
||||
if (IS_ERR_OR_NULL(csdev))
|
||||
|
@ -325,18 +346,26 @@ int coresight_enable(struct coresight_device *csdev)
|
|||
if (csdev->type != CORESIGHT_DEV_TYPE_SOURCE) {
|
||||
ret = -EINVAL;
|
||||
pr_err("coresight: wrong device type in %s\n", __func__);
|
||||
goto out;
|
||||
goto err;
|
||||
}
|
||||
if (csdev->enable)
|
||||
goto out;
|
||||
|
||||
coresight_build_path(csdev, &path);
|
||||
if (!coresight_build_path(csdev, &path)) {
|
||||
ret = -EINVAL;
|
||||
pr_err("coresight: build path failed\n");
|
||||
goto err;
|
||||
}
|
||||
ret = coresight_enable_path(&path, true);
|
||||
coresight_release_path(&path);
|
||||
if (ret)
|
||||
pr_err("coresight: enable failed\n");
|
||||
goto err;
|
||||
out:
|
||||
up(&coresight_mutex);
|
||||
return 0;
|
||||
err:
|
||||
up(&coresight_mutex);
|
||||
pr_err("coresight: enable failed\n");
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(coresight_enable);
|
||||
|
|
Loading…
Reference in a new issue