* [PATCH] staging: netlogic: Replacing pr_err with dev_err after function call to devm_kzalloc
@ 2016-03-03 3:34 pooja.shamili
2016-03-03 6:29 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: pooja.shamili @ 2016-03-03 3:34 UTC (permalink / raw)
To: outreachy-kernel
The function devm_kzalloc has a first argument of type struct device *.
This is the type of argument required by printing functions such as
dev_dbg, dev_err, etc. Thus, functions like pr_err should not normally
be used after a call to devm_kzalloc. Thus, all pr_err occurances are
replaced with dev_err function calls.
This was done using Coccinelle, the patch being:
@@
expression E1,E2;
expression list args;
identifier I;
@@
E1 = (struct I *)devm_kzalloc(E2, ...);
<...
- pr_err(
++ dev_err(E2,
args);
...>
Signed-off-by: pooja.shamili <poojashamili@gmail.com>
---
drivers/staging/netlogic/xlr_net.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index 0015847..4804fe8 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -1028,7 +1028,8 @@ static int xlr_net_probe(struct platform_device *pdev)
for (port = 0; port < pdev->num_resources / 2; port++) {
ndev = alloc_etherdev_mq(sizeof(struct xlr_net_priv), 32);
if (!ndev) {
- pr_err("Allocation of Ethernet device failed\n");
+ dev_err(&pdev->dev,
+ "Allocation of Ethernet device failed\n");
return -ENOMEM;
}
@@ -1040,8 +1041,8 @@ static int xlr_net_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, port);
if (res == NULL) {
- pr_err("No memory resource for MAC %d\n",
- priv->port_id);
+ dev_err(&pdev->dev, "No memory resource for MAC %d\n",
+ priv->port_id);
err = -ENODEV;
goto err_gmac;
}
@@ -1055,7 +1056,8 @@ static int xlr_net_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IRQ, port);
if (!res) {
- pr_err("No irq resource for MAC %d\n", priv->port_id);
+ dev_err(&pdev->dev, "No irq resource for MAC %d\n",
+ priv->port_id);
err = -ENODEV;
goto err_gmac;
}
@@ -1090,7 +1092,8 @@ static int xlr_net_probe(struct platform_device *pdev)
if (strcmp(res->name, "gmac") == 0) {
err = xlr_gmac_init(priv, pdev);
if (err) {
- pr_err("gmac%d init failed\n", priv->port_id);
+ dev_err(&pdev->dev, "gmac%d init failed\n",
+ priv->port_id);
goto err_gmac;
}
}
@@ -1103,8 +1106,9 @@ static int xlr_net_probe(struct platform_device *pdev)
err = register_netdev(ndev);
if (err) {
- pr_err("Registering netdev failed for gmac%d\n",
- priv->port_id);
+ dev_err(&pdev->dev,
+ "Registering netdev failed for gmac%d\n",
+ priv->port_id);
goto err_netdev;
}
platform_set_drvdata(pdev, priv);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: netlogic: Replacing pr_err with dev_err after function call to devm_kzalloc
2016-03-03 3:34 [PATCH] staging: netlogic: Replacing pr_err with dev_err after function call to devm_kzalloc pooja.shamili
@ 2016-03-03 6:29 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2016-03-03 6:29 UTC (permalink / raw)
To: pooja.shamili; +Cc: outreachy-kernel
On Thu, 3 Mar 2016, pooja.shamili wrote:
> The function devm_kzalloc has a first argument of type struct device *.
> This is the type of argument required by printing functions such as
> dev_dbg, dev_err, etc. Thus, functions like pr_err should not normally
> be used after a call to devm_kzalloc. Thus, all pr_err occurances are
> replaced with dev_err function calls.
>
> This was done using Coccinelle, the patch being:
>
> @@
> expression E1,E2;
> expression list args;
> identifier I;
> @@
>
> E1 = (struct I *)devm_kzalloc(E2, ...);
> <...
> - pr_err(
> ++ dev_err(E2,
Why did you use ++?
julia
> args);
> ...>
>
> Signed-off-by: pooja.shamili <poojashamili@gmail.com>
> ---
> drivers/staging/netlogic/xlr_net.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
> index 0015847..4804fe8 100644
> --- a/drivers/staging/netlogic/xlr_net.c
> +++ b/drivers/staging/netlogic/xlr_net.c
> @@ -1028,7 +1028,8 @@ static int xlr_net_probe(struct platform_device *pdev)
> for (port = 0; port < pdev->num_resources / 2; port++) {
> ndev = alloc_etherdev_mq(sizeof(struct xlr_net_priv), 32);
> if (!ndev) {
> - pr_err("Allocation of Ethernet device failed\n");
> + dev_err(&pdev->dev,
> + "Allocation of Ethernet device failed\n");
> return -ENOMEM;
> }
>
> @@ -1040,8 +1041,8 @@ static int xlr_net_probe(struct platform_device *pdev)
> res = platform_get_resource(pdev, IORESOURCE_MEM, port);
>
> if (res == NULL) {
> - pr_err("No memory resource for MAC %d\n",
> - priv->port_id);
> + dev_err(&pdev->dev, "No memory resource for MAC %d\n",
> + priv->port_id);
> err = -ENODEV;
> goto err_gmac;
> }
> @@ -1055,7 +1056,8 @@ static int xlr_net_probe(struct platform_device *pdev)
>
> res = platform_get_resource(pdev, IORESOURCE_IRQ, port);
> if (!res) {
> - pr_err("No irq resource for MAC %d\n", priv->port_id);
> + dev_err(&pdev->dev, "No irq resource for MAC %d\n",
> + priv->port_id);
> err = -ENODEV;
> goto err_gmac;
> }
> @@ -1090,7 +1092,8 @@ static int xlr_net_probe(struct platform_device *pdev)
> if (strcmp(res->name, "gmac") == 0) {
> err = xlr_gmac_init(priv, pdev);
> if (err) {
> - pr_err("gmac%d init failed\n", priv->port_id);
> + dev_err(&pdev->dev, "gmac%d init failed\n",
> + priv->port_id);
> goto err_gmac;
> }
> }
> @@ -1103,8 +1106,9 @@ static int xlr_net_probe(struct platform_device *pdev)
>
> err = register_netdev(ndev);
> if (err) {
> - pr_err("Registering netdev failed for gmac%d\n",
> - priv->port_id);
> + dev_err(&pdev->dev,
> + "Registering netdev failed for gmac%d\n",
> + priv->port_id);
> goto err_netdev;
> }
> platform_set_drvdata(pdev, priv);
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160303033418.GA20938%40localhost.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-03 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 3:34 [PATCH] staging: netlogic: Replacing pr_err with dev_err after function call to devm_kzalloc pooja.shamili
2016-03-03 6:29 ` [Outreachy kernel] " Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.