lkml.org 
[lkml]   [2018]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] netcp_ethss: Delete error messages for a failed memory allocation in three functions
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jan 2018 22:08:50 +0100

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/ti/netcp_ethss.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 4ad821655e51..91ce6f8f8098 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3176,20 +3176,15 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u64),
GFP_KERNEL);
- if (!gbe_dev->hw_stats) {
- dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
+ if (!gbe_dev->hw_stats)
return -ENOMEM;
- }

gbe_dev->hw_stats_prev =
devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u32),
GFP_KERNEL);
- if (!gbe_dev->hw_stats_prev) {
- dev_err(gbe_dev->dev,
- "hw_stats_prev memory allocation failed\n");
+ if (!gbe_dev->hw_stats_prev)
return -ENOMEM;
- }

gbe_dev->ss_version = XGBE_SS_VERSION_10;
gbe_dev->sgmii_port_regs = gbe_dev->ss_regs +
@@ -3296,20 +3291,15 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u64),
GFP_KERNEL);
- if (!gbe_dev->hw_stats) {
- dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
+ if (!gbe_dev->hw_stats)
return -ENOMEM;
- }

gbe_dev->hw_stats_prev =
devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u32),
GFP_KERNEL);
- if (!gbe_dev->hw_stats_prev) {
- dev_err(gbe_dev->dev,
- "hw_stats_prev memory allocation failed\n");
+ if (!gbe_dev->hw_stats_prev)
return -ENOMEM;
- }

gbe_dev->sgmii_port_regs = gbe_dev->ss_regs + GBE13_SGMII_MODULE_OFFSET;
gbe_dev->host_port_regs = gbe_dev->switch_regs + GBE13_HOST_PORT_OFFSET;
@@ -3368,20 +3358,15 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u64),
GFP_KERNEL);
- if (!gbe_dev->hw_stats) {
- dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
+ if (!gbe_dev->hw_stats)
return -ENOMEM;
- }

gbe_dev->hw_stats_prev =
devm_kzalloc(gbe_dev->dev,
gbe_dev->num_et_stats * sizeof(u32),
GFP_KERNEL);
- if (!gbe_dev->hw_stats_prev) {
- dev_err(gbe_dev->dev,
- "hw_stats_prev memory allocation failed\n");
+ if (!gbe_dev->hw_stats_prev)
return -ENOMEM;
- }

ret = of_address_to_resource(node, GBENU_SM_REG_INDEX, &res);
if (ret) {
--
2.15.1
\
 
 \ /
  Last update: 2018-01-02 22:29    [W:0.023 / U:11.068 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site