All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH] drivers/char/mxser.c : change pci_find_device by
Date: Wed, 17 May 2006 00:17:41 +0000	[thread overview]
Message-ID: <20060517001741.GB6355@kroah.com> (raw)
In-Reply-To: <446A5865.8040403@yahoo.fr>

[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]

On Wed, May 17, 2006 at 12:55:33AM +0200, trem wrote:
> From: trem <tremyfr@yahoo.fr>
> 
> This patch simply change pci_find_device by pci_get_device, because
> pci_find_device is deprecated. pci_dev_put has been added to decrement
> the counter, so unload could be done.
> 
> Signed-Off-By: trem <tremyfr@yahoo.fr>
> ---
> 

> diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
> index 0fb2fb9..82ccc31 100644
> --- a/drivers/char/mxser.c
> +++ b/drivers/char/mxser.c
> @@ -817,7 +817,7 @@ static int mxser_init(void)
>  	index = 0;
>  	b = 0;
>  	while (b < n) {
> -		pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev);
> +		pdev = pci_get_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev);
>  			if (pdev == NULL) {
>  			b++;
>  			continue;
> @@ -832,6 +832,7 @@ static int mxser_init(void)
>  		} else {
>  			if (pci_enable_device(pdev)) {
>  				printk(KERN_ERR "Moxa SmartI/O PCI enable fail !\n");
> +				pci_dev_put(pdev);

No, you double decrement this, not good.

>  				continue;
>  			}
>  			retval = mxser_get_PCI_conf(busnum, devnum, (int) mxser_pcibrds[b].driver_data, &hwconf);
> @@ -844,15 +845,19 @@ static int mxser_init(void)
>  					printk(KERN_ERR "Invalid interrupt vector,board not configured\n");
>  				else if (retval == MXSER_ERR_IOADDR)
>  					printk(KERN_ERR "Invalid I/O address,board not configured\n");
> +				pci_dev_put(pdev);
>  				continue;
>  			}
>  			mxser_getcfg(m, &hwconf);
>  			//init mxsercfg first, or mxsercfg data is not correct on ISR.
>  			//mxser_initbrd will hook ISR.
> -			if (mxser_initbrd(m, &hwconf) < 0)
> +			if (mxser_initbrd(m, &hwconf) < 0) {
> +				pci_dev_put(pdev);
>  				continue;
> +			}
>  			m++;
>  		}
> +		pci_dev_put(pdev);

Again, double decrement, which is a bug.

Please read the documentation for how pci_get_device() works before
sending further patches.

thanks,

greg k-h

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

      reply	other threads:[~2006-05-17  0:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-16 22:55 [KJ] [PATCH] drivers/char/mxser.c : change pci_find_device by trem
2006-05-17  0:17 ` Greg KH [this message]

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=20060517001741.GB6355@kroah.com \
    --to=greg@kroah.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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.