libata-acpi: register/unregister device to/from power resource
authorLin Ming <ming.m.lin@intel.com>
Mon, 25 Jun 2012 08:13:07 +0000 (16:13 +0800)
committerJeff Garzik <jgarzik@redhat.com>
Fri, 29 Jun 2012 15:38:15 +0000 (11:38 -0400)
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/acpi/power.c
drivers/ata/libata-acpi.c

index dd6d6a3c6780d7e787c1c3427b808618d8c64fa4..eb6408741a8f8de6faa0fa77d153dcbe97eb0ec0 100644 (file)
@@ -390,6 +390,7 @@ void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handl
                __acpi_power_resource_unregister_device(dev,
                        list->handles[i]);
 }
+EXPORT_SYMBOL_GPL(acpi_power_resource_unregister_device);
 
 static int __acpi_power_resource_register_device(
        struct acpi_power_managed_device *powered_device, acpi_handle handle)
@@ -460,6 +461,7 @@ no_power_resource:
        printk(KERN_WARNING PREFIX "Invalid Power Resource to register!");
        return -ENODEV;
 }
+EXPORT_SYMBOL_GPL(acpi_power_resource_register_device);
 
 /**
  * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in
index e01807a1ef31c7739b755b0dcf0fb76f40bca0c8..f36284e3290d5def51bbcbf0390556ae61067248 100644 (file)
@@ -1025,14 +1025,46 @@ static void ata_acpi_remove_pm_notifier(struct ata_device *dev)
        }
 }
 
+static void ata_acpi_register_power_resource(struct ata_device *dev)
+{
+       struct scsi_device *sdev = dev->sdev;
+       acpi_handle handle;
+       struct device *device;
+
+       handle = ata_dev_acpi_handle(dev);
+       if (!handle)
+               return;
+
+       device = &sdev->sdev_gendev;
+
+       acpi_power_resource_register_device(device, handle);
+}
+
+static void ata_acpi_unregister_power_resource(struct ata_device *dev)
+{
+       struct scsi_device *sdev = dev->sdev;
+       acpi_handle handle;
+       struct device *device;
+
+       handle = ata_dev_acpi_handle(dev);
+       if (!handle)
+               return;
+
+       device = &sdev->sdev_gendev;
+
+       acpi_power_resource_unregister_device(device, handle);
+}
+
 void ata_acpi_bind(struct ata_device *dev)
 {
        ata_acpi_add_pm_notifier(dev);
+       ata_acpi_register_power_resource(dev);
 }
 
 void ata_acpi_unbind(struct ata_device *dev)
 {
        ata_acpi_remove_pm_notifier(dev);
+       ata_acpi_unregister_power_resource(dev);
 }
 
 static int compat_pci_ata(struct ata_port *ap)