2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2013-03-03 23:05:55 +01:00
|
|
|
* container.c - ACPI Generic Container Driver
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
|
* Copyright (C) 2004 Anil S Keshavamurthy (anil.s.keshavamurthy@intel.com)
|
|
|
|
|
* Copyright (C) 2004 Keiichiro Tokunaga (tokunaga.keiich@jp.fujitsu.com)
|
|
|
|
|
* Copyright (C) 2004 Motoyuki Ito (motoyuki@soft.fujitsu.com)
|
|
|
|
|
* Copyright (C) 2004 FUJITSU LIMITED
|
2013-03-03 23:05:55 +01:00
|
|
|
* Copyright (C) 2004, 2013 Intel Corp.
|
|
|
|
|
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
2005-04-16 15:20:36 -07:00
|
|
|
*
|
|
|
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
*
|
|
|
|
|
* 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/acpi.h>
|
2013-12-29 15:25:48 +01:00
|
|
|
#include <linux/container.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-03-11 09:17:07 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#define _COMPONENT ACPI_CONTAINER_COMPONENT
|
2007-02-12 22:42:12 -05:00
|
|
|
ACPI_MODULE_NAME("container");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-07-23 14:44:41 +02:00
|
|
|
static const struct acpi_device_id container_device_ids[] = {
|
|
|
|
|
{"ACPI0004", 0},
|
|
|
|
|
{"PNP0A05", 0},
|
|
|
|
|
{"PNP0A06", 0},
|
|
|
|
|
{"", 0},
|
|
|
|
|
};
|
|
|
|
|
|
2014-05-30 04:28:20 +02:00
|
|
|
#ifdef CONFIG_ACPI_CONTAINER
|
|
|
|
|
|
2013-12-29 15:25:48 +01:00
|
|
|
static int acpi_container_offline(struct container_dev *cdev)
|
|
|
|
|
{
|
|
|
|
|
struct acpi_device *adev = ACPI_COMPANION(&cdev->dev);
|
|
|
|
|
struct acpi_device *child;
|
|
|
|
|
|
|
|
|
|
/* Check all of the dependent devices' physical companions. */
|
|
|
|
|
list_for_each_entry(child, &adev->children, node)
|
|
|
|
|
if (!acpi_scan_is_offline(child, false))
|
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void acpi_container_release(struct device *dev)
|
|
|
|
|
{
|
|
|
|
|
kfree(to_container_dev(dev));
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-22 21:55:32 +01:00
|
|
|
static int container_device_attach(struct acpi_device *adev,
|
2013-02-08 23:52:39 +01:00
|
|
|
const struct acpi_device_id *not_used)
|
|
|
|
|
{
|
2013-12-29 15:25:48 +01:00
|
|
|
struct container_dev *cdev;
|
|
|
|
|
struct device *dev;
|
|
|
|
|
int ret;
|
|
|
|
|
|
2014-02-16 01:51:01 +01:00
|
|
|
if (adev->flags.is_dock_station)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2013-12-29 15:25:48 +01:00
|
|
|
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
|
|
|
|
|
if (!cdev)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
cdev->offline = acpi_container_offline;
|
|
|
|
|
dev = &cdev->dev;
|
|
|
|
|
dev->bus = &container_subsys;
|
|
|
|
|
dev_set_name(dev, "%s", dev_name(&adev->dev));
|
|
|
|
|
ACPI_COMPANION_SET(dev, adev);
|
|
|
|
|
dev->release = acpi_container_release;
|
|
|
|
|
ret = device_register(dev);
|
2014-02-12 00:52:49 +01:00
|
|
|
if (ret) {
|
|
|
|
|
put_device(dev);
|
2013-12-29 15:25:48 +01:00
|
|
|
return ret;
|
2014-02-12 00:52:49 +01:00
|
|
|
}
|
2013-12-29 15:25:48 +01:00
|
|
|
adev->driver_data = dev;
|
2013-02-08 23:52:39 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-22 21:55:32 +01:00
|
|
|
static void container_device_detach(struct acpi_device *adev)
|
|
|
|
|
{
|
2013-12-29 15:25:48 +01:00
|
|
|
struct device *dev = acpi_driver_data(adev);
|
|
|
|
|
|
|
|
|
|
adev->driver_data = NULL;
|
|
|
|
|
if (dev)
|
|
|
|
|
device_unregister(dev);
|
2013-11-22 21:55:32 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-21 02:58:18 +02:00
|
|
|
static void container_device_online(struct acpi_device *adev)
|
|
|
|
|
{
|
|
|
|
|
struct device *dev = acpi_driver_data(adev);
|
|
|
|
|
|
|
|
|
|
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 23:08:45 +01:00
|
|
|
static struct acpi_scan_handler container_handler = {
|
2007-07-23 14:44:41 +02:00
|
|
|
.ids = container_device_ids,
|
2013-02-08 23:52:39 +01:00
|
|
|
.attach = container_device_attach,
|
2013-11-22 21:55:32 +01:00
|
|
|
.detach = container_device_detach,
|
2013-03-03 23:05:55 +01:00
|
|
|
.hotplug = {
|
|
|
|
|
.enabled = true,
|
2013-12-29 15:25:48 +01:00
|
|
|
.demand_offline = true,
|
2014-09-21 02:58:18 +02:00
|
|
|
.notify_online = container_device_online,
|
2013-03-03 23:05:55 +01:00
|
|
|
},
|
2005-04-16 15:20:36 -07:00
|
|
|
};
|
|
|
|
|
|
2014-05-30 04:28:20 +02:00
|
|
|
void __init acpi_container_init(void)
|
|
|
|
|
{
|
|
|
|
|
acpi_scan_add_handler(&container_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
static struct acpi_scan_handler container_handler = {
|
|
|
|
|
.ids = container_device_ids,
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-08 23:52:39 +01:00
|
|
|
void __init acpi_container_init(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2013-03-03 23:08:45 +01:00
|
|
|
acpi_scan_add_handler_with_hotplug(&container_handler, "container");
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2014-05-30 04:28:20 +02:00
|
|
|
|
|
|
|
|
#endif /* CONFIG_ACPI_CONTAINER */
|