From: Andrew Lunn <andrew@lunn.ch>
To: Jijie Shao <shaojijie@huawei.com>
Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, shenjian15@huawei.com,
wangpeiyang1@huawei.com, liuyonglong@huawei.com,
sudongming1@huawei.com, xujunsheng@huawei.com,
shiyongbang@huawei.com, jdamato@fastly.com,
jonathan.cameron@huawei.com,
shameerali.kolothum.thodi@huawei.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH V2 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module
Date: Fri, 16 Aug 2024 04:25:39 +0200 [thread overview]
Message-ID: <79122634-093b-44a3-bbcd-479d6692affc@lunn.ch> (raw)
In-Reply-To: <20240813135640.1694993-4-shaojijie@huawei.com>
> +static int hbg_mdio_cmd_send(struct hbg_mac *mac, u32 prt_addr, u32 dev_addr,
> + u32 type, u32 op_code)
> +{
> + struct hbg_mdio_command mdio_cmd;
> +
> + hbg_mdio_get_command(mac, &mdio_cmd);
> + mdio_cmd.mdio_st = type;
> + /* if auto scan enabled, this value need fix to 0 */
> + mdio_cmd.mdio_start = 0x1;
> + mdio_cmd.mdio_op = op_code;
> + mdio_cmd.mdio_prtad = prt_addr;
> + mdio_cmd.mdio_devad = dev_addr;
> + hbg_mdio_set_command(mac, &mdio_cmd);
> +
> + /* wait operation complete and check the result */
> + return hbg_mdio_check_send_result(mac);
> +struct hbg_mdio_command {
> + union {
> + struct {
> + u32 mdio_devad : 5;
> + u32 mdio_prtad :5;
> + u32 mdio_op : 2;
> + u32 mdio_st : 2;
> + u32 mdio_start : 1;
> + u32 mdio_clk_sel : 1;
> + u32 mdio_auto_scan : 1;
> + u32 mdio_clk_sel_exp : 1;
> + u32 rev : 14;
> + };
> + u32 bits;
> + };
> +};
This is generally not the way to do this. Please look at the macros in
include/linux/bitfield.h. FIELD_PREP, GENMASK, BIT, FIELD_GET
etc. These are guaranteed to work for both big and little endian, and
you avoid issues where the compiler decides to add padding in your
bitfields.
Andrew
next prev parent reply other threads:[~2024-08-16 2:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 13:56 [RFC PATCH V2 net-next 00/11] Add support of HIBMCGE Ethernet Driver Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 01/11] net: hibmcge: Add pci table supported in this module Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 02/11] net: hibmcge: Add read/write registers supported through the bar space Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 03/11] net: hibmcge: Add mdio and hardware configuration supported in this module Jijie Shao
2024-08-16 2:14 ` Andrew Lunn
2024-08-16 3:07 ` Jijie Shao
2024-08-16 2:25 ` Andrew Lunn [this message]
2024-08-16 6:10 ` Jijie Shao
2024-08-16 21:04 ` Andrew Lunn
2024-08-17 1:11 ` Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 04/11] net: hibmcge: Add interrupt " Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 05/11] net: hibmcge: Implement some .ndo functions Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 06/11] net: hibmcge: Implement .ndo_start_xmit function Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 07/11] net: hibmcge: Implement rx_poll function to receive packets Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 08/11] net: hibmcge: Implement some ethtool_ops functions Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 09/11] net: hibmcge: Add a Makefile and update Kconfig for hibmcge Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 10/11] net: hibmcge: Add maintainer " Jijie Shao
2024-08-13 13:56 ` [RFC PATCH V2 net-next 11/11] net: add is_valid_ether_addr check in dev_set_mac_address Jijie Shao
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=79122634-093b-44a3-bbcd-479d6692affc@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=jonathan.cameron@huawei.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=shiyongbang@huawei.com \
--cc=sudongming1@huawei.com \
--cc=wangpeiyang1@huawei.com \
--cc=xujunsheng@huawei.com \
--cc=yisen.zhuang@huawei.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®