All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xie He <xie.he.0141@gmail.com>, Martin Schiller <ms@dev.tdt.de>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.8 07/24] drivers/net/wan/x25_asy: Correct the ndo_open and ndo_stop functions
Date: Mon, 12 Oct 2020 15:02:22 -0400	[thread overview]
Message-ID: <20201012190239.3279198-7-sashal@kernel.org> (raw)
In-Reply-To: <20201012190239.3279198-1-sashal@kernel.org>

From: Xie He <xie.he.0141@gmail.com>

[ Upstream commit ed46cd1d4cc4b2cf05f31fe25fc68d1a9d3589ba ]

1.
Move the lapb_register/lapb_unregister calls into the ndo_open/ndo_stop
functions.
This makes the LAPB protocol start/stop when the network interface
starts/stops. When the network interface is down, the LAPB protocol
shouldn't be running and the LAPB module shoudn't be generating control
frames.

2.
Move netif_start_queue/netif_stop_queue into the ndo_open/ndo_stop
functions.
This makes the TX queue start/stop when the network interface
starts/stops.
(netif_stop_queue was originally in the ndo_stop function. But to make
the code look better, I created a new function to use as ndo_stop, and
made it call the original ndo_stop function. I moved netif_stop_queue
from the original ndo_stop function to the new ndo_stop function.)

Cc: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wan/x25_asy.c | 43 +++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 84640a0c13f35..6b427d5dec7e4 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -456,7 +456,6 @@ static int x25_asy_open(struct net_device *dev)
 {
 	struct x25_asy *sl = netdev_priv(dev);
 	unsigned long len;
-	int err;
 
 	if (sl->tty == NULL)
 		return -ENODEV;
@@ -482,14 +481,7 @@ static int x25_asy_open(struct net_device *dev)
 	sl->xleft    = 0;
 	sl->flags   &= (1 << SLF_INUSE);      /* Clear ESCAPE & ERROR flags */
 
-	netif_start_queue(dev);
-
-	/*
-	 *	Now attach LAPB
-	 */
-	err = lapb_register(dev, &x25_asy_callbacks);
-	if (err == LAPB_OK)
-		return 0;
+	return 0;
 
 	/* Cleanup */
 	kfree(sl->xbuff);
@@ -511,7 +503,6 @@ static int x25_asy_close(struct net_device *dev)
 	if (sl->tty)
 		clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
 
-	netif_stop_queue(dev);
 	sl->rcount = 0;
 	sl->xleft  = 0;
 	spin_unlock(&sl->lock);
@@ -596,7 +587,6 @@ static int x25_asy_open_tty(struct tty_struct *tty)
 static void x25_asy_close_tty(struct tty_struct *tty)
 {
 	struct x25_asy *sl = tty->disc_data;
-	int err;
 
 	/* First make sure we're connected. */
 	if (!sl || sl->magic != X25_ASY_MAGIC)
@@ -607,11 +597,6 @@ static void x25_asy_close_tty(struct tty_struct *tty)
 		dev_close(sl->dev);
 	rtnl_unlock();
 
-	err = lapb_unregister(sl->dev);
-	if (err != LAPB_OK)
-		pr_err("%s: lapb_unregister error: %d\n",
-		       __func__, err);
-
 	tty->disc_data = NULL;
 	sl->tty = NULL;
 	x25_asy_free(sl);
@@ -714,15 +699,39 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
 
 static int x25_asy_open_dev(struct net_device *dev)
 {
+	int err;
 	struct x25_asy *sl = netdev_priv(dev);
 	if (sl->tty == NULL)
 		return -ENODEV;
+
+	err = lapb_register(dev, &x25_asy_callbacks);
+	if (err != LAPB_OK)
+		return -ENOMEM;
+
+	netif_start_queue(dev);
+
+	return 0;
+}
+
+static int x25_asy_close_dev(struct net_device *dev)
+{
+	int err;
+
+	netif_stop_queue(dev);
+
+	err = lapb_unregister(dev);
+	if (err != LAPB_OK)
+		pr_err("%s: lapb_unregister error: %d\n",
+		       __func__, err);
+
+	x25_asy_close(dev);
+
 	return 0;
 }
 
 static const struct net_device_ops x25_asy_netdev_ops = {
 	.ndo_open	= x25_asy_open_dev,
-	.ndo_stop	= x25_asy_close,
+	.ndo_stop	= x25_asy_close_dev,
 	.ndo_start_xmit	= x25_asy_xmit,
 	.ndo_tx_timeout	= x25_asy_timeout,
 	.ndo_change_mtu	= x25_asy_change_mtu,
-- 
2.25.1


  parent reply	other threads:[~2020-10-12 19:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 19:02 [PATCH AUTOSEL 5.8 01/24] net: lantiq: Add locking for TX DMA channel Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 02/24] platform/x86: touchscreen_dmi: Add info for the MPMAN Converter9 2-in-1 Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 03/24] platform/x86: asus-nb-wmi: Revert "Do not load on Asus T100TA and T200TA" Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 04/24] platform/x86: asus-wmi: Add BATC battery name to the list of supported Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 05/24] platform/x86: mlx-platform: Fix extended topology configuration for power supply units Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 06/24] mt76: mt7615: reduce maximum VHT MPDU length to 7991 Sasha Levin
2020-10-12 19:02   ` Sasha Levin
2020-10-12 19:02   ` Sasha Levin
2020-10-12 19:02 ` Sasha Levin [this message]
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 08/24] net: mscc: ocelot: fix fields offset in SG_CONFIG_REG_3 Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 09/24] net/fsl: quieten expected MDIO access failures Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 10/24] net: usb: ax88179_178a: add Toshiba usb 3.0 adapter Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 11/24] net: atlantic: fix build when object tree is separate Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 12/24] net: usb: ax88179_178a: add MCT usb 3.0 adapter Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 13/24] net: dsa: felix: fix incorrect action offsets for VCAP IS2 Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 14/24] via-rhine: Fix for the hardware having a reset failure after resume Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 15/24] via-rhine: VTunknown1 device is really VT8251 South Bridge Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 16/24] vhost vdpa: fix vhost_vdpa_open error handling Sasha Levin
2020-10-12 19:02   ` Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 17/24] net: usb: pegasus: Proper error handing when setting pegasus' MAC address Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 18/24] net: usb: rtl8150: set random MAC address when set_ethernet_addr() fails Sasha Levin
2020-10-12 19:11   ` Joe Perches
2020-10-12 21:01     ` Petko Manolov
2020-10-14 14:04       ` Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 19/24] usermodehelper: reset umask to default before executing user process Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 20/24] riscv: Fixup bootup failure with HARDENED_USERCOPY Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 21/24] arm/arm64: xen: Fix to convert percpu address to gfn correctly Sasha Levin
2020-10-12 19:02   ` Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 22/24] exfat: fix pointer error checking Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 23/24] gpio: pca953x: Survive spurious interrupts Sasha Levin
2020-10-12 19:02 ` [PATCH AUTOSEL 5.8 24/24] net: usb: qmi_wwan: add Cellient MPL200 card Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201012190239.3279198-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ms@dev.tdt.de \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xie.he.0141@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.