diff mbox

[03/10] net: stmmac: Use platform data tied with compatible strings

Message ID 1386350983-13281-4-git-send-email-wens@csie.org (mailing list archive)
State New, archived
Headers show

Commit Message

Chen-Yu Tsai Dec. 6, 2013, 5:29 p.m. UTC
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

Comments

David Miller Dec. 6, 2013, 9:26 p.m. UTC | #1
From: Chen-Yu Tsai <wens@csie.org>
Date: Sat,  7 Dec 2013 01:29:36 +0800

> +	device = of_match_device(stmmac_dt_ids, &pdev->dev);
> +	if (!device)
> +		return -ENODEV;
> +
> +	if (device->data)
> +	    memcpy(plat, device->data, sizeof(*plat));
> +

Don't invent your own indentation using spaces, this memcpy()
call is not indented properly, it should be two TABs.
Chen-Yu Tsai Dec. 7, 2013, 2:13 a.m. UTC | #2
On Sat, Dec 7, 2013 at 5:26 AM, David Miller <davem@davemloft.net> wrote:
> From: Chen-Yu Tsai <wens@csie.org>
> Date: Sat,  7 Dec 2013 01:29:36 +0800
>
>> +     device = of_match_device(stmmac_dt_ids, &pdev->dev);
>> +     if (!device)
>> +             return -ENODEV;
>> +
>> +     if (device->data)
>> +         memcpy(plat, device->data, sizeof(*plat));
>> +
>
> Don't invent your own indentation using spaces, this memcpy()
> call is not indented properly, it should be two TABs.

Noted. Will fix.
diff mbox

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 74c7aef..df3fd1c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -26,8 +26,19 @@ 
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/of_device.h>
 #include "stmmac.h"
 
+static const struct of_device_id stmmac_dt_ids[] = {
+	{ .compatible = "st,spear600-gmac"},
+	{ .compatible = "snps,dwmac-3.610"},
+	{ .compatible = "snps,dwmac-3.70a"},
+	{ .compatible = "snps,dwmac-3.710"},
+	{ .compatible = "snps,dwmac"},
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
+
 #ifdef CONFIG_OF
 static int stmmac_probe_config_dt(struct platform_device *pdev,
 				  struct plat_stmmacenet_data *plat,
@@ -35,10 +46,18 @@  static int stmmac_probe_config_dt(struct platform_device *pdev,
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct stmmac_dma_cfg *dma_cfg;
+	const struct of_device_id *device;
 
 	if (!np)
 		return -ENODEV;
 
+	device = of_match_device(stmmac_dt_ids, &pdev->dev);
+	if (!device)
+		return -ENODEV;
+
+	if (device->data)
+	    memcpy(plat, device->data, sizeof(*plat));
+
 	*mac = of_get_mac_address(np);
 	plat->interface = of_get_phy_mode(np);
 
@@ -257,16 +276,6 @@  static const struct dev_pm_ops stmmac_pltfr_pm_ops = {
 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
 #endif /* CONFIG_PM */
 
-static const struct of_device_id stmmac_dt_ids[] = {
-	{ .compatible = "st,spear600-gmac"},
-	{ .compatible = "snps,dwmac-3.610"},
-	{ .compatible = "snps,dwmac-3.70a"},
-	{ .compatible = "snps,dwmac-3.710"},
-	{ .compatible = "snps,dwmac"},
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
-
 struct platform_driver stmmac_pltfr_driver = {
 	.probe = stmmac_pltfr_probe,
 	.remove = stmmac_pltfr_remove,