[v2,35/36,RFC] coresight: add return value for fixup connections
diff mbox series

Message ID 1555344260-12375-36-git-send-email-suzuki.poulose@arm.com
State Superseded
Headers show
Series
  • coresight: Support for ACPI bindings
Related show

Commit Message

Suzuki K Poulose April 15, 2019, 4:04 p.m. UTC
Handle failures in fixing up connections for a newly registered
device. This will be useful to handle cases where we fail to expose
the links via sysfs for the connections.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Comments

Mathieu Poirier April 29, 2019, 5:44 p.m. UTC | #1
On Mon, Apr 15, 2019 at 05:04:18PM +0100, Suzuki K Poulose wrote:
> Handle failures in fixing up connections for a newly registered
> device. This will be useful to handle cases where we fail to expose
> the links via sysfs for the connections.
> 
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/hwtracing/coresight/coresight.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 010bc86..4d63063 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -1025,18 +1025,18 @@ static int coresight_orphan_match(struct device *dev, void *data)
>  	return 0;
>  }
>  
> -static void coresight_fixup_orphan_conns(struct coresight_device *csdev)
> +static int coresight_fixup_orphan_conns(struct coresight_device *csdev)
>  {
>  	/*
>  	 * No need to check for a return value as orphan connection(s)
>  	 * are hooked-up with each newly added component.
>  	 */
> -	bus_for_each_dev(&coresight_bustype, NULL,
> +	return bus_for_each_dev(&coresight_bustype, NULL,
>  			 csdev, coresight_orphan_match);

After this patch the comment is no longer true - please consider amending.

With the above:

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

>  }
>  
>  
> -static void coresight_fixup_device_conns(struct coresight_device *csdev)
> +static int coresight_fixup_device_conns(struct coresight_device *csdev)
>  {
>  	int i;
>  
> @@ -1056,6 +1056,8 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)
>  			conn->child_dev = NULL;
>  		}
>  	}
> +
> +	return 0;
>  }
>  
>  static int coresight_remove_match(struct device *dev, void *data)
> @@ -1265,10 +1267,15 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
>  
>  	mutex_lock(&coresight_mutex);
>  
> -	coresight_fixup_device_conns(csdev);
> -	coresight_fixup_orphan_conns(csdev);
> +	ret = coresight_fixup_device_conns(csdev);
> +	if (!ret)
> +		ret = coresight_fixup_orphan_conns(csdev);
>  
>  	mutex_unlock(&coresight_mutex);
> +	if (ret) {
> +		coresight_unregister(csdev);
> +		return ERR_PTR(ret);
> +	}
>  
>  	return csdev;
>  
> -- 
> 2.7.4
>

Patch
diff mbox series

diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 010bc86..4d63063 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -1025,18 +1025,18 @@  static int coresight_orphan_match(struct device *dev, void *data)
 	return 0;
 }
 
-static void coresight_fixup_orphan_conns(struct coresight_device *csdev)
+static int coresight_fixup_orphan_conns(struct coresight_device *csdev)
 {
 	/*
 	 * No need to check for a return value as orphan connection(s)
 	 * are hooked-up with each newly added component.
 	 */
-	bus_for_each_dev(&coresight_bustype, NULL,
+	return bus_for_each_dev(&coresight_bustype, NULL,
 			 csdev, coresight_orphan_match);
 }
 
 
-static void coresight_fixup_device_conns(struct coresight_device *csdev)
+static int coresight_fixup_device_conns(struct coresight_device *csdev)
 {
 	int i;
 
@@ -1056,6 +1056,8 @@  static void coresight_fixup_device_conns(struct coresight_device *csdev)
 			conn->child_dev = NULL;
 		}
 	}
+
+	return 0;
 }
 
 static int coresight_remove_match(struct device *dev, void *data)
@@ -1265,10 +1267,15 @@  struct coresight_device *coresight_register(struct coresight_desc *desc)
 
 	mutex_lock(&coresight_mutex);
 
-	coresight_fixup_device_conns(csdev);
-	coresight_fixup_orphan_conns(csdev);
+	ret = coresight_fixup_device_conns(csdev);
+	if (!ret)
+		ret = coresight_fixup_orphan_conns(csdev);
 
 	mutex_unlock(&coresight_mutex);
+	if (ret) {
+		coresight_unregister(csdev);
+		return ERR_PTR(ret);
+	}
 
 	return csdev;