Commit 9126e75e authored by Ivan Khoronzhuk's avatar Ivan Khoronzhuk Committed by David S. Miller
Browse files

net: ethernet: ti: cpsw_ethtool: simplify slave loops



Only for consistency reasons, do it like in main cpsw.c module
and use ndev reference but not by means of slave.

Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfe59032
Loading
Loading
Loading
Loading
+21 −19
Original line number Original line Diff line number Diff line
@@ -458,7 +458,6 @@ int cpsw_nway_reset(struct net_device *ndev)
static void cpsw_suspend_data_pass(struct net_device *ndev)
static void cpsw_suspend_data_pass(struct net_device *ndev)
{
{
	struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
	struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
	struct cpsw_slave *slave;
	int i;
	int i;


	/* Disable NAPI scheduling */
	/* Disable NAPI scheduling */
@@ -467,12 +466,13 @@ static void cpsw_suspend_data_pass(struct net_device *ndev)
	/* Stop all transmit queues for every network device.
	/* Stop all transmit queues for every network device.
	 * Disable re-using rx descriptors with dormant_on.
	 * Disable re-using rx descriptors with dormant_on.
	 */
	 */
	for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) {
	for (i = 0; i < cpsw->data.slaves; i++) {
		if (!(slave->ndev && netif_running(slave->ndev)))
		ndev = cpsw->slaves[i].ndev;
		if (!(ndev && netif_running(ndev)))
			continue;
			continue;


		netif_tx_stop_all_queues(slave->ndev);
		netif_tx_stop_all_queues(ndev);
		netif_dormant_on(slave->ndev);
		netif_dormant_on(ndev);
	}
	}


	/* Handle rest of tx packets and stop cpdma channels */
	/* Handle rest of tx packets and stop cpdma channels */
@@ -483,13 +483,14 @@ static int cpsw_resume_data_pass(struct net_device *ndev)
{
{
	struct cpsw_priv *priv = netdev_priv(ndev);
	struct cpsw_priv *priv = netdev_priv(ndev);
	struct cpsw_common *cpsw = priv->cpsw;
	struct cpsw_common *cpsw = priv->cpsw;
	struct cpsw_slave *slave;
	int i, ret;
	int i, ret;


	/* Allow rx packets handling */
	/* Allow rx packets handling */
	for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++)
	for (i = 0; i < cpsw->data.slaves; i++) {
		if (slave->ndev && netif_running(slave->ndev))
		ndev = cpsw->slaves[i].ndev;
			netif_dormant_off(slave->ndev);
		if (ndev && netif_running(ndev))
			netif_dormant_off(ndev);
	}


	/* After this receive is started */
	/* After this receive is started */
	if (cpsw->usage_count) {
	if (cpsw->usage_count) {
@@ -502,9 +503,11 @@ static int cpsw_resume_data_pass(struct net_device *ndev)
	}
	}


	/* Resume transmit for every affected interface */
	/* Resume transmit for every affected interface */
	for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++)
	for (i = 0; i < cpsw->data.slaves; i++) {
		if (slave->ndev && netif_running(slave->ndev))
		ndev = cpsw->slaves[i].ndev;
			netif_tx_start_all_queues(slave->ndev);
		if (ndev && netif_running(ndev))
			netif_tx_start_all_queues(ndev);
	}


	return 0;
	return 0;
}
}
@@ -587,7 +590,7 @@ int cpsw_set_channels_common(struct net_device *ndev,
{
{
	struct cpsw_priv *priv = netdev_priv(ndev);
	struct cpsw_priv *priv = netdev_priv(ndev);
	struct cpsw_common *cpsw = priv->cpsw;
	struct cpsw_common *cpsw = priv->cpsw;
	struct cpsw_slave *slave;
	struct net_device *sl_ndev;
	int i, ret;
	int i, ret;


	ret = cpsw_check_ch_settings(cpsw, chs);
	ret = cpsw_check_ch_settings(cpsw, chs);
@@ -604,20 +607,19 @@ int cpsw_set_channels_common(struct net_device *ndev,
	if (ret)
	if (ret)
		goto err;
		goto err;


	for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) {
	for (i = 0; i < cpsw->data.slaves; i++) {
		if (!(slave->ndev && netif_running(slave->ndev)))
		sl_ndev = cpsw->slaves[i].ndev;
		if (!(sl_ndev && netif_running(sl_ndev)))
			continue;
			continue;


		/* Inform stack about new count of queues */
		/* Inform stack about new count of queues */
		ret = netif_set_real_num_tx_queues(slave->ndev,
		ret = netif_set_real_num_tx_queues(sl_ndev, cpsw->tx_ch_num);
						   cpsw->tx_ch_num);
		if (ret) {
		if (ret) {
			dev_err(priv->dev, "cannot set real number of tx queues\n");
			dev_err(priv->dev, "cannot set real number of tx queues\n");
			goto err;
			goto err;
		}
		}


		ret = netif_set_real_num_rx_queues(slave->ndev,
		ret = netif_set_real_num_rx_queues(sl_ndev, cpsw->rx_ch_num);
						   cpsw->rx_ch_num);
		if (ret) {
		if (ret) {
			dev_err(priv->dev, "cannot set real number of rx queues\n");
			dev_err(priv->dev, "cannot set real number of rx queues\n");
			goto err;
			goto err;