Skip to content

Commit 7c78b4a

Browse files
John Crispindavem330
authored andcommitted
net: mediatek: move the pending_work struct to the device generic struct
The worker always touches both netdevs. It is ethernet core and not MAC specific. We only need one worker, which belongs into the ethernets core struct. Signed-off-by: John Crispin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e7d425d commit 7c78b4a

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ static void mtk_tx_timeout(struct net_device *dev)
11931193
eth->netdev[mac->id]->stats.tx_errors++;
11941194
netif_err(eth, tx_err, dev,
11951195
"transmit timed out\n");
1196-
schedule_work(&mac->pending_work);
1196+
schedule_work(&eth->pending_work);
11971197
}
11981198

11991199
static irqreturn_t mtk_handle_irq(int irq, void *_eth)
@@ -1430,16 +1430,15 @@ static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
14301430

14311431
static void mtk_pending_work(struct work_struct *work)
14321432
{
1433-
struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
1434-
struct mtk_eth *eth = mac->hw;
1433+
struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
14351434
int err, i;
14361435
unsigned long restart = 0;
14371436

14381437
rtnl_lock();
14391438

14401439
/* stop all devices to make sure that dma is properly shut down */
14411440
for (i = 0; i < MTK_MAC_COUNT; i++) {
1442-
if (!netif_oper_up(eth->netdev[i]))
1441+
if (!eth->netdev[i])
14431442
continue;
14441443
mtk_stop(eth->netdev[i]);
14451444
__set_bit(i, &restart);
@@ -1464,15 +1463,13 @@ static int mtk_cleanup(struct mtk_eth *eth)
14641463
int i;
14651464

14661465
for (i = 0; i < MTK_MAC_COUNT; i++) {
1467-
struct mtk_mac *mac = netdev_priv(eth->netdev[i]);
1468-
14691466
if (!eth->netdev[i])
14701467
continue;
14711468

14721469
unregister_netdev(eth->netdev[i]);
14731470
free_netdev(eth->netdev[i]);
1474-
cancel_work_sync(&mac->pending_work);
14751471
}
1472+
cancel_work_sync(&eth->pending_work);
14761473

14771474
return 0;
14781475
}
@@ -1660,7 +1657,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
16601657
mac->id = id;
16611658
mac->hw = eth;
16621659
mac->of_node = np;
1663-
INIT_WORK(&mac->pending_work, mtk_pending_work);
16641660

16651661
mac->hw_stats = devm_kzalloc(eth->dev,
16661662
sizeof(*mac->hw_stats),
@@ -1762,6 +1758,7 @@ static int mtk_probe(struct platform_device *pdev)
17621758

17631759
eth->dev = &pdev->dev;
17641760
eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE);
1761+
INIT_WORK(&eth->pending_work, mtk_pending_work);
17651762

17661763
err = mtk_hw_init(eth);
17671764
if (err)

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ struct mtk_rx_ring {
363363
* @clk_gp1: The gmac1 clock
364364
* @clk_gp2: The gmac2 clock
365365
* @mii_bus: If there is a bus we need to create an instance for it
366+
* @pending_work: The workqueue used to reset the dma ring
366367
*/
367368

368369
struct mtk_eth {
@@ -389,6 +390,7 @@ struct mtk_eth {
389390
struct clk *clk_gp1;
390391
struct clk *clk_gp2;
391392
struct mii_bus *mii_bus;
393+
struct work_struct pending_work;
392394
};
393395

394396
/* struct mtk_mac - the structure that holds the info about the MACs of the
@@ -398,15 +400,13 @@ struct mtk_eth {
398400
* @hw: Backpointer to our main datastruture
399401
* @hw_stats: Packet statistics counter
400402
* @phy_dev: The attached PHY if available
401-
* @pending_work: The workqueue used to reset the dma ring
402403
*/
403404
struct mtk_mac {
404405
int id;
405406
struct device_node *of_node;
406407
struct mtk_eth *hw;
407408
struct mtk_hw_stats *hw_stats;
408409
struct phy_device *phy_dev;
409-
struct work_struct pending_work;
410410
};
411411

412412
/* the struct describing the SoC. these are declared in the soc_xyz.c files */

0 commit comments

Comments
 (0)