From: Thomas Renninger <trenn@suse.de>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org, "R.Durgadoss" <durgadoss.r@intel.com>
Subject: Re: [PATCH 28/48] thermal: Add event notification to thermal framework
Date: Thu, 13 Jan 2011 12:07:00 +0100 [thread overview]
Message-ID: <201101131207.01290.trenn@suse.de> (raw)
In-Reply-To: <4cb18728709683c91a5f6f8d5f337bfb498b089a.1294827492.git.len.brown@intel.com>
On Wednesday 12 January 2011 11:19:22 Len Brown wrote:
> menuconfig THERMAL
> tristate "Generic Thermal sysfs driver"
> + depends on NET
A dependency from the thermal driver to CONFIG_NET should
be avoided if possible.
Please consider to apply below patch on top.
Also the code is a bit nicer arranged with this one and all netlink
specific stuff is at one place.
Based on latest acpi test branch, drivers/thermal compile tested
with and without CONFIG_NET.
Thomas
---
thermal: Avoid CONFIG_NET compile dependency
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: R.Durgadoss <durgadoss.r@intel.com>
CC: Len Brown <len.brown@intel.com>
---
drivers/thermal/Kconfig | 1 -
drivers/thermal/thermal_sys.c | 177 ++++++++++++++++++++++-------------------
include/linux/thermal.h | 5 +-
3 files changed, 98 insertions(+), 85 deletions(-)
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index f7a5dba..bf7c687 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -4,7 +4,6 @@
menuconfig THERMAL
tristate "Generic Thermal sysfs driver"
- depends on NET
help
Generic Thermal Sysfs driver offers a generic mechanism for
thermal management. Usually it's made up of one or more thermal
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 7d0e63c..5bbacff 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -32,8 +32,6 @@
#include <linux/thermal.h>
#include <linux/spinlock.h>
#include <linux/reboot.h>
-#include <net/netlink.h>
-#include <net/genetlink.h>
MODULE_AUTHOR("Zhang Rui");
MODULE_DESCRIPTION("Generic thermal management sysfs support");
@@ -60,6 +58,10 @@ static LIST_HEAD(thermal_tz_list);
static LIST_HEAD(thermal_cdev_list);
static DEFINE_MUTEX(thermal_list_lock);
+#ifdef CONFIG_NET /* needed for netlink messages */
+#include <net/netlink.h>
+#include <net/genetlink.h>
+
static unsigned int thermal_event_seqnum;
static struct genl_family thermal_event_genl_family = {
@@ -76,6 +78,96 @@ static struct genl_multicast_group thermal_event_mcgrp = {
static int genetlink_init(void);
static void genetlink_exit(void);
+int generate_netlink_event(u32 orig, enum events event)
+{
+ struct sk_buff *skb;
+ struct nlattr *attr;
+ struct thermal_genl_event *thermal_event;
+ void *msg_header;
+ int size;
+ int result;
+
+ /* allocate memory */
+ size = nla_total_size(sizeof(struct thermal_genl_event)) + \
+ nla_total_size(0);
+
+ skb = genlmsg_new(size, GFP_ATOMIC);
+ if (!skb)
+ return -ENOMEM;
+
+ /* add the genetlink message header */
+ msg_header = genlmsg_put(skb, 0, thermal_event_seqnum++,
+ &thermal_event_genl_family, 0,
+ THERMAL_GENL_CMD_EVENT);
+ if (!msg_header) {
+ nlmsg_free(skb);
+ return -ENOMEM;
+ }
+
+ /* fill the data */
+ attr = nla_reserve(skb, THERMAL_GENL_ATTR_EVENT, \
+ sizeof(struct thermal_genl_event));
+
+ if (!attr) {
+ nlmsg_free(skb);
+ return -EINVAL;
+ }
+
+ thermal_event = nla_data(attr);
+ if (!thermal_event) {
+ nlmsg_free(skb);
+ return -EINVAL;
+ }
+
+ memset(thermal_event, 0, sizeof(struct thermal_genl_event));
+
+ thermal_event->orig = orig;
+ thermal_event->event = event;
+
+ /* send multicast genetlink message */
+ result = genlmsg_end(skb, msg_header);
+ if (result < 0) {
+ nlmsg_free(skb);
+ return result;
+ }
+
+ result = genlmsg_multicast(skb, 0, thermal_event_mcgrp.id, GFP_ATOMIC);
+ if (result)
+ printk(KERN_INFO "failed to send netlink event:%d", result);
+
+ return result;
+}
+EXPORT_SYMBOL(generate_netlink_event);
+
+static int genetlink_init(void)
+{
+ int result;
+
+ result = genl_register_family(&thermal_event_genl_family);
+ if (result)
+ return result;
+
+ result = genl_register_mc_group(&thermal_event_genl_family,
+ &thermal_event_mcgrp);
+ if (result)
+ genl_unregister_family(&thermal_event_genl_family);
+ return result;
+}
+
+static void genetlink_exit(void)
+{
+ genl_unregister_family(&thermal_event_genl_family);
+}
+
+#else
+
+static void genetlink_exit(void) {};
+static int genetlink_init(void) { return 0; }
+int generate_netlink_event(u32 orig, enum events event) { return 0; }
+EXPORT_SYMBOL(generate_netlink_event);
+
+#endif /* CONFIG_NET */
+
static int get_idr(struct idr *idr, struct mutex *lock, int *id)
{
int err;
@@ -1225,82 +1317,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
EXPORT_SYMBOL(thermal_zone_device_unregister);
-int generate_netlink_event(u32 orig, enum events event)
-{
- struct sk_buff *skb;
- struct nlattr *attr;
- struct thermal_genl_event *thermal_event;
- void *msg_header;
- int size;
- int result;
-
- /* allocate memory */
- size = nla_total_size(sizeof(struct thermal_genl_event)) + \
- nla_total_size(0);
-
- skb = genlmsg_new(size, GFP_ATOMIC);
- if (!skb)
- return -ENOMEM;
-
- /* add the genetlink message header */
- msg_header = genlmsg_put(skb, 0, thermal_event_seqnum++,
- &thermal_event_genl_family, 0,
- THERMAL_GENL_CMD_EVENT);
- if (!msg_header) {
- nlmsg_free(skb);
- return -ENOMEM;
- }
-
- /* fill the data */
- attr = nla_reserve(skb, THERMAL_GENL_ATTR_EVENT, \
- sizeof(struct thermal_genl_event));
-
- if (!attr) {
- nlmsg_free(skb);
- return -EINVAL;
- }
-
- thermal_event = nla_data(attr);
- if (!thermal_event) {
- nlmsg_free(skb);
- return -EINVAL;
- }
-
- memset(thermal_event, 0, sizeof(struct thermal_genl_event));
-
- thermal_event->orig = orig;
- thermal_event->event = event;
-
- /* send multicast genetlink message */
- result = genlmsg_end(skb, msg_header);
- if (result < 0) {
- nlmsg_free(skb);
- return result;
- }
-
- result = genlmsg_multicast(skb, 0, thermal_event_mcgrp.id, GFP_ATOMIC);
- if (result)
- printk(KERN_INFO "failed to send netlink event:%d", result);
-
- return result;
-}
-EXPORT_SYMBOL(generate_netlink_event);
-
-static int genetlink_init(void)
-{
- int result;
-
- result = genl_register_family(&thermal_event_genl_family);
- if (result)
- return result;
-
- result = genl_register_mc_group(&thermal_event_genl_family,
- &thermal_event_mcgrp);
- if (result)
- genl_unregister_family(&thermal_event_genl_family);
- return result;
-}
-
static int __init thermal_init(void)
{
int result = 0;
@@ -1316,11 +1332,6 @@ static int __init thermal_init(void)
return result;
}
-static void genetlink_exit(void)
-{
- genl_unregister_family(&thermal_event_genl_family);
-}
-
static void __exit thermal_exit(void)
{
class_unregister(&thermal_class);
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 8651556..1c31614 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -127,6 +127,8 @@ struct thermal_zone_device {
struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
#endif
};
+
+#ifdef CONFIG_NET
/* Adding event notification support elements */
#define THERMAL_GENL_FAMILY_NAME "thermal_event"
#define THERMAL_GENL_VERSION 0x01
@@ -158,6 +160,8 @@ enum {
__THERMAL_GENL_CMD_MAX,
};
#define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)
+#endif
+extern int generate_netlink_event(u32 orig, enum events event);
struct thermal_zone_device *thermal_zone_device_register(char *, int, void *,
const struct thermal_zone_device_ops *, int tc1, int tc2,
@@ -172,6 +176,5 @@ void thermal_zone_device_update(struct thermal_zone_device *);
struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
const struct thermal_cooling_device_ops *);
void thermal_cooling_device_unregister(struct thermal_cooling_device *);
-extern int generate_netlink_event(u32 orig, enum events event);
#endif /* __THERMAL_H__ */
next prev parent reply other threads:[~2011-01-13 11:07 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-12 10:18 ACPI patches for 2.6.38-merge Len Brown
2011-01-12 10:18 ` [PATCH 01/48] PNP: Compile all pnp built-in stuff in one module namespace Len Brown
2011-01-12 10:18 ` [PATCH 02/48] PNP: Set up pnp_debug via module and not via boot param Len Brown
2011-01-12 10:18 ` [PATCH 03/48] thermal: make ops constant Len Brown
2011-01-12 10:18 ` [PATCH 04/48] Add CPER PCIe error section structure and constants definition Len Brown
2011-01-12 10:18 ` [PATCH 05/48] ACPI, APEI, Add APEI generic error status printing support Len Brown
2011-01-12 10:19 ` [PATCH 06/48] ACPI, APEI, Report GHES error information via printk Len Brown
2011-01-12 10:19 ` [PATCH 07/48] ACPI processor: remove processor throttling control procfs I/F Len Brown
2011-01-12 10:19 ` [PATCH 08/48] ACPI video: remove output switching control Len Brown
2011-01-12 10:19 ` [PATCH 09/48] ACPI video: check cap._DDC flag before getting EDID Len Brown
2011-01-12 10:19 ` [PATCH 10/48] ACPI video: introduce module parameter video.use_bios_initial_backlight Len Brown
2011-01-12 10:19 ` [PATCH 11/48] IPMI: Add one interface to get more info of low-level IPMI device Len Brown
2011-01-12 10:19 ` [PATCH 12/48] IPMI: Add the document description of ipmi_get_smi_info Len Brown
2011-01-12 10:19 ` [PATCH 13/48] IPMI/ACPI: Add the IPMI opregion driver to enable ACPI to access BMC controller Len Brown
2011-01-12 10:19 ` [PATCH 14/48] PM: Fix oops in suspend/hibernate code related to failing ioremap() Len Brown
2011-01-12 18:39 ` Jiri Slaby
2011-01-12 18:40 ` Randy Dunlap
2011-01-12 18:42 ` Randy Dunlap
2011-01-12 20:05 ` Rafael J. Wysocki
2011-01-12 20:21 ` Randy Dunlap
2011-01-12 20:29 ` Rafael J. Wysocki
2011-01-12 20:32 ` Randy Dunlap
2011-01-12 10:19 ` [PATCH 15/48] PM / ACPI: Move NVS saving and restoring code to drivers/acpi Len Brown
2011-01-12 10:19 ` [PATCH 16/48] ACPI / PM: Update file information and the list of includes in nvs.c Len Brown
2011-01-12 10:19 ` [PATCH 17/48] ACPI / PM: Make suspend_nvs_save() use acpi_os_map_memory() Len Brown
2011-01-12 10:19 ` [PATCH 18/48] ACPI: Use ioremap_cache() Len Brown
2011-01-12 10:19 ` [PATCH 19/48] ACPI / ACPICA: Fix global lock acquisition Len Brown
2011-01-12 10:19 ` [PATCH 20/48] ACPI / PM: Do not enable multiple devices to wake up simultaneously Len Brown
2011-01-12 10:19 ` [PATCH 21/48] ACPI / PM: Use device wakeup flags for handling ACPI wakeup devices Len Brown
2011-01-12 10:19 ` [PATCH 22/48] ACPI / PM: Drop special ACPI wakeup flags Len Brown
2011-01-12 10:19 ` [PATCH 23/48] ACPI / PM: Report wakeup events from buttons Len Brown
2011-01-12 10:19 ` [PATCH 24/48] ACPI / PM: Blacklist Averatec machine known to require acpi_sleep=nonvs Len Brown
2011-01-12 10:19 ` [PATCH 25/48] ACPI: Check the returned value of set_cpus_allowed_ptr before T-state operation Len Brown
2011-01-12 10:19 ` [PATCH 26/48] ACPI: Reevaluate whether the T-state is supported or not after cpu is online/offline Len Brown
2011-01-12 10:19 ` [PATCH 27/48] PNP / ACPI: Use DEVICE_ACPI_HANDLE() for device ACPI handle access Len Brown
2011-01-12 10:19 ` [PATCH 28/48] thermal: Add event notification to thermal framework Len Brown
2011-01-13 11:07 ` Thomas Renninger [this message]
2011-01-13 11:14 ` Thomas Renninger
2011-01-13 11:21 ` Thomas Renninger
2011-01-13 11:31 ` R, Durgadoss
2011-01-13 11:47 ` Thomas Renninger
2011-01-13 12:36 ` R, Durgadoss
2011-01-13 13:41 ` Thomas Renninger
2011-01-14 3:35 ` Len Brown
2011-01-14 9:58 ` Thomas Renninger
2011-01-12 10:19 ` [PATCH 29/48] ACPI: update CONFIG_ACPI_PROCFS description Len Brown
2011-01-12 10:19 ` [PATCH 30/48] ACPI: delete CONFIG_ACPI_PROCFS_POWER and power procfs I/F in 2.6.39 Len Brown
2011-01-12 10:19 ` [PATCH 31/48] ACPI, APEI, Generic Hardware Error Source POLL/IRQ/NMI notification type support Len Brown
2011-01-12 10:19 ` [PATCH 32/48] ACPI / PM: Prevent acpi_power_get_inferred_state() from making changes Len Brown
2011-01-12 10:19 ` [PATCH 33/48] ACPI / PM: Add functions for manipulating lists of power resources Len Brown
2011-01-12 10:19 ` [PATCH 34/48] ACPI / PM: Introduce function for refcounting device " Len Brown
2011-01-12 10:19 ` [PATCH 35/48] ACPI / PM: Introduce __acpi_bus_get_power() Len Brown
2011-01-12 10:19 ` [PATCH 36/48] ACPI / PM: Add function for device power state initialization Len Brown
2011-01-12 10:19 ` [PATCH 37/48] ACPI / PM: Add function for updating device power state consistently Len Brown
2011-01-12 10:19 ` [PATCH 38/48] ACPI / PM: Register acpi_power_driver early Len Brown
2011-01-12 10:19 ` [PATCH 39/48] ACPI / PM: Register power resource devices as soon as they are needed Len Brown
2011-01-12 10:19 ` [PATCH 40/48] ACPI / Fan: Rework the handling of power resources Len Brown
2011-01-12 10:19 ` [PATCH 41/48] Platform / x86: Make fujitsu_laptop use acpi_bus_update_power() Len Brown
2011-01-12 10:19 ` [PATCH 42/48] ACPI / PM: Drop acpi_bus_get_power() Len Brown
2011-01-12 10:19 ` [PATCH 43/48] ACPI / PM: Drop acpi_power_nocheck Len Brown
2011-01-12 10:19 ` [PATCH 44/48] ACPI / PM: Rename acpi_power_off_device() Len Brown
2011-01-12 10:19 ` [PATCH 45/48] ACPI / PM: Check status of power resources under mutexes Len Brown
2011-01-12 10:19 ` [PATCH 46/48] ACPI: Always check if _PRW is present before trying to evaluate it Len Brown
2011-01-12 10:19 ` [PATCH 47/48] ACPI: Drop device flag wake_capable Len Brown
2011-01-12 10:19 ` [PATCH 48/48] ACPI / Battery: Update information on info notification and resume Len Brown
2011-01-12 15:23 ` ACPI patches for 2.6.38-merge Thomas Renninger
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=201101131207.01290.trenn@suse.de \
--to=trenn@suse.de \
--cc=durgadoss.r@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@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