Skip to contentSkip to conversation

stmmac: pci: Refactor DMI probing

PATCH Superseded Jan Kiszka 5 participants 13 messages May 22, 2017 – May 23, 2017

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover stmmac: pci: Refactor DMI probing

Some cleanups of the way we probe DMI platforms in the driver. Reduces a bit of open-coding and makes the logic easier reusable for any potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

Jan

Jan Kiszka (3):
stmmac: pci: Overcome stmmac_pci_info structure
stmmac: pci: Make stmmac_pci_find_phy_addr truly generic
stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 184 ++++++++++++-----------
 1 file changed, 99 insertions(+), 85 deletions(-)
Signature · 1 line
2.12.0
author
#1 lore raw

PATCH 1/3 stmmac: pci: Overcome stmmac_pci_info structure

First, pass the PCI device reference as function parameter. Then the setup function knows which stmmac_pci_dmi_data structure to use. Finally, we are left with a setup function in stmmac_pci_info and can convert the structure into a function pointer. By converting stmmac_default_data to that type, we can make a setup function mandatory, and probing becomes more regular.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 122 +++++++++++------------
 1 file changed, 59 insertions(+), 63 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +59 -63
index 22f910795be4..990a61acd70e 100644
@@ -37,18 +37,46 @@ struct stmmac_pci_dmi_data {
 	int phy_addr;
 };
 
-struct stmmac_pci_info {
-	struct pci_dev *pdev;
-	int (*setup)(struct plat_stmmacenet_data *plat,
-		     struct stmmac_pci_info *info);
-	struct stmmac_pci_dmi_data *dmi;
+typedef int (*stmmac_setup)(struct pci_dev *, struct plat_stmmacenet_data *);
+
+static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+	{
+		.name = "Galileo",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "GalileoGen2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-0YA2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-1YA2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "SIMATIC IOT2000",
+		.asset_tag = "6ES7647-0AA00-1YA2",
+		.func = 7,
+		.phy_addr = 1,
+	},
+	{}
 };
 
-static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
+static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
+				    struct stmmac_pci_dmi_data *dmi_data)
 {
 	const char *name = dmi_get_system_info(DMI_BOARD_NAME);
 	const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-	unsigned int func = PCI_FUNC(info->pdev->devfn);
+	unsigned int func = PCI_FUNC(pdev->devfn);
 	struct stmmac_pci_dmi_data *dmi;
 
 	/*
@@ -58,7 +86,7 @@ static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
 	if (!name)
 		return 1;
 
-	for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
+	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
 		if (!strcmp(dmi->name, name) && dmi->func == func) {
 			/* If asset tag is provided, match on it as well. */
 			if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
@@ -100,7 +128,8 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
 	plat->rx_queues_cfg[0].pkt_route = 0x0;
 }
 
-static void stmmac_default_data(struct plat_stmmacenet_data *plat)
+static int stmmac_default_setup(struct pci_dev *pdev,
+				struct plat_stmmacenet_data *plat)
 {
 	/* Set common default data first */
 	common_default_data(plat);
@@ -112,12 +141,13 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 	plat->dma_cfg->pbl = 32;
 	plat->dma_cfg->pblx8 = true;
 	/* TODO: AXI */
+
+	return 0;
 }
 
