Skip to content

Commit 9232b16

Browse files
mugunthanvnmdavem330
authored andcommitted
driver: net: ethernet: cpsw: make cpts as pointer
As CPTS is common module for both EMAC in Dual EMAC mode so making cpts as pointer. Signed-off-by: Mugunthan V N <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f6e135c commit 9232b16

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ struct cpsw_priv {
319319
/* snapshot of IRQ numbers */
320320
u32 irqs_table[4];
321321
u32 num_irqs;
322-
struct cpts cpts;
322+
struct cpts *cpts;
323323
};
324324

325325
#define napi_to_priv(napi) container_of(napi, struct cpsw_priv, napi)
@@ -383,7 +383,7 @@ void cpsw_tx_handler(void *token, int len, int status)
383383
*/
384384
if (unlikely(netif_queue_stopped(ndev)))
385385
netif_start_queue(ndev);
386-
cpts_tx_timestamp(&priv->cpts, skb);
386+
cpts_tx_timestamp(priv->cpts, skb);
387387
priv->stats.tx_packets++;
388388
priv->stats.tx_bytes += len;
389389
dev_kfree_skb_any(skb);
@@ -404,7 +404,7 @@ void cpsw_rx_handler(void *token, int len, int status)
404404
}
405405
if (likely(status >= 0)) {
406406
skb_put(skb, len);
407-
cpts_rx_timestamp(&priv->cpts, skb);
407+
cpts_rx_timestamp(priv->cpts, skb);
408408
skb->protocol = eth_type_trans(skb, ndev);
409409
netif_receive_skb(skb);
410410
priv->stats.rx_bytes += len;
@@ -760,7 +760,8 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
760760
return NETDEV_TX_OK;
761761
}
762762

763-
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && priv->cpts.tx_enable)
763+
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
764+
priv->cpts->tx_enable)
764765
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
765766

766767
skb_tx_timestamp(skb);
@@ -815,18 +816,18 @@ static void cpsw_hwtstamp_v1(struct cpsw_priv *priv)
815816
struct cpsw_slave *slave = &priv->slaves[priv->data.cpts_active_slave];
816817
u32 ts_en, seq_id;
817818

