From: Greg KH Date: Wed, 17 May 2006 00:17:41 +0000 Subject: Re: [KJ] [PATCH] drivers/char/mxser.c : change pci_find_device by Message-Id: <20060517001741.GB6355@kroah.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============5806693927485207==" List-Id: References: <446A5865.8040403@yahoo.fr> In-Reply-To: <446A5865.8040403@yahoo.fr> To: kernel-janitors@vger.kernel.org --===============5806693927485207== Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 17, 2006 at 12:55:33AM +0200, trem wrote: > From: trem > > 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 > --- > > 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 --===============5806693927485207== Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline _______________________________________________ Kernel-janitors mailing list Kernel-janitors@lists.osdl.org https://lists.osdl.org/mailman/listinfo/kernel-janitors --===============5806693927485207==--