From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>
Subject: [PATCH 2/3] ACPI / dock: Pass ACPI device pointer to acpi_device_is_battery()
Date: Tue, 11 Feb 2014 01:10:51 +0100 [thread overview]
Message-ID: <3670100.egnJn4ezsJ@vostro.rjw.lan> (raw)
In-Reply-To: <3728252.WpMGKRKmqq@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Since we already know what the device's PNP IDs are when
acpi_device_is_battery() is called, it is not necessary to run
acpi_get_object_info() for the device in that function. Instead, if
acpi_device_is_battery() is passed a pointer to a struct acpi_device
object, it can use the list of PNP IDs from that object, so make that
happen and modify the function's header accordingly
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/dock.c | 2 +-
drivers/acpi/internal.h | 2 +-
drivers/acpi/scan.c | 24 +++++++++++-------------
3 files changed, 13 insertions(+), 15 deletions(-)
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -97,7 +97,7 @@ void acpi_free_pnp_ids(struct acpi_devic
int acpi_bind_one(struct device *dev, struct acpi_device *adev);
int acpi_unbind_one(struct device *dev);
bool acpi_device_is_present(struct acpi_device *adev);
-bool acpi_device_is_battery(acpi_handle handle);
+bool acpi_device_is_battery(struct acpi_device *adev);
/* --------------------------------------------------------------------------
Power Resource
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -1662,24 +1662,22 @@ bool acpi_bay_match(acpi_handle handle)
return acpi_ata_match(phandle);
}
-bool acpi_device_is_battery(acpi_handle handle)
+bool acpi_device_is_battery(struct acpi_device *adev)
{
- struct acpi_device_info *info;
- bool ret = false;
-
- if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
- return false;
+ struct acpi_hardware_id *hwid;
- if (info->valid & ACPI_VALID_HID)
- ret = !strcmp("PNP0C0A", info->hardware_id.string);
+ list_for_each_entry(hwid, &adev->pnp.ids, list)
+ if (!strcmp("PNP0C0A", hwid->id))
+ return true;
- kfree(info);
- return ret;
+ return false;
}
-static bool is_ejectable_bay(acpi_handle handle)
+static bool is_ejectable_bay(struct acpi_device *adev)
{
- if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(handle))
+ acpi_handle handle = adev->handle;
+
+ if (acpi_has_method(handle, "_EJ0") && acpi_device_is_battery(adev))
return true;
return acpi_bay_match(handle);
@@ -1989,7 +1987,7 @@ static void acpi_scan_init_hotplug(struc
{
struct acpi_hardware_id *hwid;
- if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev->handle)) {
+ if (acpi_dock_match(adev->handle) || is_ejectable_bay(adev)) {
acpi_dock_add(adev);
return;
}
Index: linux-pm/drivers/acpi/dock.c
===================================================================
--- linux-pm.orig/drivers/acpi/dock.c
+++ linux-pm/drivers/acpi/dock.c
@@ -796,7 +796,7 @@ void acpi_dock_add(struct acpi_device *a
dock_station->flags |= DOCK_IS_DOCK;
if (acpi_ata_match(handle))
dock_station->flags |= DOCK_IS_ATA;
- if (acpi_device_is_battery(handle))
+ if (acpi_device_is_battery(adev))
dock_station->flags |= DOCK_IS_BAT;
ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
next prev parent reply other threads:[~2014-02-10 23:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-11 0:09 [PATCH 0/3] ACPI / dock: Rework the handling of dock notifications Rafael J. Wysocki
2014-02-11 0:10 ` [PATCH 1/3] ACPI / dock: Dispatch dock notifications from the global notify handler Rafael J. Wysocki
2014-02-14 0:45 ` [Update][PATCH " Rafael J. Wysocki
2014-02-11 0:10 ` Rafael J. Wysocki [this message]
2014-02-11 0:11 ` [PATCH 3/3] ACPI / dock: Associate dock platform devices with ACPI device objects Rafael J. Wysocki
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=3670100.egnJn4ezsJ@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=bhelgaas@google.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@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®