linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Zhang Rui <rui.zhang@intel.com>,
	linux-acpi@vger.kernel.org, "Rafael J . Wysocki" <rjw@sisk.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 2/2] ACPI / thermal: reuse module_acpi_driver
Date: Thu,  3 Oct 2013 11:04:54 +0300	[thread overview]
Message-ID: <1380787494-14385-2-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1380787494-14385-1-git-send-email-andriy.shevchenko@linux.intel.com>

There is a macro to register and unregister modules in simple cases, Let's use
it and clean up the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Changes to v1:
 - fix compilation error

 drivers/acpi/thermal.c | 190 ++++++++++++++++++++++---------------------------
 1 file changed, 86 insertions(+), 104 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index e600b5d..9230c36 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -978,6 +978,84 @@ static void acpi_thermal_notify(struct acpi_device *device, u32 event)
 	}
 }
 
+static int thermal_act(const struct dmi_system_id *d) {
+
+	if (act == 0) {
+		pr_notice(PREFIX "%s detected: "
+			  "disabling all active thermal trip points\n", d->ident);
+		act = -1;
+	}
+	return 0;
+}
+
+static int thermal_nocrt(const struct dmi_system_id *d) {
+
+	pr_notice(PREFIX "%s detected: "
+		  "disabling all critical thermal trip point actions.\n", d->ident);
+	nocrt = 1;
+	return 0;
+}
+
+static int thermal_tzp(const struct dmi_system_id *d) {
+
+	if (tzp == 0) {
+		pr_notice(PREFIX "%s detected: "
+			  "enabling thermal zone polling\n", d->ident);
+		tzp = 300;	/* 300 dS = 30 Seconds */
+	}
+	return 0;
+}
+
+static int thermal_psv(const struct dmi_system_id *d) {
+
+	if (psv == 0) {
+		pr_notice(PREFIX "%s detected: "
+			  "disabling all passive thermal trip points\n", d->ident);
+		psv = -1;
+	}
+	return 0;
+}
+
+static struct dmi_system_id thermal_dmi_table[] __initdata = {
+	/*
+	 * Award BIOS on this AOpen makes thermal control almost worthless.
+	 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
+	 */
+	{
+	 .callback = thermal_act,
+	 .ident = "AOpen i915GMm-HFS",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
+		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
+		},
+	},
+	{
+	 .callback = thermal_psv,
+	 .ident = "AOpen i915GMm-HFS",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
+		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
+		},
+	},
+	{
+	 .callback = thermal_tzp,
+	 .ident = "AOpen i915GMm-HFS",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
+		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
+		},
+	},
+	{
+	 .callback = thermal_nocrt,
+	 .ident = "Gigabyte GA-7ZX",
+	 .matches = {
+		DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
+		DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
+		},
+	},
+	{}
+};
+
 /*
  * On some platforms, the AML code has dependency about
  * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx.
@@ -1068,10 +1146,16 @@ static int acpi_thermal_add(struct acpi_device *device)
 	int result = 0;
 	struct acpi_thermal *tz = NULL;
 
-
 	if (!device)
 		return -EINVAL;
 
+	dmi_check_system(thermal_dmi_table);
+
+	if (off) {
+		pr_notice(PREFIX "thermal control disabled\n");
+		return -ENODEV;
+	}
+
 	tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
 	if (!tz)
 		return -ENOMEM;
@@ -1153,106 +1237,4 @@ static int acpi_thermal_resume(struct device *dev)
 }
 #endif
 
-static int thermal_act(const struct dmi_system_id *d) {
-
-	if (act == 0) {
-		pr_notice(PREFIX "%s detected: "
-			  "disabling all active thermal trip points\n", d->ident);
-		act = -1;
-	}
-	return 0;
-}
-static int thermal_nocrt(const struct dmi_system_id *d) {
-
-	pr_notice(PREFIX "%s detected: "
-		  "disabling all critical thermal trip point actions.\n", d->ident);
-	nocrt = 1;
-	return 0;
-}
-static int thermal_tzp(const struct dmi_system_id *d) {
-
-	if (tzp == 0) {
-		pr_notice(PREFIX "%s detected: "
-			  "enabling thermal zone polling\n", d->ident);
-		tzp = 300;	/* 300 dS = 30 Seconds */
-	}
-	return 0;
-}
-static int thermal_psv(const struct dmi_system_id *d) {
-
-	if (psv == 0) {
-		pr_notice(PREFIX "%s detected: "
-			  "disabling all passive thermal trip points\n", d->ident);
-		psv = -1;
-	}
-	return 0;
-}
-
-static struct dmi_system_id thermal_dmi_table[] __initdata = {
-	/*
-	 * Award BIOS on this AOpen makes thermal control almost worthless.
-	 * http://bugzilla.kernel.org/show_bug.cgi?id=8842
-	 */
-	{
-	 .callback = thermal_act,
-	 .ident = "AOpen i915GMm-HFS",
-	 .matches = {
-		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
-		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
-		},
-	},
-	{
-	 .callback = thermal_psv,
-	 .ident = "AOpen i915GMm-HFS",
-	 .matches = {
-		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
-		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
-		},
-	},
-	{
-	 .callback = thermal_tzp,
-	 .ident = "AOpen i915GMm-HFS",
-	 .matches = {
-		DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
-		DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
-		},
-	},
-	{
-	 .callback = thermal_nocrt,
-	 .ident = "Gigabyte GA-7ZX",
-	 .matches = {
-		DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
-		DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
-		},
-	},
-	{}
-};
-
-static int __init acpi_thermal_init(void)
-{
-	int result = 0;
-
-	dmi_check_system(thermal_dmi_table);
-
-	if (off) {
-		pr_notice(PREFIX "thermal control disabled\n");
-		return -ENODEV;
-	}
-
-	result = acpi_bus_register_driver(&acpi_thermal_driver);
-	if (result < 0)
-		return -ENODEV;
-
-	return 0;
-}
-
-static void __exit acpi_thermal_exit(void)
-{
-
-	acpi_bus_unregister_driver(&acpi_thermal_driver);
-
-	return;
-}
-
-module_init(acpi_thermal_init);
-module_exit(acpi_thermal_exit);
+module_acpi_driver(acpi_thermal_driver);
-- 
1.8.4.rc3


      reply	other threads:[~2013-10-03  8:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03  8:04 [PATCH v2 1/2] ACPI / thermal: convert printk(LEVEL...) to pr_<lvl> Andy Shevchenko
2013-10-03  8:04 ` Andy Shevchenko [this message]

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=1380787494-14385-2-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=rui.zhang@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).