-static int quark_default_data(struct plat_stmmacenet_data *plat,
-			      struct stmmac_pci_info *info)
+static int quark_default_setup(struct pci_dev *pdev,
+			       struct plat_stmmacenet_data *plat)
 {
-	struct pci_dev *pdev = info->pdev;
 	int ret;
 
 	/* Set common default data first */
@@ -127,7 +157,7 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 	 * Refuse to load the driver and register net device if MAC controller
 	 * does not connect to any PHY interface.
 	 */
-	ret = stmmac_pci_find_phy_addr(info);
+	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
 	if (ret < 0)
 		return ret;
 
@@ -143,43 +173,6 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 	return 0;
 }
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
-	{
-		.name = "Galileo",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "GalileoGen2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 6,
-		.phy_addr = 1,
-	},
-	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 7,
-		.phy_addr = 1,
-	},
-	{}
-};
-
-static struct stmmac_pci_info quark_pci_info = {
-	.setup = quark_default_data,
-	.dmi = quark_pci_dmi_data,
-};
-
 /**
  * stmmac_pci_probe
  *
@@ -195,7 +188,7 @@ static struct stmmac_pci_info quark_pci_info = {
 static int stmmac_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id)
 {
-	struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
+	stmmac_setup setup = (stmmac_setup)id->driver_data;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_resources res;
 	int i;
@@ -236,15 +229,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	if (info) {
-		info->pdev = pdev;
-		if (info->setup) {
-			ret = info->setup(plat, info);
-			if (ret)
-				return ret;
-		}
-	} else
-		stmmac_default_data(plat);
+	ret = setup(pdev, plat);
+	if (ret)
+		return ret;
 
 	pci_enable_msi(pdev);
 
@@ -275,9 +262,18 @@ static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_suspend, stmmac_resume);
 #define STMMAC_DEVICE_ID 0x1108
 
 static const struct pci_device_id stmmac_id_table[] = {
-	{PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
-	{PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
-	{PCI_VDEVICE(INTEL, STMMAC_QUARK_ID), (kernel_ulong_t)&quark_pci_info},
+	{
+		PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID),
+		(kernel_ulong_t)&stmmac_default_setup,
+	},
+	{
+		PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC),
+		(kernel_ulong_t)&stmmac_default_setup,
+	},
+	{
+		PCI_VDEVICE(INTEL, STMMAC_QUARK_ID),
+		(kernel_ulong_t)&quark_default_setup,
+	},
 	{}
 };
 
Signature · 1 line
2.12.0
author
#4 lore raw

PATCH 2/3 stmmac: pci: Make stmmac_pci_find_phy_addr truly generic

In reply to Jan Kiszka

Move the special case for the early Galileo firmware into quark_default_setup. This allows to use stmmac_pci_find_phy_addr for non-quark cases.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +12 -7
index 990a61acd70e..ffa59b76e884 100644
@@ -79,12 +79,8 @@ static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
 	unsigned int func = PCI_FUNC(pdev->devfn);
 	struct stmmac_pci_dmi_data *dmi;
 
-	/*
-	 * Galileo boards with old firmware don't support DMI. We always return
-	 * 1 here, so at least first found MAC controller would be probed.
-	 */
 	if (!name)
-		return 1;
+		return -ENODEV;
 
 	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
 		if (!strcmp(dmi->name, name) && dmi->func == func) {
@@ -158,8 +154,17 @@ static int quark_default_setup(struct pci_dev *pdev,
 	 * does not connect to any PHY interface.
 	 */
 	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
-	if (ret < 0)
-		return ret;
+	if (ret < 0) {
+		/*
+		 * Galileo boards with old firmware don't support DMI. We always
+		 * use 1 here as PHY address, so at least the first found MAC
+		 * controller would be probed.
+		 */
+		if (!dmi_get_system_info(DMI_BOARD_NAME))
+			ret = 1;
+		else
+			return ret;
+	}
 
 	plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
 	plat->phy_addr = ret;
Signature · 1 line
2.12.0
author
#5 lore raw

PATCH 3/3 stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

In reply to Jan Kiszka

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 77 ++++++++++++++----------
 1 file changed, 45 insertions(+), 32 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +45 -32
index ffa59b76e884..23ef235c6c0d 100644
@@ -31,65 +31,78 @@
  * with PHY.
  */
 struct stmmac_pci_dmi_data {
-	const char *name;
-	const char *asset_tag;
-	unsigned int func;
+	int func;
 	int phy_addr;
 };
 
 typedef int (*stmmac_setup)(struct pci_dev *, struct plat_stmmacenet_data *);
 
-static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data[] = {
 	{
-		.name = "Galileo",
 		.func = 6,
 		.phy_addr = 1,
 	},
+	{-1, -1},
+};
+
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
 	{
-		.name = "GalileoGen2",
 		.func = 6,
 		.phy_addr = 1,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
+		.func = 7,
 		.phy_addr = 1,
 	},
+	{-1, -1},
+};
+
+static const struct dmi_system_id quark_pci_dmi[] = {
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 6,
-		.phy_addr = 1,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Galileo"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-1YA2",
-		.func = 7,
-		.phy_addr = 1,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-0YA2"),
+		},
+		.driver_data = (void *)galileo_stmmac_dmi_data,
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-1YA2"),
+		},
+		.driver_data = (void *)iot2040_stmmac_dmi_data,
 	},
 	{}
 };
 
 static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
