[OpenWrt-Devel] [PATCH 1/3] b53: add b53_mac_array_to_u64() utility function
Jonas Gorski
jogo at openwrt.org
Fri Feb 27 13:36:06 EST 2015
Hi,
On Mon, Feb 23, 2015 at 3:41 PM, Alexandru Ardelean
<ardeleanalex at gmail.com> wrote:
> From: Alexandru Ardelean <ardeleanalex at gmail.com>
>
> Converts an MAC array of u8 to a u64 value.
>
> Signed-off-by: Alexandru Ardelean <ardeleanalex at gmail.com>
> ---
> target/linux/generic/files/drivers/net/phy/b53/b53_regs.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h b/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
> index ba50915..4379c58 100644
> --- a/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
> +++ b/target/linux/generic/files/drivers/net/phy/b53/b53_regs.h
> @@ -20,6 +20,16 @@
> #ifndef __B53_REGS_H
> #define __B53_REGS_H
>
> +/* Utility function for converting u8 arrays into u64 values to be written with b53_write */
You only use this in b53_common.c, so why not just have it in there?
And maybe merge it into the patch atually adding a user.
> +static inline u64 b53_mac_array_to_u64(const u8 *u8_arr) {
> + u64 mac = (*(const u64 *)u8_arr);
Also this will likely produce alignment issues on e.g. mips, which
doesn't allow unaligned accesses.
> +#ifdef __BIG_ENDIAN
> + return (mac >> 16);
> +#else
> + return (mac << 16);
> +#endif
> +}
> +
> /* Management Port (SMP) Page offsets */
> #define B53_CTRL_PAGE 0x00 /* Control */
> #define B53_STAT_PAGE 0x01 /* Status */
> --
Jonas
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list