mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Wahren <wahrenst@gmx.net>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stefan Wahren <wahrenst@gmx.net>,
	Jacob Keller <jacob.e.keller@intel.com>
Subject: [PATCH V4 03/15 net-next] qca_spi: Improve SPI IRQ handling
Date: Sun, 28 Jan 2024 21:10:47 +0100	[thread overview]
Message-ID: <20240128201059.6259-4-wahrenst@gmx.net> (raw)
In-Reply-To: <20240128201059.6259-1-wahrenst@gmx.net>

The functions qcaspi_netdev_open/close are responsible of request &
free of the SPI interrupt, which wasn't the best choice because
allocation problems are discovered not during probe. So let us split
IRQ allocation & enabling, so we can take advantage of a device
managed IRQ.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index fe50c2dd7cc8..3f7e38a11ba0 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -688,7 +688,6 @@ qcaspi_netdev_open(struct net_device *dev)
 {
 	struct qcaspi *qca = netdev_priv(dev);
 	struct task_struct *thread;
-	int ret = 0;

 	if (!qca)
 		return -EINVAL;
@@ -709,14 +708,7 @@ qcaspi_netdev_open(struct net_device *dev)

 	qca->spi_thread = thread;

-	ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0,
-			  dev->name, qca);
-	if (ret) {
-		netdev_err(dev, "%s: unable to get IRQ %d (irqval=%d).\n",
-			   QCASPI_DRV_NAME, qca->spi_dev->irq, ret);
-		kthread_stop(qca->spi_thread);
-		return ret;
-	}
+	enable_irq(qca->spi_dev->irq);

 	/* SPI thread takes care of TX queue */

@@ -731,7 +723,7 @@ qcaspi_netdev_close(struct net_device *dev)
 	netif_stop_queue(dev);

 	qcaspi_write_register(qca, SPI_REG_INTR_ENABLE, 0, wr_verify);
-	free_irq(qca->spi_dev->irq, qca);
+	disable_irq(qca->spi_dev->irq);

 	if (qca->spi_thread) {
 		kthread_stop(qca->spi_thread);
@@ -989,6 +981,15 @@ qca_spi_probe(struct spi_device *spi)

 	spi_set_drvdata(spi, qcaspi_devs);

+	ret = devm_request_irq(&spi->dev, spi->irq, qcaspi_intr_handler,
+			       IRQF_NO_AUTOEN, qca->net_dev->name, qca);
+	if (ret) {
+		dev_err(&spi->dev, "Unable to get IRQ %d (irqval=%d).\n",
+			spi->irq, ret);
+		free_netdev(qcaspi_devs);
+		return ret;
+	}
+
 	ret = of_get_ethdev_address(spi->dev.of_node, qca->net_dev);
 	if (ret) {
 		eth_hw_addr_random(qca->net_dev);
--
2.34.1


  parent reply	other threads:[~2024-01-28 20:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-28 20:10 [PATCH V4 00/15 net-next] qca_spi: collection of improvements Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 01/15 net-next] qca_spi: Add check for kthread_stop Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 02/15 net-next] qca_spi: Improve SPI thread creation Stefan Wahren
2024-01-28 20:10 ` Stefan Wahren [this message]
2024-01-28 20:10 ` [PATCH V4 04/15 net-next] qca_spi: Avoid skb_copy_expand in TX path Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 05/15 net-next] qca_7k_common: Drop unnecessary function description Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 06/15 net-next] qca_7k_common: Drop unused len from qcafrm_handle Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 07/15 net-next] qca_spi: Add QCASPI prefix to ring defines Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 08/15 net-next] qca_spi: Introduce QCASPI_RX_MAX_FRAMES Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 09/15 net-next] qca_spi: Improve calculation of RX buffer size Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 10/15 net-next] qca_spi: Log expected signature in error case Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 11/15 net-next] qca_spi: Adjust log of SPI_REG_RDBUF_BYTE_AVA Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 12/15 net-next] qca_7k: Replace BSD boilerplate with SPDX Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 13/15 net-next] qca_7k: Replace old mail address Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 14/15 net-next] mailmap: add entry for Stefan Wahren Stefan Wahren
2024-01-28 20:10 ` [PATCH V4 15/15 net-next] MAINTAINERS: add entry for qca7k driver(s) Stefan Wahren
2024-01-31 13:40 ` [PATCH V4 00/15 net-next] qca_spi: collection of improvements patchwork-bot+netdevbpf

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=20240128201059.6259-4-wahrenst@gmx.net \
    --to=wahrenst@gmx.net \
    --cc=LinoSanfilippo@gmx.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®