[PATCH 1/3] net: cpsw: replace pr_xxx with dev_xxx functions

Subsystems: networking drivers, the rest, ti ethernet switch driver (cpsw)

STALE5006d

8 messages, 3 authors, 2012-12-04 · open the first message on its own page

[PATCH 1/3] net: cpsw: replace pr_xxx with dev_xxx functions

From: jlu@pengutronix.de (Jan Luebbe)
Date: 2012-12-03 13:49:27

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |   47 ++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index fb1a692..c0e676a 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -729,7 +729,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		return -EINVAL;
 
 	if (of_property_read_u32(node, "slaves", &prop)) {
-		pr_err("Missing slaves property in the DT.\n");
+		dev_err(&pdev->dev, "Missing slaves property in the DT.\n");
 		return -EINVAL;
 	}
 	data->slaves = prop;
@@ -737,91 +737,91 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 	data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
 				   data->slaves, GFP_KERNEL);
 	if (!data->slave_data) {
-		pr_err("Could not allocate slave memory.\n");
+		dev_err(&pdev->dev, "Could not allocate slave memory.\n");
 		return -EINVAL;
 	}
 
 	data->no_bd_ram = of_property_read_bool(node, "no_bd_ram");
 
 	if (of_property_read_u32(node, "cpdma_channels", &prop)) {
-		pr_err("Missing cpdma_channels property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_channels property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->channels = prop;
 
 	if (of_property_read_u32(node, "host_port_no", &prop)) {
-		pr_err("Missing host_port_no property in the DT.\n");
+		dev_err(&pdev->dev, "Missing host_port_no property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->host_port_num = prop;
 
 	if (of_property_read_u32(node, "cpdma_reg_ofs", &prop)) {
-		pr_err("Missing cpdma_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_reg_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->cpdma_reg_ofs = prop;
 
 	if (of_property_read_u32(node, "cpdma_sram_ofs", &prop)) {
-		pr_err("Missing cpdma_sram_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_sram_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->cpdma_sram_ofs = prop;
 
 	if (of_property_read_u32(node, "ale_reg_ofs", &prop)) {
-		pr_err("Missing ale_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing ale_reg_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->ale_reg_ofs = prop;
 
 	if (of_property_read_u32(node, "ale_entries", &prop)) {
-		pr_err("Missing ale_entries property in the DT.\n");
+		dev_err(&pdev->dev, "Missing ale_entries property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->ale_entries = prop;
 
 	if (of_property_read_u32(node, "host_port_reg_ofs", &prop)) {
-		pr_err("Missing host_port_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing host_port_reg_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->host_port_reg_ofs = prop;
 
 	if (of_property_read_u32(node, "hw_stats_reg_ofs", &prop)) {
-		pr_err("Missing hw_stats_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing hw_stats_reg_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->hw_stats_reg_ofs = prop;
 
 	if (of_property_read_u32(node, "bd_ram_ofs", &prop)) {
-		pr_err("Missing bd_ram_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing bd_ram_ofs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->bd_ram_ofs = prop;
 
 	if (of_property_read_u32(node, "bd_ram_size", &prop)) {
-		pr_err("Missing bd_ram_size property in the DT.\n");
+		dev_err(&pdev->dev, "Missing bd_ram_size property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->bd_ram_size = prop;
 
 	if (of_property_read_u32(node, "rx_descs", &prop)) {
-		pr_err("Missing rx_descs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing rx_descs property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
 	data->rx_descs = prop;
 
 	if (of_property_read_u32(node, "mac_control", &prop)) {
-		pr_err("Missing mac_control property in the DT.\n");
+		dev_err(&pdev->dev, "Missing mac_control property in the DT.\n");
 		ret = -EINVAL;
 		goto error_ret;
 	}
@@ -833,14 +833,14 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		const void *mac_addr = NULL;
 
 		if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
-			pr_err("Missing slave[%d] phy_id property\n", i);
+			dev_err(&pdev->dev, "Missing slave[%d] phy_id property.\n", i);
 			ret = -EINVAL;
 			goto error_ret;
 		}
 		slave_data->phy_id = phy_id;
 
 		if (of_property_read_u32(slave_node, "slave_reg_ofs", &prop)) {
-			pr_err("Missing slave[%d] slave_reg_ofs property\n", i);
+			dev_err(&pdev->dev, "Missing slave[%d] slave_reg_ofs property.\n", i);
 			ret = -EINVAL;
 			goto error_ret;
 		}
@@ -848,8 +848,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 
 		if (of_property_read_u32(slave_node, "sliver_reg_ofs",
 					 &prop)) {
-			pr_err("Missing slave[%d] sliver_reg_ofs property\n",
-				i);
+			dev_err(&pdev->dev, "Missing slave[%d] sliver_reg_ofs property.\n", i);
 			ret = -EINVAL;
 			goto error_ret;
 		}
@@ -868,7 +867,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 	ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
 	/* We do not want to force this, as in some cases may not have child */
 	if (ret)
-		pr_warn("Doesn't have any child node\n");
+		dev_warn(&pdev->dev, "Doesn't have any child node\n");
 
 	return 0;
 
@@ -890,7 +889,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 
 	ndev = alloc_etherdev(sizeof(struct cpsw_priv));
 	if (!ndev) {
-		pr_err("error allocating net_device\n");
+		pr_err("cpsw: error allocating net_device\n");
 		return -ENOMEM;
 	}
 
@@ -909,7 +908,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	if (cpsw_probe_dt(&priv->data, pdev)) {
-		pr_err("cpsw: platform data missing\n");
+		dev_err(&pdev->dev, "platform data missing\n");
 		ret = -ENODEV;
 		goto clean_ndev_ret;
 	}
@@ -917,10 +916,10 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
 
 	if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
 		memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
-		pr_info("Detected MACID = %pM", priv->mac_addr);
+		dev_info(&pdev->dev, "Detected MACID = %pM", priv->mac_addr);
 	} else {
 		eth_random_addr(priv->mac_addr);
-		pr_info("Random MACID = %pM", priv->mac_addr);
+		dev_info(&pdev->dev, "Random MACID = %pM", priv->mac_addr);
 	}
 
 	memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
@@ -1120,7 +1119,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct cpsw_priv *priv = netdev_priv(ndev);
 
-	pr_info("removing device");
+	dev_info(&pdev->dev, "removing device");
 	platform_set_drvdata(pdev, NULL);
 
 	free_irq(ndev->irq, priv);
-- 
1.7.10.4

[PATCH 2/3] net: cpsw: verify correct number of slaves in DT

From: jlu@pengutronix.de (Jan Luebbe)
Date: 2012-12-03 13:49:28

Check that the number of available slaves passed from DT matches the
value of the "slaves" property in the cpsw node. Otherwise, priv->slaves
would be the wrong size.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c0e676a..8de3e92 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -832,6 +832,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		const char *phy_id = NULL;
 		const void *mac_addr = NULL;
 
+		if (!of_device_is_available(slave_node))
+			continue;
+
+		if (i >= data->slaves) {
+			dev_err(&pdev->dev, "Too many slaves in the DT (> %d).\n",
+				data->slaves);
+			ret = -EINVAL;
+			goto error_ret;
+		}
+
 		if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
 			dev_err(&pdev->dev, "Missing slave[%d] phy_id property.\n", i);
 			ret = -EINVAL;
@@ -861,6 +871,13 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		i++;
 	}
 
+	if (i < data->slaves) {
+		dev_err(&pdev->dev, "Not enough slaves in the DT (< %d).\n",
+			data->slaves);
+		ret = -EINVAL;
+		goto error_ret;
+	}
+
 	/*
 	 * Populate all the child nodes here...
 	 */
-- 
1.7.10.4

[PATCH 3/3] net: cpsw: implement ioctl for MII

From: jlu@pengutronix.de (Jan Luebbe)
Date: 2012-12-03 13:49:29

This allows using tools like mii-diag on CPSW.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 8de3e92..f476c03 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -629,6 +629,20 @@ static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags)
 		dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n");
 }
 
+static int cpsw_ndo_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	struct phy_device *phy = priv->slaves[0].phy;
+
+	if (!netif_running(ndev))
+		return -EINVAL;
+
+	if (!phy)
+		return -ENODEV;
+
+	return phy_mii_ioctl(phy, rq, cmd);
+}
+
 static void cpsw_ndo_tx_timeout(struct net_device *ndev)
 {
 	struct cpsw_priv *priv = netdev_priv(ndev);
@@ -670,6 +684,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
 	.ndo_start_xmit		= cpsw_ndo_start_xmit,
 	.ndo_change_rx_flags	= cpsw_ndo_change_rx_flags,
 	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_do_ioctl		= cpsw_ndo_do_ioctl,
 	.ndo_change_mtu		= eth_change_mtu,
 	.ndo_tx_timeout		= cpsw_ndo_tx_timeout,
 	.ndo_get_stats		= cpsw_ndo_get_stats,
-- 
1.7.10.4

[PATCH 3/3] net: cpsw: implement ioctl for MII

From: Ben Hutchings <hidden>
Date: 2012-12-03 14:16:51

On Mon, 2012-12-03 at 14:49 +0100, Jan Luebbe wrote:
quoted hunk
This allows using tools like mii-diag on CPSW.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 8de3e92..f476c03 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -629,6 +629,20 @@ static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags)
 		dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n");
 }
 
+static int cpsw_ndo_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	struct phy_device *phy = priv->slaves[0].phy;
+
+	if (!netif_running(ndev))
+		return -EINVAL;
This is consistent with other drivers, and I'm not going to object to
one more instance, but I don't think this is the proper error code - we
don't know that there's anything wrong with the arguments, it's just
that the *device* is in the wrong state.  I don't know what the right
error code is, though.  Really I would prefer that MDIO would work even
when the device is down, unless you know that all MDIO-manageable
devices are powered off.

Ben.
quoted hunk
+	if (!phy)
+		return -ENODEV;
+
+	return phy_mii_ioctl(phy, rq, cmd);
+}
+
 static void cpsw_ndo_tx_timeout(struct net_device *ndev)
 {
 	struct cpsw_priv *priv = netdev_priv(ndev);
@@ -670,6 +684,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
 	.ndo_start_xmit		= cpsw_ndo_start_xmit,
 	.ndo_change_rx_flags	= cpsw_ndo_change_rx_flags,
 	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_do_ioctl		= cpsw_ndo_do_ioctl,
 	.ndo_change_mtu		= eth_change_mtu,
 	.ndo_tx_timeout		= cpsw_ndo_tx_timeout,
 	.ndo_get_stats		= cpsw_ndo_get_stats,
-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

[PATCH 1/3] net: cpsw: replace pr_xxx with dev_xxx functions

From: Mugunthan V N <hidden>
Date: 2012-12-03 16:59:28

On 12/3/2012 7:19 PM, Jan Luebbe wrote:
quoted hunk
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
  drivers/net/ethernet/ti/cpsw.c |   47 ++++++++++++++++++++--------------------
  1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index fb1a692..c0e676a 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -729,7 +729,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  		return -EINVAL;
  
  	if (of_property_read_u32(node, "slaves", &prop)) {
-		pr_err("Missing slaves property in the DT.\n");
+		dev_err(&pdev->dev, "Missing slaves property in the DT.\n");
  		return -EINVAL;
  	}
  	data->slaves = prop;
@@ -737,91 +737,91 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  	data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
  				   data->slaves, GFP_KERNEL);
  	if (!data->slave_data) {
-		pr_err("Could not allocate slave memory.\n");
+		dev_err(&pdev->dev, "Could not allocate slave memory.\n");
  		return -EINVAL;
  	}
  
  	data->no_bd_ram = of_property_read_bool(node, "no_bd_ram");
  
  	if (of_property_read_u32(node, "cpdma_channels", &prop)) {
-		pr_err("Missing cpdma_channels property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_channels property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->channels = prop;
  
  	if (of_property_read_u32(node, "host_port_no", &prop)) {
-		pr_err("Missing host_port_no property in the DT.\n");
+		dev_err(&pdev->dev, "Missing host_port_no property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->host_port_num = prop;
  
  	if (of_property_read_u32(node, "cpdma_reg_ofs", &prop)) {
-		pr_err("Missing cpdma_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_reg_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->cpdma_reg_ofs = prop;
  
  	if (of_property_read_u32(node, "cpdma_sram_ofs", &prop)) {
-		pr_err("Missing cpdma_sram_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing cpdma_sram_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->cpdma_sram_ofs = prop;
  
  	if (of_property_read_u32(node, "ale_reg_ofs", &prop)) {
-		pr_err("Missing ale_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing ale_reg_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->ale_reg_ofs = prop;
  
  	if (of_property_read_u32(node, "ale_entries", &prop)) {
-		pr_err("Missing ale_entries property in the DT.\n");
+		dev_err(&pdev->dev, "Missing ale_entries property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->ale_entries = prop;
  
  	if (of_property_read_u32(node, "host_port_reg_ofs", &prop)) {
-		pr_err("Missing host_port_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing host_port_reg_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->host_port_reg_ofs = prop;
  
  	if (of_property_read_u32(node, "hw_stats_reg_ofs", &prop)) {
-		pr_err("Missing hw_stats_reg_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing hw_stats_reg_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->hw_stats_reg_ofs = prop;
  
  	if (of_property_read_u32(node, "bd_ram_ofs", &prop)) {
-		pr_err("Missing bd_ram_ofs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing bd_ram_ofs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->bd_ram_ofs = prop;
  
  	if (of_property_read_u32(node, "bd_ram_size", &prop)) {
-		pr_err("Missing bd_ram_size property in the DT.\n");
+		dev_err(&pdev->dev, "Missing bd_ram_size property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->bd_ram_size = prop;
  
  	if (of_property_read_u32(node, "rx_descs", &prop)) {
-		pr_err("Missing rx_descs property in the DT.\n");
+		dev_err(&pdev->dev, "Missing rx_descs property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
  	data->rx_descs = prop;
  
  	if (of_property_read_u32(node, "mac_control", &prop)) {
-		pr_err("Missing mac_control property in the DT.\n");
+		dev_err(&pdev->dev, "Missing mac_control property in the DT.\n");
  		ret = -EINVAL;
  		goto error_ret;
  	}
@@ -833,14 +833,14 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  		const void *mac_addr = NULL;
  
  		if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
-			pr_err("Missing slave[%d] phy_id property\n", i);
+			dev_err(&pdev->dev, "Missing slave[%d] phy_id property.\n", i);
  			ret = -EINVAL;
  			goto error_ret;
  		}
  		slave_data->phy_id = phy_id;
  
  		if (of_property_read_u32(slave_node, "slave_reg_ofs", &prop)) {
-			pr_err("Missing slave[%d] slave_reg_ofs property\n", i);
+			dev_err(&pdev->dev, "Missing slave[%d] slave_reg_ofs property.\n", i);
  			ret = -EINVAL;
  			goto error_ret;
  		}
@@ -848,8 +848,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  
  		if (of_property_read_u32(slave_node, "sliver_reg_ofs",
  					 &prop)) {
-			pr_err("Missing slave[%d] sliver_reg_ofs property\n",
-				i);
+			dev_err(&pdev->dev, "Missing slave[%d] sliver_reg_ofs property.\n", i);
  			ret = -EINVAL;
  			goto error_ret;
  		}
@@ -868,7 +867,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  	ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
  	/* We do not want to force this, as in some cases may not have child */
  	if (ret)
-		pr_warn("Doesn't have any child node\n");
+		dev_warn(&pdev->dev, "Doesn't have any child node\n");
  
  	return 0;
  
@@ -890,7 +889,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
  
  	ndev = alloc_etherdev(sizeof(struct cpsw_priv));
  	if (!ndev) {
-		pr_err("error allocating net_device\n");
+		pr_err("cpsw: error allocating net_device\n");
  		return -ENOMEM;
  	}
  
@@ -909,7 +908,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
  	pm_runtime_enable(&pdev->dev);
  
  	if (cpsw_probe_dt(&priv->data, pdev)) {
-		pr_err("cpsw: platform data missing\n");
+		dev_err(&pdev->dev, "platform data missing\n");
  		ret = -ENODEV;
  		goto clean_ndev_ret;
  	}
@@ -917,10 +916,10 @@ static int __devinit cpsw_probe(struct platform_device *pdev)
  
  	if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
  		memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
-		pr_info("Detected MACID = %pM", priv->mac_addr);
+		dev_info(&pdev->dev, "Detected MACID = %pM", priv->mac_addr);
  	} else {
  		eth_random_addr(priv->mac_addr);
-		pr_info("Random MACID = %pM", priv->mac_addr);
+		dev_info(&pdev->dev, "Random MACID = %pM", priv->mac_addr);
  	}
  
  	memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
@@ -1120,7 +1119,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev)
  	struct net_device *ndev = platform_get_drvdata(pdev);
  	struct cpsw_priv *priv = netdev_priv(ndev);
  
-	pr_info("removing device");
+	dev_info(&pdev->dev, "removing device");
  	platform_set_drvdata(pdev, NULL);
  
  	free_irq(ndev->irq, priv);
The patches look good to me.

Acked-by: Mugunthan V N<redacted>

[PATCH 2/3] net: cpsw: verify correct number of slaves in DT

From: Mugunthan V N <hidden>
Date: 2012-12-03 17:00:18

On 12/3/2012 7:19 PM, Jan Luebbe wrote:
quoted hunk
Check that the number of available slaves passed from DT matches the
value of the "slaves" property in the cpsw node. Otherwise, priv->slaves
would be the wrong size.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
  drivers/net/ethernet/ti/cpsw.c |   17 +++++++++++++++++
  1 file changed, 17 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c0e676a..8de3e92 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -832,6 +832,16 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  		const char *phy_id = NULL;
  		const void *mac_addr = NULL;
  
+		if (!of_device_is_available(slave_node))
+			continue;
+
+		if (i >= data->slaves) {
+			dev_err(&pdev->dev, "Too many slaves in the DT (> %d).\n",
+				data->slaves);
+			ret = -EINVAL;
+			goto error_ret;
+		}
+
  		if (of_property_read_string(slave_node, "phy_id", &phy_id)) {
  			dev_err(&pdev->dev, "Missing slave[%d] phy_id property.\n", i);
  			ret = -EINVAL;
@@ -861,6 +871,13 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
  		i++;
  	}
  
+	if (i < data->slaves) {
+		dev_err(&pdev->dev, "Not enough slaves in the DT (< %d).\n",
+			data->slaves);
+		ret = -EINVAL;
+		goto error_ret;
+	}
+
  	/*
  	 * Populate all the child nodes here...
  	 */
The patches look good to me.

Acked-by: Mugunthan V N<redacted>

Regards
Mugunthan V N

[PATCH 3/3] net: cpsw: implement ioctl for MII

From: Mugunthan V N <hidden>
Date: 2012-12-03 17:04:27

On 12/3/2012 7:19 PM, Jan Luebbe wrote:
quoted hunk
This allows using tools like mii-diag on CPSW.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
  drivers/net/ethernet/ti/cpsw.c |   15 +++++++++++++++
  1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 8de3e92..f476c03 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -629,6 +629,20 @@ static void cpsw_ndo_change_rx_flags(struct net_device *ndev, int flags)
  		dev_err(&ndev->dev, "multicast traffic cannot be filtered!\n");
  }
  
+static int cpsw_ndo_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
+{
+	struct cpsw_priv *priv = netdev_priv(ndev);
+	struct phy_device *phy = priv->slaves[0].phy;
+
+	if (!netif_running(ndev))
+		return -EINVAL;
+
+	if (!phy)
+		return -ENODEV;
+
+	return phy_mii_ioctl(phy, rq, cmd);
+}
+
  static void cpsw_ndo_tx_timeout(struct net_device *ndev)
  {
  	struct cpsw_priv *priv = netdev_priv(ndev);
@@ -670,6 +684,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
  	.ndo_start_xmit		= cpsw_ndo_start_xmit,
  	.ndo_change_rx_flags	= cpsw_ndo_change_rx_flags,
  	.ndo_validate_addr	= eth_validate_addr,
+	.ndo_do_ioctl		= cpsw_ndo_do_ioctl,
  	.ndo_change_mtu		= eth_change_mtu,
  	.ndo_tx_timeout		= cpsw_ndo_tx_timeout,
  	.ndo_get_stats		= cpsw_ndo_get_stats,
Already ndo_do_ioctl is already implemented. Can you rebase the patch 
with latest git repo
and resubmit the patch

Regards
Mugunthan V N

[PATCH 3/3] net: cpsw: implement ioctl for MII

From: jlu@pengutronix.de (Jan Lübbe)
Date: 2012-12-04 11:06:24

On Mon, 2012-12-03 at 22:34 +0530, Mugunthan V N wrote:
Already ndo_do_ioctl is already implemented. Can you rebase the patch 
with latest git repo
and resubmit the patch
Sorry, I should have checked that before. I'll update the other patches
and resubmit.
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help