]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: btmtksdio: Lookup device node only as fallback
authorChen-Yu Tsai <wenst@chromium.org>
Tue, 8 Oct 2024 08:27:20 +0000 (16:27 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 14 Nov 2024 20:31:12 +0000 (15:31 -0500)
If the device tree is properly written, the SDIO function device node
should be correctly defined, and the mmc core in Linux should correctly
tie it to the device being probed.

Only fall back to searching for the device node by compatible if the
original device node tied to the device is incorrect, as seen in older
device trees.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btmtksdio.c

index cc097aedc1e14d30158093c3fe52328c3ff034b9..a1dfcfe43d3aad5269210dac8de7799dd6629341 100644 (file)
@@ -1328,6 +1328,8 @@ static int btmtksdio_probe(struct sdio_func *func,
 {
        struct btmtksdio_dev *bdev;
        struct hci_dev *hdev;
+       struct device_node *old_node;
+       bool restore_node;
        int err;
 
        bdev = devm_kzalloc(&func->dev, sizeof(*bdev), GFP_KERNEL);
@@ -1411,13 +1413,24 @@ static int btmtksdio_probe(struct sdio_func *func,
        if (err)
                bt_dev_err(hdev, "failed to initialize device wakeup");
 
-       bdev->dev->of_node = of_find_compatible_node(NULL, NULL,
-                                                    "mediatek,mt7921s-bluetooth");
+       restore_node = false;
+       if (!of_device_is_compatible(bdev->dev->of_node, "mediatek,mt7921s-bluetooth")) {
+               restore_node = true;
+               old_node = bdev->dev->of_node;
+               bdev->dev->of_node = of_find_compatible_node(NULL, NULL,
+                                                            "mediatek,mt7921s-bluetooth");
+       }
+
        bdev->reset = devm_gpiod_get_optional(bdev->dev, "reset",
                                              GPIOD_OUT_LOW);
        if (IS_ERR(bdev->reset))
                err = PTR_ERR(bdev->reset);
 
+       if (restore_node) {
+               of_node_put(bdev->dev->of_node);
+               bdev->dev->of_node = old_node;
+       }
+
        return err;
 }