-				    struct stmmac_pci_dmi_data *dmi_data)
+				    const struct dmi_system_id *dmi_list)
 {
-	const char *name = dmi_get_system_info(DMI_BOARD_NAME);
-	const char *asset_tag = dmi_get_system_info(DMI_BOARD_ASSET_TAG);
-	unsigned int func = PCI_FUNC(pdev->devfn);
-	struct stmmac_pci_dmi_data *dmi;
+	const struct stmmac_pci_dmi_data *dmi_data;
+	const struct dmi_system_id *dmi_id;
+	int func = PCI_FUNC(pdev->devfn);
 
-	if (!name)
+	dmi_id = dmi_first_match(dmi_list);
+	if (!dmi_id)
 		return -ENODEV;
 
-	for (dmi = dmi_data; dmi->name && *dmi->name; dmi++) {
-		if (!strcmp(dmi->name, name) && dmi->func == func) {
-			/* If asset tag is provided, match on it as well. */
-			if (dmi->asset_tag && strcmp(dmi->asset_tag, asset_tag))
-				continue;
-			return dmi->phy_addr;
-		}
-	}
+	for (dmi_data = dmi_id->driver_data; dmi_data->func >= 0; dmi_data++)
+		if (dmi_data->func == func)
+			return dmi_data->phy_addr;
 
 	return -ENODEV;
 }
