Commit 4811a411 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Wolfram Sang
Browse files

i2c: i801: Improve i801_acpi_probe/remove functions



By using ACPI_HANDLE() the handler argument can be retrieved directly.
Both address space handler functions check the handler argument and
return an error if it's NULL. This allows to further simplify the code.

Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
Tested-by: default avatarJean Delvare <jdelvare@suse.de>
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent e462aa7e
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -1635,31 +1635,22 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,

static int i801_acpi_probe(struct i801_priv *priv)
{
	struct acpi_device *adev;
	acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev);
	acpi_status status;

	adev = ACPI_COMPANION(&priv->pci_dev->dev);
	if (adev) {
		status = acpi_install_address_space_handler(adev->handle,
				ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler,
				NULL, priv);
	status = acpi_install_address_space_handler(ah, ACPI_ADR_SPACE_SYSTEM_IO,
						    i801_acpi_io_handler, NULL, priv);
	if (ACPI_SUCCESS(status))
		return 0;
	}

	return acpi_check_resource_conflict(&priv->pci_dev->resource[SMBBAR]);
}

static void i801_acpi_remove(struct i801_priv *priv)
{
	struct acpi_device *adev;

	adev = ACPI_COMPANION(&priv->pci_dev->dev);
	if (!adev)
		return;
	acpi_handle ah = ACPI_HANDLE(&priv->pci_dev->dev);

	acpi_remove_address_space_handler(adev->handle,
		ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler);
	acpi_remove_address_space_handler(ah, ACPI_ADR_SPACE_SYSTEM_IO, i801_acpi_io_handler);
}
#else
static inline int i801_acpi_probe(struct i801_priv *priv) { return 0; }