On Wed, 2020-05-06 at 22:16 +0300, Leon Romanovsky wrote: > On Tue, May 5, 2020 at 5:03 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> > > > > This adds the driver for the MediaTek Ethernet MAC used on the MT8* SoC > > family. For now we only support full-duplex. [] > > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_mac.c b/drivers/net/ethernet/mediatek/mtk_eth_mac.c [] > > +struct mtk_mac_priv { > > + struct regmap *regs; > > + struct regmap *pericfg; > > + > > + struct clk_bulk_data clks[MTK_MAC_NCLKS]; > > + > > + void *ring_base; > > + struct mtk_mac_ring_desc *descs_base; > > + dma_addr_t dma_addr; > > + struct mtk_mac_ring tx_ring; > > + struct mtk_mac_ring rx_ring; > > + struct work_struct tx_work; > > + > > + struct mii_bus *mii; > > + struct napi_struct napi; > > + > > + struct device_node *phy_node; > > + phy_interface_t phy_intf; > > + struct phy_device *phydev; > > + unsigned int link; > > + int speed; > > + int duplex; > > + > > + /* Protects against concurrent descriptor access. */ > > + spinlock_t lock; > > + unsigned long lock_flags; > > + > > + struct rtnl_link_stats64 stats; > > +}; > > + > > +static struct net_device *mtk_mac_get_netdev(struct mtk_mac_priv *priv) > > +{ > > + char *ptr = (char *)priv; > > + > > + return (struct net_device *)(ptr - ALIGN(sizeof(struct net_device), > > + NETDEV_ALIGN)); > > +} This code looks ugly/fragile. Why not store the struct net_device * in struct mtk_mac_priv ?