]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: phy: am335x-control: prevent module from being unloaded when in use
authorLothar Waßmann <LW@KARO-electronics.de>
Wed, 11 Dec 2013 14:51:15 +0000 (15:51 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 27 Aug 2014 08:32:21 +0000 (10:32 +0200)
drivers/usb/phy/phy-am335x-control.c

index 35b6083b799949bc30f4f359ee62a55542959ca9..df3e1ba5013cdd9cffdc20e8a1b0b4366faac0d4 100644 (file)
@@ -140,6 +140,9 @@ static int am335x_control_usb_probe(struct platform_device *pdev)
        const struct of_device_id *of_id;
        const struct phy_control *phy_ctrl;
 
+       if (!try_module_get(pdev->dev.parent->driver->owner))
+               return -EPROBE_DEFER;
+
        of_id = of_match_node(omap_control_usb_id_table, pdev->dev.of_node);
        if (!of_id)
                return -EINVAL;
@@ -171,8 +174,15 @@ static int am335x_control_usb_probe(struct platform_device *pdev)
        return 0;
 }
 
+static int am335x_control_usb_remove(struct platform_device *pdev)
+{
+       module_put(pdev->dev.parent->driver->owner);
+       return 0;
+}
+
 static struct platform_driver am335x_control_driver = {
        .probe          = am335x_control_usb_probe,
+       .remove         = am335x_control_usb_remove,
        .driver         = {
                .name   = "am335x-control-usb",
                .owner  = THIS_MODULE,