lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <79122634-093b-44a3-bbcd-479d6692affc@lunn.ch>
Date: Fri, 16 Aug 2024 04:25:39 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Jijie Shao <shaojijie@...wei.com>
Cc: yisen.zhuang@...wei.com, salil.mehta@...wei.com, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	horms@...nel.org, shenjian15@...wei.com, wangpeiyang1@...wei.com,
	liuyonglong@...wei.com, sudongming1@...wei.com,
	xujunsheng@...wei.com, shiyongbang@...wei.com, jdamato@...tly.com,
	jonathan.cameron@...wei.com, shameerali.kolothum.thodi@...wei.com,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH V2 net-next 03/11] net: hibmcge: Add mdio and
 hardware configuration supported in this module

> +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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