From: "Joaquín Ignacio Aramendía" <samsagax@gmail.com>
To: linux@roeck-us.net
Cc: "Joaquín Ignacio Aramendía" <samsagax@gmail.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
gregkh@linuxfoundation.org
Subject: [PATCH 3/3] hwmon: (oxp-sensors) Refactor init() and remove probe()
Date: Mon, 17 Jul 2023 09:40:06 -0300 [thread overview]
Message-ID: <20230717124013.38796-5-samsagax@gmail.com> (raw)
In-Reply-To: <20230717124013.38796-2-samsagax@gmail.com>
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
next prev parent reply other threads:[~2023-07-17 12:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 12:40 [PATCH 0/3] hwmon: (oxp-sensors) Refactor probe() and init() and remove devm_add_groups() Joaquín Ignacio Aramendía
2023-07-17 12:40 ` [PATCH 1/3] hwmon: (oxp-sensors) Move tt_toggle attribute to dev_groups Joaquín Ignacio Aramendía
2023-07-17 13:42 ` Greg KH
2023-07-17 16:29 ` Joaquin Aramendia
2023-07-17 12:40 ` [PATCH 2/3] hwmon: (oxp-sensors) Move board detection to the init function Joaquín Ignacio Aramendía
2023-07-17 12:40 ` Joaquín Ignacio Aramendía [this message]
2023-07-17 13:45 ` [PATCH 3/3] hwmon: (oxp-sensors) Refactor init() and remove probe() Greg KH
2023-07-17 15:02 ` Guenter Roeck
2023-07-17 16:40 ` Joaquin Aramendia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230717124013.38796-5-samsagax@gmail.com \
--to=samsagax@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome