diff mbox series

[v2,05/24] EDAC, mc: Fix and improve sysfs init functions

Message ID 20190624150758.6695-6-rrichter@marvell.com
State New
Headers show
Series EDAC, mc, ghes: Fixes and updates to improve memory error reporting | expand

Commit Message

Robert Richter June 24, 2019, 3:09 p.m. UTC
Remove gotos as they just create overhead. Also, fix debug message for
the case edac_create_dimm_object() is failing.

Signed-off-by: Robert Richter <rrichter@marvell.com>

---
 drivers/edac/edac_mc_sysfs.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

-- 
2.20.1

Comments

Borislav Petkov Aug. 13, 2019, 8:26 a.m. UTC | #1
On Mon, Jun 24, 2019 at 03:09:02PM +0000, Robert Richter wrote:
> Remove gotos as they just create overhead.


Overhead?

> Also, fix debug message for

> the case edac_create_dimm_object() is failing.

> 

> Signed-off-by: Robert Richter <rrichter@marvell.com>

> ---

>  drivers/edac/edac_mc_sysfs.c | 25 +++++++++----------------

>  1 file changed, 9 insertions(+), 16 deletions(-)

> 

> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c

> index 7c01e1cc030c..29dd9719f82f 100644

> --- a/drivers/edac/edac_mc_sysfs.c

> +++ b/drivers/edac/edac_mc_sysfs.c

> @@ -655,8 +655,9 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,

>  	err = device_add(&dimm->dev);

>  	if (err)

>  		put_device(&dimm->dev);

> -

> -	edac_dbg(0, "created rank/dimm device %s\n", dev_name(&dimm->dev));

> +	else

> +		edac_dbg(0, "created rank/dimm device %s\n",

> +			dev_name(&dimm->dev));


Please add a message to the error case too.

>  	return err;

>  }

> @@ -938,7 +939,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,

>  	if (err < 0) {

>  		edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));

>  		put_device(&mci->dev);

> -		goto out;

> +		return err;

>  	}

>  

>  	/*

> @@ -987,7 +988,6 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,

>  	}

>  	device_unregister(&mci->dev);

>  

> -out:

>  	return err;

>  }

>  

> @@ -1044,10 +1044,8 @@ int __init edac_mc_sysfs_init(void)

>  	int err;

>  

>  	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);

> -	if (!mci_pdev) {

> -		err = -ENOMEM;

> -		goto out;

> -	}

> +	if (!mci_pdev)

> +		return -ENOMEM;

>  

>  	mci_pdev->bus = edac_get_sysfs_subsys();

>  	mci_pdev->type = &mc_attr_type;

> @@ -1056,15 +1054,10 @@ int __init edac_mc_sysfs_init(void)

>  

>  	err = device_add(mci_pdev);

>  	if (err < 0)

> -		goto out_put_device;

> -

> -	edac_dbg(0, "device %s created\n", dev_name(mci_pdev));

> -

> -	return 0;

> +		put_device(mci_pdev);

> +	else

> +		edac_dbg(0, "device %s created\n", dev_name(mci_pdev));


Ditto.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
diff mbox series

Patch

diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 7c01e1cc030c..29dd9719f82f 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -655,8 +655,9 @@  static int edac_create_dimm_object(struct mem_ctl_info *mci,
 	err = device_add(&dimm->dev);
 	if (err)
 		put_device(&dimm->dev);
-
-	edac_dbg(0, "created rank/dimm device %s\n", dev_name(&dimm->dev));
+	else
+		edac_dbg(0, "created rank/dimm device %s\n",
+			dev_name(&dimm->dev));
 
 	return err;
 }
@@ -938,7 +939,7 @@  int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,
 	if (err < 0) {
 		edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
 		put_device(&mci->dev);
-		goto out;
+		return err;
 	}
 
 	/*
@@ -987,7 +988,6 @@  int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,
 	}
 	device_unregister(&mci->dev);
 
-out:
 	return err;
 }
 
@@ -1044,10 +1044,8 @@  int __init edac_mc_sysfs_init(void)
 	int err;
 
 	mci_pdev = kzalloc(sizeof(*mci_pdev), GFP_KERNEL);
-	if (!mci_pdev) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!mci_pdev)
+		return -ENOMEM;
 
 	mci_pdev->bus = edac_get_sysfs_subsys();
 	mci_pdev->type = &mc_attr_type;
@@ -1056,15 +1054,10 @@  int __init edac_mc_sysfs_init(void)
 
 	err = device_add(mci_pdev);
 	if (err < 0)
-		goto out_put_device;
-
-	edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
-
-	return 0;
+		put_device(mci_pdev);
+	else
+		edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
 
- out_put_device:
-	put_device(mci_pdev);
- out:
 	return err;
 }