diff mbox series

[v1,1/1] hwmon: (nct6775) Drop duplicate NULL check in ->init() and ->exit()

Message ID 20220610103324.87483-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Headers show
Series [v1,1/1] hwmon: (nct6775) Drop duplicate NULL check in ->init() and ->exit() | expand

Commit Message

Andy Shevchenko June 10, 2022, 10:33 a.m. UTC
Since platform_device_unregister() is NULL-aware, we don't need to duplicate
this check. Remove it and fold the rest of the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwmon/nct6775-platform.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Zev Weiss June 10, 2022, 5:58 p.m. UTC | #1
On Fri, Jun 10, 2022 at 03:33:24AM PDT, Andy Shevchenko wrote:
>Since platform_device_unregister() is NULL-aware, we don't need to duplicate
>this check. Remove it and fold the rest of the code.
>
>Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>---
> drivers/hwmon/nct6775-platform.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>

Reviewed-by: Zev Weiss <zev@bewilderbeest.net>
Guenter Roeck June 11, 2022, 2:06 p.m. UTC | #2
On Fri, Jun 10, 2022 at 01:33:24PM +0300, Andy Shevchenko wrote:
> Since platform_device_unregister() is NULL-aware, we don't need to duplicate
> this check. Remove it and fold the rest of the code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Zev Weiss <zev@bewilderbeest.net>

Applied to hwmon-next.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c
index 6d46c9401898..3a48627419ba 100644
--- a/drivers/hwmon/nct6775-platform.c
+++ b/drivers/hwmon/nct6775-platform.c
@@ -1200,10 +1200,8 @@  static int __init sensors_nct6775_platform_init(void)
 exit_device_put:
 	platform_device_put(pdev[i]);
 exit_device_unregister:
-	while (--i >= 0) {
-		if (pdev[i])
-			platform_device_unregister(pdev[i]);
-	}
+	while (i--)
+		platform_device_unregister(pdev[i]);
 exit_unregister:
 	platform_driver_unregister(&nct6775_driver);
 	return err;
@@ -1213,10 +1211,8 @@  static void __exit sensors_nct6775_platform_exit(void)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(pdev); i++) {
-		if (pdev[i])
-			platform_device_unregister(pdev[i]);
-	}
+	for (i = 0; i < ARRAY_SIZE(pdev); i++)
+		platform_device_unregister(pdev[i]);
 	platform_driver_unregister(&nct6775_driver);
 }