All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: "David S. Miller" <davem@davemloft.net>,
	Tristram Ha <Tristram.Ha@microchip.com>,
	netdev@vger.kernel.org
Cc: Frank Pavlic <f.pavlic@kunbus.de>,
	Eduard Mainhardt <e.mainhardt@kunbus.de>,
	Ben Dooks <ben.dooks@codethink.co.uk>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Sergey Shcherbakov <shchers@gmail.com>,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Subject: [PATCH 3/6] net: ks8851: Delay requesting IRQ until opened
Date: Wed, 20 Mar 2019 15:02:00 +0100	[thread overview]
Message-ID: <cf9c7846c5790170d50c4d18f94be69215721eb7.1553089248.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1553089248.git.lukas@wunner.de>

The ks8851 driver currently requests the IRQ before registering the
net_device.  Because the net_device name is used as IRQ name and is
still "eth%d" when the IRQ is requested, it's impossibe to tell IRQs
apart if multiple ks8851 chips are present.  Most other drivers delay
requesting the IRQ until the net_device is opened.  Do the same.

The driver doesn't enable interrupts on the chip before opening the
net_device and disables them when closing it, so there doesn't seem to
be a need to request the IRQ already on probe.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
---
 drivers/net/ethernet/micrel/ks8851.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 1633fa5c709c..c9faec4c5b25 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -785,6 +785,15 @@ static void ks8851_tx_work(struct work_struct *work)
 static int ks8851_net_open(struct net_device *dev)
 {
 	struct ks8851_net *ks = netdev_priv(dev);
+	int ret;
+
+	ret = request_threaded_irq(dev->irq, NULL, ks8851_irq,
+				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+				   dev->name, ks);
+	if (ret < 0) {
+		netdev_err(dev, "failed to get irq\n");
+		return ret;
+	}
 
 	/* lock the card, even if we may not actually be doing anything
 	 * else at the moment */
@@ -899,6 +908,8 @@ static int ks8851_net_stop(struct net_device *dev)
 		dev_kfree_skb(txb);
 	}
 
+	free_irq(dev->irq, ks);
+
 	return 0;
 }
 
@@ -1529,14 +1540,6 @@ static int ks8851_probe(struct spi_device *spi)
 	ks8851_read_selftest(ks);
 	ks8851_init_mac(ks);
 
-	ret = request_threaded_irq(spi->irq, NULL, ks8851_irq,
-				   IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-				   ndev->name, ks);
-	if (ret < 0) {
-		dev_err(&spi->dev, "failed to get irq\n");
-		goto err_irq;
-	}
-
 	ret = register_netdev(ndev);
 	if (ret) {
 		dev_err(&spi->dev, "failed to register network device\n");
@@ -1549,11 +1552,7 @@ static int ks8851_probe(struct spi_device *spi)
 
 	return 0;
 
-
 err_netdev:
-	free_irq(ndev->irq, ks);
-
-err_irq:
 err_id:
 	if (gpio_is_valid(gpio))
 		gpio_set_value(gpio, 0);
@@ -1574,7 +1573,6 @@ static int ks8851_remove(struct spi_device *spi)
 		dev_info(&spi->dev, "remove\n");
 
 	unregister_netdev(priv->netdev);
-	free_irq(spi->irq, priv);
 	if (gpio_is_valid(priv->gpio))
 		gpio_set_value(priv->gpio, 0);
 	regulator_disable(priv->vdd_reg);
-- 
2.20.1


  parent reply	other threads:[~2019-03-20 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 14:02 [PATCH 0/6] ks8851 fixes & cleanups Lukas Wunner
2019-03-20 14:02 ` [PATCH 2/6] net: ks8851: Reassert reset pin if chip ID check fails Lukas Wunner
2019-03-20 14:02 ` [PATCH 6/6] net: ks8851: Deduplicate register macros Lukas Wunner
2019-03-20 14:02 ` [PATCH 4/6] net: ks8851: Set initial carrier state to down Lukas Wunner
2019-03-20 14:02 ` [PATCH 1/6] net: ks8851: Dequeue RX packets explicitly Lukas Wunner
2019-03-20 14:02 ` [PATCH 5/6] net: ks8851: Fix register macro misnomers Lukas Wunner
2019-03-20 14:02 ` Lukas Wunner [this message]
2019-03-20 17:26 ` [PATCH 0/6] ks8851 fixes & cleanups Ben Dooks
2019-03-20 19:44 ` David Miller

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=cf9c7846c5790170d50c4d18f94be69215721eb7.1553089248.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=Tristram.Ha@microchip.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=e.mainhardt@kunbus.de \
    --cc=f.pavlic@kunbus.de \
    --cc=netdev@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=sboyd@codeaurora.org \
    --cc=shchers@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.