All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	netdev@vger.kernel.org,
	Kweh Hock Leong <hock.leong.kweh@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Vince Bridgers <vbridgers2013@gmail.com>
Subject: Re: [PATCH 2/5] stmmac: pci: use managed resources
Date: Wed, 22 Oct 2014 11:36:33 +0300	[thread overview]
Message-ID: <1413966993.2396.26.camel@linux.intel.com> (raw)
In-Reply-To: <5446C827.2040801@cogentembedded.com>

On Wed, 2014-10-22 at 00:55 +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 10/21/2014 08:35 PM, Andy Shevchenko wrote:
> 
> > Migrate pci driver to managed resources to reduce boilerplate error handling
> > code.
> 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 46 +++++-------------------
> >   1 file changed, 8 insertions(+), 38 deletions(-)
> 
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > index 5459a4e..f8d4ce2 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > @@ -65,45 +65,29 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
> >   			    const struct pci_device_id *id)
> >   {
> >   	int ret = 0;
> > -	void __iomem *addr = NULL;
> >   	struct stmmac_priv *priv = NULL;
> > -	int i;
> > +	int pci_bar = 0;
> 
>     I don't see this variable changing anywhere...

See my comment below.

> 
> >   	/* Enable pci device */
> > -	ret = pci_enable_device(pdev);
> > +	ret = pcim_enable_device(pdev);
> >   	if (ret) {
> >   		pr_err("%s : ERROR: failed to enable %s device\n", __func__,
> >   		       pci_name(pdev));
> >   		return ret;
> >   	}
> > -	if (pci_request_regions(pdev, STMMAC_RESOURCE_NAME)) {
> > -		pr_err("%s: ERROR: failed to get PCI region\n", __func__);
> > -		ret = -ENODEV;
> > -		goto err_out_req_reg_failed;
> > -	}
> > +	ret = pcim_iomap_regions(pdev, BIT(pci_bar), pci_name(pdev));
> > +	if (ret)
> > +		return ret;
> >
> > -	/* Get the base address of device */
> > -	for (i = 0; i <= 5; i++) {
> > -		if (pci_resource_len(pdev, i) == 0)
> > -			continue;
> > -		addr = pci_iomap(pdev, i, 0);
> > -		if (addr == NULL) {
> > -			pr_err("%s: ERROR: cannot map register memory aborting",
> > -			       __func__);
> > -			ret = -EIO;
> > -			goto err_out_map_failed;
> > -		}
> > -		break;
> > -	}
> 
>     It's not an equivalent change: the old code mapped a first existing BAR, 
> you always map BAR0. Are you sure that's what you meant? If so, wouldn't hurt 
> to describe this in the changelog...

So, I was trying to find any specification on public regarding to boards
that have this IP, no luck so far. I guess that that code was created
due to XILINX FPGA usage which probably can provide any BAR user wants
to. Thus, I imply that in real applications the BAR most probably will
be 0. However, I left variable which can be overridden in future
(regarding to PCI ID).

It would be nice to hear someone from ST about this. Giuseppe?


-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy

  reply	other threads:[~2014-10-22  8:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 16:35 [PATCH 0/5] stmmac: pci: various cleanups and fixes Andy Shevchenko
2014-10-21 16:35 ` [PATCH 1/5] stmmac: pci: convert to use dev_pm_ops Andy Shevchenko
2014-10-21 16:35 ` [PATCH 2/5] stmmac: pci: use managed resources Andy Shevchenko
2014-10-21 20:55   ` Sergei Shtylyov
2014-10-22  8:36     ` Andy Shevchenko [this message]
2014-10-27 15:28       ` Giuseppe CAVALLARO
2014-10-30  8:05         ` Andy Shevchenko
2014-11-12  5:14           ` Rayagond Kokatanur
2014-11-12  9:28             ` Andy Shevchenko
2014-10-21 16:35 ` [PATCH 3/5] stmmac: pci: convert to use dev_* macros Andy Shevchenko
2014-10-21 16:35 ` [PATCH 4/5] stmmac: pci: set default filter bins Andy Shevchenko
2014-10-21 16:35 ` [PATCH 5/5] stmmac: pci: remove FSF address Andy Shevchenko
2014-10-30  8:13 ` [PATCH 0/5] stmmac: pci: various cleanups and fixes Giuseppe CAVALLARO
2014-10-30  9:41   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413966993.2396.26.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=hock.leong.kweh@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=vbridgers2013@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.