kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Kulikov Vasiliy <segooon@gmail.com>
Cc: kernel-janitors@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Alan Cox <alan@linux.intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rakib Mullick <rakib.mullick@gmail.com>,
	Ben Hutchings <ben@decadent.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/18] char: moxa: call disable_pci_device() if
Date: Sat, 07 Aug 2010 07:22:05 +0000	[thread overview]
Message-ID: <20100807072205.GW9031@bicker> (raw)
In-Reply-To: <1281124152-12630-1-git-send-email-segooon@gmail.com>

On Fri, Aug 06, 2010 at 11:49:10PM +0400, Kulikov Vasiliy wrote:
> Driver should call disable_pci_device() if it returns from pci_probe()
> with error. Also it must not be called if pci_request_region() fails as
> it means that somebody uses device resources and rules the device.
> 

I think we should disable it actually.  The comments on
pci_enable_device() and pci_disable_device() say that only the first and
last callers actually enable and disable it.  The others just increment
or decrement a counter.

regards,
dan carpenter

> Move pci_enable_device() after checking moxa_boards[] to remove senseless
> pci_enable_device()/pci_disable_device().
> 
> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
> ---
>  drivers/char/moxa.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
> index 107b0bd..0ea5aeb 100644
> --- a/drivers/char/moxa.c
> +++ b/drivers/char/moxa.c
> @@ -939,11 +939,6 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
>  	int board_type = ent->driver_data;
>  	int retval;
>  
> -	retval = pci_enable_device(pdev);
> -	if (retval) {
> -		dev_err(&pdev->dev, "can't enable pci device\n");
> -		goto err;
> -	}
>  
>  	for (i = 0; i < MAX_BOARDS; i++)
>  		if (moxa_boards[i].basemem = NULL)
> @@ -956,6 +951,12 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
>  		goto err;
>  	}
>  
> +	retval = pci_enable_device(pdev);
> +	if (retval) {
> +		dev_err(&pdev->dev, "can't enable pci device\n");
> +		goto err;
> +	}
> +
>  	board = &moxa_boards[i];
>  
>  	retval = pci_request_region(pdev, 2, "moxa-base");
> @@ -1001,6 +1002,7 @@ err_base:
>  	board->basemem = NULL;
>  err_reg:
>  	pci_release_region(pdev, 2);
> +	pci_disable_device(pdev);
>  err:
>  	return retval;
>  }
> -- 
> 1.7.0.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-08-07  7:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06 19:49 [PATCH 01/18] char: moxa: call disable_pci_device() if pci_probe() failed Kulikov Vasiliy
2010-08-07  7:22 ` Dan Carpenter [this message]
2010-08-07  8:55   ` [PATCH 01/18] char: moxa: call disable_pci_device() if Vasiliy Kulikov
2010-08-07  9:58     ` Dan Carpenter
2010-08-07 18:02       ` Vasiliy Kulikov
2010-08-07 19:08         ` Dan Carpenter

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=20100807072205.GW9031@bicker \
    --to=error27@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@linux.intel.com \
    --cc=ben@decadent.org.uk \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rakib.mullick@gmail.com \
    --cc=segooon@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).