Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux-2.6-microblaze.git] / drivers / tty / synclink_gt.c
index 25e9bef..72b76cd 100644 (file)
@@ -1433,16 +1433,8 @@ static int hdlcdev_open(struct net_device *dev)
        int rc;
        unsigned long flags;
 
-       if (!try_module_get(THIS_MODULE))
-               return -EBUSY;
-
        DBGINFO(("%s hdlcdev_open\n", dev->name));
 
-       /* generic HDLC layer open processing */
-       rc = hdlc_open(dev);
-       if (rc)
-               return rc;
-
        /* arbitrate between network and tty opens */
        spin_lock_irqsave(&info->netlock, flags);
        if (info->port.count != 0 || info->netcount != 0) {
@@ -1461,6 +1453,16 @@ static int hdlcdev_open(struct net_device *dev)
                return rc;
        }
 
+       /* generic HDLC layer open processing */
+       rc = hdlc_open(dev);
+       if (rc) {
+               shutdown(info);
+               spin_lock_irqsave(&info->netlock, flags);
+               info->netcount = 0;
+               spin_unlock_irqrestore(&info->netlock, flags);
+               return rc;
+       }
+
        /* assert RTS and DTR, apply hardware settings */
        info->signals |= SerialSignal_RTS | SerialSignal_DTR;
        program_hw(info);
@@ -1506,7 +1508,6 @@ static int hdlcdev_close(struct net_device *dev)
        info->netcount=0;
        spin_unlock_irqrestore(&info->netlock, flags);
 
-       module_put(THIS_MODULE);
        return 0;
 }