Skip to content

Commit e3f3803

Browse files
shimodaykuba-moo
authored andcommitted
net: renesas: rswitch: Move linkfix variables to rswitch_gwca
To improve readability, move linkfix related variables to struct rswitch_gwca. Also, rename function names "desc" with "linkfix". Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 251eadc commit e3f3803

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static int rswitch_gwca_queue_format(struct net_device *ndev,
386386
rswitch_desc_set_dptr(&desc->desc, gq->ring_dma);
387387
desc->desc.die_dt = DT_LINKFIX;
388388

389-
linkfix = &priv->linkfix_table[gq->index];
389+
linkfix = &priv->gwca.linkfix_table[gq->index];
390390
linkfix->die_dt = DT_LINKFIX;
391391
rswitch_desc_set_dptr(linkfix, gq->ring_dma);
392392

@@ -470,7 +470,7 @@ static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev,
470470
rswitch_desc_set_dptr(&desc->desc, gq->ring_dma);
471471
desc->desc.die_dt = DT_LINKFIX;
472472

473-
linkfix = &priv->linkfix_table[gq->index];
473+
linkfix = &priv->gwca.linkfix_table[gq->index];
474474
linkfix->die_dt = DT_LINKFIX;
475475
rswitch_desc_set_dptr(linkfix, gq->ring_dma);
476476

@@ -480,28 +480,31 @@ static int rswitch_gwca_queue_ext_ts_format(struct net_device *ndev,
480480
return 0;
481481
}
482482

483-
static int rswitch_gwca_desc_alloc(struct rswitch_private *priv)
483+
static int rswitch_gwca_linkfix_alloc(struct rswitch_private *priv)
484484
{
485485
int i, num_queues = priv->gwca.num_queues;
486+
struct rswitch_gwca *gwca = &priv->gwca;
486487
struct device *dev = &priv->pdev->dev;
487488

488-
priv->linkfix_table_size = sizeof(struct rswitch_desc) * num_queues;
489-
priv->linkfix_table = dma_alloc_coherent(dev, priv->linkfix_table_size,
490-
&priv->linkfix_table_dma, GFP_KERNEL);
491-
if (!priv->linkfix_table)
489+
gwca->linkfix_table_size = sizeof(struct rswitch_desc) * num_queues;
490+
gwca->linkfix_table = dma_alloc_coherent(dev, gwca->linkfix_table_size,
491+
&gwca->linkfix_table_dma, GFP_KERNEL);
492+
if (!gwca->linkfix_table)
492493
return -ENOMEM;
493494
for (i = 0; i < num_queues; i++)
494-
priv->linkfix_table[i].die_dt = DT_EOS;
495+
gwca->linkfix_table[i].die_dt = DT_EOS;
495496

496497
return 0;
497498
}
498499

499-
static void rswitch_gwca_desc_free(struct rswitch_private *priv)
500+
static void rswitch_gwca_linkfix_free(struct rswitch_private *priv)
500501
{
501-
if (priv->linkfix_table)
502-
dma_free_coherent(&priv->pdev->dev, priv->linkfix_table_size,
503-
priv->linkfix_table, priv->linkfix_table_dma);
504-
priv->linkfix_table = NULL;
502+
struct rswitch_gwca *gwca = &priv->gwca;
503+
504+
if (gwca->linkfix_table)
505+
dma_free_coherent(&priv->pdev->dev, gwca->linkfix_table_size,
506+
gwca->linkfix_table, gwca->linkfix_table_dma);
507+
gwca->linkfix_table = NULL;
505508
}
506509

507510
static struct rswitch_gwca_queue *rswitch_gwca_get(struct rswitch_private *priv)
@@ -617,8 +620,8 @@ static int rswitch_gwca_hw_init(struct rswitch_private *priv)
617620

618621
iowrite32(GWVCC_VEM_SC_TAG, priv->addr + GWVCC);
619622
iowrite32(0, priv->addr + GWTTFC);
620-
iowrite32(lower_32_bits(priv->linkfix_table_dma), priv->addr + GWDCBAC1);
621-
iowrite32(upper_32_bits(priv->linkfix_table_dma), priv->addr + GWDCBAC0);
623+
iowrite32(lower_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCBAC1);
624+
iowrite32(upper_32_bits(priv->gwca.linkfix_table_dma), priv->addr + GWDCBAC0);
622625
rswitch_gwca_set_rate_limit(priv, priv->gwca.speed);
623626

624627
for (i = 0; i < RSWITCH_NUM_PORTS; i++) {
@@ -1650,7 +1653,7 @@ static int rswitch_init(struct rswitch_private *priv)
16501653
if (err < 0)
16511654
return err;
16521655

1653-
err = rswitch_gwca_desc_alloc(priv);
1656+
err = rswitch_gwca_linkfix_alloc(priv);
16541657
if (err < 0)
16551658
return -ENOMEM;
16561659

@@ -1712,7 +1715,7 @@ static int rswitch_init(struct rswitch_private *priv)
17121715
rswitch_device_free(priv, i);
17131716

17141717
err_device_alloc:
1715-
rswitch_gwca_desc_free(priv);
1718+
rswitch_gwca_linkfix_free(priv);
17161719

17171720
return err;
17181721
}
@@ -1791,7 +1794,7 @@ static void rswitch_deinit(struct rswitch_private *priv)
17911794
rswitch_device_free(priv, i);
17921795
}
17931796

1794-
rswitch_gwca_desc_free(priv);
1797+
rswitch_gwca_linkfix_free(priv);
17951798

17961799
rswitch_clock_disable(priv);
17971800
}

drivers/net/ethernet/renesas/rswitch.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,9 @@ struct rswitch_gwca_queue {
930930
#define RSWITCH_NUM_IRQ_REGS (RSWITCH_MAX_NUM_QUEUES / BITS_PER_TYPE(u32))
931931
struct rswitch_gwca {
932932
int index;
933+
struct rswitch_desc *linkfix_table;
934+
dma_addr_t linkfix_table_dma;
935+
u32 linkfix_table_size;
933936
struct rswitch_gwca_queue *queues;
934937
int num_queues;
935938
DECLARE_BITMAP(used, RSWITCH_MAX_NUM_QUEUES);
@@ -969,9 +972,6 @@ struct rswitch_private {
969972
struct platform_device *pdev;
970973
void __iomem *addr;
971974
struct rcar_gen4_ptp_private *ptp_priv;
972-
struct rswitch_desc *linkfix_table;
973-
dma_addr_t linkfix_table_dma;
974-
u32 linkfix_table_size;
975975

976976
struct rswitch_device *rdev[RSWITCH_NUM_PORTS];
977977

0 commit comments

Comments
 (0)