818-
if (!priv->cpts.tx_enable && !priv->cpts.rx_enable) {
819+
if (!priv->cpts->tx_enable && !priv->cpts->rx_enable) {
819820
slave_write(slave, 0, CPSW1_TS_CTL);
820821
return;
821822
}
822823

823824
seq_id = (30 << CPSW_V1_SEQ_ID_OFS_SHIFT) | ETH_P_1588;
824825
ts_en = EVENT_MSG_BITS << CPSW_V1_MSG_TYPE_OFS;
825826

826-
if (priv->cpts.tx_enable)
827+
if (priv->cpts->tx_enable)
827828
ts_en |= CPSW_V1_TS_TX_EN;
828829

829-
if (priv->cpts.rx_enable)
830+
if (priv->cpts->rx_enable)
830831
ts_en |= CPSW_V1_TS_RX_EN;
831832

832833
slave_write(slave, ts_en, CPSW1_TS_CTL);
@@ -841,10 +842,10 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
841842
ctrl = slave_read(slave, CPSW2_CONTROL);
842843
ctrl &= ~CTRL_ALL_TS_MASK;
843844

844-
if (priv->cpts.tx_enable)
845+
if (priv->cpts->tx_enable)
845846
ctrl |= CTRL_TX_TS_BITS;
846847

847-
if (priv->cpts.rx_enable)
848+
if (priv->cpts->rx_enable)
848849
ctrl |= CTRL_RX_TS_BITS;
849850

850851
mtype = (30 << TS_SEQ_ID_OFFSET_SHIFT) | EVENT_MSG_BITS;
@@ -857,7 +858,7 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
857858
static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
858859
{
859860
struct cpsw_priv *priv = netdev_priv(dev);
860-
struct cpts *cpts = &priv->cpts;
861+
struct cpts *cpts = priv->cpts;
861862
struct hwtstamp_config cfg;
862863

863864
if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
@@ -1086,7 +1087,7 @@ static int cpsw_get_ts_info(struct net_device *ndev,
10861087
SOF_TIMESTAMPING_RX_SOFTWARE |
10871088
SOF_TIMESTAMPING_SOFTWARE |
10881089
SOF_TIMESTAMPING_RAW_HARDWARE;
1089-
info->phc_index = priv->cpts.phc_index;
1090+
info->phc_index = priv->cpts->phc_index;
10901091
info->tx_types =
10911092
(1 << HWTSTAMP_TX_OFF) |
10921093
(1 << HWTSTAMP_TX_ON);
@@ -1272,6 +1273,11 @@ static int cpsw_probe(struct platform_device *pdev)
12721273
priv->dev = &ndev->dev;
12731274
priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG);
12741275
priv->rx_packet_max = max(rx_packet_max, 128);
1276+
priv->cpts = devm_kzalloc(&pdev->dev, sizeof(struct cpts), GFP_KERNEL);
1277+
if (!ndev) {
1278+
pr_err("error allocating cpts\n");
1279+
goto clean_ndev_ret;
1280+
}
12751281

12761282
/*
12771283
* This may be required here for child devices.
@@ -1358,7 +1364,7 @@ static int cpsw_probe(struct platform_device *pdev)
13581364
switch (priv->version) {
13591365
case CPSW_VERSION_1:
13601366
priv->host_port_regs = ss_regs + CPSW1_HOST_PORT_OFFSET;
1361-
priv->cpts.reg = ss_regs + CPSW1_CPTS_OFFSET;
1367+
priv->cpts->reg = ss_regs + CPSW1_CPTS_OFFSET;
13621368
dma_params.dmaregs = ss_regs + CPSW1_CPDMA_OFFSET;
13631369
dma_params.txhdp = ss_regs + CPSW1_STATERAM_OFFSET;
13641370
ale_params.ale_regs = ss_regs + CPSW1_ALE_OFFSET;
@@ -1369,7 +1375,7 @@ static int cpsw_probe(struct platform_device *pdev)
13691375
break;
13701376
case CPSW_VERSION_2:
13711377
priv->host_port_regs = ss_regs + CPSW2_HOST_PORT_OFFSET;
1372-
priv->cpts.reg = ss_regs + CPSW2_CPTS_OFFSET;
1378+
priv->cpts->reg = ss_regs + CPSW2_CPTS_OFFSET;
13731379
dma_params.dmaregs = ss_regs + CPSW2_CPDMA_OFFSET;
13741380
dma_params.txhdp = ss_regs + CPSW2_STATERAM_OFFSET;
13751381
ale_params.ale_regs = ss_regs + CPSW2_ALE_OFFSET;
@@ -1471,7 +1477,7 @@ static int cpsw_probe(struct platform_device *pdev)
14711477
goto clean_irq_ret;
14721478
}
14731479

1474-
if (cpts_register(&pdev->dev, &priv->cpts,
1480+
if (cpts_register(&pdev->dev, priv->cpts,
14751481
data->cpts_clock_mult, data->cpts_clock_shift))
14761482
dev_err(priv->dev, "error registering cpts device\n");
14771483

@@ -1516,7 +1522,7 @@ static int cpsw_remove(struct platform_device *pdev)
15161522
pr_info("removing device");
15171523
platform_set_drvdata(pdev, NULL);
15181524

1519-
cpts_unregister(&priv->cpts);
1525+
cpts_unregister(priv->cpts);
15201526
free_irq(ndev->irq, priv);
15211527
cpsw_ale_destroy(priv->ale);
15221528
cpdma_chan_destroy(priv->txch);

0 commit comments

Comments
 (0)