From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Zhang Rui <rui.zhang@intel.com>, "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-next@vger.kernel.org, linux-kernel@vger.kernel.org,
Sudip Mukherjee <sudip@vectorindia.org>,
Aaron Lu <aaron.lu@intel.com>
Subject: linux-next: manual merge of the thermal tree with the pm tree
Date: Fri, 10 Oct 2014 12:10:33 +1100 [thread overview]
Message-ID: <20141010121033.38dc4d0e@canb.auug.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 5686 bytes --]
Hi Zhang,
Today's linux-next merge of the thermal tree got a conflict in
drivers/acpi/fan.c between commit 88989fd26a74 ("ACPI / fan: printk
replacement") from the pm tree and commits 71532a58d2b0 ("ACPI / fan:
remove unused macro") and ff39c76855e8 ("ACPI / fan: convert to
platform driver") from the thermal tree.
I fixed it up (see below) and can carry the fix as necessary (no action
is required).
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
diff --cc drivers/acpi/fan.c
index 5328b1090e08,e007c4987bea..000000000000
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@@ -27,15 -27,11 +27,11 @@@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/thermal.h>
#include <linux/acpi.h>
-
- #define ACPI_FAN_CLASS "fan"
- #define ACPI_FAN_FILE_STATE "state"
-
- #define _COMPONENT ACPI_FAN_COMPONENT
- ACPI_MODULE_NAME("fan");
+ #include <linux/platform_device.h>
+ #include <linux/sort.h>
MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION("ACPI Fan Driver");
@@@ -125,25 -221,128 +221,129 @@@ static const struct thermal_cooling_dev
};
/* --------------------------------------------------------------------------
- Driver Interface
- -------------------------------------------------------------------------- */
+ * Driver Interface
+ * --------------------------------------------------------------------------
+*/
- static int acpi_fan_add(struct acpi_device *device)
+ static bool acpi_fan_is_acpi4(struct acpi_device *device)
{
- int result = 0;
- struct thermal_cooling_device *cdev;
+ return acpi_has_method(device->handle, "_FIF") &&
+ acpi_has_method(device->handle, "_FPS") &&
+ acpi_has_method(device->handle, "_FSL") &&
+ acpi_has_method(device->handle, "_FST");
+ }
- if (!device)
- return -EINVAL;
+ static int acpi_fan_get_fif(struct acpi_device *device)
+ {
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_buffer format = { sizeof("NNNN"), "NNNN" };
+ struct acpi_buffer fif = { sizeof(fan->fif), &fan->fif };
+ union acpi_object *obj;
+ acpi_status status;
+
+ status = acpi_evaluate_object(device->handle, "_FIF", NULL, &buffer);
+ if (ACPI_FAILURE(status))
+ return status;
+
+ obj = buffer.pointer;
+ if (!obj || obj->type != ACPI_TYPE_PACKAGE) {
+ dev_err(&device->dev, "Invalid _FIF data\n");
+ status = -EINVAL;
+ goto err;
+ }
- strcpy(acpi_device_name(device), "Fan");
- strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
+ status = acpi_extract_package(obj, &format, &fif);
+ if (ACPI_FAILURE(status)) {
+ dev_err(&device->dev, "Invalid _FIF element\n");
+ status = -EINVAL;
+ }
- result = acpi_bus_update_power(device->handle, NULL);
- if (result) {
- dev_err(&device->dev, "Setting initial power state\n");
- goto end;
+ err:
+ kfree(obj);
+ return status;
+ }
+
+ static int acpi_fan_speed_cmp(const void *a, const void *b)
+ {
+ const struct acpi_fan_fps *fps1 = a;
+ const struct acpi_fan_fps *fps2 = b;
+ return fps1->speed - fps2->speed;
+ }
+
+ static int acpi_fan_get_fps(struct acpi_device *device)
+ {
+ struct acpi_fan *fan = acpi_driver_data(device);
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *obj;
+ acpi_status status;
+ int i;
+
+ status = acpi_evaluate_object(device->handle, "_FPS", NULL, &buffer);
+ if (ACPI_FAILURE(status))
+ return status;
+
+ obj = buffer.pointer;
+ if (!obj || obj->type != ACPI_TYPE_PACKAGE || obj->package.count < 2) {
+ dev_err(&device->dev, "Invalid _FPS data\n");
+ status = -EINVAL;
+ goto err;
+ }
+
+ fan->fps_count = obj->package.count - 1; /* minus revision field */
+ fan->fps = devm_kzalloc(&device->dev,
+ fan->fps_count * sizeof(struct acpi_fan_fps),
+ GFP_KERNEL);
+ if (!fan->fps) {
+ dev_err(&device->dev, "Not enough memory\n");
+ status = -ENOMEM;
+ goto err;
+ }
+ for (i = 0; i < fan->fps_count; i++) {
+ struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
+ struct acpi_buffer fps = { sizeof(fan->fps[i]), &fan->fps[i] };
+ status = acpi_extract_package(&obj->package.elements[i + 1],
+ &format, &fps);
+ if (ACPI_FAILURE(status)) {
+ dev_err(&device->dev, "Invalid _FPS element\n");
+ break;
+ }
+ }
+
+ /* sort the state array according to fan speed in increase order */
+ sort(fan->fps, fan->fps_count, sizeof(*fan->fps),
+ acpi_fan_speed_cmp, NULL);
+
+ err:
+ kfree(obj);
+ return status;
+ }
+
+ static int acpi_fan_probe(struct platform_device *pdev)
+ {
+ int result = 0;
+ struct thermal_cooling_device *cdev;
+ struct acpi_fan *fan;
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+
+ fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL);
+ if (!fan) {
+ dev_err(&device->dev, "No memory for fan\n");
+ return -ENOMEM;
+ }
+ device->driver_data = fan;
+ platform_set_drvdata(pdev, fan);
+
+ if (acpi_fan_is_acpi4(device)) {
+ if (acpi_fan_get_fif(device) || acpi_fan_get_fps(device))
+ goto end;
+ fan->acpi4 = true;
+ } else {
+ result = acpi_device_update_power(device, NULL);
+ if (result) {
+ dev_err(&device->dev, "Setting initial power state\n");
+ goto end;
+ }
}
cdev = thermal_cooling_device_register("Fan", device,
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next reply other threads:[~2014-10-10 1:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 1:10 Stephen Rothwell [this message]
2014-10-10 8:40 ` linux-next: manual merge of the thermal tree with the pm tree Zhang Rui
-- strict thread matches above, loose matches on Subject: below --
2024-01-01 23:09 Stephen Rothwell
2023-04-06 0:32 Stephen Rothwell
2023-01-24 22:45 Stephen Rothwell
2023-01-25 11:57 ` Wysocki, Rafael J
2023-01-24 22:39 Stephen Rothwell
2023-01-25 11:57 ` Wysocki, Rafael J
2023-01-04 23:10 Stephen Rothwell
2023-01-04 23:35 ` Stephen Rothwell
2023-01-05 14:27 ` Wysocki, Rafael J
2023-01-05 15:30 ` Daniel Lezcano
2023-01-05 20:13 ` Wysocki, Rafael J
2023-01-04 23:03 Stephen Rothwell
2022-11-17 1:29 Stephen Rothwell
2022-11-17 16:18 ` Rafael J. Wysocki
2022-11-27 23:22 ` Stephen Rothwell
2022-11-28 12:51 ` Rafael J. Wysocki
2022-11-28 13:22 ` Daniel Lezcano
2022-11-28 13:48 ` Bagas Sanjaya
2022-11-28 13:54 ` Rafael J. Wysocki
2022-11-28 13:56 ` Daniel Lezcano
2022-11-29 14:32 ` Geert Uytterhoeven
2014-01-06 3:14 Stephen Rothwell
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=20141010121033.38dc4d0e@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=aaron.lu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
--cc=sudip@vectorindia.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;
as well as URLs for NNTP newsgroup(s).