Merge branches 'acpi-general', 'acpi-processor', 'acpi-lpss' and 'acpi-battery'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 19 Jun 2014 12:40:48 +0000 (14:40 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 19 Jun 2014 12:40:48 +0000 (14:40 +0200)
* acpi-general:
  ACPI: use kstrto*() instead of simple_strto*()

* acpi-processor:
  ACPI / processor replace __attribute__((packed)) by __packed

* acpi-lpss:
  ACPI / LPSS: Take I2C host controllers out of reset

* acpi-battery:
  ACPI / battery: add quirk for Acer Aspire V5-573G
  ACPI / battery: use callback for setting up quirks

arch/ia64/hp/common/sba_iommu.c
drivers/acpi/battery.c
drivers/acpi/osl.c
drivers/acpi/tables.c
include/acpi/processor.h

index 1a871b7..344387a 100644 (file)
@@ -242,7 +242,7 @@ struct ioc {
        struct pci_dev  *sac_only_dev;
 };
 
-static struct ioc *ioc_list;
+static struct ioc *ioc_list, *ioc_found;
 static int reserve_sba_gart = 1;
 
 static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
@@ -1809,20 +1809,13 @@ static struct ioc_iommu ioc_iommu_info[] __initdata = {
        { SX2000_IOC_ID, "sx2000", NULL },
 };
 
-static struct ioc *
-ioc_init(unsigned long hpa, void *handle)
+static void ioc_init(unsigned long hpa, struct ioc *ioc)
 {
-       struct ioc *ioc;
        struct ioc_iommu *info;
 
-       ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
-       if (!ioc)
-               return NULL;
-
        ioc->next = ioc_list;
        ioc_list = ioc;
 
-       ioc->handle = handle;
        ioc->ioc_hpa = ioremap(hpa, 0x1000);
 
        ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID);
@@ -1863,8 +1856,6 @@ ioc_init(unsigned long hpa, void *handle)
                "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n",
                ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF,
                hpa, ioc->iov_size >> 20, ioc->ibase);
-
-       return ioc;
 }
 
 
@@ -2031,22 +2022,21 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
 #endif
 }
 
-static int
-acpi_sba_ioc_add(struct acpi_device *device,
-                const struct acpi_device_id *not_used)
+static void acpi_sba_ioc_add(struct ioc *ioc)
 {
-       struct ioc *ioc;
+       acpi_handle handle = ioc->handle;
        acpi_status status;
        u64 hpa, length;
        struct acpi_device_info *adi;
 
-       status = hp_acpi_csr_space(device->handle, &hpa, &length);
+       ioc_found = ioc->next;
+       status = hp_acpi_csr_space(handle, &hpa, &length);
        if (ACPI_FAILURE(status))
-               return 1;
+               goto err;
 
-       status = acpi_get_object_info(device->handle, &adi);
+       status = acpi_get_object_info(handle, &adi);
        if (ACPI_FAILURE(status))
-               return 1;
+               goto err;
 
        /*
         * For HWP0001, only SBA appears in ACPI namespace.  It encloses the PCI
@@ -2067,13 +2057,13 @@ acpi_sba_ioc_add(struct acpi_device *device,
        if (!iovp_shift)
                iovp_shift = 12;
 
-       ioc = ioc_init(hpa, device->handle);
-       if (!ioc)
-               return 1;
-
+       ioc_init(hpa, ioc);
        /* setup NUMA node association */
-       sba_map_ioc_to_node(ioc, device->handle);
-       return 0;
+       sba_map_ioc_to_node(ioc, handle);
+       return;
+
+ err:
+       kfree(ioc);
 }
 
 static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
@@ -2081,9 +2071,26 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
        {"HWP0004", 0},
        {"", 0},
 };
+
+static int acpi_sba_ioc_attach(struct acpi_device *device,
+                              const struct acpi_device_id *not_used)
+{
+       struct ioc *ioc;
+
+       ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
+       if (!ioc)
+               return -ENOMEM;
+
+       ioc->next = ioc_found;
+       ioc_found = ioc;
+       ioc->handle = device->handle;
+       return 1;
+}
+
+
 static struct acpi_scan_handler acpi_sba_ioc_handler = {
        .ids    = hp_ioc_iommu_device_ids,
-       .attach = acpi_sba_ioc_add,
+       .attach = acpi_sba_ioc_attach,
 };
 
 static int __init acpi_sba_ioc_init_acpi(void)
@@ -2118,9 +2125,12 @@ sba_init(void)
 #endif
 
        /*
-        * ioc_list should be populated by the acpi_sba_ioc_handler's .attach()
+        * ioc_found should be populated by the acpi_sba_ioc_handler's .attach()
         * routine, but that only happens if acpi_scan_init() has already run.
         */
