diff mbox

[Xenial] UBUNTU: SAUCE: mwifiex: Use PCI ID instead of DMI ID to identify Edge Gateways

Message ID 1478689435-25553-1-git-send-email-jesse.sung@canonical.com
State New
Headers show

Commit Message

Wen-chien Jesse Sung Nov. 9, 2016, 11:03 a.m. UTC
From: Wen-chien Jesse Sung <jesse.sung@canonical.com>

BugLink: https://launchpad.net/bugs/1640418

The DMI ID string may be changed in some models. Use PCI ID as an
indentification instead.

Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
---
 drivers/net/wireless/mwifiex/pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Brad Figg Nov. 9, 2016, 1:15 p.m. UTC | #1

Seth Forshee Nov. 9, 2016, 1:34 p.m. UTC | #2
On Wed, Nov 09, 2016 at 07:03:55PM +0800, jesse.sung@canonical.com wrote:
> From: Wen-chien Jesse Sung <jesse.sung@canonical.com>
> 
> BugLink: https://launchpad.net/bugs/1640418
> 
> The DMI ID string may be changed in some models. Use PCI ID as an
> indentification instead.
> 
> Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
> ---
>  drivers/net/wireless/mwifiex/pcie.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
> index 0dbb528..644e28f7 100644
> --- a/drivers/net/wireless/mwifiex/pcie.c
> +++ b/drivers/net/wireless/mwifiex/pcie.c
> @@ -219,8 +219,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
>  	}
>  
>  	priv = mwifiex_get_priv(card->adapter, MWIFIEX_BSS_ROLE_STA);
> -	if (dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5000") ||
> -		dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5100"))
> +	if (pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0720, NULL) ||
> +		pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0733, NULL))
>  		priv->is_edge_gateway = true;
>  	return 0;
>  }

pci_get_subsys() increments the device refcount, so don't you have a
resource leak here?
Seth Forshee Nov. 9, 2016, 1:45 p.m. UTC | #3
On Wed, Nov 09, 2016 at 07:34:04AM -0600, Seth Forshee wrote:
> On Wed, Nov 09, 2016 at 07:03:55PM +0800, jesse.sung@canonical.com wrote:
> > From: Wen-chien Jesse Sung <jesse.sung@canonical.com>
> > 
> > BugLink: https://launchpad.net/bugs/1640418
> > 
> > The DMI ID string may be changed in some models. Use PCI ID as an
> > indentification instead.
> > 
> > Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>
> > ---
> >  drivers/net/wireless/mwifiex/pcie.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
> > index 0dbb528..644e28f7 100644
> > --- a/drivers/net/wireless/mwifiex/pcie.c
> > +++ b/drivers/net/wireless/mwifiex/pcie.c
> > @@ -219,8 +219,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
> >  	}
> >  
> >  	priv = mwifiex_get_priv(card->adapter, MWIFIEX_BSS_ROLE_STA);
> > -	if (dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5000") ||
> > -		dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5100"))
> > +	if (pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0720, NULL) ||
> > +		pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0733, NULL))
> >  		priv->is_edge_gateway = true;
> >  	return 0;
> >  }
> 
> pci_get_subsys() increments the device refcount, so don't you have a
> resource leak here?

You have a pointer to the pci_dev, can't you just check the ids there?
I.e.:

  if (pdev->subsystem_vendor == 0x1028 &&
      (pdev->subsystem_device == 0x0720 || pdev->subsystem_device == 0x0733))

Would that work?
diff mbox

Patch

diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 0dbb528..644e28f7 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -219,8 +219,8 @@  static int mwifiex_pcie_probe(struct pci_dev *pdev,
 	}
 
 	priv = mwifiex_get_priv(card->adapter, MWIFIEX_BSS_ROLE_STA);
-	if (dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5000") ||
-		dmi_match(DMI_PRODUCT_NAME, "Edge Gateway 5100"))
+	if (pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0720, NULL) ||
+		pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, 0x1028, 0x0733, NULL))
 		priv->is_edge_gateway = true;
 	return 0;
 }