Skip to content

Commit 51a9533

Browse files
grygoriySdavem330
authored andcommitted
net: ethernet: ti: cpsw: resolve build deps of cpsw drivers
A following patches introduce new CPSW switchdev driver which uses common code with legacy CPSW driver. This will introduce build dependency between CPSW switchdev and CPSW legacy drivers related to for_each_slave() and cpsw_slave_index() - they can be compiled both, but only one of them will be not functional depending in Kconfig settings due to duffrences in Slave Ports indexes calculation. To fix this make for_each_slave() local (it's used now only by legacy CPSW driver) and convert cpsw_slave_index() to be a function pointer which is assigned in probe. Driver to probe is defined by DT. Signed-off-by: Grygorii Strashko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e85c143 commit 51a9533

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ MODULE_PARM_DESC(descs_pool_size, "Number of CPDMA CPPI descriptors in pool");
8787
#define CPSW_XDP_CONSUMED 1
8888
#define CPSW_XDP_PASS 0
8989

90+
static int cpsw_slave_index_priv(struct cpsw_common *cpsw,
91+
struct cpsw_priv *priv)
92+
{
93+
return cpsw->data.dual_emac ? priv->emac_port : cpsw->data.active_slave;
94+
}
95+
96+
static int cpsw_get_slave_port(u32 slave_num)
97+
{
98+
return slave_num + 1;
99+
}
100+
90101
static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
91102
__be16 proto, u16 vid);
92103

@@ -2774,6 +2785,8 @@ static int cpsw_probe(struct platform_device *pdev)
27742785
return -ENOMEM;
27752786

27762787
platform_set_drvdata(pdev, cpsw);
2788+
cpsw_slave_index = cpsw_slave_index_priv;
2789+
27772790
cpsw->dev = dev;
27782791

27792792
mode = devm_gpiod_get_array_optional(dev, "mode", GPIOD_OUT_LOW);

drivers/net/ethernet/ti/cpsw_priv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "cpsw_sl.h"
2020
#include "davinci_cpdma.h"
2121

22+
int (*cpsw_slave_index)(struct cpsw_common *cpsw, struct cpsw_priv *priv);
23+
2224
int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
2325
int ale_ageout, phys_addr_t desc_mem_phys,
2426
int descs_pool_size)

drivers/net/ethernet/ti/cpsw_priv.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,8 @@ struct cpsw_priv {
373373
#define ndev_to_cpsw(ndev) (((struct cpsw_priv *)netdev_priv(ndev))->cpsw)
374374
#define napi_to_cpsw(napi) container_of(napi, struct cpsw_common, napi)
375375

376-
#define cpsw_slave_index(cpsw, priv) \
377-
((cpsw->data.dual_emac) ? priv->emac_port : \
378-
cpsw->data.active_slave)
379-
380-
static inline int cpsw_get_slave_port(u32 slave_num)
381-
{
382-
return slave_num + 1;
383-
}
376+
extern int (*cpsw_slave_index)(struct cpsw_common *cpsw,
377+
struct cpsw_priv *priv);
384378

385379
struct addr_sync_ctx {
386380
struct net_device *ndev;

0 commit comments

Comments
 (0)