Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1646759 > unrolled thread
| Started by | Jan Kiszka <jan.kiszka@siemens.com> |
|---|---|
| First post | 2017-05-22 13:20 +0200 |
| Last post | 2017-05-22 19:10 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka <jan.kiszka@siemens.com> - 2017-05-22 13:20 +0200
Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Joe Perches <joe@perches.com> - 2017-05-22 13:40 +0200
Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Jan Kiszka <jan.kiszka@siemens.com> - 2017-05-22 14:50 +0200
Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Joe Perches <joe@perches.com> - 2017-05-22 15:20 +0200
Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-05-22 19:10 +0200
| From | Jan Kiszka <jan.kiszka@siemens.com> |
|---|---|
| Date | 2017-05-22 13:20 +0200 |
| Subject | [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses |
| Message-ID | <tJTxx-50U-25@gated-at.bofh.it> |
Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 77 ++++++++++++++----------
1 file changed, 45 insertions(+), 32 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index ffa59b76e884..23ef235c6c0d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -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
--
2.12.0
[toc] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-05-22 13:40 +0200 |
| Subject | Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses |
| Message-ID | <tJTQS-56Q-11@gated-at.bofh.it> |
| In reply to | #1646759 |
On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
[]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
[]
> @@ -31,65 +31,78 @@
[]
> +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?
[toc] | [prev] | [next] | [standalone]
| From | Jan Kiszka <jan.kiszka@siemens.com> |
|---|---|
| Date | 2017-05-22 14:50 +0200 |
| Subject | Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses |
| Message-ID | <tJUWC-5LA-3@gated-at.bofh.it> |
| In reply to | #1646771 |
On 2017-05-22 13:33, Joe Perches wrote:
> On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
>> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> []
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> []
>> @@ -31,65 +31,78 @@
> []
>> +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
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2017-05-22 15:20 +0200 |
| Subject | Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses |
| Message-ID | <tJVpD-6c9-1@gated-at.bofh.it> |
| In reply to | #1646843 |
On Mon, 2017-05-22 at 14:49 +0200, Jan Kiszka wrote:
> On 2017-05-22 13:33, Joe Perches wrote:
> > On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
> > > Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> >
> > []
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> >
> > []
> > > @@ -31,65 +31,78 @@
> >
> > []
> > > +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).
Right. Apologies for noise.
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-05-22 19:10 +0200 |
| Subject | Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses |
| Message-ID | <tJZ0e-8sT-21@gated-at.bofh.it> |
| In reply to | #1646759 |
On Mon, May 22, 2017 at 2:12 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> struct stmmac_pci_dmi_data {
> - 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,
}
?
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web