@@ -319,7 +319,7 @@ struct cpsw_priv {
319
319
/* snapshot of IRQ numbers */
320
320
u32 irqs_table [4 ];
321
321
u32 num_irqs ;
322
- struct cpts cpts ;
322
+ struct cpts * cpts ;
323
323
};
324
324
325
325
#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)
383
383
*/
384
384
if (unlikely (netif_queue_stopped (ndev )))
385
385
netif_start_queue (ndev );
386
- cpts_tx_timestamp (& priv -> cpts , skb );
386
+ cpts_tx_timestamp (priv -> cpts , skb );
387
387
priv -> stats .tx_packets ++ ;
388
388
priv -> stats .tx_bytes += len ;
389
389
dev_kfree_skb_any (skb );
@@ -404,7 +404,7 @@ void cpsw_rx_handler(void *token, int len, int status)
404
404
}
405
405
if (likely (status >= 0 )) {
406
406
skb_put (skb , len );
407
- cpts_rx_timestamp (& priv -> cpts , skb );
407
+ cpts_rx_timestamp (priv -> cpts , skb );
408
408
skb -> protocol = eth_type_trans (skb , ndev );
409
409
netif_receive_skb (skb );
410
410
priv -> stats .rx_bytes += len ;
@@ -760,7 +760,8 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb,
760
760
return NETDEV_TX_OK ;
761
761
}
762
762
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 )
764
765
skb_shinfo (skb )-> tx_flags |= SKBTX_IN_PROGRESS ;
765
766
766
767
skb_tx_timestamp (skb );
@@ -815,18 +816,18 @@ static void cpsw_hwtstamp_v1(struct cpsw_priv *priv)
815
816
struct cpsw_slave * slave = & priv -> slaves [priv -> data .cpts_active_slave ];
816
817
u32 ts_en , seq_id ;
817
818
818
- if (!priv -> cpts . tx_enable && !priv -> cpts . rx_enable ) {
819
+ if (!priv -> cpts -> tx_enable && !priv -> cpts -> rx_enable ) {
819
820
slave_write (slave , 0 , CPSW1_TS_CTL );
820
821
return ;
821
822
}
822
823
823
824
seq_id = (30 << CPSW_V1_SEQ_ID_OFS_SHIFT ) | ETH_P_1588 ;
824
825
ts_en = EVENT_MSG_BITS << CPSW_V1_MSG_TYPE_OFS ;
825
826
826
- if (priv -> cpts . tx_enable )
827
+ if (priv -> cpts -> tx_enable )
827
828
ts_en |= CPSW_V1_TS_TX_EN ;
828
829
829
- if (priv -> cpts . rx_enable )
830
+ if (priv -> cpts -> rx_enable )
830
831
ts_en |= CPSW_V1_TS_RX_EN ;
831
832
832
833
slave_write (slave , ts_en , CPSW1_TS_CTL );
@@ -841,10 +842,10 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
841
842
ctrl = slave_read (slave , CPSW2_CONTROL );
842
843
ctrl &= ~CTRL_ALL_TS_MASK ;
843
844
844
- if (priv -> cpts . tx_enable )
845
+ if (priv -> cpts -> tx_enable )
845
846
ctrl |= CTRL_TX_TS_BITS ;
846
847
847
- if (priv -> cpts . rx_enable )
848
+ if (priv -> cpts -> rx_enable )
848
849
ctrl |= CTRL_RX_TS_BITS ;
849
850
850
851
mtype = (30 << TS_SEQ_ID_OFFSET_SHIFT ) | EVENT_MSG_BITS ;
@@ -857,7 +858,7 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
857
858
static int cpsw_hwtstamp_ioctl (struct net_device * dev , struct ifreq * ifr )
858
859
{
859
860
struct cpsw_priv * priv = netdev_priv (dev );
860
- struct cpts * cpts = & priv -> cpts ;
861
+ struct cpts * cpts = priv -> cpts ;
861
862
struct hwtstamp_config cfg ;
862
863
863
864
if (copy_from_user (& cfg , ifr -> ifr_data , sizeof (cfg )))
@@ -1086,7 +1087,7 @@ static int cpsw_get_ts_info(struct net_device *ndev,
1086
1087
SOF_TIMESTAMPING_RX_SOFTWARE |
1087
1088
SOF_TIMESTAMPING_SOFTWARE |
1088
1089
SOF_TIMESTAMPING_RAW_HARDWARE ;
1089
- info -> phc_index = priv -> cpts . phc_index ;
1090
+ info -> phc_index = priv -> cpts -> phc_index ;
1090
1091
info -> tx_types =
1091
1092
(1 << HWTSTAMP_TX_OFF ) |
1092
1093
(1 << HWTSTAMP_TX_ON );
@@ -1272,6 +1273,11 @@ static int cpsw_probe(struct platform_device *pdev)
1272
1273
priv -> dev = & ndev -> dev ;
1273
1274
priv -> msg_enable = netif_msg_init (debug_level , CPSW_DEBUG );
1274
1275
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
+ }
1275
1281
1276
1282
/*
1277
1283
* This may be required here for child devices.
@@ -1358,7 +1364,7 @@ static int cpsw_probe(struct platform_device *pdev)
1358
1364
switch (priv -> version ) {
1359
1365
case CPSW_VERSION_1 :
1360
1366
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 ;
1362
1368
dma_params .dmaregs = ss_regs + CPSW1_CPDMA_OFFSET ;
1363
1369
dma_params .txhdp = ss_regs + CPSW1_STATERAM_OFFSET ;
1364
1370
ale_params .ale_regs = ss_regs + CPSW1_ALE_OFFSET ;
@@ -1369,7 +1375,7 @@ static int cpsw_probe(struct platform_device *pdev)
1369
1375
break ;
1370
1376
case CPSW_VERSION_2 :
1371
1377
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 ;
1373
1379
dma_params .dmaregs = ss_regs + CPSW2_CPDMA_OFFSET ;
1374
1380
dma_params .txhdp = ss_regs + CPSW2_STATERAM_OFFSET ;
1375
1381
ale_params .ale_regs = ss_regs + CPSW2_ALE_OFFSET ;
@@ -1471,7 +1477,7 @@ static int cpsw_probe(struct platform_device *pdev)
1471
1477
goto clean_irq_ret ;
1472
1478
}
1473
1479
1474
- if (cpts_register (& pdev -> dev , & priv -> cpts ,
1480
+ if (cpts_register (& pdev -> dev , priv -> cpts ,
1475
1481
data -> cpts_clock_mult , data -> cpts_clock_shift ))
1476
1482
dev_err (priv -> dev , "error registering cpts device\n" );
1477
1483
@@ -1516,7 +1522,7 @@ static int cpsw_remove(struct platform_device *pdev)
1516
1522
pr_info ("removing device" );
1517
1523
platform_set_drvdata (pdev , NULL );
1518
1524
1519
- cpts_unregister (& priv -> cpts );
1525
+ cpts_unregister (priv -> cpts );
1520
1526
free_irq (ndev -> irq , priv );
1521
1527
cpsw_ale_destroy (priv -> ale );
1522
1528
cpdma_chan_destroy (priv -> txch );
0 commit comments