]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
usb: musb: jz4740: Unconditionally depend on devicetree
authorPaul Cercueil <paul@crapouillou.net>
Mon, 16 Mar 2020 21:11:33 +0000 (16:11 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Mar 2020 19:03:27 +0000 (20:03 +0100)
The jz4740-musb driver is unconditionally probed from devicetree, so we
can add a hard dependency on devicetree. This makes the code a bit
cleaner, and is more future-proof as the platform data is now retrieved
using of_device_get_match_data().

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Bin Liu <b-liu@ti.com>
Link: https://lore.kernel.org/r/20200316211136.2274-6-b-liu@ti.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/Kconfig
drivers/usb/musb/jz4740.c

index 3268adb7d7cf48c91bd8dad0470eee5dfac58ba3..3b0d1c20ebe67bf737e23882e4127906fc6c9515 100644 (file)
@@ -110,6 +110,7 @@ config USB_MUSB_UX500
 
 config USB_MUSB_JZ4740
        tristate "JZ4740"
+       depends on OF
        depends on MIPS || COMPILE_TEST
        depends on USB_MUSB_GADGET
        depends on USB=n || USB_OTG_BLACKLIST_HUB
index 7f813bdaf1d16bdff15709478a47cd6a61ba406b..22eebe43ae1e101d8c89e4d888c09e4a0dc7fd1b 100644 (file)
@@ -166,7 +166,7 @@ static const struct musb_hdrc_platform_data jz4740_musb_pdata = {
 static int jz4740_probe(struct platform_device *pdev)
 {
        struct device                   *dev = &pdev->dev;
-       const struct musb_hdrc_platform_data *pdata = &jz4740_musb_pdata;
+       const struct musb_hdrc_platform_data *pdata;
        struct platform_device          *musb;
        struct jz4740_glue              *glue;
        struct clk                      *clk;
@@ -176,6 +176,12 @@ static int jz4740_probe(struct platform_device *pdev)
        if (!glue)
                return -ENOMEM;
 
+       pdata = of_device_get_match_data(dev);
+       if (!pdata) {
+               dev_err(dev, "missing platform data");
+               return -EINVAL;
+       }
+
        musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
        if (!musb) {
                dev_err(dev, "failed to allocate musb device");
@@ -242,20 +248,18 @@ static int jz4740_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id jz4740_musb_of_match[] = {
-       { .compatible = "ingenic,jz4740-musb" },
+       { .compatible = "ingenic,jz4740-musb", .data = &jz4740_musb_pdata },
        { /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, jz4740_musb_of_match);
-#endif
 
 static struct platform_driver jz4740_driver = {
        .probe          = jz4740_probe,
        .remove         = jz4740_remove,
        .driver         = {
                .name   = "musb-jz4740",
-               .of_match_table = of_match_ptr(jz4740_musb_of_match),
+               .of_match_table = jz4740_musb_of_match,
        },
 };