From: Leon Romanovsky <leon@kernel.org>
To: Jeroen de Borst <jeroendb@google.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
jesse.brandeburg@intel.com
Subject: Re: [PATCH net-next v5 1/2] gve: Adding a new AdminQ command to verify driver
Date: Sun, 20 Nov 2022 21:40:12 +0200 [thread overview]
Message-ID: <Y3qCnJi2D/WOK0BG@unreal> (raw)
In-Reply-To: <20221117162701.2356849-2-jeroendb@google.com>
On Thu, Nov 17, 2022 at 08:27:00AM -0800, Jeroen de Borst wrote:
> Check whether the driver is compatible with the device
> presented.
>
> Signed-off-by: Jeroen de Borst <jeroendb@google.com>
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> ---
> drivers/net/ethernet/google/gve/gve.h | 1 +
> drivers/net/ethernet/google/gve/gve_adminq.c | 21 +++++++-
> drivers/net/ethernet/google/gve/gve_adminq.h | 49 ++++++++++++++++++
> drivers/net/ethernet/google/gve/gve_main.c | 52 ++++++++++++++++++++
> 4 files changed, 122 insertions(+), 1 deletion(-)
<...>
> +enum gve_driver_capbility {
> + gve_driver_capability_gqi_qpl = 0,
> + gve_driver_capability_gqi_rda = 1,
> + gve_driver_capability_dqo_qpl = 2, /* reserved for future use */
> + gve_driver_capability_dqo_rda = 3,
> +};
> +
> +#define GVE_CAP1(a) BIT((int)a)
> +#define GVE_CAP2(a) BIT(((int)a) - 64)
> +#define GVE_CAP3(a) BIT(((int)a) - 128)
> +#define GVE_CAP4(a) BIT(((int)a) - 192)
> +
> +#define GVE_DRIVER_CAPABILITY_FLAGS1 \
> + (GVE_CAP1(gve_driver_capability_gqi_qpl) | \
> + GVE_CAP1(gve_driver_capability_gqi_rda) | \
> + GVE_CAP1(gve_driver_capability_dqo_rda))
I never understood it why people do it.
You created named enum gve_driver_capbility, but nothing in the code
uses this name and you use the values as bits, which later you cast them
to int.
It will be much saner, if you use anonymous enum, which is int in
C-world and you won't need any (int) casting when you call to BIT().
BTW, you don't need this casting anyway and it will be much better if you
use >> for bit operations and not "- 64|128|192".
Thanks
next prev parent reply other threads:[~2022-11-20 19:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 16:26 [PATCH net-next v5 0/2] Handle alternate miss-completions Jeroen de Borst
2022-11-17 16:27 ` [PATCH net-next v5 1/2] gve: Adding a new AdminQ command to verify driver Jeroen de Borst
2022-11-20 19:40 ` Leon Romanovsky [this message]
2022-11-17 16:27 ` [PATCH net-next v5 2/2] gve: Handle alternate miss completions Jeroen de Borst
2022-11-21 11:00 ` [PATCH net-next v5 0/2] Handle alternate miss-completions 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=Y3qCnJi2D/WOK0BG@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=jeroendb@google.com \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).