Skip to content

Commit

Permalink
net: mediatek: move the pending_work struct to the device generic struct
Browse files Browse the repository at this point in the history
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 <blogic@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
John Crispin authored and David S. Miller committed Apr 13, 2016
1 parent e7d425d commit 7c78b4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ static void mtk_tx_timeout(struct net_device *dev)
eth->netdev[mac->id]->stats.tx_errors++;
netif_err(eth, tx_err, dev,
"transmit timed out\n");
schedule_work(&mac->pending_work);
schedule_work(&eth->pending_work);
}

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

static void mtk_pending_work(struct work_struct *work)
{
struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
struct mtk_eth *eth = mac->hw;
struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
int err, i;
unsigned long restart = 0;

rtnl_lock();

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

for (i = 0; i < MTK_MAC_COUNT; i++) {
struct mtk_mac *mac = netdev_priv(eth->netdev[i]);

if (!eth->netdev[i])
continue;

unregister_netdev(eth->netdev[i]);
free_netdev(eth->netdev[i]);
cancel_work_sync(&mac->pending_work);
}
cancel_work_sync(&eth->pending_work);

return 0;
}
Expand Down Expand Up @@ -1660,7 +1657,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
mac->id = id;
mac->hw = eth;
mac->of_node = np;
INIT_WORK(&mac->pending_work, mtk_pending_work);

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

eth->dev = &pdev->dev;
eth->msg_enable = netif_msg_init(mtk_msg_level, MTK_DEFAULT_MSG_ENABLE);
INIT_WORK(&eth->pending_work, mtk_pending_work);

err = mtk_hw_init(eth);
if (err)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ struct mtk_rx_ring {
* @clk_gp1: The gmac1 clock
* @clk_gp2: The gmac2 clock
* @mii_bus: If there is a bus we need to create an instance for it
* @pending_work: The workqueue used to reset the dma ring
*/

struct mtk_eth {
Expand All @@ -389,6 +390,7 @@ struct mtk_eth {
struct clk *clk_gp1;
struct clk *clk_gp2;
struct mii_bus *mii_bus;
struct work_struct pending_work;
};

/* struct mtk_mac - the structure that holds the info about the MACs of the
Expand All @@ -398,15 +400,13 @@ struct mtk_eth {
* @hw: Backpointer to our main datastruture
* @hw_stats: Packet statistics counter
* @phy_dev: The attached PHY if available
* @pending_work: The workqueue used to reset the dma ring
*/
struct mtk_mac {
int id;
struct device_node *of_node;
struct mtk_eth *hw;
struct mtk_hw_stats *hw_stats;
struct phy_device *phy_dev;
struct work_struct pending_work;
};

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

0 comments on commit 7c78b4a

Please sign in to comment.