lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230717124013.38796-5-samsagax@gmail.com>
Date:   Mon, 17 Jul 2023 09:40:06 -0300
From:   Joaquín Ignacio Aramendía 
        <samsagax@...il.com>
To:     linux@...ck-us.net
Cc:     Joaquín Ignacio Aramendía 
        <samsagax@...il.com>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org
Subject: [PATCH 3/3] hwmon: (oxp-sensors) Refactor init() and remove probe()

Since the driver is not hotpluggable the probe() funtion is not used
more than once.

Move all attribute registration logic to the init() function.
---
 drivers/hwmon/oxp-sensors.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c
index c70d9355eeba..39de49c8a392 100644
--- a/drivers/hwmon/oxp-sensors.c
+++ b/drivers/hwmon/oxp-sensors.c
@@ -431,32 +431,20 @@ static const struct hwmon_chip_info oxp_ec_chip_info = {
 	.info = oxp_platform_sensors,
 };
 
-/* Initialization logic */
-static int oxp_platform_probe(struct platform_device *pdev)
-{
-	const struct dmi_system_id *dmi_entry;
-	struct device *dev = &pdev->dev;
-	struct device *hwdev;
-
-	hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL,
-						     &oxp_ec_chip_info, NULL);
-
-	return PTR_ERR_OR_ZERO(hwdev);
-}
-
 static struct platform_driver oxp_platform_driver = {
 	.driver = {
 		.name = "oxp-platform",
 		.dev_groups = oxp_ec_groups,
 	},
-	.probe = oxp_platform_probe,
 };
 
 static struct platform_device *oxp_platform_device;
 
+/* Initialization logic */
 static int __init oxp_platform_init(void)
 {
 	const struct dmi_system_id *dmi_entry;
+	struct device *hwdev;
 
 	/*
 	 * Have to check for AMD processor here because DMI strings are the
@@ -472,10 +460,21 @@ static int __init oxp_platform_init(void)
 	board = (enum oxp_board)(unsigned long)dmi_entry->driver_data;
 
 	oxp_platform_device =
-		platform_create_bundle(&oxp_platform_driver,
-				       oxp_platform_probe, NULL, 0, NULL, 0);
+		platform_create_bundle(&oxp_platform_driver, NULL, NULL, 0,
+				       NULL, 0);
+	if (IS_ERR(oxp_platform_device))
+		return PTR_ERR(oxp_platform_device);
 
-	return PTR_ERR_OR_ZERO(oxp_platform_device);
+	hwdev = devm_hwmon_device_register_with_info(&oxp_platform_device->dev,
+						     "oxpec", NULL,
+						     &oxp_ec_chip_info, NULL);
+	if (IS_ERR(hwdev)) {
+		platform_device_unregister(oxp_platform_device);
+		platform_driver_unregister(&oxp_platform_driver);
+		return PTR_ERR(hwdev);
+	}
+
+	return 0;
 }
 
 static void __exit oxp_platform_exit(void)
-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