@@ -68,18 +68,19 @@ static inline bool apple_gmux_is_indexed(unsigned long iostart)
static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool *indexed_ret)
{
u8 ver_major, ver_minor, ver_release;
+ struct device *dev = NULL;
+ struct acpi_device *adev;
struct resource *res;
bool indexed = false;
+ bool ret = false;
if (!pnp_dev) {
- struct acpi_device *adev;
- struct device *dev;
-
adev = acpi_dev_get_first_match_dev(GMUX_ACPI_HID, NULL, -1);
if (!adev)
return false;
- dev = acpi_get_first_physical_node(adev);
+ dev = get_device(acpi_get_first_physical_node(adev));
+ acpi_dev_put(adev);
if (!dev)
return false;
@@ -87,11 +88,8 @@ static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool *indexed_ret)
}
res = pnp_get_resource(pnp_dev, IORESOURCE_IO, 0);
- if (!res)
- return false;
-
- if (resource_size(res) < GMUX_MIN_IO_LEN)
- return false;
+ if (!res || resource_size(res) < GMUX_MIN_IO_LEN)
+ goto out;
/*
* Invalid version information may indicate either that the gmux
@@ -103,13 +101,16 @@ static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, bool *indexed_ret)
if (ver_major == 0xff && ver_minor == 0xff && ver_release == 0xff) {
indexed = apple_gmux_is_indexed(res->start);
if (!indexed)
- return false;
+ goto out;
}
if (indexed_ret)
*indexed_ret = indexed;
- return true;
+ ret = true;
+out:
+ put_device(dev);
+ return ret;
}
/**