@@ -153,7 +166,7 @@ static int quark_default_setup(struct pci_dev *pdev,
 	 * Refuse to load the driver and register net device if MAC controller
 	 * does not connect to any PHY interface.
 	 */
-	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi_data);
+	ret = stmmac_pci_find_phy_addr(pdev, quark_pci_dmi);
 	if (ret < 0) {
 		/*
 		 * Galileo boards with old firmware don't support DMI. We always
Signature · 1 line
2.12.0
#6 lore raw

Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0
@@ -31,65 +31,78 @@

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c line 54

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +2 -4
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
 	{
-		.name = "GalileoGen2",
 		.func = 6,
 		.phy_addr = 1,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
+		.func = 7,

Why change this from 6 to 7?

author
#7 lore raw

Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

Quoted 7 lines · Joe Perches
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0
@@ -31,65 +31,78 @@

[]

Quoted 14 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c line 54

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +2 -4
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
 	{
-		.name = "GalileoGen2",
 		.func = 6,
 		.phy_addr = 1,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
+		.func = 7,

Why change this from 6 to 7?

The diff is confusing here: If you look at the outcome, we now have galileo_stmmac_dmi_data with function 6 only (also used for the IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both MACs are wired up).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#8 lore raw

Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

Quoted 26 lines · Jan Kiszka
Quoted 10 lines · Joe Perches
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0

[]

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +0 -0
@@ -31,65 +31,78 @@

[]

Quoted 14 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c line 54

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +2 -4
+static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
 	{
-		.name = "GalileoGen2",
 		.func = 6,
 		.phy_addr = 1,
 	},
 	{
-		.name = "SIMATIC IOT2000",
-		.asset_tag = "6ES7647-0AA00-0YA2",
-		.func = 6,
+		.func = 7,

Why change this from 6 to 7?

Quoted 4 lines

The diff is confusing here: If you look at the outcome, we now have galileo_stmmac_dmi_data with function 6 only (also used for the IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both MACs are wired up).

Right. Apologies for noise.

maintainer
#10 lore raw
In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>
Date: Mon, 22 May 2017 13:12:06 +0200

Quoted 5 lines

Some cleanups of the way we probe DMI platforms in the driver. Reduces a bit of open-coding and makes the logic easier reusable for any potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

This doesn't compile:

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’) drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’) scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1

#9 lore raw

Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses

In reply to Jan Kiszka

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c line 36

Quoted 9 lines · Jan Kiszka

Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.

struct stmmac_pci_dmi_data {

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +1 -3
-       const char *name;
-       const char *asset_tag;
-       unsigned int func;
+       int func;
        int phy_addr;
 };

Perhaps

  struct stmmac_pci_dmi_data {
     unsigned int func;
     int phy_addr;

};

struct stmmac_pci_info {
struct stmmac_pci_dmi_data *data;
size_t nmaps;
(*setup)(struct plat_stmmacenet_data *plat, struct stmmac_pci_info *info);
};

static const struct stmmac_pci_dmi_data galileo_stmmac_dmi_data[] = {
        {
                 .func = 6,
                 .phy_addr = 1,
        },
};

static struct stmmac_pci_info galileo_pci_info = {
.map = galileo_stmmac_dmi_data,
.nmaps = ARRAY_SIZE(galileo_stmmac_dmi_data), .setup = quark_default_setup,
}

?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#11 lore raw
In reply to David Miller
Quoted 11 lines · David Miller

From: Jan Kiszka <[email protected]>
Date: Mon, 22 May 2017 13:12:06 +0200

Quoted 5 lines

Some cleanups of the way we probe DMI platforms in the driver. Reduces a bit of open-coding and makes the logic easier reusable for any potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

This doesn't compile:

Quoted 11 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’) drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’) scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1

Hmm. Which arch is this?

Jan

#2 lore raw

Re: [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure

In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

First, pass the PCI device reference as function parameter. Then the setup function knows which stmmac_pci_dmi_data structure to use. Finally, we are left with a setup function in stmmac_pci_info and can convert the structure into a function pointer. By converting stmmac_default_data to that type, we can make a setup function mandatory, and probing becomes more regular.

I don't see any good reason for this patch. Besides that it will not compile (as David noticed already).

Can we modify structures with less intrusion?
I'm pretty sure we can convert (if you wish, however I would leave it for now, there is no issue with current approach) with as twice less lines.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#12 lore raw
In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>
Date: Mon, 22 May 2017 19:06:07 +0200

Quoted 24 lines · David Miller
Quoted 11 lines

From: Jan Kiszka <[email protected]>
Date: Mon, 22 May 2017 13:12:06 +0200

Quoted 5 lines

Some cleanups of the way we probe DMI platforms in the driver. Reduces a bit of open-coding and makes the logic easier reusable for any potential DMI platform != Quark.

Tested on IOT2000 and Galileo Gen2.

This doesn't compile:

Quoted 11 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:285:3: note: (near initialization for ‘stmmac_id_table[0].class’) drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:289:3: note: (near initialization for ‘stmmac_id_table[1].class’) scripts/Makefile.build:302: recipe for target 'drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o' failed make[5]: *** [drivers/net/ethernet/stmicro/stmmac/stmmac_pci.o] Error 1

Quoted 1 line

Hmm. Which arch is this?

x86_64, allmodconfig

#3 lore raw

Re: [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure

In reply to Jan Kiszka
url: https://github.com/0day-ci/linux/commits/Jan-Kiszka/stmmac-pci-Refactor-DMI-probing/20170523-165305 config: x86_64-allmodconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0…

Hi Jan,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.12-rc2 next-20170523]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Jan-Kiszka/stmmac-pci-Refactor-DMI-probing/20170523-165305
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: error: initializer element is not computable at load time
      (kernel_ulong_t)&stmmac_default_setup,
      ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: note: (near initialization for 'stmmac_id_table[0].class')
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: error: initializer element is not computable at load time
      (kernel_ulong_t)&stmmac_default_setup,
      ^

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: note: (near initialization for 'stmmac_id_table[1].class')

vim +267 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

261 #define STMMAC_QUARK_ID 0x0937
262 #define STMMAC_DEVICE_ID 0x1108
263
264 static const struct pci_device_id stmmac_id_table[] = {
265 {
266 PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID),

 > 267			(kernel_ulong_t)&stmmac_default_setup,

268 },
269 {
270 PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC),

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation