You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'dock' into test
Conflicts: drivers/acpi/osl.c Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
+2
-2
@@ -1415,8 +1415,8 @@ M: rdunlap@xenotime.net
|
||||
S: Maintained
|
||||
|
||||
DOCKING STATION DRIVER
|
||||
P: Kristen Carlson Accardi
|
||||
M: kristen.c.accardi@intel.com
|
||||
P: Shaohua Li
|
||||
M: shaohua.li@intel.com
|
||||
L: linux-acpi@vger.kernel.org
|
||||
S: Supported
|
||||
|
||||
|
||||
@@ -160,15 +160,8 @@ config ACPI_DOCK
|
||||
tristate "Dock"
|
||||
depends on EXPERIMENTAL
|
||||
help
|
||||
This driver adds support for ACPI controlled docking stations
|
||||
|
||||
config ACPI_BAY
|
||||
tristate "Removable Drive Bay (EXPERIMENTAL)"
|
||||
depends on EXPERIMENTAL
|
||||
depends on ACPI_DOCK
|
||||
help
|
||||
This driver adds support for ACPI controlled removable drive
|
||||
bays such as the IBM ultrabay or the Dell Module Bay.
|
||||
This driver adds support for ACPI controlled docking stations and removable
|
||||
drive bays such as the IBM ultrabay or the Dell Module Bay.
|
||||
|
||||
config ACPI_PROCESSOR
|
||||
tristate "Processor"
|
||||
|
||||
@@ -45,7 +45,6 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o
|
||||
obj-$(CONFIG_ACPI_BUTTON) += button.o
|
||||
obj-$(CONFIG_ACPI_FAN) += fan.o
|
||||
obj-$(CONFIG_ACPI_DOCK) += dock.o
|
||||
obj-$(CONFIG_ACPI_BAY) += bay.o
|
||||
obj-$(CONFIG_ACPI_VIDEO) += video.o
|
||||
obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
|
||||
obj-$(CONFIG_ACPI_PCI_SLOT) += pci_slot.o
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
/*
|
||||
* bay.c - ACPI removable drive bay driver
|
||||
*
|
||||
* Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com>
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <acpi/acpi_bus.h>
|
||||
#include <acpi/acpi_drivers.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
ACPI_MODULE_NAME("bay");
|
||||
MODULE_AUTHOR("Kristen Carlson Accardi");
|
||||
MODULE_DESCRIPTION("ACPI Removable Drive Bay Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
#define ACPI_BAY_CLASS "bay"
|
||||
#define ACPI_BAY_COMPONENT 0x10000000
|
||||
#define _COMPONENT ACPI_BAY_COMPONENT
|
||||
#define bay_dprintk(h,s) {\
|
||||
char prefix[80] = {'\0'};\
|
||||
struct acpi_buffer buffer = {sizeof(prefix), prefix};\
|
||||
acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
|
||||
printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); }
|
||||
static void bay_notify(acpi_handle handle, u32 event, void *data);
|
||||
|
||||
static const struct acpi_device_id bay_device_ids[] = {
|
||||
{"LNXIOBAY", 0},
|
||||
{"", 0},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, bay_device_ids);
|
||||
|
||||
struct bay {
|
||||
acpi_handle handle;
|
||||
char *name;
|
||||
struct list_head list;
|
||||
struct platform_device *pdev;
|
||||
};
|
||||
|
||||
static LIST_HEAD(drive_bays);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Drive Bay functions *
|
||||
*****************************************************************************/
|
||||
/**
|
||||
* is_ejectable - see if a device is ejectable
|
||||
* @handle: acpi handle of the device
|
||||
*
|
||||
* If an acpi object has a _EJ0 method, then it is ejectable
|
||||
*/
|
||||
static int is_ejectable(acpi_handle handle)
|
||||
{
|
||||
acpi_status status;
|
||||
acpi_handle tmp;
|
||||
|
||||
status = acpi_get_handle(handle, "_EJ0", &tmp);
|
||||
if (ACPI_FAILURE(status))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* bay_present - see if the bay device is present
|
||||
* @bay: the drive bay
|
||||
*
|
||||
* execute the _STA method.
|
||||
*/
|
||||
static int bay_present(struct bay *bay)
|
||||
{
|
||||
unsigned long sta;
|
||||
acpi_status status;
|
||||
|
||||
if (bay) {
|
||||
status = acpi_evaluate_integer(bay->handle, "_STA", NULL, &sta);
|
||||
if (ACPI_SUCCESS(status) && sta)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* eject_device - respond to an eject request
|
||||
* @handle - the device to eject
|
||||
*
|
||||
* Call this devices _EJ0 method.
|
||||
*/
|
||||
static void eject_device(acpi_handle handle)
|
||||
{
|
||||
struct acpi_object_list arg_list;
|
||||
union acpi_object arg;
|
||||
|
||||
bay_dprintk(handle, "Ejecting device");
|
||||
|
||||
arg_list.count = 1;
|
||||
arg_list.pointer = &arg;
|
||||
arg.type = ACPI_TYPE_INTEGER;
|
||||
arg.integer.value = 1;
|
||||
|
||||
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0",
|
||||
&arg_list, NULL)))
|
||||
pr_debug("Failed to evaluate _EJ0!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* show_present - read method for "present" file in sysfs
|
||||
*/
|
||||
static ssize_t show_present(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct bay *bay = dev_get_drvdata(dev);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", bay_present(bay));
|
||||
|
||||
}
|
||||
static DEVICE_ATTR(present, S_IRUGO, show_present, NULL);
|
||||
|
||||
/*
|
||||
* write_eject - write method for "eject" file in sysfs
|
||||
*/
|
||||
static ssize_t write_eject(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct bay *bay = dev_get_drvdata(dev);
|
||||
|
||||
if (!count)
|
||||
return -EINVAL;
|
||||
|
||||
eject_device(bay->handle);
|
||||
return count;
|
||||
}
|
||||
static DEVICE_ATTR(eject, S_IWUSR, NULL, write_eject);
|
||||
|
||||
/**
|
||||
* is_ata - see if a device is an ata device
|
||||
* @handle: acpi handle of the device
|
||||
*
|
||||
* If an acpi object has one of 4 ATA ACPI methods defined,
|
||||
* then it is an ATA device
|
||||
*/
|
||||
static int is_ata(acpi_handle handle)
|
||||
{
|
||||
acpi_handle tmp;
|
||||
|
||||
if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) ||
|
||||
(ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) ||
|
||||
(ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) ||
|
||||
(ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp))))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* parent_is_ata(acpi_handle handle)
|
||||
*
|
||||
*/
|
||||
static int parent_is_ata(acpi_handle handle)
|
||||
{
|
||||
acpi_handle phandle;
|
||||
|
||||
if (acpi_get_parent(handle, &phandle))
|
||||
return 0;
|
||||
|
||||
return is_ata(phandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* is_ejectable_bay - see if a device is an ejectable drive bay
|
||||
* @handle: acpi handle of the device
|
||||
*
|
||||
* If an acpi object is ejectable and has one of the ACPI ATA
|
||||
* methods defined, then we can safely call it an ejectable
|
||||
* drive bay
|
||||
*/
|
||||
static int is_ejectable_bay(acpi_handle handle)
|
||||
{
|
||||
if ((is_ata(handle) || parent_is_ata(handle)) && is_ejectable(handle))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* eject_removable_drive - try to eject this drive
|
||||
* @dev : the device structure of the drive
|
||||
*
|
||||
* If a device is a removable drive that requires an _EJ0 method
|
||||
* to be executed in order to safely remove from the system, do
|
||||
* it. ATM - always returns success
|
||||
*/
|
||||
int eject_removable_drive(struct device *dev)
|
||||
{
|
||||
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
|
||||
|
||||
if (handle) {
|
||||
bay_dprintk(handle, "Got device handle");
|
||||
if (is_ejectable_bay(handle))
|
||||
eject_device(handle);
|
||||
} else {
|
||||
printk("No acpi handle for device\n");
|
||||
}
|
||||
|
||||
/* should I return an error code? */
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(eject_removable_drive);
|
||||
#endif /* 0 */
|
||||
|
||||
static int acpi_bay_add_fs(struct bay *bay)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = &bay->pdev->dev;
|
||||
|
||||
ret = device_create_file(dev, &dev_attr_present);
|
||||
if (ret)
|
||||
goto add_fs_err;
|
||||
ret = device_create_file(dev, &dev_attr_eject);
|
||||
if (ret) {
|
||||
device_remove_file(dev, &dev_attr_present);
|
||||
goto add_fs_err;
|
||||
}
|
||||
return 0;
|
||||
|
||||
add_fs_err:
|
||||
bay_dprintk(bay->handle, "Error adding sysfs files\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void acpi_bay_remove_fs(struct bay *bay)
|
||||
{
|
||||
struct device *dev = &bay->pdev->dev;
|
||||
|
||||
/* cleanup sysfs */
|
||||
device_remove_file(dev, &dev_attr_present);
|
||||
device_remove_file(dev, &dev_attr_eject);
|
||||
}
|
||||
|
||||
static int bay_is_dock_device(acpi_handle handle)
|
||||
{
|
||||
acpi_handle parent;
|
||||
|
||||
acpi_get_parent(handle, &parent);
|
||||
|
||||
/* if the device or it's parent is dependent on the
|
||||
* dock, then we are a dock device
|
||||
*/
|
||||
return (is_dock_device(handle) || is_dock_device(parent));
|
||||
}
|
||||
|
||||
static int bay_add(acpi_handle handle, int id)
|
||||
{
|
||||
acpi_status status;
|
||||
struct bay *new_bay;
|
||||
struct platform_device *pdev;
|
||||
struct acpi_buffer nbuffer = {ACPI_ALLOCATE_BUFFER, NULL};
|
||||
acpi_get_name(handle, ACPI_FULL_PATHNAME, &nbuffer);
|
||||
|
||||
bay_dprintk(handle, "Adding notify handler");
|
||||
|
||||
/*
|
||||
* Initialize bay device structure
|
||||
*/
|
||||
new_bay = kzalloc(sizeof(*new_bay), GFP_ATOMIC);
|
||||
INIT_LIST_HEAD(&new_bay->list);
|
||||
new_bay->handle = handle;
|
||||
new_bay->name = (char *)nbuffer.pointer;
|
||||
|
||||
/* initialize platform device stuff */
|
||||
pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0);
|
||||
if (IS_ERR(pdev)) {
|
||||
printk(KERN_ERR PREFIX "Error registering bay device\n");
|
||||
goto bay_add_err;
|
||||
}
|
||||
new_bay->pdev = pdev;
|
||||
platform_set_drvdata(pdev, new_bay);
|
||||
|
||||
/*
|
||||
* we want the bay driver to be able to send uevents
|
||||
*/
|
||||
pdev->dev.uevent_suppress = 0;
|
||||
|
||||
/* register for events on this device */
|
||||
status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
|
||||
bay_notify, new_bay);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
printk(KERN_INFO PREFIX "Error installing bay notify handler\n");
|
||||
platform_device_unregister(new_bay->pdev);
|
||||
goto bay_add_err;
|
||||
}
|
||||
|
||||
if (acpi_bay_add_fs(new_bay)) {
|
||||
acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
|
||||
bay_notify);
|
||||
platform_device_unregister(new_bay->pdev);
|
||||
goto bay_add_err;
|
||||
}
|
||||
|
||||
/* if we are on a dock station, we should register for dock
|
||||
* notifications.
|
||||
*/
|
||||
if (bay_is_dock_device(handle)) {
|
||||
bay_dprintk(handle, "Is dependent on dock\n");
|
||||
register_hotplug_dock_device(handle, bay_notify, new_bay);
|
||||
}
|
||||
list_add(&new_bay->list, &drive_bays);
|
||||
printk(KERN_INFO PREFIX "Bay [%s] Added\n", new_bay->name);
|
||||
return 0;
|
||||
|
||||
bay_add_err:
|
||||
kfree(new_bay->name);
|
||||
kfree(new_bay);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/**
|
||||
* bay_notify - act upon an acpi bay notification
|
||||
* @handle: the bay handle
|
||||
* @event: the acpi event
|
||||
* @data: our driver data struct
|
||||
*
|
||||
*/
|
||||
static void bay_notify(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
struct bay *bay_dev = (struct bay *)data;
|
||||
struct device *dev = &bay_dev->pdev->dev;
|
||||
char event_string[12];
|
||||
char *envp[] = { event_string, NULL };
|
||||
|
||||
bay_dprintk(handle, "Bay event");
|
||||
sprintf(event_string, "BAY_EVENT=%d", event);
|
||||
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
|
||||
}
|
||||
|
||||
static acpi_status
|
||||
find_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
|
||||
{
|
||||
int *count = (int *)context;
|
||||
|
||||
/*
|
||||
* there could be more than one ejectable bay.
|
||||
* so, just return AE_OK always so that every object
|
||||
* will be checked.
|
||||
*/
|
||||
if (is_ejectable_bay(handle)) {
|
||||
bay_dprintk(handle, "found ejectable bay");
|
||||
if (!bay_add(handle, *count))
|
||||
(*count)++;
|
||||
}
|
||||
return AE_OK;
|
||||
}
|
||||
|
||||
static int __init bay_init(void)
|
||||
{
|
||||
int bays = 0;
|
||||
|
||||
INIT_LIST_HEAD(&drive_bays);
|
||||
|
||||
if (acpi_disabled)
|
||||
return -ENODEV;
|
||||
|
||||
/* look for dockable drive bays */
|
||||
acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
|
||||
ACPI_UINT32_MAX, find_bay, &bays, NULL);
|
||||
|
||||
if (!bays)
|
||||
return -ENODEV;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit bay_exit(void)
|
||||
{
|
||||
struct bay *bay, *tmp;
|
||||
|
||||
list_for_each_entry_safe(bay, tmp, &drive_bays, list) {
|
||||
if (is_dock_device(bay->handle))
|
||||
unregister_hotplug_dock_device(bay->handle);
|
||||
acpi_bay_remove_fs(bay);
|
||||
acpi_remove_notify_handler(bay->handle, ACPI_SYSTEM_NOTIFY,
|
||||
bay_notify);
|
||||
platform_device_unregister(bay->pdev);
|
||||
kfree(bay->name);
|
||||
kfree(bay);
|
||||
}
|
||||
}
|
||||
|
||||
postcore_initcall(bay_init);
|
||||
module_exit(bay_exit);
|
||||
|
||||
@@ -525,6 +525,19 @@ static int acpi_bus_check_scope(struct acpi_device *device)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
|
||||
int register_acpi_bus_notifier(struct notifier_block *nb)
|
||||
{
|
||||
return blocking_notifier_chain_register(&acpi_bus_notify_list, nb);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(register_acpi_bus_notifier);
|
||||
|
||||
void unregister_acpi_bus_notifier(struct notifier_block *nb)
|
||||
{
|
||||
blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
|
||||
|
||||
/**
|
||||
* acpi_bus_notify
|
||||
* ---------------
|
||||
@@ -535,6 +548,8 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
|
||||
int result = 0;
|
||||
struct acpi_device *device = NULL;
|
||||
|
||||
blocking_notifier_call_chain(&acpi_bus_notify_list,
|
||||
type, (void *)handle);
|
||||
|
||||
if (acpi_bus_get_device(handle, &device))
|
||||
return;
|
||||
|
||||
+297
-85
File diff suppressed because it is too large
Load Diff
+41
-5
@@ -682,6 +682,22 @@ static void acpi_os_execute_deferred(struct work_struct *work)
|
||||
return;
|
||||
}
|
||||
|
||||
static void acpi_os_execute_hp_deferred(struct work_struct *work)
|
||||
{
|
||||
struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
|
||||
if (!dpc) {
|
||||
printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
|
||||
return;
|
||||
}
|
||||
|
||||
acpi_os_wait_events_complete(NULL);
|
||||
|
||||
dpc->function(dpc->context);
|
||||
kfree(dpc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: acpi_os_execute
|
||||
@@ -697,12 +713,13 @@ static void acpi_os_execute_deferred(struct work_struct *work)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
acpi_status acpi_os_execute(acpi_execute_type type,
|
||||
acpi_osd_exec_callback function, void *context)
|
||||
static acpi_status __acpi_os_execute(acpi_execute_type type,
|
||||
acpi_osd_exec_callback function, void *context, int hp)
|
||||
{
|
||||
acpi_status status = AE_OK;
|
||||
struct acpi_os_dpc *dpc;
|
||||
struct workqueue_struct *queue;
|
||||
int ret;
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
|
||||
"Scheduling function [%p(%p)] for deferred execution.\n",
|
||||
function, context));
|
||||
@@ -726,9 +743,17 @@ acpi_status acpi_os_execute(acpi_execute_type type,
|
||||
dpc->function = function;
|
||||
dpc->context = context;
|
||||
|
||||
INIT_WORK(&dpc->work, acpi_os_execute_deferred);
|
||||
queue = (type == OSL_NOTIFY_HANDLER) ? kacpi_notify_wq : kacpid_wq;
|
||||
if (!queue_work(queue, &dpc->work)) {
|
||||
if (!hp) {
|
||||
INIT_WORK(&dpc->work, acpi_os_execute_deferred);
|
||||
queue = (type == OSL_NOTIFY_HANDLER) ?
|
||||
kacpi_notify_wq : kacpid_wq;
|
||||
ret = queue_work(queue, &dpc->work);
|
||||
} else {
|
||||
INIT_WORK(&dpc->work, acpi_os_execute_hp_deferred);
|
||||
ret = schedule_work(&dpc->work);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
printk(KERN_ERR PREFIX
|
||||
"Call to queue_work() failed.\n");
|
||||
status = AE_ERROR;
|
||||
@@ -737,8 +762,19 @@ acpi_status acpi_os_execute(acpi_execute_type type,
|
||||
return_ACPI_STATUS(status);
|
||||
}
|
||||
|
||||
acpi_status acpi_os_execute(acpi_execute_type type,
|
||||
acpi_osd_exec_callback function, void *context)
|
||||
{
|
||||
return __acpi_os_execute(type, function, context, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(acpi_os_execute);
|
||||
|
||||
acpi_status acpi_os_hotplug_execute(acpi_osd_exec_callback function,
|
||||
void *context)
|
||||
{
|
||||
return __acpi_os_execute(0, function, context, 1);
|
||||
}
|
||||
|
||||
void acpi_os_wait_events_complete(void *context)
|
||||
{
|
||||
flush_workqueue(kacpid_wq);
|
||||
|
||||
+50
-89
@@ -120,21 +120,6 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap)
|
||||
ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
|
||||
}
|
||||
|
||||
static void ata_acpi_eject_device(acpi_handle handle)
|
||||
{
|
||||
struct acpi_object_list arg_list;
|
||||
union acpi_object arg;
|
||||
|
||||
arg_list.count = 1;
|
||||
arg_list.pointer = &arg;
|
||||
arg.type = ACPI_TYPE_INTEGER;
|
||||
arg.integer.value = 1;
|
||||
|
||||
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_EJ0",
|
||||
&arg_list, NULL)))
|
||||
printk(KERN_ERR "Failed to evaluate _EJ0!\n");
|
||||
}
|
||||
|
||||
/* @ap and @dev are the same as ata_acpi_handle_hotplug() */
|
||||
static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
|
||||
{
|
||||
@@ -157,7 +142,6 @@ static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
|
||||
* @ap: ATA port ACPI event occurred
|
||||
* @dev: ATA device ACPI event occurred (can be NULL)
|
||||
* @event: ACPI event which occurred
|
||||
* @is_dock_event: boolean indicating whether the event was a dock one
|
||||
*
|
||||
* All ACPI bay / device realted events end up in this function. If
|
||||
* the event is port-wide @dev is NULL. If the event is specific to a
|
||||
@@ -171,116 +155,99 @@ static void ata_acpi_detach_device(struct ata_port *ap, struct ata_device *dev)
|
||||
* ACPI notify handler context. May sleep.
|
||||
*/
|
||||
static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
|
||||
u32 event, int is_dock_event)
|
||||
u32 event)
|
||||
{
|
||||
char event_string[12];
|
||||
char *envp[] = { event_string, NULL };
|
||||
struct ata_eh_info *ehi = &ap->link.eh_info;
|
||||
struct kobject *kobj = NULL;
|
||||
int wait = 0;
|
||||
unsigned long flags;
|
||||
acpi_handle handle, tmphandle;
|
||||
unsigned long sta;
|
||||
acpi_status status;
|
||||
acpi_handle handle;
|
||||
|
||||
if (dev) {
|
||||
if (dev->sdev)
|
||||
kobj = &dev->sdev->sdev_gendev.kobj;
|
||||
if (dev)
|
||||
handle = dev->acpi_handle;
|
||||
} else {
|
||||
kobj = &ap->dev->kobj;
|
||||
else
|
||||
handle = ap->acpi_handle;
|
||||
}
|
||||
|
||||
status = acpi_get_handle(handle, "_EJ0", &tmphandle);
|
||||
if (ACPI_FAILURE(status))
|
||||
/* This device does not support hotplug */
|
||||
return;
|
||||
|
||||
if (event == ACPI_NOTIFY_BUS_CHECK ||
|
||||
event == ACPI_NOTIFY_DEVICE_CHECK)
|
||||
status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
|
||||
|
||||
spin_lock_irqsave(ap->lock, flags);
|
||||
|
||||
/*
|
||||
* When dock driver calls into the routine, it will always use
|
||||
* ACPI_NOTIFY_BUS_CHECK/ACPI_NOTIFY_DEVICE_CHECK for add and
|
||||
* ACPI_NOTIFY_EJECT_REQUEST for remove
|
||||
*/
|
||||
switch (event) {
|
||||
case ACPI_NOTIFY_BUS_CHECK:
|
||||
case ACPI_NOTIFY_DEVICE_CHECK:
|
||||
ata_ehi_push_desc(ehi, "ACPI event");
|
||||
|
||||
if (ACPI_FAILURE(status)) {
|
||||
ata_port_printk(ap, KERN_ERR,
|
||||
"acpi: failed to determine bay status (0x%x)\n",
|
||||
status);
|
||||
break;
|
||||
}
|
||||
|
||||
if (sta) {
|
||||
ata_ehi_hotplugged(ehi);
|
||||
ata_port_freeze(ap);
|
||||
} else {
|
||||
/* The device has gone - unplug it */
|
||||
ata_acpi_detach_device(ap, dev);
|
||||
wait = 1;
|
||||
}
|
||||
ata_ehi_hotplugged(ehi);
|
||||
ata_port_freeze(ap);
|
||||
break;
|
||||
case ACPI_NOTIFY_EJECT_REQUEST:
|
||||
ata_ehi_push_desc(ehi, "ACPI event");
|
||||
|
||||
if (!is_dock_event)
|
||||
break;
|
||||
|
||||
/* undock event - immediate unplug */
|
||||
ata_acpi_detach_device(ap, dev);
|
||||
wait = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* make sure kobj doesn't go away while ap->lock is released */
|
||||
kobject_get(kobj);
|
||||
|
||||
spin_unlock_irqrestore(ap->lock, flags);
|
||||
|
||||
if (wait) {
|
||||
if (wait)
|
||||
ata_port_wait_eh(ap);
|
||||
ata_acpi_eject_device(handle);
|
||||
}
|
||||
|
||||
if (kobj && !is_dock_event) {
|
||||
sprintf(event_string, "BAY_EVENT=%d", event);
|
||||
kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
|
||||
}
|
||||
|
||||
kobject_put(kobj);
|
||||
}
|
||||
|
||||
static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
struct ata_device *dev = data;
|
||||
|
||||
ata_acpi_handle_hotplug(dev->link->ap, dev, event, 1);
|
||||
ata_acpi_handle_hotplug(dev->link->ap, dev, event);
|
||||
}
|
||||
|
||||
static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
struct ata_port *ap = data;
|
||||
|
||||
ata_acpi_handle_hotplug(ap, NULL, event, 1);
|
||||
ata_acpi_handle_hotplug(ap, NULL, event);
|
||||
}
|
||||
|
||||
static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data)
|
||||
static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
|
||||
u32 event)
|
||||
{
|
||||
struct kobject *kobj = NULL;
|
||||
char event_string[20];
|
||||
char *envp[] = { event_string, NULL };
|
||||
|
||||
if (dev) {
|
||||
if (dev->sdev)
|
||||
kobj = &dev->sdev->sdev_gendev.kobj;
|
||||
} else
|
||||
kobj = &ap->dev->kobj;
|
||||
|
||||
if (kobj) {
|
||||
snprintf(event_string, 20, "BAY_EVENT=%d", event);
|
||||
kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
|
||||
}
|
||||
}
|
||||
|
||||
static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
ata_acpi_uevent(data, NULL, event);
|
||||
}
|
||||
|
||||
static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
struct ata_device *dev = data;
|
||||
|
||||
ata_acpi_handle_hotplug(dev->link->ap, dev, event, 0);
|
||||
ata_acpi_uevent(dev->link->ap, dev, event);
|
||||
}
|
||||
|
||||
static void ata_acpi_ap_notify(acpi_handle handle, u32 event, void *data)
|
||||
{
|
||||
struct ata_port *ap = data;
|
||||
static struct acpi_dock_ops ata_acpi_dev_dock_ops = {
|
||||
.handler = ata_acpi_dev_notify_dock,
|
||||
.uevent = ata_acpi_dev_uevent,
|
||||
};
|
||||
|
||||
ata_acpi_handle_hotplug(ap, NULL, event, 0);
|
||||
}
|
||||
static struct acpi_dock_ops ata_acpi_ap_dock_ops = {
|
||||
.handler = ata_acpi_ap_notify_dock,
|
||||
.uevent = ata_acpi_ap_uevent,
|
||||
};
|
||||
|
||||
/**
|
||||
* ata_acpi_associate - associate ATA host with ACPI objects
|
||||
@@ -315,24 +282,18 @@ void ata_acpi_associate(struct ata_host *host)
|
||||
ata_acpi_associate_ide_port(ap);
|
||||
|
||||
if (ap->acpi_handle) {
|
||||
acpi_install_notify_handler(ap->acpi_handle,
|
||||
ACPI_SYSTEM_NOTIFY,
|
||||
ata_acpi_ap_notify, ap);
|
||||
/* we might be on a docking station */
|
||||
register_hotplug_dock_device(ap->acpi_handle,
|
||||
ata_acpi_ap_notify_dock, ap);
|
||||
&ata_acpi_ap_dock_ops, ap);
|
||||
}
|
||||
|
||||
for (j = 0; j < ata_link_max_devices(&ap->link); j++) {
|
||||
struct ata_device *dev = &ap->link.device[j];
|
||||
|
||||
if (dev->acpi_handle) {
|
||||
acpi_install_notify_handler(dev->acpi_handle,
|
||||
ACPI_SYSTEM_NOTIFY,
|
||||
ata_acpi_dev_notify, dev);
|
||||
/* we might be on a docking station */
|
||||
register_hotplug_dock_device(dev->acpi_handle,
|
||||
ata_acpi_dev_notify_dock, dev);
|
||||
&ata_acpi_dev_dock_ops, dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,9 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct acpi_dock_ops acpiphp_dock_ops = {
|
||||
.handler = handle_hotplug_event_func,
|
||||
};
|
||||
|
||||
/* callback routine to register each ACPI PCI slot object */
|
||||
static acpi_status
|
||||
@@ -285,7 +287,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
|
||||
*/
|
||||
newfunc->flags &= ~FUNC_HAS_EJ0;
|
||||
if (register_hotplug_dock_device(handle,
|
||||
handle_hotplug_event_func, newfunc))
|
||||
&acpiphp_dock_ops, newfunc))
|
||||
dbg("failed to register dock device\n");
|
||||
|
||||
/* we need to be notified when dock events happen
|
||||
|
||||
@@ -327,6 +327,9 @@ int acpi_bus_get_private_data(acpi_handle, void **);
|
||||
extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
|
||||
extern int register_acpi_notifier(struct notifier_block *);
|
||||
extern int unregister_acpi_notifier(struct notifier_block *);
|
||||
|
||||
extern int register_acpi_bus_notifier(struct notifier_block *nb);
|
||||
extern void unregister_acpi_bus_notifier(struct notifier_block *nb);
|
||||
/*
|
||||
* External Functions
|
||||
*/
|
||||
|
||||
@@ -116,12 +116,17 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
|
||||
/*--------------------------------------------------------------------------
|
||||
Dock Station
|
||||
-------------------------------------------------------------------------- */
|
||||
struct acpi_dock_ops {
|
||||
acpi_notify_handler handler;
|
||||
acpi_notify_handler uevent;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
|
||||
extern int is_dock_device(acpi_handle handle);
|
||||
extern int register_dock_notifier(struct notifier_block *nb);
|
||||
extern void unregister_dock_notifier(struct notifier_block *nb);
|
||||
extern int register_hotplug_dock_device(acpi_handle handle,
|
||||
acpi_notify_handler handler,
|
||||
struct acpi_dock_ops *ops,
|
||||
void *context);
|
||||
extern void unregister_hotplug_dock_device(acpi_handle handle);
|
||||
#else
|
||||
@@ -137,7 +142,7 @@ static inline void unregister_dock_notifier(struct notifier_block *nb)
|
||||
{
|
||||
}
|
||||
static inline int register_hotplug_dock_device(acpi_handle handle,
|
||||
acpi_notify_handler handler,
|
||||
struct acpi_dock_ops *ops,
|
||||
void *context)
|
||||
{
|
||||
return -ENODEV;
|
||||
|
||||
@@ -193,6 +193,9 @@ acpi_status
|
||||
acpi_os_execute(acpi_execute_type type,
|
||||
acpi_osd_exec_callback function, void *context);
|
||||
|
||||
acpi_status
|
||||
acpi_os_hotplug_execute(acpi_osd_exec_callback function, void *context);
|
||||
|
||||
void acpi_os_wait_events_complete(void *context);
|
||||
|
||||
void acpi_os_sleep(acpi_integer milliseconds);
|
||||
|
||||
Reference in New Issue
Block a user