From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Ming Yu <a0282524688@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-can@vger.kernel.org,
netdev@vger.kernel.org, linux-watchdog@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-usb@vger.kernel.org, tmyu0@nuvoton.com, lee@kernel.org,
linus.walleij@linaro.org, brgl@bgdev.pl, andi.shyti@kernel.org,
mkl@pengutronix.de, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
wim@linux-watchdog.org, linux@roeck-us.net, jdelvare@suse.com,
alexandre.belloni@bootlin.com
Subject: Re: [PATCH v5 4/7] can: Add Nuvoton NCT6694 CAN support
Date: Thu, 16 Jan 2025 01:45:02 +0900 [thread overview]
Message-ID: <cef1b9bf-59f6-484d-861e-82b405653ca1@wanadoo.fr> (raw)
In-Reply-To: <20250114033010.2445925-5-a0282524688@gmail.com>
On 14/01/2025 at 12:30, Ming Yu wrote:
(...)
> +static void nct6694_can_clean(struct net_device *ndev)
> +{
> + struct nct6694_can_priv *priv = netdev_priv(ndev);
> +
> + if (priv->tx_skb || netif_queue_stopped(ndev))
> + ndev->stats.tx_errors++;
> + dev_kfree_skb(priv->tx_skb);
Use:
can_flush_echo_skb(ndev);
(related to the following comments).
> + priv->tx_skb = NULL;
> +}
(...)
> +static void nct6694_can_tx_work(struct work_struct *work)
> +{
> + struct nct6694_can_priv *priv = container_of(work,
> + struct nct6694_can_priv,
> + tx_work);
> + struct net_device *ndev = priv->ndev;
> +
> + guard(mutex)(&priv->lock);
> +
> + if (priv->tx_skb) {
> + if (priv->can.state == CAN_STATE_BUS_OFF) {
Just stop the queue when the can bus is off so that you do not have do
check the bus status each time a frame is sent.
> + nct6694_can_clean(ndev);
> + } else {
> + nct6694_can_tx(ndev);
> + can_put_echo_skb(priv->tx_skb, ndev, 0, 0);
> + priv->tx_skb = NULL;
> + }
> + }
> +}
> +
> +static netdev_tx_t nct6694_can_start_xmit(struct sk_buff *skb,
> + struct net_device *ndev)
> +{
> + struct nct6694_can_priv *priv = netdev_priv(ndev);
> +
> + if (can_dev_dropped_skb(ndev, skb))
> + return NETDEV_TX_OK;
> +
> + if (priv->tx_skb) {
> + netdev_err(ndev, "hard_xmit called while tx busy\n");
> + return NETDEV_TX_BUSY;
> + }
> +
> + netif_stop_queue(ndev);
> + priv->tx_skb = skb;
Here, you can directly do:
can_put_echo_skb(skb, ndev, 0, 0);
The skb remains accessible under priv->can.echo_skb[0]. With this, you
can remove the priv->tx_skb field.
> + queue_work(priv->wq, &priv->tx_work);
> +
> + return NETDEV_TX_OK;
> +}
Yours sincerely,
Vincent Mailhol
next prev parent reply other threads:[~2025-01-15 16:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 3:30 [PATCH v5 0/7] Add Nuvoton NCT6694 MFD drivers Ming Yu
2025-01-14 3:30 ` [PATCH v5 1/7] mfd: Add core driver for Nuvoton NCT6694 Ming Yu
2025-01-15 16:04 ` Lee Jones
2025-01-16 2:28 ` Ming Yu
2025-01-14 3:30 ` [PATCH v5 2/7] gpio: Add Nuvoton NCT6694 GPIO support Ming Yu
2025-01-14 12:12 ` Bartosz Golaszewski
2025-01-15 7:05 ` Ming Yu
2025-01-14 3:30 ` [PATCH v5 3/7] i2c: Add Nuvoton NCT6694 I2C support Ming Yu
2025-01-14 3:30 ` [PATCH v5 4/7] can: Add Nuvoton NCT6694 CAN support Ming Yu
2025-01-14 8:05 ` Vincent Mailhol
2025-01-14 10:46 ` Ming Yu
2025-01-14 15:11 ` Vincent Mailhol
2025-01-15 2:11 ` Ming Yu
2025-01-15 3:36 ` Vincent Mailhol
2025-01-15 5:35 ` Ming Yu
2025-01-15 6:43 ` Vincent Mailhol
2025-01-15 7:03 ` Ming Yu
2025-01-15 16:45 ` Vincent Mailhol [this message]
2025-01-16 6:34 ` Ming Yu
2025-01-16 11:23 ` Vincent Mailhol
2025-01-14 3:30 ` [PATCH v5 5/7] watchdog: Add Nuvoton NCT6694 WDT support Ming Yu
2025-01-14 3:30 ` [PATCH v5 6/7] hwmon: Add Nuvoton NCT6694 HWMON support Ming Yu
2025-01-14 3:30 ` [PATCH v5 7/7] rtc: Add Nuvoton NCT6694 RTC support Ming Yu
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=cef1b9bf-59f6-484d-861e-82b405653ca1@wanadoo.fr \
--to=mailhol.vincent@wanadoo.fr \
--cc=a0282524688@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andi.shyti@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=brgl@bgdev.pl \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jdelvare@suse.com \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tmyu0@nuvoton.com \
--cc=wim@linux-watchdog.org \
/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