From: Julian Haller <jhaller@bbl.ms.philips.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Julian Haller <julian.haller@philips.com>,
Guenter Roeck <linux@roeck-us.net>,
"Rafael J . Wysocki" <rafael@kernel.org>
Subject: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
Date: Wed, 22 Jun 2022 16:49:01 +0200 [thread overview]
Message-ID: <20220622144902.2954712-1-jhaller@bbl.ms.philips.com> (raw)
From: Guenter Roeck <linux@roeck-us.net>
[ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
The thermal subsystem registers a hwmon driver without providing
chip or sysfs group information. This is for legacy reasons and
would be difficult to change. At the same time, we want to enforce
that chip information is provided when registering a hwmon device
using hwmon_device_register_with_info(). To enable this, introduce
a special API for use only by the thermal subsystem.
Acked-by: Rafael J . Wysocki <rafael@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
include/linux/hwmon.h | 3 +++
2 files changed, 28 insertions(+)
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index c73b93b9bb87..e8a9955e3683 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -743,6 +743,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
}
EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
+/**
+ * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
+ * @dev: the parent device
+ * @name: hwmon name attribute
+ * @drvdata: driver data to attach to created device
+ *
+ * The use of this function is restricted. It is provided for legacy reasons
+ * and must only be called from the thermal subsystem.
+ *
+ * hwmon_device_unregister() must be called when the device is no
+ * longer needed.
+ *
+ * Returns the pointer to the new device.
+ */
+struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+ void *drvdata)
+{
+ if (!name || !dev)
+ return ERR_PTR(-EINVAL);
+
+ return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
+
/**
* hwmon_device_register - register w/ hwmon
* @dev: the device to register
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 72579168189d..104c492959b9 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -408,6 +408,9 @@ hwmon_device_register_with_info(struct device *dev,
const struct hwmon_chip_info *info,
const struct attribute_group **extra_groups);
struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+ void *drvdata);
+struct device *
devm_hwmon_device_register_with_info(struct device *dev,
const char *name, void *drvdata,
const struct hwmon_chip_info *info,
--
2.25.1
next reply other threads:[~2022-06-22 14:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 14:49 Julian Haller [this message]
2022-06-22 14:49 ` [PATCH 5.4 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal() Julian Haller
2022-06-22 15:02 ` [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Guenter Roeck
2022-06-22 15:39 ` Julian Haller
2022-06-22 15:44 ` Guenter Roeck
2022-06-22 16:09 ` Greg KH
2022-06-22 16:12 ` Sasha Levin
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=20220622144902.2954712-1-jhaller@bbl.ms.philips.com \
--to=jhaller@bbl.ms.philips.com \
--cc=julian.haller@philips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®