ACPI / AC: change notification handler type to ACPI_ALL_NOTIFY

With kernel 3.13rc5 there are no AC adapter notifications on my laptop.

Commit cc8ef5270734 "ACPI / AC: convert ACPI ac driver to platform bus"
changed the driver to listen to device notifications only. However, AML
code on my laptop notifies the driver with zero event.

This patch changes the driver to listen to all events again.

Fixes: cc8ef5270734 (ACPI / AC: convert ACPI ac driver to platform bus)
References: https://bugzilla.kernel.org/show_bug.cgi?id=67821
Signed-off-by: Alexander Mezin <mezin.alexander@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / TPM: fix memory leak when walking ACPI namespace

In function ppi_callback(), memory allocated by acpi_get_name() will get
leaked when current device isn't the desired TPM device, so fix the
memory leak.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpi-tpm' into acpi-dsm
ACPI: introduce helper interfaces for _DSM method

There are several drivers making use of ACPI _DSM method to detect
and invoke device specific methods. Currently every driver has
implemented its private version to support ACPI _DSM method.
So this patch introduces three helper functions to support ACPI _DSM
method, which will be used to replace open-coded versions.

It helps to simplify code and improve code readability.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
PCI / pci-label: release allocated ACPI object on error recovery path

Function dsm_get_label() leaks the returned ACPI object if
obj->package.count is not 2, so fix the possible memory leak.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / PCI: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in pci-label driver.
Also enforce more strict checks on objects returned by _DSM method.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
PCI / pci-label: treat PCI label with index 0 as valid label

Current pci-label driver detects ACPI label by checking label index
returned by ACPI _DSM method, and treats it as valid if label index
is positive. According to ACPI Firmware specification 3.1, zero is
also an valid label index. So change code to detect availability of
ACPI slot label by checking availaiblity of ACPI _DSM function for
PCI label.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / TPM: match node name instead of full path when searching for TPM device

When searching ACPI object for TPM device, it should match current
ACPI object name instead of the full path.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / TPM: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in TPM driver.

This patch also help to get rid of following warning messages:
[  163.509575] ACPI Error: Incorrect return type [Buffer] requested [Package]
(20130517/nsxfeval-135)

But there is still an warning left.
[  181.637366] ACPI Warning: \_SB_.IIO0.LPC0.TPM_._DSM: Argument #4 type
mismatch - Found [Buffer], ACPI requires [Package] (20130517/nsarguments-95)

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / TPM: detect PPI features by checking availability of _DSM functions

Detecting physical presence interface features by checking availbility
of corresponding ACPI _DSM functions, it should be more accurate than
checking TPM version number.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / i2c-hid: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in i2c-hid driver.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / i915: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in i915 driver.

Function intel_dsm() is used to check functions supported by ACPI _DSM
method, but it has strange check for special value 0x80000002. After
digging into nouveau driver, I think the check is copied from nouveau
driver and is useless for i915 driver, so remove it.

Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
nouveau / ACPI: fix memory leak in ACPI _DSM related code

Fix memory leak in function nouveau_optimus_dsm() and nouveau_dsm().

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / nouveau: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in nouveau driver.
After analyzing the ACPI _DSM related code, I changed nouveau_optimus_dsm()
to expect a buffer and nouveau_dsm() to expect an integer only.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI / extlog: replace open-coded _DSM code with helper functions

Use helper functions to simplify _DSM related code in acpi_extlog driver.
Also mark initialization data and functions with __init and __initdata
to reduce memory footprint.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Tested-by: Chen, Gong <gong.chen@linux.intel.com>
Reviewed-by: Chen, Gong <gong.chen@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Merge branch 'acpi-dsm'

* acpi-dsm:
  ACPI / extlog: replace open-coded _DSM code with helper functions
  ACPI / nouveau: replace open-coded _DSM code with helper functions
  nouveau / ACPI: fix memory leak in ACPI _DSM related code
  ACPI / i915: replace open-coded _DSM code with helper functions
  ACPI / i2c-hid: replace open-coded _DSM code with helper functions
  ACPI / TPM: detect PPI features by checking availability of _DSM functions
  ACPI / TPM: replace open-coded _DSM code with helper functions
  ACPI / TPM: match node name instead of full path when searching for TPM device
  PCI / pci-label: treat PCI label with index 0 as valid label
  ACPI / PCI: replace open-coded _DSM code with helper functions
  PCI / pci-label: release allocated ACPI object on error recovery path
  ACPI: introduce helper interfaces for _DSM method
  ACPI / TPM: fix memory leak when walking ACPI namespace
Merge branch 'acpi-ac'

* acpi-ac:
  ACPI / AC: change notification handler type to ACPI_ALL_NOTIFY