Skip to content

Commit 8c58813

Browse files
committed
net: macb: store macb_config in struct macb
Store macb_config in struct macb. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
1 parent cac2ca9 commit 8c58813

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

drivers/net/ethernet/cadence/macb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,6 @@ struct macb {
11771177
int duplex;
11781178

11791179
u32 caps;
1180-
unsigned int dma_burst_length;
11811180

11821181
phy_interface_t phy_interface;
11831182

@@ -1190,7 +1189,6 @@ struct macb {
11901189
u64 ethtool_stats[GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES];
11911190

11921191
unsigned int rx_frm_len_mask;
1193-
unsigned int jumbo_max_len;
11941192

11951193
u32 wol;
11961194

@@ -1214,6 +1212,8 @@ struct macb {
12141212

12151213
int rx_bd_rd_prefetch;
12161214
int tx_bd_rd_prefetch;
1215+
1216+
const struct macb_config *config;
12171217
};
12181218

12191219
#ifdef CONFIG_MACB_USE_HWSTAMP

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,8 +2144,9 @@ static void macb_configure_dma(struct macb *bp)
21442144
else
21452145
dmacfg |= GEM_BF(RXBS, buffer_size);
21462146
}
2147-
if (bp->dma_burst_length)
2148-
dmacfg = GEM_BFINS(FBLDO, bp->dma_burst_length, dmacfg);
2147+
if (bp->config->dma_burst_length)
2148+
dmacfg = GEM_BFINS(FBLDO, bp->config->dma_burst_length,
2149+
dmacfg);
21492150
dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
21502151
dmacfg &= ~GEM_BIT(ENDIA_PKT);
21512152

@@ -2201,8 +2202,8 @@ static void macb_init_hw(struct macb *bp)
22012202
config |= MACB_BIT(NBC); /* No BroadCast */
22022203
config |= macb_dbw(bp);
22032204
macb_writel(bp, NCFGR, config);
2204-
if ((bp->caps & MACB_CAPS_JUMBO) && bp->jumbo_max_len)
2205-
gem_writel(bp, JML, bp->jumbo_max_len);
2205+
if ((bp->caps & MACB_CAPS_JUMBO) && bp->config->jumbo_max_len)
2206+
gem_writel(bp, JML, bp->config->jumbo_max_len);
22062207
bp->speed = SPEED_10;
22072208
bp->duplex = DUPLEX_HALF;
22082209
bp->rx_frm_len_mask = MACB_RX_FRMLEN_MASK;
@@ -3208,13 +3209,12 @@ static const struct net_device_ops macb_netdev_ops = {
32083209
/* Configure peripheral capabilities according to device tree
32093210
* and integration options used
32103211
*/
3211-
static void macb_configure_caps(struct macb *bp,
3212-
const struct macb_config *dt_conf)
3212+
static void macb_configure_caps(struct macb *bp)
32133213
{
32143214
u32 dcfg;
32153215

3216-
if (dt_conf)
3217-
bp->caps = dt_conf->caps;
3216+
if (bp->config)
3217+
bp->caps = bp->config->caps;
32183218

32193219
if (hw_is_gem(bp->regs, bp->native_io)) {
32203220
bp->caps |= MACB_CAPS_MACB_IS_GEM;
@@ -3926,10 +3926,6 @@ static const struct macb_config default_gem_config = {
39263926
static int macb_probe(struct platform_device *pdev)
39273927
{
39283928
const struct macb_config *macb_config = &default_gem_config;
3929-
int (*clk_init)(struct platform_device *, struct clk **,
3930-
struct clk **, struct clk **, struct clk **)
3931-
= macb_config->clk_init;
3932-
int (*init)(struct platform_device *) = macb_config->init;
39333929
struct device_node *np = pdev->dev.of_node;
39343930
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
39353931
unsigned int queue_mask, num_queues;
@@ -3952,14 +3948,11 @@ static int macb_probe(struct platform_device *pdev)
39523948
const struct of_device_id *match;
39533949

39543950
match = of_match_node(macb_dt_ids, np);
3955-
if (match && match->data) {
3951+
if (match && match->data)
39563952
macb_config = match->data;
3957-
clk_init = macb_config->clk_init;
3958-
init = macb_config->init;
3959-
}
39603953
}
39613954

3962-
err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk);
3955+
err = macb_config->clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk);
39633956
if (err)
39643957
return err;
39653958

@@ -3980,6 +3973,7 @@ static int macb_probe(struct platform_device *pdev)
39803973
bp->pdev = pdev;
39813974
bp->dev = dev;
39823975
bp->regs = mem;
3976+
bp->config = macb_config;
39833977
bp->native_io = native_io;
39843978
if (native_io) {
39853979
bp->macb_reg_readl = hw_readl_native;
@@ -3990,14 +3984,10 @@ static int macb_probe(struct platform_device *pdev)
39903984
}
39913985
bp->num_queues = num_queues;
39923986
bp->queue_mask = queue_mask;
3993-
if (macb_config)
3994-
bp->dma_burst_length = macb_config->dma_burst_length;
39953987
bp->pclk = pclk;
39963988
bp->hclk = hclk;
39973989
bp->tx_clk = tx_clk;
39983990
bp->rx_clk = rx_clk;
3999-
if (macb_config)
4000-
bp->jumbo_max_len = macb_config->jumbo_max_len;
40013991

40023992
bp->wol = 0;
40033993
if (of_get_property(np, "magic-packet", NULL))
@@ -4007,7 +3997,7 @@ static int macb_probe(struct platform_device *pdev)
40073997
spin_lock_init(&bp->lock);
40083998

40093999
/* setup capabilities */
4010-
macb_configure_caps(bp, macb_config);
4000+
macb_configure_caps(bp);
40114001

40124002
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
40134003
if (GEM_BFEXT(DAW64, gem_readl(bp, DCFG6))) {
@@ -4066,7 +4056,7 @@ static int macb_probe(struct platform_device *pdev)
40664056
}
40674057

40684058
/* IP specific init */
4069-
err = init(pdev);
4059+
err = bp->config->init(pdev);
40704060
if (err)
40714061
goto err_out_free_netdev;
40724062

0 commit comments

Comments
 (0)