From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Martyn Welch <martyn.welch@collabora.com>
Cc: Claudiu Manoil <claudiu.manoil@nxp.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
kernel@collabora.com, Vadim Fedorenko <vadim.fedorenko@linux.dev>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] net: enetc: Replace ifdef with IS_ENABLED
Date: Wed, 4 Sep 2024 01:44:46 +0300 [thread overview]
Message-ID: <20240903224446.mp55dvria3rrtope@skbuf> (raw)
In-Reply-To: <20240903140420.2150707-1-martyn.welch@collabora.com> <20240903140420.2150707-1-martyn.welch@collabora.com>
Hi Martyn,
On Tue, Sep 03, 2024 at 03:04:18PM +0100, Martyn Welch wrote:
> The enetc driver uses ifdefs when checking whether
> CONFIG_FSL_ENETC_PTP_CLOCK is enabled in a number of places. This works
> if the driver is compiled in but fails if the driver is available as a
> kernel module. Replace the instances of ifdef with use of the IS_ENABLED
> macro, that will evaluate as true when this feature is built as a kernel
> module and follows the kernel's coding style.
>
> Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
> ---
>
> Changes since v1:
> - Switched from preprocessor conditionals to normal C conditionals.
Thanks for the patch. Can you please send a v3 rebased on the latest
net-next, which now contains commit 3dd261ca7f84 ("net: enetc: Remove
setting of RX software timestamp")? The change needs rethinking a bit.
Also, could you git format-patch --subject-prefix="PATCH net-next v3"
next time? The networking subsystem tends to require that from patch
submitters, to indicate the tree that the patch should be applied to.
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> index 5e684b23c5f5..a9402c1907bf 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> @@ -853,24 +853,25 @@ static int enetc_get_ts_info(struct net_device *ndev,
> info->phc_index = -1;
> }
>
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> - info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
> - SOF_TIMESTAMPING_RX_HARDWARE |
> - SOF_TIMESTAMPING_RAW_HARDWARE |
> - SOF_TIMESTAMPING_TX_SOFTWARE |
> - SOF_TIMESTAMPING_RX_SOFTWARE |
> - SOF_TIMESTAMPING_SOFTWARE;
> -
> - info->tx_types = (1 << HWTSTAMP_TX_OFF) |
> - (1 << HWTSTAMP_TX_ON) |
> - (1 << HWTSTAMP_TX_ONESTEP_SYNC);
> - info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
> - (1 << HWTSTAMP_FILTER_ALL);
> -#else
> - info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
> - SOF_TIMESTAMPING_TX_SOFTWARE |
> - SOF_TIMESTAMPING_SOFTWARE;
> -#endif
> + if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
> + info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
> + SOF_TIMESTAMPING_RX_HARDWARE |
> + SOF_TIMESTAMPING_RAW_HARDWARE |
> + SOF_TIMESTAMPING_TX_SOFTWARE |
> + SOF_TIMESTAMPING_RX_SOFTWARE |
> + SOF_TIMESTAMPING_SOFTWARE;
> +
> + info->tx_types = (1 << HWTSTAMP_TX_OFF) |
> + (1 << HWTSTAMP_TX_ON) |
> + (1 << HWTSTAMP_TX_ONESTEP_SYNC);
> + info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
> + (1 << HWTSTAMP_FILTER_ALL);
> + } else {
> + info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
> + SOF_TIMESTAMPING_TX_SOFTWARE |
> + SOF_TIMESTAMPING_SOFTWARE;
> + }
> +
How about:
if (!IS_ENABLED()) {
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE;
return 0;
}
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE |
SOF_TIMESTAMPING_TX_SOFTWARE;
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
(1 << HWTSTAMP_TX_ON) |
(1 << HWTSTAMP_TX_ONESTEP_SYNC);
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
(1 << HWTSTAMP_FILTER_ALL);
return 0;
?
I think I prefer the style with the early return.
> return 0;
> }
>
> --
> 2.45.2
next prev parent reply other threads:[~2024-09-03 22:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 14:04 [PATCH v2] net: enetc: Replace ifdef with IS_ENABLED Martyn Welch
2024-09-03 14:39 ` Vadim Fedorenko
2024-09-03 22:44 ` Vladimir Oltean [this message]
2024-09-04 8:59 ` Martyn Welch
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=20240903224446.mp55dvria3rrtope@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel@collabora.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martyn.welch@collabora.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
/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