+       while (ioc_found)
+               acpi_sba_ioc_add(ioc_found);
+
        if (!ioc_list) {
 #ifdef CONFIG_IA64_GENERIC
                /*
index e48fc98..0d7116f 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/jiffies.h>
 #include <linux/async.h>
 #include <linux/dmi.h>
+#include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/suspend.h>
 #include <asm/unaligned.h>
@@ -70,6 +71,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
 MODULE_LICENSE("GPL");
 
 static int battery_bix_broken_package;
+static int battery_notification_delay_ms;
 static unsigned int cache_time = 1000;
 module_param(cache_time, uint, 0644);
 MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -930,7 +932,10 @@ static ssize_t acpi_battery_write_alarm(struct file *file,
                goto end;
        }
        alarm_string[count] = '\0';
-       battery->alarm = simple_strtol(alarm_string, NULL, 0);
+       if (kstrtoint(alarm_string, 0, &battery->alarm)) {
+               result = -EINVAL;
+               goto end;
+       }
        result = acpi_battery_set_alarm(battery);
       end:
        if (!result)
@@ -1062,6 +1067,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
        if (!battery)
                return;
        old = battery->bat.dev;
+       /*
+       * On Acer Aspire V5-573G notifications are sometimes triggered too
+       * early. For example, when AC is unplugged and notification is
+       * triggered, battery state is still reported as "Full", and changes to
+       * "Discharging" only after short delay, without any notification.
+       */
+       if (battery_notification_delay_ms > 0)
+               msleep(battery_notification_delay_ms);
        if (event == ACPI_BATTERY_NOTIFY_INFO)
                acpi_battery_refresh(battery);
        acpi_battery_update(battery, false);
@@ -1106,14 +1119,35 @@ static int battery_notify(struct notifier_block *nb,
        return 0;
 }
 
+static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
+{
+       battery_bix_broken_package = 1;
+       return 0;
+}
+
+static int battery_notification_delay_quirk(const struct dmi_system_id *d)
+{
+       battery_notification_delay_ms = 1000;
+       return 0;
+}
+
 static struct dmi_system_id bat_dmi_table[] = {
        {
+               .callback = battery_bix_broken_package_quirk,
                .ident = "NEC LZ750/LS",
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
                },
        },
+       {
+               .callback = battery_notification_delay_quirk,
+               .ident = "Acer Aspire V5-573G",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
+               },
+       },
        {},
 };
 
@@ -1227,8 +1261,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
        if (acpi_disabled)
                return;
 
-       if (dmi_check_system(bat_dmi_table))
-               battery_bix_broken_package = 1;
+       dmi_check_system(bat_dmi_table);
        
 #ifdef CONFIG_ACPI_PROCFS_POWER
        acpi_battery_dir = acpi_lock_battery_dir();
index 3f2bdc8..bad25b0 100644 (file)
@@ -235,7 +235,8 @@ void acpi_os_vprintf(const char *fmt, va_list args)
 static unsigned long acpi_rsdp;
 static int __init setup_acpi_rsdp(char *arg)
 {
-       acpi_rsdp = simple_strtoul(arg, NULL, 16);
+       if (kstrtoul(arg, 16, &acpi_rsdp))
+               return -EINVAL;
        return 0;
 }
 early_param("acpi_rsdp", setup_acpi_rsdp);
index 05550ba..6d5a6cd 100644 (file)
@@ -360,7 +360,8 @@ static int __init acpi_parse_apic_instance(char *str)
        if (!str)
                return -EINVAL;
 
-       acpi_apic_instance = simple_strtoul(str, NULL, 0);
+       if (kstrtoint(str, 0, &acpi_apic_instance))
+               return -EINVAL;
 
        pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);
 
index 6eb1d3c..9b9b6f2 100644 (file)
@@ -53,7 +53,7 @@ struct acpi_power_register {
        u8 bit_offset;
        u8 access_size;
        u64 address;
-} __attribute__ ((packed));
+} __packed;
 
 struct acpi_processor_cx {
        u8 valid;
@@ -83,7 +83,7 @@ struct acpi_psd_package {
        u64 domain;
        u64 coord_type;
        u64 num_processors;
-} __attribute__ ((packed));
+} __packed;
 
 struct acpi_pct_register {
        u8 descriptor;
@@ -93,7 +93,7 @@ struct acpi_pct_register {
        u8 bit_offset;
        u8 reserved;
        u64 address;
-} __attribute__ ((packed));
+} __packed;
 
 struct acpi_processor_px {
        u64 core_frequency;     /* megahertz */
@@ -124,7 +124,7 @@ struct acpi_tsd_package {
        u64 domain;
        u64 coord_type;
        u64 num_processors;
-} __attribute__ ((packed));
+} __packed;
 
 struct acpi_ptc_register {
        u8 descriptor;
@@ -134,7 +134,7 @@ struct acpi_ptc_register {
        u8 bit_offset;
        u8 reserved;
        u64 address;
-} __attribute__ ((packed));
+} __packed;
 
 struct acpi_processor_tx_tss {
        u64 freqpercentage;     /* */