Skip to contentSkip to conversation

platform/mellanox: nvsw-sn2201: fix error code in nvsw_sn2201_create_static_devices()

PATCH In review Dan Carpenter 3 participants 3 messages Jun 15, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/mellanox: nvsw-sn2201: fix error code in nvsw_sn2201_create_static_devices()

This should return PTR_ERR() instead of IS_ERR(). Also "dev->client" has been set to NULL by this point so it returns 0/success so preserve the error code earlier.

Fixes 662f24826f95 ("platform/mellanox: Add support for new SN2201 system")
---
 drivers/platform/mellanox/nvsw-sn2201.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/mellanox/nvsw-sn2201.c +3 -1
index 0bcdc7c75007..217e22e81c1a 100644
@@ -890,6 +890,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 				  int size)
 {
 	struct mlxreg_hotplug_device *dev = devs;
+	int ret;
 	int i;
 
 	/* Create I2C static devices. */
@@ -901,6 +902,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 				dev->nr, dev->brdinfo->addr);
 
 			dev->adapter = NULL;
+			ret = PTR_ERR(dev->client);
 			goto fail_create_static_devices;
 		}
 	}
@@ -914,7 +916,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 		dev->client = NULL;
 		dev->adapter = NULL;
 	}
-	return IS_ERR(dev->client);
+	return ret;
 }
 
 static void nvsw_sn2201_destroy_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Wednesday, June 15, 2022 11:11 AM
To: Hans de Goede <[email protected]>; Michael Shych <[email protected]>
Cc: Mark Gross <[email protected]>; Vadim Pasternak <[email protected]>; [email protected]; kernel- [email protected]
Subject: [PATCH] platform/mellanox: nvsw-sn2201: fix error code in nvsw_sn2201_create_static_devices()

Quoted 7 lines

This should return PTR_ERR() instead of IS_ERR(). Also "dev->client" has been set to NULL by this point so it returns 0/success so preserve the error code earlier.

Fixes 662f24826f95 ("platform/mellanox: Add support for new SN2201

system")

Quoted 40 lines
---
 drivers/platform/mellanox/nvsw-sn2201.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/mellanox/nvsw-sn2201.c +1 -0
index 0bcdc7c75007..217e22e81c1a 100644
@@ -890,6 +890,7 @@ nvsw_sn2201_create_static_devices(struct
 nvsw_sn2201 *nvsw_sn2201,
 				  int size)
 {
 	struct mlxreg_hotplug_device *dev = devs;
+	int ret;
 	int i;
 
drivers/platform/mellanox/nvsw-sn2201.c +1 -0
 	/* Create I2C static devices. */
@@ -901,6 +902,7 @@ nvsw_sn2201_create_static_devices(struct
 nvsw_sn2201 *nvsw_sn2201,
 				dev->nr, dev->brdinfo->addr);
 
 			dev->adapter = NULL;
+			ret = PTR_ERR(dev->client);
 			goto fail_create_static_devices;
 		}
drivers/platform/mellanox/nvsw-sn2201.c +1 -1
 	}
@@ -914,7 +916,7 @@ nvsw_sn2201_create_static_devices(struct
 nvsw_sn2201 *nvsw_sn2201,
 		dev->client = NULL;
 		dev->adapter = NULL;
 	}
-	return IS_ERR(dev->client);
+	return ret;
 }
 

static void nvsw_sn2201_destroy_static_devices(struct nvsw_sn2201
*nvsw_sn2201,
--
2.35.1

#2 lore raw
In reply to Dan Carpenter

Hi,

Quoted 6 lines · Dan Carpenter

This should return PTR_ERR() instead of IS_ERR(). Also "dev->client" has been set to NULL by this point so it returns 0/success so preserve the error code earlier.

Fixes 662f24826f95 ("platform/mellanox: Add support for new SN2201 system")

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 33 lines
---
 drivers/platform/mellanox/nvsw-sn2201.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/mellanox/nvsw-sn2201.c +3 -1
index 0bcdc7c75007..217e22e81c1a 100644
@@ -890,6 +890,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 				  int size)
 {
 	struct mlxreg_hotplug_device *dev = devs;
+	int ret;
 	int i;
 
 	/* Create I2C static devices. */
@@ -901,6 +902,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 				dev->nr, dev->brdinfo->addr);
 
 			dev->adapter = NULL;
+			ret = PTR_ERR(dev->client);
 			goto fail_create_static_devices;
 		}
 	}
@@ -914,7 +916,7 @@ nvsw_sn2201_create_static_devices(struct nvsw_sn2201 *nvsw_sn2201,
 		dev->client = NULL;
 		dev->adapter = NULL;
 	}
-	return IS_ERR(dev->client);
+	return ret;
 }
 
 static void nvsw_sn2201_destroy_static_devices(struct nvsw_sn2201 *nvsw_sn2201,