Skip to content

Commit 1bed7f9

Browse files
xdarklightUlf Hansson
authored andcommitted
mmc: meson-mx-sdio: Ignore disabled "mmc-slot" child-nodes
The meson-mx-sdio (and mmc core) only support one MMC/SD/SDIO slot (device) per host. Thus having multiple mmc-slot nodes (one for the up to three supported slots with one device each on the meson-mx-sdio hardware) can be problematic. Allow specifying all slots (with their respective device) connected to the meson-mx-sdio hardware in device-tree, while making sure that only the enabled one(s) are actually considered by the driver. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 38fffa9 commit 1bed7f9

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

drivers/mmc/host/meson-mx-sdio.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -493,23 +493,30 @@ static struct mmc_host_ops meson_mx_mmc_ops = {
493493

494494
static struct platform_device *meson_mx_mmc_slot_pdev(struct device *parent)
495495
{
496-
struct device_node *slot_node;
497-
struct platform_device *pdev;
496+
struct platform_device *pdev = NULL;
497+
498+
for_each_available_child_of_node_scoped(parent->of_node, slot_node) {
499+
if (!of_device_is_compatible(slot_node, "mmc-slot"))
500+
continue;
501+
502+
/*
503+
* TODO: the MMC core framework currently does not support
504+
* controllers with multiple slots properly. So we only
505+
* register the first slot for now.
506+
*/
507+
if (pdev) {
508+
dev_warn(parent,
509+
"more than one 'mmc-slot' compatible child found - using the first one and ignoring all subsequent ones\n");
510+
break;
511+
}
498512

499-
/*
500-
* TODO: the MMC core framework currently does not support
501-
* controllers with multiple slots properly. So we only register
502-
* the first slot for now
503-
*/
504-
slot_node = of_get_compatible_child(parent->of_node, "mmc-slot");
505-
if (!slot_node) {
506-
dev_warn(parent, "no 'mmc-slot' sub-node found\n");
507-
return ERR_PTR(-ENOENT);
513+
pdev = of_platform_device_create(slot_node, NULL, parent);
514+
if (!pdev)
515+
dev_err(parent,
516+
"Failed to create platform device for mmc-slot node '%pOF'\n",
517+
slot_node);
508518
}
509519

510-
pdev = of_platform_device_create(slot_node, NULL, parent);
511-
of_node_put(slot_node);
512-
513520
return pdev;
514521
}
515522

@@ -642,8 +649,6 @@ static int meson_mx_mmc_probe(struct platform_device *pdev)
642649
slot_pdev = meson_mx_mmc_slot_pdev(&pdev->dev);
643650
if (!slot_pdev)
644651
return -ENODEV;
645-
else if (IS_ERR(slot_pdev))
646-
return PTR_ERR(slot_pdev);
647652

648653
mmc = devm_mmc_alloc_host(&slot_pdev->dev, sizeof(*host));
649654
if (!mmc) {

0 commit comments

Comments
 (0)