Commit 4f3cde3a authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki

mmc: sdhci-acpi: Switch to use acpi_dev_hid_uid_match()

Since we have a generic helper, drop custom implementation in the driver.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7e70c8ac
...@@ -61,7 +61,7 @@ struct sdhci_acpi_slot { ...@@ -61,7 +61,7 @@ struct sdhci_acpi_slot {
mmc_pm_flag_t pm_caps; mmc_pm_flag_t pm_caps;
unsigned int flags; unsigned int flags;
size_t priv_size; size_t priv_size;
int (*probe_slot)(struct platform_device *, const char *, const char *); int (*probe_slot)(struct platform_device *, struct acpi_device *);
int (*remove_slot)(struct platform_device *); int (*remove_slot)(struct platform_device *);
int (*free_slot)(struct platform_device *pdev); int (*free_slot)(struct platform_device *pdev);
int (*setup_host)(struct platform_device *pdev); int (*setup_host)(struct platform_device *pdev);
...@@ -325,12 +325,10 @@ static bool sdhci_acpi_cht_pci_wifi(unsigned int vendor, unsigned int device, ...@@ -325,12 +325,10 @@ static bool sdhci_acpi_cht_pci_wifi(unsigned int vendor, unsigned int device,
* wifi card in the expected slot with an ACPI companion node, is used to * wifi card in the expected slot with an ACPI companion node, is used to
* indicate that acpi_device_fix_up_power() should be avoided. * indicate that acpi_device_fix_up_power() should be avoided.
*/ */
static inline bool sdhci_acpi_no_fixup_child_power(const char *hid, static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
const char *uid)
{ {
return sdhci_acpi_cht() && return sdhci_acpi_cht() &&
!strcmp(hid, "80860F14") && acpi_dev_hid_uid_match(adev, "80860F14", "2") &&
!strcmp(uid, "2") &&
sdhci_acpi_cht_pci_wifi(0x14e4, 0x43ec, 0, 28); sdhci_acpi_cht_pci_wifi(0x14e4, 0x43ec, 0, 28);
} }
...@@ -345,8 +343,7 @@ static inline bool sdhci_acpi_byt_defer(struct device *dev) ...@@ -345,8 +343,7 @@ static inline bool sdhci_acpi_byt_defer(struct device *dev)
return false; return false;
} }
static inline bool sdhci_acpi_no_fixup_child_power(const char *hid, static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
const char *uid)
{ {
return false; return false;
} }
...@@ -375,19 +372,18 @@ static int bxt_get_cd(struct mmc_host *mmc) ...@@ -375,19 +372,18 @@ static int bxt_get_cd(struct mmc_host *mmc)
return ret; return ret;
} }
static int intel_probe_slot(struct platform_device *pdev, const char *hid, static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
const char *uid)
{ {
struct sdhci_acpi_host *c = platform_get_drvdata(pdev); struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
struct intel_host *intel_host = sdhci_acpi_priv(c); struct intel_host *intel_host = sdhci_acpi_priv(c);
struct sdhci_host *host = c->host; struct sdhci_host *host = c->host;
if (hid && uid && !strcmp(hid, "80860F14") && !strcmp(uid, "1") && if (acpi_dev_hid_uid_match(adev, "80860F14", "1") &&
sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 && sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807) sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807)
host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */ host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
if (hid && !strcmp(hid, "80865ACA")) if (acpi_dev_hid_uid_match(adev, "80865ACA", NULL))
host->mmc_host_ops.get_cd = bxt_get_cd; host->mmc_host_ops.get_cd = bxt_get_cd;
intel_dsm_init(intel_host, &pdev->dev, host->mmc); intel_dsm_init(intel_host, &pdev->dev, host->mmc);
...@@ -473,8 +469,7 @@ static irqreturn_t sdhci_acpi_qcom_handler(int irq, void *ptr) ...@@ -473,8 +469,7 @@ static irqreturn_t sdhci_acpi_qcom_handler(int irq, void *ptr)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int qcom_probe_slot(struct platform_device *pdev, const char *hid, static int qcom_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
const char *uid)
{ {
struct sdhci_acpi_host *c = platform_get_drvdata(pdev); struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
struct sdhci_host *host = c->host; struct sdhci_host *host = c->host;
...@@ -482,7 +477,7 @@ static int qcom_probe_slot(struct platform_device *pdev, const char *hid, ...@@ -482,7 +477,7 @@ static int qcom_probe_slot(struct platform_device *pdev, const char *hid,
*irq = -EINVAL; *irq = -EINVAL;
if (strcmp(hid, "QCOM8051")) if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
return 0; return 0;
*irq = platform_get_irq(pdev, 1); *irq = platform_get_irq(pdev, 1);
...@@ -501,14 +496,12 @@ static int qcom_free_slot(struct platform_device *pdev) ...@@ -501,14 +496,12 @@ static int qcom_free_slot(struct platform_device *pdev)
struct sdhci_host *host = c->host; struct sdhci_host *host = c->host;
struct acpi_device *adev; struct acpi_device *adev;
int *irq = sdhci_acpi_priv(c); int *irq = sdhci_acpi_priv(c);
const char *hid;
adev = ACPI_COMPANION(dev); adev = ACPI_COMPANION(dev);
if (!adev) if (!adev)
return -ENODEV; return -ENODEV;
hid = acpi_device_hid(adev); if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
if (strcmp(hid, "QCOM8051"))
return 0; return 0;
if (*irq < 0) if (*irq < 0)
...@@ -583,7 +576,7 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_amd = { ...@@ -583,7 +576,7 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_amd = {
}; };
static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev, static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev,
const char *hid, const char *uid) struct acpi_device *adev)
{ {
struct sdhci_acpi_host *c = platform_get_drvdata(pdev); struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
struct sdhci_host *host = c->host; struct sdhci_host *host = c->host;
...@@ -654,17 +647,12 @@ static const struct acpi_device_id sdhci_acpi_ids[] = { ...@@ -654,17 +647,12 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
}; };
MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids); MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid, static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev)
const char *uid)
{ {
const struct sdhci_acpi_uid_slot *u; const struct sdhci_acpi_uid_slot *u;
for (u = sdhci_acpi_uids; u->hid; u++) { for (u = sdhci_acpi_uids; u->hid; u++) {
if (strcmp(u->hid, hid)) if (acpi_dev_hid_uid_match(adev, u->hid, u->uid))
continue;
if (!u->uid)
return u->slot;
if (uid && !strcmp(u->uid, uid))
return u->slot; return u->slot;
} }
return NULL; return NULL;
...@@ -680,22 +668,17 @@ static int sdhci_acpi_probe(struct platform_device *pdev) ...@@ -680,22 +668,17 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
struct resource *iomem; struct resource *iomem;
resource_size_t len; resource_size_t len;
size_t priv_size; size_t priv_size;
const char *hid;
const char *uid;
int err; int err;
device = ACPI_COMPANION(dev); device = ACPI_COMPANION(dev);
if (!device) if (!device)
return -ENODEV; return -ENODEV;
hid = acpi_device_hid(device); slot = sdhci_acpi_get_slot(device);
uid = acpi_device_uid(device);
slot = sdhci_acpi_get_slot(hid, uid);
/* Power on the SDHCI controller and its children */ /* Power on the SDHCI controller and its children */
acpi_device_fix_up_power(device); acpi_device_fix_up_power(device);
if (!sdhci_acpi_no_fixup_child_power(hid, uid)) { if (!sdhci_acpi_no_fixup_child_power(device)) {
list_for_each_entry(child, &device->children, node) list_for_each_entry(child, &device->children, node)
if (child->status.present && child->status.enabled) if (child->status.present && child->status.enabled)
acpi_device_fix_up_power(child); acpi_device_fix_up_power(child);
...@@ -745,7 +728,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) ...@@ -745,7 +728,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
if (c->slot) { if (c->slot) {
if (c->slot->probe_slot) { if (c->slot->probe_slot) {
err = c->slot->probe_slot(pdev, hid, uid); err = c->slot->probe_slot(pdev, device);
if (err) if (err)
goto err_free; goto err_free;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment