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>
Subject: [PATCH V4 02/15 net-next] qca_spi: Improve SPI thread creation
Date: Sun, 28 Jan 2024 21:10:46 +0100	[thread overview]
Message-ID: <20240128201059.6259-3-wahrenst@gmx.net> (raw)
In-Reply-To: <20240128201059.6259-1-wahrenst@gmx.net>

Directly storing the result of kthread_run within the private
driver data makes it harder to identify if the pointer has a
running thread or not. So better use a local variable for
the result check and we don't have to care about error pointer
in the rest of the code.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/net/ethernet/qualcomm/qca_spi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

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

 	if (!qca)
@@ -697,15 +698,17 @@ qcaspi_netdev_open(struct net_device *dev)
 	qca->sync = QCASPI_SYNC_UNKNOWN;
 	qcafrm_fsm_init_spi(&qca->frm_handle);

-	qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
-				      qca, "%s", dev->name);
+	thread = kthread_run((void *)qcaspi_spi_thread,
+			     qca, "%s", dev->name);

-	if (IS_ERR(qca->spi_thread)) {
+	if (IS_ERR(thread)) {
 		netdev_err(dev, "%s: unable to start kernel thread.\n",
 			   QCASPI_DRV_NAME);
-		return PTR_ERR(qca->spi_thread);
+		return PTR_ERR(thread);
 	}

+	qca->spi_thread = thread;
+
 	ret = request_irq(qca->spi_dev->irq, qcaspi_intr_handler, 0,
 			  dev->name, qca);
 	if (ret) {
--
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 ` Stefan Wahren [this message]
2024-01-28 20:10 ` [PATCH V4 03/15 net-next] qca_spi: Improve SPI IRQ handling Stefan Wahren
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-3-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=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®