* Re: [PATCH 4/4] remoteproc: Get rid of tedious error path
@ 2020-04-14 8:53 Markus Elfring
2020-04-14 12:27 ` Alex Elder
0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-04-14 8:53 UTC (permalink / raw)
To: Mathieu Poirier, linux-remoteproc
Cc: linux-kernel, Alex Elder, Bjorn Andersson, Ohad Ben-Cohen, Suman Anna
…
> +++ b/drivers/remoteproc/remoteproc_core.c
…
> @@ -2105,11 +2104,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
…
> +out:
> + put_device(&rproc->dev);
How do you think about to use the label “put_device”?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] remoteproc: Get rid of tedious error path
2020-04-14 8:53 [PATCH 4/4] remoteproc: Get rid of tedious error path Markus Elfring
@ 2020-04-14 12:27 ` Alex Elder
0 siblings, 0 replies; 5+ messages in thread
From: Alex Elder @ 2020-04-14 12:27 UTC (permalink / raw)
To: Markus Elfring, Mathieu Poirier, linux-remoteproc
Cc: linux-kernel, Bjorn Andersson, Ohad Ben-Cohen, Suman Anna
On 4/14/20 3:53 AM, Markus Elfring wrote:
> …
>> +++ b/drivers/remoteproc/remoteproc_core.c
> …
>> @@ -2105,11 +2104,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> …
>> +out:
>> + put_device(&rproc->dev);
>
> How do you think about to use the label “put_device”?
+1
>
> Regards,
> Markus
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] remoteproc: Get rid of tedious error path
2020-04-13 19:34 ` [PATCH 4/4] remoteproc: Get rid of tedious error path Mathieu Poirier
2020-04-13 20:56 ` Alex Elder
@ 2020-04-13 20:56 ` Alex Elder
1 sibling, 0 replies; 5+ messages in thread
From: Alex Elder @ 2020-04-13 20:56 UTC (permalink / raw)
To: Mathieu Poirier, bjorn.andersson, ohad
Cc: s-anna, linux-remoteproc, linux-kernel
On 4/13/20 2:34 PM, Mathieu Poirier wrote:
> Get rid of tedious error management by moving firmware and operation
> allocation after calling device_initialize(). That way we take advantage
> of the automatic call to rproc_type_release() to cleanup after ourselves
> when put_device() is called.
Looks good to me.
Reviewed-by: Alex Elder <elder@linaro.org>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 22 +++++++++-------------
> 1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index c272d78f07e8..10009b95867a 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2061,12 +2061,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> if (!rproc)
> return NULL;
>
> - if (rproc_alloc_firmware(rproc, name, firmware))
> - goto free_rproc;
> -
> - if (rproc_alloc_ops(rproc, ops))
> - goto free_firmware;
> -
> rproc->name = name;
> rproc->priv = &rproc[1];
> rproc->auto_boot = true;
> @@ -2079,12 +2073,17 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> rproc->dev.driver_data = rproc;
> idr_init(&rproc->notifyids);
>
> + if (rproc_alloc_firmware(rproc, name, firmware))
> + goto out;
> +
> + if (rproc_alloc_ops(rproc, ops))
> + goto out;
> +
> /* Assign a unique device index and name */
> rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
> if (rproc->index < 0) {
> dev_err(dev, "ida_simple_get failed: %d\n", rproc->index);
> - put_device(&rproc->dev);
> - return NULL;
> + goto out;
> }
>
> dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
> @@ -2105,11 +2104,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> rproc->state = RPROC_OFFLINE;
>
> return rproc;
> -
> -free_firmware:
> - kfree(rproc->firmware);
> -free_rproc:
> - kfree(rproc);
> +out:
> + put_device(&rproc->dev);
> return NULL;
> }
> EXPORT_SYMBOL(rproc_alloc);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 4/4] remoteproc: Get rid of tedious error path
2020-04-13 19:34 ` [PATCH 4/4] remoteproc: Get rid of tedious error path Mathieu Poirier
@ 2020-04-13 20:56 ` Alex Elder
2020-04-13 20:56 ` Alex Elder
1 sibling, 0 replies; 5+ messages in thread
From: Alex Elder @ 2020-04-13 20:56 UTC (permalink / raw)
To: Mathieu Poirier, bjorn.andersson, ohad
Cc: s-anna, linux-remoteproc, linux-kernel
On 4/13/20 2:34 PM, Mathieu Poirier wrote:
> Get rid of tedious error management by moving firmware and operation
> allocation after calling device_initialize(). That way we take advantage
> of the automatic call to rproc_type_release() to cleanup after ourselves
> when put_device() is called.
Looks good to me.
Reviewed-by: Alex Elder <elder@linaro.org>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 22 +++++++++-------------
> 1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index c272d78f07e8..10009b95867a 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2061,12 +2061,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> if (!rproc)
> return NULL;
>
> - if (rproc_alloc_firmware(rproc, name, firmware))
> - goto free_rproc;
> -
> - if (rproc_alloc_ops(rproc, ops))
> - goto free_firmware;
> -
> rproc->name = name;
> rproc->priv = &rproc[1];
> rproc->auto_boot = true;
> @@ -2079,12 +2073,17 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> rproc->dev.driver_data = rproc;
> idr_init(&rproc->notifyids);
>
> + if (rproc_alloc_firmware(rproc, name, firmware))
> + goto out;
> +
> + if (rproc_alloc_ops(rproc, ops))
> + goto out;
> +
> /* Assign a unique device index and name */
> rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
> if (rproc->index < 0) {
> dev_err(dev, "ida_simple_get failed: %d\n", rproc->index);
> - put_device(&rproc->dev);
> - return NULL;
> + goto out;
> }
>
> dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
> @@ -2105,11 +2104,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
> rproc->state = RPROC_OFFLINE;
>
> return rproc;
> -
> -free_firmware:
> - kfree(rproc->firmware);
> -free_rproc:
> - kfree(rproc);
> +out:
> + put_device(&rproc->dev);
> return NULL;
> }
> EXPORT_SYMBOL(rproc_alloc);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] remoteproc: Get rid of tedious error path
2020-04-13 19:33 [PATCH 0/4] remoteproc: Refactor function rproc_alloc() Mathieu Poirier
@ 2020-04-13 19:34 ` Mathieu Poirier
2020-04-13 20:56 ` Alex Elder
2020-04-13 20:56 ` Alex Elder
0 siblings, 2 replies; 5+ messages in thread
From: Mathieu Poirier @ 2020-04-13 19:34 UTC (permalink / raw)
To: bjorn.andersson, ohad; +Cc: s-anna, elder, linux-remoteproc, linux-kernel
Get rid of tedious error management by moving firmware and operation
allocation after calling device_initialize(). That way we take advantage
of the automatic call to rproc_type_release() to cleanup after ourselves
when put_device() is called.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
drivers/remoteproc/remoteproc_core.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c272d78f07e8..10009b95867a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2061,12 +2061,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
if (!rproc)
return NULL;
- if (rproc_alloc_firmware(rproc, name, firmware))
- goto free_rproc;
-
- if (rproc_alloc_ops(rproc, ops))
- goto free_firmware;
-
rproc->name = name;
rproc->priv = &rproc[1];
rproc->auto_boot = true;
@@ -2079,12 +2073,17 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
rproc->dev.driver_data = rproc;
idr_init(&rproc->notifyids);
+ if (rproc_alloc_firmware(rproc, name, firmware))
+ goto out;
+
+ if (rproc_alloc_ops(rproc, ops))
+ goto out;
+
/* Assign a unique device index and name */
rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
if (rproc->index < 0) {
dev_err(dev, "ida_simple_get failed: %d\n", rproc->index);
- put_device(&rproc->dev);
- return NULL;
+ goto out;
}
dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
@@ -2105,11 +2104,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
rproc->state = RPROC_OFFLINE;
return rproc;
-
-free_firmware:
- kfree(rproc->firmware);
-free_rproc:
- kfree(rproc);
+out:
+ put_device(&rproc->dev);
return NULL;
}
EXPORT_SYMBOL(rproc_alloc);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-14 12:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 8:53 [PATCH 4/4] remoteproc: Get rid of tedious error path Markus Elfring
2020-04-14 12:27 ` Alex Elder
-- strict thread matches above, loose matches on Subject: below --
2020-04-13 19:33 [PATCH 0/4] remoteproc: Refactor function rproc_alloc() Mathieu Poirier
2020-04-13 19:34 ` [PATCH 4/4] remoteproc: Get rid of tedious error path Mathieu Poirier
2020-04-13 20:56 ` Alex Elder
2020-04-13 20:56 ` Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).